diff options
author | Thorsten Behrens <tbehrens@novell.com> | 2011-04-28 00:12:58 +0200 |
---|---|---|
committer | Thorsten Behrens <tbehrens@novell.com> | 2011-04-28 00:12:58 +0200 |
commit | f51c3f66b1034c9f15171678d1239c25d64341ba (patch) | |
tree | 438eb4b3d4da31d276dcb227da6afce76e165f00 /connectivity/source | |
parent | b8502c8251b0760f1bf03c968974f1fe3f288ae2 (diff) | |
parent | 86e7ed8c72184b7a04b836848743979aa3f5fd3d (diff) |
Merge commit 'ooo/DEV300_m106' into integration/dev300_m106
Conflicts:
avmedia/source/gstreamer/gstframegrabber.cxx
avmedia/source/gstreamer/gstplayer.cxx
avmedia/source/gstreamer/gstplayer.hxx
basic/inc/basic/sbxdef.hxx
basic/source/classes/sbxmod.cxx
basic/source/comp/makefile.mk
basic/source/comp/sbcomp.cxx
basic/source/inc/namecont.hxx
basic/source/inc/scriptcont.hxx
basic/source/runtime/methods.cxx
basic/source/runtime/runtime.cxx
basic/source/runtime/stdobj.cxx
basic/source/runtime/step1.cxx
basic/source/uno/namecont.cxx
basic/util/makefile.mk
connectivity/source/commontools/predicateinput.cxx
connectivity/source/drivers/dbase/DNoException.cxx
connectivity/source/drivers/dbase/DTable.cxx
connectivity/source/drivers/file/fcomp.cxx
connectivity/source/drivers/jdbc/JConnection.cxx
connectivity/source/drivers/odbcbase/OResultSet.cxx
connectivity/source/drivers/odbcbase/OStatement.cxx
connectivity/source/parse/sqlnode.cxx
desktop/source/app/app.cxx
drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx
drawinglayer/source/processor2d/vclprocessor2d.cxx
formula/inc/formula/token.hxx
formula/source/core/api/token.cxx
fpicker/source/win32/filepicker/VistaFilePickerImpl.hxx
fpicker/source/win32/filepicker/platform_vista.h
framework/source/helper/persistentwindowstate.cxx
framework/source/uielement/menubarmanager.cxx
oovbaapi/ooo/vba/XFoundFiles.idl
oovbaapi/ooo/vba/excel/XApplication.idl
oovbaapi/ooo/vba/msforms/XCheckBox.idl
oovbaapi/ooo/vba/msforms/XComboBox.idl
oovbaapi/ooo/vba/msforms/XControl.idl
oovbaapi/ooo/vba/msforms/XGroupBox.idl
oovbaapi/ooo/vba/msforms/XLabel.idl
oovbaapi/ooo/vba/msforms/XListBox.idl
oovbaapi/ooo/vba/msforms/XNewFont.idl
oovbaapi/ooo/vba/msforms/XRadioButton.idl
oovbaapi/ooo/vba/msforms/XTextBox.idl
oovbaapi/ooo/vba/msforms/XToggleButton.idl
scripting/source/dlgprov/dlgevtatt.cxx
sfx2/source/control/unoctitm.cxx
sfx2/source/doc/objstor.cxx
sfx2/source/doc/objxtor.cxx
svx/inc/svx/svdograf.hxx
svx/source/form/fmpage.cxx
svx/source/form/fmpgeimp.cxx
svx/source/svdraw/svdedtv.cxx
svx/source/svdraw/svdfmtf.cxx
svx/source/svdraw/svdograf.cxx
svx/source/svdraw/svdouno.cxx
svx/source/xml/xmlgrhlp.cxx
uui/source/iahndl-ssl.cxx
vbahelper/Library_msforms.mk
vbahelper/Library_vbahelper.mk
vbahelper/inc/vbahelper/vbahelper.hxx
vbahelper/prj/build.lst
vbahelper/source/msforms/vbacombobox.cxx
vbahelper/source/msforms/vbacontrol.cxx
vbahelper/source/msforms/vbacontrols.cxx
vbahelper/source/msforms/vbaframe.cxx
vbahelper/source/msforms/vbaframe.hxx
vbahelper/source/msforms/vbalabel.cxx
vbahelper/source/msforms/vbalabel.hxx
vbahelper/source/msforms/vbalistbox.cxx
vbahelper/source/msforms/vbalistbox.hxx
vbahelper/source/msforms/vbamultipage.cxx
vbahelper/source/msforms/vbatogglebutton.cxx
vbahelper/source/msforms/vbauserform.cxx
vbahelper/source/vbahelper/vbacommandbar.cxx
vbahelper/source/vbahelper/vbacommandbarcontrol.cxx
vbahelper/source/vbahelper/vbacommandbarcontrols.hxx
vbahelper/source/vbahelper/vbahelper.cxx
vbahelper/source/vbahelper/vbawindowbase.cxx
xmloff/source/meta/xmlmetai.cxx
xmloff/source/style/PageMasterExportPropMapper.cxx
xmloff/source/style/PageMasterStyleMap.cxx
xmloff/source/text/txtexppr.cxx
xmloff/source/text/txtprmap.cxx
Diffstat (limited to 'connectivity/source')
28 files changed, 773 insertions, 128 deletions
diff --git a/connectivity/source/commontools/FValue.cxx b/connectivity/source/commontools/FValue.cxx index 797cad9de343..0a8b5bd1b972 100644 --- a/connectivity/source/commontools/FValue.cxx +++ b/connectivity/source/commontools/FValue.cxx @@ -788,12 +788,30 @@ sal_Bool operator==(const DateTime& _rLH,const DateTime& _rRH) bool ORowSetValue::operator==(const ORowSetValue& _rRH) const { - if(m_eTypeKind != _rRH.m_eTypeKind) - return false; - if ( m_bSigned != _rRH.m_bSigned ) - return false; - if(m_bNull != _rRH.isNull()) + if ( m_eTypeKind != _rRH.m_eTypeKind ) + { + switch(m_eTypeKind) + { + case DataType::FLOAT: + case DataType::DOUBLE: + case DataType::REAL: + return getDouble() == _rRH.getDouble(); + default: + switch(_rRH.m_eTypeKind) + { + case DataType::FLOAT: + case DataType::DOUBLE: + case DataType::REAL: + return getDouble() == _rRH.getDouble(); + default: + break; + } + break; + } return false; + } + if ( m_bNull != _rRH.isNull() ) + return false; if(m_bNull && _rRH.isNull()) return true; @@ -803,16 +821,28 @@ bool ORowSetValue::operator==(const ORowSetValue& _rRH) const { case DataType::VARCHAR: case DataType::CHAR: - case DataType::DECIMAL: - case DataType::NUMERIC: case DataType::LONGVARCHAR: { ::rtl::OUString aVal1(m_aValue.m_pString); ::rtl::OUString aVal2(_rRH.m_aValue.m_pString); - bRet = aVal1 == aVal2; - break; + return aVal1 == aVal2; } + default: + if ( m_bSigned != _rRH.m_bSigned ) + return false; + break; + } + switch(m_eTypeKind) + { + case DataType::DECIMAL: + case DataType::NUMERIC: + { + ::rtl::OUString aVal1(m_aValue.m_pString); + ::rtl::OUString aVal2(_rRH.m_aValue.m_pString); + bRet = aVal1 == aVal2; + } + break; case DataType::FLOAT: bRet = *(float*)m_aValue.m_pValue == *(float*)_rRH.m_aValue.m_pValue; break; diff --git a/connectivity/source/commontools/predicateinput.cxx b/connectivity/source/commontools/predicateinput.cxx index b53be005a019..06c743d65561 100644 --- a/connectivity/source/commontools/predicateinput.cxx +++ b/connectivity/source/commontools/predicateinput.cxx @@ -32,8 +32,10 @@ #include <comphelper/types.hxx> #include <connectivity/dbtools.hxx> #include <com/sun/star/sdbc/DataType.hpp> +#include <com/sun/star/sdbc/ColumnValue.hpp> #include <osl/diagnose.h> #include <connectivity/sqlnode.hxx> +#include <connectivity/PColumn.hxx> #include <comphelper/numbers.hxx> //......................................................................... @@ -326,63 +328,116 @@ namespace dbtools ::rtl::OUString sError; OSQLParseNode* pParseNode = implPredicateTree( sError, sValue, _rxField ); - if ( _pErrorMessage ) *_pErrorMessage = sError; + if ( _pErrorMessage ) + *_pErrorMessage = sError; - if ( pParseNode ) + sReturn = implParseNode(pParseNode,_bForStatementUse); + } + + return sReturn; + } + + ::rtl::OUString OPredicateInputController::getPredicateValue( + const ::rtl::OUString& _sField, const ::rtl::OUString& _rPredicateValue, sal_Bool _bForStatementUse, ::rtl::OUString* _pErrorMessage ) const + { + ::rtl::OUString sReturn = _rPredicateValue; + ::rtl::OUString sError; + ::rtl::OUString sField = _sField; + sal_Int32 nIndex = 0; + sField = sField.getToken(0,'(',nIndex); + if(nIndex == -1) + sField = _sField; + sal_Int32 nType = ::connectivity::OSQLParser::getFunctionReturnType(sField,&m_aParser.getContext()); + if ( nType == DataType::OTHER || !sField.getLength() ) + { + // first try the international version + ::rtl::OUString sSql; + sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SELECT * ")); + sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" FROM x WHERE ")); + sSql += sField; + sSql += _rPredicateValue; + ::std::auto_ptr<OSQLParseNode> pParseNode( const_cast< OSQLParser& >( m_aParser ).parseTree( sError, sSql, sal_True ) ); + nType = DataType::DOUBLE; + if ( pParseNode.get() ) { - OSQLParseNode* pOdbcSpec = pParseNode->getByRule( OSQLParseNode::odbc_fct_spec ); - if ( pOdbcSpec ) + OSQLParseNode* pColumnRef = pParseNode->getByRule(OSQLParseNode::column_ref); + if ( pColumnRef ) { - if ( !_bForStatementUse ) - { - if ( ( pOdbcSpec->count() >= 2 ) - && ( SQL_NODE_STRING == pOdbcSpec->getChild(1)->getNodeType() ) - ) - { + } + } + } - sReturn = pOdbcSpec->getChild(1)->getTokenValue(); - } - else - OSL_FAIL( "OPredicateInputController::getPredicateValue: unknown/invalid structure (odbc + param use)!" ); - } - else - { - OSQLParseNode* pFuncSpecParent = pOdbcSpec->getParent(); - OSL_ENSURE( pFuncSpecParent, "OPredicateInputController::getPredicateValue: an ODBC func spec node without parent?" ); - if ( pFuncSpecParent ) - pFuncSpecParent->parseNodeToStr( - sReturn, m_xConnection, &m_aParser.getContext(), sal_False, sal_True - ); - } + Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData(); + parse::OParseColumn* pColumn = new parse::OParseColumn( sField, + ::rtl::OUString(), + ::rtl::OUString(), + ::rtl::OUString(), + ColumnValue::NULLABLE_UNKNOWN, + 0, + 0, + nType, + sal_False, + sal_False, + xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers()); + Reference<XPropertySet> xColumn = pColumn; + pColumn->setFunction(sal_True); + pColumn->setRealName(sField); + + OSQLParseNode* pParseNode = implPredicateTree( sError, _rPredicateValue, xColumn ); + if ( _pErrorMessage ) + *_pErrorMessage = sError; + return pParseNode ? implParseNode(pParseNode,_bForStatementUse) : sReturn; + } + + ::rtl::OUString OPredicateInputController::implParseNode(OSQLParseNode* pParseNode,sal_Bool _bForStatementUse) const + { + ::rtl::OUString sReturn; + if ( pParseNode ) + { + ::std::auto_ptr<OSQLParseNode> pTemp(pParseNode); + OSQLParseNode* pOdbcSpec = pParseNode->getByRule( OSQLParseNode::odbc_fct_spec ); + if ( pOdbcSpec ) + { + if ( _bForStatementUse ) + { + OSQLParseNode* pFuncSpecParent = pOdbcSpec->getParent(); + OSL_ENSURE( pFuncSpecParent, "OPredicateInputController::getPredicateValue: an ODBC func spec node without parent?" ); + if ( pFuncSpecParent ) + pFuncSpecParent->parseNodeToStr(sReturn, m_xConnection, &m_aParser.getContext(), sal_False, sal_True); } else { - if ( pParseNode->count() >= 3 ) + OSQLParseNode* pValueNode = pOdbcSpec->getChild(1); + if ( SQL_NODE_STRING == pValueNode->getNodeType() ) + sReturn = pValueNode->getTokenValue(); + else + pValueNode->parseNodeToStr(sReturn, m_xConnection, &m_aParser.getContext(), sal_False, sal_True); + } + } + else + { + if ( pParseNode->count() >= 3 ) + { + OSQLParseNode* pValueNode = pParseNode->getChild(2); + OSL_ENSURE( pValueNode, "OPredicateInputController::getPredicateValue: invalid node child!" ); + if ( !_bForStatementUse ) { - OSQLParseNode* pValueNode = pParseNode->getChild(2); - OSL_ENSURE( pValueNode, "OPredicateInputController::getPredicateValue: invalid node child!" ); - if ( !_bForStatementUse ) - { - if ( SQL_NODE_STRING == pValueNode->getNodeType() ) - sReturn = pValueNode->getTokenValue(); - else - pValueNode->parseNodeToStr( - sReturn, m_xConnection, &m_aParser.getContext(), sal_False, sal_True - ); - } + if ( SQL_NODE_STRING == pValueNode->getNodeType() ) + sReturn = pValueNode->getTokenValue(); else pValueNode->parseNodeToStr( sReturn, m_xConnection, &m_aParser.getContext(), sal_False, sal_True ); } else - OSL_FAIL( "OPredicateInputController::getPredicateValue: unknown/invalid structure (noodbc)!" ); + pValueNode->parseNodeToStr( + sReturn, m_xConnection, &m_aParser.getContext(), sal_False, sal_True + ); } - - delete pParseNode; + else + OSL_FAIL( "OPredicateInputController::getPredicateValue: unknown/invalid structure (noodbc)!" ); } } - return sReturn; } //......................................................................... diff --git a/connectivity/source/drivers/ado/AColumn.cxx b/connectivity/source/drivers/ado/AColumn.cxx index 7ac506d99cae..8d0a3347bdd3 100644 --- a/connectivity/source/drivers/ado/AColumn.cxx +++ b/connectivity/source/drivers/ado/AColumn.cxx @@ -168,7 +168,8 @@ void OAdoColumn::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& r { sal_Int32 nVal=0; rValue >>= nVal; - m_aColumn.put_NumericScale((sal_Int8)nVal); + if ( !m_IsCurrency ) + m_aColumn.put_NumericScale((sal_Int8)nVal); } break; case PROPERTY_ID_ISNULLABLE: @@ -215,6 +216,8 @@ void OAdoColumn::fillPropertyValues() DataTypeEnum eType = m_aColumn.get_Type(); m_IsCurrency = (eType == adCurrency); + if ( m_IsCurrency && !m_Scale) + m_Scale = 4; m_Type = ADOS::MapADOType2Jdbc(eType); sal_Bool bForceTo = sal_True; diff --git a/connectivity/source/drivers/ado/AConnection.cxx b/connectivity/source/drivers/ado/AConnection.cxx index 200884e4de98..0ab23e892db1 100644 --- a/connectivity/source/drivers/ado/AConnection.cxx +++ b/connectivity/source/drivers/ado/AConnection.cxx @@ -469,6 +469,11 @@ void OConnection::buildTypeInfo() throw( SQLException) aInfo->aSimpleType.aLocalTypeName = ADOS::getField(pRecordset,nPos++).get_Value(); aInfo->aSimpleType.nMinimumScale = ADOS::getField(pRecordset,nPos++).get_Value(); aInfo->aSimpleType.nMaximumScale = ADOS::getField(pRecordset,nPos++).get_Value(); + if ( adCurrency == aInfo->eType && !aInfo->aSimpleType.nMaximumScale) + { + aInfo->aSimpleType.nMinimumScale = 4; + aInfo->aSimpleType.nMaximumScale = 4; + } aInfo->aSimpleType.nNumPrecRadix = ADOS::getField(pRecordset,nPos++).get_Value(); // Now that we have the type info, save it // in the Hashtable if we don't already have an diff --git a/connectivity/source/drivers/ado/AResultSet.cxx b/connectivity/source/drivers/ado/AResultSet.cxx index e8c7a41cd0bc..42c32e577158 100644 --- a/connectivity/source/drivers/ado/AResultSet.cxx +++ b/connectivity/source/drivers/ado/AResultSet.cxx @@ -401,7 +401,7 @@ void SAL_CALL OResultSet::beforeFirst( ) throw(SQLException, RuntimeException) if(first()) - previous(); + m_bOnFirstAfterOpen = !previous(); } // ------------------------------------------------------------------------- void SAL_CALL OResultSet::afterLast( ) throw(SQLException, RuntimeException) diff --git a/connectivity/source/drivers/ado/ado.xcu b/connectivity/source/drivers/ado/ado.xcu index e95e1a676c12..58bfcf8975a9 100644 --- a/connectivity/source/drivers/ado/ado.xcu +++ b/connectivity/source/drivers/ado/ado.xcu @@ -117,6 +117,11 @@ <value>true</value> </prop> </node> + <node oor:name="RespectDriverResultSetType" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:boolean"> + <value>true</value> + </prop> + </node> </node> <node oor:name="MetaData"> <node oor:name="SupportsTableCreation" oor:op="replace"> diff --git a/connectivity/source/drivers/dbase/DNoException.cxx b/connectivity/source/drivers/dbase/DNoException.cxx index b130547e9265..357b2baad44a 100644 --- a/connectivity/source/drivers/dbase/DNoException.cxx +++ b/connectivity/source/drivers/dbase/DNoException.cxx @@ -225,7 +225,7 @@ void ODbaseTable::AllocBuffer() } // If no buffer available: allocate - if (m_pBuffer == NULL && nSize) + if (m_pBuffer == NULL && nSize > 0) { m_nBufferSize = nSize; m_pBuffer = new sal_uInt8[m_nBufferSize+1]; @@ -484,11 +484,14 @@ SvStream& connectivity::dbase::operator << (SvStream &rStream, const ONDXPage& r sal_uIntPtr nTell = rStream.Tell() % 512; sal_uInt16 nBufferSize = rStream.GetBufferSize(); sal_uIntPtr nSize = nBufferSize - nTell; - char* pEmptyData = new char[nSize]; - memset(pEmptyData,0x00,nSize); - rStream.Write((sal_uInt8*)pEmptyData,nSize); - rStream.Seek(nTell); - delete [] pEmptyData; + if ( nSize <= nBufferSize ) + { + char* pEmptyData = new char[nSize]; + memset(pEmptyData,0x00,nSize); + rStream.Write((sal_uInt8*)pEmptyData,nSize); + rStream.Seek(nTell); + delete [] pEmptyData; + } } return rStream; } diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx index 5630800b47f2..e17c2ee59bc3 100644 --- a/connectivity/source/drivers/dbase/DTable.cxx +++ b/connectivity/source/drivers/dbase/DTable.cxx @@ -2775,7 +2775,7 @@ void ODbaseTable::AllocBuffer() } // if there is no buffer available: allocate: - if (m_pBuffer == NULL && nSize) + if (m_pBuffer == NULL && nSize > 0) { m_nBufferSize = nSize; m_pBuffer = new sal_uInt8[m_nBufferSize+1]; diff --git a/connectivity/source/drivers/dbase/dindexnode.cxx b/connectivity/source/drivers/dbase/dindexnode.cxx index 590eb5b46fae..b2fea12ab294 100644 --- a/connectivity/source/drivers/dbase/dindexnode.cxx +++ b/connectivity/source/drivers/dbase/dindexnode.cxx @@ -883,11 +883,14 @@ SvStream& connectivity::dbase::operator << (SvStream &rStream, const ONDXPage& r sal_uIntPtr nTell = rStream.Tell() % PAGE_SIZE; sal_uInt16 nBufferSize = rStream.GetBufferSize(); sal_uIntPtr nRemainSize = nBufferSize - nTell; - char* pEmptyData = new char[nRemainSize]; - memset(pEmptyData,0x00,nRemainSize); - rStream.Write((sal_uInt8*)pEmptyData,nRemainSize); - rStream.Seek(nTell); - delete [] pEmptyData; + if ( nRemainSize <= nBufferSize ) + { + char* pEmptyData = new char[nRemainSize]; + memset(pEmptyData,0x00,nRemainSize); + rStream.Write((sal_uInt8*)pEmptyData,nRemainSize); + rStream.Seek(nTell); + delete [] pEmptyData; + } } return rStream; } diff --git a/connectivity/source/drivers/file/fcomp.cxx b/connectivity/source/drivers/file/fcomp.cxx index bd920d356034..903fecd21524 100644 --- a/connectivity/source/drivers/file/fcomp.cxx +++ b/connectivity/source/drivers/file/fcomp.cxx @@ -97,7 +97,7 @@ void OPredicateCompiler::start(OSQLParseNode* pSQLParseNode) OSQLParseNode * pTableExp = pSQLParseNode->getChild(3); DBG_ASSERT(pTableExp != NULL,"Fehler im Parse Tree"); DBG_ASSERT(SQL_ISRULE(pTableExp,table_exp)," Fehler im Parse Tree"); - DBG_ASSERT(pTableExp->count() == 5,"Fehler im Parse Tree"); + DBG_ASSERT(pTableExp->count() == TABLE_EXPRESSION_CHILD_COUNT,"Fehler im Parse Tree"); // check that we don't use anything other than count(*) as function OSQLParseNode* pSelection = pSQLParseNode->getChild(2); @@ -115,7 +115,7 @@ void OPredicateCompiler::start(OSQLParseNode* pSQLParseNode) pWhereClause = pTableExp->getChild(1); - pOrderbyClause = pTableExp->getChild(4); + pOrderbyClause = pTableExp->getChild(ORDER_BY_CHILD_POS); (void)pOrderbyClause; } else if (SQL_ISRULE(pSQLParseNode,update_statement_searched)) @@ -295,10 +295,19 @@ OOperand* OPredicateCompiler::execute_LIKE(OSQLParseNode* pPredicateNode) throw( OSQLParseNode* pAtom = pPart2->getChild(pPart2->count()-2); OSQLParseNode* pOptEscape = pPart2->getChild(pPart2->count()-1); - if (!(pAtom->getNodeType() == SQL_NODE_STRING || SQL_ISRULE(pAtom,parameter))) + if (!(pAtom->getNodeType() == SQL_NODE_STRING || + SQL_ISRULE(pAtom,parameter) || + // odbc date + SQL_ISRULE(pAtom,set_fct_spec) || + SQL_ISRULE(pAtom,position_exp) || + SQL_ISRULE(pAtom,char_substring_fct) || + // upper, lower etc. + SQL_ISRULE(pAtom,fold)) ) { - m_pAnalyzer->getConnection()->throwGenericSQLException(STR_QUERY_INVALID_LIKE_STRING,NULL); + m_pAnalyzer->getConnection()->throwGenericSQLException(STR_QUERY_TOO_COMPLEX,NULL); + return NULL; } + if (pOptEscape->count() != 0) { if (pOptEscape->count() != 2) diff --git a/connectivity/source/drivers/flat/ETable.cxx b/connectivity/source/drivers/flat/ETable.cxx index c4638889d15e..584838ad6446 100644 --- a/connectivity/source/drivers/flat/ETable.cxx +++ b/connectivity/source/drivers/flat/ETable.cxx @@ -160,7 +160,7 @@ void OFlatTable::fillColumns(const ::com::sun::star::lang::Locale& _aLocale) } ++nRowCount; } - while(nRowCount < nMaxRowsToScan && m_pFileStream->ReadByteStringLine(aFirstLine,nEncoding)); + while(nRowCount < nMaxRowsToScan && m_pFileStream->ReadByteStringLine(aFirstLine,nEncoding) && !m_pFileStream->IsEof()); for (xub_StrLen i = 0; i < nFieldCount; i++) { @@ -495,7 +495,8 @@ String OFlatTable::getEntry() // name and extension have to coincide if ( m_pConnection->matchesExtension( sExt ) ) { - sName = sName.replaceAt(sName.getLength()-(sExt.getLength()+1),sExt.getLength()+1,::rtl::OUString()); + if ( sExt.getLength() ) + sName = sName.replaceAt(sName.getLength()-(sExt.getLength()+1),sExt.getLength()+1,::rtl::OUString()); if ( sName == m_Name ) { Reference< XContentAccess > xContentAccess( xDir, UNO_QUERY ); diff --git a/connectivity/source/drivers/hsqldb/HDriver.cxx b/connectivity/source/drivers/hsqldb/HDriver.cxx index 622ba2c5a7d8..fcb3408a3c52 100644 --- a/connectivity/source/drivers/hsqldb/HDriver.cxx +++ b/connectivity/source/drivers/hsqldb/HDriver.cxx @@ -44,6 +44,7 @@ #include <com/sun/star/embed/XStorage.hpp> #include <com/sun/star/frame/XDesktop.hpp> #include <com/sun/star/lang/Locale.hpp> +#include <com/sun/star/util/XFlushable.hpp> #include "HTerminateListener.hxx" #include "hsqldb/HCatalog.hxx" #include "diagnose_ex.h" @@ -73,6 +74,7 @@ namespace connectivity using namespace ::com::sun::star::embed; using namespace ::com::sun::star::io; using namespace ::com::sun::star::task; + using namespace ::com::sun::star::util; using namespace ::com::sun::star::reflection; namespace hsqldb @@ -619,6 +621,22 @@ namespace connectivity m_bInShutDownConnections = sal_True; } //------------------------------------------------------------------ + void ODriverDelegator::flushConnections() + { + TWeakPairVector::iterator aEnd = m_aConnections.end(); + for (TWeakPairVector::iterator i = m_aConnections.begin(); aEnd != i; ++i) + { + try + { + Reference<XFlushable> xCon(i->second.second.first.get(),UNO_QUERY); + xCon->flush(); + } + catch(Exception&) + { + } + } + } + //------------------------------------------------------------------ void SAL_CALL ODriverDelegator::preCommit( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) { ::osl::MutexGuard aGuard(m_aMutex); diff --git a/connectivity/source/drivers/hsqldb/HTerminateListener.cxx b/connectivity/source/drivers/hsqldb/HTerminateListener.cxx index 070d5e8be5cb..739132cf9035 100644 --- a/connectivity/source/drivers/hsqldb/HTerminateListener.cxx +++ b/connectivity/source/drivers/hsqldb/HTerminateListener.cxx @@ -52,6 +52,7 @@ throw( RuntimeException ) void SAL_CALL OConnectionController::queryTermination( const EventObject& /*aEvent*/ ) throw( TerminationVetoException, RuntimeException ) { + m_pDriver->flushConnections(); } void SAL_CALL OConnectionController::notifyTermination( const EventObject& /*aEvent*/ ) diff --git a/connectivity/source/drivers/jdbc/JConnection.cxx b/connectivity/source/drivers/jdbc/JConnection.cxx index 90209d8c528b..14cb26fa9f95 100644 --- a/connectivity/source/drivers/jdbc/JConnection.cxx +++ b/connectivity/source/drivers/jdbc/JConnection.cxx @@ -823,7 +823,7 @@ sal_Bool java_sql_Connection::construct(const ::rtl::OUString& url, static const char * cSignature = "(Ljava/lang/String;Ljava/util/Properties;)Ljava/sql/Connection;"; static const char * cMethodName = "connect"; // Java-Call - static jmethodID mID = NULL; + jmethodID mID = NULL; if ( !mID ) mID = t.pEnv->GetMethodID( m_Driver_theClass, cMethodName, cSignature ); if ( mID ) diff --git a/connectivity/source/drivers/jdbc/jdbc.xcu b/connectivity/source/drivers/jdbc/jdbc.xcu index f4f599a701d9..2afaa54a9e90 100644 --- a/connectivity/source/drivers/jdbc/jdbc.xcu +++ b/connectivity/source/drivers/jdbc/jdbc.xcu @@ -147,6 +147,11 @@ <value>true</value> </prop> </node> + <node oor:name="RespectDriverResultSetType" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:boolean"> + <value>true</value> + </prop> + </node> </node> <node oor:name="MetaData"> <node oor:name="SupportsTableCreation" oor:op="replace"> diff --git a/connectivity/source/drivers/jdbc/tools.cxx b/connectivity/source/drivers/jdbc/tools.cxx index 2faf420524ad..b2841391eec9 100644 --- a/connectivity/source/drivers/jdbc/tools.cxx +++ b/connectivity/source/drivers/jdbc/tools.cxx @@ -152,6 +152,7 @@ java_util_Properties* connectivity::createStringPropertyArray(const Sequence< Pr && pBegin->Name.compareToAscii( "Authentication" ) && pBegin->Name.compareToAscii( "PreferDosLikeLineEnds" ) && pBegin->Name.compareToAscii( "PrimaryKeySupport" ) + && pBegin->Name.compareToAscii( "RespectDriverResultSetType" ) ) { ::rtl::OUString aStr; diff --git a/connectivity/source/drivers/macab/MacabRecord.cxx b/connectivity/source/drivers/macab/MacabRecord.cxx index d3521663e9e1..b3be998aa6fa 100644 --- a/connectivity/source/drivers/macab/MacabRecord.cxx +++ b/connectivity/source/drivers/macab/MacabRecord.cxx @@ -203,7 +203,7 @@ sal_Int32 MacabRecord::compareFields(const macabfield *_field1, const macabfield result = CFStringCompare( (CFStringRef) _field1->value, (CFStringRef) _field2->value, - 0); // 0 = no options (like ignore case) + kCFCompareLocalized); // Specifies that the comparison should take into account differences related to locale, such as the thousands separator character. break; case kABDateProperty: diff --git a/connectivity/source/drivers/odbc/odbc.xcu b/connectivity/source/drivers/odbc/odbc.xcu index 74ba8815d021..c0d3939aa0e0 100644 --- a/connectivity/source/drivers/odbc/odbc.xcu +++ b/connectivity/source/drivers/odbc/odbc.xcu @@ -152,6 +152,11 @@ <value>true</value> </prop> </node> + <node oor:name="RespectDriverResultSetType" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:boolean"> + <value>true</value> + </prop> + </node> </node> <node oor:name="MetaData"> <node oor:name="SupportsTableCreation" oor:op="replace"> diff --git a/connectivity/source/drivers/odbcbase/ODatabaseMetaDataResultSet.cxx b/connectivity/source/drivers/odbcbase/ODatabaseMetaDataResultSet.cxx index 55f7548d5f70..6df4f2c0275a 100644 --- a/connectivity/source/drivers/odbcbase/ODatabaseMetaDataResultSet.cxx +++ b/connectivity/source/drivers/odbcbase/ODatabaseMetaDataResultSet.cxx @@ -979,7 +979,8 @@ void ODatabaseMetaDataResultSet::openColumnPrivileges( const Any& catalog, cons m_bFreeHandle = sal_True; ::rtl::OString aPKQ,aPKO,aPKN,aCOL; - aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding); + if ( catalog.hasValue() ) + aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding); aPKO = ::rtl::OUStringToOString(schema,m_nTextEncoding); aPKN = ::rtl::OUStringToOString(table,m_nTextEncoding); aCOL = ::rtl::OUStringToOString(columnNamePattern,m_nTextEncoding); @@ -1013,7 +1014,8 @@ void ODatabaseMetaDataResultSet::openColumns( const Any& catalog, m_bFreeHandle = sal_True; ::rtl::OString aPKQ,aPKO,aPKN,aCOL; - aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding); + if ( catalog.hasValue() ) + aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding); aPKO = ::rtl::OUStringToOString(schemaPattern,m_nTextEncoding); aPKN = ::rtl::OUStringToOString(tableNamePattern,m_nTextEncoding); aCOL = ::rtl::OUStringToOString(columnNamePattern,m_nTextEncoding); @@ -1081,7 +1083,8 @@ void ODatabaseMetaDataResultSet::openProcedureColumns( const Any& catalog, m_bFreeHandle = sal_True; ::rtl::OString aPKQ,aPKO,aPKN,aCOL; - aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding); + if ( catalog.hasValue() ) + aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding); aPKO = ::rtl::OUStringToOString(schemaPattern,m_nTextEncoding); aPKN = ::rtl::OUStringToOString(procedureNamePattern,m_nTextEncoding); aCOL = ::rtl::OUStringToOString(columnNamePattern,m_nTextEncoding); @@ -1116,7 +1119,8 @@ void ODatabaseMetaDataResultSet::openProcedures(const Any& catalog, const ::rtl: m_bFreeHandle = sal_True; ::rtl::OString aPKQ,aPKO,aPKN,aCOL; - aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding); + if ( catalog.hasValue() ) + aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding); aPKO = ::rtl::OUStringToOString(schemaPattern,m_nTextEncoding); aPKN = ::rtl::OUStringToOString(procedureNamePattern,m_nTextEncoding); @@ -1146,6 +1150,7 @@ void ODatabaseMetaDataResultSet::openSpecialColumns(sal_Bool _bRowVer,const Any& m_bFreeHandle = sal_True; ::rtl::OString aPKQ,aPKO,aPKN,aCOL; + if ( catalog.hasValue() ) aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding); aPKO = ::rtl::OUStringToOString(schema,m_nTextEncoding); aPKN = ::rtl::OUStringToOString(table,m_nTextEncoding); @@ -1236,7 +1241,8 @@ void ODatabaseMetaDataResultSet::openPrimaryKeys(const Any& catalog, const ::rtl m_bFreeHandle = sal_True; ::rtl::OString aPKQ,aPKO,aPKN,aCOL; - aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding); + if ( catalog.hasValue() ) + aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding); aPKO = ::rtl::OUStringToOString(schema,m_nTextEncoding); const char *pPKQ = catalog.hasValue() && aPKQ.getLength() ? aPKQ.getStr() : NULL, @@ -1265,7 +1271,8 @@ void ODatabaseMetaDataResultSet::openTablePrivileges(const Any& catalog, const : m_bFreeHandle = sal_True; ::rtl::OString aPKQ,aPKO,aPKN; - aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding); + if ( catalog.hasValue() ) + aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding); aPKO = ::rtl::OUStringToOString(schemaPattern,m_nTextEncoding); const char *pPKQ = catalog.hasValue() && aPKQ.getLength() ? aPKQ.getStr() : NULL, @@ -1295,7 +1302,8 @@ void ODatabaseMetaDataResultSet::openIndexInfo( const Any& catalog, const ::rtl: m_bFreeHandle = sal_True; ::rtl::OString aPKQ,aPKO,aPKN; - aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding); + if ( catalog.hasValue() ) + aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding); aPKO = ::rtl::OUStringToOString(schema,m_nTextEncoding); const char *pPKQ = catalog.hasValue() && aPKQ.getLength() ? aPKQ.getStr() : NULL, diff --git a/connectivity/source/drivers/odbcbase/OResultSet.cxx b/connectivity/source/drivers/odbcbase/OResultSet.cxx index e789f4bd111b..dbe77cd21e48 100644 --- a/connectivity/source/drivers/odbcbase/OResultSet.cxx +++ b/connectivity/source/drivers/odbcbase/OResultSet.cxx @@ -1368,15 +1368,24 @@ sal_Bool OResultSet::isBookmarkable() const //------------------------------------------------------------------------------ void OResultSet::setFetchDirection(sal_Int32 _par0) { - N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_CURSOR_TYPE,(SQLPOINTER)(sal_IntPtr)_par0,SQL_IS_UINTEGER); + OSL_ENSURE(_par0>0,"Illegal fetch direction!"); + if ( _par0 > 0 ) + { + N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_CURSOR_TYPE,(SQLPOINTER)(sal_IntPtr)_par0,SQL_IS_UINTEGER); + } } //------------------------------------------------------------------------------ void OResultSet::setFetchSize(sal_Int32 _par0) { - N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_ARRAY_SIZE,(SQLPOINTER)(sal_IntPtr)_par0,SQL_IS_UINTEGER); - delete m_pRowStatusArray; - m_pRowStatusArray = new SQLUSMALLINT[_par0]; - N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_STATUS_PTR,m_pRowStatusArray,SQL_IS_POINTER); + OSL_ENSURE(_par0>0,"Illegal fetch size!"); + if ( _par0 > 0 ) + { + N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_ARRAY_SIZE,(SQLPOINTER)(sal_IntPtr)_par0,SQL_IS_UINTEGER); + delete m_pRowStatusArray; + + m_pRowStatusArray = new SQLUSMALLINT[_par0]; + N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_STATUS_PTR,m_pRowStatusArray,SQL_IS_POINTER); + } } // ------------------------------------------------------------------------- IPropertyArrayHelper* OResultSet::createArrayHelper( ) const diff --git a/connectivity/source/drivers/odbcbase/OResultSetMetaData.cxx b/connectivity/source/drivers/odbcbase/OResultSetMetaData.cxx index 34f60939f9f8..1eb6796c5b08 100644 --- a/connectivity/source/drivers/odbcbase/OResultSetMetaData.cxx +++ b/connectivity/source/drivers/odbcbase/OResultSetMetaData.cxx @@ -61,7 +61,11 @@ OResultSetMetaData::~OResultSetMetaData() ); ::rtl::OUString sValue; if ( nRet == SQL_SUCCESS ) + { + if ( nRealLen < 0 ) + nRealLen = BUFFER_LEN; sValue = ::rtl::OUString(pName,nRealLen,m_pConnection->getTextEncoding()); + } delete [] pName; OTools::ThrowException(m_pConnection,nRet,m_aStatementHandle,SQL_HANDLE_STMT,*this); if(nRealLen > BUFFER_LEN) @@ -75,7 +79,7 @@ OResultSetMetaData::~OResultSetMetaData() &nRealLen, NULL ); - if ( nRet == SQL_SUCCESS ) + if ( nRet == SQL_SUCCESS && nRealLen > 0) sValue = ::rtl::OUString(pName,nRealLen,m_pConnection->getTextEncoding()); delete [] pName; OTools::ThrowException(m_pConnection,nRet,m_aStatementHandle,SQL_HANDLE_STMT,*this); diff --git a/connectivity/source/drivers/odbcbase/OStatement.cxx b/connectivity/source/drivers/odbcbase/OStatement.cxx index 8a92fa87911c..3ae95c951954 100644 --- a/connectivity/source/drivers/odbcbase/OStatement.cxx +++ b/connectivity/source/drivers/odbcbase/OStatement.cxx @@ -877,13 +877,15 @@ void OStatement_Base::setFetchDirection(sal_Int32 _par0) void OStatement_Base::setFetchSize(sal_Int32 _par0) { OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!"); + OSL_ENSURE(_par0>0,"Illegal fetch size!"); + if ( _par0 > 0 ) + { + SQLRETURN nRetCode = N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_ARRAY_SIZE,(SQLPOINTER)(sal_IntPtr)_par0,SQL_IS_UINTEGER); - SQLRETURN nRetCode = N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_ARRAY_SIZE,(SQLPOINTER)(sal_IntPtr)_par0,SQL_IS_UINTEGER); - - delete m_pRowStatusArray; - m_pRowStatusArray = new SQLUSMALLINT[_par0]; - nRetCode = N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_STATUS_PTR,m_pRowStatusArray,SQL_IS_POINTER); - OSL_UNUSED( nRetCode ); + delete m_pRowStatusArray; + m_pRowStatusArray = new SQLUSMALLINT[_par0]; + nRetCode = N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_STATUS_PTR,m_pRowStatusArray,SQL_IS_POINTER); + } } //------------------------------------------------------------------------------ void OStatement_Base::setMaxFieldSize(sal_Int32 _par0) diff --git a/connectivity/source/inc/hsqldb/HDriver.hxx b/connectivity/source/inc/hsqldb/HDriver.hxx index 2ef4164899c7..4fce57fb6878 100644 --- a/connectivity/source/inc/hsqldb/HDriver.hxx +++ b/connectivity/source/inc/hsqldb/HDriver.hxx @@ -124,6 +124,7 @@ namespace connectivity virtual void SAL_CALL reverted( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException); void shutdownConnections(); + void flushConnections(); protected: /// dtor virtual ~ODriverDelegator(); diff --git a/connectivity/source/parse/PColumn.cxx b/connectivity/source/parse/PColumn.cxx index cff8c5d93fd9..a709976d1dd3 100644 --- a/connectivity/source/parse/PColumn.cxx +++ b/connectivity/source/parse/PColumn.cxx @@ -156,13 +156,15 @@ OParseColumn* OParseColumn::createColumnForResultSet( const Reference< XResultSe _rxResMetaData->isCurrency( _nColumnPos ), _rxDBMetaData->supportsMixedCaseQuotedIdentifiers() ); - pColumn->setTableName( ::dbtools::composeTableName( _rxDBMetaData, - _rxResMetaData->getCatalogName( _nColumnPos ), - _rxResMetaData->getSchemaName( _nColumnPos ), - _rxResMetaData->getTableName( _nColumnPos ), - sal_False, - eComplete - ) ); + const ::rtl::OUString sTableName = _rxResMetaData->getTableName( _nColumnPos ); + if ( sTableName.getLength() ) + pColumn->setTableName( ::dbtools::composeTableName( _rxDBMetaData, + _rxResMetaData->getCatalogName( _nColumnPos ), + _rxResMetaData->getSchemaName( _nColumnPos ), + sTableName, + sal_False, + eComplete + ) ); pColumn->setIsSearchable( _rxResMetaData->isSearchable( _nColumnPos ) ); pColumn->setRealName(_rxResMetaData->getColumnName( _nColumnPos )); pColumn->setLabel(sLabel); diff --git a/connectivity/source/parse/sqlbison.y b/connectivity/source/parse/sqlbison.y index dbfbd7ad1322..7abcacd6f736 100755 --- a/connectivity/source/parse/sqlbison.y +++ b/connectivity/source/parse/sqlbison.y @@ -218,6 +218,14 @@ using namespace connectivity; %token <pParseNode> SQL_TOKEN_VALUE SQL_TOKEN_CURRENT_CATALOG SQL_TOKEN_CURRENT_DEFAULT_TRANSFORM_GROUP SQL_TOKEN_CURRENT_PATH SQL_TOKEN_CURRENT_ROLE SQL_TOKEN_CURRENT_SCHEMA SQL_TOKEN_CURRENT_USER %token <pParseNode> SQL_TOKEN_SESSION_USER SQL_TOKEN_SYSTEM_USER SQL_TOKEN_VARCHAR SQL_TOKEN_VARBINARY SQL_TOKEN_VARYING SQL_TOKEN_OBJECT SQL_TOKEN_NCLOB SQL_TOKEN_NATIONAL %token <pParseNode> SQL_TOKEN_LARGE SQL_TOKEN_CLOB SQL_TOKEN_BLOB SQL_TOKEN_BIGINT SQL_TOKEN_BINARY SQL_TOKEN_WITHOUT SQL_TOKEN_BOOLEAN SQL_TOKEN_INTERVAL +// window function +%token <pParseNode> SQL_TOKEN_OVER SQL_TOKEN_ROW_NUMBER SQL_TOKEN_NTILE SQL_TOKEN_LEAD SQL_TOKEN_LAG SQL_TOKEN_RESPECT SQL_TOKEN_IGNORE SQL_TOKEN_NULLS +%token <pParseNode> SQL_TOKEN_FIRST_VALUE SQL_TOKEN_LAST_VALUE SQL_TOKEN_NTH_VALUE SQL_TOKEN_FIRST SQL_TOKEN_LAST +%token <pParseNode> SQL_TOKEN_EXCLUDE SQL_TOKEN_OTHERS SQL_TOKEN_TIES SQL_TOKEN_FOLLOWING SQL_TOKEN_UNBOUNDED SQL_TOKEN_PRECEDING SQL_TOKEN_RANGE SQL_TOKEN_ROWS +%token <pParseNode> SQL_TOKEN_PARTITION SQL_TOKEN_WINDOW SQL_TOKEN_NO +// LIMIT and OFFSEt +%token <pParseNode> SQL_TOKEN_LIMIT SQL_TOKEN_OFFSET SQL_TOKEN_NEXT SQL_TOKEN_ONLY + /* operators */ %left SQL_TOKEN_NAME %left <pParseNode> SQL_TOKEN_OR @@ -272,7 +280,7 @@ using namespace connectivity; %type <pParseNode> form_conversion char_translation trim_fct trim_operands trim_spec bit_value_fct bit_substring_fct op_column_commalist %type <pParseNode> /*bit_concatenation*/ bit_value_exp bit_factor bit_primary collate_clause char_value_fct unique_spec value_exp_commalist in_predicate_value unique_test update_source %type <pParseNode> function_arg_commalist3 string_function_3Argument function_arg_commalist4 string_function_4Argument function_arg_commalist2 string_function_1Argument string_function_2Argument -%type <pParseNode> date_function_0Argument date_function_1Argument function_name12 function_name23 function_name1 function_name2 function_name3 function_name0 numeric_function_0Argument numeric_function_1Argument numeric_function_2Argument date_function_3Argument +%type <pParseNode> date_function_0Argument date_function_1Argument function_name12 function_name23 function_name1 function_name2 function_name3 function_name0 numeric_function_0Argument numeric_function_1Argument numeric_function_2Argument %type <pParseNode> all query_primary sql_not for_length upper_lower comparison column_val cross_union /*opt_schema_element_list*/ %type <pParseNode> /*op_authorization op_schema*/ nil_fkt schema_element base_table_def base_table_element base_table_element_commalist %type <pParseNode> column_def odbc_fct_spec odbc_call_spec odbc_fct_type op_parameter union_statement @@ -287,6 +295,16 @@ using namespace connectivity; %type <pParseNode> binary_string_type numeric_type boolean_type datetime_type interval_type opt_paren_precision paren_char_length opt_paren_char_large_length paren_character_large_object_length %type <pParseNode> large_object_length opt_multiplier character_large_object_type national_character_large_object_type binary_large_object_string_type opt_with_or_without_time_zone %type <pParseNode> approximate_numeric_type exact_numeric_type opt_paren_precision_scale +/* window function rules */ +%type <pParseNode> window_function window_function_type ntile_function number_of_tiles lead_or_lag_function lead_or_lag lead_or_lag_extent offset default_expression null_treatment +%type <pParseNode> first_or_last_value_function first_or_last_value nth_value_function nth_row from_first_or_last window_name_or_specification in_line_window_specification opt_lead_or_lag_function +%type <pParseNode> opt_null_treatment opt_from_first_or_last simple_value_specification dynamic_parameter_specification window_name window_clause window_definition_list window_definition +%type <pParseNode> new_window_name window_specification_details existing_window_name window_partition_clause window_partition_column_reference_list window_partition_column_reference window_frame_clause +%type <pParseNode> window_frame_units window_frame_extent window_frame_start window_frame_preceding window_frame_between window_frame_bound_1 window_frame_bound_2 window_frame_bound window_frame_following window_frame_exclusion +%type <pParseNode> opt_window_frame_clause opt_window_partition_clause opt_existing_window_name window_specification opt_window_frame_exclusion opt_window_clause opt_offset +%type <pParseNode> opt_fetch_first_row_count fetch_first_clause offset_row_count fetch_first_row_count first_or_next row_or_rows opt_result_offset_clause result_offset_clause +/* LIMIT and OFFSET */ +%type <pParseNode> opt_limit_offset_clause limit_offset_clause opt_fetch_first_clause %% /* Parse Tree an OSQLParser zurueckliefern @@ -921,19 +939,89 @@ selection: } | scalar_exp_commalist ; +opt_result_offset_clause: + /* empty */ {$$ = SQL_NEW_RULE;} + | result_offset_clause + ; +result_offset_clause: + SQL_TOKEN_OFFSET offset_row_count row_or_rows + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + } + ; +opt_fetch_first_row_count: + /* empty */ {$$ = SQL_NEW_RULE;} + | fetch_first_row_count + ; +first_or_next: + SQL_TOKEN_FIRST + | SQL_TOKEN_NEXT + ; +row_or_rows: + SQL_TOKEN_ROW + | SQL_TOKEN_ROWS + ; +opt_fetch_first_clause: + /* empty */ {$$ = SQL_NEW_RULE;} + | fetch_first_clause + ; +fetch_first_clause: + SQL_TOKEN_FETCH first_or_next opt_fetch_first_row_count row_or_rows SQL_TOKEN_ONLY + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + $$->append($4); + $$->append($5); + } + ; +offset_row_count: + literal + ; +fetch_first_row_count: + literal + ; +opt_limit_offset_clause: + /* empty */ {$$ = SQL_NEW_RULE;} + | limit_offset_clause + ; +opt_offset: + /* empty */ {$$ = SQL_NEW_RULE;} + | SQL_TOKEN_OFFSET SQL_TOKEN_INTNUM + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + } + ; +limit_offset_clause: + SQL_TOKEN_LIMIT SQL_TOKEN_INTNUM opt_offset + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + } + ; table_exp: - from_clause - opt_where_clause - opt_group_by_clause - opt_having_clause - opt_order_by_clause - {$$ = SQL_NEW_RULE; + from_clause opt_where_clause opt_group_by_clause opt_having_clause opt_window_clause opt_order_by_clause opt_limit_offset_clause opt_result_offset_clause opt_fetch_first_clause + { + $$ = SQL_NEW_RULE; $$->append($1); $$->append($2); $$->append($3); $$->append($4); - $$->append($5);} + $$->append($5); + $$->append($6); + $$->append($7); + $$->append($8); + $$->append($9); + } ; from_clause: @@ -1852,10 +1940,10 @@ function_name12: ; function_name23: SQL_TOKEN_LOCATE + | SQL_TOKEN_DATEDIFF ; function_name3: string_function_3Argument - | date_function_3Argument ; function_name: string_function @@ -1913,8 +2001,6 @@ date_function_1Argument: | SQL_TOKEN_TIMEVALUE | SQL_TOKEN_DATEVALUE ; -date_function_3Argument: - SQL_TOKEN_DATEDIFF date_function: SQL_TOKEN_TIMESTAMPADD @@ -1952,6 +2038,362 @@ numeric_function: SQL_TOKEN_RAND | SQL_TOKEN_TRUNCATE ; + +window_function: + window_function_type SQL_TOKEN_OVER window_name_or_specification + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + } + ; +window_function_type : + rank_function_type '(' ')' + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION)); + } + | SQL_TOKEN_ROW_NUMBER '(' ')' + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION)); + } + | general_set_fct + | ntile_function + | lead_or_lag_function + | first_or_last_value_function + | nth_value_function +; +ntile_function : + SQL_TOKEN_NTILE '(' number_of_tiles ')' + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION)); + } + ; +dynamic_parameter_specification: + parameter + ; +simple_value_specification: + literal + ; +number_of_tiles : + simple_value_specification + | dynamic_parameter_specification + ; +opt_lead_or_lag_function: + /* empty */ {$$ = SQL_NEW_RULE;} + | ',' offset + { + $$ = SQL_NEW_RULE; + $$->append($1 = newNode(",", SQL_NODE_PUNCTUATION)); + $$->append($2); + } + | ',' offset ',' default_expression + { + $$ = SQL_NEW_RULE; + $$->append($1 = newNode(",", SQL_NODE_PUNCTUATION)); + $$->append($2); + $$->append($3 = newNode(",", SQL_NODE_PUNCTUATION)); + $$->append($4); + } + ; +opt_null_treatment: + /* empty */ {$$ = SQL_NEW_RULE;} + | null_treatment + ; + +lead_or_lag_function: + lead_or_lag '(' lead_or_lag_extent opt_lead_or_lag_function ')' opt_null_treatment + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4); + $$->append($5 = newNode(")", SQL_NODE_PUNCTUATION)); + $$->append($6); + } + ; +lead_or_lag: + SQL_TOKEN_LEAD + | SQL_TOKEN_LAG + ; +lead_or_lag_extent: + value_exp + ; +offset: + SQL_TOKEN_INTNUM + ; +default_expression: + value_exp + ; +null_treatment: + SQL_TOKEN_RESPECT SQL_TOKEN_NULLS + | SQL_TOKEN_IGNORE SQL_TOKEN_NULLS + ; +first_or_last_value_function: + first_or_last_value '(' value_exp ')' opt_null_treatment + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION)); + $$->append($5); + } + ; +first_or_last_value : + SQL_TOKEN_FIRST_VALUE + | SQL_TOKEN_LAST_VALUE + ; +opt_from_first_or_last: + /* empty */ {$$ = SQL_NEW_RULE;} + | from_first_or_last + ; +nth_value_function: + SQL_TOKEN_NTH_VALUE '(' value_exp ',' nth_row ')' opt_from_first_or_last opt_null_treatment + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($3); + $$->append($4 = newNode(",", SQL_NODE_PUNCTUATION)); + $$->append($5); + $$->append($6 = newNode(")", SQL_NODE_PUNCTUATION)); + $$->append($7); + $$->append($8); + } + ; +nth_row: + simple_value_specification + | dynamic_parameter_specification + ; +from_first_or_last: + SQL_TOKEN_FROM SQL_TOKEN_FIRST + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + } + | SQL_TOKEN_FROM SQL_TOKEN_LAST + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + } + ; +window_name: + SQL_TOKEN_NAME + ; +window_name_or_specification: + window_name + | in_line_window_specification + ; +in_line_window_specification: + window_specification + ; +opt_window_clause: + /* empty */ {$$ = SQL_NEW_RULE;} + | window_clause + ; +window_clause: + SQL_TOKEN_WINDOW window_definition_list + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + } + ; +window_definition_list: + window_definition_list ',' window_definition + {$1->append($3); + $$ = $1;} + | window_definition + {$$ = SQL_NEW_COMMALISTRULE; + $$->append($1);} + ; +window_definition: + new_window_name SQL_TOKEN_AS window_specification + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + } + ; +new_window_name: + window_name + ; +window_specification: + '(' window_specification_details ')' + { + $$ = SQL_NEW_RULE; + $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION)); + $$->append($2); + $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION)); + } + ; +opt_existing_window_name: + /* empty */ {$$ = SQL_NEW_RULE;} + | existing_window_name + ; +opt_window_partition_clause: + /* empty */ {$$ = SQL_NEW_RULE;} + | window_partition_clause + ; +opt_window_frame_clause: + /* empty */ {$$ = SQL_NEW_RULE;} + | window_frame_clause + ; +window_specification_details: + opt_existing_window_name + opt_window_partition_clause + opt_order_by_clause + opt_window_frame_clause + ; +existing_window_name: + window_name + ; +window_partition_clause: + SQL_TOKEN_PARTITION SQL_TOKEN_BY window_partition_column_reference_list + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + } + ; +window_partition_column_reference_list: + window_partition_column_reference_list ',' window_partition_column_reference + {$1->append($3); + $$ = $1;} + | window_partition_column_reference + {$$ = SQL_NEW_COMMALISTRULE; + $$->append($1);} + ; +window_partition_column_reference: + column_ref opt_collate_clause + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + } + ; +opt_window_frame_exclusion: + /* empty */ {$$ = SQL_NEW_RULE;} + | window_frame_exclusion + ; +window_frame_clause: + window_frame_units window_frame_extent opt_window_frame_exclusion + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + } + ; +window_frame_units: + SQL_TOKEN_ROWS + | SQL_TOKEN_RANGE + ; +window_frame_extent: + window_frame_start + | window_frame_between + ; +window_frame_start: + SQL_TOKEN_UNBOUNDED SQL_TOKEN_PRECEDING + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + } + | window_frame_preceding + | SQL_TOKEN_CURRENT SQL_TOKEN_ROW + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + } + ; +window_frame_preceding: + unsigned_value_spec SQL_TOKEN_PRECEDING + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + } + ; +window_frame_between: + SQL_TOKEN_BETWEEN window_frame_bound_1 SQL_TOKEN_AND window_frame_bound_2 + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + $$->append($4); + } + ; +window_frame_bound_1: + window_frame_bound + ; +window_frame_bound_2: + window_frame_bound + ; +window_frame_bound: + window_frame_start + | SQL_TOKEN_UNBOUNDED SQL_TOKEN_FOLLOWING + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + } + | window_frame_following + ; +window_frame_following: + unsigned_value_spec SQL_TOKEN_FOLLOWING + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + } + ; +window_frame_exclusion: + SQL_TOKEN_EXCLUDE SQL_TOKEN_CURRENT SQL_TOKEN_ROW + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + } + | SQL_TOKEN_EXCLUDE SQL_TOKEN_GROUP + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + } + | SQL_TOKEN_EXCLUDE SQL_TOKEN_TIES + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + } + | SQL_TOKEN_EXCLUDE SQL_TOKEN_NO SQL_TOKEN_OTHERS + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + $$->append($3); + } + ; op_parameter: {$$ = SQL_NEW_RULE;} | '?' SQL_EQUAL @@ -2006,11 +2448,16 @@ odbc_fct_spec: $$->append($1); $$->append($2); } + | SQL_TOKEN_FN set_fct_spec + { + $$ = SQL_NEW_RULE; + $$->append($1); + $$->append($2); + } ; odbc_fct_type: - SQL_TOKEN_FN - | SQL_TOKEN_D + SQL_TOKEN_D | SQL_TOKEN_T | SQL_TOKEN_TS ; @@ -2316,6 +2763,7 @@ value_exp_primary: | set_fct_spec | scalar_subquery | case_expression + | window_function | '(' value_exp ')' { $$ = SQL_NEW_RULE; diff --git a/connectivity/source/parse/sqlflex.l b/connectivity/source/parse/sqlflex.l index c959230c0da9..85296a863381 100755 --- a/connectivity/source/parse/sqlflex.l +++ b/connectivity/source/parse/sqlflex.l @@ -212,15 +212,19 @@ END {SQL_NEW_KEYWORD(SQL_TOKEN_END); } EVERY {SQL_NEW_KEYWORD(SQL_TOKEN_EVERY); } ESCAPE {SQL_NEW_KEYWORD(SQL_TOKEN_ESCAPE); } EXCEPT {SQL_NEW_KEYWORD(SQL_TOKEN_EXCEPT); } +EXCLUDE {SQL_NEW_KEYWORD(SQL_TOKEN_EXCLUDE); } EXISTS {SQL_NEW_KEYWORD(SQL_TOKEN_EXISTS); } EXP {SQL_NEW_KEYWORD(SQL_TOKEN_EXP); } EXTRACT {SQL_NEW_KEYWORD(SQL_TOKEN_EXTRACT); } FALSE {SQL_NEW_KEYWORD(SQL_TOKEN_FALSE); } FETCH {SQL_NEW_KEYWORD(SQL_TOKEN_FETCH); } +FIRST {SQL_NEW_KEYWORD(SQL_TOKEN_FIRST); } +FIRST_VALUE {SQL_NEW_KEYWORD(SQL_TOKEN_FIRST_VALUE); } FLOAT {SQL_NEW_KEYWORD(SQL_TOKEN_FLOAT); } FLOOR {SQL_NEW_KEYWORD(SQL_TOKEN_FLOOR); } FN {SQL_NEW_KEYWORD(SQL_TOKEN_FN); } +FOLLOWING {SQL_NEW_KEYWORD(SQL_TOKEN_FOLLOWING); } FOR {SQL_NEW_KEYWORD(SQL_TOKEN_FOR); } FOREIGN {SQL_NEW_KEYWORD(SQL_TOKEN_FOREIGN); } FOUND {SQL_NEW_KEYWORD(SQL_TOKEN_FOUND); } @@ -234,6 +238,7 @@ GROUP {SQL_NEW_KEYWORD(SQL_TOKEN_GROUP); } HAVING {SQL_NEW_KEYWORD(SQL_TOKEN_HAVING); } HOUR {SQL_NEW_KEYWORD(SQL_TOKEN_HOUR); } +IGNORE {SQL_NEW_KEYWORD(SQL_TOKEN_IGNORE); } IN {SQL_NEW_KEYWORD(SQL_TOKEN_IN); } INNER {SQL_NEW_KEYWORD(SQL_TOKEN_INNER); } INSERT {SQL_NEW_KEYWORD(SQL_TOKEN_INSERT); } @@ -249,12 +254,17 @@ JOIN {SQL_NEW_KEYWORD(SQL_TOKEN_JOIN); } KEY {SQL_NEW_KEYWORD(SQL_TOKEN_KEY); } +LAG {SQL_NEW_KEYWORD(SQL_TOKEN_LAG); } LARGE {SQL_NEW_KEYWORD(SQL_TOKEN_LARGE); } +LAST {SQL_NEW_KEYWORD(SQL_TOKEN_LAST); } +LAST_VALUE {SQL_NEW_KEYWORD(SQL_TOKEN_LAST_VALUE); } LCASE {SQL_NEW_KEYWORD(SQL_TOKEN_LCASE); } +LEAD {SQL_NEW_KEYWORD(SQL_TOKEN_LEAD); } LEADING {SQL_NEW_KEYWORD(SQL_TOKEN_LEADING); } LEFT {SQL_NEW_KEYWORD(SQL_TOKEN_LEFT); } LENGTH {SQL_NEW_KEYWORD(SQL_TOKEN_LENGTH); } LIKE {SQL_NEW_KEYWORD(SQL_TOKEN_LIKE); } +LIMIT {SQL_NEW_KEYWORD(SQL_TOKEN_LIMIT); } LN {SQL_NEW_KEYWORD(SQL_TOKEN_LN); } LOCAL {SQL_NEW_KEYWORD(SQL_TOKEN_LOCAL); } LOCATE {SQL_NEW_KEYWORD(SQL_TOKEN_LOCATE); } @@ -276,29 +286,40 @@ NATURAL {SQL_NEW_KEYWORD(SQL_TOKEN_NATURAL); } NCHAR {SQL_NEW_KEYWORD(SQL_TOKEN_NCHAR); } NCLOB {SQL_NEW_KEYWORD(SQL_TOKEN_NCLOB); } NEW {SQL_NEW_KEYWORD(SQL_TOKEN_NEW); } +NEXT {SQL_NEW_KEYWORD(SQL_TOKEN_NEXT); } +NO {SQL_NEW_KEYWORD(SQL_TOKEN_NO); } NOT {SQL_NEW_KEYWORD(SQL_TOKEN_NOT); } NOW {SQL_NEW_KEYWORD(SQL_TOKEN_NOW); } +NTH_VALUE {SQL_NEW_KEYWORD(SQL_TOKEN_NTH_VALUE); } +NTILE {SQL_NEW_KEYWORD(SQL_TOKEN_NTILE); } NULL {SQL_NEW_KEYWORD(SQL_TOKEN_NULL); } NULLIF {SQL_NEW_KEYWORD(SQL_TOKEN_NULLIF); } +NULLS {SQL_NEW_KEYWORD(SQL_TOKEN_NULLS); } NUMERIC {SQL_NEW_KEYWORD(SQL_TOKEN_NUMERIC); } OBJECT {SQL_NEW_KEYWORD(SQL_TOKEN_OBJECT); } OCTET_LENGTH {SQL_NEW_KEYWORD(SQL_TOKEN_OCTET_LENGTH); } OF {SQL_NEW_KEYWORD(SQL_TOKEN_OF); } +OFFSET {SQL_NEW_KEYWORD(SQL_TOKEN_OFFSET); } OJ {SQL_NEW_KEYWORD(SQL_TOKEN_OJ); } OLD {SQL_NEW_KEYWORD(SQL_TOKEN_OLD); } ON {SQL_NEW_KEYWORD(SQL_TOKEN_ON); } +ONLY {SQL_NEW_KEYWORD(SQL_TOKEN_ONLY); } OPTION {SQL_NEW_KEYWORD(SQL_TOKEN_OPTION); } OR {SQL_NEW_KEYWORD(SQL_TOKEN_OR); } ORDER {SQL_NEW_KEYWORD(SQL_TOKEN_ORDER); } +OTHERS {SQL_NEW_KEYWORD(SQL_TOKEN_OTHERS); } OUTER {SQL_NEW_KEYWORD(SQL_TOKEN_OUTER); } +OVER {SQL_NEW_KEYWORD(SQL_TOKEN_OVER); } +PARTITION {SQL_NEW_KEYWORD(SQL_TOKEN_PARTITION); } PERCENT_RANK {SQL_NEW_KEYWORD(SQL_TOKEN_PERCENT_RANK); } PERCENTILE_CONT {SQL_NEW_KEYWORD(SQL_TOKEN_PERCENTILE_CONT); } PERCENTILE_DISC {SQL_NEW_KEYWORD(SQL_TOKEN_PERCENTILE_DISC); } PI {SQL_NEW_KEYWORD(SQL_TOKEN_PI); } POSITION {SQL_NEW_KEYWORD(SQL_TOKEN_POSITION); } POWER {SQL_NEW_KEYWORD(SQL_TOKEN_POWER); } +PRECEDING {SQL_NEW_KEYWORD(SQL_TOKEN_PRECEDING); } PRECISION {SQL_NEW_KEYWORD(SQL_TOKEN_PRECISION); } PRIMARY {SQL_NEW_KEYWORD(SQL_TOKEN_PRIMARY); } PRIVILEGES {SQL_NEW_KEYWORD(SQL_TOKEN_PRIVILEGES); } @@ -309,16 +330,20 @@ QUARTER {SQL_NEW_KEYWORD(SQL_TOKEN_QUARTER); } RADIANS {SQL_NEW_KEYWORD(SQL_TOKEN_RADIANS); } RAND {SQL_NEW_KEYWORD(SQL_TOKEN_RAND); } +RANGE {SQL_NEW_KEYWORD(SQL_TOKEN_RANGE); } RANK {SQL_NEW_KEYWORD(SQL_TOKEN_RANK); } REAL {SQL_NEW_KEYWORD(SQL_TOKEN_REAL); } REFERENCES {SQL_NEW_KEYWORD(SQL_TOKEN_REFERENCES); } REFERENCING {SQL_NEW_KEYWORD(SQL_TOKEN_REFERENCING); } REPEAT {SQL_NEW_KEYWORD(SQL_TOKEN_REPEAT); } REPLACE {SQL_NEW_KEYWORD(SQL_TOKEN_REPLACE); } +RESPECT {SQL_NEW_KEYWORD(SQL_TOKEN_RESPECT); } ROLLBACK {SQL_NEW_KEYWORD(SQL_TOKEN_ROLLBACK); } ROUND {SQL_NEW_KEYWORD(SQL_TOKEN_ROUND); } ROUNDMAGIC {SQL_NEW_KEYWORD(SQL_TOKEN_ROUNDMAGIC); } ROW {SQL_NEW_KEYWORD(SQL_TOKEN_ROW); } +ROWS {SQL_NEW_KEYWORD(SQL_TOKEN_ROWS); } +ROW_NUMBER {SQL_NEW_KEYWORD(SQL_TOKEN_ROW_NUMBER); } RIGHT {SQL_NEW_KEYWORD(SQL_TOKEN_RIGHT); } RTRIM {SQL_NEW_KEYWORD(SQL_TOKEN_RTRIM); } @@ -345,6 +370,7 @@ SYSTEM_USER {SQL_NEW_KEYWORD(SQL_TOKEN_SYSTEM_USER); } TABLE {SQL_NEW_KEYWORD(SQL_TOKEN_TABLE); } TAN {SQL_NEW_KEYWORD(SQL_TOKEN_TAN); } THEN {SQL_NEW_KEYWORD(SQL_TOKEN_THEN); } +TIES {SQL_NEW_KEYWORD(SQL_TOKEN_TIES); } TIME {SQL_NEW_KEYWORD(SQL_TOKEN_TIME); } TIMESTAMP {SQL_NEW_KEYWORD(SQL_TOKEN_TIMESTAMP); } TIMESTAMPADD {SQL_NEW_KEYWORD(SQL_TOKEN_TIMESTAMPADD); } @@ -363,6 +389,7 @@ TS {SQL_NEW_KEYWORD(SQL_TOKEN_TS); } T {SQL_NEW_KEYWORD(SQL_TOKEN_T); } UCASE {SQL_NEW_KEYWORD(SQL_TOKEN_UCASE); } +UNBOUNDED {SQL_NEW_KEYWORD(SQL_TOKEN_UNBOUNDED); } UNION {SQL_NEW_KEYWORD(SQL_TOKEN_UNION); } UNIQUE {SQL_NEW_KEYWORD(SQL_TOKEN_UNIQUE); } UNKNOWN {SQL_NEW_KEYWORD(SQL_TOKEN_UNKNOWN); } diff --git a/connectivity/source/parse/sqliterator.cxx b/connectivity/source/parse/sqliterator.cxx index 82677e870aae..0c3b6a0cd958 100644 --- a/connectivity/source/parse/sqliterator.cxx +++ b/connectivity/source/parse/sqliterator.cxx @@ -1069,9 +1069,9 @@ void OSQLParseTreeIterator::traverseByColumnNames(const OSQLParseNode* pSelectNo OSQLParseNode * pTableExp = pSelectNode->getChild(3); OSL_ENSURE(pTableExp != NULL,"OSQLParseTreeIterator: error in parse tree!"); OSL_ENSURE(SQL_ISRULE(pTableExp,table_exp),"OSQLParseTreeIterator:table_exp error in parse tree!"); - OSL_ENSURE(pTableExp->count() == 5,"OSQLParseTreeIterator: error in parse tree!"); + OSL_ENSURE(pTableExp->count() == TABLE_EXPRESSION_CHILD_COUNT,"OSQLParseTreeIterator: error in parse tree!"); - sal_uInt32 nPos = ( _bOrder ? 4 : 2 ); + sal_uInt32 nPos = ( _bOrder ? ORDER_BY_CHILD_POS : 2 ); OSQLParseNode * pOptByClause = pTableExp->getChild(nPos); OSL_ENSURE(pOptByClause != NULL,"OSQLParseTreeIterator: error in parse tree!"); @@ -1234,7 +1234,7 @@ bool OSQLParseTreeIterator::traverseSelectionCriteria(const OSQLParseNode* pSele OSQLParseNode * pTableExp = pSelectNode->getChild(3); OSL_ENSURE(pTableExp != NULL,"OSQLParseTreeIterator: error in parse tree!"); OSL_ENSURE(SQL_ISRULE(pTableExp,table_exp),"OSQLParseTreeIterator: error in parse tree!"); - OSL_ENSURE(pTableExp->count() == 5,"OSQLParseTreeIterator: error in parse tree!"); + OSL_ENSURE(pTableExp->count() == TABLE_EXPRESSION_CHILD_COUNT,"OSQLParseTreeIterator: error in parse tree!"); pWhereClause = pTableExp->getChild(1); } else if (SQL_ISRULE(pSelectNode,update_statement_searched)) { @@ -1452,7 +1452,7 @@ void OSQLParseTreeIterator::traverseANDCriteria(OSQLParseNode * pSearchCondition } //----------------------------------------------------------------------------- void OSQLParseTreeIterator::traverseParameter(const OSQLParseNode* _pParseNode - ,const OSQLParseNode* _pColumnRef + ,const OSQLParseNode* _pParentNode ,const ::rtl::OUString& _aColumnName ,const ::rtl::OUString& _aTableRange ,const ::rtl::OUString& _rColumnAlias) @@ -1491,18 +1491,18 @@ void OSQLParseTreeIterator::traverseParameter(const OSQLParseNode* _pParseNode } // found a parameter - if ( _pColumnRef && (SQL_ISRULE(_pColumnRef,general_set_fct) || SQL_ISRULE(_pColumnRef,set_fct_spec)) ) + if ( _pParentNode && (SQL_ISRULE(_pParentNode,general_set_fct) || SQL_ISRULE(_pParentNode,set_fct_spec)) ) {// found a function as column_ref ::rtl::OUString sFunctionName; - _pColumnRef->getChild(0)->parseNodeToStr( sFunctionName, m_pImpl->m_xConnection, NULL, sal_False, sal_False ); - const sal_uInt32 nCount = _pColumnRef->count(); + _pParentNode->getChild(0)->parseNodeToStr( sFunctionName, m_pImpl->m_xConnection, NULL, sal_False, sal_False ); + const sal_uInt32 nCount = _pParentNode->count(); sal_uInt32 i = 0; for(; i < nCount;++i) { - if ( _pColumnRef->getChild(i) == _pParseNode ) + if ( _pParentNode->getChild(i) == _pParseNode ) break; } - sal_Int32 nType = ::connectivity::OSQLParser::getFunctionParameterType( _pColumnRef->getParent()->getChild(0)->getTokenID(), i+1); + sal_Int32 nType = ::connectivity::OSQLParser::getFunctionParameterType( _pParentNode->getChild(0)->getTokenID(), i-1); OParseColumn* pColumn = new OParseColumn( sParameterName, ::rtl::OUString(), @@ -1553,14 +1553,14 @@ void OSQLParseTreeIterator::traverseParameter(const OSQLParseNode* _pParseNode if ( bNotFound ) { sal_Int32 nType = DataType::VARCHAR; - OSQLParseNode* pParent = _pColumnRef ? _pColumnRef->getParent() : NULL; + OSQLParseNode* pParent = _pParentNode ? _pParentNode->getParent() : NULL; if ( pParent && (SQL_ISRULE(pParent,general_set_fct) || SQL_ISRULE(pParent,set_fct_spec)) ) { - const sal_uInt32 nCount = _pColumnRef->count(); + const sal_uInt32 nCount = _pParentNode->count(); sal_uInt32 i = 0; for(; i < nCount;++i) { - if ( _pColumnRef->getChild(i) == _pParseNode ) + if ( _pParentNode->getChild(i) == _pParseNode ) break; } nType = ::connectivity::OSQLParser::getFunctionParameterType( pParent->getChild(0)->getTokenID(), i+1); @@ -1968,7 +1968,7 @@ const OSQLParseNode* OSQLParseTreeIterator::getWhereTree() const OSQLParseNode * pTableExp = m_pParseTree->getChild(3); OSL_ENSURE(pTableExp != NULL,"OSQLParseTreeIterator: error in parse tree!"); OSL_ENSURE(SQL_ISRULE(pTableExp,table_exp),"OSQLParseTreeIterator: error in parse tree!"); - OSL_ENSURE(pTableExp->count() == 5,"OSQLParseTreeIterator: error in parse tree!"); + OSL_ENSURE(pTableExp->count() == TABLE_EXPRESSION_CHILD_COUNT,"OSQLParseTreeIterator: error in parse tree!"); pWhereClause = pTableExp->getChild(1); } @@ -1998,9 +1998,9 @@ const OSQLParseNode* OSQLParseTreeIterator::getOrderTree() const OSQLParseNode * pTableExp = m_pParseTree->getChild(3); OSL_ENSURE(pTableExp != NULL,"OSQLParseTreeIterator: error in parse tree!"); OSL_ENSURE(SQL_ISRULE(pTableExp,table_exp),"OSQLParseTreeIterator: error in parse tree!"); - OSL_ENSURE(pTableExp->count() == 5,"OSQLParseTreeIterator: error in parse tree!"); + OSL_ENSURE(pTableExp->count() == TABLE_EXPRESSION_CHILD_COUNT,"OSQLParseTreeIterator: error in parse tree!"); - pOrderClause = pTableExp->getChild(4); + pOrderClause = pTableExp->getChild(ORDER_BY_CHILD_POS); // Wenn es aber eine order_by ist, dann darf sie nicht leer sein: if(pOrderClause->count() != 3) pOrderClause = NULL; @@ -2020,7 +2020,7 @@ const OSQLParseNode* OSQLParseTreeIterator::getGroupByTree() const OSQLParseNode * pTableExp = m_pParseTree->getChild(3); OSL_ENSURE(pTableExp != NULL,"OSQLParseTreeIterator: error in parse tree!"); OSL_ENSURE(SQL_ISRULE(pTableExp,table_exp),"OSQLParseTreeIterator: error in parse tree!"); - OSL_ENSURE(pTableExp->count() == 5,"OSQLParseTreeIterator: error in parse tree!"); + OSL_ENSURE(pTableExp->count() == TABLE_EXPRESSION_CHILD_COUNT,"OSQLParseTreeIterator: error in parse tree!"); pGroupClause = pTableExp->getChild(2); // Wenn es aber eine order_by ist, dann darf sie nicht leer sein: @@ -2041,7 +2041,7 @@ const OSQLParseNode* OSQLParseTreeIterator::getHavingTree() const OSQLParseNode * pTableExp = m_pParseTree->getChild(3); OSL_ENSURE(pTableExp != NULL,"OSQLParseTreeIterator: error in parse tree!"); OSL_ENSURE(SQL_ISRULE(pTableExp,table_exp),"OSQLParseTreeIterator: error in parse tree!"); - OSL_ENSURE(pTableExp->count() == 5,"OSQLParseTreeIterator: error in parse tree!"); + OSL_ENSURE(pTableExp->count() == TABLE_EXPRESSION_CHILD_COUNT,"OSQLParseTreeIterator: error in parse tree!"); pHavingClause = pTableExp->getChild(3); // Wenn es aber eine order_by ist, dann darf sie nicht leer sein: diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx index c69017e0744b..599128dd5936 100644 --- a/connectivity/source/parse/sqlnode.cxx +++ b/connectivity/source/parse/sqlnode.cxx @@ -2470,7 +2470,7 @@ void OSQLParseNode::parseLeaf(::rtl::OUStringBuffer& rString, const SQLParseNode if (rString.getLength()) rString.appendAscii(" "); - const ::rtl::OString sT = OSQLParser::TokenIDToStr(m_nNodeID, &rParam.m_rContext); + const ::rtl::OString sT = OSQLParser::TokenIDToStr(m_nNodeID, rParam.bInternational ? &rParam.m_rContext : NULL); rString.append(::rtl::OStringToOUString(sT,RTL_TEXTENCODING_UTF8)); } break; case SQL_NODE_STRING: |