5 * This file is part of the LibreOffice project.
7 * This Source Code Form is subject to the terms of the Mozilla Public
8 * License, v. 2.0. If a copy of the MPL was not distributed with this
9 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 * This file incorporates work covered by the following license notice:
13 * Licensed to the Apache Software Foundation (ASF) under one or more
14 * contributor license agreements. See the NOTICE file distributed
15 * with this work for additional information regarding copyright
16 * ownership. The ASF licenses this file to you under the Apache
17 * License, Version 2.0 (the "License"); you may not use this file
18 * except in compliance with the License. You may obtain a copy of
19 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
25 #include <connectivity/sqlnode.hxx>
26 #include <connectivity/sqlparse.hxx>
27 #include <connectivity/sqlbison_exports.hxx>
28 #include <connectivity/sqlscan.hxx>
29 #include <connectivity/internalnode.hxx>
30 #include <com/sun/star/lang/Locale.hpp>
31 #include <com/sun/star/sdbc/DataType.hpp>
32 #include <com/sun/star/util/Date.hpp>
33 #include <com/sun/star/util/DateTime.hpp>
34 #include <com/sun/star/util/Time.hpp>
35 #include <com/sun/star/util/XNumberFormatter.hpp>
36 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
37 #include <com/sun/star/util/XNumberFormats.hpp>
38 #include <com/sun/star/util/NumberFormat.hpp>
39 #include <com/sun/star/util/XNumberFormatTypes.hpp>
40 #include <com/sun/star/beans/XPropertySet.hpp>
41 #include <com/sun/star/i18n/KParseType.hpp>
42 #include <com/sun/star/i18n/KParseTokens.hpp>
44 #include <osl/diagnose.h>
45 #include "connectivity/dbconversion.hxx"
46 #include <rtl/ustrbuf.hxx>
47 #include <sal/macros.h>
50 #pragma warning(push, 1)
51 #pragma warning(disable:4273 4701)
55 # pragma GCC diagnostic ignored "-Wwrite-strings"
56 # pragma GCC diagnostic ignored "-Wunused-function"
59 inline connectivity
::OSQLInternalNode
* newNode
(const sal_Char
* pNewValue
,
60 const connectivity
::SQLNodeType eNodeType
,
61 const sal_uInt32 nNodeID
= 0);
63 inline connectivity
::OSQLInternalNode
* newNode
(const OString
& _NewValue
,
64 const connectivity
::SQLNodeType eNodeType
,
65 const sal_uInt32 nNodeID
= 0);
67 inline connectivity
::OSQLInternalNode
* newNode
(const OUString
& _NewValue
,
68 const connectivity
::SQLNodeType eNodeType
,
69 const sal_uInt32 nNodeID
= 0);
72 // yyi is the internal number of the rule that is currently being reduced
73 // This can be mapped to extrnal rule number via the yyrmap.
74 #define SQL_NEW_RULE newNode("", SQL_NODE_RULE, yyr1[yyn])
75 #define SQL_NEW_LISTRULE newNode("", SQL_NODE_LISTRULE, yyr1[yyn])
76 #define SQL_NEW_COMMALISTRULE newNode("", SQL_NODE_COMMALISTRULE, yyr1[yyn])
79 extern connectivity
::OSQLParser
* xxx_pGLOBAL_SQLPARSER
;
81 #if !(defined MACOSX && defined PPC)
82 #define YYERROR_VERBOSE
85 #define SQLyyerror(s) \
87 xxx_pGLOBAL_SQLPARSER
->error(s
); \
90 using namespace connectivity
;
91 #define SQLyylex xxx_pGLOBAL_SQLPARSER->SQLlex
96 connectivity
::OSQLParseNode
* pParseNode
;
98 %type
<pParseNode
> '(' ')' ',' ':' ';' '?' '[' ']' '{' '}' '.' 'K' 'M' 'G' 'T' 'P'
100 %token
<pParseNode
> SQL_TOKEN_STRING SQL_TOKEN_ACCESS_DATE SQL_TOKEN_INT SQL_TOKEN_REAL_NUM
101 %token
<pParseNode
> SQL_TOKEN_INTNUM SQL_TOKEN_APPROXNUM SQL_TOKEN_NOT SQL_TOKEN_NAME
104 %nonassoc
<pParseNode
> SQL_TOKEN_UMINUS
108 /* literal keyword tokens */
110 %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
112 %token
<pParseNode
> SQL_TOKEN_BETWEEN SQL_TOKEN_BIT SQL_TOKEN_BOTH SQL_TOKEN_BY
114 %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
115 %token
<pParseNode
> SQL_TOKEN_CURRENT SQL_TOKEN_CURSOR
117 %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
118 %token
<pParseNode
> SQL_TOKEN_DISTINCT SQL_TOKEN_DOUBLE SQL_TOKEN_DROP
120 %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
122 %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
124 %left
<pParseNode
> SQL_TOKEN_JOIN
125 %token
<pParseNode
> SQL_TOKEN_KEY SQL_TOKEN_LEADING SQL_TOKEN_LIKE SQL_TOKEN_LOCAL SQL_TOKEN_LOWER
126 %token
<pParseNode
> SQL_TOKEN_MAX SQL_TOKEN_MIN SQL_TOKEN_NATURAL SQL_TOKEN_NCHAR SQL_TOKEN_NULL SQL_TOKEN_NUMERIC
128 %token
<pParseNode
> SQL_TOKEN_OCTET_LENGTH SQL_TOKEN_OF SQL_TOKEN_ON SQL_TOKEN_OPTION SQL_TOKEN_ORDER SQL_TOKEN_OUTER
130 %token
<pParseNode
> SQL_TOKEN_PRECISION SQL_TOKEN_PRIMARY SQL_TOKEN_PRIVILEGES SQL_TOKEN_PROCEDURE SQL_TOKEN_PUBLIC
131 %token
<pParseNode
> SQL_TOKEN_REAL SQL_TOKEN_REFERENCES SQL_TOKEN_ROLLBACK
133 %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
135 %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
136 %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
137 %token
<pParseNode
> SQL_TOKEN_WHERE SQL_TOKEN_WITH SQL_TOKEN_WORK SQL_TOKEN_ZONE
140 %token
<pParseNode
> SQL_TOKEN_CALL SQL_TOKEN_D SQL_TOKEN_FN SQL_TOKEN_T SQL_TOKEN_TS SQL_TOKEN_OJ
141 /* string functions */
142 %token
<pParseNode
> SQL_TOKEN_ASCII SQL_TOKEN_BIT_LENGTH SQL_TOKEN_CHAR SQL_TOKEN_CHAR_LENGTH SQL_TOKEN_SQL_TOKEN_INTNUM
143 %token
<pParseNode
> SQL_TOKEN_CONCAT
144 %token
<pParseNode
> SQL_TOKEN_DIFFERENCE SQL_TOKEN_INSERT SQL_TOKEN_LCASE SQL_TOKEN_LEFT SQL_TOKEN_LENGTH SQL_TOKEN_LOCATE
145 %token
<pParseNode
> SQL_TOKEN_LOCATE_2 SQL_TOKEN_LTRIM SQL_TOKEN_POSITION SQL_TOKEN_REPEAT SQL_TOKEN_REPLACE
146 %token
<pParseNode
> SQL_TOKEN_RIGHT SQL_TOKEN_RTRIM SQL_TOKEN_SOUNDEX SQL_TOKEN_SPACE SQL_TOKEN_SUBSTRING SQL_TOKEN_UCASE
148 /* time and date functions */
149 %token
<pParseNode
> SQL_TOKEN_CURRENT_DATE SQL_TOKEN_CURRENT_TIME SQL_TOKEN_CURRENT_TIMESTAMP SQL_TOKEN_CURDATE SQL_TOKEN_CURTIME
150 %token
<pParseNode
> SQL_TOKEN_DAYNAME SQL_TOKEN_DAYOFMONTH SQL_TOKEN_DAYOFWEEK SQL_TOKEN_DAYOFYEAR SQL_TOKEN_EXTRACT
151 %token
<pParseNode
> SQL_TOKEN_HOUR SQL_TOKEN_MINUTE SQL_TOKEN_MONTH SQL_TOKEN_MONTHNAME SQL_TOKEN_NOW SQL_TOKEN_QUARTER SQL_TOKEN_DATEDIFF
152 %token
<pParseNode
> SQL_TOKEN_SECOND SQL_TOKEN_TIMESTAMPADD SQL_TOKEN_TIMESTAMPDIFF SQL_TOKEN_TIMEVALUE SQL_TOKEN_WEEK SQL_TOKEN_YEAR
154 /* numeric functions */
155 %token
<pParseNode
> SQL_TOKEN_ABS SQL_TOKEN_ACOS SQL_TOKEN_ASIN SQL_TOKEN_ATAN SQL_TOKEN_ATAN2 SQL_TOKEN_CEILING
156 %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
157 %token
<pParseNode
> SQL_TOKEN_LOG10 SQL_TOKEN_MOD SQL_TOKEN_PI SQL_TOKEN_POWER SQL_TOKEN_RADIANS SQL_TOKEN_RAND SQL_TOKEN_ROUNDMAGIC
158 %token
<pParseNode
> SQL_TOKEN_ROUND SQL_TOKEN_SIGN SQL_TOKEN_SIN SQL_TOKEN_SQRT SQL_TOKEN_TAN SQL_TOKEN_TRUNCATE
160 // computational operation
161 %token
<pParseNode
> SQL_TOKEN_EVERY SQL_TOKEN_INTERSECTION SQL_TOKEN_FUSION SQL_TOKEN_COLLECT SQL_TOKEN_VAR_POP SQL_TOKEN_VAR_SAMP
162 %token
<pParseNode
> SQL_TOKEN_STDDEV_SAMP SQL_TOKEN_STDDEV_POP
164 %token
<pParseNode
> SQL_TOKEN_RANK SQL_TOKEN_DENSE_RANK SQL_TOKEN_PERCENT_RANK SQL_TOKEN_CUME_DIST SQL_TOKEN_PERCENTILE_CONT SQL_TOKEN_PERCENTILE_DISC SQL_TOKEN_WITHIN SQL_TOKEN_ARRAY_AGG
165 %token
<pParseNode
> SQL_TOKEN_CASE SQL_TOKEN_THEN SQL_TOKEN_END SQL_TOKEN_NULLIF SQL_TOKEN_COALESCE SQL_TOKEN_WHEN SQL_TOKEN_ELSE
166 %token
<pParseNode
> SQL_TOKEN_BEFORE SQL_TOKEN_AFTER SQL_TOKEN_INSTEAD SQL_TOKEN_EACH SQL_TOKEN_REFERENCING SQL_TOKEN_BEGIN SQL_TOKEN_ATOMIC SQL_TOKEN_TRIGGER SQL_TOKEN_ROW SQL_TOKEN_STATEMENT
167 %token
<pParseNode
> SQL_TOKEN_NEW SQL_TOKEN_OLD
168 %token
<pParseNode
> SQL_TOKEN_VALUE SQL_TOKEN_CURRENT_CATALOG SQL_TOKEN_CURRENT_DEFAULT_TRANSFORM_GROUP SQL_TOKEN_CURRENT_PATH SQL_TOKEN_CURRENT_ROLE SQL_TOKEN_CURRENT_SCHEMA SQL_TOKEN_CURRENT_USER
169 %token
<pParseNode
> SQL_TOKEN_SESSION_USER SQL_TOKEN_SYSTEM_USER SQL_TOKEN_VARCHAR SQL_TOKEN_VARBINARY SQL_TOKEN_VARYING SQL_TOKEN_OBJECT SQL_TOKEN_NCLOB SQL_TOKEN_NATIONAL
170 %token
<pParseNode
> SQL_TOKEN_LARGE SQL_TOKEN_CLOB SQL_TOKEN_BLOB SQL_TOKEN_BIGINT SQL_TOKEN_BINARY SQL_TOKEN_WITHOUT SQL_TOKEN_BOOLEAN SQL_TOKEN_INTERVAL
172 %token
<pParseNode
> SQL_TOKEN_OVER SQL_TOKEN_ROW_NUMBER SQL_TOKEN_NTILE SQL_TOKEN_LEAD SQL_TOKEN_LAG SQL_TOKEN_RESPECT SQL_TOKEN_IGNORE SQL_TOKEN_NULLS
173 %token
<pParseNode
> SQL_TOKEN_FIRST_VALUE SQL_TOKEN_LAST_VALUE SQL_TOKEN_NTH_VALUE SQL_TOKEN_FIRST SQL_TOKEN_LAST
174 %token
<pParseNode
> SQL_TOKEN_EXCLUDE SQL_TOKEN_OTHERS SQL_TOKEN_TIES SQL_TOKEN_FOLLOWING SQL_TOKEN_UNBOUNDED SQL_TOKEN_PRECEDING SQL_TOKEN_RANGE SQL_TOKEN_ROWS
175 %token
<pParseNode
> SQL_TOKEN_PARTITION SQL_TOKEN_WINDOW SQL_TOKEN_NO
177 %token
<pParseNode
> SQL_TOKEN_LIMIT SQL_TOKEN_OFFSET SQL_TOKEN_NEXT SQL_TOKEN_ONLY
181 %left
<pParseNode
> SQL_TOKEN_OR
182 %left
<pParseNode
> SQL_TOKEN_AND
184 %left
<pParseNode
> SQL_LESSEQ SQL_GREATEQ SQL_NOTEQUAL SQL_LESS SQL_GREAT SQL_EQUAL
/* '<' '>' = <> < > <= >= != */
185 %left
<pParseNode
> '+' '-' SQL_CONCAT
186 %left
<pParseNode
> '*' '/'
187 %left SQL_TOKEN_NATURAL SQL_TOKEN_CROSS SQL_TOKEN_FULL SQL_TOKEN_LEFT SQL_TOKEN_RIGHT
194 %token
<pParseNode
> SQL_TOKEN_INVALIDSYMBOL
196 /*%type <pParseNode> sql_single_statement */
198 %type
<pParseNode
> sql
/*schema */
199 %type
<pParseNode
> column_def_opt_list column_def_opt table_constraint_def column_commalist
200 %type
<pParseNode
> view_def opt_with_check_option opt_column_commalist privilege_def
201 %type
<pParseNode
> opt_with_grant_option privileges operation_commalist operation
202 %type
<pParseNode
> grantee_commalist grantee opt_order_by_clause ordering_spec_commalist
203 %type
<pParseNode
> ordering_spec opt_asc_desc manipulative_statement commit_statement
204 %type
<pParseNode
> /*delete_statement_positioned*/ delete_statement_searched fetch_statement
205 %type
<pParseNode
> insert_statement values_or_query_spec
206 %type
<pParseNode
> rollback_statement select_statement_into opt_all_distinct
207 %type
<pParseNode
> /*update_statement_positioned*/ assignment_commalist assignment
208 %type
<pParseNode
> update_statement_searched target_commalist target opt_where_clause
209 %type
<pParseNode
> select_statement selection table_exp from_clause table_ref_commalist table_ref
210 %type
<pParseNode
> where_clause opt_group_by_clause column_ref_commalist opt_having_clause
211 %type
<pParseNode
> search_condition predicate comparison_predicate comparison_predicate_part_2 between_predicate between_predicate_part_2
212 %type
<pParseNode
> like_predicate opt_escape test_for_null null_predicate_part_2 in_predicate in_predicate_part_2 character_like_predicate_part_2 other_like_predicate_part_2
213 %type
<pParseNode
> all_or_any_predicate any_all_some existence_test subquery quantified_comparison_predicate_part_2
214 %type
<pParseNode
> scalar_exp_commalist parameter_ref literal parenthesized_boolean_value_expression
215 %type
<pParseNode
> column_ref data_type column cursor parameter range_variable user
/*like_check*/
216 /* neue Regeln bei OJ */
217 %type
<pParseNode
> derived_column as_clause table_name num_primary term num_value_exp
218 %type
<pParseNode
> value_exp_primary num_value_fct unsigned_value_spec cast_spec set_fct_spec scalar_subquery
219 %type
<pParseNode
> position_exp extract_exp length_exp general_value_spec
220 %type
<pParseNode
> general_set_fct set_fct_type query_exp non_join_query_exp joined_table
221 %type
<pParseNode
> non_join_query_term non_join_query_primary simple_table
222 %type
<pParseNode
> table_value_const_list row_value_constructor row_value_const_list row_value_constructor_elem
223 %type
<pParseNode
> qualified_join value_exp query_term join_type outer_join_type join_condition boolean_term
224 %type
<pParseNode
> boolean_factor boolean_primary named_columns_join join_spec
225 %type
<pParseNode
> cast_operand cast_target factor datetime_value_exp
/*interval_value_exp*/ datetime_term datetime_factor
226 %type
<pParseNode
> datetime_primary datetime_value_fct time_zone time_zone_specifier
/*interval_term*/ interval_qualifier
227 %type
<pParseNode
> start_field non_second_datetime_field end_field single_datetime_field extract_field datetime_field time_zone_field
228 %type
<pParseNode
> extract_source char_length_exp octet_length_exp bit_length_exp select_sublist string_value_exp
229 %type
<pParseNode
> char_value_exp concatenation char_factor char_primary string_value_fct char_substring_fct fold
230 %type
<pParseNode
> form_conversion char_translation trim_fct trim_operands trim_spec bit_value_fct bit_substring_fct op_column_commalist
231 %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
232 %type
<pParseNode
> function_arg_commalist3 string_function_3Argument function_arg_commalist4 string_function_4Argument function_arg_commalist2 string_function_1Argument string_function_2Argument
233 %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
234 %type
<pParseNode
> all query_primary sql_not for_length upper_lower comparison column_val cross_union
/*opt_schema_element_list*/
235 %type
<pParseNode
> /*op_authorization op_schema*/ nil_fkt schema_element base_table_def base_table_element base_table_element_commalist
236 %type
<pParseNode
> column_def odbc_fct_spec odbc_call_spec odbc_fct_type op_parameter union_statement
237 %type
<pParseNode
> op_odbc_call_parameter odbc_parameter_commalist odbc_parameter function_args_commalist function_arg
238 %type
<pParseNode
> catalog_name schema_name table_node numeric_function string_function function_name date_function table_primary_as_range_column opt_as
239 %type
<pParseNode
> ordered_set_function inverse_distribution_function hypothetical_set_function hypothetical_set_function_value_expression_list rank_function_type within_group_specification inverse_distribution_function_type array_aggregate_function inverse_distribution_function_argument
240 %type
<pParseNode
> case_expression else_clause result_expression result case_abbreviation case_specification searched_when_clause simple_when_clause searched_case simple_case
241 %type
<pParseNode
> when_operand_list when_operand case_operand
242 %type
<pParseNode
> trigger_definition trigger_name trigger_action_time trigger_event transition_table_or_variable_list triggered_action trigger_column_list triggered_when_clause triggered_SQL_statement SQL_procedure_statement old_transition_variable_name new_transition_variable_name
243 %type
<pParseNode
> op_referencing op_trigger_columnlist op_triggered_action_for opt_row trigger_for SQL_procedure_statement_list transition_table_or_variable old_transition_table_name new_transition_table_name transition_table_name
244 %type
<pParseNode
> searched_when_clause_list simple_when_clause_list predefined_type opt_char_set_spec opt_collate_clause character_string_type national_character_string_type
245 %type
<pParseNode
> binary_string_type numeric_type boolean_type datetime_type interval_type opt_paren_precision paren_char_length opt_paren_char_large_length paren_character_large_object_length
246 %type
<pParseNode
> large_object_length opt_multiplier character_large_object_type national_character_large_object_type binary_large_object_string_type opt_with_or_without_time_zone
247 %type
<pParseNode
> approximate_numeric_type exact_numeric_type opt_paren_precision_scale
248 /* window function rules */
249 %type
<pParseNode
> window_function window_function_type ntile_function number_of_tiles lead_or_lag_function lead_or_lag lead_or_lag_extent offset default_expression null_treatment
250 %type
<pParseNode
> first_or_last_value_function first_or_last_value nth_value_function nth_row from_first_or_last window_name_or_specification in_line_window_specification opt_lead_or_lag_function
251 %type
<pParseNode
> opt_null_treatment opt_from_first_or_last simple_value_specification dynamic_parameter_specification window_name window_clause window_definition_list window_definition
252 %type
<pParseNode
> new_window_name window_specification_details existing_window_name window_partition_clause window_partition_column_reference_list window_partition_column_reference window_frame_clause
253 %type
<pParseNode
> window_frame_units window_frame_extent window_frame_start window_frame_preceding window_frame_between window_frame_bound_1 window_frame_bound_2 window_frame_bound window_frame_following window_frame_exclusion
254 %type
<pParseNode
> opt_window_frame_clause opt_window_partition_clause opt_existing_window_name window_specification opt_window_frame_exclusion opt_window_clause opt_offset
255 %type
<pParseNode
> opt_fetch_first_row_count fetch_first_clause offset_row_count fetch_first_row_count first_or_next row_or_rows opt_result_offset_clause result_offset_clause
256 /* LIMIT and OFFSET */
257 %type
<pParseNode
> opt_limit_offset_clause limit_offset_clause opt_fetch_first_clause
260 /* Parse Tree an OSQLParser zurueckliefern
261 * (der Zugriff ueber yyval nach Aufruf des Parsers scheitert,
264 sql_single_statement:
266 { xxx_pGLOBAL_SQLPARSER
->setParseTree
( $1 ); }
268 { xxx_pGLOBAL_SQLPARSER
->setParseTree
( $1 ); }
271 /* schema definition language */
272 /* Note: other ``sql:sal_Unicode() rules appear later in the grammar */
275 manipulative_statement
287 | SQL_TOKEN_AUTHORIZATION user
297 | SQL_TOKEN_NAME '.' SQL_TOKEN_NAME
301 $$->append(newNode(".", SQL_NODE_PUNCTUATION));
307 SQL_TOKEN_CREATE SQL_TOKEN_SCHEMA op_schema op_authorization opt_schema_element_list
318 opt_schema_element_list:
320 | schema_glement_list
325 {$$ = SQL_NEW_LISTRULE;
327 | schema_element_list schema_element
341 SQL_TOKEN_CREATE SQL_TOKEN_TABLE table_node
'(' base_table_element_commalist
')'
346 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
348 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));}
351 base_table_element_commalist:
353 {$$
= SQL_NEW_COMMALISTRULE
;
355 | base_table_element_commalist
',' base_table_element
362 | table_constraint_def
366 column data_type column_def_opt_list
375 /* empty */ {$$
= SQL_NEW_LISTRULE
;}
376 | column_def_opt_list column_def_opt
386 | SQL_TOKEN_PRIMARY SQL_TOKEN_KEY
394 SQL_TOKEN_NOT SQL_TOKEN_NULL
399 | SQL_TOKEN_DEFAULT literal
403 | SQL_TOKEN_DEFAULT SQL_TOKEN_NULL
407 | SQL_TOKEN_DEFAULT SQL_TOKEN_USER
411 | SQL_TOKEN_DEFAULT nil_fkt
418 | SQL_TOKEN_CHECK
'(' search_condition
')'
421 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
423 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));}
424 | SQL_TOKEN_REFERENCES table_node
428 | SQL_TOKEN_REFERENCES table_node
'(' column_commalist
')'
432 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
434 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));}
437 table_constraint_def:
438 unique_spec
'(' column_commalist
')'
441 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
443 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));}
444 | SQL_TOKEN_FOREIGN SQL_TOKEN_KEY
'(' column_commalist
')' SQL_TOKEN_REFERENCES table_node
448 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
450 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
453 | SQL_TOKEN_FOREIGN SQL_TOKEN_KEY
'(' column_commalist
')' SQL_TOKEN_REFERENCES table_node
'(' column_commalist
')'
457 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
459 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
462 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
464 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));}
465 | SQL_TOKEN_CHECK
'(' search_condition
')'
468 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
470 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));}
473 /* empty */ {$$
= SQL_NEW_RULE
;}
474 |
'(' column_commalist
')'
476 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
478 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
482 column_commalist
',' column
486 {$$
= SQL_NEW_COMMALISTRULE
;
491 SQL_TOKEN_CREATE SQL_TOKEN_VIEW table_node opt_column_commalist SQL_TOKEN_AS select_statement opt_with_check_option
502 opt_with_check_option:
503 /* empty */ {$$
= SQL_NEW_RULE
;}
504 | SQL_TOKEN_WITH SQL_TOKEN_CHECK SQL_TOKEN_OPTION
511 opt_column_commalist:
512 /* empty */ {$$
= SQL_NEW_RULE
;}
513 |
'(' column_commalist
')'
515 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
517 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));}
521 SQL_TOKEN_GRANT privileges SQL_TOKEN_ON table_node SQL_TOKEN_TO grantee_commalist
522 opt_with_grant_option
533 opt_with_grant_option:
534 /* empty */ {$$
= SQL_NEW_RULE
;}
535 | SQL_TOKEN_WITH SQL_TOKEN_GRANT SQL_TOKEN_OPTION
543 SQL_TOKEN_ALL SQL_TOKEN_PRIVILEGES
547 | operation_commalist
552 {$$
= SQL_NEW_COMMALISTRULE
;
554 | operation_commalist
',' operation
561 | SQL_TOKEN_INSERT opt_column_commalist
566 | SQL_TOKEN_UPDATE opt_column_commalist
570 | SQL_TOKEN_REFERENCES opt_column_commalist
580 {$$
= SQL_NEW_COMMALISTRULE
;
582 | grantee_commalist
',' grantee
592 /* module language */
595 /* empty */ {$$
= SQL_NEW_RULE
;}
596 | SQL_TOKEN_ORDER SQL_TOKEN_BY ordering_spec_commalist
603 ordering_spec_commalist:
605 {$$
= SQL_NEW_COMMALISTRULE
;
607 | ordering_spec_commalist
',' ordering_spec
613 /* SQL_TOKEN_INTNUM opt_asc_desc
618 predicate opt_asc_desc
623 | row_value_constructor_elem opt_asc_desc
637 manipulative_statement_list:
638 manipulative_statement
639 {$$ = SQL_NEW_LISTRULE;
641 | manipulative_statement_list manipulative_statement
653 /* manipulative statements */
655 manipulative_statement:
657 /* | delete_statement_positioned*/
658 | delete_statement_searched
662 | select_statement_into
663 /* | update_statement_positioned*/
664 | update_statement_searched
666 |
'{' odbc_call_spec
'}'
669 $$
->append
(newNode
("{", SQL_NODE_PUNCTUATION
));
671 $$
->append
(newNode
("}", SQL_NODE_PUNCTUATION
));
677 | union_statement SQL_TOKEN_UNION all select_statement
687 SQL_TOKEN_COMMIT SQL_TOKEN_WORK
693 delete_statement_positioned:
694 SQL_TOKEN_DELETE SQL_TOKEN_FROM table_node SQL_TOKEN_WHERE SQL_TOKEN_CURRENT SQL_TOKEN_OF cursor
705 delete_statement_searched:
706 SQL_TOKEN_DELETE SQL_TOKEN_FROM table_node opt_where_clause
715 SQL_TOKEN_FETCH cursor SQL_TOKEN_INTO target_commalist
724 SQL_TOKEN_INSERT SQL_TOKEN_INTO table_node opt_column_commalist query_exp
732 values_or_query_spec:
733 SQL_TOKEN_VALUES
'(' table_value_const_list
')'
736 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
738 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
742 table_value_const_list:
743 row_value_constructor
744 {$$
= SQL_NEW_COMMALISTRULE
;
746 | table_value_const_list
',' row_value_constructor
750 row_value_const_list:
751 row_value_constructor_elem
752 {$$
= SQL_NEW_COMMALISTRULE
;
754 | row_value_const_list
',' row_value_constructor_elem
758 row_value_constructor:
759 row_value_constructor_elem
760 /* | '(' row_value_const_list ')'
763 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
765 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
769 row_value_constructor_elem:
776 SQL_TOKEN_ROLLBACK SQL_TOKEN_WORK
783 /* INTO target_commalist herausgenommen */
784 select_statement_into:
785 SQL_TOKEN_SELECT opt_all_distinct selection SQL_TOKEN_INTO target_commalist table_exp
802 update_statement_positioned:
803 SQL_TOKEN_UPDATE table_node SQL_TOKEN_SET assignment_commalist
804 SQL_TOKEN_WHERE SQL_TOKEN_CURRENT SQL_TOKEN_OF cursor
816 assignment_commalist:
818 {$$
= SQL_NEW_COMMALISTRULE
;
820 | assignment_commalist
',' assignment
826 column SQL_EQUAL update_source
836 update_statement_searched:
837 SQL_TOKEN_UPDATE table_node SQL_TOKEN_SET assignment_commalist opt_where_clause
848 {$$
= SQL_NEW_COMMALISTRULE
;
850 | target_commalist
',' target
860 /* empty */ {$$
= SQL_NEW_RULE
;}
864 /* query expressions */
873 /* SELECT STATEMENT */
875 SQL_TOKEN_SELECT opt_all_distinct selection table_exp
889 $$
->append
(newNode
("*", SQL_NODE_PUNCTUATION
));
891 | scalar_exp_commalist
893 opt_result_offset_clause:
894 /* empty */ {$$
= SQL_NEW_RULE
;}
895 | result_offset_clause
897 result_offset_clause:
898 SQL_TOKEN_OFFSET offset_row_count row_or_rows
906 opt_fetch_first_row_count:
907 /* empty */ {$$
= SQL_NEW_RULE
;}
908 | fetch_first_row_count
918 opt_fetch_first_clause:
919 /* empty */ {$$
= SQL_NEW_RULE
;}
923 SQL_TOKEN_FETCH first_or_next opt_fetch_first_row_count row_or_rows SQL_TOKEN_ONLY
936 fetch_first_row_count:
940 opt_limit_offset_clause:
941 /* empty */ {$$
= SQL_NEW_RULE
;}
942 | limit_offset_clause
945 /* empty */ {$$
= SQL_NEW_RULE
;}
946 | SQL_TOKEN_OFFSET SQL_TOKEN_INTNUM
954 SQL_TOKEN_LIMIT SQL_TOKEN_INTNUM opt_offset
963 from_clause opt_where_clause opt_group_by_clause opt_having_clause opt_window_clause opt_order_by_clause opt_limit_offset_clause opt_result_offset_clause opt_fetch_first_clause
979 SQL_TOKEN_FROM table_ref_commalist
988 { $$
= SQL_NEW_COMMALISTRULE
;
990 | table_ref_commalist
',' table_ref
996 /* empty */ {$$
= SQL_NEW_RULE
;}
1000 /* empty */ {$$
= SQL_NEW_RULE
;}
1003 table_primary_as_range_column:
1004 {$$
= SQL_NEW_RULE
;}
1005 | opt_as SQL_TOKEN_NAME op_column_commalist
1014 table_node table_primary_as_range_column
1020 | subquery range_variable op_column_commalist
1028 |
'{' SQL_TOKEN_OJ joined_table
'}'
1031 $$
->append
(newNode
("{", SQL_NODE_PUNCTUATION
));
1034 $$
->append
(newNode
("}", SQL_NODE_PUNCTUATION
));
1036 |
'(' joined_table
')'
1039 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
1041 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
1045 SQL_TOKEN_WHERE search_condition
1051 opt_group_by_clause:
1052 /* empty */ {$$
= SQL_NEW_RULE
;}
1053 | SQL_TOKEN_GROUP SQL_TOKEN_BY column_ref_commalist
1060 column_ref_commalist:
1062 {$$
= SQL_NEW_COMMALISTRULE
;
1065 {$$
= SQL_NEW_COMMALISTRULE
;
1067 | column_ref_commalist
',' column_ref
1070 | column_ref_commalist
',' set_fct_spec
1076 /* empty */ {$$
= SQL_NEW_RULE
;}
1077 | SQL_TOKEN_HAVING search_condition
1083 /* search conditions */
1086 |
'(' search_condition
')'
1087 { // boolean_primary: rule 2
1089 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
1091 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
1093 | row_value_constructor_elem
/*[^')' ',']*/
1095 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
())// boolean_primary: rule 3
1099 if
( SQL_ISTOKEN
( $1, NULL
))
1101 OSQLParseNode
* pColumnRef
= newNode
("", SQL_NODE_RULE
,OSQLParser
::RuleID
(OSQLParseNode
::column_ref
));
1102 pColumnRef
->append
(newNode
(xxx_pGLOBAL_SQLPARSER
->getFieldName
(),SQL_NODE_NAME
));
1103 OSQLParseNode
* pTFN
= new OSQLInternalNode
("", SQL_NODE_RULE
,OSQLParser
::RuleID
(OSQLParseNode
::test_for_null
));
1104 pTFN
->append
(pColumnRef
);
1106 OSQLParseNode
* pNPP2
= new OSQLInternalNode
("", SQL_NODE_RULE
, OSQLParser
::RuleID
(OSQLParseNode
::null_predicate_part_2
));
1107 pNPP2
->append
(new OSQLInternalNode
("", SQL_NODE_KEYWORD
, SQL_TOKEN_IS
));
1108 pNPP2
->append
(new OSQLInternalNode
("", SQL_NODE_RULE
, OSQLParser
::RuleID
(OSQLParseNode
::sql_not
)));
1109 pNPP2
->append
(new OSQLInternalNode
("", SQL_NODE_KEYWORD
, SQL_TOKEN_NULL
));
1110 pTFN
->append
(pNPP2
);
1118 nErg
= xxx_pGLOBAL_SQLPARSER
->buildComparsionRule
($$
,$1);
1122 OSQLParseNode
* pTemp
= $$
;
1123 $$
= pTemp
->removeAt
((sal_uInt32
)0);
1139 parenthesized_boolean_value_expression:
1140 '(' search_condition
')'
1141 { // boolean_primary: rule 2
1143 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
1145 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
1149 boolean_primary %dprec
2
1150 | SQL_TOKEN_NOT boolean_primary %dprec
1
1151 { // boolean_factor: rule 1
1159 | boolean_term SQL_TOKEN_AND boolean_factor
1161 $$
= SQL_NEW_RULE
; // boolean_term: rule 1
1169 | search_condition SQL_TOKEN_OR boolean_term
1171 $$
= SQL_NEW_RULE
; // search_condition
1178 comparison_predicate %dprec
1
1180 | all_or_any_predicate
1183 | test_for_null %dprec
2
1187 comparison_predicate_part_2:
1188 comparison row_value_constructor
1190 $$
= SQL_NEW_RULE
; // comparison_predicate: rule 1
1194 comparison_predicate:
1195 row_value_constructor comparison row_value_constructor
1197 $$
= SQL_NEW_RULE
; // comparison_predicate: rule 1
1202 | comparison row_value_constructor
1204 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
()) // comparison_predicate: rule 2
1207 sal_Int16 nErg
= xxx_pGLOBAL_SQLPARSER
->buildPredicateRule
($$
,$2,$1);
1210 OSQLParseNode
* pTemp
= $$
;
1211 $$
= pTemp
->removeAt
((sal_uInt32
)0);
1233 | SQL_TOKEN_IS sql_not SQL_TOKEN_DISTINCT SQL_TOKEN_FROM
1241 | SQL_TOKEN_IS sql_not
1248 between_predicate_part_2:
1249 sql_not SQL_TOKEN_BETWEEN row_value_constructor SQL_TOKEN_AND row_value_constructor
1251 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
()) // between_predicate: rule 2
1255 sal_Int16 nErg
= xxx_pGLOBAL_SQLPARSER
->buildPredicateRule
($$
,$3,$2,$5);
1258 OSQLParseNode
* pTemp
= $$
;
1259 $$
= pTemp
->removeAt
((sal_uInt32
)0);
1260 OSQLParseNode
* pColumnRef
= $$
->removeAt
((sal_uInt32
)0);
1262 OSQLParseNode
* pBetween_predicate
= new OSQLInternalNode
("", SQL_NODE_RULE
,OSQLParser
::RuleID
(OSQLParseNode
::between_predicate
));
1263 pBetween_predicate
->append
(pColumnRef
);
1264 pBetween_predicate
->append
($$
);
1265 $$
= pBetween_predicate
;
1278 $$
= SQL_NEW_RULE
; // between_predicate: rule 1
1287 row_value_constructor between_predicate_part_2
1289 $$
= SQL_NEW_RULE
; // between_predicate: rule 1
1293 | between_predicate_part_2
1295 character_like_predicate_part_2:
1296 sql_not SQL_TOKEN_LIKE string_value_exp opt_escape
1298 $$
= SQL_NEW_RULE
; // like_predicate: rule 1
1305 other_like_predicate_part_2:
1306 sql_not SQL_TOKEN_LIKE value_exp_primary opt_escape
1308 $$
= SQL_NEW_RULE
; // like_predicate: rule 1
1316 row_value_constructor character_like_predicate_part_2
1318 $$
= SQL_NEW_RULE
; // like_predicate: rule 1
1322 | row_value_constructor other_like_predicate_part_2
1324 $$
= SQL_NEW_RULE
; // like_predicate: rule 3
1328 | character_like_predicate_part_2
1330 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
()) // like_predicate: rule 5
1332 OSQLParseNode
* pColumnRef
= newNode
("", SQL_NODE_RULE
,OSQLParser
::RuleID
(OSQLParseNode
::column_ref
));
1333 pColumnRef
->append
(newNode
(xxx_pGLOBAL_SQLPARSER
->getFieldName
(),SQL_NODE_NAME
));
1336 $$
->append
(pColumnRef
);
1338 OSQLParseNode
* p2nd
= $1->removeAt
(2);
1339 OSQLParseNode
* p3rd
= $1->removeAt
(2);
1340 if
( !xxx_pGLOBAL_SQLPARSER
->buildLikeRule
($1,p2nd
,p3rd
) )
1350 | other_like_predicate_part_2
1352 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
()) // like_predicate: rule 6
1354 OSQLParseNode
* pColumnRef
= newNode
("", SQL_NODE_RULE
,OSQLParser
::RuleID
(OSQLParseNode
::column_ref
));
1355 pColumnRef
->append
(newNode
(xxx_pGLOBAL_SQLPARSER
->getFieldName
(),SQL_NODE_NAME
));
1358 $$
->append
(pColumnRef
);
1360 OSQLParseNode
* p2nd
= $1->removeAt
(2);
1361 OSQLParseNode
* p3rd
= $1->removeAt
(2);
1362 if
( !xxx_pGLOBAL_SQLPARSER
->buildLikeRule
($1,p2nd
,p3rd
) )
1375 /* empty */ {$$
= SQL_NEW_RULE
;}
1376 | SQL_TOKEN_ESCAPE string_value_exp
1380 |
'{' SQL_TOKEN_ESCAPE SQL_TOKEN_STRING
'}'
1383 $$
->append
(newNode
("{", SQL_NODE_PUNCTUATION
));
1386 $$
->append
(newNode
("}", SQL_NODE_PUNCTUATION
));
1390 null_predicate_part_2:
1391 SQL_TOKEN_IS sql_not SQL_TOKEN_NULL
1393 $$
= SQL_NEW_RULE
; // test_for_null: rule 1
1398 | SQL_TOKEN_IS sql_not SQL_TOKEN_UNKNOWN
1400 $$
= SQL_NEW_RULE
; // test_for_null: rule 1
1407 row_value_constructor null_predicate_part_2
1409 $$
= SQL_NEW_RULE
; // test_for_null: rule 1
1413 | null_predicate_part_2
1415 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
())// test_for_null: rule 2
1417 OSQLParseNode
* pColumnRef
= newNode
("", SQL_NODE_RULE
,OSQLParser
::RuleID
(OSQLParseNode
::column_ref
));
1418 pColumnRef
->append
(newNode
(xxx_pGLOBAL_SQLPARSER
->getFieldName
(),SQL_NODE_NAME
));
1421 $$
->append
(pColumnRef
);
1433 |
'(' value_exp_commalist
')'
1435 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
1437 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
1440 in_predicate_part_2:
1441 sql_not SQL_TOKEN_IN in_predicate_value
1443 $$
= SQL_NEW_RULE
;// in_predicate: rule 1
1450 row_value_constructor in_predicate_part_2
1452 $$
= SQL_NEW_RULE
;// in_predicate: rule 1
1456 | in_predicate_part_2
1458 if
( xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
() )// in_predicate: rule 2
1460 OSQLParseNode
* pColumnRef
= newNode
("", SQL_NODE_RULE
,OSQLParser
::RuleID
(OSQLParseNode
::column_ref
));
1461 pColumnRef
->append
(newNode
(xxx_pGLOBAL_SQLPARSER
->getFieldName
(),SQL_NODE_NAME
));
1464 $$
->append
(pColumnRef
);
1471 quantified_comparison_predicate_part_2:
1472 comparison any_all_some subquery
1480 all_or_any_predicate:
1481 row_value_constructor quantified_comparison_predicate_part_2
1487 | quantified_comparison_predicate_part_2
1489 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
())
1491 OSQLParseNode
* pColumnRef
= newNode
("", SQL_NODE_RULE
,OSQLParser
::RuleID
(OSQLParseNode
::column_ref
));
1492 pColumnRef
->append
(newNode
(xxx_pGLOBAL_SQLPARSER
->getFieldName
(),SQL_NODE_NAME
));
1495 $$
->append
(pColumnRef
);
1510 SQL_TOKEN_EXISTS subquery
1516 SQL_TOKEN_UNIQUE subquery
1524 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
1526 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));}
1529 /* scalar expressions */
1530 scalar_exp_commalist:
1533 $$
= SQL_NEW_COMMALISTRULE
;
1536 | scalar_exp_commalist
',' select_sublist
1543 /* table_node '.' '*'
1547 $$->append(newNode(".", SQL_NODE_PUNCTUATION));
1548 $$->append(newNode("*", SQL_NODE_PUNCTUATION));
1563 $$ = newNode("*", SQL_NODE_PUNCTUATION);
1567 $$ = newNode("?", SQL_NODE_PUNCTUATION);
1573 $$->append(newNode("*", SQL_NODE_PUNCTUATION));
1574 xxx_pGLOBAL_SQLPARSER->reduceLiteral($$, sal_False);
1580 $$->append(newNode("?", SQL_NODE_PUNCTUATION));
1581 xxx_pGLOBAL_SQLPARSER->reduceLiteral($$, sal_False);
1589 | SQL_TOKEN_REAL_NUM
1591 | SQL_TOKEN_APPROXNUM
1592 | SQL_TOKEN_ACCESS_DATE
1593 /* rules for predicate check */
1594 | literal SQL_TOKEN_STRING
1596 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
())
1601 xxx_pGLOBAL_SQLPARSER
->reduceLiteral
($$
, sal_True
);
1606 | literal SQL_TOKEN_INT
1608 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
())
1613 xxx_pGLOBAL_SQLPARSER
->reduceLiteral
($$
, sal_True
);
1618 | literal SQL_TOKEN_REAL_NUM
1620 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
())
1625 xxx_pGLOBAL_SQLPARSER
->reduceLiteral
($$
, sal_True
);
1630 | literal SQL_TOKEN_APPROXNUM
1632 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
())
1637 xxx_pGLOBAL_SQLPARSER
->reduceLiteral
($$
, sal_True
);
1646 /* empty */ {$$
= SQL_NEW_RULE
;}
1647 | SQL_TOKEN_AS column
1656 SQL_TOKEN_POSITION
'(' value_exp SQL_TOKEN_IN value_exp
')'
1660 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
1664 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
1666 | SQL_TOKEN_POSITION
'(' value_exp_commalist
')'
1670 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
1672 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
1681 SQL_TOKEN_CHAR_LENGTH
'(' value_exp
')'
1685 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
1687 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
1689 | SQL_TOKEN_SQL_TOKEN_INTNUM
'(' value_exp
')'
1693 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
1695 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
1700 SQL_TOKEN_OCTET_LENGTH
'(' value_exp
')'
1704 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
1706 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
1710 SQL_TOKEN_BIT_LENGTH
'(' value_exp
')'
1714 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
1716 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
1737 non_second_datetime_field
1754 SQL_TOKEN_TIMEZONE_HOUR
1759 | SQL_TOKEN_TIMEZONE_MINUTE
1771 /* | interval_value_exp
1778 SQL_TOKEN_EXTRACT
'(' extract_field SQL_TOKEN_FROM value_exp
')'
1782 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
1786 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
1789 unsigned_value_spec:
1800 | SQL_TOKEN_CURRENT_CATALOG
1801 | SQL_TOKEN_CURRENT_DEFAULT_TRANSFORM_GROUP
1802 | SQL_TOKEN_CURRENT_PATH
1803 | SQL_TOKEN_CURRENT_ROLE
1804 | SQL_TOKEN_CURRENT_SCHEMA
1805 | SQL_TOKEN_CURRENT_USER
1806 | SQL_TOKEN_SESSION_USER
1807 | SQL_TOKEN_SYSTEM_USER
1811 |
'{' odbc_fct_spec
'}'
1814 $$
->append
(newNode
("{", SQL_NODE_PUNCTUATION
));
1816 $$
->append
(newNode
("}", SQL_NODE_PUNCTUATION
));
1818 | function_name
'(' ')'
1822 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
1823 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
1825 | function_name0
'(' ')'
1829 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
1830 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
1832 | function_name1
'(' function_arg
')'
1836 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
1838 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
1840 | function_name2
'(' function_arg_commalist2
')'
1844 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
1846 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
1848 | function_name3
'(' function_arg_commalist3
')'
1852 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
1854 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
1856 | string_function_4Argument
'(' function_arg_commalist4
')'
1860 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
1862 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
1864 | function_name
'(' function_args_commalist
')'
1868 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
1870 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
1872 | function_name12
'(' function_args_commalist
')'
1874 if
( $3->count
() == 1 ||
$3->count
() == 2 )
1878 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
1880 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
1885 | function_name23
'(' function_args_commalist
')'
1887 if
( $3->count
() == 2 ||
$3->count
() == 3)
1891 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
1893 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
1900 date_function_0Argument
1901 | numeric_function_0Argument
1904 string_function_1Argument
1905 | date_function_1Argument
1906 | numeric_function_1Argument
1909 string_function_2Argument
1910 | numeric_function_2Argument
1920 | SQL_TOKEN_DATEDIFF
1923 string_function_3Argument
1931 string_function_1Argument:
1941 string_function_2Argument:
1946 string_function_3Argument:
1949 string_function_4Argument:
1956 | SQL_TOKEN_DIFFERENCE
1957 | SQL_TOKEN_LOCATE_2
1960 date_function_0Argument:
1965 date_function_1Argument:
1967 | SQL_TOKEN_DAYOFMONTH
1968 | SQL_TOKEN_DAYOFYEAR
1971 | SQL_TOKEN_MONTHNAME
1978 | SQL_TOKEN_TIMEVALUE
1979 | SQL_TOKEN_DATEVALUE
1983 SQL_TOKEN_TIMESTAMPADD
1984 | SQL_TOKEN_TIMESTAMPDIFF
1986 numeric_function_0Argument:
1989 numeric_function_1Argument:
2007 | SQL_TOKEN_ROUNDMAGIC
2009 numeric_function_2Argument:
2016 | SQL_TOKEN_TRUNCATE
2020 window_function_type SQL_TOKEN_OVER window_name_or_specification
2028 window_function_type
:
2029 rank_function_type
'(' ')'
2033 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
2034 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
2036 | SQL_TOKEN_ROW_NUMBER
'(' ')'
2040 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
2041 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
2045 | lead_or_lag_function
2046 | first_or_last_value_function
2047 | nth_value_function
2050 SQL_TOKEN_NTILE
'(' number_of_tiles
')'
2054 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
2056 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
2059 dynamic_parameter_specification:
2062 simple_value_specification:
2066 simple_value_specification
2067 | dynamic_parameter_specification
2069 opt_lead_or_lag_function:
2070 /* empty */ {$$
= SQL_NEW_RULE
;}
2074 $$
->append
(newNode
(",", SQL_NODE_PUNCTUATION
));
2077 |
',' offset
',' default_expression
2080 $$
->append
(newNode
(",", SQL_NODE_PUNCTUATION
));
2082 $$
->append
(newNode
(",", SQL_NODE_PUNCTUATION
));
2087 /* empty */ {$$
= SQL_NEW_RULE
;}
2091 lead_or_lag_function:
2092 lead_or_lag
'(' lead_or_lag_extent opt_lead_or_lag_function
')' opt_null_treatment
2096 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
2099 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
2117 SQL_TOKEN_RESPECT SQL_TOKEN_NULLS
2118 | SQL_TOKEN_IGNORE SQL_TOKEN_NULLS
2120 first_or_last_value_function:
2121 first_or_last_value
'(' value_exp
')' opt_null_treatment
2125 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
2127 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
2131 first_or_last_value
:
2132 SQL_TOKEN_FIRST_VALUE
2133 | SQL_TOKEN_LAST_VALUE
2135 opt_from_first_or_last:
2136 /* empty */ {$$
= SQL_NEW_RULE
;}
2137 | from_first_or_last
2140 SQL_TOKEN_NTH_VALUE
'(' value_exp
',' nth_row
')' opt_from_first_or_last opt_null_treatment
2144 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
2146 $$
->append
(newNode
(",", SQL_NODE_PUNCTUATION
));
2148 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
2154 simple_value_specification
2155 | dynamic_parameter_specification
2158 SQL_TOKEN_FROM SQL_TOKEN_FIRST
2164 | SQL_TOKEN_FROM SQL_TOKEN_LAST
2174 window_name_or_specification:
2176 | in_line_window_specification
2178 in_line_window_specification:
2179 window_specification
2182 /* empty */ {$$
= SQL_NEW_RULE
;}
2186 SQL_TOKEN_WINDOW window_definition_list
2193 window_definition_list:
2194 window_definition_list
',' window_definition
2198 {$$
= SQL_NEW_COMMALISTRULE
;
2202 new_window_name SQL_TOKEN_AS window_specification
2213 window_specification:
2214 '(' window_specification_details
')'
2217 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
2219 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
2222 opt_existing_window_name:
2223 /* empty */ {$$
= SQL_NEW_RULE
;}
2224 | existing_window_name
2226 opt_window_partition_clause:
2227 /* empty */ {$$
= SQL_NEW_RULE
;}
2228 | window_partition_clause
2230 opt_window_frame_clause:
2231 /* empty */ {$$
= SQL_NEW_RULE
;}
2232 | window_frame_clause
2234 window_specification_details:
2235 opt_existing_window_name
2236 opt_window_partition_clause
2238 opt_window_frame_clause
2240 existing_window_name:
2243 window_partition_clause:
2244 SQL_TOKEN_PARTITION SQL_TOKEN_BY window_partition_column_reference_list
2252 window_partition_column_reference_list:
2253 window_partition_column_reference_list
',' window_partition_column_reference
2256 | window_partition_column_reference
2257 {$$
= SQL_NEW_COMMALISTRULE
;
2260 window_partition_column_reference:
2261 column_ref opt_collate_clause
2268 opt_window_frame_exclusion:
2269 /* empty */ {$$
= SQL_NEW_RULE
;}
2270 | window_frame_exclusion
2272 window_frame_clause:
2273 window_frame_units window_frame_extent opt_window_frame_exclusion
2285 window_frame_extent:
2287 | window_frame_between
2290 SQL_TOKEN_UNBOUNDED SQL_TOKEN_PRECEDING
2296 | window_frame_preceding
2297 | SQL_TOKEN_CURRENT SQL_TOKEN_ROW
2304 window_frame_preceding:
2305 unsigned_value_spec SQL_TOKEN_PRECEDING
2312 window_frame_between:
2313 SQL_TOKEN_BETWEEN window_frame_bound_1 SQL_TOKEN_AND window_frame_bound_2
2322 window_frame_bound_1:
2325 window_frame_bound_2:
2330 | SQL_TOKEN_UNBOUNDED SQL_TOKEN_FOLLOWING
2336 | window_frame_following
2338 window_frame_following:
2339 unsigned_value_spec SQL_TOKEN_FOLLOWING
2346 window_frame_exclusion:
2347 SQL_TOKEN_EXCLUDE SQL_TOKEN_CURRENT SQL_TOKEN_ROW
2354 | SQL_TOKEN_EXCLUDE SQL_TOKEN_GROUP
2360 | SQL_TOKEN_EXCLUDE SQL_TOKEN_TIES
2366 | SQL_TOKEN_EXCLUDE SQL_TOKEN_NO SQL_TOKEN_OTHERS
2375 {$$
= SQL_NEW_RULE
;}
2379 $$
->append
(newNode
("?", SQL_NODE_PUNCTUATION
));
2384 op_parameter SQL_TOKEN_CALL table_node op_odbc_call_parameter
2394 op_odbc_call_parameter:
2395 {$$
= SQL_NEW_RULE
;}
2396 |
'(' odbc_parameter_commalist
')'
2399 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
2401 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
2405 odbc_parameter_commalist:
2407 {$$
= SQL_NEW_COMMALISTRULE
;
2409 | odbc_parameter_commalist
',' odbc_parameter
2416 /* empty */ {$$
= SQL_NEW_RULE
;}
2422 odbc_fct_type SQL_TOKEN_STRING
2428 | SQL_TOKEN_FN set_fct_spec
2443 set_fct_type
'(' opt_all_distinct function_arg
')'
2447 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
2450 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
2452 | SQL_TOKEN_COUNT
'(' '*' ')'
2456 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
2457 $$
->append
(newNode
("*", SQL_NODE_PUNCTUATION
));
2458 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
2460 | SQL_TOKEN_COUNT
'(' opt_all_distinct function_arg
')'
2464 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
2467 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
2469 | ordered_set_function
2470 | array_aggregate_function
2480 | SQL_TOKEN_STDDEV_POP
2481 | SQL_TOKEN_STDDEV_SAMP
2482 | SQL_TOKEN_VAR_SAMP
2486 | SQL_TOKEN_INTERSECTION
2489 ordered_set_function:
2490 hypothetical_set_function
2491 | inverse_distribution_function
2493 hypothetical_set_function:
2494 rank_function_type
'(' hypothetical_set_function_value_expression_list
')' within_group_specification
2498 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
2500 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
2503 | rank_function_type
'(' hypothetical_set_function_value_expression_list SQL_TOKEN_BY value_exp_commalist
')' within_group_specification
2507 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
2511 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
2516 within_group_specification:
2520 | SQL_TOKEN_WITHIN SQL_TOKEN_GROUP
'(' opt_order_by_clause
')'
2525 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
2527 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
2530 hypothetical_set_function_value_expression_list:
2534 inverse_distribution_function:
2535 inverse_distribution_function_type
'('inverse_distribution_function_argument
')' within_group_specification
2539 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
2541 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
2544 inverse_distribution_function_argument:
2547 inverse_distribution_function_type:
2548 SQL_TOKEN_PERCENTILE_CONT
2549 | SQL_TOKEN_PERCENTILE_DISC
2552 array_aggregate_function:
2553 SQL_TOKEN_ARRAY_AGG
'(' value_exp opt_order_by_clause
')'
2557 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
2560 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
2566 | SQL_TOKEN_DENSE_RANK
2567 | SQL_TOKEN_PERCENT_RANK
2568 | SQL_TOKEN_CUME_DIST
2571 SQL_TOKEN_LEFT %prec SQL_TOKEN_LEFT
2576 | SQL_TOKEN_RIGHT %prec SQL_TOKEN_RIGHT
2581 | SQL_TOKEN_FULL %prec SQL_TOKEN_FULL
2588 SQL_TOKEN_ON search_condition
2597 | named_columns_join
2600 /* empty */ {$$
= SQL_NEW_RULE
;}
2607 | outer_join_type SQL_TOKEN_OUTER
2615 table_ref SQL_TOKEN_CROSS SQL_TOKEN_JOIN table_ref
2626 /* wenn SQL_TOKEN_NATURAL, dann keine join_spec */
2627 table_ref SQL_TOKEN_NATURAL join_type SQL_TOKEN_JOIN table_ref
2636 | table_ref join_type SQL_TOKEN_JOIN table_ref join_spec
2651 SQL_TOKEN_USING
'(' column_commalist
')'
2655 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
2657 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
2662 | values_or_query_spec
2665 non_join_query_primary:
2667 |
'(' non_join_query_exp
')'
2670 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
2672 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
2675 non_join_query_term:
2676 non_join_query_primary
2677 | query_term SQL_TOKEN_INTERSECT all query_primary
2687 non_join_query_primary
2691 | query_exp SQL_TOKEN_UNION all query_term
2699 | query_exp SQL_TOKEN_EXCEPT all query_term
2709 /* empty*/ {$$
= SQL_NEW_RULE
;}
2713 non_join_query_exp
/*[^')']*/
2726 SQL_TOKEN_CAST
'(' cast_operand SQL_TOKEN_AS cast_target
')'
2730 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
2734 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
2747 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
2749 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
2760 |
'-' num_primary %prec SQL_TOKEN_UMINUS
2763 $$
->append
(newNode
("-", SQL_NODE_PUNCTUATION
));
2766 |
'+' num_primary %prec SQL_TOKEN_UMINUS
2769 $$
->append
(newNode
("+", SQL_NODE_PUNCTUATION
));
2780 $$
->append
(newNode
("*", SQL_NODE_PUNCTUATION
));
2787 $$
->append
(newNode
("/", SQL_NODE_PUNCTUATION
));
2794 | num_value_exp
'+' term
2798 $$
->append
(newNode
("+", SQL_NODE_PUNCTUATION
));
2801 | num_value_exp
'-' term
2805 $$
->append
(newNode
("-", SQL_NODE_PUNCTUATION
));
2810 /* value_exp_primary
2815 |*/ datetime_value_fct
2822 SQL_TOKEN_CURRENT_DATE
2827 | SQL_TOKEN_CURRENT_TIME
2832 | SQL_TOKEN_CURRENT_TIMESTAMP
2839 SQL_TOKEN_AT time_zone_specifier
2846 time_zone_specifier:
2852 /* | SQL_TOKEN_TIME SQL_TOKEN_ZONE interval_value_exp
2866 | datetime_primary time_zone
2883 | interval_term '*' factor
2887 $$->append(newNode("*", SQL_NODE_PUNCTUATION));
2890 | interval_term '/' factor
2894 $$->append(newNode("/", SQL_NODE_PUNCTUATION));
2905 /* | interval_value_exp '+' datetime_term
2909 $$->append(newNode("+", SQL_NODE_PUNCTUATION));
2912 | datetime_value_exp '+' interval_term
2916 $$->append(newNode("+", SQL_NODE_PUNCTUATION));
2919 | datetime_value_exp '-' interval_term
2923 $$->append(newNode("-", SQL_NODE_PUNCTUATION));
2934 | interval_value_exp '+' interval_term
2938 $$->append(newNode("+", SQL_NODE_PUNCTUATION));
2941 | interval_value_exp '-' interval_term
2945 $$->append(newNode("-", SQL_NODE_PUNCTUATION));
2948 | '(' datetime_value_exp '-' datetime_term ')' interval_qualifier
2951 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
2953 $$->append(newNode("-", SQL_NODE_PUNCTUATION));
2955 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
2960 non_second_datetime_field:
2968 non_second_datetime_field opt_paren_precision
2976 non_second_datetime_field
2977 | SQL_TOKEN_SECOND opt_paren_precision
2985 single_datetime_field:
2986 non_second_datetime_field opt_paren_precision
2992 | SQL_TOKEN_SECOND opt_paren_precision_scale
3001 start_field SQL_TOKEN_TO end_field
3008 | single_datetime_field
3011 function_arg_commalist2:
3012 function_arg
',' function_arg
3013 {$$
= SQL_NEW_COMMALISTRULE
;
3017 function_arg_commalist3:
3018 function_arg
',' function_arg
',' function_arg
3020 $$
= SQL_NEW_COMMALISTRULE
;
3026 function_arg_commalist4:
3027 function_arg
',' function_arg
',' function_arg
',' function_arg
3029 $$
= SQL_NEW_COMMALISTRULE
;
3036 value_exp_commalist:
3038 {$$
= SQL_NEW_COMMALISTRULE
;
3040 | value_exp_commalist
',' value_exp
3043 /* this rule is only valid if we check predicates */
3044 | value_exp_commalist
';' value_exp
3046 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
())
3057 | value_exp comparison value_exp
3064 | value_exp SQL_TOKEN_USING value_exp comparison value_exp
3072 | value_exp SQL_TOKEN_BY value_exp_commalist
3080 function_args_commalist:
3082 {$$
= SQL_NEW_COMMALISTRULE
;
3084 | function_args_commalist
',' function_arg
3087 /* this rule is only valid if we check predicates */
3088 | function_args_commalist
';' function_arg
3090 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
())
3101 num_value_exp
/*[^')']*/
3103 | datetime_value_exp
3122 char_value_exp
'+' char_factor
3126 $$
->append
(newNode
("+", SQL_NODE_PUNCTUATION
));
3129 | value_exp SQL_CONCAT value_exp
3143 SQL_TOKEN_COLLATE table_node
3152 | char_primary collate_clause
3171 SQL_TOKEN_SUBSTRING
'(' bit_value_exp SQL_TOKEN_FROM string_value_exp for_length
')'
3175 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
3180 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
3198 bit_value_exp '+' bit_factor
3202 $$->append(newNode("+", SQL_NODE_PUNCTUATION));
3215 {$$
= SQL_NEW_RULE
;}
3216 /* value_exp_primary
3247 {$$
= SQL_NEW_RULE
;}
3248 | SQL_TOKEN_FOR value_exp
3256 SQL_TOKEN_SUBSTRING
'(' value_exp SQL_TOKEN_FROM value_exp for_length
')'
3260 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
3265 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
3267 | SQL_TOKEN_SUBSTRING
'(' value_exp_commalist
')'
3271 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
3273 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
3281 upper_lower
'(' value_exp
')'
3285 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
3287 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
3291 SQL_TOKEN_CONVERT
'(' string_value_exp SQL_TOKEN_USING table_node
')'
3295 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
3299 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
3301 | SQL_TOKEN_CONVERT
'(' cast_operand
',' cast_target
')'
3305 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
3307 $$
->append
(newNode
(",", SQL_NODE_PUNCTUATION
));
3309 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
3313 SQL_TOKEN_TRANSLATE
'(' string_value_exp SQL_TOKEN_USING table_node
')'
3317 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
3321 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
3325 SQL_TOKEN_TRIM
'(' trim_operands
')'
3329 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
3331 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
3335 trim_spec value_exp SQL_TOKEN_FROM value_exp
3343 | trim_spec SQL_TOKEN_FROM value_exp
3350 | value_exp SQL_TOKEN_FROM value_exp
3357 | SQL_TOKEN_FROM value_exp
3369 | SQL_TOKEN_TRAILING
3387 SQL_TOKEN_NAME
'.' schema_name
3391 $$
->append
(newNode
(".", SQL_NODE_PUNCTUATION
));
3394 | SQL_TOKEN_NAME
':' schema_name
3398 $$
->append
(newNode
(":", SQL_NODE_PUNCTUATION
));
3403 SQL_TOKEN_NAME
'.' table_name
3407 $$
->append
(newNode
(".", SQL_NODE_PUNCTUATION
));
3422 /* | table_node '.' column_val %prec '.'
3425 $$->append(newNode(".", SQL_NODE_PUNCTUATION));
3428 | SQL_TOKEN_NAME
'.' column_val %prec
'.'
3431 $$
->append
(newNode
(".", SQL_NODE_PUNCTUATION
));
3434 | SQL_TOKEN_NAME
'.' SQL_TOKEN_NAME
'.' column_val %prec
'.'
3437 $$
->append
(newNode
(".", SQL_NODE_PUNCTUATION
));
3439 $$
->append
(newNode
(".", SQL_NODE_PUNCTUATION
));
3441 | SQL_TOKEN_NAME
'.' SQL_TOKEN_NAME
'.' SQL_TOKEN_NAME
'.' column_val %prec
'.'
3444 $$
->append
(newNode
(".", SQL_NODE_PUNCTUATION
));
3446 $$
->append
(newNode
(".", SQL_NODE_PUNCTUATION
));
3448 $$
->append
(newNode
(".", SQL_NODE_PUNCTUATION
));
3451 | SQL_TOKEN_NAME
':' SQL_TOKEN_NAME
'.' SQL_TOKEN_NAME
'.' column_val %prec
'.'
3454 $$
->append
(newNode
(":", SQL_NODE_PUNCTUATION
));
3456 $$
->append
(newNode
(".", SQL_NODE_PUNCTUATION
));
3458 $$
->append
(newNode
(".", SQL_NODE_PUNCTUATION
));
3461 /* | SQL_TOKEN_NAME ';' SQL_TOKEN_NAME '.' SQL_TOKEN_NAME '.' column_val
3464 $$->append(newNode(";", SQL_NODE_PUNCTUATION));
3466 $$->append(newNode(".", SQL_NODE_PUNCTUATION));
3468 $$->append(newNode(".", SQL_NODE_PUNCTUATION));
3481 $$
->append
(newNode
("*", SQL_NODE_PUNCTUATION
));
3488 {$$
= SQL_NEW_RULE
;}
3489 | SQL_TOKEN_CHARACTER SQL_TOKEN_SET SQL_TOKEN_NAME
3498 {$$
= SQL_NEW_RULE
;}
3502 character_string_type opt_char_set_spec opt_collate_clause
3509 | national_character_string_type opt_collate_clause
3515 | binary_string_type
3521 character_string_type:
3522 SQL_TOKEN_CHARACTER opt_paren_precision
3528 | SQL_TOKEN_CHAR opt_paren_precision
3534 | SQL_TOKEN_CHARACTER SQL_TOKEN_VARYING paren_char_length
3541 | SQL_TOKEN_CHAR SQL_TOKEN_VARYING paren_char_length
3548 | SQL_TOKEN_VARCHAR paren_char_length
3554 | character_large_object_type
3556 opt_paren_precision:
3557 {$$
= SQL_NEW_RULE
;}
3561 '(' SQL_TOKEN_INTNUM
')'
3564 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
3566 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
3569 opt_paren_char_large_length:
3570 {$$
= SQL_NEW_RULE
;}
3571 | paren_character_large_object_length
3573 paren_character_large_object_length:
3574 '(' large_object_length
')'
3577 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
3579 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
3583 large_object_length:
3584 SQL_TOKEN_INTNUM opt_multiplier
3592 {$$
= SQL_NEW_RULE
;}
3596 $$
->append
(newNode
("K", SQL_NODE_PUNCTUATION
));
3601 $$
->append
(newNode
("M", SQL_NODE_PUNCTUATION
));
3606 $$
->append
(newNode
("G", SQL_NODE_PUNCTUATION
));
3611 $$
->append
(newNode
("T", SQL_NODE_PUNCTUATION
));
3616 $$
->append
(newNode
("P", SQL_NODE_PUNCTUATION
));
3619 character_large_object_type:
3620 SQL_TOKEN_CHARACTER SQL_TOKEN_LARGE SQL_TOKEN_OBJECT opt_paren_char_large_length
3628 | SQL_TOKEN_CHAR SQL_TOKEN_LARGE SQL_TOKEN_OBJECT opt_paren_char_large_length
3636 | SQL_TOKEN_CLOB opt_paren_char_large_length
3643 national_character_string_type:
3644 SQL_TOKEN_NATIONAL SQL_TOKEN_CHARACTER opt_paren_precision
3651 | SQL_TOKEN_NATIONAL SQL_TOKEN_CHAR opt_paren_precision
3658 | SQL_TOKEN_NCHAR opt_paren_precision
3664 | SQL_TOKEN_NATIONAL SQL_TOKEN_CHARACTER SQL_TOKEN_VARYING paren_char_length
3672 | SQL_TOKEN_NATIONAL SQL_TOKEN_CHAR SQL_TOKEN_VARYING paren_char_length
3680 | SQL_TOKEN_NCHAR SQL_TOKEN_VARYING paren_char_length
3687 | national_character_large_object_type
3689 national_character_large_object_type:
3690 SQL_TOKEN_NATIONAL SQL_TOKEN_CHARACTER SQL_TOKEN_LARGE SQL_TOKEN_OBJECT opt_paren_char_large_length
3699 | SQL_TOKEN_NCHAR SQL_TOKEN_LARGE SQL_TOKEN_OBJECT opt_paren_char_large_length
3707 | SQL_TOKEN_NCLOB opt_paren_char_large_length
3715 SQL_TOKEN_BINARY opt_paren_precision
3721 | SQL_TOKEN_BINARY SQL_TOKEN_VARYING paren_char_length
3728 | SQL_TOKEN_VARBINARY paren_char_length
3734 | binary_large_object_string_type
3736 binary_large_object_string_type:
3737 SQL_TOKEN_BINARY SQL_TOKEN_LARGE SQL_TOKEN_OBJECT opt_paren_char_large_length
3745 | SQL_TOKEN_BLOB opt_paren_char_large_length
3754 | approximate_numeric_type
3756 opt_paren_precision_scale:
3757 {$$
= SQL_NEW_RULE
;}
3758 |
'(' SQL_TOKEN_INTNUM
')'
3761 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
3763 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
3765 |
'(' SQL_TOKEN_INTNUM
',' SQL_TOKEN_INTNUM
')'
3768 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
3770 $$
->append
(newNode
(",", SQL_NODE_PUNCTUATION
));
3772 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
3776 SQL_TOKEN_NUMERIC opt_paren_precision_scale
3782 | SQL_TOKEN_DECIMAL opt_paren_precision_scale
3788 | SQL_TOKEN_DEC opt_paren_precision_scale
3794 | SQL_TOKEN_SMALLINT
3799 approximate_numeric_type:
3800 SQL_TOKEN_FLOAT
'(' SQL_TOKEN_INTNUM
')'
3804 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
3806 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
3811 | SQL_TOKEN_DOUBLE SQL_TOKEN_PRECISION
3823 | SQL_TOKEN_TIME opt_paren_precision opt_with_or_without_time_zone
3830 | SQL_TOKEN_TIMESTAMP opt_paren_precision opt_with_or_without_time_zone
3838 opt_with_or_without_time_zone:
3839 {$$
= SQL_NEW_RULE
;}
3840 | SQL_TOKEN_WITH SQL_TOKEN_TIME SQL_TOKEN_ZONE
3847 | SQL_TOKEN_WITHOUT SQL_TOKEN_TIME SQL_TOKEN_ZONE
3856 SQL_TOKEN_INTERVAL interval_qualifier
3863 /* the various things you can name */
3867 | SQL_TOKEN_POSITION
3869 sal_uInt32 nNod
= $$
->getRuleID
();
3871 $$
= newNode
(xxx_pGLOBAL_SQLPARSER
->TokenIDToStr
(nNod
), SQL_NODE_NAME
);
3873 | SQL_TOKEN_CHAR_LENGTH
3875 sal_uInt32 nNod
= $$
->getRuleID
();
3877 $$
= newNode
(xxx_pGLOBAL_SQLPARSER
->TokenIDToStr
(nNod
), SQL_NODE_NAME
);
3881 sal_uInt32 nNod
= $$
->getRuleID
();
3883 $$
= newNode
(xxx_pGLOBAL_SQLPARSER
->TokenIDToStr
(nNod
), SQL_NODE_NAME
);
3888 | case_specification
3891 SQL_TOKEN_NULLIF
'(' value_exp_commalist
')'
3895 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
3897 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
3899 | SQL_TOKEN_COALESCE
'(' value_exp
')'
3903 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
3905 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
3907 | SQL_TOKEN_COALESCE
'(' value_exp_commalist
')'
3911 $$
->append
(newNode
("(", SQL_NODE_PUNCTUATION
));
3913 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
3921 SQL_TOKEN_CASE case_operand simple_when_clause_list else_clause SQL_TOKEN_END
3932 SQL_TOKEN_CASE searched_when_clause_list else_clause SQL_TOKEN_END
3941 simple_when_clause_list:
3944 $$
= SQL_NEW_LISTRULE
;
3947 | searched_when_clause_list simple_when_clause
3954 SQL_TOKEN_WHEN when_operand_list SQL_TOKEN_THEN result
3965 {$$
= SQL_NEW_COMMALISTRULE
;
3967 | when_operand_list
',' when_operand
3972 row_value_constructor_elem
3973 | comparison_predicate_part_2 %dprec
1
3974 | between_predicate_part_2
3975 | in_predicate_part_2
3976 | character_like_predicate_part_2
3977 | null_predicate_part_2 %dprec
2
3979 searched_when_clause_list:
3980 searched_when_clause
3982 $$
= SQL_NEW_LISTRULE
;
3985 | searched_when_clause_list searched_when_clause
3991 searched_when_clause:
3992 SQL_TOKEN_WHEN search_condition SQL_TOKEN_THEN result
4002 {$$
= SQL_NEW_RULE
;}
4003 | SQL_TOKEN_ELSE result
4017 row_value_constructor_elem
4020 cursor: SQL_TOKEN_NAME
4026 module: SQL_TOKEN_NAME
4035 $$
->append
(newNode
(":", SQL_NODE_PUNCTUATION
));
4038 {$$
= SQL_NEW_RULE
; // test
4039 $$
->append
(newNode
("?", SQL_NODE_PUNCTUATION
));}
4040 |
'[' SQL_TOKEN_NAME
']'
4042 $$
->append
(newNode
("[", SQL_NODE_PUNCTUATION
));
4044 $$
->append
(newNode
("]", SQL_NODE_PUNCTUATION
));}
4048 procedure: SQL_TOKEN_NAME
4055 {$$
= SQL_NEW_RULE
;}
4056 | opt_as SQL_TOKEN_NAME
4063 user: SQL_TOKEN_NAME
4066 /* PREDICATECHECK RULES */
4068 search_condition
/* checking predicats */
4070 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
()) // sql: rule 1
4073 if
( SQL_ISRULE
($$
,search_condition
) )
4075 $$
->insert
(0,newNode
("(", SQL_NODE_PUNCTUATION
));
4076 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
4082 |
'(' sql
')' /* checking predicats */
4085 SQL_TOKEN_CREATE SQL_TOKEN_TRIGGER trigger_name trigger_action_time trigger_event SQL_TOKEN_ON table_name op_referencing triggered_action
4103 | SQL_TOKEN_REFERENCING transition_table_or_variable_list
4110 trigger_action_time:
4113 | SQL_TOKEN_INSTEAD SQL_TOKEN_OF
4123 | SQL_TOKEN_UPDATE op_trigger_columnlist
4130 op_trigger_columnlist:
4134 | SQL_TOKEN_OF trigger_column_list
4141 trigger_column_list:
4145 op_triggered_action_for triggered_when_clause triggered_SQL_statement
4153 op_triggered_action_for:
4157 | SQL_TOKEN_FOR SQL_TOKEN_EACH trigger_for
4167 | SQL_TOKEN_STATEMENT
4169 triggered_when_clause:
4173 | SQL_TOKEN_WHEN parenthesized_boolean_value_expression
4180 triggered_SQL_statement:
4181 SQL_procedure_statement
4182 | SQL_TOKEN_BEGIN SQL_TOKEN_ATOMIC SQL_procedure_statement_list
';' SQL_TOKEN_END
4188 $$
->append
(newNode
(";", SQL_NODE_PUNCTUATION
));
4192 SQL_procedure_statement_list:
4193 SQL_procedure_statement
4195 $$
= SQL_NEW_LISTRULE
;
4198 | SQL_procedure_statement_list
';' SQL_procedure_statement
4204 SQL_procedure_statement:
4208 transition_table_or_variable_list:
4209 transition_table_or_variable
4211 $$
= SQL_NEW_LISTRULE
;
4214 | transition_table_or_variable_list transition_table_or_variable
4221 transition_table_or_variable:
4222 SQL_TOKEN_OLD opt_row opt_as old_transition_variable_name
4230 | SQL_TOKEN_NEW opt_row opt_as new_transition_variable_name
4238 | SQL_TOKEN_OLD SQL_TOKEN_TABLE opt_as old_transition_table_name
4246 | SQL_TOKEN_NEW SQL_TOKEN_TABLE opt_as new_transition_table_name
4255 old_transition_table_name:
4256 transition_table_name
4258 new_transition_table_name:
4259 transition_table_name
4261 transition_table_name:
4264 old_transition_variable_name:
4267 new_transition_variable_name:
4276 using namespace
::com
::sun
::star
::sdbc
;
4277 using namespace
::com
::sun
::star
::beans
;
4278 using namespace
::com
::sun
::star
::uno
;
4279 using namespace
::com
::sun
::star
::i18n
;
4280 using namespace
::com
::sun
::star
::lang
;
4281 using namespace
::com
::sun
::star
::util
;
4282 using namespace
::osl
;
4283 using namespace
::dbtools
;
4285 connectivity::OSQLInternalNode
* newNode
(const sal_Char
* pNewValue
,
4286 const connectivity
::SQLNodeType eNodeType
,
4287 const sal_uInt32 nNodeID
)
4289 return new connectivity
::OSQLInternalNode
(pNewValue
, eNodeType
, nNodeID
);
4292 connectivity::OSQLInternalNode
* newNode
(const OString
& _NewValue
,
4293 const connectivity
::SQLNodeType eNodeType
,
4294 const sal_uInt32 nNodeID
)
4296 return new connectivity
::OSQLInternalNode
(_NewValue
, eNodeType
, nNodeID
);
4299 connectivity::OSQLInternalNode
* newNode
(const OUString
& _NewValue
,
4300 const connectivity
::SQLNodeType eNodeType
,
4301 const sal_uInt32 nNodeID
)
4303 return new connectivity
::OSQLInternalNode
(_NewValue
, eNodeType
, nNodeID
);
4306 OParseContext::OParseContext
()
4311 OParseContext::~OParseContext
()
4316 OUString OParseContext
::getErrorMessage
(ErrorCode _eCode
) const
4321 case ERROR_GENERAL
: aMsg
= "Syntax error in SQL expression"; break
;
4322 case ERROR_VALUE_NO_LIKE
: aMsg
= "The value #1 can not be used with LIKE."; break
;
4323 case ERROR_FIELD_NO_LIKE
: aMsg
= "LIKE can not be used with this field."; break
;
4324 case ERROR_INVALID_COMPARE
: aMsg
= "The entered criterion can not be compared with this field."; break
;
4325 case ERROR_INVALID_INT_COMPARE
: aMsg
= "The field can not be compared with a number."; break
;
4326 case ERROR_INVALID_DATE_COMPARE
: aMsg
= "The field can not be compared with a date."; break
;
4327 case ERROR_INVALID_REAL_COMPARE
: aMsg
= "The field can not be compared with a floating point number."; break
;
4328 case ERROR_INVALID_TABLE_NOSUCH
: aMsg
= "The database does not contain a table named \"#\"."; break
;
4329 case ERROR_INVALID_TABLE_OR_QUERY
: aMsg
= "The database does contain neither a table nor a query named \"#\"."; break
;
4330 case ERROR_INVALID_COLUMN
: aMsg
= "The column \"#1\" is unknown in the table \"#2\"."; break
;
4331 case ERROR_INVALID_TABLE_EXIST
: aMsg
= "The database already contains a table or view with name \"#\"."; break
;
4332 case ERROR_INVALID_QUERY_EXIST
: aMsg
= "The database already contains a query with name \"#\"."; break
;
4334 OSL_FAIL
( "OParseContext::getErrorMessage: unknown error code!" );
4341 OString OParseContext
::getIntlKeywordAscii
(InternationalKeyCode _eKey
) const
4346 case KEY_LIKE
: aKeyword
= "LIKE"; break
;
4347 case KEY_NOT
: aKeyword
= "NOT"; break
;
4348 case KEY_NULL
: aKeyword
= "NULL"; break
;
4349 case KEY_TRUE
: aKeyword
= "True"; break
;
4350 case KEY_FALSE
: aKeyword
= "False"; break
;
4351 case KEY_IS
: aKeyword
= "IS"; break
;
4352 case KEY_BETWEEN
: aKeyword
= "BETWEEN"; break
;
4353 case KEY_OR
: aKeyword
= "OR"; break
;
4354 case KEY_AND
: aKeyword
= "AND"; break
;
4355 case KEY_AVG
: aKeyword
= "AVG"; break
;
4356 case KEY_COUNT
: aKeyword
= "COUNT"; break
;
4357 case KEY_MAX
: aKeyword
= "MAX"; break
;
4358 case KEY_MIN
: aKeyword
= "MIN"; break
;
4359 case KEY_SUM
: aKeyword
= "SUM"; break
;
4360 case KEY_EVERY
: aKeyword
= "EVERY"; break
;
4361 case KEY_ANY
: aKeyword
= "ANY"; break
;
4362 case KEY_SOME
: aKeyword
= "SOME"; break
;
4363 case KEY_STDDEV_POP
: aKeyword
= "STDDEV_POP"; break
;
4364 case KEY_STDDEV_SAMP
: aKeyword
= "STDDEV_SAMP"; break
;
4365 case KEY_VAR_SAMP
: aKeyword
= "VAR_SAMP"; break
;
4366 case KEY_VAR_POP
: aKeyword
= "VAR_POP"; break
;
4367 case KEY_COLLECT
: aKeyword
= "COLLECT"; break
;
4368 case KEY_FUSION
: aKeyword
= "FUSION"; break
;
4369 case KEY_INTERSECTION
:aKeyword
= "INTERSECTION"; break
;
4370 case KEY_NONE
: break
;
4372 OSL_FAIL
( "OParseContext::getIntlKeywordAscii: unknown key!" );
4379 IParseContext::InternationalKeyCode OParseContext
::getIntlKeyCode
(const OString
& rToken
) const
4381 static IParseContext
::InternationalKeyCode Intl_TokenID
[] =
4383 KEY_LIKE
, KEY_NOT
, KEY_NULL
, KEY_TRUE
,
4384 KEY_FALSE
, KEY_IS
, KEY_BETWEEN
, KEY_OR
,
4385 KEY_AND
, KEY_AVG
, KEY_COUNT
, KEY_MAX
,
4386 KEY_MIN
, KEY_SUM
, KEY_EVERY
,KEY_ANY
,KEY_SOME
,
4387 KEY_STDDEV_POP
,KEY_STDDEV_SAMP
,KEY_VAR_SAMP
,
4388 KEY_VAR_POP
,KEY_COLLECT
,KEY_FUSION
,KEY_INTERSECTION
4391 sal_uInt32 nCount
= SAL_N_ELEMENTS
( Intl_TokenID
);
4392 for
(sal_uInt32 i
= 0; i
< nCount
; i
++)
4394 OString aKey
= getIntlKeywordAscii
(Intl_TokenID
[i
]);
4395 if
(rToken.equalsIgnoreAsciiCase
(aKey
))
4396 return Intl_TokenID
[i
];
4403 static Locale
& impl_getLocaleInstance
( )
4405 static Locale s_aLocale
( "en", "US", "" );
4410 Locale OParseContext
::getPreferredLocale
( ) const
4412 return getDefaultLocale
();
4416 const Locale
& OParseContext
::getDefaultLocale
()
4418 return impl_getLocaleInstance
();
4421 // Der (leider globale) yylval fuer die Uebergabe von
4422 // Werten vom Scanner an den Parser. Die globale Variable
4423 // wird nur kurzzeitig verwendet, der Parser liest die Variable
4424 // sofort nach dem Scanner-Aufruf in eine gleichnamige eigene
4428 OUString ConvertLikeToken
(const OSQLParseNode
* pTokenNode
, const OSQLParseNode
* pEscapeNode
, bool bInternational
)
4430 OUStringBuffer aMatchStr
(0);
4431 if
(pTokenNode
->isToken
())
4433 sal_Unicode cEscape
= 0;
4434 if
(pEscapeNode
->count
())
4435 cEscape
= pEscapeNode
->getChild
(1)->getTokenValue
().toChar
();
4437 // Platzhalter austauschen
4438 aMatchStr
= pTokenNode
->getTokenValue
();
4439 const sal_Int32 nLen
= aMatchStr.getLength
();
4440 OUStringBuffer sSearch
,sReplace
;
4441 if
( bInternational
)
4443 sSearch.appendAscii
("%_",2);
4444 sReplace.appendAscii
("*?",2);
4448 sSearch.appendAscii
("*?",2);
4449 sReplace.appendAscii
("%_",2);
4452 bool wasEscape
= false
;
4453 for
(sal_Int32 i
= 0; i
< nLen
; i
++)
4455 const sal_Unicode c
= aMatchStr
[i
];
4456 // SQL standard requires the escape to be followed
4457 // by a meta-character ('%', '_' or itself), else error
4458 // We are more lenient here and let it escape anything.
4459 // Especially since some databases (e.g. Microsoft SQL Server)
4460 // have more meta-characters than the standard, such as e.g. '[' and ']'
4472 if
(c
== sSearch
[0])
4474 else if
(c
== sSearch
[1])
4479 aMatchStr
[i
] = sReplace
[match
];
4483 return aMatchStr.makeStringAndClear
();
4486 sal_uInt32 OSQLParser
::s_nRuleIDs
[OSQLParseNode
::rule_count
+ 1];
4487 OSQLParser::RuleIDMap OSQLParser
::s_aReverseRuleIDLookup
;
4488 OParseContext OSQLParser
::s_aDefaultContext
;
4490 sal_Int32 OSQLParser
::s_nRefCount
= 0;
4491 // ::osl::Mutex OSQLParser::s_aMutex;
4492 OSQLScanner
* OSQLParser
::s_pScanner
= 0;
4493 OSQLParseNodesGarbageCollector
* OSQLParser
::s_pGarbageCollector
= 0;
4494 ::com
::sun
::star
::uno
::Reference
< ::com
::sun
::star
::i18n
::XLocaleData4
> OSQLParser
::s_xLocaleData
= NULL
;
4496 void setParser
(OSQLParser
* _pParser
)
4498 xxx_pGLOBAL_SQLPARSER
= _pParser
;
4501 void OSQLParser
::setParseTree
(OSQLParseNode
* pNewParseTree
)
4503 ::osl
::MutexGuard aGuard
(getMutex
());
4504 m_pParseTree
= pNewParseTree
;
4508 /** Delete all comments in a query.
4510 See also getComment()/concatComment() implementation for
4511 OQueryController::translateStatement().
4513 static OUString delComment
( const OUString
& rQuery
)
4515 // First a quick search if there is any "--" or "//" or "/*", if not then the whole
4516 // copying loop is pointless.
4517 if
(rQuery.indexOfAsciiL
( "--", 2, 0) < 0 && rQuery.indexOfAsciiL
( "//", 2, 0) < 0 &&
4518 rQuery.indexOfAsciiL
( "/*", 2, 0) < 0)
4521 const sal_Unicode
* pCopy
= rQuery.getStr
();
4522 sal_Int32 nQueryLen
= rQuery.getLength
();
4523 bool bIsText1
= false
; // "text"
4524 bool bIsText2
= false
; // 'text'
4525 bool bComment2
= false
; // /* comment */
4526 bool bComment
= false
; // -- or // comment
4527 OUStringBuffer aBuf
(nQueryLen
);
4528 for
(sal_Int32 i
=0; i
< nQueryLen
; ++i
)
4532 if
((i
+1) < nQueryLen
)
4534 if
(pCopy
[i
]=='*' && pCopy
[i
+1]=='/')
4542 // comment can't close anymore, actually an error, but..
4546 if
(pCopy
[i
] == '\n')
4550 if
(pCopy
[i
] == '\"' && !bIsText2
)
4551 bIsText1
= !bIsText1
;
4552 else if
(pCopy
[i
] == '\'' && !bIsText1
)
4553 bIsText2
= !bIsText2
;
4554 if
(!bIsText1
&& !bIsText2
&& (i
+1) < nQueryLen
)
4556 if
((pCopy
[i
]=='-' && pCopy
[i
+1]=='-') ||
(pCopy
[i
]=='/' && pCopy
[i
+1]=='/'))
4558 else if
((pCopy
[i
]=='/' && pCopy
[i
+1]=='*'))
4562 if
(!bComment
&& !bComment2
)
4563 aBuf.append
( &pCopy
[i
], 1);
4565 return aBuf.makeStringAndClear
();
4568 OSQLParseNode
* OSQLParser
::parseTree
(OUString
& rErrorMessage
,
4569 const OUString
& rStatement
,
4570 bool bInternational
)
4574 // Guard the parsing
4575 ::osl
::MutexGuard aGuard
(getMutex
());
4579 // delete comments before parsing
4580 OUString sTemp
= delComment
(rStatement
);
4582 // defines how to scan
4583 s_pScanner
->SetRule
(s_pScanner
->GetSQLRule
()); // initial
4584 s_pScanner
->prepareScan
(sTemp
, m_pContext
, bInternational
);
4586 SQLyylval.pParseNode
= NULL
;
4588 m_pParseTree
= NULL
;
4589 m_sErrorMessage
= "";
4592 if
(SQLyyparse
() != 0)
4594 // only set the error message, if it's not already set
4595 if
(m_sErrorMessage.isEmpty
())
4596 m_sErrorMessage
= s_pScanner
->getErrorMessage
();
4597 if
(m_sErrorMessage.isEmpty
())
4598 m_sErrorMessage
= m_pContext
->getErrorMessage
(IParseContext
::ERROR_GENERAL
);
4600 rErrorMessage
= m_sErrorMessage
;
4602 // clear the garbage collector
4603 (*s_pGarbageCollector
)->clearAndDelete
();
4608 (*s_pGarbageCollector
)->clear
();
4611 // to work around a bug in MKS YACC return the member m_pParseTree
4612 // instead of Sdbyyval.pParseNode
4614 SAL_WARN_IF
(!m_pParseTree
, "connectivity.parse",
4615 "OSQLParser: Parser did not create ParseTree");
4616 return m_pParseTree
;
4620 OString OSQLParser
::TokenIDToStr
(sal_uInt32 nTokenID
, const IParseContext
* pContext
)
4625 IParseContext
::InternationalKeyCode eKeyCode
= IParseContext
::KEY_NONE
;
4628 case SQL_TOKEN_LIKE
: eKeyCode
= IParseContext
::KEY_LIKE
; break
;
4629 case SQL_TOKEN_NOT
: eKeyCode
= IParseContext
::KEY_NOT
; break
;
4630 case SQL_TOKEN_NULL
: eKeyCode
= IParseContext
::KEY_NULL
; break
;
4631 case SQL_TOKEN_TRUE
: eKeyCode
= IParseContext
::KEY_TRUE
; break
;
4632 case SQL_TOKEN_FALSE
: eKeyCode
= IParseContext
::KEY_FALSE
; break
;
4633 case SQL_TOKEN_IS
: eKeyCode
= IParseContext
::KEY_IS
; break
;
4634 case SQL_TOKEN_BETWEEN
: eKeyCode
= IParseContext
::KEY_BETWEEN
; break
;
4635 case SQL_TOKEN_OR
: eKeyCode
= IParseContext
::KEY_OR
; break
;
4636 case SQL_TOKEN_AND
: eKeyCode
= IParseContext
::KEY_AND
; break
;
4637 case SQL_TOKEN_AVG
: eKeyCode
= IParseContext
::KEY_AVG
; break
;
4638 case SQL_TOKEN_COUNT
: eKeyCode
= IParseContext
::KEY_COUNT
; break
;
4639 case SQL_TOKEN_MAX
: eKeyCode
= IParseContext
::KEY_MAX
; break
;
4640 case SQL_TOKEN_MIN
: eKeyCode
= IParseContext
::KEY_MIN
; break
;
4641 case SQL_TOKEN_SUM
: eKeyCode
= IParseContext
::KEY_SUM
; break
;
4643 if
( eKeyCode
!= IParseContext
::KEY_NONE
)
4644 aStr
= pContext
->getIntlKeywordAscii
(eKeyCode
);
4649 aStr
= yytname
[YYTRANSLATE
(nTokenID
)];
4650 if
(aStr.startsWith
("SQL_TOKEN_"))
4651 aStr
= aStr.copy
(10);
4658 aStr
= aStr.toAsciiLowerCase
();
4664 #if OSL_DEBUG_LEVEL > 1
4665 OUString OSQLParser
::RuleIDToStr
(sal_uInt32 nRuleID
)
4667 OSL_ENSURE
(nRuleID
< SAL_N_ELEMENTS
(yytname
), "OSQLParser::RuleIDToStr: Invalid nRuleId!");
4668 return OUString
::createFromAscii
(yytname
[nRuleID
]);
4673 sal_uInt32 OSQLParser
::StrToRuleID
(const OString
& rValue
)
4675 // Search for the given name in yytname and return the index
4676 // (or UNKNOWN_RULE, if not found)
4677 static sal_uInt32 nLen
= SAL_N_ELEMENTS
(yytname
);
4678 for
(sal_uInt32 i
= YYTRANSLATE
(SQL_TOKEN_INVALIDSYMBOL
); i
< (nLen
-1); i
++)
4680 if
(rValue
== yytname
[i
])
4685 return OSQLParseNode
::UNKNOWN_RULE
;
4689 OSQLParseNode::Rule OSQLParser
::RuleIDToRule
( sal_uInt32 _nRule
)
4691 OSQLParser
::RuleIDMap
::const_iterator i
(s_aReverseRuleIDLookup.find
(_nRule
));
4692 if
(i
== s_aReverseRuleIDLookup.end
())
4694 SAL_INFO
("connectivity.parse",
4695 "connectivity::OSQLParser::RuleIDToRule cannot reverse-lookup rule. "
4696 "Reverse mapping incomplete? "
4697 "_nRule='" << _nRule
<< "' "
4698 "yytname[_nRule]='" << yytname
[_nRule
] << "'");
4699 return OSQLParseNode
::UNKNOWN_RULE
;
4706 sal_uInt32 OSQLParser
::RuleID
(OSQLParseNode
::Rule eRule
)
4708 return s_nRuleIDs
[(sal_uInt16
)eRule
];
4711 sal_Int16 OSQLParser
::buildNode
(OSQLParseNode
*& pAppend
,OSQLParseNode
* pCompare
,OSQLParseNode
* pLiteral
,OSQLParseNode
* pLiteral2
)
4713 OSQLParseNode
* pColumnRef
= new OSQLInternalNode
("", SQL_NODE_RULE
,OSQLParser
::RuleID
(OSQLParseNode
::column_ref
));
4714 pColumnRef
->append
(new OSQLInternalNode
(m_sFieldName
,SQL_NODE_NAME
));
4715 OSQLParseNode
* pComp
= NULL
;
4716 if
( SQL_ISTOKEN
( pCompare
, BETWEEN
) && pLiteral2
)
4717 pComp
= new OSQLInternalNode
("", SQL_NODE_RULE
,OSQLParser
::RuleID
(OSQLParseNode
::between_predicate_part_2
));
4719 pComp
= new OSQLInternalNode
("", SQL_NODE_RULE
,OSQLParser
::RuleID
(OSQLParseNode
::comparison_predicate
));
4721 pComp
->append
(pColumnRef
);
4722 pComp
->append
(pCompare
);
4723 pComp
->append
(pLiteral
);
4726 pComp
->append
(new OSQLInternalNode
("", SQL_NODE_KEYWORD
,SQL_TOKEN_AND
));
4727 pComp
->append
(pLiteral2
);
4729 pAppend
->append
(pComp
);
4733 sal_Int16 OSQLParser
::buildStringNodes
(OSQLParseNode
*& pLiteral
)
4738 if
(SQL_ISRULE
(pLiteral
,set_fct_spec
) || SQL_ISRULE
(pLiteral
,general_set_fct
) || SQL_ISRULE
(pLiteral
,column_ref
)
4739 || SQL_ISRULE
(pLiteral
,subquery
))
4740 return
1; // here I have a function that I can't transform into a string
4742 if
(pLiteral
->getNodeType
() == SQL_NODE_INTNUM || pLiteral
->getNodeType
() == SQL_NODE_APPROXNUM || pLiteral
->getNodeType
() == SQL_NODE_ACCESS_DATE
)
4744 OSQLParseNode
* pParent
= pLiteral
->getParent
();
4746 OSQLParseNode
* pNewNode
= new OSQLInternalNode
(pLiteral
->getTokenValue
(), SQL_NODE_STRING
);
4747 pParent
->replace
(pLiteral
, pNewNode
);
4753 for
(sal_uInt32 i
=0;i
<pLiteral
->count
();++i
)
4755 OSQLParseNode
* pChild
= pLiteral
->getChild
(i
);
4756 buildStringNodes
(pChild
);
4758 if
(SQL_ISRULE
(pLiteral
,term
) || SQL_ISRULE
(pLiteral
,value_exp_primary
))
4760 m_sErrorMessage
= m_pContext
->getErrorMessage
(IParseContext
::ERROR_INVALID_COMPARE
);
4766 sal_Int16 OSQLParser
::buildComparsionRule
(OSQLParseNode
*& pAppend
,OSQLParseNode
* pLiteral
)
4768 OSQLParseNode
* pComp
= new OSQLInternalNode
("=", SQL_NODE_EQUAL
);
4769 return buildPredicateRule
(pAppend
,pLiteral
,pComp
);
4774 void OSQLParser
::reduceLiteral
(OSQLParseNode
*& pLiteral
, bool bAppendBlank
)
4776 OSL_ENSURE
(pLiteral
->isRule
(), "This is no Rule");
4777 OSL_ENSURE
(pLiteral
->count
() == 2, "OSQLParser::ReduceLiteral() Invalid count");
4778 OSQLParseNode
* pTemp
= pLiteral
;
4779 OUStringBuffer aValue
(pLiteral
->getChild
(0)->getTokenValue
());
4782 aValue.appendAscii
(" ");
4785 aValue.append
(pLiteral
->getChild
(1)->getTokenValue
());
4787 pLiteral
= new OSQLInternalNode
(aValue.makeStringAndClear
(),SQL_NODE_STRING
);
4792 void OSQLParser
::error(const sal_Char
*fmt
)
4794 if
(m_sErrorMessage.isEmpty
())
4796 OUString sStr
(fmt
,strlen
(fmt
),RTL_TEXTENCODING_UTF8
);
4797 OUString sSQL_TOKEN
("SQL_TOKEN_");
4799 sal_Int32 nPos1
= sStr.indexOf
(sSQL_TOKEN
);
4802 OUString sFirst
= sStr.copy
(0,nPos1
);
4803 sal_Int32 nPos2
= sStr.indexOf
(sSQL_TOKEN
,nPos1
+1);
4806 OUString sSecond
= sStr.copy
(nPos1
+sSQL_TOKEN.getLength
(),nPos2
-nPos1
-sSQL_TOKEN.getLength
());
4808 sFirst
+= sStr.copy
(nPos2
+sSQL_TOKEN.getLength
());
4811 sFirst
+= sStr.copy
(nPos1
+sSQL_TOKEN.getLength
());
4813 m_sErrorMessage
= sFirst
;
4816 m_sErrorMessage
= sStr
;
4818 OUString aError
= s_pScanner
->getErrorMessage
();
4819 if
(!aError.isEmpty
())
4821 m_sErrorMessage
+= ", ";
4822 m_sErrorMessage
+= aError
;
4827 int OSQLParser
::SQLlex
()
4829 return s_pScanner
->SQLlex
();
4832 #if defined _MSC_VER
4833 #pragma warning(pop)