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 external rule number via the yyrmap.
74 #define SQL_NEW_RULE newNode("", SQLNodeType::Rule, yyr1[yyn])
75 #define SQL_NEW_LISTRULE newNode("", SQLNodeType::ListRule, yyr1[yyn])
76 #define SQL_NEW_COMMALISTRULE newNode("", SQLNodeType::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
> 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(".", SQLNodeType::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
("(", SQLNodeType
::Punctuation
));
348 $$
->append
(newNode
(")", SQLNodeType
::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
("(", SQLNodeType
::Punctuation
));
423 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));}
424 | SQL_TOKEN_REFERENCES table_node
428 | SQL_TOKEN_REFERENCES table_node
'(' column_commalist
')'
432 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
434 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));}
437 table_constraint_def:
438 unique_spec
'(' column_commalist
')'
441 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
443 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));}
444 | SQL_TOKEN_FOREIGN SQL_TOKEN_KEY
'(' column_commalist
')' SQL_TOKEN_REFERENCES table_node
448 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
450 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
453 | SQL_TOKEN_FOREIGN SQL_TOKEN_KEY
'(' column_commalist
')' SQL_TOKEN_REFERENCES table_node
'(' column_commalist
')'
457 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
459 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
462 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
464 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));}
465 | SQL_TOKEN_CHECK
'(' search_condition
')'
468 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
470 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));}
473 /* empty */ {$$
= SQL_NEW_RULE
;}
474 |
'(' column_commalist
')'
476 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
478 $$
->append
(newNode
(")", SQLNodeType
::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
("(", SQLNodeType
::Punctuation
));
517 $$
->append
(newNode
(")", SQLNodeType
::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
("{", SQLNodeType
::Punctuation
));
671 $$
->append
(newNode
("}", SQLNodeType
::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
("(", SQLNodeType
::Punctuation
));
738 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
742 table_value_const_list:
743 row_value_constructor
744 {$$
= SQL_NEW_COMMALISTRULE
;
746 | table_value_const_list
',' row_value_constructor
751 row_value_const_list:
752 row_value_constructor_elem
753 {$$ = SQL_NEW_COMMALISTRULE;
755 | row_value_const_list ',' row_value_constructor_elem
760 row_value_constructor:
761 row_value_constructor_elem
762 /* | '(' row_value_const_list ')'
765 $$->append(newNode("(", SQLNodeType::Punctuation));
767 $$->append(newNode(")", SQLNodeType::Punctuation));
771 row_value_constructor_elem:
778 SQL_TOKEN_ROLLBACK SQL_TOKEN_WORK
785 /* INTO target_commalist herausgenommen */
786 select_statement_into:
787 SQL_TOKEN_SELECT opt_all_distinct selection SQL_TOKEN_INTO target_commalist table_exp
804 update_statement_positioned:
805 SQL_TOKEN_UPDATE table_node SQL_TOKEN_SET assignment_commalist
806 SQL_TOKEN_WHERE SQL_TOKEN_CURRENT SQL_TOKEN_OF cursor
818 assignment_commalist:
820 {$$
= SQL_NEW_COMMALISTRULE
;
822 | assignment_commalist
',' assignment
828 column SQL_EQUAL update_source
838 update_statement_searched:
839 SQL_TOKEN_UPDATE table_node SQL_TOKEN_SET assignment_commalist opt_where_clause
850 {$$
= SQL_NEW_COMMALISTRULE
;
852 | target_commalist
',' target
862 /* empty */ {$$
= SQL_NEW_RULE
;}
866 /* query expressions */
875 /* SELECT STATEMENT */
877 SQL_TOKEN_SELECT opt_all_distinct selection table_exp
891 $$
->append
(newNode
("*", SQLNodeType
::Punctuation
));
893 | scalar_exp_commalist
895 opt_result_offset_clause:
896 /* empty */ {$$
= SQL_NEW_RULE
;}
897 | result_offset_clause
899 result_offset_clause:
900 SQL_TOKEN_OFFSET offset_row_count row_or_rows
908 opt_fetch_first_row_count:
909 /* empty */ {$$
= SQL_NEW_RULE
;}
910 | fetch_first_row_count
920 opt_fetch_first_clause:
921 /* empty */ {$$
= SQL_NEW_RULE
;}
925 SQL_TOKEN_FETCH first_or_next opt_fetch_first_row_count row_or_rows SQL_TOKEN_ONLY
938 fetch_first_row_count:
942 opt_limit_offset_clause:
943 /* empty */ {$$
= SQL_NEW_RULE
;}
944 | limit_offset_clause
947 /* empty */ {$$
= SQL_NEW_RULE
;}
948 | SQL_TOKEN_OFFSET SQL_TOKEN_INTNUM
956 SQL_TOKEN_LIMIT SQL_TOKEN_INTNUM opt_offset
965 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
981 SQL_TOKEN_FROM table_ref_commalist
990 { $$
= SQL_NEW_COMMALISTRULE
;
992 | table_ref_commalist
',' table_ref
998 /* empty */ {$$
= SQL_NEW_RULE
;}
1002 /* empty */ {$$
= SQL_NEW_RULE
;}
1005 table_primary_as_range_column:
1006 {$$
= SQL_NEW_RULE
;}
1007 | opt_as SQL_TOKEN_NAME op_column_commalist
1016 table_node table_primary_as_range_column
1022 | subquery range_variable op_column_commalist
1030 |
'{' SQL_TOKEN_OJ joined_table
'}'
1033 $$
->append
(newNode
("{", SQLNodeType
::Punctuation
));
1036 $$
->append
(newNode
("}", SQLNodeType
::Punctuation
));
1038 |
'(' joined_table
')'
1041 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
1043 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
1047 SQL_TOKEN_WHERE search_condition
1053 opt_group_by_clause:
1054 /* empty */ {$$
= SQL_NEW_RULE
;}
1055 | SQL_TOKEN_GROUP SQL_TOKEN_BY column_ref_commalist
1062 column_ref_commalist:
1064 {$$
= SQL_NEW_COMMALISTRULE
;
1067 {$$
= SQL_NEW_COMMALISTRULE
;
1069 | column_ref_commalist
',' column_ref
1072 | column_ref_commalist
',' set_fct_spec
1078 /* empty */ {$$
= SQL_NEW_RULE
;}
1079 | SQL_TOKEN_HAVING search_condition
1085 /* search conditions */
1088 |
'(' search_condition
')'
1089 { // boolean_primary: rule 2
1091 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
1093 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
1095 | row_value_constructor_elem
/*[^')' ',']*/
1097 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
())// boolean_primary: rule 3
1101 if
( SQL_ISTOKEN
( $1, NULL
))
1103 OSQLParseNode
* pColumnRef
= newNode
("", SQLNodeType
::Rule
,OSQLParser
::RuleID
(OSQLParseNode
::column_ref
));
1104 pColumnRef
->append
(newNode
(xxx_pGLOBAL_SQLPARSER
->getFieldName
(),SQLNodeType
::Name
));
1105 OSQLParseNode
* pTFN
= new OSQLInternalNode
("", SQLNodeType
::Rule
,OSQLParser
::RuleID
(OSQLParseNode
::test_for_null
));
1106 pTFN
->append
(pColumnRef
);
1108 OSQLParseNode
* pNPP2
= new OSQLInternalNode
("", SQLNodeType
::Rule
, OSQLParser
::RuleID
(OSQLParseNode
::null_predicate_part_2
));
1109 pNPP2
->append
(new OSQLInternalNode
("", SQLNodeType
::Keyword
, SQL_TOKEN_IS
));
1110 pNPP2
->append
(new OSQLInternalNode
("", SQLNodeType
::Rule
, OSQLParser
::RuleID
(OSQLParseNode
::sql_not
)));
1111 pNPP2
->append
(new OSQLInternalNode
("", SQLNodeType
::Keyword
, SQL_TOKEN_NULL
));
1112 pTFN
->append
(pNPP2
);
1120 nErg
= xxx_pGLOBAL_SQLPARSER
->buildComparsionRule
($$
,$1);
1124 OSQLParseNode
* pTemp
= $$
;
1125 $$
= pTemp
->removeAt
((sal_uInt32
)0);
1141 parenthesized_boolean_value_expression:
1142 '(' search_condition
')'
1143 { // boolean_primary: rule 2
1145 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
1147 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
1151 boolean_primary %dprec
2
1152 | SQL_TOKEN_NOT boolean_primary %dprec
1
1153 { // boolean_factor: rule 1
1161 | boolean_term SQL_TOKEN_AND boolean_factor
1163 $$
= SQL_NEW_RULE
; // boolean_term: rule 1
1171 | search_condition SQL_TOKEN_OR boolean_term
1173 $$
= SQL_NEW_RULE
; // search_condition
1180 comparison_predicate %dprec
1
1182 | all_or_any_predicate
1185 | test_for_null %dprec
2
1189 comparison_predicate_part_2:
1190 comparison row_value_constructor
1192 $$
= SQL_NEW_RULE
; // comparison_predicate: rule 1
1196 comparison_predicate:
1197 row_value_constructor comparison row_value_constructor
1199 $$
= SQL_NEW_RULE
; // comparison_predicate: rule 1
1204 | comparison row_value_constructor
1206 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
()) // comparison_predicate: rule 2
1209 sal_Int16 nErg
= xxx_pGLOBAL_SQLPARSER
->buildPredicateRule
($$
,$2,$1);
1212 OSQLParseNode
* pTemp
= $$
;
1213 $$
= pTemp
->removeAt
((sal_uInt32
)0);
1235 | SQL_TOKEN_IS sql_not SQL_TOKEN_DISTINCT SQL_TOKEN_FROM
1243 | SQL_TOKEN_IS sql_not
1250 between_predicate_part_2:
1251 sql_not SQL_TOKEN_BETWEEN row_value_constructor SQL_TOKEN_AND row_value_constructor
1253 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
()) // between_predicate: rule 2
1257 sal_Int16 nErg
= xxx_pGLOBAL_SQLPARSER
->buildPredicateRule
($$
,$3,$2,$5);
1260 OSQLParseNode
* pTemp
= $$
;
1261 $$
= pTemp
->removeAt
((sal_uInt32
)0);
1262 OSQLParseNode
* pColumnRef
= $$
->removeAt
((sal_uInt32
)0);
1264 OSQLParseNode
* pBetween_predicate
= new OSQLInternalNode
("", SQLNodeType
::Rule
,OSQLParser
::RuleID
(OSQLParseNode
::between_predicate
));
1265 pBetween_predicate
->append
(pColumnRef
);
1266 pBetween_predicate
->append
($$
);
1267 $$
= pBetween_predicate
;
1280 $$
= SQL_NEW_RULE
; // between_predicate: rule 1
1289 row_value_constructor between_predicate_part_2
1291 $$
= SQL_NEW_RULE
; // between_predicate: rule 1
1295 | between_predicate_part_2
1297 character_like_predicate_part_2:
1298 sql_not SQL_TOKEN_LIKE string_value_exp opt_escape
1300 $$
= SQL_NEW_RULE
; // like_predicate: rule 1
1307 other_like_predicate_part_2:
1308 sql_not SQL_TOKEN_LIKE value_exp_primary opt_escape
1310 $$
= SQL_NEW_RULE
; // like_predicate: rule 1
1318 row_value_constructor character_like_predicate_part_2
1320 $$
= SQL_NEW_RULE
; // like_predicate: rule 1
1324 | row_value_constructor other_like_predicate_part_2
1326 $$
= SQL_NEW_RULE
; // like_predicate: rule 3
1330 | character_like_predicate_part_2
1332 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
()) // like_predicate: rule 5
1334 OSQLParseNode
* pColumnRef
= newNode
("", SQLNodeType
::Rule
,OSQLParser
::RuleID
(OSQLParseNode
::column_ref
));
1335 pColumnRef
->append
(newNode
(xxx_pGLOBAL_SQLPARSER
->getFieldName
(),SQLNodeType
::Name
));
1338 $$
->append
(pColumnRef
);
1340 OSQLParseNode
* p2nd
= $1->removeAt
(2);
1341 OSQLParseNode
* p3rd
= $1->removeAt
(2);
1342 if
( !xxx_pGLOBAL_SQLPARSER
->buildLikeRule
($1,p2nd
,p3rd
) )
1352 | other_like_predicate_part_2
1354 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
()) // like_predicate: rule 6
1356 OSQLParseNode
* pColumnRef
= newNode
("", SQLNodeType
::Rule
,OSQLParser
::RuleID
(OSQLParseNode
::column_ref
));
1357 pColumnRef
->append
(newNode
(xxx_pGLOBAL_SQLPARSER
->getFieldName
(),SQLNodeType
::Name
));
1360 $$
->append
(pColumnRef
);
1362 OSQLParseNode
* p2nd
= $1->removeAt
(2);
1363 OSQLParseNode
* p3rd
= $1->removeAt
(2);
1364 if
( !xxx_pGLOBAL_SQLPARSER
->buildLikeRule
($1,p2nd
,p3rd
) )
1377 /* empty */ {$$
= SQL_NEW_RULE
;}
1378 | SQL_TOKEN_ESCAPE string_value_exp
1382 |
'{' SQL_TOKEN_ESCAPE SQL_TOKEN_STRING
'}'
1385 $$
->append
(newNode
("{", SQLNodeType
::Punctuation
));
1388 $$
->append
(newNode
("}", SQLNodeType
::Punctuation
));
1392 null_predicate_part_2:
1393 SQL_TOKEN_IS sql_not SQL_TOKEN_NULL
1395 $$
= SQL_NEW_RULE
; // test_for_null: rule 1
1400 | SQL_TOKEN_IS sql_not SQL_TOKEN_UNKNOWN
1402 $$
= SQL_NEW_RULE
; // test_for_null: rule 1
1409 row_value_constructor null_predicate_part_2
1411 $$
= SQL_NEW_RULE
; // test_for_null: rule 1
1415 | null_predicate_part_2
1417 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
())// test_for_null: rule 2
1419 OSQLParseNode
* pColumnRef
= newNode
("", SQLNodeType
::Rule
,OSQLParser
::RuleID
(OSQLParseNode
::column_ref
));
1420 pColumnRef
->append
(newNode
(xxx_pGLOBAL_SQLPARSER
->getFieldName
(),SQLNodeType
::Name
));
1423 $$
->append
(pColumnRef
);
1435 |
'(' value_exp_commalist
')'
1437 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
1439 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
1442 in_predicate_part_2:
1443 sql_not SQL_TOKEN_IN in_predicate_value
1445 $$
= SQL_NEW_RULE
;// in_predicate: rule 1
1452 row_value_constructor in_predicate_part_2
1454 $$
= SQL_NEW_RULE
;// in_predicate: rule 1
1458 | in_predicate_part_2
1460 if
( xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
() )// in_predicate: rule 2
1462 OSQLParseNode
* pColumnRef
= newNode
("", SQLNodeType
::Rule
,OSQLParser
::RuleID
(OSQLParseNode
::column_ref
));
1463 pColumnRef
->append
(newNode
(xxx_pGLOBAL_SQLPARSER
->getFieldName
(),SQLNodeType
::Name
));
1466 $$
->append
(pColumnRef
);
1473 quantified_comparison_predicate_part_2:
1474 comparison any_all_some subquery
1482 all_or_any_predicate:
1483 row_value_constructor quantified_comparison_predicate_part_2
1489 | quantified_comparison_predicate_part_2
1491 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
())
1493 OSQLParseNode
* pColumnRef
= newNode
("", SQLNodeType
::Rule
,OSQLParser
::RuleID
(OSQLParseNode
::column_ref
));
1494 pColumnRef
->append
(newNode
(xxx_pGLOBAL_SQLPARSER
->getFieldName
(),SQLNodeType
::Name
));
1497 $$
->append
(pColumnRef
);
1512 SQL_TOKEN_EXISTS subquery
1518 SQL_TOKEN_UNIQUE subquery
1526 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
1528 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));}
1531 /* scalar expressions */
1532 scalar_exp_commalist:
1535 $$
= SQL_NEW_COMMALISTRULE
;
1538 | scalar_exp_commalist
',' select_sublist
1545 /* table_node '.' '*'
1549 $$->append(newNode(".", SQLNodeType::Punctuation));
1550 $$->append(newNode("*", SQLNodeType::Punctuation));
1565 $$ = newNode("*", SQLNodeType::Punctuation);
1569 $$ = newNode("?", SQLNodeType::Punctuation);
1575 $$->append(newNode("*", SQLNodeType::Punctuation));
1576 xxx_pGLOBAL_SQLPARSER->reduceLiteral($$, sal_False);
1582 $$->append(newNode("?", SQLNodeType::Punctuation));
1583 xxx_pGLOBAL_SQLPARSER->reduceLiteral($$, sal_False);
1591 | SQL_TOKEN_REAL_NUM
1593 | SQL_TOKEN_APPROXNUM
1594 | SQL_TOKEN_ACCESS_DATE
1595 /* rules for predicate check */
1596 | literal SQL_TOKEN_STRING
1598 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
())
1603 xxx_pGLOBAL_SQLPARSER
->reduceLiteral
($$
, sal_True
);
1608 | literal SQL_TOKEN_INT
1610 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
())
1615 xxx_pGLOBAL_SQLPARSER
->reduceLiteral
($$
, sal_True
);
1620 | literal SQL_TOKEN_REAL_NUM
1622 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
())
1627 xxx_pGLOBAL_SQLPARSER
->reduceLiteral
($$
, sal_True
);
1632 | literal SQL_TOKEN_APPROXNUM
1634 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
())
1639 xxx_pGLOBAL_SQLPARSER
->reduceLiteral
($$
, sal_True
);
1648 /* empty */ {$$
= SQL_NEW_RULE
;}
1649 | SQL_TOKEN_AS column
1658 SQL_TOKEN_POSITION
'(' value_exp SQL_TOKEN_IN value_exp
')'
1662 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
1666 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
1668 | SQL_TOKEN_POSITION
'(' value_exp_commalist
')'
1672 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
1674 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
1683 SQL_TOKEN_CHAR_LENGTH
'(' value_exp
')'
1687 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
1689 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
1691 | SQL_TOKEN_SQL_TOKEN_INTNUM
'(' value_exp
')'
1695 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
1697 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
1702 SQL_TOKEN_OCTET_LENGTH
'(' value_exp
')'
1706 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
1708 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
1712 SQL_TOKEN_BIT_LENGTH
'(' value_exp
')'
1716 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
1718 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
1739 non_second_datetime_field
1756 SQL_TOKEN_TIMEZONE_HOUR
1761 | SQL_TOKEN_TIMEZONE_MINUTE
1768 SQL_TOKEN_EXTRACT
'(' extract_field SQL_TOKEN_FROM value_exp
')'
1772 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
1776 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
1779 unsigned_value_spec:
1790 | SQL_TOKEN_CURRENT_CATALOG
1791 | SQL_TOKEN_CURRENT_DEFAULT_TRANSFORM_GROUP
1792 | SQL_TOKEN_CURRENT_PATH
1793 | SQL_TOKEN_CURRENT_ROLE
1794 | SQL_TOKEN_CURRENT_SCHEMA
1795 | SQL_TOKEN_CURRENT_USER
1796 | SQL_TOKEN_SESSION_USER
1797 | SQL_TOKEN_SYSTEM_USER
1801 |
'{' odbc_fct_spec
'}'
1804 $$
->append
(newNode
("{", SQLNodeType
::Punctuation
));
1806 $$
->append
(newNode
("}", SQLNodeType
::Punctuation
));
1808 | function_name
'(' ')'
1812 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
1813 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
1815 | function_name0
'(' ')'
1819 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
1820 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
1822 | function_name1
'(' function_arg
')'
1826 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
1828 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
1830 | function_name2
'(' function_arg_commalist2
')'
1834 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
1836 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
1838 | function_name3
'(' function_arg_commalist3
')'
1842 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
1844 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
1846 | string_function_4Argument
'(' function_arg_commalist4
')'
1850 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
1852 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
1854 | function_name
'(' function_args_commalist
')'
1858 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
1860 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
1862 | function_name12
'(' function_args_commalist
')'
1864 if
( $3->count
() == 1 ||
$3->count
() == 2 )
1868 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
1870 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
1875 | function_name23
'(' function_args_commalist
')'
1877 if
( $3->count
() == 2 ||
$3->count
() == 3)
1881 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
1883 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
1890 date_function_0Argument
1891 | numeric_function_0Argument
1894 string_function_1Argument
1895 | date_function_1Argument
1896 | numeric_function_1Argument
1899 string_function_2Argument
1900 | numeric_function_2Argument
1910 | SQL_TOKEN_DATEDIFF
1913 string_function_3Argument
1921 string_function_1Argument:
1931 string_function_2Argument:
1936 string_function_3Argument:
1939 string_function_4Argument:
1946 | SQL_TOKEN_DIFFERENCE
1947 | SQL_TOKEN_LOCATE_2
1950 date_function_0Argument:
1955 date_function_1Argument:
1957 | SQL_TOKEN_DAYOFMONTH
1958 | SQL_TOKEN_DAYOFYEAR
1961 | SQL_TOKEN_MONTHNAME
1968 | SQL_TOKEN_TIMEVALUE
1969 | SQL_TOKEN_DATEVALUE
1973 SQL_TOKEN_TIMESTAMPADD
1974 | SQL_TOKEN_TIMESTAMPDIFF
1976 numeric_function_0Argument:
1979 numeric_function_1Argument:
1997 | SQL_TOKEN_ROUNDMAGIC
1999 numeric_function_2Argument:
2006 | SQL_TOKEN_TRUNCATE
2010 window_function_type SQL_TOKEN_OVER window_name_or_specification
2018 window_function_type
:
2019 rank_function_type
'(' ')'
2023 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
2024 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
2026 | SQL_TOKEN_ROW_NUMBER
'(' ')'
2030 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
2031 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
2035 | lead_or_lag_function
2036 | first_or_last_value_function
2037 | nth_value_function
2040 SQL_TOKEN_NTILE
'(' number_of_tiles
')'
2044 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
2046 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
2049 dynamic_parameter_specification:
2052 simple_value_specification:
2056 simple_value_specification
2057 | dynamic_parameter_specification
2059 opt_lead_or_lag_function:
2060 /* empty */ {$$
= SQL_NEW_RULE
;}
2064 $$
->append
(newNode
(",", SQLNodeType
::Punctuation
));
2067 |
',' offset
',' default_expression
2070 $$
->append
(newNode
(",", SQLNodeType
::Punctuation
));
2072 $$
->append
(newNode
(",", SQLNodeType
::Punctuation
));
2077 /* empty */ {$$
= SQL_NEW_RULE
;}
2081 lead_or_lag_function:
2082 lead_or_lag
'(' lead_or_lag_extent opt_lead_or_lag_function
')' opt_null_treatment
2086 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
2089 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
2107 SQL_TOKEN_RESPECT SQL_TOKEN_NULLS
2108 | SQL_TOKEN_IGNORE SQL_TOKEN_NULLS
2110 first_or_last_value_function:
2111 first_or_last_value
'(' value_exp
')' opt_null_treatment
2115 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
2117 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
2121 first_or_last_value
:
2122 SQL_TOKEN_FIRST_VALUE
2123 | SQL_TOKEN_LAST_VALUE
2125 opt_from_first_or_last:
2126 /* empty */ {$$
= SQL_NEW_RULE
;}
2127 | from_first_or_last
2130 SQL_TOKEN_NTH_VALUE
'(' value_exp
',' nth_row
')' opt_from_first_or_last opt_null_treatment
2134 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
2136 $$
->append
(newNode
(",", SQLNodeType
::Punctuation
));
2138 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
2144 simple_value_specification
2145 | dynamic_parameter_specification
2148 SQL_TOKEN_FROM SQL_TOKEN_FIRST
2154 | SQL_TOKEN_FROM SQL_TOKEN_LAST
2164 window_name_or_specification:
2166 | in_line_window_specification
2168 in_line_window_specification:
2169 window_specification
2172 /* empty */ {$$
= SQL_NEW_RULE
;}
2176 SQL_TOKEN_WINDOW window_definition_list
2183 window_definition_list:
2184 window_definition_list
',' window_definition
2188 {$$
= SQL_NEW_COMMALISTRULE
;
2192 new_window_name SQL_TOKEN_AS window_specification
2203 window_specification:
2204 '(' window_specification_details
')'
2207 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
2209 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
2212 opt_existing_window_name:
2213 /* empty */ {$$
= SQL_NEW_RULE
;}
2214 | existing_window_name
2216 opt_window_partition_clause:
2217 /* empty */ {$$
= SQL_NEW_RULE
;}
2218 | window_partition_clause
2220 opt_window_frame_clause:
2221 /* empty */ {$$
= SQL_NEW_RULE
;}
2222 | window_frame_clause
2224 window_specification_details:
2225 opt_existing_window_name
2226 opt_window_partition_clause
2228 opt_window_frame_clause
2230 existing_window_name:
2233 window_partition_clause:
2234 SQL_TOKEN_PARTITION SQL_TOKEN_BY window_partition_column_reference_list
2242 window_partition_column_reference_list:
2243 window_partition_column_reference_list
',' window_partition_column_reference
2246 | window_partition_column_reference
2247 {$$
= SQL_NEW_COMMALISTRULE
;
2250 window_partition_column_reference:
2251 column_ref opt_collate_clause
2258 opt_window_frame_exclusion:
2259 /* empty */ {$$
= SQL_NEW_RULE
;}
2260 | window_frame_exclusion
2262 window_frame_clause:
2263 window_frame_units window_frame_extent opt_window_frame_exclusion
2275 window_frame_extent:
2277 | window_frame_between
2280 SQL_TOKEN_UNBOUNDED SQL_TOKEN_PRECEDING
2286 | window_frame_preceding
2287 | SQL_TOKEN_CURRENT SQL_TOKEN_ROW
2294 window_frame_preceding:
2295 unsigned_value_spec SQL_TOKEN_PRECEDING
2302 window_frame_between:
2303 SQL_TOKEN_BETWEEN window_frame_bound_1 SQL_TOKEN_AND window_frame_bound_2
2312 window_frame_bound_1:
2315 window_frame_bound_2:
2320 | SQL_TOKEN_UNBOUNDED SQL_TOKEN_FOLLOWING
2326 | window_frame_following
2328 window_frame_following:
2329 unsigned_value_spec SQL_TOKEN_FOLLOWING
2336 window_frame_exclusion:
2337 SQL_TOKEN_EXCLUDE SQL_TOKEN_CURRENT SQL_TOKEN_ROW
2344 | SQL_TOKEN_EXCLUDE SQL_TOKEN_GROUP
2350 | SQL_TOKEN_EXCLUDE SQL_TOKEN_TIES
2356 | SQL_TOKEN_EXCLUDE SQL_TOKEN_NO SQL_TOKEN_OTHERS
2365 {$$
= SQL_NEW_RULE
;}
2369 $$
->append
(newNode
("?", SQLNodeType
::Punctuation
));
2374 op_parameter SQL_TOKEN_CALL table_node op_odbc_call_parameter
2384 op_odbc_call_parameter:
2385 {$$
= SQL_NEW_RULE
;}
2386 |
'(' odbc_parameter_commalist
')'
2389 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
2391 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
2395 odbc_parameter_commalist:
2397 {$$
= SQL_NEW_COMMALISTRULE
;
2399 | odbc_parameter_commalist
',' odbc_parameter
2406 /* empty */ {$$
= SQL_NEW_RULE
;}
2412 odbc_fct_type SQL_TOKEN_STRING
2418 | SQL_TOKEN_FN set_fct_spec
2433 set_fct_type
'(' opt_all_distinct function_arg
')'
2437 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
2440 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
2442 | SQL_TOKEN_COUNT
'(' '*' ')'
2446 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
2447 $$
->append
(newNode
("*", SQLNodeType
::Punctuation
));
2448 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
2450 | SQL_TOKEN_COUNT
'(' opt_all_distinct function_arg
')'
2454 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
2457 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
2459 | ordered_set_function
2460 | array_aggregate_function
2470 | SQL_TOKEN_STDDEV_POP
2471 | SQL_TOKEN_STDDEV_SAMP
2472 | SQL_TOKEN_VAR_SAMP
2476 | SQL_TOKEN_INTERSECTION
2479 ordered_set_function:
2480 hypothetical_set_function
2481 | inverse_distribution_function
2483 hypothetical_set_function:
2484 rank_function_type
'(' hypothetical_set_function_value_expression_list
')' within_group_specification
2488 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
2490 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
2493 | rank_function_type
'(' hypothetical_set_function_value_expression_list SQL_TOKEN_BY value_exp_commalist
')' within_group_specification
2497 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
2501 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
2506 within_group_specification:
2510 | SQL_TOKEN_WITHIN SQL_TOKEN_GROUP
'(' opt_order_by_clause
')'
2515 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
2517 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
2520 hypothetical_set_function_value_expression_list:
2524 inverse_distribution_function:
2525 inverse_distribution_function_type
'('inverse_distribution_function_argument
')' within_group_specification
2529 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
2531 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
2534 inverse_distribution_function_argument:
2537 inverse_distribution_function_type:
2538 SQL_TOKEN_PERCENTILE_CONT
2539 | SQL_TOKEN_PERCENTILE_DISC
2542 array_aggregate_function:
2543 SQL_TOKEN_ARRAY_AGG
'(' value_exp opt_order_by_clause
')'
2547 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
2550 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
2556 | SQL_TOKEN_DENSE_RANK
2557 | SQL_TOKEN_PERCENT_RANK
2558 | SQL_TOKEN_CUME_DIST
2561 SQL_TOKEN_LEFT %prec SQL_TOKEN_LEFT
2566 | SQL_TOKEN_RIGHT %prec SQL_TOKEN_RIGHT
2571 | SQL_TOKEN_FULL %prec SQL_TOKEN_FULL
2578 SQL_TOKEN_ON search_condition
2587 | named_columns_join
2590 /* empty */ {$$
= SQL_NEW_RULE
;}
2597 | outer_join_type SQL_TOKEN_OUTER
2605 table_ref SQL_TOKEN_CROSS SQL_TOKEN_JOIN table_ref
2616 /* wenn SQL_TOKEN_NATURAL, dann keine join_spec */
2617 table_ref SQL_TOKEN_NATURAL join_type SQL_TOKEN_JOIN table_ref
2626 | table_ref join_type SQL_TOKEN_JOIN table_ref join_spec
2641 SQL_TOKEN_USING
'(' column_commalist
')'
2645 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
2647 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
2652 | values_or_query_spec
2655 non_join_query_primary:
2657 |
'(' non_join_query_exp
')'
2660 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
2662 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
2665 non_join_query_term:
2666 non_join_query_primary
2667 | query_term SQL_TOKEN_INTERSECT all query_primary
2677 non_join_query_primary
2681 | query_exp SQL_TOKEN_UNION all query_term
2689 | query_exp SQL_TOKEN_EXCEPT all query_term
2699 /* empty*/ {$$
= SQL_NEW_RULE
;}
2703 non_join_query_exp
/*[^')']*/
2716 SQL_TOKEN_CAST
'(' cast_operand SQL_TOKEN_AS cast_target
')'
2720 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
2724 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
2737 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
2739 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
2750 |
'-' num_primary %prec SQL_TOKEN_UMINUS
2753 $$
->append
(newNode
("-", SQLNodeType
::Punctuation
));
2756 |
'+' num_primary %prec SQL_TOKEN_UMINUS
2759 $$
->append
(newNode
("+", SQLNodeType
::Punctuation
));
2770 $$
->append
(newNode
("*", SQLNodeType
::Punctuation
));
2777 $$
->append
(newNode
("/", SQLNodeType
::Punctuation
));
2784 | num_value_exp
'+' term
2788 $$
->append
(newNode
("+", SQLNodeType
::Punctuation
));
2791 | num_value_exp
'-' term
2795 $$
->append
(newNode
("-", SQLNodeType
::Punctuation
));
2800 /* value_exp_primary
2805 |*/ datetime_value_fct
2812 SQL_TOKEN_CURRENT_DATE
2817 | SQL_TOKEN_CURRENT_TIME
2822 | SQL_TOKEN_CURRENT_TIMESTAMP
2829 SQL_TOKEN_AT time_zone_specifier
2836 time_zone_specifier:
2842 /* | SQL_TOKEN_TIME SQL_TOKEN_ZONE interval_value_exp
2856 | datetime_primary time_zone
2873 | interval_term '*' factor
2877 $$->append(newNode("*", SQLNodeType::Punctuation));
2880 | interval_term '/' factor
2884 $$->append(newNode("/", SQLNodeType::Punctuation));
2895 /* | interval_value_exp '+' datetime_term
2899 $$->append(newNode("+", SQLNodeType::Punctuation));
2902 | datetime_value_exp '+' interval_term
2906 $$->append(newNode("+", SQLNodeType::Punctuation));
2909 | datetime_value_exp '-' interval_term
2913 $$->append(newNode("-", SQLNodeType::Punctuation));
2924 | interval_value_exp '+' interval_term
2928 $$->append(newNode("+", SQLNodeType::Punctuation));
2931 | interval_value_exp '-' interval_term
2935 $$->append(newNode("-", SQLNodeType::Punctuation));
2938 | '(' datetime_value_exp '-' datetime_term ')' interval_qualifier
2941 $$->append(newNode("(", SQLNodeType::Punctuation));
2943 $$->append(newNode("-", SQLNodeType::Punctuation));
2945 $$->append(newNode(")", SQLNodeType::Punctuation));
2950 non_second_datetime_field:
2958 non_second_datetime_field opt_paren_precision
2966 non_second_datetime_field
2967 | SQL_TOKEN_SECOND opt_paren_precision
2975 single_datetime_field:
2976 non_second_datetime_field opt_paren_precision
2982 | SQL_TOKEN_SECOND opt_paren_precision_scale
2991 start_field SQL_TOKEN_TO end_field
2998 | single_datetime_field
3001 function_arg_commalist2:
3002 function_arg
',' function_arg
3003 {$$
= SQL_NEW_COMMALISTRULE
;
3007 function_arg_commalist3:
3008 function_arg
',' function_arg
',' function_arg
3010 $$
= SQL_NEW_COMMALISTRULE
;
3016 function_arg_commalist4:
3017 function_arg
',' function_arg
',' function_arg
',' function_arg
3019 $$
= SQL_NEW_COMMALISTRULE
;
3026 value_exp_commalist:
3028 {$$
= SQL_NEW_COMMALISTRULE
;
3030 | value_exp_commalist
',' value_exp
3033 /* this rule is only valid if we check predicates */
3034 | value_exp_commalist
';' value_exp
3036 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
())
3047 | value_exp comparison value_exp
3054 | value_exp SQL_TOKEN_USING value_exp comparison value_exp
3062 | value_exp SQL_TOKEN_BY value_exp_commalist
3070 function_args_commalist:
3072 {$$
= SQL_NEW_COMMALISTRULE
;
3074 | function_args_commalist
',' function_arg
3077 /* this rule is only valid if we check predicates */
3078 | function_args_commalist
';' function_arg
3080 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
())
3091 num_value_exp
/*[^')']*/
3093 | datetime_value_exp
3112 char_value_exp
'+' char_factor
3116 $$
->append
(newNode
("+", SQLNodeType
::Punctuation
));
3119 | value_exp SQL_CONCAT value_exp
3133 SQL_TOKEN_COLLATE table_node
3142 | char_primary collate_clause
3161 SQL_TOKEN_SUBSTRING
'(' bit_value_exp SQL_TOKEN_FROM string_value_exp for_length
')'
3165 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
3170 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
3188 bit_value_exp '+' bit_factor
3192 $$->append(newNode("+", SQLNodeType::Punctuation));
3205 {$$
= SQL_NEW_RULE
;}
3206 /* value_exp_primary
3237 {$$
= SQL_NEW_RULE
;}
3238 | SQL_TOKEN_FOR value_exp
3246 SQL_TOKEN_SUBSTRING
'(' value_exp SQL_TOKEN_FROM value_exp for_length
')'
3250 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
3255 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
3257 | SQL_TOKEN_SUBSTRING
'(' value_exp_commalist
')'
3261 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
3263 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
3271 upper_lower
'(' value_exp
')'
3275 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
3277 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
3281 SQL_TOKEN_CONVERT
'(' string_value_exp SQL_TOKEN_USING table_node
')'
3285 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
3289 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
3291 | SQL_TOKEN_CONVERT
'(' cast_operand
',' cast_target
')'
3295 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
3297 $$
->append
(newNode
(",", SQLNodeType
::Punctuation
));
3299 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
3303 SQL_TOKEN_TRANSLATE
'(' string_value_exp SQL_TOKEN_USING table_node
')'
3307 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
3311 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
3315 SQL_TOKEN_TRIM
'(' trim_operands
')'
3319 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
3321 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
3325 trim_spec value_exp SQL_TOKEN_FROM value_exp
3333 | trim_spec SQL_TOKEN_FROM value_exp
3340 | value_exp SQL_TOKEN_FROM value_exp
3347 | SQL_TOKEN_FROM value_exp
3359 | SQL_TOKEN_TRAILING
3377 SQL_TOKEN_NAME
'.' schema_name
3381 $$
->append
(newNode
(".", SQLNodeType
::Punctuation
));
3384 | SQL_TOKEN_NAME
':' schema_name
3388 $$
->append
(newNode
(":", SQLNodeType
::Punctuation
));
3393 SQL_TOKEN_NAME
'.' table_name
3397 $$
->append
(newNode
(".", SQLNodeType
::Punctuation
));
3412 /* | table_node '.' column_val %prec '.'
3415 $$->append(newNode(".", SQLNodeType::Punctuation));
3418 | SQL_TOKEN_NAME
'.' column_val %prec
'.'
3421 $$
->append
(newNode
(".", SQLNodeType
::Punctuation
));
3424 | SQL_TOKEN_NAME
'.' SQL_TOKEN_NAME
'.' column_val %prec
'.'
3427 $$
->append
(newNode
(".", SQLNodeType
::Punctuation
));
3429 $$
->append
(newNode
(".", SQLNodeType
::Punctuation
));
3431 | SQL_TOKEN_NAME
'.' SQL_TOKEN_NAME
'.' SQL_TOKEN_NAME
'.' column_val %prec
'.'
3434 $$
->append
(newNode
(".", SQLNodeType
::Punctuation
));
3436 $$
->append
(newNode
(".", SQLNodeType
::Punctuation
));
3438 $$
->append
(newNode
(".", SQLNodeType
::Punctuation
));
3441 | SQL_TOKEN_NAME
':' SQL_TOKEN_NAME
'.' SQL_TOKEN_NAME
'.' column_val %prec
'.'
3444 $$
->append
(newNode
(":", SQLNodeType
::Punctuation
));
3446 $$
->append
(newNode
(".", SQLNodeType
::Punctuation
));
3448 $$
->append
(newNode
(".", SQLNodeType
::Punctuation
));
3451 /* | SQL_TOKEN_NAME ';' SQL_TOKEN_NAME '.' SQL_TOKEN_NAME '.' column_val
3454 $$->append(newNode(";", SQLNodeType::Punctuation));
3456 $$->append(newNode(".", SQLNodeType::Punctuation));
3458 $$->append(newNode(".", SQLNodeType::Punctuation));
3471 $$
->append
(newNode
("*", SQLNodeType
::Punctuation
));
3478 {$$
= SQL_NEW_RULE
;}
3479 | SQL_TOKEN_CHARACTER SQL_TOKEN_SET SQL_TOKEN_NAME
3488 {$$
= SQL_NEW_RULE
;}
3492 character_string_type opt_char_set_spec opt_collate_clause
3499 | national_character_string_type opt_collate_clause
3505 | binary_string_type
3511 character_string_type:
3512 SQL_TOKEN_CHARACTER opt_paren_precision
3518 | SQL_TOKEN_CHAR opt_paren_precision
3524 | SQL_TOKEN_CHARACTER SQL_TOKEN_VARYING paren_char_length
3531 | SQL_TOKEN_CHAR SQL_TOKEN_VARYING paren_char_length
3538 | SQL_TOKEN_VARCHAR paren_char_length
3544 | character_large_object_type
3546 opt_paren_precision:
3547 {$$
= SQL_NEW_RULE
;}
3551 '(' SQL_TOKEN_INTNUM
')'
3554 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
3556 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
3559 opt_paren_char_large_length:
3560 {$$
= SQL_NEW_RULE
;}
3561 | paren_character_large_object_length
3563 paren_character_large_object_length:
3564 '(' large_object_length
')'
3567 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
3569 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
3573 large_object_length:
3574 SQL_TOKEN_INTNUM opt_multiplier
3582 {$$
= SQL_NEW_RULE
;}
3586 $$
->append
(newNode
("K", SQLNodeType
::Punctuation
));
3591 $$
->append
(newNode
("M", SQLNodeType
::Punctuation
));
3596 $$
->append
(newNode
("G", SQLNodeType
::Punctuation
));
3601 $$
->append
(newNode
("T", SQLNodeType
::Punctuation
));
3606 $$
->append
(newNode
("P", SQLNodeType
::Punctuation
));
3609 character_large_object_type:
3610 SQL_TOKEN_CHARACTER SQL_TOKEN_LARGE SQL_TOKEN_OBJECT opt_paren_char_large_length
3618 | SQL_TOKEN_CHAR SQL_TOKEN_LARGE SQL_TOKEN_OBJECT opt_paren_char_large_length
3626 | SQL_TOKEN_CLOB opt_paren_char_large_length
3633 national_character_string_type:
3634 SQL_TOKEN_NATIONAL SQL_TOKEN_CHARACTER opt_paren_precision
3641 | SQL_TOKEN_NATIONAL SQL_TOKEN_CHAR opt_paren_precision
3648 | SQL_TOKEN_NCHAR opt_paren_precision
3654 | SQL_TOKEN_NATIONAL SQL_TOKEN_CHARACTER SQL_TOKEN_VARYING paren_char_length
3662 | SQL_TOKEN_NATIONAL SQL_TOKEN_CHAR SQL_TOKEN_VARYING paren_char_length
3670 | SQL_TOKEN_NCHAR SQL_TOKEN_VARYING paren_char_length
3677 | national_character_large_object_type
3679 national_character_large_object_type:
3680 SQL_TOKEN_NATIONAL SQL_TOKEN_CHARACTER SQL_TOKEN_LARGE SQL_TOKEN_OBJECT opt_paren_char_large_length
3689 | SQL_TOKEN_NCHAR SQL_TOKEN_LARGE SQL_TOKEN_OBJECT opt_paren_char_large_length
3697 | SQL_TOKEN_NCLOB opt_paren_char_large_length
3705 SQL_TOKEN_BINARY opt_paren_precision
3711 | SQL_TOKEN_BINARY SQL_TOKEN_VARYING paren_char_length
3718 | SQL_TOKEN_VARBINARY paren_char_length
3724 | binary_large_object_string_type
3726 binary_large_object_string_type:
3727 SQL_TOKEN_BINARY SQL_TOKEN_LARGE SQL_TOKEN_OBJECT opt_paren_char_large_length
3735 | SQL_TOKEN_BLOB opt_paren_char_large_length
3744 | approximate_numeric_type
3746 opt_paren_precision_scale:
3747 {$$
= SQL_NEW_RULE
;}
3748 |
'(' SQL_TOKEN_INTNUM
')'
3751 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
3753 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
3755 |
'(' SQL_TOKEN_INTNUM
',' SQL_TOKEN_INTNUM
')'
3758 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
3760 $$
->append
(newNode
(",", SQLNodeType
::Punctuation
));
3762 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
3766 SQL_TOKEN_NUMERIC opt_paren_precision_scale
3772 | SQL_TOKEN_DECIMAL opt_paren_precision_scale
3778 | SQL_TOKEN_DEC opt_paren_precision_scale
3784 | SQL_TOKEN_SMALLINT
3789 approximate_numeric_type:
3790 SQL_TOKEN_FLOAT
'(' SQL_TOKEN_INTNUM
')'
3794 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
3796 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
3801 | SQL_TOKEN_DOUBLE SQL_TOKEN_PRECISION
3813 | SQL_TOKEN_TIME opt_paren_precision opt_with_or_without_time_zone
3820 | SQL_TOKEN_TIMESTAMP opt_paren_precision opt_with_or_without_time_zone
3828 opt_with_or_without_time_zone:
3829 {$$
= SQL_NEW_RULE
;}
3830 | SQL_TOKEN_WITH SQL_TOKEN_TIME SQL_TOKEN_ZONE
3837 | SQL_TOKEN_WITHOUT SQL_TOKEN_TIME SQL_TOKEN_ZONE
3846 SQL_TOKEN_INTERVAL interval_qualifier
3853 /* the various things you can name */
3857 | SQL_TOKEN_POSITION
3859 sal_uInt32 nNod
= $$
->getRuleID
();
3861 $$
= newNode
(xxx_pGLOBAL_SQLPARSER
->TokenIDToStr
(nNod
), SQLNodeType
::Name
);
3863 | SQL_TOKEN_CHAR_LENGTH
3865 sal_uInt32 nNod
= $$
->getRuleID
();
3867 $$
= newNode
(xxx_pGLOBAL_SQLPARSER
->TokenIDToStr
(nNod
), SQLNodeType
::Name
);
3871 sal_uInt32 nNod
= $$
->getRuleID
();
3873 $$
= newNode
(xxx_pGLOBAL_SQLPARSER
->TokenIDToStr
(nNod
), SQLNodeType
::Name
);
3878 | case_specification
3881 SQL_TOKEN_NULLIF
'(' value_exp_commalist
')'
3885 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
3887 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
3889 | SQL_TOKEN_COALESCE
'(' value_exp
')'
3893 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
3895 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
3897 | SQL_TOKEN_COALESCE
'(' value_exp_commalist
')'
3901 $$
->append
(newNode
("(", SQLNodeType
::Punctuation
));
3903 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
3911 SQL_TOKEN_CASE case_operand simple_when_clause_list else_clause SQL_TOKEN_END
3922 SQL_TOKEN_CASE searched_when_clause_list else_clause SQL_TOKEN_END
3931 simple_when_clause_list:
3934 $$
= SQL_NEW_LISTRULE
;
3937 | searched_when_clause_list simple_when_clause
3944 SQL_TOKEN_WHEN when_operand_list SQL_TOKEN_THEN result
3955 {$$
= SQL_NEW_COMMALISTRULE
;
3957 | when_operand_list
',' when_operand
3962 row_value_constructor_elem
3963 | comparison_predicate_part_2 %dprec
1
3964 | between_predicate_part_2
3965 | in_predicate_part_2
3966 | character_like_predicate_part_2
3967 | null_predicate_part_2 %dprec
2
3969 searched_when_clause_list:
3970 searched_when_clause
3972 $$
= SQL_NEW_LISTRULE
;
3975 | searched_when_clause_list searched_when_clause
3981 searched_when_clause:
3982 SQL_TOKEN_WHEN search_condition SQL_TOKEN_THEN result
3992 {$$
= SQL_NEW_RULE
;}
3993 | SQL_TOKEN_ELSE result
4007 row_value_constructor_elem
4010 cursor: SQL_TOKEN_NAME
4016 module: SQL_TOKEN_NAME
4025 $$
->append
(newNode
(":", SQLNodeType
::Punctuation
));
4028 {$$
= SQL_NEW_RULE
; // test
4029 $$
->append
(newNode
("?", SQLNodeType
::Punctuation
));}
4030 |
'[' SQL_TOKEN_NAME
']'
4032 $$
->append
(newNode
("[", SQLNodeType
::Punctuation
));
4034 $$
->append
(newNode
("]", SQLNodeType
::Punctuation
));}
4038 procedure: SQL_TOKEN_NAME
4045 {$$
= SQL_NEW_RULE
;}
4046 | opt_as SQL_TOKEN_NAME
4053 user: SQL_TOKEN_NAME
4056 /* PREDICATECHECK RULES */
4058 search_condition
/* checking predicats */
4060 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
()) // sql: rule 1
4063 if
( SQL_ISRULE
($$
,search_condition
) )
4065 $$
->insert
(0,newNode
("(", SQLNodeType
::Punctuation
));
4066 $$
->append
(newNode
(")", SQLNodeType
::Punctuation
));
4072 |
'(' sql
')' /* checking predicats */
4075 SQL_TOKEN_CREATE SQL_TOKEN_TRIGGER trigger_name trigger_action_time trigger_event SQL_TOKEN_ON table_name op_referencing triggered_action
4093 | SQL_TOKEN_REFERENCING transition_table_or_variable_list
4100 trigger_action_time:
4103 | SQL_TOKEN_INSTEAD SQL_TOKEN_OF
4113 | SQL_TOKEN_UPDATE op_trigger_columnlist
4120 op_trigger_columnlist:
4124 | SQL_TOKEN_OF trigger_column_list
4131 trigger_column_list:
4135 op_triggered_action_for triggered_when_clause triggered_SQL_statement
4143 op_triggered_action_for:
4147 | SQL_TOKEN_FOR SQL_TOKEN_EACH trigger_for
4157 | SQL_TOKEN_STATEMENT
4159 triggered_when_clause:
4163 | SQL_TOKEN_WHEN parenthesized_boolean_value_expression
4170 triggered_SQL_statement:
4171 SQL_procedure_statement
4172 | SQL_TOKEN_BEGIN SQL_TOKEN_ATOMIC SQL_procedure_statement_list
';' SQL_TOKEN_END
4178 $$
->append
(newNode
(";", SQLNodeType
::Punctuation
));
4182 SQL_procedure_statement_list:
4183 SQL_procedure_statement
4185 $$
= SQL_NEW_LISTRULE
;
4188 | SQL_procedure_statement_list
';' SQL_procedure_statement
4194 SQL_procedure_statement:
4198 transition_table_or_variable_list:
4199 transition_table_or_variable
4201 $$
= SQL_NEW_LISTRULE
;
4204 | transition_table_or_variable_list transition_table_or_variable
4211 transition_table_or_variable:
4212 SQL_TOKEN_OLD opt_row opt_as old_transition_variable_name
4220 | SQL_TOKEN_NEW opt_row opt_as new_transition_variable_name
4228 | SQL_TOKEN_OLD SQL_TOKEN_TABLE opt_as old_transition_table_name
4236 | SQL_TOKEN_NEW SQL_TOKEN_TABLE opt_as new_transition_table_name
4245 old_transition_table_name:
4246 transition_table_name
4248 new_transition_table_name:
4249 transition_table_name
4251 transition_table_name:
4254 old_transition_variable_name:
4257 new_transition_variable_name:
4266 using namespace
::com
::sun
::star
::sdbc
;
4267 using namespace
::com
::sun
::star
::beans
;
4268 using namespace
::com
::sun
::star
::uno
;
4269 using namespace
::com
::sun
::star
::i18n
;
4270 using namespace
::com
::sun
::star
::lang
;
4271 using namespace
::com
::sun
::star
::util
;
4272 using namespace
::osl
;
4273 using namespace
::dbtools
;
4275 connectivity::OSQLInternalNode
* newNode
(const sal_Char
* pNewValue
,
4276 const connectivity
::SQLNodeType eNodeType
,
4277 const sal_uInt32 nNodeID
)
4279 return new connectivity
::OSQLInternalNode
(pNewValue
, eNodeType
, nNodeID
);
4282 connectivity::OSQLInternalNode
* newNode
(const OString
& _NewValue
,
4283 const connectivity
::SQLNodeType eNodeType
,
4284 const sal_uInt32 nNodeID
)
4286 return new connectivity
::OSQLInternalNode
(_NewValue
, eNodeType
, nNodeID
);
4289 connectivity::OSQLInternalNode
* newNode
(const OUString
& _NewValue
,
4290 const connectivity
::SQLNodeType eNodeType
,
4291 const sal_uInt32 nNodeID
)
4293 return new connectivity
::OSQLInternalNode
(_NewValue
, eNodeType
, nNodeID
);
4296 OParseContext::OParseContext
()
4301 OParseContext::~OParseContext
()
4306 OUString OParseContext
::getErrorMessage
(ErrorCode _eCode
) const
4311 case ErrorCode
::General
: aMsg
= "Syntax error in SQL expression"; break
;
4312 case ErrorCode
::ValueNoLike
: aMsg
= "The value #1 can not be used with LIKE."; break
;
4313 case ErrorCode
::FieldNoLike
: aMsg
= "LIKE can not be used with this field."; break
;
4314 case ErrorCode
::InvalidCompare
: aMsg
= "The entered criterion can not be compared with this field."; break
;
4315 case ErrorCode
::InvalidIntCompare
: aMsg
= "The field can not be compared with a number."; break
;
4316 case ErrorCode
::InvalidDateCompare
: aMsg
= "The field can not be compared with a date."; break
;
4317 case ErrorCode
::InvalidRealCompare
: aMsg
= "The field can not be compared with a floating point number."; break
;
4318 case ErrorCode
::InvalidTableNosuch
: aMsg
= "The database does not contain a table named \"#\"."; break
;
4319 case ErrorCode
::InvalidTableOrQuery
: aMsg
= "The database does contain neither a table nor a query named \"#\"."; break
;
4320 case ErrorCode
::InvalidColumn
: aMsg
= "The column \"#1\" is unknown in the table \"#2\"."; break
;
4321 case ErrorCode
::InvalidTableExist
: aMsg
= "The database already contains a table or view with name \"#\"."; break
;
4322 case ErrorCode
::InvalidQueryExist
: aMsg
= "The database already contains a query with name \"#\"."; break
;
4324 OSL_FAIL
( "OParseContext::getErrorMessage: unknown error code!" );
4331 OString OParseContext
::getIntlKeywordAscii
(InternationalKeyCode _eKey
) const
4336 case InternationalKeyCode
::Like
: aKeyword
= "LIKE"; break
;
4337 case InternationalKeyCode
::Not
: aKeyword
= "NOT"; break
;
4338 case InternationalKeyCode
::Null
: aKeyword
= "NULL"; break
;
4339 case InternationalKeyCode
::True
: aKeyword
= "True"; break
;
4340 case InternationalKeyCode
::False
: aKeyword
= "False"; break
;
4341 case InternationalKeyCode
::Is
: aKeyword
= "IS"; break
;
4342 case InternationalKeyCode
::Between
: aKeyword
= "BETWEEN"; break
;
4343 case InternationalKeyCode
::Or
: aKeyword
= "OR"; break
;
4344 case InternationalKeyCode
::And
: aKeyword
= "AND"; break
;
4345 case InternationalKeyCode
::Avg
: aKeyword
= "AVG"; break
;
4346 case InternationalKeyCode
::Count
: aKeyword
= "COUNT"; break
;
4347 case InternationalKeyCode
::Max
: aKeyword
= "MAX"; break
;
4348 case InternationalKeyCode
::Min
: aKeyword
= "MIN"; break
;
4349 case InternationalKeyCode
::Sum
: aKeyword
= "SUM"; break
;
4350 case InternationalKeyCode
::Every
: aKeyword
= "EVERY"; break
;
4351 case InternationalKeyCode
::Any
: aKeyword
= "ANY"; break
;
4352 case InternationalKeyCode
::Some
: aKeyword
= "SOME"; break
;
4353 case InternationalKeyCode
::StdDevPop
: aKeyword
= "STDDEV_POP"; break
;
4354 case InternationalKeyCode
::StdDevSamp
: aKeyword
= "STDDEV_SAMP"; break
;
4355 case InternationalKeyCode
::VarSamp
: aKeyword
= "VAR_SAMP"; break
;
4356 case InternationalKeyCode
::VarPop
: aKeyword
= "VAR_POP"; break
;
4357 case InternationalKeyCode
::Collect
: aKeyword
= "COLLECT"; break
;
4358 case InternationalKeyCode
::Fusion
: aKeyword
= "FUSION"; break
;
4359 case InternationalKeyCode
::Intersection
:aKeyword
= "INTERSECTION"; break
;
4360 case InternationalKeyCode
::None
: break
;
4362 OSL_FAIL
( "OParseContext::getIntlKeywordAscii: unknown key!" );
4369 IParseContext::InternationalKeyCode OParseContext
::getIntlKeyCode
(const OString
& rToken
) const
4371 static IParseContext
::InternationalKeyCode Intl_TokenID
[] =
4373 InternationalKeyCode
::Like
, InternationalKeyCode
::Not
, InternationalKeyCode
::Null
, InternationalKeyCode
::True
,
4374 InternationalKeyCode
::False
, InternationalKeyCode
::Is
, InternationalKeyCode
::Between
, InternationalKeyCode
::Or
,
4375 InternationalKeyCode
::And
, InternationalKeyCode
::Avg
, InternationalKeyCode
::Count
, InternationalKeyCode
::Max
,
4376 InternationalKeyCode
::Min
, InternationalKeyCode
::Sum
, InternationalKeyCode
::Every
,InternationalKeyCode
::Any
,InternationalKeyCode
::Some
,
4377 InternationalKeyCode
::StdDevPop
,InternationalKeyCode
::StdDevSamp
,InternationalKeyCode
::VarSamp
,
4378 InternationalKeyCode
::VarPop
,InternationalKeyCode
::Collect
,InternationalKeyCode
::Fusion
,InternationalKeyCode
::Intersection
4381 sal_uInt32 nCount
= SAL_N_ELEMENTS
( Intl_TokenID
);
4382 for
(sal_uInt32 i
= 0; i
< nCount
; i
++)
4384 OString aKey
= getIntlKeywordAscii
(Intl_TokenID
[i
]);
4385 if
(rToken.equalsIgnoreAsciiCase
(aKey
))
4386 return Intl_TokenID
[i
];
4389 return InternationalKeyCode
::None
;
4393 static Locale
& impl_getLocaleInstance
( )
4395 static Locale s_aLocale
( "en", "US", "" );
4400 Locale OParseContext
::getPreferredLocale
( ) const
4402 return getDefaultLocale
();
4406 const Locale
& OParseContext
::getDefaultLocale
()
4408 return impl_getLocaleInstance
();
4411 // Der (leider globale) yylval fuer die Uebergabe von
4412 // Werten vom Scanner an den Parser. Die globale Variable
4413 // wird nur kurzzeitig verwendet, der Parser liest die Variable
4414 // sofort nach dem Scanner-Aufruf in eine gleichnamige eigene
4418 OUString ConvertLikeToken
(const OSQLParseNode
* pTokenNode
, const OSQLParseNode
* pEscapeNode
, bool bInternational
)
4420 OUStringBuffer aMatchStr
(0);
4421 if
(pTokenNode
->isToken
())
4423 sal_Unicode cEscape
= 0;
4424 if
(pEscapeNode
->count
())
4425 cEscape
= pEscapeNode
->getChild
(1)->getTokenValue
().toChar
();
4427 // Platzhalter austauschen
4428 aMatchStr
= pTokenNode
->getTokenValue
();
4429 const sal_Int32 nLen
= aMatchStr.getLength
();
4430 OUStringBuffer sSearch
,sReplace
;
4431 if
( bInternational
)
4433 sSearch.appendAscii
("%_",2);
4434 sReplace.appendAscii
("*?",2);
4438 sSearch.appendAscii
("*?",2);
4439 sReplace.appendAscii
("%_",2);
4442 bool wasEscape
= false
;
4443 for
(sal_Int32 i
= 0; i
< nLen
; i
++)
4445 const sal_Unicode c
= aMatchStr
[i
];
4446 // SQL standard requires the escape to be followed
4447 // by a meta-character ('%', '_' or itself), else error
4448 // We are more lenient here and let it escape anything.
4449 // Especially since some databases (e.g. Microsoft SQL Server)
4450 // have more meta-characters than the standard, such as e.g. '[' and ']'
4462 if
(c
== sSearch
[0])
4464 else if
(c
== sSearch
[1])
4469 aMatchStr
[i
] = sReplace
[match
];
4473 return aMatchStr.makeStringAndClear
();
4476 sal_uInt32 OSQLParser
::s_nRuleIDs
[OSQLParseNode
::rule_count
+ 1];
4477 OSQLParser::RuleIDMap OSQLParser
::s_aReverseRuleIDLookup
;
4478 OParseContext OSQLParser
::s_aDefaultContext
;
4480 sal_Int32 OSQLParser
::s_nRefCount
= 0;
4481 // ::osl::Mutex OSQLParser::s_aMutex;
4482 OSQLScanner
* OSQLParser
::s_pScanner
= 0;
4483 OSQLParseNodesGarbageCollector
* OSQLParser
::s_pGarbageCollector
= 0;
4484 css::uno
::Reference
< css
::i18n
::XLocaleData4
> OSQLParser
::s_xLocaleData
= NULL
;
4486 void setParser
(OSQLParser
* _pParser
)
4488 xxx_pGLOBAL_SQLPARSER
= _pParser
;
4491 void OSQLParser
::setParseTree
(OSQLParseNode
* pNewParseTree
)
4493 ::osl
::MutexGuard aGuard
(getMutex
());
4494 m_pParseTree
= pNewParseTree
;
4498 /** Delete all comments in a query.
4500 See also getComment()/concatComment() implementation for
4501 OQueryController::translateStatement().
4503 static OUString delComment
( const OUString
& rQuery
)
4505 // First a quick search if there is any "--" or "//" or "/*", if not then the whole
4506 // copying loop is pointless.
4507 if
(rQuery.indexOfAsciiL
( "--", 2, 0) < 0 && rQuery.indexOfAsciiL
( "//", 2, 0) < 0 &&
4508 rQuery.indexOfAsciiL
( "/*", 2, 0) < 0)
4511 const sal_Unicode
* pCopy
= rQuery.getStr
();
4512 sal_Int32 nQueryLen
= rQuery.getLength
();
4513 bool bIsText1
= false
; // "text"
4514 bool bIsText2
= false
; // 'text'
4515 bool bComment2
= false
; // /* comment */
4516 bool bComment
= false
; // -- or // comment
4517 OUStringBuffer aBuf
(nQueryLen
);
4518 for
(sal_Int32 i
=0; i
< nQueryLen
; ++i
)
4522 if
((i
+1) < nQueryLen
)
4524 if
(pCopy
[i
]=='*' && pCopy
[i
+1]=='/')
4532 // comment can't close anymore, actually an error, but..
4536 if
(pCopy
[i
] == '\n')
4540 if
(pCopy
[i
] == '\"' && !bIsText2
)
4541 bIsText1
= !bIsText1
;
4542 else if
(pCopy
[i
] == '\'' && !bIsText1
)
4543 bIsText2
= !bIsText2
;
4544 if
(!bIsText1
&& !bIsText2
&& (i
+1) < nQueryLen
)
4546 if
((pCopy
[i
]=='-' && pCopy
[i
+1]=='-') ||
(pCopy
[i
]=='/' && pCopy
[i
+1]=='/'))
4548 else if
((pCopy
[i
]=='/' && pCopy
[i
+1]=='*'))
4552 if
(!bComment
&& !bComment2
)
4553 aBuf.append
( &pCopy
[i
], 1);
4555 return aBuf.makeStringAndClear
();
4558 OSQLParseNode
* OSQLParser
::parseTree
(OUString
& rErrorMessage
,
4559 const OUString
& rStatement
,
4560 bool bInternational
)
4564 // Guard the parsing
4565 ::osl
::MutexGuard aGuard
(getMutex
());
4569 // delete comments before parsing
4570 OUString sTemp
= delComment
(rStatement
);
4572 // defines how to scan
4573 s_pScanner
->SetRule
(s_pScanner
->GetSQLRule
()); // initial
4574 s_pScanner
->prepareScan
(sTemp
, m_pContext
, bInternational
);
4576 SQLyylval.pParseNode
= NULL
;
4578 m_pParseTree
= NULL
;
4579 m_sErrorMessage
= "";
4582 if
(SQLyyparse
() != 0)
4584 // only set the error message, if it's not already set
4585 if
(m_sErrorMessage.isEmpty
())
4586 m_sErrorMessage
= s_pScanner
->getErrorMessage
();
4587 if
(m_sErrorMessage.isEmpty
())
4588 m_sErrorMessage
= m_pContext
->getErrorMessage
(IParseContext
::ErrorCode
::General
);
4590 rErrorMessage
= m_sErrorMessage
;
4592 // clear the garbage collector
4593 (*s_pGarbageCollector
)->clearAndDelete
();
4598 (*s_pGarbageCollector
)->clear
();
4601 // to work around a bug in MKS YACC return the member m_pParseTree
4602 // instead of Sdbyyval.pParseNode
4604 SAL_WARN_IF
(!m_pParseTree
, "connectivity.parse",
4605 "OSQLParser: Parser did not create ParseTree");
4606 return m_pParseTree
;
4610 OString OSQLParser
::TokenIDToStr
(sal_uInt32 nTokenID
, const IParseContext
* pContext
)
4615 IParseContext
::InternationalKeyCode eKeyCode
= IParseContext
::InternationalKeyCode
::None
;
4618 case SQL_TOKEN_LIKE
: eKeyCode
= IParseContext
::InternationalKeyCode
::Like
; break
;
4619 case SQL_TOKEN_NOT
: eKeyCode
= IParseContext
::InternationalKeyCode
::Not
; break
;
4620 case SQL_TOKEN_NULL
: eKeyCode
= IParseContext
::InternationalKeyCode
::Null
; break
;
4621 case SQL_TOKEN_TRUE
: eKeyCode
= IParseContext
::InternationalKeyCode
::True
; break
;
4622 case SQL_TOKEN_FALSE
: eKeyCode
= IParseContext
::InternationalKeyCode
::False
; break
;
4623 case SQL_TOKEN_IS
: eKeyCode
= IParseContext
::InternationalKeyCode
::Is
; break
;
4624 case SQL_TOKEN_BETWEEN
: eKeyCode
= IParseContext
::InternationalKeyCode
::Between
; break
;
4625 case SQL_TOKEN_OR
: eKeyCode
= IParseContext
::InternationalKeyCode
::Or
; break
;
4626 case SQL_TOKEN_AND
: eKeyCode
= IParseContext
::InternationalKeyCode
::And
; break
;
4627 case SQL_TOKEN_AVG
: eKeyCode
= IParseContext
::InternationalKeyCode
::Avg
; break
;
4628 case SQL_TOKEN_COUNT
: eKeyCode
= IParseContext
::InternationalKeyCode
::Count
; break
;
4629 case SQL_TOKEN_MAX
: eKeyCode
= IParseContext
::InternationalKeyCode
::Max
; break
;
4630 case SQL_TOKEN_MIN
: eKeyCode
= IParseContext
::InternationalKeyCode
::Min
; break
;
4631 case SQL_TOKEN_SUM
: eKeyCode
= IParseContext
::InternationalKeyCode
::Sum
; break
;
4633 if
( eKeyCode
!= IParseContext
::InternationalKeyCode
::None
)
4634 aStr
= pContext
->getIntlKeywordAscii
(eKeyCode
);
4639 aStr
= yytname
[YYTRANSLATE
(nTokenID
)];
4640 if
(aStr.startsWith
("SQL_TOKEN_"))
4641 aStr
= aStr.copy
(10);
4648 aStr
= aStr.toAsciiLowerCase
();
4654 #if OSL_DEBUG_LEVEL > 0
4655 OUString OSQLParser
::RuleIDToStr
(sal_uInt32 nRuleID
)
4657 OSL_ENSURE
(nRuleID
< SAL_N_ELEMENTS
(yytname
), "OSQLParser::RuleIDToStr: Invalid nRuleId!");
4658 return OUString
::createFromAscii
(yytname
[nRuleID
]);
4663 sal_uInt32 OSQLParser
::StrToRuleID
(const OString
& rValue
)
4665 // Search for the given name in yytname and return the index
4666 // (or UNKNOWN_RULE, if not found)
4667 static sal_uInt32 nLen
= SAL_N_ELEMENTS
(yytname
);
4668 for
(sal_uInt32 i
= YYTRANSLATE
(SQL_TOKEN_INVALIDSYMBOL
); i
< (nLen
-1); i
++)
4670 if
(rValue
== yytname
[i
])
4675 return OSQLParseNode
::UNKNOWN_RULE
;
4679 OSQLParseNode::Rule OSQLParser
::RuleIDToRule
( sal_uInt32 _nRule
)
4681 OSQLParser
::RuleIDMap
::const_iterator i
(s_aReverseRuleIDLookup.find
(_nRule
));
4682 if
(i
== s_aReverseRuleIDLookup.end
())
4684 SAL_INFO
("connectivity.parse",
4685 "connectivity::OSQLParser::RuleIDToRule cannot reverse-lookup rule. "
4686 "Reverse mapping incomplete? "
4687 "_nRule='" << _nRule
<< "' "
4688 "yytname[_nRule]='" << yytname
[_nRule
] << "'");
4689 return OSQLParseNode
::UNKNOWN_RULE
;
4696 sal_uInt32 OSQLParser
::RuleID
(OSQLParseNode
::Rule eRule
)
4698 return s_nRuleIDs
[(sal_uInt16
)eRule
];
4701 sal_Int16 OSQLParser
::buildNode
(OSQLParseNode
*& pAppend
,OSQLParseNode
* pCompare
,OSQLParseNode
* pLiteral
,OSQLParseNode
* pLiteral2
)
4703 OSQLParseNode
* pColumnRef
= new OSQLInternalNode
("", SQLNodeType
::Rule
,OSQLParser
::RuleID
(OSQLParseNode
::column_ref
));
4704 pColumnRef
->append
(new OSQLInternalNode
(m_sFieldName
,SQLNodeType
::Name
));
4705 OSQLParseNode
* pComp
= NULL
;
4706 if
( SQL_ISTOKEN
( pCompare
, BETWEEN
) && pLiteral2
)
4707 pComp
= new OSQLInternalNode
("", SQLNodeType
::Rule
,OSQLParser
::RuleID
(OSQLParseNode
::between_predicate_part_2
));
4709 pComp
= new OSQLInternalNode
("", SQLNodeType
::Rule
,OSQLParser
::RuleID
(OSQLParseNode
::comparison_predicate
));
4711 pComp
->append
(pColumnRef
);
4712 pComp
->append
(pCompare
);
4713 pComp
->append
(pLiteral
);
4716 pComp
->append
(new OSQLInternalNode
("", SQLNodeType
::Keyword
,SQL_TOKEN_AND
));
4717 pComp
->append
(pLiteral2
);
4719 pAppend
->append
(pComp
);
4723 sal_Int16 OSQLParser
::buildStringNodes
(OSQLParseNode
*& pLiteral
)
4728 if
(SQL_ISRULE
(pLiteral
,set_fct_spec
) || SQL_ISRULE
(pLiteral
,general_set_fct
) || SQL_ISRULE
(pLiteral
,column_ref
)
4729 || SQL_ISRULE
(pLiteral
,subquery
))
4730 return
1; // here I have a function that I can't transform into a string
4732 if
(pLiteral
->getNodeType
() == SQLNodeType
::IntNum || pLiteral
->getNodeType
() == SQLNodeType
::ApproxNum || pLiteral
->getNodeType
() == SQLNodeType
::AccessDate
)
4734 OSQLParseNode
* pParent
= pLiteral
->getParent
();
4736 OSQLParseNode
* pNewNode
= new OSQLInternalNode
(pLiteral
->getTokenValue
(), SQLNodeType
::String
);
4737 pParent
->replace
(pLiteral
, pNewNode
);
4743 for
(sal_uInt32 i
=0;i
<pLiteral
->count
();++i
)
4745 OSQLParseNode
* pChild
= pLiteral
->getChild
(i
);
4746 buildStringNodes
(pChild
);
4748 if
(SQL_ISRULE
(pLiteral
,term
) || SQL_ISRULE
(pLiteral
,value_exp_primary
))
4750 m_sErrorMessage
= m_pContext
->getErrorMessage
(IParseContext
::ErrorCode
::InvalidCompare
);
4756 sal_Int16 OSQLParser
::buildComparsionRule
(OSQLParseNode
*& pAppend
,OSQLParseNode
* pLiteral
)
4758 OSQLParseNode
* pComp
= new OSQLInternalNode
("=", SQLNodeType
::Equal
);
4759 return buildPredicateRule
(pAppend
,pLiteral
,pComp
);
4764 void OSQLParser
::reduceLiteral
(OSQLParseNode
*& pLiteral
, bool bAppendBlank
)
4766 OSL_ENSURE
(pLiteral
->isRule
(), "This is no Rule");
4767 OSL_ENSURE
(pLiteral
->count
() == 2, "OSQLParser::ReduceLiteral() Invalid count");
4768 OSQLParseNode
* pTemp
= pLiteral
;
4769 OUStringBuffer aValue
(pLiteral
->getChild
(0)->getTokenValue
());
4772 aValue.appendAscii
(" ");
4775 aValue.append
(pLiteral
->getChild
(1)->getTokenValue
());
4777 pLiteral
= new OSQLInternalNode
(aValue.makeStringAndClear
(),SQLNodeType
::String
);
4782 void OSQLParser
::error(const sal_Char
*fmt
)
4784 if
(m_sErrorMessage.isEmpty
())
4786 OUString sStr
(fmt
,strlen
(fmt
),RTL_TEXTENCODING_UTF8
);
4787 OUString sSQL_TOKEN
("SQL_TOKEN_");
4789 sal_Int32 nPos1
= sStr.indexOf
(sSQL_TOKEN
);
4792 OUString sFirst
= sStr.copy
(0,nPos1
);
4793 sal_Int32 nPos2
= sStr.indexOf
(sSQL_TOKEN
,nPos1
+1);
4796 OUString sSecond
= sStr.copy
(nPos1
+sSQL_TOKEN.getLength
(),nPos2
-nPos1
-sSQL_TOKEN.getLength
());
4798 sFirst
+= sStr.copy
(nPos2
+sSQL_TOKEN.getLength
());
4801 sFirst
+= sStr.copy
(nPos1
+sSQL_TOKEN.getLength
());
4803 m_sErrorMessage
= sFirst
;
4806 m_sErrorMessage
= sStr
;
4808 OUString aError
= s_pScanner
->getErrorMessage
();
4809 if
(!aError.isEmpty
())
4811 m_sErrorMessage
+= ", ";
4812 m_sErrorMessage
+= aError
;
4817 int OSQLParser
::SQLlex
()
4819 return s_pScanner
->SQLlex
();
4822 #if defined _MSC_VER
4823 #pragma warning(pop)