24#include <com/sun/star/sdbc/XColumnLocate.hpp>
27#include <com/sun/star/sdb/SQLFilterOperator.hpp>
33#include <sqlbison.hxx>
45 : m_pAnalyzer(pAnalyzer)
72 if (
SQL_ISRULE(pSQLParseNode,select_statement))
75 DBG_ASSERT(pSQLParseNode->
count() >= 4,
"OFILECursor: Error in Parse Tree");
78 DBG_ASSERT(pTableExp !=
nullptr,
"Error in Parse Tree");
84 if (
SQL_ISRULE(pSelection,scalar_exp_commalist) )
86 for (
size_t i = 0;
i < pSelection->
count();
i++)
89 if (
SQL_ISRULE(pColumnRef,general_set_fct) && pColumnRef->
count() != 4 )
97 pWhereClause = pTableExp->
getChild(1);
101 else if (
SQL_ISRULE(pSQLParseNode,update_statement_searched))
103 DBG_ASSERT(pSQLParseNode->
count() == 5,
"OFILECursor: Error in Parse Tree");
104 pWhereClause = pSQLParseNode->
getChild(4);
106 else if (
SQL_ISRULE(pSQLParseNode,delete_statement_searched))
109 pWhereClause = pSQLParseNode->
getChild(3);
118 DBG_ASSERT(pWhereClause->
count() == 2,
"OFILECursor: Error in Parse Tree");
121 DBG_ASSERT(pComparisonPredicate !=
nullptr,
"OFILECursor: Error in Parse Tree");
123 execute( pComparisonPredicate );
128 DBG_ASSERT(
SQL_ISRULE(pWhereClause,opt_where_clause),
"OPredicateCompiler: Error in Parse Tree");
136 if (pPredicateNode->
count() == 3 &&
142 else if ((
SQL_ISRULE(pPredicateNode,search_condition) ||
SQL_ISRULE(pPredicateNode,boolean_term))
144 pPredicateNode->
count() == 3)
157 OSL_FAIL(
"OPredicateCompiler: Error in Parse Tree");
160 else if (
SQL_ISRULE(pPredicateNode,boolean_factor))
165 else if (
SQL_ISRULE(pPredicateNode,comparison_predicate))
169 else if (
SQL_ISRULE(pPredicateNode,like_predicate))
173 else if (
SQL_ISRULE(pPredicateNode,between_predicate))
177 else if (
SQL_ISRULE(pPredicateNode,test_for_null))
181 else if(
SQL_ISRULE(pPredicateNode,num_value_exp))
193 OSL_FAIL(
"OPredicateCompiler: Error in Parse Tree num_value_exp");
208 OSL_FAIL(
"OPredicateCompiler: Error in Parse Tree num_value_exp");
220 DBG_ASSERT(pPredicateNode->
count() == 3,
"OFILECursor: Error in Parse Tree");
240 sal_Int32 ePredicateType( SQLFilterOperator::EQUAL );
244 ePredicateType = SQLFilterOperator::EQUAL;
246 ePredicateType = SQLFilterOperator::NOT_EQUAL;
248 ePredicateType = SQLFilterOperator::LESS;
250 ePredicateType = SQLFilterOperator::LESS_EQUAL;
252 ePredicateType = SQLFilterOperator::GREATER_EQUAL;
254 ePredicateType = SQLFilterOperator::GREATER;
256 OSL_FAIL(
"OPredicateCompiler::execute_COMPARE: unexpected node type!" );
266 DBG_ASSERT(pPredicateNode->
count() == 2,
"OFILECursor: Error in Parse Tree");
288 if (pOptEscape->
count() != 0)
290 if (pOptEscape->
count() != 2)
314 DBG_ASSERT(pPredicateNode->
count() == 2,
"OFILECursor: Error in Parse Tree");
338 pOperator =
new OOp_COMPARE(bNot ? SQLFilterOperator::GREATER_EQUAL : SQLFilterOperator::LESS);
341 if ( pColumnOp && pOb1 && pOb2 )
346 case DataType::VARCHAR:
347 case DataType::LONGVARCHAR:
351 case DataType::DECIMAL:
352 case DataType::NUMERIC:
356 case DataType::FLOAT:
360 case DataType::DOUBLE:
373 case DataType::TIMESTAMP:
391 DBG_ASSERT(pPredicateNode->
count() == 2,
"OFILECursor: Error in Parse Tree");
395 sal_Int32 ePredicateType;
397 ePredicateType = SQLFilterOperator::NOT_SQLNULL;
399 ePredicateType = SQLFilterOperator::SQLNULL;
402 OBoolOperator* pOperator = (ePredicateType == SQLFilterOperator::SQLNULL) ?
413 OUString aColumnName;
414 if (pPredicateNode->
count() == 1)
418 else if (pPredicateNode->
count() == 3)
429 STR_INVALID_COLUMNNAME,
430 "$columnname$", aColumnName
434 css::uno::Reference< css::beans::XPropertySet> xCol;
444 STR_INVALID_COLUMNNAME,
445 "$columnname$", aColumnName
455 else if (
SQL_ISRULE(pPredicateNode,parameter))
469 else if((pPredicateNode->
count() == 2) &&
510 else if(
SQL_ISRULE(pPredicateNode,set_fct_spec)
512 ||
SQL_ISRULE(pPredicateNode,char_substring_fct)
517 else if(
SQL_ISRULE(pPredicateNode,length_exp) )
536 for (
auto const&
code : rCodeList)
551 const bool bResult = pOperand->
isValid();
562 for (
auto const&
code : rCodeList)
584 DBG_ASSERT(pPredicateNode->
count() >= 4,
"OFILECursor: Error in Parse Tree");
602 OSL_ENSURE(pPredicateNode->
getChild(0)->
isToken(),
"The first one must be the name of the function!");
606 case SQL_TOKEN_CHAR_LENGTH:
607 case SQL_TOKEN_LENGTH:
608 case SQL_TOKEN_OCTET_LENGTH:
609 case SQL_TOKEN_ASCII:
610 case SQL_TOKEN_LCASE:
611 case SQL_TOKEN_LTRIM:
612 case SQL_TOKEN_RTRIM:
613 case SQL_TOKEN_SPACE:
614 case SQL_TOKEN_UCASE:
619 case SQL_TOKEN_CEILING:
621 case SQL_TOKEN_DEGREES:
623 case SQL_TOKEN_FLOOR:
624 case SQL_TOKEN_LOG10:
626 case SQL_TOKEN_RADIANS:
631 case SQL_TOKEN_DAYNAME:
632 case SQL_TOKEN_DAYOFMONTH:
633 case SQL_TOKEN_DAYOFWEEK:
634 case SQL_TOKEN_DAYOFYEAR:
636 case SQL_TOKEN_MINUTE:
637 case SQL_TOKEN_MONTH:
638 case SQL_TOKEN_MONTHNAME:
639 case SQL_TOKEN_QUARTER:
640 case SQL_TOKEN_SECOND:
647 case SQL_TOKEN_CHAR_LENGTH:
648 case SQL_TOKEN_LENGTH:
649 case SQL_TOKEN_OCTET_LENGTH:
652 case SQL_TOKEN_ASCII:
655 case SQL_TOKEN_LCASE:
659 case SQL_TOKEN_LTRIM:
662 case SQL_TOKEN_RTRIM:
665 case SQL_TOKEN_SPACE:
668 case SQL_TOKEN_UCASE:
683 case SQL_TOKEN_CEILING:
689 case SQL_TOKEN_DEGREES:
695 case SQL_TOKEN_FLOOR:
698 case SQL_TOKEN_LOG10:
704 case SQL_TOKEN_RADIANS:
719 case SQL_TOKEN_DAYOFWEEK:
722 case SQL_TOKEN_DAYOFMONTH:
725 case SQL_TOKEN_DAYOFYEAR:
728 case SQL_TOKEN_MONTH:
731 case SQL_TOKEN_DAYNAME:
734 case SQL_TOKEN_MONTHNAME:
737 case SQL_TOKEN_QUARTER:
746 case SQL_TOKEN_MINUTE:
749 case SQL_TOKEN_SECOND:
753 OSL_FAIL(
"Error in switch!");
757 case SQL_TOKEN_CONCAT:
758 case SQL_TOKEN_INSERT:
760 case SQL_TOKEN_LOCATE:
761 case SQL_TOKEN_LOCATE_2:
762 case SQL_TOKEN_REPEAT:
763 case SQL_TOKEN_REPLACE:
764 case SQL_TOKEN_RIGHT:
766 case SQL_TOKEN_ROUND:
769 case SQL_TOKEN_POWER:
770 case SQL_TOKEN_ATAN2:
772 case SQL_TOKEN_CURDATE:
773 case SQL_TOKEN_CURTIME:
779 for (
size_t i=0;
i < pList->
count(); ++
i)
787 case SQL_TOKEN_CONCAT:
790 case SQL_TOKEN_INSERT:
796 case SQL_TOKEN_LOCATE:
797 case SQL_TOKEN_LOCATE_2:
800 case SQL_TOKEN_REPEAT:
803 case SQL_TOKEN_REPLACE:
806 case SQL_TOKEN_RIGHT:
812 case SQL_TOKEN_ROUND:
819 case SQL_TOKEN_POWER:
822 case SQL_TOKEN_ATAN2:
828 case SQL_TOKEN_CURDATE:
831 case SQL_TOKEN_CURTIME:
841 OSL_FAIL(
"Error in switch!");
846 case SQL_TOKEN_SUBSTRING:
848 if ( pPredicateNode->
count() == 4 )
851 for (
size_t i=0;
i < pList->
count(); ++
i)
863 case SQL_TOKEN_POSITION:
865 if ( pPredicateNode->
count() == 4 )
868 for (
size_t i=0;
i < pList->
count(); ++
i)
static double toDouble(std::string_view rString)
css::util::Time getTime() const
OUString getString() const
css::util::Date getDate() const
css::util::DateTime getDateTime() const
sal_uInt32 getTokenID() const
const OUString & getTokenValue() const
OSQLParseNode * getChild(sal_uInt32 nPos) const
SQLNodeType getNodeType() const
OUString getResourceStringWithSubstitution(TranslateId pResId, const char *_pAsciiPatternToReplace, const OUString &_rStringToSubstitute) const
loads a string from the shared resource file, and replaces a given ASCII pattern with a given string
ACOS(X) Returns the arc cosine of X, that is, the value whose cosine is X.
ASIN(X) Returns the arc sine of X, that is, the value whose sine is X.
ATAN2(Y,X) Returns the arc tangent of the two variables X and Y.
ATAN(X) Returns the arc tangent of X, that is, the value whose tangent is X:
ABS(X) Returns the absolute value of X:
ASCII(str) Returns the ASCII code value of the leftmost character of the string str.
CEILING(X) Returns the smallest integer value not less than X:
LENGTH(str) OCTET_LENGTH(str) CHAR_LENGTH(str) CHARACTER_LENGTH(str) Returns the length of the string...
CHAR(N,...) CHAR() interprets the arguments as integers and returns a string consisting of the charac...
CONCAT(str1,str2,...) Returns the string that results from concatenating the arguments.
COS(X) Returns the cosine of X, where X is given in radians:
CURDATE() CURRENT_DATE Returns today's date as a value in 'YYYY-MM-DD' or YYYYMMDD format,...
CURTIME() CURRENT_TIME Returns the current time as a value in 'HH:MM:SS' or HHMMSS format,...
DAYNAME(date) Returns the name of the weekday for date:
DAYOFMONTH(date) Returns the day of the month for date, in the range 1 to 31:
DAYOFWEEK(date) Returns the weekday index for date (1 = Sunday, 2 = Monday, ... 7 = Saturday).
DAYOFYEAR(date) Returns the day of the year for date, in the range 1 to 366:
DEGREES(X) Returns the argument X, converted from radians to degrees:
EXP(X) Returns the value of e (the base of natural logarithms) raised to the power of X:
FLOOR(X) Returns the largest integer value not greater than X:
HOUR(time) Returns the hour for time, in the range 0 to 23:
INSERT(str,pos,len,newstr) Returns the string str, with the substring beginning at position pos and l...
LTRIM(str) Returns the string str with leading space characters removed:
LEFT(str,len) Returns the leftmost len characters from the string str:
LN(X) Returns the natural logarithm of X:
LOCATE(substr,str) POSITION(substr IN str) Returns the position of the first occurrence of substring ...
LOG10(X) Returns the base-10 logarithm of X:
LOG(X) LOG(B,X) If called with one parameter, this function returns the natural logarithm of X:
LCASE(str) LOWER(str) Returns the string str with all characters changed to lowercase according to th...
MINUTE(time) Returns the minute for time, in the range 0 to 59:
MOD(N,M) % Modulo (like the % operator in C).
MONTHNAME(date) Returns the name of the month for date:
MONTH(date) Returns the month for date, in the range 1 to 12:
NOW() Returns the current date and time as a value in 'YYYY-MM-DD HH:MM:SS' or YYYYMMDDHHMMSS format,...
PI() Returns the value of PI.
POWER(X,Y) Returns the value of X raised to the power of Y:
QUARTER(date) Returns the quarter of the year for date, in the range 1 to 4:
RTRIM(str) Returns the string str with trailing space characters removed:
RADIANS(X) Returns the argument X, converted from degrees to radians:
REPEAT(str,count) Returns a string consisting of the string str repeated count times.
REPLACE(str,from_str,to_str) Returns the string str with all occurrences of the string from_str repla...
RIGHT(str,len) Returns the rightmost len characters from the string str:
ROUND(X) ROUND(X,D) Returns the argument X, rounded to the nearest integer.
SECOND(time) Returns the second for time, in the range 0 to 59:
SIGN(X) Returns the sign of the argument as -1, 0, or 1, depending on whether X is negative,...
SIN(X) Returns the sine of X, where X is given in radians:
SPACE(N) Returns a string consisting of N space characters:
SQRT(X) Returns the non-negative square root of X:
SUBSTRING(str,pos) SUBSTRING(str FROM pos) Returns a substring from string str starting at position p...
TAN(X) Returns the tangent of X, where X is given in radians:
UCASE(str) UPPER(str) Returns the string str with all characters changed to uppercase according to th...
WEEK(date) WEEK(date,first) With a single argument, returns the week for date, in the range 0 to 53 (...
YEAR(date) Returns the year for date, in the range 1000 to 9999:
sal_Int32 getDBType() const
virtual void setValue(const ORowSetValue &_rVal)=0
virtual const ORowSetValue & getValue() const =0
void execute_LIKE(connectivity::OSQLParseNode const *pPredicateNode)
void execute_COMPARE(connectivity::OSQLParseNode const *pPredicateNode)
void execute_Fold(OSQLParseNode const *pPredicateNode)
void execute_ISNULL(connectivity::OSQLParseNode const *pPredicateNode)
OSQLAnalyzer * m_pAnalyzer
void start(connectivity::OSQLParseNode const *pSQLParseNode)
void executeFunction(OSQLParseNode const *pPredicateNode)
void execute_BETWEEN(connectivity::OSQLParseNode const *pPredicateNode)
OOperand * execute_Operand(connectivity::OSQLParseNode const *pPredicateNode)
OOperand * execute(connectivity::OSQLParseNode const *pPredicateNode)
css::uno::Reference< css::container::XNameAccess > m_orgColumns
sal_Int32 m_nParamCounter
virtual ~OPredicateCompiler() override
void evaluateSelection(OCodeList &rCodeList, ORowSetValueDecoratorRef const &_rVal)
bool evaluate(OCodeList &rCodeList)
OConnection * getConnection() const
static OOperandAttr * createOperandAttr(sal_Int32 _nPos, const css::uno::Reference< css::beans::XPropertySet > &_xCol)
special stop operand is appended when a list of arguments ends
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
std::vector< std::unique_ptr< OCode > > OCodeList
#define SQL_ISRULE(pParseNode, eRule)
#define ORDER_BY_CHILD_POS
#define TABLE_EXPRESSION_CHILD_COUNT
#define SQL_ISPUNCTUATION(pParseNode, aString)
#define SQL_ISTOKEN(pParseNode, token)