[Libreoffice-commits] core.git: connectivity/source
Tamas Bunth
tamas.bunth at collabora.co.uk
Sat Apr 14 12:16:38 UTC 2018
connectivity/source/parse/sqlnode.cxx | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
New commits:
commit f5a2fedaebcf71824ecef9b5e7683237646175b4
Author: Tamas Bunth <tamas.bunth at collabora.co.uk>
Date: Sun Apr 8 13:34:27 2018 +0200
tdf#105075 Firebird: Support Limit of query_GUI
Firebird uses "SELECT FIRST <num> ..." format to limit the number of
result row numbers instead of "SELECT ... LIMIT <num>"
My first approach was to improve OSQLParser and make it understand the
Firebird dialect. But it is hard because the parser has hard-coded
getChild(int) calls all over the code and all the indexes should be
updated.
Instead of this, we recognise the LIMIT keyword with the parser, remove
it and push the FIRST <num> part manually right after SELECT.
All of this should happen in case of Firebird and only when using the
query-GUI.
Change-Id: I53f3f977f77cf98b91b25a7eaa6ebb2ee8ac0951
Reviewed-on: https://gerrit.libreoffice.org/52591
Reviewed-by: Lionel Elie Mamane <lionel at mamane.lu>
Tested-by: Jenkins <ci at libreoffice.org>
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;
}
More information about the Libreoffice-commits
mailing list