23#include <osl/diagnose.h>
26#include <sqlbison.hxx>
30#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
31#include <com/sun/star/sdbc/ResultSetType.hpp>
32#include <com/sun/star/sdbc/FetchDirection.hpp>
33#include <com/sun/star/lang/DisposedException.hpp>
58 ,m_xDBMetaData(_pConnection->getMetaData())
60 ,m_aSQLIterator( _pConnection, _pConnection->createCatalog()->getTables(), m_aParser )
61 ,m_pConnection(_pConnection)
62 ,m_pParseTree(nullptr)
67 ,m_nResultSetType(ResultSetType::FORWARD_ONLY)
68 ,m_nFetchDirection(FetchDirection::FORWARD)
69 ,m_nResultSetConcurrency(ResultSetConcurrency::UPDATABLE)
70 ,m_bEscapeProcessing(true)
72 sal_Int32 nAttrib = 0;
94 SAL_INFO(
"connectivity.drivers",
"file Ocke.Janssen@sun.com OStatement_Base::disposeResultSet" );
135 OStatement_BASE::acquire();
140 OStatement_BASE::release();
145 const Any aRet = OStatement_BASE::queryInterface(rType);
155 return ::comphelper::concatSequences(
aTypes.getTypes(),OStatement_BASE::getTypes());
166 ::osl::MutexGuard aGuard(
m_aMutex );
174 SAL_INFO(
"connectivity.drivers",
"file Ocke.Janssen@sun.com OStatement_Base::clearMyResultSet " );
175 ::osl::MutexGuard aGuard(
m_aMutex );
186 catch(
const DisposedException& ) { }
194 ::osl::MutexGuard aGuard(
m_aMutex );
202 ::osl::MutexGuard aGuard(
m_aMutex );
212 return new ::cppu::OPropertyArrayHelper(aProps);
241 ::osl::MutexGuard aGuard(
m_aMutex );
251 ::osl::MutexGuard aGuard(
m_aMutex );
273 ::osl::MutexGuard aGuard(
m_aMutex );
282 return pResult->getRowCountResult();
293 OStatement_BASE::disposing();
298 return ::cppu::OPropertySetHelper::createPropertySetInfo(
getInfoHelper());
309 OSL_ENSURE(
m_pSQLAnalyzer,
"OResultSet::analyzeSQL: Analyzer isn't set!");
319 OSL_ENSURE(
SQL_ISRULE(pOrderingSpecCommalist,ordering_spec_commalist),
"OResultSet: Error in Parse Tree");
321 for (
size_t m = 0;
m < pOrderingSpecCommalist->
count();
m++)
324 OSL_ENSURE(
SQL_ISRULE(pOrderingSpec,ordering_spec),
"OResultSet: Error in Parse Tree");
325 OSL_ENSURE(pOrderingSpec->
count() == 2,
"OResultSet: Error in Parse Tree");
330 throw SQLException();
340 OUString aColumnName;
341 if (pColumnRef->
count() == 1)
343 else if (pColumnRef->
count() == 3)
349 throw SQLException();
359 OSQLColumns::const_iterator aFind = ::connectivity::find(aSelectColumns->begin(),aSelectColumns->end(),aColumnName,aCase);
360 if ( aFind == aSelectColumns->end() )
361 throw SQLException();
373 throw SQLException(aErr,*
this,OUString(),0,
Any());
382 m_pConnection->throwGenericSQLException(STR_QUERY_NO_TABLE,*
this);
386 m_pConnection->throwGenericSQLException(STR_QUERY_MORE_TABLES,*
this);
390 m_pConnection->throwGenericSQLException(STR_QUERY_NO_COLUMN,*
this);
397 m_pConnection->throwGenericSQLException(STR_QUERY_TOO_COMPLEX,*
this);
402 m_pConnection->throwGenericSQLException(STR_QUERY_TOO_COMPLEX, *
this);
412 OSL_ENSURE(
m_pTable.is(),
"No table!");
418 (*m_aRow)[0]->setBound(
true);
424 (*m_aEvaluateRow)[0]->setBound(
true);
493 std::vector<OUString> aColumnNameList;
498 OSL_ENSURE(pOptColumnCommalist !=
nullptr,
"OResultSet: Error in Parse Tree");
499 OSL_ENSURE(
SQL_ISRULE(pOptColumnCommalist,opt_column_commalist),
"OResultSet: Error in Parse Tree");
500 if (pOptColumnCommalist->
count() == 0)
503 aColumnNameList.insert(aColumnNameList.end(), aNames.begin(), aNames.end());
507 OSL_ENSURE(pOptColumnCommalist->
count() == 3,
"OResultSet: Error in Parse Tree");
510 OSL_ENSURE(pColumnCommalist !=
nullptr,
"OResultSet: Error in Parse Tree");
511 OSL_ENSURE(
SQL_ISRULE(pColumnCommalist,column_commalist),
"OResultSet: Error in Parse Tree");
512 OSL_ENSURE(pColumnCommalist->
count() > 0,
"OResultSet: Error in Parse Tree");
515 for (
size_t i = 0;
i < pColumnCommalist->
count();
i++)
518 OSL_ENSURE(pCol !=
nullptr,
"OResultSet: Error in Parse Tree");
522 if ( aColumnNameList.empty() )
527 OSL_ENSURE(pValuesOrQuerySpec !=
nullptr,
"OResultSet: pValuesOrQuerySpec must not be NULL!");
528 OSL_ENSURE(
SQL_ISRULE(pValuesOrQuerySpec,values_or_query_spec),
"OResultSet: ! SQL_ISRULE(pValuesOrQuerySpec,values_or_query_spec)");
529 OSL_ENSURE(pValuesOrQuerySpec->
count() > 0,
"OResultSet: pValuesOrQuerySpec->count() <= 0");
535 OSL_ENSURE(pValuesOrQuerySpec->
count() == 4,
"OResultSet: pValuesOrQuerySpec->count() != 4");
539 OSL_ENSURE(pInsertAtomCommalist !=
nullptr,
"OResultSet: pInsertAtomCommalist must not be NULL!");
540 OSL_ENSURE(pInsertAtomCommalist->
count() > 0,
"OResultSet: pInsertAtomCommalist <= 0");
543 for (
size_t i = 0;
i < pInsertAtomCommalist->
count();
i++)
546 OSL_ENSURE(pRow_Value_Const !=
nullptr,
"OResultSet: pRow_Value_Const must not be NULL!");
551 else if(pRow_Value_Const->
isToken())
555 if(pRow_Value_Const->
count() == aColumnNameList.size())
557 for (
size_t j = 0; j < pRow_Value_Const->
count(); ++j)
579 OSL_ENSURE(pAssignmentCommalist !=
nullptr,
"OResultSet: pAssignmentCommalist == NULL");
580 OSL_ENSURE(
SQL_ISRULE(pAssignmentCommalist,assignment_commalist),
"OResultSet: Error in Parse Tree");
581 OSL_ENSURE(pAssignmentCommalist->
count() > 0,
"OResultSet: pAssignmentCommalist->count() <= 0");
584 std::vector< OUString> aList(1);
585 for (
size_t i = 0;
i < pAssignmentCommalist->
count();
i++)
588 OSL_ENSURE(pAssignment !=
nullptr,
"OResultSet: pAssignment == NULL");
590 OSL_ENSURE(pAssignment->
count() == 3,
"OResultSet: pAssignment->count() != 3");
593 OSL_ENSURE(pCol !=
nullptr,
"OResultSet: pCol == NULL");
596 OSL_ENSURE(pComp !=
nullptr,
"OResultSet: pComp == NULL");
604 OSL_ENSURE(pVal !=
nullptr,
"OResultSet: pVal == NULL");
614 OSL_ENSURE(
o3tl::make_unsigned(
nIndex) <= aColumnNameList.size(),
"SdbFileCursor::ParseAssignValues: nIndex > aColumnNameList.GetTokenCount()");
615 OUString aColumnName(aColumnNameList[
nIndex]);
616 OSL_ENSURE(aColumnName.getLength() > 0,
"OResultSet: Column-Name not found");
617 OSL_ENSURE(pRow_Value_Constructor_Elem !=
nullptr,
"OResultSet: pRow_Value_Constructor_Elem must not be NULL!");
631 else if (
SQL_ISRULE(pRow_Value_Constructor_Elem,parameter))
640 const OUString& aValue,
642 sal_uInt32 nParameter)
659 (*m_aAssignValues)[
nId]->setNull();
666 case DataType::VARCHAR:
667 case DataType::LONGVARCHAR:
673 if (aValue.equalsIgnoreAsciiCase(
"TRUE") || aValue[0] ==
'1')
674 *(*m_aAssignValues)[
nId] =
true;
675 else if (aValue.equalsIgnoreAsciiCase(
"FALSE") || aValue[0] ==
'0')
676 *(*m_aAssignValues)[
nId] =
false;
680 case DataType::TINYINT:
681 case DataType::SMALLINT:
682 case DataType::INTEGER:
683 case DataType::DECIMAL:
684 case DataType::NUMERIC:
686 case DataType::DOUBLE:
689 case DataType::TIMESTAMP:
::boost::spirit::classic::rule< ScannerT > assignment
::cppu::IPropertyArrayHelper * getArrayHelper()
void describeProperties(css::uno::Sequence< css::beans::Property > &_rProps) const
void registerProperty(const OUString &_rName, sal_Int32 _nHandle, sal_Int32 _nAttributes, void *_pPointerToMember, const css::uno::Type &_rMemberType)
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
void parseNodeToStr(OUString &rString, const css::uno::Reference< css::sdbc::XConnection > &_rxConnection, const IParseContext *pContext=nullptr, bool _bIntl=false, bool _bQuote=true) const
const OUString & getTokenValue() const
OSQLParseNode * getChild(sal_uInt32 nPos) const
SQLNodeType getNodeType() const
const ::rtl::Reference< OSQLColumns > & getSelectColumns() const
const OSQLTables & getTables() const
void setParseTree(const OSQLParseNode *pNewParseTree)
const OSQLParseNode * getOrderTree() const
const OSQLParseNode * getParseTree() const
OSQLStatementType getStatementType() const
void traverseAll()
traverses the complete statement tree, and fills all our data with the information obatined during tr...
std::unique_ptr< OSQLParseNode > parseTree(OUString &rErrorMessage, const OUString &rStatement, bool bInternational=false)
void setBindingRow(const OValueRefRow &_aRow)
void setSelectRow(const OValueRefRow &_rRow)
void setAssignValues(const ORefAssignValues &_aAssignValues)
void setSqlAnalyzer(OSQLAnalyzer *_pSQLAnalyzer)
void setColumnMapping(std::vector< sal_Int32 > &&_aColumnMapping)
static void setBoundedColumns(const OValueRefRow &_rRow, const OValueRefRow &_rSelectRow, const ::rtl::Reference< connectivity::OSQLColumns > &_rxColumns, const css::uno::Reference< css::container::XIndexAccess > &_xNames, bool _bSetColumnMapping, const css::uno::Reference< css::sdbc::XDatabaseMetaData > &_xMetaData, std::vector< sal_Int32 > &_rColMapping)
void setEvaluationRow(const OValueRefRow &_aRow)
void setOrderByAscending(std::vector< TAscendingOrder > &&_aOrderbyAsc)
void setOrderByColumns(std::vector< sal_Int32 > &&_aColumnOrderBy)
virtual void SAL_CALL disposing() override
virtual void SAL_CALL release() noexcept override
std::unique_ptr< OSQLAnalyzer > m_pSQLAnalyzer
virtual void SAL_CALL disposing() override
OValueRefRow m_aSelectRow
void ParseAssignValues(const std::vector< OUString > &aColumnNameList, connectivity::OSQLParseNode *pRow_Value_Constructor_Elem, sal_Int32 nIndex)
std::vector< sal_Int32 > m_aColMapping
virtual void parseParamterElem(const OUString &_sColumnName, OSQLParseNode *pRow_Value_Constructor_Elem)
connectivity::OSQLParseTreeIterator m_aSQLIterator
css::uno::Reference< css::container::XNameAccess > m_xColNames
css::sdbc::SQLWarning m_aLastWarning
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
void createColumnMapping()
virtual void SAL_CALL clearWarnings() override
virtual void construct(const OUString &sql)
OStatement_Base(OConnection *_pConnection)
connectivity::OSQLParseNode * m_pParseTree
virtual void initializeResultSet(OResultSet *_pResult)
sal_Int32 m_nResultSetConcurrency
std::vector< sal_Int32 > m_aOrderbyColumnNumber
void setOrderbyColumn(connectivity::OSQLParseNode const *pColumnRef, connectivity::OSQLParseNode const *pAscendingDescending)
rtl::Reference< OConnection > m_pConnection
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
virtual ::cppu::IPropertyArrayHelper * createArrayHelper() const override
sal_Int32 m_nFetchDirection
rtl::Reference< OFileTable > m_pTable
connectivity::OSQLParser m_aParser
sal_Int32 m_nResultSetType
css::uno::WeakReference< css::sdbc::XResultSet > m_xResultSet
ORefAssignValues m_aAssignValues
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
sal_Int32 m_nMaxFieldSize
virtual ::cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper() override
std::vector< TAscendingOrder > m_aOrderbyAscending
sal_Int32 m_nQueryTimeOut
std::vector< sal_Int32 > m_aParameterIndexes
css::uno::Reference< css::sdbc::XDatabaseMetaData > m_xDBMetaData
virtual ~OStatement_Base() override
virtual css::uno::Any SAL_CALL getWarnings() override
virtual void SAL_CALL cancel() override
virtual void SAL_CALL close() override
OConnection * getOwnConnection() const
virtual void SAL_CALL acquire() noexcept override
void SetAssignValue(const OUString &aColumnName, const OUString &aValue, bool bSetNull=false, sal_uInt32 nParameter=SQL_NO_PARAMETER)
OValueRefRow m_aEvaluateRow
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnection() override
virtual void SAL_CALL release() noexcept override
virtual sal_Int32 SAL_CALL executeUpdate(const OUString &sql) override
virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL executeQuery(const OUString &sql) override
virtual sal_Bool SAL_CALL execute(const OUString &sql) override
virtual void SAL_CALL acquire() noexcept override
virtual rtl::Reference< OResultSet > createResultSet() override
mutable::osl::Mutex m_aMutex
virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const &rType) SAL_OVERRIDE
#define SAL_INFO(area, stream)
Reference< XComponentContext > getComponentContext(Reference< XMultiServiceFactory > const &factory)
IMPLEMENT_SERVICE_INFO(OStatement,"com.sun.star.sdbc.driver.file.Statement","com.sun.star.sdbc.Statement")
::cppu::WeakComponentImplHelper< css::sdbc::XWarningsSupplier, css::util::XCancellable, css::sdbc::XCloseable > OStatement_BASE
std::map< OUString, OSQLTable, comphelper::UStringMixLess > OSQLTables
void checkDisposed(bool _bThrow)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
#define PROPERTY_ID_RESULTSETTYPE
#define PROPERTY_ID_QUERYTIMEOUT
#define PROPERTY_ID_CURSORNAME
#define PROPERTY_ID_RESULTSETCONCURRENCY
#define PROPERTY_ID_MAXFIELDSIZE
#define PROPERTY_ID_FETCHSIZE
#define PROPERTY_ID_MAXROWS
#define PROPERTY_ID_ESCAPEPROCESSING
#define PROPERTY_ID_FETCHDIRECTION
#define SQL_ISRULE(pParseNode, eRule)
#define SQL_ISTOKEN(pParseNode, token)
TSetBound is a functor to set the bound value with e.q. for_each call.