2 //--------------------------------------------------------------------------
4 // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 // Copyright 2008 by Sun Microsystems, Inc.
8 // OpenOffice.org - a multi-platform office productivity suite
10 // $RCSfile: sqlbison.y,v $
12 // $Revision: 1.66.6.5 $
14 // This file is part of OpenOffice.org.
16 // OpenOffice.org is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU Lesser General Public License version 3
18 // only, as published by the Free Software Foundation.
20 // OpenOffice.org is distributed in the hope that it will be useful,
21 // but WITHOUT ANY WARRANTY; without even the implied warranty of
22 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 // GNU Lesser General Public License version 3 for more details
24 // (a copy is included in the LICENSE file that accompanied this code).
26 // You should have received a copy of the GNU Lesser General Public License
27 // version 3 along with OpenOffice.org. If not, see
28 // <http://www.openoffice.org/license.html>
29 // for a copy of the LGPLv3 License.
31 //--------------------------------------------------------------------------
36 #ifndef _CONNECTIVITY_SQLNODE_HXX
37 #include <connectivity/sqlnode.hxx>
39 #ifndef _CONNECTIVITY_SQLPARSE_HXX
40 #include <connectivity/sqlparse.hxx>
42 #ifndef _CONNECTIVITY_SQLINTERNALNODE_HXX
43 #include <internalnode.hxx>
45 #ifndef _COM_SUN_STAR_LANG_LOCALE_HPP_
46 #include <com/sun/star/lang/Locale.hpp>
48 #ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
49 #include <com/sun/star/sdbc/DataType.hpp>
51 #ifndef _COM_SUN_STAR_UTIL_DATE_HPP_
52 #include <com/sun/star/util/Date.hpp>
54 #ifndef _COM_SUN_STAR_UTIL_DATETIME_HPP_
55 #include <com/sun/star/util/DateTime.hpp>
57 #ifndef _COM_SUN_STAR_UTIL_TIME_HPP_
58 #include <com/sun/star/util/Time.hpp>
60 #ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTER_HPP_
61 #include <com/sun/star/util/XNumberFormatter.hpp>
63 #ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATSSUPPLIER_HPP_
64 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
66 #ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATS_HPP_
67 #include <com/sun/star/util/XNumberFormats.hpp>
69 #ifndef _COM_SUN_STAR_UTIL_NUMBERFORMAT_HPP_
70 #include <com/sun/star/util/NumberFormat.hpp>
72 #ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTYPES_HPP_
73 #include <com/sun/star/util/XNumberFormatTypes.hpp>
75 #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
76 #include <com/sun/star/beans/XPropertySet.hpp>
78 #ifndef _COM_SUN_STAR_I18N_KPARSETYPE_HPP_
79 #include <com/sun/star/i18n/KParseType.hpp>
81 #ifndef _COM_SUN_STAR_I18N_KPARSETOKENS_HPP_
82 #include <com/sun/star/i18n/KParseTokens.hpp>
84 #ifndef _CONNECTIVITY_SQLSCAN_HXX
85 #include "sqlscan.hxx"
87 #ifndef _OSL_DIAGNOSE_H_
88 #include <osl/diagnose.h>
90 #ifndef _DBHELPER_DBCONVERSION_HXX_
91 #include "connectivity/dbconversion.hxx"
93 #include <rtl/ustrbuf.hxx>
96 #pragma GCC system_header
97 #elif defined __SUNPRO_CC
99 #elif defined _MSC_VER
100 #pragma warning(push, 1)
101 #pragma warning(disable:4273 4701 4706)
104 static ::rtl
::OUString aEmptyString
;
106 static connectivity
::OSQLInternalNode
* newNode
(const sal_Char
* pNewValue
,
107 const connectivity
::SQLNodeType eNodeType
,
108 const sal_uInt32 nNodeID
= 0)
110 OSL_TRACE
("connectivity: Rule Number: %d,%d",eNodeType
,nNodeID
);
111 return new connectivity
::OSQLInternalNode
(pNewValue
, eNodeType
, nNodeID
);
114 static connectivity
::OSQLInternalNode
* newNode
(const ::rtl
::OString
& _NewValue
,
115 const connectivity
::SQLNodeType eNodeType
,
116 const sal_uInt32 nNodeID
= 0)
118 OSL_TRACE
("connectivity: Rule Number: %d,%d",eNodeType
,nNodeID
);
119 return new connectivity
::OSQLInternalNode
(_NewValue
, eNodeType
, nNodeID
);
122 static connectivity
::OSQLInternalNode
* newNode
(const ::rtl
::OUString
& _NewValue
,
123 const connectivity
::SQLNodeType eNodeType
,
124 const sal_uInt32 nNodeID
= 0)
126 OSL_TRACE
("connectivity: Rule Number: %d,%d",eNodeType
,nNodeID
);
127 return new connectivity
::OSQLInternalNode
(_NewValue
, eNodeType
, nNodeID
);
131 // yyi ist die interne Nr. der Regel, die gerade reduziert wird.
132 // Ueber die Mapping-Tabelle yyrmap wird daraus eine externe Regel-Nr.
133 #define SQL_NEW_RULE newNode(aEmptyString, SQL_NODE_RULE, yyr1[yyn])
134 #define SQL_NEW_LISTRULE newNode(aEmptyString, SQL_NODE_LISTRULE, yyr1[yyn])
135 #define SQL_NEW_COMMALISTRULE newNode(aEmptyString, SQL_NODE_COMMALISTRULE, yyr1[yyn])
138 connectivity::OSQLParser
* xxx_pGLOBAL_SQLPARSER
;
140 #define YYERROR_VERBOSE
142 #define SQLyyerror(s) \
144 xxx_pGLOBAL_SQLPARSER
->error(s
); \
147 using namespace connectivity
;
148 #define SQLyylex xxx_pGLOBAL_SQLPARSER->SQLlex
150 /* symbolic tokens */
153 connectivity
::OSQLParseNode
* pParseNode
;
155 %type
<pParseNode
> '(' ')' ',' ':' ';' '?' '[' ']' '{' '}' '.'
157 %token
<pParseNode
> SQL_TOKEN_STRING SQL_TOKEN_ACCESS_DATE SQL_TOKEN_INT SQL_TOKEN_REAL_NUM
158 %token
<pParseNode
> SQL_TOKEN_INTNUM SQL_TOKEN_APPROXNUM SQL_TOKEN_NOT SQL_TOKEN_NAME
161 %nonassoc
<pParseNode
> SQL_TOKEN_UMINUS
165 /* literal keyword tokens */
167 %token
<pParseNode
> SQL_TOKEN_ALL SQL_TOKEN_ALTER SQL_TOKEN_AMMSC SQL_TOKEN_ANY SQL_TOKEN_AS SQL_TOKEN_ASC SQL_TOKEN_AT SQL_TOKEN_AUTHORIZATION SQL_TOKEN_AVG
169 %token
<pParseNode
> SQL_TOKEN_BETWEEN SQL_TOKEN_BIT SQL_TOKEN_BOTH SQL_TOKEN_BY
171 %token
<pParseNode
> SQL_TOKEN_CAST SQL_TOKEN_CHARACTER SQL_TOKEN_CHECK SQL_TOKEN_COLLATE SQL_TOKEN_COMMIT SQL_TOKEN_CONTINUE SQL_TOKEN_CONVERT SQL_TOKEN_COUNT SQL_TOKEN_CREATE SQL_TOKEN_CROSS
172 %token
<pParseNode
> SQL_TOKEN_CURRENT SQL_TOKEN_CURSOR
174 %token
<pParseNode
> SQL_TOKEN_DATE SQL_TOKEN_DATEVALUE SQL_TOKEN_DAY SQL_TOKEN_DEC SQL_TOKEN_DECIMAL SQL_TOKEN_DECLARE SQL_TOKEN_DEFAULT SQL_TOKEN_DELETE SQL_TOKEN_DESC
175 %token
<pParseNode
> SQL_TOKEN_DISTINCT SQL_TOKEN_DOUBLE SQL_TOKEN_DROP
177 %token
<pParseNode
> SQL_TOKEN_ESCAPE SQL_TOKEN_EXCEPT SQL_TOKEN_EXISTS SQL_TOKEN_FALSE SQL_TOKEN_FETCH SQL_TOKEN_FLOAT SQL_TOKEN_FOR SQL_TOKEN_FOREIGN SQL_TOKEN_FOUND SQL_TOKEN_FROM SQL_TOKEN_FULL
179 %token
<pParseNode
> SQL_TOKEN_GRANT SQL_TOKEN_GROUP SQL_TOKEN_HAVING SQL_TOKEN_IN SQL_TOKEN_INDICATOR SQL_TOKEN_INNER SQL_TOKEN_INTEGER SQL_TOKEN_INTO SQL_TOKEN_IS SQL_TOKEN_INTERSECT
181 %token
<pParseNode
> SQL_TOKEN_JOIN SQL_TOKEN_KEY SQL_TOKEN_LEADING SQL_TOKEN_LIKE SQL_TOKEN_LOCAL SQL_TOKEN_LOWER
182 %token
<pParseNode
> SQL_TOKEN_MAX SQL_TOKEN_MIN SQL_TOKEN_NATURAL SQL_TOKEN_NCHAR SQL_TOKEN_NULL SQL_TOKEN_NUMERIC
184 %token
<pParseNode
> SQL_TOKEN_OCTET_LENGTH SQL_TOKEN_OF SQL_TOKEN_ON SQL_TOKEN_OPTION SQL_TOKEN_ORDER SQL_TOKEN_OUTER
186 %token
<pParseNode
> SQL_TOKEN_PRECISION SQL_TOKEN_PRIMARY SQL_TOKEN_PRIVILEGES SQL_TOKEN_PROCEDURE SQL_TOKEN_PUBLIC
187 %token
<pParseNode
> SQL_TOKEN_REAL SQL_TOKEN_REFERENCES SQL_TOKEN_ROLLBACK
189 %token
<pParseNode
> SQL_TOKEN_SCHEMA SQL_TOKEN_SELECT SQL_TOKEN_SET SQL_TOKEN_SIZE SQL_TOKEN_SMALLINT SQL_TOKEN_SOME SQL_TOKEN_SQLCODE SQL_TOKEN_SQLERROR SQL_TOKEN_SUM
191 %token
<pParseNode
> SQL_TOKEN_TABLE SQL_TOKEN_TIME SQL_TOKEN_TIMESTAMP SQL_TOKEN_TIMEZONE_HOUR SQL_TOKEN_TIMEZONE_MINUTE SQL_TOKEN_TO SQL_TOKEN_TRAILING SQL_TOKEN_TRANSLATE SQL_TOKEN_TRIM SQL_TOKEN_TRUE SQL_TOKEN_UNION
192 %token
<pParseNode
> SQL_TOKEN_UNIQUE SQL_TOKEN_UNKNOWN SQL_TOKEN_UPDATE SQL_TOKEN_UPPER SQL_TOKEN_USAGE SQL_TOKEN_USER SQL_TOKEN_USING SQL_TOKEN_VALUES SQL_TOKEN_VIEW
193 %token
<pParseNode
> SQL_TOKEN_WHERE SQL_TOKEN_WITH SQL_TOKEN_WORK SQL_TOKEN_ZONE
196 %token
<pParseNode
> SQL_TOKEN_CALL SQL_TOKEN_D SQL_TOKEN_FN SQL_TOKEN_T SQL_TOKEN_TS SQL_TOKEN_OJ
197 /* string functions */
198 %token
<pParseNode
> SQL_TOKEN_ASCII SQL_TOKEN_BIT_LENGTH SQL_TOKEN_CHAR SQL_TOKEN_CHAR_LENGTH SQL_TOKEN_CHARACTER_LENGTH
199 %token
<pParseNode
> SQL_TOKEN_CONCAT
200 %token
<pParseNode
> SQL_TOKEN_DIFFERENCE SQL_TOKEN_INSERT SQL_TOKEN_LCASE SQL_TOKEN_LEFT SQL_TOKEN_LENGTH SQL_TOKEN_LOCATE
201 %token
<pParseNode
> SQL_TOKEN_LOCATE_2 SQL_TOKEN_LTRIM SQL_TOKEN_POSITION SQL_TOKEN_REPEAT SQL_TOKEN_REPLACE
202 %token
<pParseNode
> SQL_TOKEN_RIGHT SQL_TOKEN_RTRIM SQL_TOKEN_SOUNDEX SQL_TOKEN_SPACE SQL_TOKEN_SUBSTRING SQL_TOKEN_UCASE
204 /* time and date functions */
205 %token
<pParseNode
> SQL_TOKEN_CURRENT_DATE SQL_TOKEN_CURRENT_TIME SQL_TOKEN_CURRENT_TIMESTAMP SQL_TOKEN_CURDATE SQL_TOKEN_CURTIME
206 %token
<pParseNode
> SQL_TOKEN_DAYNAME SQL_TOKEN_DAYOFMONTH SQL_TOKEN_DAYOFWEEK SQL_TOKEN_DAYOFYEAR SQL_TOKEN_EXTRACT
207 %token
<pParseNode
> SQL_TOKEN_HOUR SQL_TOKEN_MINUTE SQL_TOKEN_MONTH SQL_TOKEN_MONTHNAME SQL_TOKEN_NOW SQL_TOKEN_QUARTER SQL_TOKEN_DATEDIFF
208 %token
<pParseNode
> SQL_TOKEN_SECOND SQL_TOKEN_TIMESTAMPADD SQL_TOKEN_TIMESTAMPDIFF SQL_TOKEN_TIMEVALUE SQL_TOKEN_WEEK SQL_TOKEN_YEAR
210 /* numeric functions */
211 %token
<pParseNode
> SQL_TOKEN_ABS SQL_TOKEN_ACOS SQL_TOKEN_ASIN SQL_TOKEN_ATAN SQL_TOKEN_ATAN2 SQL_TOKEN_CEILING
212 %token
<pParseNode
> SQL_TOKEN_COS SQL_TOKEN_COT SQL_TOKEN_DEGREES SQL_TOKEN_EXP SQL_TOKEN_FLOOR SQL_TOKEN_LOGF SQL_TOKEN_LOG SQL_TOKEN_LN
213 %token
<pParseNode
> SQL_TOKEN_LOG10 SQL_TOKEN_MOD SQL_TOKEN_PI SQL_TOKEN_POWER SQL_TOKEN_RADIANS SQL_TOKEN_RAND SQL_TOKEN_ROUNDMAGIC
214 %token
<pParseNode
> SQL_TOKEN_ROUND SQL_TOKEN_SIGN SQL_TOKEN_SIN SQL_TOKEN_SQRT SQL_TOKEN_TAN SQL_TOKEN_TRUNCATE
216 // computational operation
217 %token
<pParseNode
> SQL_TOKEN_EVERY SQL_TOKEN_INTERSECTION SQL_TOKEN_FUSION SQL_TOKEN_COLLECT SQL_TOKEN_VAR_POP SQL_TOKEN_VAR_SAMP
218 %token
<pParseNode
> SQL_TOKEN_STDDEV_SAMP SQL_TOKEN_STDDEV_POP
222 %left
<pParseNode
> SQL_TOKEN_OR
223 %left
<pParseNode
> SQL_TOKEN_AND
225 %left
<pParseNode
> SQL_LESSEQ SQL_GREATEQ SQL_NOTEQUAL SQL_LESS SQL_GREAT SQL_EQUAL
/* '<' '>' = <> < > <= >= != */
226 %left
<pParseNode
> '+' '-' SQL_CONCAT
227 %left
<pParseNode
> '*' '/'
228 %left SQL_TOKEN_NATURAL SQL_TOKEN_CROSS SQL_TOKEN_FULL SQL_TOKEN_LEFT SQL_TOKEN_RIGHT
235 %token
<pParseNode
> SQL_TOKEN_INVALIDSYMBOL
237 /*%type <pParseNode> sql_single_statement */
239 %type
<pParseNode
> sql
/*schema */
240 %type
<pParseNode
> column_def_opt_list column_def_opt table_constraint_def column_commalist
241 %type
<pParseNode
> view_def opt_with_check_option opt_column_commalist privilege_def
242 %type
<pParseNode
> opt_with_grant_option privileges operation_commalist operation
243 %type
<pParseNode
> grantee_commalist grantee opt_order_by_clause ordering_spec_commalist
244 %type
<pParseNode
> ordering_spec opt_asc_desc manipulative_statement commit_statement
245 %type
<pParseNode
> /*delete_statement_positioned*/ delete_statement_searched fetch_statement
246 %type
<pParseNode
> insert_statement values_or_query_spec
247 %type
<pParseNode
> rollback_statement select_statement_into opt_all_distinct
248 %type
<pParseNode
> /*update_statement_positioned*/ assignment_commalist assignment
249 %type
<pParseNode
> update_statement_searched target_commalist target opt_where_clause
250 %type
<pParseNode
> select_statement selection table_exp from_clause table_ref_commalist table_ref
251 %type
<pParseNode
> where_clause opt_group_by_clause column_ref_commalist opt_having_clause
252 %type
<pParseNode
> search_condition predicate comparison_predicate between_predicate
253 %type
<pParseNode
> like_predicate opt_escape test_for_null in_predicate
254 %type
<pParseNode
> all_or_any_predicate any_all_some existence_test subquery
255 %type
<pParseNode
> scalar_exp_commalist parameter_ref literal
256 %type
<pParseNode
> column_ref data_type column cursor parameter range_variable user
/*like_check*/
257 /* neue Regeln bei OJ */
258 %type
<pParseNode
> derived_column as_clause table_name num_primary term num_value_exp
259 %type
<pParseNode
> value_exp_primary num_value_fct unsigned_value_spec cast_spec set_fct_spec scalar_subquery
260 %type
<pParseNode
> position_exp extract_exp length_exp general_value_spec
261 %type
<pParseNode
> general_set_fct set_fct_type query_exp non_join_query_exp joined_table
262 %type
<pParseNode
> non_join_query_term non_join_query_primary simple_table
263 %type
<pParseNode
> table_value_const_list row_value_constructor row_value_const_list row_value_constructor_elem
264 %type
<pParseNode
> qualified_join value_exp query_term join_type outer_join_type join_condition boolean_term
265 %type
<pParseNode
> boolean_factor truth_value boolean_test boolean_primary named_columns_join join_spec
266 %type
<pParseNode
> cast_operand cast_target factor datetime_value_exp
/*interval_value_exp*/ datetime_term datetime_factor
267 %type
<pParseNode
> datetime_primary datetime_value_fct time_zone time_zone_specifier
/*interval_term*/ /*interval_qualifier*/
268 %type
<pParseNode
> /*start_field*/ non_second_datetime_field
/*end_field*/ /*single_datetime_field*/ extract_field datetime_field time_zone_field
269 %type
<pParseNode
> extract_source char_length_exp octet_length_exp bit_length_exp select_sublist string_value_exp
270 %type
<pParseNode
> char_value_exp concatenation char_factor char_primary string_value_fct char_substring_fct fold
271 %type
<pParseNode
> form_conversion char_translation trim_fct trim_operands trim_spec bit_value_fct bit_substring_fct op_column_commalist
272 %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
273 %type
<pParseNode
> function_arg_commalist3 string_function_3Argument function_arg_commalist4 string_function_4Argument function_arg_commalist2 string_function_1Argument string_function_2Argument
274 %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
275 %type
<pParseNode
> all query_primary sql_not for_length upper_lower comparison column_val cross_union
/*opt_schema_element_list*/
276 %type
<pParseNode
> /*op_authorization op_schema*/ nil_fkt schema_element base_table_def base_table_element base_table_element_commalist
277 %type
<pParseNode
> column_def odbc_fct_spec odbc_call_spec odbc_fct_type op_parameter union_statement
278 %type
<pParseNode
> op_odbc_call_parameter odbc_parameter_commalist odbc_parameter function_args_commalist function_arg
279 %type
<pParseNode
> catalog_name schema_name table_node numeric_function string_function function_name date_function table_primary_as_range_column opt_as
282 /* Parse Tree an OSQLParser zurueckliefern
283 * (der Zugriff ueber yyval nach Aufruf des Parsers scheitert,
286 sql_single_statement:
288 { xxx_pGLOBAL_SQLPARSER
->setParseTree
( $1 ); }
290 { xxx_pGLOBAL_SQLPARSER
->setParseTree
( $1 ); }
295 {$$ = SQL_NEW_LISTRULE;
297 pSqlParseTreeRoot = $1; -- obsolete - Ergebnis in yyval! rdm }
305 /* schema definition language */
306 /* Note: other ``sql:sal_Unicode() rules appear later in the grammar */
314 | SQL_TOKEN_AUTHORIZATION user
324 | SQL_TOKEN_NAME '.' SQL_TOKEN_NAME
328 $$->append($2 = newNode(".", SQL_NODE_PUNCTUATION));
334 SQL_TOKEN_CREATE SQL_TOKEN_SCHEMA op_schema op_authorization opt_schema_element_list
345 opt_schema_element_list:
346 /* empty * / {$$ = SQL_NEW_RULE;}
347 | schema_glement_list
352 {$$ = SQL_NEW_LISTRULE;
354 | schema_element_list schema_element
373 SQL_TOKEN_CREATE SQL_TOKEN_TABLE table_node
'(' base_table_element_commalist
')'
378 $$
->append
($4 = newNode
("(", SQL_NODE_PUNCTUATION
));
380 $$
->append
($6 = newNode
(")", SQL_NODE_PUNCTUATION
));}
383 base_table_element_commalist:
385 {$$
= SQL_NEW_COMMALISTRULE
;
387 | base_table_element_commalist
',' base_table_element
394 | table_constraint_def
398 column data_type column_def_opt_list
407 /* empty */ {$$
= SQL_NEW_LISTRULE
;}
408 | column_def_opt_list column_def_opt
418 | SQL_TOKEN_PRIMARY SQL_TOKEN_KEY
426 SQL_TOKEN_NOT SQL_TOKEN_NULL
431 | SQL_TOKEN_DEFAULT literal
435 | SQL_TOKEN_DEFAULT SQL_TOKEN_NULL
439 | SQL_TOKEN_DEFAULT SQL_TOKEN_USER
443 | SQL_TOKEN_DEFAULT nil_fkt
450 | SQL_TOKEN_CHECK
'(' search_condition
')'
453 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
455 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));}
456 | SQL_TOKEN_REFERENCES table_node
460 | SQL_TOKEN_REFERENCES table_node
'(' column_commalist
')'
464 $$
->append
($3 = newNode
("(", SQL_NODE_PUNCTUATION
));
466 $$
->append
($5 = newNode
(")", SQL_NODE_PUNCTUATION
));}
469 table_constraint_def:
470 unique_spec
'(' column_commalist
')'
473 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
475 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));}
476 | SQL_TOKEN_FOREIGN SQL_TOKEN_KEY
'(' column_commalist
')' SQL_TOKEN_REFERENCES table_node
480 $$
->append
($3 = newNode
("(", SQL_NODE_PUNCTUATION
));
482 $$
->append
($5 = newNode
(")", SQL_NODE_PUNCTUATION
));
485 | SQL_TOKEN_FOREIGN SQL_TOKEN_KEY
'(' column_commalist
')' SQL_TOKEN_REFERENCES table_node
'(' column_commalist
')'
489 $$
->append
($3 = newNode
("(", SQL_NODE_PUNCTUATION
));
491 $$
->append
($5 = newNode
(")", SQL_NODE_PUNCTUATION
));
494 $$
->append
($8 = newNode
("(", SQL_NODE_PUNCTUATION
));
496 $$
->append
($10 = newNode
(")", SQL_NODE_PUNCTUATION
));}
497 | SQL_TOKEN_CHECK
'(' search_condition
')'
500 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
502 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));}
505 /* empty */ {$$
= SQL_NEW_RULE
;}
506 |
'(' column_commalist
')'
508 $$
->append
($1 = newNode
("(", SQL_NODE_PUNCTUATION
));
510 $$
->append
($3 = newNode
(")", SQL_NODE_PUNCTUATION
));
514 column_commalist
',' column
518 {$$
= SQL_NEW_COMMALISTRULE
;
523 SQL_TOKEN_CREATE SQL_TOKEN_VIEW table_node opt_column_commalist SQL_TOKEN_AS select_statement opt_with_check_option
534 opt_with_check_option:
535 /* empty */ {$$
= SQL_NEW_RULE
;}
536 | SQL_TOKEN_WITH SQL_TOKEN_CHECK SQL_TOKEN_OPTION
543 opt_column_commalist:
544 /* empty */ {$$
= SQL_NEW_RULE
;}
545 |
'(' column_commalist
')'
547 $$
->append
($1 = newNode
("(", SQL_NODE_PUNCTUATION
));
549 $$
->append
($3 = newNode
(")", SQL_NODE_PUNCTUATION
));}
553 SQL_TOKEN_GRANT privileges SQL_TOKEN_ON table_node SQL_TOKEN_TO grantee_commalist
554 opt_with_grant_option
565 opt_with_grant_option:
566 /* empty */ {$$
= SQL_NEW_RULE
;}
567 | SQL_TOKEN_WITH SQL_TOKEN_GRANT SQL_TOKEN_OPTION
575 SQL_TOKEN_ALL SQL_TOKEN_PRIVILEGES
579 | operation_commalist
584 {$$
= SQL_NEW_COMMALISTRULE
;
586 | operation_commalist
',' operation
593 | SQL_TOKEN_INSERT opt_column_commalist
598 | SQL_TOKEN_UPDATE opt_column_commalist
602 | SQL_TOKEN_REFERENCES opt_column_commalist
612 {$$
= SQL_NEW_COMMALISTRULE
;
614 | grantee_commalist
',' grantee
624 /* module language */
627 /* empty */ {$$
= SQL_NEW_RULE
;}
628 | SQL_TOKEN_ORDER SQL_TOKEN_BY ordering_spec_commalist
635 ordering_spec_commalist:
637 {$$
= SQL_NEW_COMMALISTRULE
;
639 | ordering_spec_commalist
',' ordering_spec
645 /* SQL_TOKEN_INTNUM opt_asc_desc
650 predicate opt_asc_desc
655 | row_value_constructor_elem opt_asc_desc
669 manipulative_statement_list:
670 manipulative_statement
671 {$$ = SQL_NEW_LISTRULE;
673 | manipulative_statement_list manipulative_statement
684 /* manipulative statements */
686 sql: manipulative_statement
689 manipulative_statement:
691 /* | delete_statement_positioned*/
692 | delete_statement_searched
696 | select_statement_into
697 /* | update_statement_positioned*/
698 | update_statement_searched
700 |
'{' odbc_call_spec
'}'
703 $$
->append
($1 = newNode
("{", SQL_NODE_PUNCTUATION
));
705 $$
->append
($3 = newNode
("}", SQL_NODE_PUNCTUATION
));
711 | union_statement SQL_TOKEN_UNION all select_statement
721 SQL_TOKEN_COMMIT SQL_TOKEN_WORK
727 delete_statement_positioned:
728 SQL_TOKEN_DELETE SQL_TOKEN_FROM table_node SQL_TOKEN_WHERE SQL_TOKEN_CURRENT SQL_TOKEN_OF cursor
739 delete_statement_searched:
740 SQL_TOKEN_DELETE SQL_TOKEN_FROM table_node opt_where_clause
749 SQL_TOKEN_FETCH cursor SQL_TOKEN_INTO target_commalist
758 SQL_TOKEN_INSERT SQL_TOKEN_INTO table_node opt_column_commalist values_or_query_spec
766 values_or_query_spec:
767 SQL_TOKEN_VALUES
'(' table_value_const_list
')'
770 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
772 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));
776 table_value_const_list:
777 row_value_constructor
778 {$$
= SQL_NEW_COMMALISTRULE
;
780 | table_value_const_list
',' row_value_constructor
784 row_value_const_list:
785 row_value_constructor_elem
786 {$$
= SQL_NEW_COMMALISTRULE
;
788 | row_value_const_list
',' row_value_constructor_elem
792 row_value_constructor:
793 row_value_constructor_elem
794 /* | '(' row_value_const_list ')'
797 $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
799 $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
803 row_value_constructor_elem:
810 SQL_TOKEN_ROLLBACK SQL_TOKEN_WORK
817 /* INTO target_commalist herausgenommen */
818 select_statement_into:
819 SQL_TOKEN_SELECT opt_all_distinct selection SQL_TOKEN_INTO target_commalist table_exp
836 update_statement_positioned:
837 SQL_TOKEN_UPDATE table_node SQL_TOKEN_SET assignment_commalist
838 SQL_TOKEN_WHERE SQL_TOKEN_CURRENT SQL_TOKEN_OF cursor
850 assignment_commalist:
852 {$$
= SQL_NEW_COMMALISTRULE
;
854 | assignment_commalist
',' assignment
860 column SQL_EQUAL update_source
870 update_statement_searched:
871 SQL_TOKEN_UPDATE table_node SQL_TOKEN_SET assignment_commalist opt_where_clause
882 {$$
= SQL_NEW_COMMALISTRULE
;
884 | target_commalist
',' target
894 /* empty */ {$$
= SQL_NEW_RULE
;}
898 /* query expressions */
907 /* SELECT STATEMENT */
909 SQL_TOKEN_SELECT opt_all_distinct selection table_exp
923 $$
->append
($1 = newNode
("*", SQL_NODE_PUNCTUATION
));
925 | scalar_exp_commalist
943 SQL_TOKEN_FROM table_ref_commalist
952 {$$
= SQL_NEW_COMMALISTRULE
;
954 | table_ref_commalist
',' table_ref
960 /* empty */ {$$
= SQL_NEW_RULE
;}
963 table_primary_as_range_column:
965 | opt_as SQL_TOKEN_NAME op_column_commalist
973 table_node table_primary_as_range_column
979 | subquery range_variable op_column_commalist
987 |
'{' SQL_TOKEN_OJ joined_table
'}'
990 $$
->append
($1 = newNode
("{", SQL_NODE_PUNCTUATION
));
993 $$
->append
($4 = newNode
("}", SQL_NODE_PUNCTUATION
));
995 |
'(' joined_table
')'
998 $$
->append
($1 = newNode
("(", SQL_NODE_PUNCTUATION
));
1000 $$
->append
($3 = newNode
(")", SQL_NODE_PUNCTUATION
));
1004 SQL_TOKEN_WHERE search_condition
1010 opt_group_by_clause:
1011 /* empty */ {$$
= SQL_NEW_RULE
;}
1012 | SQL_TOKEN_GROUP SQL_TOKEN_BY column_ref_commalist
1019 column_ref_commalist:
1021 {$$
= SQL_NEW_COMMALISTRULE
;
1024 {$$
= SQL_NEW_COMMALISTRULE
;
1026 | column_ref_commalist
',' column_ref
1029 | column_ref_commalist
',' set_fct_spec
1035 /* empty */ {$$
= SQL_NEW_RULE
;}
1036 | SQL_TOKEN_HAVING search_condition
1042 /* search conditions */
1051 |
'(' search_condition
')'
1052 { // boolean_primary: rule 2
1054 $$
->append
($1 = newNode
("(", SQL_NODE_PUNCTUATION
));
1056 $$
->append
($3 = newNode
(")", SQL_NODE_PUNCTUATION
));
1058 | row_value_constructor_elem
/*[^')' ',']*/
1060 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
())// boolean_primary: rule 3
1063 sal_Int16 nErg
= xxx_pGLOBAL_SQLPARSER
->buildComparsionRule
($$
,$1);
1066 OSQLParseNode
* pTemp
= $$
;
1067 $$
= pTemp
->removeAt
((sal_uInt32
)0);
1086 | boolean_primary SQL_TOKEN_IS sql_not truth_value
1097 | SQL_TOKEN_NOT boolean_test
1098 { // boolean_factor: rule 1
1106 | boolean_term SQL_TOKEN_AND boolean_factor
1108 $$
= SQL_NEW_RULE
; // boolean_term: rule 1
1116 | search_condition SQL_TOKEN_OR boolean_term
1118 $$
= SQL_NEW_RULE
; // search_condition
1125 comparison_predicate
1127 | all_or_any_predicate
1135 comparison_predicate:
1136 row_value_constructor comparison row_value_constructor
1138 $$
= SQL_NEW_RULE
; // comparison_predicate: rule 1
1143 | comparison row_value_constructor
1145 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
()) // comparison_predicate: rule 2
1148 sal_Int16 nErg
= xxx_pGLOBAL_SQLPARSER
->buildPredicateRule
($$
,$2,$1);
1151 OSQLParseNode
* pTemp
= $$
;
1152 $$
= pTemp
->removeAt
((sal_uInt32
)0);
1176 row_value_constructor sql_not SQL_TOKEN_BETWEEN row_value_constructor SQL_TOKEN_AND row_value_constructor
1177 {$$
= SQL_NEW_RULE
; // between_predicate: rule 1
1185 | sql_not SQL_TOKEN_BETWEEN row_value_constructor SQL_TOKEN_AND row_value_constructor
1187 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
()) // between_predicate: rule 2
1191 sal_Int16 nErg
= xxx_pGLOBAL_SQLPARSER
->buildPredicateRule
($$
,$3,$2,$5);
1194 OSQLParseNode
* pTemp
= $$
;
1195 $$
= pTemp
->removeAt
((sal_uInt32
)0);
1212 row_value_constructor SQL_TOKEN_NOT SQL_TOKEN_LIKE string_value_exp opt_escape
1214 $$
= SQL_NEW_RULE
; // like_predicate: rule 1
1221 | row_value_constructor SQL_TOKEN_LIKE string_value_exp opt_escape
1223 $$
= SQL_NEW_RULE
; // like_predicate: rule 2
1229 | row_value_constructor SQL_TOKEN_NOT SQL_TOKEN_LIKE value_exp_primary opt_escape
1231 $$
= SQL_NEW_RULE
; // like_predicate: rule 3
1238 | row_value_constructor SQL_TOKEN_LIKE value_exp_primary opt_escape
1240 $$
= SQL_NEW_RULE
; // like_predicate: rule 4
1246 | sql_not SQL_TOKEN_LIKE string_value_exp opt_escape
1248 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
()) // like_predicate: rule 5
1250 OSQLParseNode
* pColumnRef
= newNode
(aEmptyString
, SQL_NODE_RULE
,OSQLParser
::RuleID
(OSQLParseNode
::column_ref
));
1251 pColumnRef
->append
(newNode
(xxx_pGLOBAL_SQLPARSER
->getFieldName
(),SQL_NODE_NAME
));
1254 $$
->append
(pColumnRef
);
1257 if
(xxx_pGLOBAL_SQLPARSER
->buildLikeRule
($$
,$3,$4))
1268 | sql_not SQL_TOKEN_LIKE value_exp_primary opt_escape
1270 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
()) // like_predicate: rule 6
1272 OSQLParseNode
* pColumnRef
= newNode
(aEmptyString
, SQL_NODE_RULE
,OSQLParser
::RuleID
(OSQLParseNode
::column_ref
));
1273 pColumnRef
->append
(newNode
(xxx_pGLOBAL_SQLPARSER
->getFieldName
(),SQL_NODE_NAME
));
1276 $$
->append
(pColumnRef
);
1279 if
(xxx_pGLOBAL_SQLPARSER
->buildLikeRule
($$
,$3,$4))
1293 /* empty */ {$$
= SQL_NEW_RULE
;}
1294 | SQL_TOKEN_ESCAPE string_value_exp
1298 |
'{' SQL_TOKEN_ESCAPE SQL_TOKEN_STRING
'}'
1301 $$
->append
($1 = newNode
("{", SQL_NODE_PUNCTUATION
));
1304 $$
->append
($4 = newNode
("}", SQL_NODE_PUNCTUATION
));
1309 row_value_constructor SQL_TOKEN_IS sql_not truth_value
1311 $$
= SQL_NEW_RULE
; // test_for_null: rule 1
1317 | SQL_TOKEN_IS sql_not truth_value
1319 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
())// test_for_null: rule 2
1321 OSQLParseNode
* pColumnRef
= newNode
(aEmptyString
, SQL_NODE_RULE
,OSQLParser
::RuleID
(OSQLParseNode
::column_ref
));
1322 pColumnRef
->append
(newNode
(xxx_pGLOBAL_SQLPARSER
->getFieldName
(),SQL_NODE_NAME
));
1325 $$
->append
(pColumnRef
);
1339 |
'(' value_exp_commalist
')'
1341 $$
->append
($1 = newNode
("(", SQL_NODE_PUNCTUATION
));
1343 $$
->append
($3 = newNode
(")", SQL_NODE_PUNCTUATION
));
1347 row_value_constructor sql_not SQL_TOKEN_IN in_predicate_value
1349 $$
= SQL_NEW_RULE
;// in_predicate: rule 1
1355 | sql_not SQL_TOKEN_IN in_predicate_value
1357 if
( xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
() )// in_predicate: rule 2
1359 OSQLParseNode
* pColumnRef
= newNode
(aEmptyString
, SQL_NODE_RULE
,OSQLParser
::RuleID
(OSQLParseNode
::column_ref
));
1360 pColumnRef
->append
(newNode
(xxx_pGLOBAL_SQLPARSER
->getFieldName
(),SQL_NODE_NAME
));
1363 $$
->append
(pColumnRef
);
1373 all_or_any_predicate:
1374 row_value_constructor comparison any_all_some subquery
1382 | comparison any_all_some subquery
1384 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
())
1386 OSQLParseNode
* pColumnRef
= newNode
(aEmptyString
, SQL_NODE_RULE
,OSQLParser
::RuleID
(OSQLParseNode
::column_ref
));
1387 pColumnRef
->append
(newNode
(xxx_pGLOBAL_SQLPARSER
->getFieldName
(),SQL_NODE_NAME
));
1390 $$
->append
(pColumnRef
);
1407 SQL_TOKEN_EXISTS subquery
1413 SQL_TOKEN_UNIQUE subquery
1421 $$
->append
($1 = newNode
("(", SQL_NODE_PUNCTUATION
));
1423 $$
->append
($3 = newNode
(")", SQL_NODE_PUNCTUATION
));}
1426 /* scalar expressions */
1427 scalar_exp_commalist:
1430 $$
= SQL_NEW_COMMALISTRULE
;
1433 | scalar_exp_commalist
',' select_sublist
1440 /* table_node '.' '*'
1444 $$->append($2 = newNode(".", SQL_NODE_PUNCTUATION));
1445 $$->append($3 = newNode("*", SQL_NODE_PUNCTUATION));
1460 $$ = newNode("*", SQL_NODE_PUNCTUATION);
1464 $$ = newNode("?", SQL_NODE_PUNCTUATION);
1470 $$->append($2 = newNode("*", SQL_NODE_PUNCTUATION));
1471 xxx_pGLOBAL_SQLPARSER->reduceLiteral($$, sal_False);
1477 $$->append($2 = newNode("?", SQL_NODE_PUNCTUATION));
1478 xxx_pGLOBAL_SQLPARSER->reduceLiteral($$, sal_False);
1486 | SQL_TOKEN_REAL_NUM
1488 | SQL_TOKEN_APPROXNUM
1489 | SQL_TOKEN_ACCESS_DATE
1490 /* rules for predicate check */
1491 | literal SQL_TOKEN_STRING
1493 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
())
1498 xxx_pGLOBAL_SQLPARSER
->reduceLiteral
($$
, sal_True
);
1503 | literal SQL_TOKEN_INT
1505 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
())
1510 xxx_pGLOBAL_SQLPARSER
->reduceLiteral
($$
, sal_True
);
1515 | literal SQL_TOKEN_REAL_NUM
1517 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
())
1522 xxx_pGLOBAL_SQLPARSER
->reduceLiteral
($$
, sal_True
);
1527 | literal SQL_TOKEN_APPROXNUM
1529 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
())
1534 xxx_pGLOBAL_SQLPARSER
->reduceLiteral
($$
, sal_True
);
1543 /* empty */ {$$
= SQL_NEW_RULE
;}
1544 | SQL_TOKEN_AS column
1553 SQL_TOKEN_POSITION
'(' value_exp SQL_TOKEN_IN value_exp
')'
1557 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
1561 $$
->append
($6 = newNode
(")", SQL_NODE_PUNCTUATION
));
1563 | SQL_TOKEN_POSITION
'(' value_exp_commalist
')'
1567 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
1569 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));
1578 SQL_TOKEN_CHAR_LENGTH
'(' value_exp
')'
1582 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
1584 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));
1586 | SQL_TOKEN_CHARACTER_LENGTH
'(' value_exp
')'
1590 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
1592 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));
1597 SQL_TOKEN_OCTET_LENGTH
'(' value_exp
')'
1601 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
1603 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));
1607 SQL_TOKEN_BIT_LENGTH
'(' value_exp
')'
1611 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
1613 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));
1634 non_second_datetime_field
1651 SQL_TOKEN_TIMEZONE_HOUR
1656 | SQL_TOKEN_TIMEZONE_MINUTE
1668 /* | interval_value_exp
1675 SQL_TOKEN_EXTRACT
'(' extract_field SQL_TOKEN_FROM value_exp
')'
1679 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
1683 $$
->append
($6 = newNode
(")", SQL_NODE_PUNCTUATION
));
1686 unsigned_value_spec:
1699 |
'{' odbc_fct_spec
'}'
1702 $$
->append
($1 = newNode
("{", SQL_NODE_PUNCTUATION
));
1704 $$
->append
($3 = newNode
("}", SQL_NODE_PUNCTUATION
));
1706 | function_name
'(' ')'
1710 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
1711 $$
->append
($3 = newNode
(")", SQL_NODE_PUNCTUATION
));
1713 | function_name0
'(' ')'
1717 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
1718 $$
->append
($3 = newNode
(")", SQL_NODE_PUNCTUATION
));
1720 | function_name1
'(' function_arg
')'
1724 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
1726 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));
1728 | function_name2
'(' function_arg_commalist2
')'
1732 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
1734 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));
1736 | function_name3
'(' function_arg_commalist3
')'
1740 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
1742 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));
1744 | string_function_4Argument
'(' function_arg_commalist4
')'
1748 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
1750 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));
1752 | function_name
'(' function_args_commalist
')'
1756 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
1758 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));
1760 | function_name12
'(' function_args_commalist
')'
1762 if
( $3->count
() == 1 ||
$3->count
() == 2 )
1766 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
1768 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));
1773 | function_name23
'(' function_args_commalist
')'
1775 if
( $3->count
() == 2 ||
$3->count
() == 3)
1779 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
1781 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));
1788 date_function_0Argument
1789 | numeric_function_0Argument
1792 string_function_1Argument
1793 | date_function_1Argument
1794 | numeric_function_1Argument
1797 string_function_2Argument
1798 | numeric_function_2Argument
1810 string_function_3Argument
1811 | date_function_3Argument
1819 string_function_1Argument:
1829 string_function_2Argument:
1834 string_function_3Argument:
1837 string_function_4Argument:
1844 | SQL_TOKEN_DIFFERENCE
1845 | SQL_TOKEN_LOCATE_2
1848 date_function_0Argument:
1853 date_function_1Argument:
1855 | SQL_TOKEN_DAYOFMONTH
1856 | SQL_TOKEN_DAYOFYEAR
1859 | SQL_TOKEN_MONTHNAME
1866 | SQL_TOKEN_TIMEVALUE
1867 | SQL_TOKEN_DATEVALUE
1869 date_function_3Argument:
1873 SQL_TOKEN_TIMESTAMPADD
1874 | SQL_TOKEN_TIMESTAMPDIFF
1876 numeric_function_0Argument:
1879 numeric_function_1Argument:
1897 | SQL_TOKEN_ROUNDMAGIC
1899 numeric_function_2Argument:
1906 | SQL_TOKEN_TRUNCATE
1909 {$$
= SQL_NEW_RULE
;}
1913 $$
->append
($1 = newNode
("?", SQL_NODE_PUNCTUATION
));
1918 op_parameter SQL_TOKEN_CALL table_node op_odbc_call_parameter
1928 op_odbc_call_parameter:
1929 {$$
= SQL_NEW_RULE
;}
1930 |
'(' odbc_parameter_commalist
')'
1933 $$
->append
($1 = newNode
("(", SQL_NODE_PUNCTUATION
));
1935 $$
->append
($3 = newNode
(")", SQL_NODE_PUNCTUATION
));
1939 odbc_parameter_commalist:
1941 {$$
= SQL_NEW_COMMALISTRULE
;
1943 | odbc_parameter_commalist
',' odbc_parameter
1950 /* empty */ {$$
= SQL_NEW_RULE
;}
1956 odbc_fct_type SQL_TOKEN_STRING
1972 set_fct_type
'(' opt_all_distinct value_exp
')'
1976 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
1979 $$
->append
($5 = newNode
(")", SQL_NODE_PUNCTUATION
));
1981 | SQL_TOKEN_COUNT
'(' '*' ')'
1985 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
1986 $$
->append
($3 = newNode
("*", SQL_NODE_PUNCTUATION
));
1987 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));
1989 | SQL_TOKEN_COUNT
'(' opt_all_distinct value_exp
')'
1993 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
1996 $$
->append
($5 = newNode
(")", SQL_NODE_PUNCTUATION
));
2007 | SQL_TOKEN_STDDEV_POP
2008 | SQL_TOKEN_STDDEV_SAMP
2009 | SQL_TOKEN_VAR_SAMP
2013 | SQL_TOKEN_INTERSECTION
2017 SQL_TOKEN_LEFT %prec SQL_TOKEN_LEFT
2022 | SQL_TOKEN_RIGHT %prec SQL_TOKEN_RIGHT
2027 | SQL_TOKEN_FULL %prec SQL_TOKEN_FULL
2034 SQL_TOKEN_ON search_condition
2043 | named_columns_join
2052 | outer_join_type SQL_TOKEN_OUTER
2060 table_ref
/*[SQL_TOKEN_CROSS]*/ SQL_TOKEN_CROSS SQL_TOKEN_JOIN table_ref
2071 /* wenn SQL_TOKEN_NATURAL, dann keine join_spec */
2072 table_ref
/*[SQL_TOKEN_NATURAL]*/ SQL_TOKEN_NATURAL join_type SQL_TOKEN_JOIN table_ref
2081 | table_ref join_type SQL_TOKEN_JOIN table_ref join_spec
2096 SQL_TOKEN_USING
'(' column_commalist
')'
2100 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
2102 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));
2107 | values_or_query_spec
2110 non_join_query_primary:
2112 |
'(' non_join_query_exp
')'
2115 $$
->append
($1 = newNode
("(", SQL_NODE_PUNCTUATION
));
2117 $$
->append
($3 = newNode
(")", SQL_NODE_PUNCTUATION
));
2120 non_join_query_term:
2121 non_join_query_primary
2122 | query_term SQL_TOKEN_INTERSECT all query_primary
2132 non_join_query_primary
2136 | query_exp SQL_TOKEN_UNION all query_term
2144 | query_exp SQL_TOKEN_EXCEPT all query_term
2154 /* empty*/ {$$
= SQL_NEW_RULE
;}
2158 non_join_query_exp
/*[^')']*/
2171 SQL_TOKEN_CAST
'(' cast_operand SQL_TOKEN_AS cast_target
')'
2175 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
2179 $$
->append
($6 = newNode
(")", SQL_NODE_PUNCTUATION
));
2190 $$
->append
($1 = newNode
("(", SQL_NODE_PUNCTUATION
));
2192 $$
->append
($3 = newNode
(")", SQL_NODE_PUNCTUATION
));
2203 |
'-' num_primary %prec SQL_TOKEN_UMINUS
2206 $$
->append
($1 = newNode
("-", SQL_NODE_PUNCTUATION
));
2209 |
'+' num_primary %prec SQL_TOKEN_UMINUS
2212 $$
->append
($1 = newNode
("+", SQL_NODE_PUNCTUATION
));
2223 $$
->append
($2 = newNode
("*", SQL_NODE_PUNCTUATION
));
2230 $$
->append
($2 = newNode
("/", SQL_NODE_PUNCTUATION
));
2237 | num_value_exp
'+' term
2241 $$
->append
($2 = newNode
("+", SQL_NODE_PUNCTUATION
));
2244 | num_value_exp
'-' term
2248 $$
->append
($2 = newNode
("-", SQL_NODE_PUNCTUATION
));
2253 /* value_exp_primary
2258 |*/ datetime_value_fct
2265 SQL_TOKEN_CURRENT_DATE
2270 | SQL_TOKEN_CURRENT_TIME
2275 | SQL_TOKEN_CURRENT_TIMESTAMP
2282 SQL_TOKEN_AT time_zone_specifier
2289 time_zone_specifier:
2295 /* | SQL_TOKEN_TIME SQL_TOKEN_ZONE interval_value_exp
2309 | datetime_primary time_zone
2326 | interval_term '*' factor
2330 $$->append($2 = newNode("*", SQL_NODE_PUNCTUATION));
2333 | interval_term '/' factor
2337 $$->append($2 = newNode("/", SQL_NODE_PUNCTUATION));
2348 /* | interval_value_exp '+' datetime_term
2352 $$->append($2 = newNode("+", SQL_NODE_PUNCTUATION));
2355 | datetime_value_exp '+' interval_term
2359 $$->append($2 = newNode("+", SQL_NODE_PUNCTUATION));
2362 | datetime_value_exp '-' interval_term
2366 $$->append($2 = newNode("-", SQL_NODE_PUNCTUATION));
2377 | interval_value_exp '+' interval_term
2381 $$->append($2 = newNode("+", SQL_NODE_PUNCTUATION));
2384 | interval_value_exp '-' interval_term
2388 $$->append($2 = newNode("-", SQL_NODE_PUNCTUATION));
2391 | '(' datetime_value_exp '-' datetime_term ')' interval_qualifier
2394 $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
2396 $$->append($3 = newNode("-", SQL_NODE_PUNCTUATION));
2398 $$->append($5 = newNode(")", SQL_NODE_PUNCTUATION));
2403 non_second_datetime_field:
2411 non_second_datetime_field
2416 | non_second_datetime_field '(' SQL_TOKEN_INTNUM ')'
2420 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
2422 $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
2426 non_second_datetime_field
2436 | SQL_TOKEN_SECOND '(' SQL_TOKEN_INTNUM ')'
2440 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
2442 $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
2447 single_datetime_field:
2448 non_second_datetime_field
2453 | non_second_datetime_field '(' SQL_TOKEN_INTNUM ')'
2457 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
2459 $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
2466 | SQL_TOKEN_SECOND '(' SQL_TOKEN_INTNUM ')'
2470 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
2472 $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
2474 | SQL_TOKEN_SECOND '(' SQL_TOKEN_INTNUM ',' SQL_TOKEN_INTNUM ')'
2478 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
2480 $$->append($4 = newNode(",", SQL_NODE_PUNCTUATION));
2482 $$->append($6 = newNode(")", SQL_NODE_PUNCTUATION));
2488 start_field SQL_TOKEN_TO end_field
2495 | single_datetime_field
2502 function_arg_commalist2:
2503 function_arg
',' function_arg
2504 {$$
= SQL_NEW_COMMALISTRULE
;
2508 function_arg_commalist3:
2509 function_arg
',' function_arg
',' function_arg
2511 $$
= SQL_NEW_COMMALISTRULE
;
2517 function_arg_commalist4:
2518 function_arg
',' function_arg
',' function_arg
',' function_arg
2520 $$
= SQL_NEW_COMMALISTRULE
;
2527 value_exp_commalist:
2529 {$$
= SQL_NEW_COMMALISTRULE
;
2531 | value_exp_commalist
',' value_exp
2534 /* this rule is only valid if we check predicates */
2535 | value_exp_commalist
';' value_exp
2537 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
())
2548 | value_exp comparison value_exp
2556 function_args_commalist:
2558 {$$
= SQL_NEW_COMMALISTRULE
;
2560 | function_args_commalist
',' function_arg
2563 /* this rule is only valid if we check predicates */
2564 | function_args_commalist
';' function_arg
2566 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
())
2577 num_value_exp
/*[^')']*/
2579 | datetime_value_exp
2598 char_value_exp
'+' char_factor
2602 $$
->append
($2 = newNode
("+", SQL_NODE_PUNCTUATION
));
2605 | value_exp SQL_CONCAT value_exp
2619 SQL_TOKEN_COLLATE table_node
2628 | char_primary collate_clause
2647 SQL_TOKEN_SUBSTRING
'(' bit_value_exp SQL_TOKEN_FROM string_value_exp for_length
')'
2651 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
2656 $$
->append
($7 = newNode
(")", SQL_NODE_PUNCTUATION
));
2674 bit_value_exp '+' bit_factor
2678 $$->append($2 = newNode("+", SQL_NODE_PUNCTUATION));
2691 {$$
= SQL_NEW_RULE
;}
2692 /* value_exp_primary
2723 {$$
= SQL_NEW_RULE
;}
2724 | SQL_TOKEN_FOR value_exp
2732 SQL_TOKEN_SUBSTRING
'(' value_exp SQL_TOKEN_FROM value_exp for_length
')'
2736 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
2741 $$
->append
($7 = newNode
(")", SQL_NODE_PUNCTUATION
));
2743 | SQL_TOKEN_SUBSTRING
'(' value_exp_commalist
')'
2747 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
2749 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));
2757 upper_lower
'(' value_exp
')'
2761 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
2763 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));
2767 SQL_TOKEN_CONVERT
'(' string_value_exp SQL_TOKEN_USING table_node
')'
2771 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
2775 $$
->append
($6 = newNode
(")", SQL_NODE_PUNCTUATION
));
2777 | SQL_TOKEN_CONVERT
'(' cast_operand
',' cast_target
')'
2781 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
2783 $$
->append
($2 = newNode
(",", SQL_NODE_PUNCTUATION
));
2785 $$
->append
($6 = newNode
(")", SQL_NODE_PUNCTUATION
));
2789 SQL_TOKEN_TRANSLATE
'(' string_value_exp SQL_TOKEN_USING table_node
')'
2793 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
2797 $$
->append
($6 = newNode
(")", SQL_NODE_PUNCTUATION
));
2801 SQL_TOKEN_TRIM
'(' trim_operands
')'
2805 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
2807 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));
2811 trim_spec value_exp SQL_TOKEN_FROM value_exp
2819 | trim_spec SQL_TOKEN_FROM value_exp
2826 | value_exp SQL_TOKEN_FROM value_exp
2833 | SQL_TOKEN_FROM value_exp
2845 | SQL_TOKEN_TRAILING
2863 SQL_TOKEN_NAME
'.' schema_name
2867 $$
->append
($2 = newNode
(".", SQL_NODE_PUNCTUATION
));
2870 | SQL_TOKEN_NAME
':' schema_name
2874 $$
->append
($2 = newNode
(":", SQL_NODE_PUNCTUATION
));
2879 SQL_TOKEN_NAME
'.' table_name
2883 $$
->append
($2 = newNode
(".", SQL_NODE_PUNCTUATION
));
2898 /* | table_node '.' column_val %prec '.'
2901 $$->append($2 = newNode(".", SQL_NODE_PUNCTUATION));
2904 | SQL_TOKEN_NAME
'.' column_val %prec
'.'
2907 $$
->append
($2 = newNode
(".", SQL_NODE_PUNCTUATION
));
2910 | SQL_TOKEN_NAME
'.' SQL_TOKEN_NAME
'.' column_val %prec
'.'
2913 $$
->append
($2 = newNode
(".", SQL_NODE_PUNCTUATION
));
2915 $$
->append
($4 = newNode
(".", SQL_NODE_PUNCTUATION
));
2917 | SQL_TOKEN_NAME
'.' SQL_TOKEN_NAME
'.' SQL_TOKEN_NAME
'.' column_val %prec
'.'
2920 $$
->append
($2= newNode
(".", SQL_NODE_PUNCTUATION
));
2922 $$
->append
($4 = newNode
(".", SQL_NODE_PUNCTUATION
));
2924 $$
->append
($6 = newNode
(".", SQL_NODE_PUNCTUATION
));
2927 | SQL_TOKEN_NAME
':' SQL_TOKEN_NAME
'.' SQL_TOKEN_NAME
'.' column_val %prec
'.'
2930 $$
->append
($2= newNode
(":", SQL_NODE_PUNCTUATION
));
2932 $$
->append
($4 = newNode
(".", SQL_NODE_PUNCTUATION
));
2934 $$
->append
($6 = newNode
(".", SQL_NODE_PUNCTUATION
));
2937 /* | SQL_TOKEN_NAME ';' SQL_TOKEN_NAME '.' SQL_TOKEN_NAME '.' column_val
2940 $$->append($2= newNode(";", SQL_NODE_PUNCTUATION));
2942 $$->append($4 = newNode(".", SQL_NODE_PUNCTUATION));
2944 $$->append($6 = newNode(".", SQL_NODE_PUNCTUATION));
2957 $$
->append
($1 = newNode
("*", SQL_NODE_PUNCTUATION
));
2962 | SQL_TOKEN_CHARACTER
'(' SQL_TOKEN_INTNUM
')'
2965 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
2967 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));}
2969 | SQL_TOKEN_NUMERIC
'(' SQL_TOKEN_INTNUM
')'
2972 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
2974 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));}
2975 | SQL_TOKEN_NUMERIC
'(' SQL_TOKEN_INTNUM
',' SQL_TOKEN_INTNUM
')'
2978 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
2980 $$
->append
($4 = newNode
(",", SQL_NODE_PUNCTUATION
));
2982 $$
->append
($6 = newNode
(")", SQL_NODE_PUNCTUATION
));}
2984 | SQL_TOKEN_DECIMAL
'(' SQL_TOKEN_INTNUM
')'
2987 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
2989 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));}
2990 | SQL_TOKEN_DECIMAL
'(' SQL_TOKEN_INTNUM
',' SQL_TOKEN_INTNUM
')'
2993 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
2995 $$
->append
($4 = newNode
(",", SQL_NODE_PUNCTUATION
));
2997 $$
->append
($6 = newNode
(")", SQL_NODE_PUNCTUATION
));}
2999 | SQL_TOKEN_SMALLINT
3001 | SQL_TOKEN_FLOAT
'(' SQL_TOKEN_INTNUM
')'
3004 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
3006 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));}
3008 | SQL_TOKEN_DOUBLE SQL_TOKEN_PRECISION
3014 /* the various things you can name */
3018 | SQL_TOKEN_POSITION
3020 sal_uInt32 nNod
= $$
->getRuleID
();
3022 $$
= newNode
(xxx_pGLOBAL_SQLPARSER
->TokenIDToStr
(nNod
), SQL_NODE_NAME
);
3024 | SQL_TOKEN_CHAR_LENGTH
3026 sal_uInt32 nNod
= $$
->getRuleID
();
3028 $$
= newNode
(xxx_pGLOBAL_SQLPARSER
->TokenIDToStr
(nNod
), SQL_NODE_NAME
);
3032 sal_uInt32 nNod
= $$
->getRuleID
();
3034 $$
= newNode
(xxx_pGLOBAL_SQLPARSER
->TokenIDToStr
(nNod
), SQL_NODE_NAME
);
3038 cursor: SQL_TOKEN_NAME
3044 module: SQL_TOKEN_NAME
3053 $$
->append
($1 = newNode
(":", SQL_NODE_PUNCTUATION
));
3056 {$$
= SQL_NEW_RULE
; // test
3057 $$
->append
($1 = newNode
("?", SQL_NODE_PUNCTUATION
));}
3058 |
'[' SQL_TOKEN_NAME
']'
3060 $$
->append
($1 = newNode
("[", SQL_NODE_PUNCTUATION
));
3062 $$
->append
($3 = newNode
("]", SQL_NODE_PUNCTUATION
));}
3066 procedure: SQL_TOKEN_NAME
3073 {$$
= SQL_NEW_RULE
;}
3074 | opt_as SQL_TOKEN_NAME
3081 user: SQL_TOKEN_NAME
3084 /* PREDICATECHECK RULES */
3086 search_condition
/* checking predicats */
3088 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
()) // sql: rule 1
3091 if
( SQL_ISRULE
($$
,search_condition
) )
3093 $$
->insert
(0,newNode
("(", SQL_NODE_PUNCTUATION
));
3094 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
3100 |
'(' sql
')' /* checking predicats */
3105 using namespace
::com
::sun
::star
::sdbc
;
3106 using namespace
::com
::sun
::star
::beans
;
3107 using namespace
::com
::sun
::star
::uno
;
3108 using namespace
::com
::sun
::star
::i18n
;
3109 using namespace
::com
::sun
::star
::lang
;
3110 using namespace
::com
::sun
::star
::util
;
3111 using namespace
::osl
;
3112 using namespace
::dbtools
;
3113 // using namespace connectivity;
3115 //============================================================
3116 //= a helper for static ascii pseudo-unicode strings
3117 //============================================================
3119 struct _ConstAsciiString_
3122 sal_Char
const* str
;
3124 operator rtl
::OUString
() const { return rtl
::OUString
(str
, length
, RTL_TEXTENCODING_ASCII_US
); }
3125 // operator ::rtl::OUString () const { return ::rtl::OUString(str, length, RTL_TEXTENCODING_ASCII_US); }
3126 operator
const sal_Char
* () const { return str
; }
3127 operator
::rtl
::OString
() const { return str
; }
3130 #define IMPLEMENT_CONSTASCII_STRING( name, string ) \
3131 _ConstAsciiString_
const name
= { sizeof
(string)-1, string }
3133 IMPLEMENT_CONSTASCII_STRING
(ERROR_STR_GENERAL
, "Syntax error in SQL expression");
3134 IMPLEMENT_CONSTASCII_STRING
(ERROR_STR_VALUE_NO_LIKE
, "The value #1 can not be used with LIKE.");
3135 IMPLEMENT_CONSTASCII_STRING
(ERROR_STR_FIELD_NO_LIKE
, "LIKE can not be used with this field.");
3136 IMPLEMENT_CONSTASCII_STRING
(ERROR_STR_INVALID_COMPARE
, "The entered criterion can not be compared with this field.");
3137 IMPLEMENT_CONSTASCII_STRING
(ERROR_STR_INVALID_DATE_COMPARE
, "The field can not be compared with a date.");
3138 IMPLEMENT_CONSTASCII_STRING
(ERROR_STR_INVALID_REAL_COMPARE
, "The field can not be compared with a floating point number.");
3139 IMPLEMENT_CONSTASCII_STRING
(ERROR_STR_INVALID_INT_COMPARE
, "The field can not be compared with a number.");
3140 IMPLEMENT_CONSTASCII_STRING
(ERROR_STR_INVALID_TABLE
, "The database does not contain a table named \"#\".");
3141 IMPLEMENT_CONSTASCII_STRING
(ERROR_STR_INVALID_TABLE_OR_QUERY
, "The database does contain neither a table nor a query named \"#\".");
3142 IMPLEMENT_CONSTASCII_STRING
(ERROR_STR_INVALID_COLUMN
, "The column \"#1\" is unknown in the table \"#2\".");
3143 IMPLEMENT_CONSTASCII_STRING
(ERROR_STR_INVALID_TABLE_EXIST
, "The database already contains a table or view with name \"#\".");
3144 IMPLEMENT_CONSTASCII_STRING
(ERROR_STR_INVALID_QUERY_EXIST
, "The database already contains a query with name \"#\".");
3146 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_LIKE
, "LIKE");
3147 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_NOT
, "NOT");
3148 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_NULL
, "NULL");
3149 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_TRUE
, "True");
3150 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_FALSE
, "False");
3151 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_IS
, "IS");
3152 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_BETWEEN
, "BETWEEN");
3153 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_OR
, "OR");
3154 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_AND
, "AND");
3155 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_AVG
, "AVG");
3156 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_COUNT
, "COUNT");
3157 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_MAX
, "MAX");
3158 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_MIN
, "MIN");
3159 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_SUM
, "SUM");
3160 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_EVERY
, "EVERY");
3161 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_ANY
, "ANY");
3162 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_SOME
, "SOME");
3163 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_STDDEV_POP
, "STDDEV_POP");
3164 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_STDDEV_SAMP
, "STDDEV_SAMP");
3165 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_VAR_SAMP
, "VAR_SAMP");
3166 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_VAR_POP
, "VAR_POP");
3167 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_COLLECT
, "COLLECT");
3168 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_FUSION
, "FUSION");
3169 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_INTERSECTION
, "INTERSECTION");
3171 IMPLEMENT_CONSTASCII_STRING
(FIELD_STR_NULLDATE
, "NullDate");
3173 IMPLEMENT_CONSTASCII_STRING
(STR_SQL_TOKEN
, "SQL_TOKEN_");
3175 //==========================================================================
3177 //==========================================================================
3178 //-----------------------------------------------------------------------------
3179 OParseContext::OParseContext
()
3183 //-----------------------------------------------------------------------------
3184 OParseContext::~OParseContext
()
3188 //-----------------------------------------------------------------------------
3189 ::rtl
::OUString OParseContext
::getErrorMessage
(ErrorCode _eCode
) const
3191 ::rtl
::OUString aMsg
;
3194 case ERROR_GENERAL
: aMsg
= ERROR_STR_GENERAL
; break
;
3195 case ERROR_VALUE_NO_LIKE
: aMsg
= ERROR_STR_VALUE_NO_LIKE
; break
;
3196 case ERROR_FIELD_NO_LIKE
: aMsg
= ERROR_STR_FIELD_NO_LIKE
; break
;
3197 case ERROR_INVALID_COMPARE
: aMsg
= ERROR_STR_INVALID_COMPARE
; break
;
3198 case ERROR_INVALID_INT_COMPARE
: aMsg
= ERROR_STR_INVALID_INT_COMPARE
; break
;
3199 case ERROR_INVALID_DATE_COMPARE
: aMsg
= ERROR_STR_INVALID_DATE_COMPARE
; break
;
3200 case ERROR_INVALID_REAL_COMPARE
: aMsg
= ERROR_STR_INVALID_REAL_COMPARE
; break
;
3201 case ERROR_INVALID_TABLE
: aMsg
= ERROR_STR_INVALID_TABLE
; break
;
3202 case ERROR_INVALID_TABLE_OR_QUERY
: aMsg
= ERROR_STR_INVALID_TABLE_OR_QUERY
; break
;
3203 case ERROR_INVALID_COLUMN
: aMsg
= ERROR_STR_INVALID_COLUMN
; break
;
3204 case ERROR_INVALID_TABLE_EXIST
: aMsg
= ERROR_STR_INVALID_TABLE_EXIST
; break
;
3205 case ERROR_INVALID_QUERY_EXIST
: aMsg
= ERROR_STR_INVALID_QUERY_EXIST
; break
;
3207 OSL_ENSURE
( false
, "OParseContext::getErrorMessage: unknown error code!" );
3213 //-----------------------------------------------------------------------------
3214 ::rtl
::OString OParseContext
::getIntlKeywordAscii
(InternationalKeyCode _eKey
) const
3216 ::rtl
::OString aKeyword
;
3219 case KEY_LIKE
: aKeyword
= KEY_STR_LIKE
; break
;
3220 case KEY_NOT
: aKeyword
= KEY_STR_NOT
; break
;
3221 case KEY_NULL
: aKeyword
= KEY_STR_NULL
; break
;
3222 case KEY_TRUE
: aKeyword
= KEY_STR_TRUE
; break
;
3223 case KEY_FALSE
: aKeyword
= KEY_STR_FALSE
; break
;
3224 case KEY_IS
: aKeyword
= KEY_STR_IS
; break
;
3225 case KEY_BETWEEN
: aKeyword
= KEY_STR_BETWEEN
; break
;
3226 case KEY_OR
: aKeyword
= KEY_STR_OR
; break
;
3227 case KEY_AND
: aKeyword
= KEY_STR_AND
; break
;
3228 case KEY_AVG
: aKeyword
= KEY_STR_AVG
; break
;
3229 case KEY_COUNT
: aKeyword
= KEY_STR_COUNT
; break
;
3230 case KEY_MAX
: aKeyword
= KEY_STR_MAX
; break
;
3231 case KEY_MIN
: aKeyword
= KEY_STR_MIN
; break
;
3232 case KEY_SUM
: aKeyword
= KEY_STR_SUM
; break
;
3233 case KEY_EVERY
: aKeyword
= KEY_STR_EVERY
; break
;
3234 case KEY_ANY
: aKeyword
= KEY_STR_ANY
; break
;
3235 case KEY_SOME
: aKeyword
= KEY_STR_SOME
; break
;
3236 case KEY_STDDEV_POP
: aKeyword
= KEY_STR_STDDEV_POP
; break
;
3237 case KEY_STDDEV_SAMP
: aKeyword
= KEY_STR_STDDEV_SAMP
; break
;
3238 case KEY_VAR_SAMP
: aKeyword
= KEY_STR_VAR_SAMP
; break
;
3239 case KEY_VAR_POP
: aKeyword
= KEY_STR_VAR_POP
; break
;
3240 case KEY_COLLECT
: aKeyword
= KEY_STR_COLLECT
; break
;
3241 case KEY_FUSION
: aKeyword
= KEY_STR_FUSION
; break
;
3242 case KEY_INTERSECTION
:aKeyword
= KEY_STR_INTERSECTION
; break
;
3243 case KEY_NONE
: break
;
3245 OSL_ENSURE
( false
, "OParseContext::getIntlKeywordAscii: unknown key!" );
3251 //-----------------------------------------------------------------------------
3252 IParseContext::InternationalKeyCode OParseContext
::getIntlKeyCode
(const ::rtl
::OString
& rToken
) const
3254 static IParseContext
::InternationalKeyCode Intl_TokenID
[] =
3256 KEY_LIKE
, KEY_NOT
, KEY_NULL
, KEY_TRUE
,
3257 KEY_FALSE
, KEY_IS
, KEY_BETWEEN
, KEY_OR
,
3258 KEY_AND
, KEY_AVG
, KEY_COUNT
, KEY_MAX
,
3259 KEY_MIN
, KEY_SUM
, KEY_EVERY
,KEY_ANY
,KEY_SOME
,
3260 KEY_STDDEV_POP
,KEY_STDDEV_SAMP
,KEY_VAR_SAMP
,
3261 KEY_VAR_POP
,KEY_COLLECT
,KEY_FUSION
,KEY_INTERSECTION
3264 sal_uInt32 nCount
= sizeof Intl_TokenID
/ sizeof Intl_TokenID
[0];
3265 for
(sal_uInt32 i
= 0; i
< nCount
; i
++)
3267 ::rtl
::OString aKey
= getIntlKeywordAscii
(Intl_TokenID
[i
]);
3268 if
(rToken.equalsIgnoreAsciiCase
(aKey
))
3269 return Intl_TokenID
[i
];
3275 //------------------------------------------------------------------------------
3276 static Locale
& impl_getLocaleInstance
( )
3278 static Locale s_aLocale
(
3279 ::rtl
::OUString
( RTL_CONSTASCII_USTRINGPARAM
( "en" ) ),
3280 ::rtl
::OUString
( RTL_CONSTASCII_USTRINGPARAM
( "US" ) ),
3286 //------------------------------------------------------------------------------
3287 void OParseContext
::setDefaultLocale
( const ::com
::sun
::star
::lang
::Locale
& _rLocale
)
3289 impl_getLocaleInstance
() = _rLocale
;
3292 //------------------------------------------------------------------------------
3293 Locale OParseContext
::getPreferredLocale
( ) const
3295 return getDefaultLocale
();
3298 //------------------------------------------------------------------------------
3299 const Locale
& OParseContext
::getDefaultLocale
()
3301 return impl_getLocaleInstance
();
3304 //==========================================================================
3306 //==========================================================================
3307 // Der (leider globale) yylval fuer die Uebergabe von
3308 // Werten vom Scanner an den Parser. Die globale Variable
3309 // wird nur kurzzeitig verwendet, der Parser liest die Variable
3310 // sofort nach dem Scanner-Aufruf in eine gleichnamige eigene
3313 const double fMilliSecondsPerDay
= 86400000.0;
3315 //------------------------------------------------------------------------------
3318 //------------------------------------------------------------------
3319 ::rtl
::OUString ConvertLikeToken
(const OSQLParseNode
* pTokenNode
, const OSQLParseNode
* pEscapeNode
, sal_Bool bInternational
)
3321 ::rtl
::OUStringBuffer aMatchStr
;
3322 if
(pTokenNode
->isToken
())
3324 sal_Unicode cEscape
= 0;
3325 if
(pEscapeNode
->count
())
3326 cEscape
= pEscapeNode
->getChild
(1)->getTokenValue
().toChar
();
3328 // Platzhalter austauschen
3329 aMatchStr
= pTokenNode
->getTokenValue
();
3330 const sal_Int32 nLen
= aMatchStr.getLength
();
3331 ::rtl
::OUStringBuffer sSearch
,sReplace
;
3332 if
( bInternational
)
3334 sSearch.appendAscii
("%_",2);
3335 sReplace.appendAscii
("*?",2);
3339 sSearch.appendAscii
("*?",2);
3340 sReplace.appendAscii
("%_",2);
3343 for
(sal_Int32 i
= 0; i
< nLen
; i
++)
3345 const sal_Unicode c
= aMatchStr.charAt
(i
);
3346 if
(c
== sSearch.charAt
(0) || c
== sSearch.charAt
(1))
3348 if
(i
> 0 && aMatchStr.charAt
(i
-1) == cEscape
)
3352 const sal_Unicode cCharacter
= sReplace.charAt
( (c
== sSearch.charAt
(0)) ?
0 : 1);
3353 aMatchStr.setCharAt
(i
, cCharacter
);
3358 return aMatchStr.makeStringAndClear
();
3361 //==========================================================================
3363 //==========================================================================
3365 sal_uInt32 OSQLParser
::s_nRuleIDs
[OSQLParseNode
::rule_count
+ 1];
3366 OSQLParser::RuleIDMap OSQLParser
::s_aReverseRuleIDLookup
;
3367 OParseContext OSQLParser
::s_aDefaultContext
;
3369 sal_Int32 OSQLParser
::s_nRefCount
= 0;
3370 // ::osl::Mutex OSQLParser::s_aMutex;
3371 OSQLScanner
* OSQLParser
::s_pScanner
= 0;
3372 OSQLParseNodesGarbageCollector
* OSQLParser
::s_pGarbageCollector
= 0;
3373 ::com
::sun
::star
::uno
::Reference
< ::com
::sun
::star
::i18n
::XLocaleData
> OSQLParser
::s_xLocaleData
= NULL
;
3374 //-----------------------------------------------------------------------------
3375 void setParser
(OSQLParser
* _pParser
)
3377 xxx_pGLOBAL_SQLPARSER
= _pParser
;
3379 // -------------------------------------------------------------------------
3380 void OSQLParser
::setParseTree
(OSQLParseNode
* pNewParseTree
)
3382 ::osl
::MutexGuard aGuard
(getMutex
());
3383 m_pParseTree
= pNewParseTree
;
3385 //-----------------------------------------------------------------------------
3386 OSQLParseNode
* OSQLParser
::parseTree
(::rtl
::OUString
& rErrorMessage
,
3387 const ::rtl
::OUString
& rStatement
,
3388 sal_Bool bInternational
)
3392 // Guard the parsing
3393 ::osl
::MutexGuard aGuard
(getMutex
());
3397 // defines how to scan
3398 s_pScanner
->SetRule
(s_pScanner
->GetSQLRule
()); // initial
3399 s_pScanner
->prepareScan
(rStatement
, m_pContext
, bInternational
);
3401 SQLyylval.pParseNode
= NULL
;
3403 m_pParseTree
= NULL
;
3404 m_sErrorMessage
= ::rtl
::OUString
();
3406 // ... und den Parser anwerfen ...
3407 if
(SQLyyparse
() != 0)
3409 // only set the error message, if it's not already set
3410 if
(!m_sErrorMessage.getLength
())
3411 m_sErrorMessage
= s_pScanner
->getErrorMessage
();
3412 if
(!m_sErrorMessage.getLength
())
3413 m_sErrorMessage
= m_pContext
->getErrorMessage
(IParseContext
::ERROR_GENERAL
);
3415 rErrorMessage
= m_sErrorMessage
;
3417 // clear the garbage collector
3418 (*s_pGarbageCollector
)->clearAndDelete
();
3423 (*s_pGarbageCollector
)->clear
();
3425 // Das Ergebnis liefern (den Root Parse Node):
3427 // OSL_ENSURE(Sdbyyval.pParseNode != NULL,"OSQLParser: Parser hat keinen ParseNode geliefert");
3428 // return Sdbyyval.pParseNode;
3429 // geht nicht wegen Bug in MKS YACC-erzeugtem Code (es wird ein falscher ParseNode
3432 // Stattdessen setzt die Parse-Routine jetzt den Member pParseTree
3433 // - einfach diesen zurueckliefern:
3434 OSL_ENSURE
(m_pParseTree
!= NULL
,"OSQLParser: Parser hat keinen ParseTree geliefert");
3435 return m_pParseTree
;
3438 //-----------------------------------------------------------------------------
3439 ::rtl
::OString OSQLParser
::TokenIDToStr
(sal_uInt32 nTokenID
, const IParseContext
* pContext
)
3441 ::rtl
::OString aStr
;
3444 IParseContext
::InternationalKeyCode eKeyCode
= IParseContext
::KEY_NONE
;
3447 case SQL_TOKEN_LIKE
: eKeyCode
= IParseContext
::KEY_LIKE
; break
;
3448 case SQL_TOKEN_NOT
: eKeyCode
= IParseContext
::KEY_NOT
; break
;
3449 case SQL_TOKEN_NULL
: eKeyCode
= IParseContext
::KEY_NULL
; break
;
3450 case SQL_TOKEN_TRUE
: eKeyCode
= IParseContext
::KEY_TRUE
; break
;
3451 case SQL_TOKEN_FALSE
: eKeyCode
= IParseContext
::KEY_FALSE
; break
;
3452 case SQL_TOKEN_IS
: eKeyCode
= IParseContext
::KEY_IS
; break
;
3453 case SQL_TOKEN_BETWEEN
: eKeyCode
= IParseContext
::KEY_BETWEEN
; break
;
3454 case SQL_TOKEN_OR
: eKeyCode
= IParseContext
::KEY_OR
; break
;
3455 case SQL_TOKEN_AND
: eKeyCode
= IParseContext
::KEY_AND
; break
;
3456 case SQL_TOKEN_AVG
: eKeyCode
= IParseContext
::KEY_AVG
; break
;
3457 case SQL_TOKEN_COUNT
: eKeyCode
= IParseContext
::KEY_COUNT
; break
;
3458 case SQL_TOKEN_MAX
: eKeyCode
= IParseContext
::KEY_MAX
; break
;
3459 case SQL_TOKEN_MIN
: eKeyCode
= IParseContext
::KEY_MIN
; break
;
3460 case SQL_TOKEN_SUM
: eKeyCode
= IParseContext
::KEY_SUM
; break
;
3462 if
( eKeyCode
!= IParseContext
::KEY_NONE
)
3463 aStr
= pContext
->getIntlKeywordAscii
(eKeyCode
);
3466 if
(!aStr.getLength
())
3468 aStr
= yytname
[YYTRANSLATE
(nTokenID
)];
3469 if
(!aStr.compareTo
("SQL_TOKEN_",10))
3470 aStr
= aStr.copy
(10);
3475 //-----------------------------------------------------------------------------
3476 ::rtl
::OUString OSQLParser
::RuleIDToStr
(sal_uInt32 nRuleID
)
3478 OSL_ENSURE
(nRuleID
< (sizeof yytname
/sizeof yytname
[0]), "OSQLParser::RuleIDToStr: Invalid nRuleId!");
3479 return
::rtl
::OUString
::createFromAscii
(yytname
[nRuleID
]);
3482 //-----------------------------------------------------------------------------
3483 sal_uInt32 OSQLParser
::StrToRuleID
(const ::rtl
::OString
& rValue
)
3485 // In yysvar nach dem angegebenen Namen suchen, den Index zurueckliefern
3486 // (oder 0, wenn nicht gefunden)
3487 static sal_uInt32 nLen
= sizeof
(yytname
)/sizeof
(yytname
[0]);
3488 for
(sal_uInt32 i
= YYTRANSLATE
(SQL_TOKEN_INVALIDSYMBOL
); i
< (nLen
-1); i
++)
3490 if
(yytname
&& rValue
== yytname
[i
])
3498 //-----------------------------------------------------------------------------
3499 OSQLParseNode::Rule OSQLParser
::RuleIDToRule
( sal_uInt32 _nRule
)
3501 return s_aReverseRuleIDLookup
[ _nRule
];
3504 //-----------------------------------------------------------------------------
3505 sal_uInt32 OSQLParser
::RuleID
(OSQLParseNode
::Rule eRule
)
3507 return s_nRuleIDs
[(sal_uInt16
)eRule
];
3509 // -------------------------------------------------------------------------
3510 sal_Int16 OSQLParser
::buildNode
(OSQLParseNode
*& pAppend
,OSQLParseNode
* pCompare
,OSQLParseNode
* pLiteral
,OSQLParseNode
* pLiteral2
)
3512 OSQLParseNode
* pColumnRef
= new OSQLInternalNode
(aEmptyString
, SQL_NODE_RULE
,OSQLParser
::RuleID
(OSQLParseNode
::column_ref
));
3513 pColumnRef
->append
(new OSQLInternalNode
(m_sFieldName
,SQL_NODE_NAME
));
3514 OSQLParseNode
* pComp
= NULL
;
3515 if
( SQL_ISTOKEN
( pCompare
, BETWEEN
) && pLiteral2
)
3516 pComp
= new OSQLInternalNode
(aEmptyString
, SQL_NODE_RULE
,OSQLParser
::RuleID
(OSQLParseNode
::between_predicate
));
3518 pComp
= new OSQLInternalNode
(aEmptyString
, SQL_NODE_RULE
,OSQLParser
::RuleID
(OSQLParseNode
::comparison_predicate
));
3520 pComp
->append
(pColumnRef
);
3521 pComp
->append
(pCompare
);
3522 pComp
->append
(pLiteral
);
3525 pComp
->append
(new OSQLInternalNode
(aEmptyString
, SQL_NODE_KEYWORD
,SQL_TOKEN_AND
));
3526 pComp
->append
(pLiteral2
);
3528 pAppend
->append
(pComp
);
3531 //-----------------------------------------------------------------------------
3532 sal_Int16 OSQLParser
::buildStringNodes
(OSQLParseNode
*& pLiteral
)
3537 if
(SQL_ISRULE
(pLiteral
,set_fct_spec
) || SQL_ISRULE
(pLiteral
,general_set_fct
) || SQL_ISRULE
(pLiteral
,column_ref
)
3538 || SQL_ISRULE
(pLiteral
,subquery
))
3539 return
1; // here I have a function that I can't transform into a string
3541 if
(pLiteral
->getNodeType
() == SQL_NODE_INTNUM || pLiteral
->getNodeType
() == SQL_NODE_APPROXNUM || pLiteral
->getNodeType
() == SQL_NODE_ACCESS_DATE
)
3543 OSQLParseNode
* pParent
= pLiteral
->getParent
();
3545 OSQLParseNode
* pNewNode
= new OSQLInternalNode
(pLiteral
->getTokenValue
(), SQL_NODE_STRING
);
3546 pParent
->replace
(pLiteral
, pNewNode
);
3552 for
(sal_uInt32 i
=0;i
<pLiteral
->count
();++i
)
3554 OSQLParseNode
* pChild
= pLiteral
->getChild
(i
);
3555 buildStringNodes
(pChild
);
3557 if
(SQL_ISRULE
(pLiteral
,term
) || SQL_ISRULE
(pLiteral
,value_exp_primary
))
3559 m_sErrorMessage
= m_pContext
->getErrorMessage
(IParseContext
::ERROR_INVALID_COMPARE
);
3564 //-----------------------------------------------------------------------------
3565 sal_Int16 OSQLParser
::buildComparsionRule
(OSQLParseNode
*& pAppend
,OSQLParseNode
* pLiteral
)
3567 OSQLParseNode
* pComp
= new OSQLInternalNode
(::rtl
::OUString
::createFromAscii
("="), SQL_NODE_EQUAL
);
3568 return buildPredicateRule
(pAppend
,pLiteral
,pComp
);
3572 //-----------------------------------------------------------------------------
3573 void OSQLParser
::reduceLiteral
(OSQLParseNode
*& pLiteral
, sal_Bool bAppendBlank
)
3575 OSL_ENSURE
(pLiteral
->isRule
(), "This is no ::com::sun::star::chaos::Rule");
3576 OSL_ENSURE
(pLiteral
->count
() == 2, "OSQLParser::ReduceLiteral() Invalid count");
3577 OSQLParseNode
* pTemp
= pLiteral
;
3578 ::rtl
::OUStringBuffer aValue
(pLiteral
->getChild
(0)->getTokenValue
());
3581 aValue.appendAscii
(" ");
3584 aValue.append
(pLiteral
->getChild
(1)->getTokenValue
());
3586 pLiteral
= new OSQLInternalNode
(aValue.makeStringAndClear
(),SQL_NODE_STRING
);
3590 // -------------------------------------------------------------------------
3591 void OSQLParser
::error(sal_Char
*fmt
)
3593 if
(!m_sErrorMessage.getLength
())
3595 ::rtl
::OUString sStr
(fmt
,strlen
(fmt
),RTL_TEXTENCODING_UTF8
);
3596 ::rtl
::OUString sSQL_TOKEN
(::rtl
::OUString
::createFromAscii
("SQL_TOKEN_"));
3598 sal_Int32 nPos1
= sStr.indexOf
(sSQL_TOKEN
);
3601 ::rtl
::OUString sFirst
= sStr.copy
(0,nPos1
);
3602 sal_Int32 nPos2
= sStr.indexOf
(sSQL_TOKEN
,nPos1
+1);
3605 ::rtl
::OUString sSecond
= sStr.copy
(nPos1
+sSQL_TOKEN.getLength
(),nPos2
-nPos1
-sSQL_TOKEN.getLength
());
3607 sFirst
+= sStr.copy
(nPos2
+sSQL_TOKEN.getLength
());
3610 sFirst
+= sStr.copy
(nPos1
+sSQL_TOKEN.getLength
());
3612 m_sErrorMessage
= sFirst
;
3615 m_sErrorMessage
= sStr
;
3617 ::rtl
::OUString aError
= s_pScanner
->getErrorMessage
();
3618 if
(aError.getLength
())
3620 m_sErrorMessage
+= ::rtl
::OUString
::createFromAscii
(", ");
3621 m_sErrorMessage
+= aError
;
3625 // -------------------------------------------------------------------------
3626 int OSQLParser
::SQLlex
()
3628 return s_pScanner
->SQLlex
();
3631 #if defined __SUNPRO_CC
3633 #elif defined _MSC_VER
3634 #pragma warning(pop)