26#include <sqlbison.hxx>
29#include <com/sun/star/lang/Locale.hpp>
30#include <com/sun/star/util/XNumberFormatter.hpp>
31#include <com/sun/star/util/XNumberFormatTypes.hpp>
32#include <com/sun/star/i18n/LocaleData.hpp>
33#include <com/sun/star/i18n/NumberFormatIndex.hpp>
34#include <com/sun/star/beans/XPropertySet.hpp>
35#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
36#include <com/sun/star/sdbc/DataType.hpp>
37#include <com/sun/star/sdb/XQueriesSupplier.hpp>
38#include <com/sun/star/sdb/ErrorCondition.hpp>
39#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
40#include <com/sun/star/util/XNumberFormats.hpp>
41#include <com/sun/star/util/NumberFormat.hpp>
42#include <com/sun/star/i18n/KParseType.hpp>
43#include <com/sun/star/i18n/KParseTokens.hpp>
44#include <com/sun/star/i18n/CharacterClassification.hpp>
46#include <com/sun/star/util/DateTime.hpp>
47#include <com/sun/star/util/Time.hpp>
48#include <com/sun/star/util/Date.hpp>
60#include <rtl/ustrbuf.hxx>
79 bool lcl_saveConvertToNumber(
const Reference< XNumberFormatter > & _xFormatter,sal_Int32 _nKey,
const OUString& _sValue,
double& _nrValue)
84 _nrValue = _xFormatter->convertStringToNumber(_nKey, _sValue);
96 _pResetNode = _pNewNode;
109 OUString SetQuotation(
const OUString& rValue, std::u16string_view rQuote, std::u16string_view rQuoteToReplace)
113 return rQuote + rValue.replaceAll(rQuote, rQuoteToReplace) + rQuote;
130 if ( rParam.
xField->getPropertySetInfo()->hasPropertyByName( OMetaConnection::getPropMap().getNameByIndex(
PROPERTY_ID_REALNAME ) ) )
132 rParam.
xField->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex( nNamePropertyId ) ) >>= aFieldName;
138 if(!pSubTree->
count())
144 assert(pCol->
count() == 1);
148 switch (pSubTree->
count())
157 SAL_WARN(
"connectivity.parse",
"SQL: catalog and/or schema in column_ref in predicate");
160 SAL_WARN(
"connectivity.parse",
"columnMatchP: SQL grammar changed; column_ref has " << pSubTree->
count() <<
" children");
181 const Reference< XNumberFormatter >& _xFormatter,
const Reference< XPropertySet >& _xField,
182 OUString _sPredicateTableAlias,
184 bool _bIntl,
bool _bQuote, OUString _sDecSep,
bool _bPredicate,
bool _bParseToSDBC )
186 ,aMetaData( _rxConnection )
189 ,xFormatter(_xFormatter)
191 ,sPredicateTableAlias(
std::move(_sPredicateTableAlias))
193 ,sDecSep(
std::move(_sDecSep))
195 ,bInternational(_bIntl)
196 ,bPredicate(_bPredicate)
197 ,bParseToSDBCLevel( _bParseToSDBC )
204 Reference< XNumberFormatsSupplier > xSupplier(rParam.
xFormatter->getNumberFormatsSupplier());
205 Reference< XNumberFormatTypes > xTypes(xSupplier->getNumberFormats(), UNO_QUERY);
208 sal_Int32 nKey = xTypes->getFormatIndex(NumberFormatIndex::DATE_SYS_DDMMYYYY, rParam.
rLocale);
209 return rParam.
xFormatter->convertNumberToString(nKey, fDate);
216 Reference< XNumberFormatsSupplier > xSupplier(rParam.
xFormatter->getNumberFormatsSupplier());
217 Reference< XNumberFormatTypes > xTypes(xSupplier->getNumberFormats(), UNO_QUERY);
220 sal_Int32 nKey = xTypes->getFormatIndex(NumberFormatIndex::DATETIME_SYS_DDMMYYYY_HHMMSS, rParam.
rLocale);
221 return rParam.
xFormatter->convertNumberToString(nKey, fDateTime);
228 Reference< XNumberFormatsSupplier > xSupplier(rParam.
xFormatter->getNumberFormatsSupplier());
230 Reference< XNumberFormatTypes > xTypes(xSupplier->getNumberFormats(), UNO_QUERY);
233 sal_Int32 nKey = xTypes->getFormatIndex(NumberFormatIndex::TIME_HHMMSS, rParam.
rLocale);
234 return rParam.
xFormatter->convertNumberToString(nKey, fTime);
239 const Reference< XConnection >& _rxConnection,
245 rString, _rxConnection,
nullptr,
nullptr, OUString(),
247 pContext, _bIntl, _bQuote, OUString(
"."),
false );
252 const Reference< XConnection >& _rxConnection,
253 const Reference< XNumberFormatter > & xFormatter,
254 const css::lang::Locale& rIntl,
258 OSL_ENSURE(xFormatter.is(),
"OSQLParseNode::parseNodeToPredicateStr:: no formatter!");
261 parseNodeToStr(rString, _rxConnection, xFormatter,
nullptr, OUString(), rIntl, pContext,
true,
true, _sDec,
true);
266 const Reference< XConnection > & _rxConnection,
267 const Reference< XNumberFormatter > & xFormatter,
268 const Reference< XPropertySet > & _xField,
269 const OUString &_sPredicateTableAlias,
270 const css::lang::Locale& rIntl,
274 OSL_ENSURE(xFormatter.is(),
"OSQLParseNode::parseNodeToPredicateStr:: no formatter!");
277 parseNodeToStr( rString, _rxConnection, xFormatter, _xField, _sPredicateTableAlias, rIntl, pContext,
true,
true, _sDec,
true );
282 const Reference< XConnection > & _rxConnection,
283 const Reference< XNumberFormatter > & xFormatter,
284 const Reference< XPropertySet > & _xField,
285 const OUString &_sPredicateTableAlias,
286 const css::lang::Locale& rIntl,
291 bool _bPredicate)
const
293 OSL_ENSURE( _rxConnection.is(),
"OSQLParseNode::parseNodeToStr: invalid connection!" );
295 if ( !_rxConnection.is() )
298 OUStringBuffer sBuffer(rString);
303 _rxConnection, xFormatter, _xField, _sPredicateTableAlias, rIntl, pContext,
304 _bIntl, _bQuote, _sDecSep, _bPredicate,
false
307 catch(
const SQLException& )
309 SAL_WARN(
"connectivity.parse",
"OSQLParseNode::parseNodeToStr: this should not throw!" );
315 rString = sBuffer.makeStringAndClear();
319 OSQLParser& _rParser, css::sdbc::SQLException* _pErrorHolder )
const
321 OSL_PRECOND( _rxConnection.is(),
"OSQLParseNode::parseNodeToExecutableStatement: invalid connection!" );
327 Reference< XQueriesSupplier > xSuppQueries( _rxConnection, UNO_QUERY );
328 OSL_ENSURE( xSuppQueries.is(),
"OSQLParseNode::parseNodeToExecutableStatement: cannot substitute everything without a QueriesSupplier!" );
329 if ( xSuppQueries.is() )
330 aParseParam.
xQueries = xSuppQueries->getQueries();
333 aParseParam.
pParser = &_rParser;
337 Reference< XDatabaseMetaData > xMeta( _rxConnection->getMetaData() );
338 OUString sLimitValue;
340 && (xMeta->getURL().equalsIgnoreAsciiCase(
"sdbc:embedded:firebird")
341 || xMeta->getURL().startsWithIgnoreAsciiCase(
"sdbc:firebird:")))
347 _out_rString.clear();
348 OUStringBuffer sBuffer;
349 bool bSuccess =
false;
355 catch(
const SQLException& e )
361 if(sLimitValue.getLength() > 0)
363 constexpr char SELECT_KEYWORD[] =
"SELECT";
364 sBuffer.insert(sBuffer.indexOf(SELECT_KEYWORD) + strlen(SELECT_KEYWORD),
365 Concat2View(
" FIRST " + sLimitValue));
368 _out_rString = sBuffer.makeStringAndClear();
375 bool lcl_isAliasNamePresent(
const OSQLParseNode& _rTableNameNode )
393 bool bHandled =
false;
400 if(!rString.isEmpty())
403 m_aChildren[0]->impl_parseNodeToString_throw( rString, rParam,
false );
410 m_aChildren[0]->impl_parseNodeToString_throw( rString, rParam,
false );
416 m_aChildren[0]->impl_parseNodeToString_throw( rString, rParam,
false );
446 rString.append(
" AS ");
447 m_aChildren[1]->impl_parseNodeToString_throw( rString, rParam,
false );
478 m_aChildren[0]->impl_parseNodeToString_throw( rString, aNewParam,
false );
481 OUStringBuffer aStringPara;
491 aStringPara.append(
",");
496 rString.append(aStringPara);
529 aNewParam.
xField =
nullptr;
544 if (columnMatchP(pSubTree, rParam))
620 OSL_ENSURE(
getParent(),
"OSQLParseNode::impl_parseTableNameNodeToString_throw: table_name without parent?" );
635 bool bIsQuery = rParam.
xQueries->hasByName( sTableOrQueryName );
642 OSL_ENSURE( rParam.
pParser,
"OSQLParseNode::impl_parseTableNameNodeToString_throw: no parser?" );
646 rErrors.
raiseException( sdb::ErrorCondition::PARSER_CYCLIC_SUB_QUERIES );
651 aErrors.
raiseException( sdb::ErrorCondition::PARSER_CYCLIC_SUB_QUERIES );
656 Reference< XPropertySet > xQuery( rParam.
xQueries->getByName( sTableOrQueryName ), UNO_QUERY_THROW );
662 bool bEscapeProcessing =
false;
666 OSL_ENSURE( rParam.
pParser,
"OSQLParseNode::impl_parseTableNameNodeToString_throw: cannot analyze sub queries without a parser!" );
667 if ( bEscapeProcessing && rParam.
pParser )
670 std::unique_ptr< OSQLParseNode > pSubQueryNode( rParam.
pParser->
parseTree( sError, sCommand ) );
674 OUStringBuffer sSubSelect;
675 pSubQueryNode->impl_parseNodeToString_throw( sSubSelect, rParam,
false );
676 if ( !sSubSelect.isEmpty() )
677 sCommand = sSubSelect.makeStringAndClear();
681 rString.append(
" ( " );
682 rString.append(sCommand);
683 rString.append(
" )" );
687 if ( !lcl_isAliasNamePresent( *
this ) )
689 rString.append(
" AS " );
691 rString.append(SetQuotation( sTableOrQueryName,
702 catch(
const SQLException& )
716 OSL_PRECOND( (
count() == 2 ) || (
count() == 3 ) || (
count() == 5 ) ,
"Illegal count");
720 [&] (std::unique_ptr<OSQLParseNode>
const & pNode) { pNode->impl_parseNodeToString_throw(rString, rParam, false); });
727 OSL_ENSURE(
count() == 2,
"count != 2: Prepare for GPF");
736 m_aChildren[0]->impl_parseNodeToString_throw( rString, aNewParam, bSimple );
748 rString.append(SetQuotation(
aStr,
u"\'",
u"\'\'"));
758 css::uno::Any &_rCatalog,
761 const Reference< XDatabaseMetaData >& _xMetaData)
763 OSL_ENSURE(_pTableNode,
"Wrong use of getTableComponents! _pTableNode is not allowed to be null!");
766 const bool bSupportsCatalog = _xMetaData.is() && _xMetaData->supportsCatalogsInDataManipulation();
767 const bool bSupportsSchema = _xMetaData.is() && _xMetaData->supportsSchemasInDataManipulation();
778 pTableNode = pTableNode->
getChild(2);
783 if ( bSupportsCatalog && !bSupportsSchema )
787 pTableNode = pTableNode->
getChild(2);
796 SAL_WARN(
"connectivity.parse",
"Error in parse tree!");
799 return !_rTable.isEmpty();
829 case DataType::VARCHAR:
830 case DataType::LONGVARCHAR:
832 if ( !
SQL_ISRULE(pReturn,char_value_exp) && !buildStringNodes(pReturn) )
847 case DataType::VARCHAR:
848 case DataType::LONGVARCHAR:
853 case DataType::TIMESTAMP:
867 case DataType::TIMESTAMP:
882 case DataType::BOOLEAN:
883 case DataType::DECIMAL:
884 case DataType::NUMERIC:
885 case DataType::TINYINT:
886 case DataType::SMALLINT:
887 case DataType::INTEGER:
888 case DataType::BIGINT:
889 case DataType::FLOAT:
891 case DataType::DOUBLE:
896 case DataType::VARCHAR:
897 case DataType::LONGVARCHAR:
909 case DataType::DECIMAL:
910 case DataType::NUMERIC:
911 case DataType::FLOAT:
913 case DataType::DOUBLE:
918 case DataType::VARCHAR:
919 case DataType::LONGVARCHAR:
923 case DataType::INTEGER:
938 OSL_ENSURE(inPredicateCheck(),
"Only in predicate check allowed!");
957 nErg = buildNode(pAppend,pCompare,pNode1,pNode2);
988 case DataType::VARCHAR:
989 case DataType::LONGVARCHAR:
993 pAppend->
append(pLiteral);
1002 pAppend->
append(pLiteral);
1008 sal_Int16 nScale = 0;
1045 pNewNode->
append(pDateNode);
1050 case DataType::DATE:
1058 case DataType::TIME:
1066 case DataType::TIMESTAMP:
1069 if (aDateTime.Seconds || aDateTime.Minutes || aDateTime.Hours)
1077 Date aDate(aDateTime.Day,aDateTime.Month,aDateTime.Year);
1095 sal_Int16 nScale = 0;
1111 _pLiteral =
nullptr;
1125 ParseResult aResult =
m_xCharClass->parsePredefinedToken(KParseType::ANY_NUMBER,_rValue,0,
m_pData->aLocale,0,OUString(),KParseType::ANY_NUMBER,OUString());
1126 if((aResult.TokenType & KParseType::IDENTNAME) && aResult.EndPos == _rValue.getLength())
1128 aValue = OUString::number(aResult.Value);
1129 sal_Int32
nPos = aValue.lastIndexOf(
'.');
1130 if((
nPos+_nScale) < aValue.getLength())
1131 aValue = aValue.replaceAt(
nPos+_nScale,aValue.getLength()-
nPos-_nScale,
u"");
1133 aValue = aValue.replaceAt(aValue.lastIndexOf(
'.'), 1, sDecimalSeparator);
1147 static std::mutex
aMutex;
1153 const Reference< css::util::XNumberFormatter > & xFormatter,
1154 const Reference< XPropertySet > & xField,
1158 std::unique_lock aGuard(
getMutex());
1178 Reference< XPropertySetInfo> xInfo =
m_xField->getPropertySetInfo();
1215 Reference< css::util::XNumberFormatsSupplier > xFormatSup =
m_xFormatter->getNumberFormatsSupplier();
1216 if ( xFormatSup.is() )
1218 Reference< css::util::XNumberFormats > xFormats = xFormatSup->getNumberFormats();
1219 if ( xFormats.is() )
1221 css::lang::Locale aLocale;
1222 aLocale.Language =
"en";
1223 aLocale.Country =
"US";
1224 OUString sFormat(
"YYYY-MM-DD");
1233 SAL_WARN(
"connectivity.parse",
"DateFormatKey");
1239 case DataType::DATE:
1240 case DataType::TIME:
1241 case DataType::TIMESTAMP:
1244 case DataType::CHAR:
1245 case DataType::VARCHAR:
1246 case DataType::LONGVARCHAR:
1247 case DataType::CLOB:
1263 SQLyylval.pParseNode =
nullptr;
1285 (*s_pGarbageCollector)->clearAndDelete();
1292 (*s_pGarbageCollector)->clear();
1303 OSL_ENSURE(
m_pParseTree !=
nullptr,
"OSQLParser: Parser did not return a ParseTree!");
1310 :m_pContext(_pContext)
1313 ,m_nDateFormatKey(0)
1326 std::unique_lock aGuard(
getMutex());
1345 } aRuleDescriptions[] =
1449 const size_t nRuleMapCount = std::size( aRuleDescriptions );
1454 for (
const auto & aRuleDescription : aRuleDescriptions)
1457 sal_uInt32 nParserRuleID =
StrToRuleID( aRuleDescription.sRuleName );
1461 s_nRuleIDs[ aRuleDescription.eRule ] = nParserRuleID;
1476 std::unique_lock aGuard(
getMutex());
1477 OSL_ENSURE(
s_nRefCount > 0,
"OSQLParser::~OSQLParser() : suspicious call : has a refcount of 0 !");
1502 sal_Int32 nChildCount = pChildNode->
count();
1503 for(sal_Int32 j=1;j < nChildCount;++j)
1514 Reference< XNumberFormatsSupplier > xFormatSup =
m_xFormatter->getNumberFormatsSupplier();
1515 Reference< XNumberFormatTypes > xFormatTypes;
1516 if ( xFormatSup.is() )
1517 xFormatTypes.set(xFormatSup->getNumberFormats(), css::uno::UNO_QUERY);
1528 bool bSuccess = lcl_saveConvertToNumber(
m_xFormatter, nTryFormat, sValue, _rfValue );
1531 if ( !bSuccess && xFormatTypes.is() )
1535 nTryFormat = xFormatTypes->getStandardFormat( NumberFormat::DATE,
m_pData->aLocale );
1538 bSuccess = lcl_saveConvertToNumber(
m_xFormatter, nTryFormat, sValue, _rfValue );
1542 if ( !bSuccess && xFormatTypes.is() )
1546 nTryFormat = xFormatTypes->getFormatIndex( NumberFormatIndex::DATE_DIN_YYYYMMDD,
m_pData->aLocale );
1549 bSuccess = lcl_saveConvertToNumber(
m_xFormatter, nTryFormat, sValue, _rfValue );
1556 bSuccess = lcl_saveConvertToNumber(
m_xFormatter, nTryFormat, sValue, _rfValue );
1564 double fValue = 0.0;
1582 sal_uInt32 nNewNodeID)
1584 ,m_aNodeValue(pNewValue,strlen(pNewValue),RTL_TEXTENCODING_UTF8)
1585 ,m_eNodeType(eNewNodeType)
1586 ,m_nNodeID(nNewNodeID)
1593 sal_uInt32 nNewNodeID)
1595 ,m_aNodeValue(OStringToOUString(_rNewValue,RTL_TEXTENCODING_UTF8))
1596 ,m_eNodeType(eNewNodeType)
1597 ,m_nNodeID(nNewNodeID)
1604 sal_uInt32 nNewNodeID)
1606 ,m_aNodeValue(
std::move(_aNewValue))
1607 ,m_eNodeType(eNewNodeType)
1608 ,m_nNodeID(nNewNodeID)
1637 if (
this != &rParseNode)
1665 for (
size_t i=0; bResult &&
i <
count();
i++)
1679 OSL_ENSURE(pNewNode !=
nullptr,
"OSQLParseNode: invalid NewSubTree");
1680 OSL_ENSURE(pNewNode->
getParent() ==
nullptr,
"OSQLParseNode: Node is not an orphan");
1682 [&] (std::unique_ptr<OSQLParseNode>
const & r) { return r.get() == pNewNode; }),
1683 "OSQLParseNode::append() Node already element of parent");
1706 OUString suQuote(
"'");
1723 if (!rString.isEmpty())
1724 rString.append(
" ");
1725 rString.append(suQuote);
1726 const OUString sTokenValue = pODBCNode->
m_aChildren[1]->getTokenValue();
1739 rString.append(suQuote);
1779 pNewNode->
append(pLeftLeaf);
1781 pNewNode->
append(pRightLeaf);
1788 pNewNode->
append(pLeftLeaf);
1790 pNewNode->
append(pRightLeaf);
1796 if(!pSearchCondition)
1835 assert(pOldRight == pRight);
1841 replaceAndReset(pSearchCondition,pNewNode);
1855 assert(pOldLeft == pLeft);
1862 replaceAndReset(pSearchCondition,pNewNode);
1874 if(!pSearchCondition)
1893 replaceAndReset(pSearchCondition,pNewNode);
1913 replaceAndReset(pSearchCondition,pNewNode);
1929 replaceAndReset(pSearchCondition,pBooleanTest);
1938 assert(pSearchCondition->
count() == 3);
1942 assert(pComparison->
count() == 2 ||
1943 pComparison->
count() == 4);
1965 "OSQLParseNode::negateSearchCondition: unexpected node type!");
1993 sal_uInt32 nNotPos = 0;
2034 replaceAndReset(pSearchCondition,pNode);
2040 if(!pSearchCondition)
2053 sal_uInt32
nPos = 0;
2059 pNewNode = pSearchCondition->
removeAt(sal_uInt32(0));
2060 replaceAndReset(pSearchCondition,pNewNode);
2077 p2ndSearch = p2ndSearch->
getChild(1);
2081 pNewNode = pSearchCondition->
removeAt(sal_uInt32(0));
2082 replaceAndReset(pSearchCondition,pNewNode);
2087 pNewNode = pSearchCondition->
removeAt(sal_uInt32(2));
2088 replaceAndReset(pSearchCondition,pNewNode);
2107 replaceAndReset(pSearchCondition,pNode);
2115 pNewNode = pSearchCondition->
removeAt(sal_uInt32(0));
2116 replaceAndReset(pSearchCondition,pNewNode);
2120 pNewNode = pSearchCondition->
removeAt(sal_uInt32(0));
2121 replaceAndReset(pSearchCondition,pNewNode);
2129 pNewNode = pSearchCondition->
removeAt(sal_uInt32(2));
2130 replaceAndReset(pSearchCondition,pNewNode);
2134 pNewNode = pSearchCondition->
removeAt(sal_uInt32(2));
2135 replaceAndReset(pSearchCondition,pNewNode);
2143 if(!pSearchCondition)
2167 replaceAndReset(pSearchCondition,pNode);
2190 replaceAndReset(pSearchCondition,pNode);
2207 replaceAndReset(pSearchCondition,pNode);
2224 replaceAndReset(pSearchCondition,pNode);
2241 replaceAndReset(pSearchCondition,pNode);
2244#if OSL_DEBUG_LEVEL > 1
2248 OUStringBuffer
aBuf;
2250 rString =
aBuf.makeStringAndClear();
2256 for ( sal_uInt32 j=0; j<nLevel; ++j)
2257 _inout_rBuffer.appendAscii(
" " );
2262 _inout_rBuffer.appendAscii(
"RULE_ID: " );
2263 _inout_rBuffer.append( (sal_Int32)
getRuleID() );
2264 _inout_rBuffer.append(
'(' );
2266 _inout_rBuffer.append(
')' );
2267 _inout_rBuffer.append(
'\n' );
2271 child->showParseTree( _inout_rBuffer, nLevel+1 );
2280 _inout_rBuffer.appendAscii(
"SQL_KEYWORD: " );
2282 _inout_rBuffer.append(
'\n' );
2286 _inout_rBuffer.appendAscii(
"SQL_NAME: " );
2287 _inout_rBuffer.append(
'"' );
2289 _inout_rBuffer.append(
'"' );
2290 _inout_rBuffer.append(
'\n' );
2294 _inout_rBuffer.appendAscii(
"SQL_STRING: " );
2295 _inout_rBuffer.append(
'\'' );
2297 _inout_rBuffer.append(
'\'' );
2298 _inout_rBuffer.append(
'\n' );
2302 _inout_rBuffer.appendAscii(
"SQL_INTNUM: " );
2304 _inout_rBuffer.append(
'\n' );
2308 _inout_rBuffer.appendAscii(
"SQL_APPROXNUM: " );
2310 _inout_rBuffer.append(
'\n' );
2314 _inout_rBuffer.appendAscii(
"SQL_PUNCTUATION: " );
2316 _inout_rBuffer.append(
'\n' );
2326 _inout_rBuffer.append(
'\n' );
2330 _inout_rBuffer.appendAscii(
"SQL_ACCESS_DATE: " );
2332 _inout_rBuffer.append(
'\n' );
2336 _inout_rBuffer.appendAscii(
"||" );
2337 _inout_rBuffer.append(
'\n' );
2342 SAL_WARN(
"connectivity.parse",
"OSQLParser::ShowParseTree: unzulaessiger NodeType" );
2352 assert(pNewSubTree !=
nullptr &&
"OSQLParseNode: invalid NewSubTree");
2353 OSL_ENSURE(pNewSubTree->
getParent() ==
nullptr,
"OSQLParseNode: Node is not an orphan");
2366 auto pNode = std::move(*aPos);
2369 pNode->setParent(
nullptr );
2372 return pNode.release();
2379 assert(pOldSubNode !=
nullptr && pNewSubNode !=
nullptr &&
"OSQLParseNode: invalid nodes");
2380 assert(pOldSubNode != pNewSubNode &&
"OSQLParseNode: same node");
2381 assert(pNewSubNode->
getParent() ==
nullptr &&
"OSQLParseNode: node already has getParent");
2383 [&] (std::unique_ptr<OSQLParseNode>
const & r) { return r.get() == pOldSubNode; })
2384 &&
"OSQLParseNode::Replace() Node not element of parent");
2386 [&] (std::unique_ptr<OSQLParseNode>
const & r) { return r.get() == pNewSubNode; })
2387 &&
"OSQLParseNode::Replace() Node already element of parent");
2392 [&pOldSubNode](
const std::unique_ptr<OSQLParseNode>& rxChild) { return rxChild.get() == pOldSubNode; });
2394 it->reset(pNewSubNode);
2405 if (!rString.isEmpty())
2406 rString.append(
" ");
2409 rString.append(OStringToOUString(sT,RTL_TEXTENCODING_UTF8));
2412 if (!rString.isEmpty())
2413 rString.append(
" ");
2417 if (!rString.isEmpty())
2419 switch(rString[rString.getLength()-1])
2427 rString.append(
" ");
2435 rString.append(
"[");
2437 rString.append(
"]");
2447 if (!rString.isEmpty())
2448 rString.append(
" ");
2449 rString.append(
"#");
2451 rString.append(
"#");
2458 static constexpr OUStringLiteral strPoint(
u".");
2460 aTmp = aTmp.replaceAll(strPoint, rParam.
sDecSep);
2462 if (!rString.isEmpty())
2463 rString.append(
" ");
2464 rString.append(aTmp);
2477 switch( rString[rString.getLength() - 1] )
2485 rString.append(
" ");
2496 sal_Int32
nType = DataType::VARCHAR;
2499 if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_ASCII,pContext)))
nType = DataType::INTEGER;
2500 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_BIT_LENGTH,pContext)))
nType = DataType::INTEGER;
2501 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_CHAR,pContext)))
nType = DataType::VARCHAR;
2502 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_CHAR_LENGTH,pContext)))
nType = DataType::INTEGER;
2503 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_CONCAT,pContext)))
nType = DataType::VARCHAR;
2504 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_DIFFERENCE,pContext)))
nType = DataType::VARCHAR;
2505 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_INSERT,pContext)))
nType = DataType::VARCHAR;
2506 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_LCASE,pContext)))
nType = DataType::VARCHAR;
2507 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_LEFT,pContext)))
nType = DataType::VARCHAR;
2508 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_LENGTH,pContext)))
nType = DataType::INTEGER;
2509 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_LOCATE,pContext)))
nType = DataType::VARCHAR;
2510 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_LOCATE_2,pContext)))
nType = DataType::VARCHAR;
2511 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_LTRIM,pContext)))
nType = DataType::VARCHAR;
2512 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_OCTET_LENGTH,pContext)))
nType = DataType::INTEGER;
2513 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_POSITION,pContext)))
nType = DataType::INTEGER;
2514 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_REPEAT,pContext)))
nType = DataType::VARCHAR;
2515 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_REPLACE,pContext)))
nType = DataType::VARCHAR;
2516 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_RIGHT,pContext)))
nType = DataType::VARCHAR;
2517 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_RTRIM,pContext)))
nType = DataType::VARCHAR;
2518 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_SOUNDEX,pContext)))
nType = DataType::VARCHAR;
2519 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_SPACE,pContext)))
nType = DataType::VARCHAR;
2520 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_SUBSTRING,pContext)))
nType = DataType::VARCHAR;
2521 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_UCASE,pContext)))
nType = DataType::VARCHAR;
2522 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_CURRENT_DATE,pContext)))
nType = DataType::DATE;
2523 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_CURRENT_TIME,pContext)))
nType = DataType::TIME;
2524 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_CURRENT_TIMESTAMP,pContext)))
nType = DataType::TIMESTAMP;
2525 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_CURDATE,pContext)))
nType = DataType::DATE;
2526 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_DATEDIFF,pContext)))
nType = DataType::INTEGER;
2527 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_DATEVALUE,pContext)))
nType = DataType::DATE;
2528 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_CURTIME,pContext)))
nType = DataType::TIME;
2529 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_DAYNAME,pContext)))
nType = DataType::VARCHAR;
2530 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_DAYOFMONTH,pContext)))
nType = DataType::INTEGER;
2531 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_DAYOFWEEK,pContext)))
nType = DataType::INTEGER;
2532 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_DAYOFYEAR,pContext)))
nType = DataType::INTEGER;
2533 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_EXTRACT,pContext)))
nType = DataType::VARCHAR;
2534 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_HOUR,pContext)))
nType = DataType::INTEGER;
2535 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_MINUTE,pContext)))
nType = DataType::INTEGER;
2536 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_MONTH,pContext)))
nType = DataType::INTEGER;
2537 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_MONTHNAME,pContext)))
nType = DataType::VARCHAR;
2538 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_NOW,pContext)))
nType = DataType::TIMESTAMP;
2539 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_QUARTER,pContext)))
nType = DataType::INTEGER;
2540 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_SECOND,pContext)))
nType = DataType::INTEGER;
2541 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_TIMESTAMPADD,pContext)))
nType = DataType::TIMESTAMP;
2542 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_TIMESTAMPDIFF,pContext)))
nType = DataType::TIMESTAMP;
2543 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_TIMEVALUE,pContext)))
nType = DataType::TIMESTAMP;
2544 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_WEEK,pContext)))
nType = DataType::INTEGER;
2545 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_YEAR,pContext)))
nType = DataType::INTEGER;
2546 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_ABS,pContext)))
nType = DataType::DOUBLE;
2547 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_ACOS,pContext)))
nType = DataType::DOUBLE;
2548 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_ASIN,pContext)))
nType = DataType::DOUBLE;
2549 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_ATAN,pContext)))
nType = DataType::DOUBLE;
2550 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_ATAN2,pContext)))
nType = DataType::DOUBLE;
2551 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_CEILING,pContext)))
nType = DataType::DOUBLE;
2552 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_COS,pContext)))
nType = DataType::DOUBLE;
2553 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_COT,pContext)))
nType = DataType::DOUBLE;
2554 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_DEGREES,pContext)))
nType = DataType::DOUBLE;
2555 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_EXP,pContext)))
nType = DataType::DOUBLE;
2556 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_FLOOR,pContext)))
nType = DataType::DOUBLE;
2557 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_LOGF,pContext)))
nType = DataType::DOUBLE;
2558 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_LOG,pContext)))
nType = DataType::DOUBLE;
2559 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_LOG10,pContext)))
nType = DataType::DOUBLE;
2560 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_LN,pContext)))
nType = DataType::DOUBLE;
2561 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_MOD,pContext)))
nType = DataType::DOUBLE;
2562 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_PI,pContext)))
nType = DataType::DOUBLE;
2563 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_POWER,pContext)))
nType = DataType::DOUBLE;
2564 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_RADIANS,pContext)))
nType = DataType::DOUBLE;
2565 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_RAND,pContext)))
nType = DataType::DOUBLE;
2566 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_ROUND,pContext)))
nType = DataType::DOUBLE;
2567 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_ROUNDMAGIC,pContext)))
nType = DataType::DOUBLE;
2568 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_SIGN,pContext)))
nType = DataType::DOUBLE;
2569 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_SIN,pContext)))
nType = DataType::DOUBLE;
2570 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_SQRT,pContext)))
nType = DataType::DOUBLE;
2571 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_TAN,pContext)))
nType = DataType::DOUBLE;
2572 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_TRUNCATE,pContext)))
nType = DataType::DOUBLE;
2573 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_COUNT,pContext)))
nType = DataType::INTEGER;
2574 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_MAX,pContext)))
nType = DataType::DOUBLE;
2575 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_MIN,pContext)))
nType = DataType::DOUBLE;
2576 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_AVG,pContext)))
nType = DataType::DOUBLE;
2577 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_SUM,pContext)))
nType = DataType::DOUBLE;
2578 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_LOWER,pContext)))
nType = DataType::VARCHAR;
2579 else if(sFunctionName.equalsIgnoreAsciiCase(
TokenIDToStr(SQL_TOKEN_UPPER,pContext)))
nType = DataType::VARCHAR;
2586 sal_Int32
nType = DataType::VARCHAR;
2588 if(_nTokenId == SQL_TOKEN_CHAR)
nType = DataType::INTEGER;
2589 else if(_nTokenId == SQL_TOKEN_INSERT)
2592 nType = DataType::INTEGER;
2594 else if(_nTokenId == SQL_TOKEN_LEFT)
2597 nType = DataType::INTEGER;
2599 else if(_nTokenId == SQL_TOKEN_LOCATE)
2602 nType = DataType::INTEGER;
2604 else if(_nTokenId == SQL_TOKEN_LOCATE_2)
2607 nType = DataType::INTEGER;
2609 else if( _nTokenId == SQL_TOKEN_REPEAT || _nTokenId == SQL_TOKEN_RIGHT )
2612 nType = DataType::INTEGER;
2614 else if(_nTokenId == SQL_TOKEN_SPACE )
2616 nType = DataType::INTEGER;
2618 else if(_nTokenId == SQL_TOKEN_SUBSTRING)
2621 nType = DataType::INTEGER;
2623 else if(_nTokenId == SQL_TOKEN_DATEDIFF)
2626 nType = DataType::TIMESTAMP;
2628 else if(_nTokenId == SQL_TOKEN_DATEVALUE)
2629 nType = DataType::DATE;
2630 else if(_nTokenId == SQL_TOKEN_DAYNAME)
2631 nType = DataType::DATE;
2632 else if(_nTokenId == SQL_TOKEN_DAYOFMONTH)
2633 nType = DataType::DATE;
2634 else if(_nTokenId == SQL_TOKEN_DAYOFWEEK)
2635 nType = DataType::DATE;
2636 else if(_nTokenId == SQL_TOKEN_DAYOFYEAR)
2637 nType = DataType::DATE;
2638 else if(_nTokenId == SQL_TOKEN_EXTRACT)
nType = DataType::VARCHAR;
2639 else if(_nTokenId == SQL_TOKEN_HOUR)
nType = DataType::TIME;
2640 else if(_nTokenId == SQL_TOKEN_MINUTE)
nType = DataType::TIME;
2641 else if(_nTokenId == SQL_TOKEN_MONTH)
nType = DataType::DATE;
2642 else if(_nTokenId == SQL_TOKEN_MONTHNAME)
nType = DataType::DATE;
2643 else if(_nTokenId == SQL_TOKEN_NOW)
nType = DataType::TIMESTAMP;
2644 else if(_nTokenId == SQL_TOKEN_QUARTER)
nType = DataType::DATE;
2645 else if(_nTokenId == SQL_TOKEN_SECOND)
nType = DataType::TIME;
2646 else if(_nTokenId == SQL_TOKEN_TIMESTAMPADD)
nType = DataType::TIMESTAMP;
2647 else if(_nTokenId == SQL_TOKEN_TIMESTAMPDIFF)
nType = DataType::TIMESTAMP;
2648 else if(_nTokenId == SQL_TOKEN_TIMEVALUE)
nType = DataType::TIMESTAMP;
2649 else if(_nTokenId == SQL_TOKEN_WEEK)
nType = DataType::DATE;
2650 else if(_nTokenId == SQL_TOKEN_YEAR)
nType = DataType::DATE;
2652 else if(_nTokenId == SQL_TOKEN_ABS)
nType = DataType::DOUBLE;
2653 else if(_nTokenId == SQL_TOKEN_ACOS)
nType = DataType::DOUBLE;
2654 else if(_nTokenId == SQL_TOKEN_ASIN)
nType = DataType::DOUBLE;
2655 else if(_nTokenId == SQL_TOKEN_ATAN)
nType = DataType::DOUBLE;
2656 else if(_nTokenId == SQL_TOKEN_ATAN2)
nType = DataType::DOUBLE;
2657 else if(_nTokenId == SQL_TOKEN_CEILING)
nType = DataType::DOUBLE;
2658 else if(_nTokenId == SQL_TOKEN_COS)
nType = DataType::DOUBLE;
2659 else if(_nTokenId == SQL_TOKEN_COT)
nType = DataType::DOUBLE;
2660 else if(_nTokenId == SQL_TOKEN_DEGREES)
nType = DataType::DOUBLE;
2661 else if(_nTokenId == SQL_TOKEN_EXP)
nType = DataType::DOUBLE;
2662 else if(_nTokenId == SQL_TOKEN_FLOOR)
nType = DataType::DOUBLE;
2663 else if(_nTokenId == SQL_TOKEN_LOGF)
nType = DataType::DOUBLE;
2664 else if(_nTokenId == SQL_TOKEN_LOG)
nType = DataType::DOUBLE;
2665 else if(_nTokenId == SQL_TOKEN_LOG10)
nType = DataType::DOUBLE;
2666 else if(_nTokenId == SQL_TOKEN_LN)
nType = DataType::DOUBLE;
2667 else if(_nTokenId == SQL_TOKEN_MOD)
nType = DataType::DOUBLE;
2668 else if(_nTokenId == SQL_TOKEN_PI)
nType = DataType::DOUBLE;
2669 else if(_nTokenId == SQL_TOKEN_POWER)
nType = DataType::DOUBLE;
2670 else if(_nTokenId == SQL_TOKEN_RADIANS)
nType = DataType::DOUBLE;
2671 else if(_nTokenId == SQL_TOKEN_RAND)
nType = DataType::DOUBLE;
2672 else if(_nTokenId == SQL_TOKEN_ROUND)
nType = DataType::DOUBLE;
2673 else if(_nTokenId == SQL_TOKEN_ROUNDMAGIC)
nType = DataType::DOUBLE;
2674 else if(_nTokenId == SQL_TOKEN_SIGN)
nType = DataType::DOUBLE;
2675 else if(_nTokenId == SQL_TOKEN_SIN)
nType = DataType::DOUBLE;
2676 else if(_nTokenId == SQL_TOKEN_SQRT)
nType = DataType::DOUBLE;
2677 else if(_nTokenId == SQL_TOKEN_TAN)
nType = DataType::DOUBLE;
2678 else if(_nTokenId == SQL_TOKEN_TRUNCATE)
nType = DataType::DOUBLE;
2679 else if(_nTokenId == SQL_TOKEN_COUNT)
nType = DataType::INTEGER;
2680 else if(_nTokenId == SQL_TOKEN_MAX)
nType = DataType::DOUBLE;
2681 else if(_nTokenId == SQL_TOKEN_MIN)
nType = DataType::DOUBLE;
2682 else if(_nTokenId == SQL_TOKEN_AVG)
nType = DataType::DOUBLE;
2683 else if(_nTokenId == SQL_TOKEN_SUM)
nType = DataType::DOUBLE;
2685 else if(_nTokenId == SQL_TOKEN_LOWER)
nType = DataType::VARCHAR;
2686 else if(_nTokenId == SQL_TOKEN_UPPER)
nType = DataType::VARCHAR;
2709 OUString sTableRange;
2715 ,
"SQL grammar changed!");
2742 std::vector< OSQLParseNode* >::iterator aFind = std::find(
m_aNodes.begin(),
m_aNodes.end(),_pNode);
static double toDouble(std::string_view rString)
Reference< XComponentContext > m_xContext
virtual OUString getErrorMessage(ErrorCode _eCodes) const =0
virtual css::lang::Locale getPreferredLocale() const =0
gets a locale instance which should be used when parsing in the context specified by this instance
static const css::lang::Locale & getDefaultLocale()
void impl_parseTableRangeNodeToString_throw(OUStringBuffer &rString, const SQLParseNodeParameter &rParam) const
static void absorptions(OSQLParseNode *&pSearchCondition)
static void eraseBraces(OSQLParseNode *&pSearchCondition)
void impl_parseLikeNodeToString_throw(OUStringBuffer &rString, const SQLParseNodeParameter &rParam, bool bSimple=true) const
bool parseNodeToExecutableStatement(OUString &_out_rString, const css::uno::Reference< css::sdbc::XConnection > &_rxConnection, OSQLParser &_rParser, css::sdbc::SQLException *_pErrorHolder) const
parses the node to a string which can be passed to a driver's connection for execution
static void negateSearchCondition(OSQLParseNode *&pSearchCondition, bool bNegate=false)
static void disjunctiveNormalForm(OSQLParseNode *&pSearchCondition)
void parseNodeToStr(OUString &rString, const css::uno::Reference< css::sdbc::XConnection > &_rxConnection, const IParseContext *pContext=nullptr, bool _bIntl=false, bool _bQuote=true) const
void setParent(OSQLParseNode *pParseNode)
OSQLParseNode(const char *_pValueStr, SQLNodeType _eNodeType, sal_uInt32 _nNodeID=0)
OSQLParseNode & operator=(const OSQLParseNode &rParseNode)
void append(OSQLParseNode *pNewSubTree)
@ base_table_element_commalist
@ delete_statement_searched
@ between_predicate_part_2
@ other_like_predicate_part_2
@ ordering_spec_commalist
@ table_primary_as_range_column
@ update_statement_searched
@ parenthesized_boolean_value_expression
@ comparison_predicate_part_2
@ delete_statement_positioned
@ update_statement_positioned
bool addDateValue(OUStringBuffer &rString, const SQLParseNodeParameter &rParam) const
std::vector< std::unique_ptr< OSQLParseNode > > m_aChildren
void showParseTree(OUString &rString) const
static OUString convertDateTimeString(const SQLParseNodeParameter &rParam, const OUString &rString)
bool impl_parseTableNameNodeToString_throw(OUStringBuffer &rString, const SQLParseNodeParameter &rParam) const
parses a table_name node into a SQL statement particle.
sal_uInt32 getTokenID() const
bool operator==(OSQLParseNode const &rParseNode) const
static OUString getTableRange(const OSQLParseNode *_pTableRef)
return a table range when it exists.
static OUString convertDateString(const SQLParseNodeParameter &rParam, std::u16string_view rString)
static void substituteParameterNames(OSQLParseNode const *_pNode)
void replaceAndDelete(OSQLParseNode *pOldSubTree, OSQLParseNode *pNewSubTree)
Rule getKnownRuleID() const
returns the ID of the rule represented by the node If the node does not represent a rule,...
void parseNodeToPredicateStr(OUString &rString, const css::uno::Reference< css::sdbc::XConnection > &_rxConnection, const css::uno::Reference< css::util::XNumberFormatter > &xFormatter, const css::lang::Locale &rIntl, OUString _sDec, const IParseContext *pContext=nullptr) const
void impl_parseNodeToString_throw(OUStringBuffer &rString, const SQLParseNodeParameter &rParam, bool bSimple=true) const
OSQLParseNode * removeAt(sal_uInt32 nPos)
static bool getTableComponents(const OSQLParseNode *_pTableNode, css::uno::Any &_rCatalog, OUString &_rSchema, OUString &_rTable, const css::uno::Reference< css::sdbc::XDatabaseMetaData > &_xMetaData)
const OUString & getTokenValue() const
sal_uInt32 getRuleID() const
OSQLParseNode * getParent() const
void insert(sal_uInt32 nPos, OSQLParseNode *pNewSubTree)
static OUString convertTimeString(const SQLParseNodeParameter &rParam, std::u16string_view rString)
OSQLParseNode * getChild(sal_uInt32 nPos) const
static void compress(OSQLParseNode *&pSearchCondition)
OSQLParseNode * getByRule(OSQLParseNode::Rule eRule) const
OSQLParseNode * m_pParent
void parseLeaf(OUStringBuffer &rString, const SQLParseNodeParameter &rParam) const
SQLNodeType getNodeType() const
void replaceNodeValue(const OUString &rTableAlias, const OUString &rColumnName)
::std::vector< OSQLParseNode * > m_aNodes
OSQLParseNodesContainer()
void push_back(OSQLParseNode *_pNode)
void erase(OSQLParseNode *_pNode)
~OSQLParseNodesContainer()
void killThousandSeparator(OSQLParseNode *pLiteral)
bool extractDate(OSQLParseNode const *pLiteral, double &_rfValue)
friend class OSQLInternalNode
static sal_uInt32 s_nRuleIDs[OSQLParseNode::rule_count+1]
OUString stringToDouble(const OUString &_rValue, sal_Int16 _nScale)
static std::mutex & getMutex()
OSQLParseNode * buildNode_Date(const double &fValue, sal_Int32 nType)
css::uno::Reference< css::uno::XComponentContext > m_xContext
static sal_Int32 getFunctionParameterType(sal_uInt32 _nTokenId, sal_uInt32 _nPos)
css::uno::Reference< css::util::XNumberFormatter > m_xFormatter
css::uno::Reference< css::beans::XPropertySet > m_xField
static OSQLScanner * s_pScanner
static OSQLParseNode::Rule RuleIDToRule(sal_uInt32 _nRule)
static OParseContext s_aDefaultContext
static sal_Int32 s_nRefCount
static sal_Int32 getFunctionReturnType(std::u16string_view _sFunctionName, const IParseContext *pContext)
const SQLError & getErrorHelper() const
access to the SQLError instance owned by this parser
static OString TokenIDToStr(sal_uInt32 nTokenID, const IParseContext *pContext=nullptr)
static vcl::DeleteOnDeinit< css::uno::Reference< css::i18n::XLocaleData4 > > s_xLocaleData
::std::map< sal_uInt32, OSQLParseNode::Rule > RuleIDMap
std::unique_ptr< OSQLParseNode > predicateTree(OUString &rErrorMessage, const OUString &rStatement, const css::uno::Reference< css::util::XNumberFormatter > &xFormatter, const css::uno::Reference< css::beans::XPropertySet > &xField, bool bUseRealName=true)
static sal_uInt32 StrToRuleID(const OString &rValue)
OSQLParseNode * convertNode(sal_Int32 nType, OSQLParseNode *pLiteral)
OSQLParseNode * buildNode_STR_NUM(OSQLParseNode *&pLiteral)
std::unique_ptr< OSQLParseNode > parseTree(OUString &rErrorMessage, const OUString &rStatement, bool bInternational=false)
css::uno::Reference< css::i18n::XCharacterClassification > m_xCharClass
OSQLParseNode * buildDate(sal_Int32 _nType, OSQLParseNode *&pLiteral)
::std::unique_ptr< OSQLParser_Data > m_pData
static RuleIDMap s_aReverseRuleIDLookup
static OSQLParseNodesGarbageCollector * s_pGarbageCollector
OSQLParser(css::uno::Reference< css::uno::XComponentContext > xContext, const IParseContext *_pContext=nullptr)
const IParseContext * m_pContext
std::unique_ptr< OSQLParseNode > m_pParseTree
static OUString RuleIDToStr(sal_uInt32 nRuleID)
static sal_uInt32 RuleID(OSQLParseNode::Rule eRule)
sal_Int32 m_nDateFormatKey
static sal_Int32 GetENGRule()
static sal_Int32 GetGERRule()
static sal_Int32 GetSTRINGRule()
void prepareScan(const OUString &rNewStatement, const IParseContext *pContext, bool bInternational)
static sal_Int32 GetDATERule()
void setScanner(bool _bNull=false)
static sal_Int32 GetSQLRule()
void SetRule(sal_Int32 nRule)
const OUString & getErrorMessage() const
a class which provides helpers for working with SQLErrors
void raiseException(const ErrorCondition _eCondition, const css::uno::Reference< css::uno::XInterface > &_rxContext, const std::optional< OUString > &_rParamValue1=std::nullopt, const std::optional< OUString > &_rParamValue2=std::nullopt, const std::optional< OUString > &_rParamValue3=std::nullopt) const
throws an SQLException describing the given error condition
std::optional< T > set(Args &&... args)
#define DBG_UNHANDLED_EXCEPTION(...)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
Any getNumberFormatProperty(const Reference< XNumberFormatter > &_rxFormatter, sal_Int32 _nKey, const OUString &_rPropertyName)
comphelper::SingletonRef< OSQLParseNodesContainer > OSQLParseNodesGarbageCollector
::std::set< OUString > QueryNameSet
static OSQLParseNode * MakeANDNode(OSQLParseNode *pLeftLeaf, OSQLParseNode *pRightLeaf)
static OSQLParseNode * MakeORNode(OSQLParseNode *pLeftLeaf, OSQLParseNode *pRightLeaf)
std::shared_ptr< T > make_shared(Args &&... args)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
#define PROPERTY_ID_FORMATKEY
#define PROPERTY_ID_LOCALE
#define PROPERTY_ID_COMMAND
#define PROPERTY_ID_REALNAME
#define PROPERTY_ID_ESCAPEPROCESSING
OUString ConvertLikeToken(const ::connectivity::OSQLParseNode *pTokenNode, const ::connectivity::OSQLParseNode *pEscapeNode, bool bInternational)
void setParser(::connectivity::OSQLParser *)
#define SQL_ISRULE(pParseNode, eRule)
#define SQL_ISPUNCTUATION(pParseNode, aString)
#define SQL_ISTOKEN(pParseNode, token)
SQLParseNodeParameter(const css::uno::Reference< css::sdbc::XConnection > &_rxConnection, const css::uno::Reference< css::util::XNumberFormatter > &_xFormatter, const css::uno::Reference< css::beans::XPropertySet > &_xField, OUString _sPredicateTableAlias, const css::lang::Locale &_rLocale, const IParseContext *_pContext, bool _bIntl, bool _bQuote, OUString _sDecSep, bool _bPredicate, bool _bParseToSDBC)
should we create an SDBC-level statement (e.g. with substituted sub queries)?
::dbtools::DatabaseMetaData aMetaData
const IParseContext & m_rContext
const css::lang::Locale & rLocale
bool bPredicate
should we internationalize keywords and placeholders?
css::uno::Reference< css::beans::XPropertySet > xField
css::uno::Reference< css::util::XNumberFormatter > xFormatter
OUString sPredicateTableAlias
std::shared_ptr< QueryNameSet > pSubQueryHistory
css::uno::Reference< css::container::XNameAccess > xQueries
bool bParseToSDBCLevel
are we going to parse a mere predicate?
bool bInternational
should we quote identifiers?
const Reference< XComponentContext > & m_rContext