diff options
-rw-r--r-- | connectivity/source/parse/sqlnode.cxx | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx index eb4a02ca36e9..adc48a446a2e 100644 --- a/connectivity/source/parse/sqlnode.cxx +++ b/connectivity/source/parse/sqlnode.cxx @@ -347,6 +347,18 @@ bool OSQLParseNode::parseNodeToExecutableStatement( OUString& _out_rString, cons aParseParam.pParser = &_rParser; + // LIMIT keyword differs in Firebird + OSQLParseNode* pTableExp = getChild(3); + Reference< XDatabaseMetaData > xMeta( _rxConnection->getMetaData() ); + OUString sLimitValue; + if( pTableExp->getChild(6)->count() >= 2 && pTableExp->getChild(6)->getChild(1) + && (xMeta->getURL().equalsIgnoreAsciiCase("sdbc:embedded:firebird") + || xMeta->getURL().startsWithIgnoreAsciiCase("sdbc:firebird:"))) + { + sLimitValue = pTableExp->getChild(6)->getChild(1)->getTokenValue(); + pTableExp->removeAt(6); + } + _out_rString.clear(); OUStringBuffer sBuffer; bool bSuccess = false; @@ -360,6 +372,14 @@ bool OSQLParseNode::parseNodeToExecutableStatement( OUString& _out_rString, cons if ( _pErrorHolder ) *_pErrorHolder = e; } + + if(sLimitValue.getLength() > 0) + { + constexpr char SELECT_KEYWORD[] = "SELECT"; + sBuffer.insert(sBuffer.indexOf(SELECT_KEYWORD) + strlen(SELECT_KEYWORD), + " FIRST " + sLimitValue); + } + _out_rString = sBuffer.makeStringAndClear(); return bSuccess; } |