bump product version to 5.0.4.1
[LibreOffice.git] / connectivity / source / parse / sqlbison.y
blobf65601a78f6ec52b480d8f5bd159b729ab9515f5
1 %glr-parser
2 %token-table
3 %{
4 /*
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 .
22 #include <vector>
23 #include <string.h>
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>
49 #if defined _MSC_VER
50 #pragma warning(push, 1)
51 #pragma warning(disable:4273 4701)
52 #endif
54 #ifdef __GNUC__
55 # pragma GCC diagnostic ignored "-Wwrite-strings"
56 # pragma GCC diagnostic ignored "-Wunused-function"
57 #endif
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
83 #endif
85 #define SQLyyerror(s) \
86 { \
87 xxx_pGLOBAL_SQLPARSER->error(s); \
90 using namespace connectivity;
91 #define SQLyylex xxx_pGLOBAL_SQLPARSER->SQLlex
93 /* symbolic tokens */
95 %union {
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
139 /* ODBC KEYWORDS */
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
171 // window function
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
176 // LIMIT and OFFSEt
177 %token <pParseNode> SQL_TOKEN_LIMIT SQL_TOKEN_OFFSET SQL_TOKEN_NEXT SQL_TOKEN_ONLY
179 /* operators */
180 %left SQL_TOKEN_NAME
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
188 %left ')'
189 %right '='
190 %right '.'
191 %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 ); }
267 | sql ';'
268 { xxx_pGLOBAL_SQLPARSER->setParseTree( $1 ); }
271 /* schema definition language */
272 /* Note: other ``sql:sal_Unicode() rules appear later in the grammar */
274 sql:
275 manipulative_statement
276 | schema_element
278 $$ = SQL_NEW_RULE;
279 $$->append($1);
283 /***
285 op_authorization:
286 {$$ = SQL_NEW_RULE;}
287 | SQL_TOKEN_AUTHORIZATION user
289 $$ = SQL_NEW_RULE;
290 $$->append($1);
291 $$->append($2);
294 op_schema:
295 {$$ = SQL_NEW_RULE;}
296 | SQL_TOKEN_NAME
297 | SQL_TOKEN_NAME '.' SQL_TOKEN_NAME
299 $$ = SQL_NEW_RULE;
300 $$->append($1);
301 $$->append(newNode(".", SQL_NODE_PUNCTUATION));
302 $$->append($3);
306 schema:
307 SQL_TOKEN_CREATE SQL_TOKEN_SCHEMA op_schema op_authorization opt_schema_element_list
309 $$ = SQL_NEW_RULE;
310 $$->append($1);
311 $$->append($2);
312 $$->append($3);
313 $$->append($4);
314 $$->append($5);
318 opt_schema_element_list:
319 {$$ = SQL_NEW_RULE;}
320 | schema_glement_list
323 schema_element_list:
324 schema_element
325 {$$ = SQL_NEW_LISTRULE;
326 $$->append($1);}
327 | schema_element_list schema_element
328 {$1->append($2);
329 $$ = $1;}
333 schema_element:
334 base_table_def
335 | view_def
336 | privilege_def
337 | trigger_definition
340 base_table_def:
341 SQL_TOKEN_CREATE SQL_TOKEN_TABLE table_node '(' base_table_element_commalist ')'
342 {$$ = SQL_NEW_RULE;
343 $$->append($1);
344 $$->append($2);
345 $$->append($3);
346 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
347 $$->append($5);
348 $$->append(newNode(")", SQL_NODE_PUNCTUATION));}
351 base_table_element_commalist:
352 base_table_element
353 {$$ = SQL_NEW_COMMALISTRULE;
354 $$->append($1);}
355 | base_table_element_commalist ',' base_table_element
356 {$1->append($3);
357 $$ = $1;}
360 base_table_element:
361 column_def
362 | table_constraint_def
365 column_def:
366 column data_type column_def_opt_list
367 {$$ = SQL_NEW_RULE;
368 $$->append($1);
369 $$->append($2);
370 $$->append($3);
374 column_def_opt_list:
375 /* empty */ {$$ = SQL_NEW_LISTRULE;}
376 | column_def_opt_list column_def_opt
377 {$1->append($2);
378 $$ = $1;}
381 nil_fkt:
382 datetime_value_fct
384 unique_spec:
385 SQL_TOKEN_UNIQUE
386 | SQL_TOKEN_PRIMARY SQL_TOKEN_KEY
388 $$ = SQL_NEW_RULE;
389 $$->append($1);
390 $$->append($2);
393 column_def_opt:
394 SQL_TOKEN_NOT SQL_TOKEN_NULL
395 {$$ = SQL_NEW_RULE;
396 $$->append($1);
397 $$->append($2);}
398 | unique_spec
399 | SQL_TOKEN_DEFAULT literal
400 {$$ = SQL_NEW_RULE;
401 $$->append($1);
402 $$->append($2);}
403 | SQL_TOKEN_DEFAULT SQL_TOKEN_NULL
404 {$$ = SQL_NEW_RULE;
405 $$->append($1);
406 $$->append($2);}
407 | SQL_TOKEN_DEFAULT SQL_TOKEN_USER
408 {$$ = SQL_NEW_RULE;
409 $$->append($1);
410 $$->append($2);}
411 | SQL_TOKEN_DEFAULT nil_fkt
413 $$ = SQL_NEW_RULE;
414 $$->append($1);
415 $$->append($2);
417 | SQL_TOKEN_CHECK
418 | SQL_TOKEN_CHECK '(' search_condition ')'
419 {$$ = SQL_NEW_RULE;
420 $$->append($1);
421 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
422 $$->append($3);
423 $$->append(newNode(")", SQL_NODE_PUNCTUATION));}
424 | SQL_TOKEN_REFERENCES table_node
425 {$$ = SQL_NEW_RULE;
426 $$->append($1);
427 $$->append($2);}
428 | SQL_TOKEN_REFERENCES table_node '(' column_commalist ')'
429 {$$ = SQL_NEW_RULE;
430 $$->append($1);
431 $$->append($2);
432 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
433 $$->append($4);
434 $$->append(newNode(")", SQL_NODE_PUNCTUATION));}
437 table_constraint_def:
438 unique_spec '(' column_commalist ')'
439 {$$ = SQL_NEW_RULE;
440 $$->append($1);
441 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
442 $$->append($3);
443 $$->append(newNode(")", SQL_NODE_PUNCTUATION));}
444 | SQL_TOKEN_FOREIGN SQL_TOKEN_KEY '(' column_commalist ')' SQL_TOKEN_REFERENCES table_node
445 {$$ = SQL_NEW_RULE;
446 $$->append($1);
447 $$->append($2);
448 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
449 $$->append($4);
450 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
451 $$->append($6);
452 $$->append($7);}
453 | SQL_TOKEN_FOREIGN SQL_TOKEN_KEY '(' column_commalist ')' SQL_TOKEN_REFERENCES table_node '(' column_commalist ')'
454 {$$ = SQL_NEW_RULE;
455 $$->append($1);
456 $$->append($2);
457 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
458 $$->append($4);
459 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
460 $$->append($6);
461 $$->append($7);
462 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
463 $$->append($9);
464 $$->append(newNode(")", SQL_NODE_PUNCTUATION));}
465 | SQL_TOKEN_CHECK '(' search_condition ')'
466 {$$ = SQL_NEW_RULE;
467 $$->append($1);
468 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
469 $$->append($3);
470 $$->append(newNode(")", SQL_NODE_PUNCTUATION));}
472 op_column_commalist:
473 /* empty */ {$$ = SQL_NEW_RULE;}
474 | '(' column_commalist ')'
475 {$$ = SQL_NEW_RULE;
476 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
477 $$->append($2);
478 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
481 column_commalist:
482 column_commalist ',' column
483 {$1->append($3);
484 $$ = $1;}
485 | column
486 {$$ = SQL_NEW_COMMALISTRULE;
487 $$->append($1);}
490 view_def:
491 SQL_TOKEN_CREATE SQL_TOKEN_VIEW table_node opt_column_commalist SQL_TOKEN_AS select_statement opt_with_check_option
492 {$$ = SQL_NEW_RULE;
493 $$->append($1);
494 $$->append($2);
495 $$->append($3);
496 $$->append($4);
497 $$->append($5);
498 $$->append($6);
499 $$->append($7);}
502 opt_with_check_option:
503 /* empty */ {$$ = SQL_NEW_RULE;}
504 | SQL_TOKEN_WITH SQL_TOKEN_CHECK SQL_TOKEN_OPTION
505 {$$ = SQL_NEW_RULE;
506 $$->append($1);
507 $$->append($2);
508 $$->append($3);}
511 opt_column_commalist:
512 /* empty */ {$$ = SQL_NEW_RULE;}
513 | '(' column_commalist ')'
514 {$$ = SQL_NEW_RULE;
515 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
516 $$->append($2);
517 $$->append(newNode(")", SQL_NODE_PUNCTUATION));}
520 privilege_def:
521 SQL_TOKEN_GRANT privileges SQL_TOKEN_ON table_node SQL_TOKEN_TO grantee_commalist
522 opt_with_grant_option
523 {$$ = SQL_NEW_RULE;
524 $$->append($1);
525 $$->append($2);
526 $$->append($3);
527 $$->append($4);
528 $$->append($5);
529 $$->append($6);
530 $$->append($7);}
533 opt_with_grant_option:
534 /* empty */ {$$ = SQL_NEW_RULE;}
535 | SQL_TOKEN_WITH SQL_TOKEN_GRANT SQL_TOKEN_OPTION
536 {$$ = SQL_NEW_RULE;
537 $$->append($1);
538 $$->append($2);
539 $$->append($3);}
542 privileges:
543 SQL_TOKEN_ALL SQL_TOKEN_PRIVILEGES
544 {$$ = SQL_NEW_RULE;
545 $$->append($1);
546 $$->append($2);}
547 | operation_commalist
550 operation_commalist:
551 operation
552 {$$ = SQL_NEW_COMMALISTRULE;
553 $$->append($1);}
554 | operation_commalist ',' operation
555 {$1->append($3);
556 $$ = $1;}
559 operation:
560 SQL_TOKEN_SELECT
561 | SQL_TOKEN_INSERT opt_column_commalist
562 {$$ = SQL_NEW_RULE;
563 $$->append($1);
564 $$->append($2);}
565 | SQL_TOKEN_DELETE
566 | SQL_TOKEN_UPDATE opt_column_commalist
567 {$$ = SQL_NEW_RULE;
568 $$->append($1);
569 $$->append($2);}
570 | SQL_TOKEN_REFERENCES opt_column_commalist
571 {$$ = SQL_NEW_RULE;
572 $$->append($1);
573 $$->append($2);}
574 | SQL_TOKEN_USAGE
578 grantee_commalist:
579 grantee
580 {$$ = SQL_NEW_COMMALISTRULE;
581 $$->append($1);}
582 | grantee_commalist ',' grantee
583 {$1->append($3);
584 $$ = $1;}
587 grantee:
588 SQL_TOKEN_PUBLIC
589 | user
592 /* module language */
594 opt_order_by_clause:
595 /* empty */ {$$ = SQL_NEW_RULE;}
596 | SQL_TOKEN_ORDER SQL_TOKEN_BY ordering_spec_commalist
597 {$$ = SQL_NEW_RULE;
598 $$->append($1);
599 $$->append($2);
600 $$->append($3);}
603 ordering_spec_commalist:
604 ordering_spec
605 {$$ = SQL_NEW_COMMALISTRULE;
606 $$->append($1);}
607 | ordering_spec_commalist ',' ordering_spec
608 {$1->append($3);
609 $$ = $1;}
612 ordering_spec:
613 /* SQL_TOKEN_INTNUM opt_asc_desc
614 {$$ = SQL_NEW_RULE;
615 $$->append($1);
616 $$->append($2);}
618 predicate opt_asc_desc
619 {$$ = SQL_NEW_RULE;
620 $$->append($1);
621 $$->append($2);}
623 | row_value_constructor_elem opt_asc_desc
624 {$$ = SQL_NEW_RULE;
625 $$->append($1);
626 $$->append($2);}
629 opt_asc_desc:
630 {$$ = SQL_NEW_RULE;}
631 | SQL_TOKEN_ASC
632 | SQL_TOKEN_DESC
636 /***
637 manipulative_statement_list:
638 manipulative_statement
639 {$$ = SQL_NEW_LISTRULE;
640 $$->append($1);}
641 | manipulative_statement_list manipulative_statement
642 {$1->append($2);
643 $$ = $1;}
645 ***/
647 sql_not:
648 /* vide */
649 {$$ = SQL_NEW_RULE;}
650 | SQL_TOKEN_NOT
653 /* manipulative statements */
655 manipulative_statement:
656 commit_statement
657 /* | delete_statement_positioned*/
658 | delete_statement_searched
659 | fetch_statement
660 | insert_statement
661 | rollback_statement
662 | select_statement_into
663 /* | update_statement_positioned*/
664 | update_statement_searched
665 | union_statement
666 | '{' odbc_call_spec '}'
668 $$ = SQL_NEW_RULE;
669 $$->append(newNode("{", SQL_NODE_PUNCTUATION));
670 $$->append($2);
671 $$->append(newNode("}", SQL_NODE_PUNCTUATION));
675 union_statement:
676 select_statement
677 | union_statement SQL_TOKEN_UNION all select_statement
679 $$ = SQL_NEW_RULE;
680 $$->append($1);
681 $$->append($2);
682 $$->append($3);
683 $$->append($4);
686 commit_statement:
687 SQL_TOKEN_COMMIT SQL_TOKEN_WORK
688 {$$ = SQL_NEW_RULE;
689 $$->append($1);
690 $$->append($2);}
693 delete_statement_positioned:
694 SQL_TOKEN_DELETE SQL_TOKEN_FROM table_node SQL_TOKEN_WHERE SQL_TOKEN_CURRENT SQL_TOKEN_OF cursor
695 {$$ = SQL_NEW_RULE;
696 $$->append($1);
697 $$->append($2);
698 $$->append($3);
699 $$->append($4);
700 $$->append($5);
701 $$->append($6);
702 $$->append($7);}
705 delete_statement_searched:
706 SQL_TOKEN_DELETE SQL_TOKEN_FROM table_node opt_where_clause
707 {$$ = SQL_NEW_RULE;
708 $$->append($1);
709 $$->append($2);
710 $$->append($3);
711 $$->append($4);}
714 fetch_statement:
715 SQL_TOKEN_FETCH cursor SQL_TOKEN_INTO target_commalist
716 {$$ = SQL_NEW_RULE;
717 $$->append($1);
718 $$->append($2);
719 $$->append($3);
720 $$->append($4);}
723 insert_statement:
724 SQL_TOKEN_INSERT SQL_TOKEN_INTO table_node opt_column_commalist query_exp
725 {$$ = SQL_NEW_RULE;
726 $$->append($1);
727 $$->append($2);
728 $$->append($3);
729 $$->append($4);
730 $$->append($5);}
732 values_or_query_spec:
733 SQL_TOKEN_VALUES '(' table_value_const_list ')'
734 {$$ = SQL_NEW_RULE;
735 $$->append($1);
736 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
737 $$->append($3);
738 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
742 table_value_const_list:
743 row_value_constructor
744 {$$ = SQL_NEW_COMMALISTRULE;
745 $$->append($1);}
746 | table_value_const_list ',' row_value_constructor
747 {$1->append($3);
748 $$ = $1;}
750 row_value_const_list:
751 row_value_constructor_elem
752 {$$ = SQL_NEW_COMMALISTRULE;
753 $$->append($1);}
754 | row_value_const_list ',' row_value_constructor_elem
755 {$1->append($3);
756 $$ = $1;}
758 row_value_constructor:
759 row_value_constructor_elem
760 /* | '(' row_value_const_list ')'
762 $$ = SQL_NEW_RULE;
763 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
764 $$->append($2);
765 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
769 row_value_constructor_elem:
770 value_exp /*[^')']*/
771 | SQL_TOKEN_DEFAULT
775 rollback_statement:
776 SQL_TOKEN_ROLLBACK SQL_TOKEN_WORK
777 {$$ = SQL_NEW_RULE;
778 $$->append($1);
779 $$->append($2);}
783 /* INTO target_commalist herausgenommen */
784 select_statement_into:
785 SQL_TOKEN_SELECT opt_all_distinct selection SQL_TOKEN_INTO target_commalist table_exp
786 {$$ = SQL_NEW_RULE;
787 $$->append($1);
788 $$->append($2);
789 $$->append($3);
790 $$->append($4);
791 $$->append($5);
792 $$->append($6); }
795 opt_all_distinct:
796 {$$ = SQL_NEW_RULE;}
797 | SQL_TOKEN_ALL
798 | SQL_TOKEN_DISTINCT
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
805 {$$ = SQL_NEW_RULE;
806 $$->append($1);
807 $$->append($2);
808 $$->append($3);
809 $$->append($4);
810 $$->append($5);
811 $$->append($6);
812 $$->append($7);
813 $$->append($8);}
816 assignment_commalist:
817 assignment
818 {$$ = SQL_NEW_COMMALISTRULE;
819 $$->append($1);}
820 | assignment_commalist ',' assignment
821 {$1->append($3);
822 $$ = $1;}
825 assignment:
826 column SQL_EQUAL update_source
827 {$$ = SQL_NEW_RULE;
828 $$->append($1);
829 $$->append($2);
830 $$->append($3);}
832 update_source:
833 value_exp
834 | SQL_TOKEN_DEFAULT
836 update_statement_searched:
837 SQL_TOKEN_UPDATE table_node SQL_TOKEN_SET assignment_commalist opt_where_clause
838 {$$ = SQL_NEW_RULE;
839 $$->append($1);
840 $$->append($2);
841 $$->append($3);
842 $$->append($4);
843 $$->append($5);}
846 target_commalist:
847 target
848 {$$ = SQL_NEW_COMMALISTRULE;
849 $$->append($1);}
850 | target_commalist ',' target
851 {$1->append($3);
852 $$ = $1;}
855 target:
856 parameter_ref
859 opt_where_clause:
860 /* empty */ {$$ = SQL_NEW_RULE;}
861 | where_clause
864 /* query expressions */
866 query_term:
867 non_join_query_term
869 $$ = SQL_NEW_RULE;
870 $$->append($1);
873 /* SELECT STATEMENT */
874 select_statement:
875 SQL_TOKEN_SELECT opt_all_distinct selection table_exp
877 $$ = SQL_NEW_RULE;
878 $$->append($1);
879 $$->append($2);
880 $$->append($3);
881 $$->append($4);
885 selection:
888 $$ = SQL_NEW_RULE;
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
900 $$ = SQL_NEW_RULE;
901 $$->append($1);
902 $$->append($2);
903 $$->append($3);
906 opt_fetch_first_row_count:
907 /* empty */ {$$ = SQL_NEW_RULE;}
908 | fetch_first_row_count
910 first_or_next:
911 SQL_TOKEN_FIRST
912 | SQL_TOKEN_NEXT
914 row_or_rows:
915 SQL_TOKEN_ROW
916 | SQL_TOKEN_ROWS
918 opt_fetch_first_clause:
919 /* empty */ {$$ = SQL_NEW_RULE;}
920 | fetch_first_clause
922 fetch_first_clause:
923 SQL_TOKEN_FETCH first_or_next opt_fetch_first_row_count row_or_rows SQL_TOKEN_ONLY
925 $$ = SQL_NEW_RULE;
926 $$->append($1);
927 $$->append($2);
928 $$->append($3);
929 $$->append($4);
930 $$->append($5);
933 offset_row_count:
934 literal
936 fetch_first_row_count:
937 literal
940 opt_limit_offset_clause:
941 /* empty */ {$$ = SQL_NEW_RULE;}
942 | limit_offset_clause
944 opt_offset:
945 /* empty */ {$$ = SQL_NEW_RULE;}
946 | SQL_TOKEN_OFFSET SQL_TOKEN_INTNUM
948 $$ = SQL_NEW_RULE;
949 $$->append($1);
950 $$->append($2);
953 limit_offset_clause:
954 SQL_TOKEN_LIMIT SQL_TOKEN_INTNUM opt_offset
956 $$ = SQL_NEW_RULE;
957 $$->append($1);
958 $$->append($2);
959 $$->append($3);
962 table_exp:
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
965 $$ = SQL_NEW_RULE;
966 $$->append($1);
967 $$->append($2);
968 $$->append($3);
969 $$->append($4);
970 $$->append($5);
971 $$->append($6);
972 $$->append($7);
973 $$->append($8);
974 $$->append($9);
978 from_clause:
979 SQL_TOKEN_FROM table_ref_commalist
980 { $$ = SQL_NEW_RULE;
981 $$->append($1);
982 $$->append($2); }
985 table_ref_commalist:
987 table_ref
988 { $$ = SQL_NEW_COMMALISTRULE;
989 $$->append($1); }
990 | table_ref_commalist ',' table_ref
991 { $1->append($3);
992 $$ = $1; }
995 opt_as:
996 /* empty */ {$$ = SQL_NEW_RULE;}
997 | SQL_TOKEN_AS
999 opt_row:
1000 /* empty */ {$$ = SQL_NEW_RULE;}
1001 | SQL_TOKEN_ROW
1003 table_primary_as_range_column:
1004 {$$ = SQL_NEW_RULE;}
1005 | opt_as SQL_TOKEN_NAME op_column_commalist
1007 $$ = SQL_NEW_RULE;
1008 $$->append($1);
1009 $$->append($2);
1010 $$->append($3);
1013 table_ref:
1014 table_node table_primary_as_range_column
1016 $$ = SQL_NEW_RULE;
1017 $$->append($1);
1018 $$->append($2);
1020 | subquery range_variable op_column_commalist
1022 $$ = SQL_NEW_RULE;
1023 $$->append($1);
1024 $$->append($2);
1025 $$->append($3);
1027 | joined_table
1028 | '{' SQL_TOKEN_OJ joined_table '}'
1030 $$ = SQL_NEW_RULE;
1031 $$->append(newNode("{", SQL_NODE_PUNCTUATION));
1032 $$->append($2);
1033 $$->append($3);
1034 $$->append(newNode("}", SQL_NODE_PUNCTUATION));
1036 | '(' joined_table ')'
1038 $$ = SQL_NEW_RULE;
1039 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
1040 $$->append($2);
1041 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
1044 where_clause:
1045 SQL_TOKEN_WHERE search_condition
1046 {$$ = SQL_NEW_RULE;
1047 $$->append($1);
1048 $$->append($2);}
1051 opt_group_by_clause:
1052 /* empty */ {$$ = SQL_NEW_RULE;}
1053 | SQL_TOKEN_GROUP SQL_TOKEN_BY column_ref_commalist
1054 {$$ = SQL_NEW_RULE;
1055 $$->append($1);
1056 $$->append($2);
1057 $$->append($3);}
1060 column_ref_commalist:
1061 column_ref
1062 {$$ = SQL_NEW_COMMALISTRULE;
1063 $$->append($1);}
1064 | set_fct_spec
1065 {$$ = SQL_NEW_COMMALISTRULE;
1066 $$->append($1);}
1067 | column_ref_commalist ',' column_ref
1068 {$1->append($3);
1069 $$ = $1;}
1070 | column_ref_commalist ',' set_fct_spec
1071 {$1->append($3);
1072 $$ = $1;}
1075 opt_having_clause:
1076 /* empty */ {$$ = SQL_NEW_RULE;}
1077 | SQL_TOKEN_HAVING search_condition
1078 {$$ = SQL_NEW_RULE;
1079 $$->append($1);
1080 $$->append($2);}
1083 /* search conditions */
1084 boolean_primary:
1085 predicate
1086 | '(' search_condition ')'
1087 { // boolean_primary: rule 2
1088 $$ = SQL_NEW_RULE;
1089 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
1090 $$->append($2);
1091 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
1093 | row_value_constructor_elem /*[^')' ',']*/
1095 if(xxx_pGLOBAL_SQLPARSER->inPredicateCheck())// boolean_primary: rule 3
1097 $$ = SQL_NEW_RULE;
1098 sal_Int16 nErg = 0;
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);
1112 $$->append(pTFN);
1114 nErg = 1;
1116 else
1118 nErg = xxx_pGLOBAL_SQLPARSER->buildComparsionRule($$,$1);
1120 if(nErg == 1)
1122 OSQLParseNode* pTemp = $$;
1123 $$ = pTemp->removeAt((sal_uInt32)0);
1124 delete pTemp;
1126 else
1128 delete $$;
1129 if(nErg)
1130 YYERROR;
1131 else
1132 YYABORT;
1135 else
1136 YYERROR;
1139 parenthesized_boolean_value_expression:
1140 '(' search_condition ')'
1141 { // boolean_primary: rule 2
1142 $$ = SQL_NEW_RULE;
1143 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
1144 $$->append($2);
1145 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
1148 boolean_factor:
1149 boolean_primary %dprec 2
1150 | SQL_TOKEN_NOT boolean_primary %dprec 1
1151 { // boolean_factor: rule 1
1152 $$ = SQL_NEW_RULE;
1153 $$->append($1);
1154 $$->append($2);
1157 boolean_term:
1158 boolean_factor
1159 | boolean_term SQL_TOKEN_AND boolean_factor
1161 $$ = SQL_NEW_RULE; // boolean_term: rule 1
1162 $$->append($1);
1163 $$->append($2);
1164 $$->append($3);
1167 search_condition:
1168 boolean_term
1169 | search_condition SQL_TOKEN_OR boolean_term
1171 $$ = SQL_NEW_RULE; // search_condition
1172 $$->append($1);
1173 $$->append($2);
1174 $$->append($3);
1177 predicate:
1178 comparison_predicate %dprec 1
1179 | between_predicate
1180 | all_or_any_predicate
1181 | existence_test
1182 | unique_test
1183 | test_for_null %dprec 2
1184 | in_predicate
1185 | like_predicate
1187 comparison_predicate_part_2:
1188 comparison row_value_constructor
1190 $$ = SQL_NEW_RULE; // comparison_predicate: rule 1
1191 $$->append($1);
1192 $$->append($2);
1194 comparison_predicate:
1195 row_value_constructor comparison row_value_constructor
1197 $$ = SQL_NEW_RULE; // comparison_predicate: rule 1
1198 $$->append($1);
1199 $$->append($2);
1200 $$->append($3);
1202 | comparison row_value_constructor
1204 if(xxx_pGLOBAL_SQLPARSER->inPredicateCheck()) // comparison_predicate: rule 2
1206 $$ = SQL_NEW_RULE;
1207 sal_Int16 nErg = xxx_pGLOBAL_SQLPARSER->buildPredicateRule($$,$2,$1);
1208 if(nErg == 1)
1210 OSQLParseNode* pTemp = $$;
1211 $$ = pTemp->removeAt((sal_uInt32)0);
1212 delete pTemp;
1214 else
1216 delete $$;
1217 YYABORT;
1220 else
1222 YYERROR;
1226 comparison:
1227 SQL_LESS
1228 | SQL_NOTEQUAL
1229 | SQL_EQUAL
1230 | SQL_GREAT
1231 | SQL_LESSEQ
1232 | SQL_GREATEQ
1233 | SQL_TOKEN_IS sql_not SQL_TOKEN_DISTINCT SQL_TOKEN_FROM
1235 $$ = SQL_NEW_RULE;
1236 $$->append($1);
1237 $$->append($2);
1238 $$->append($3);
1239 $$->append($4);
1241 | SQL_TOKEN_IS sql_not
1243 $$ = SQL_NEW_RULE;
1244 $$->append($1);
1245 $$->append($2);
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
1253 $$ = SQL_NEW_RULE;
1255 sal_Int16 nErg = xxx_pGLOBAL_SQLPARSER->buildPredicateRule($$,$3,$2,$5);
1256 if(nErg == 1)
1258 OSQLParseNode* pTemp = $$;
1259 $$ = pTemp->removeAt((sal_uInt32)0);
1260 OSQLParseNode* pColumnRef = $$->removeAt((sal_uInt32)0);
1261 $$->insert(0,$1);
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;
1267 delete pTemp;
1268 delete $4;
1270 else
1272 delete $$;
1273 YYABORT;
1276 else
1278 $$ = SQL_NEW_RULE; // between_predicate: rule 1
1279 $$->append($1);
1280 $$->append($2);
1281 $$->append($3);
1282 $$->append($4);
1283 $$->append($5);
1286 between_predicate:
1287 row_value_constructor between_predicate_part_2
1289 $$ = SQL_NEW_RULE; // between_predicate: rule 1
1290 $$->append($1);
1291 $$->append($2);
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
1299 $$->append($1);
1300 $$->append($2);
1301 $$->append($3);
1302 $$->append($4);
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
1309 $$->append($1);
1310 $$->append($2);
1311 $$->append($3);
1312 $$->append($4);
1315 like_predicate:
1316 row_value_constructor character_like_predicate_part_2
1318 $$ = SQL_NEW_RULE; // like_predicate: rule 1
1319 $$->append($1);
1320 $$->append($2);
1322 | row_value_constructor other_like_predicate_part_2
1324 $$ = SQL_NEW_RULE; // like_predicate: rule 3
1325 $$->append($1);
1326 $$->append($2);
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));
1335 $$ = SQL_NEW_RULE;
1336 $$->append(pColumnRef);
1337 $$->append($1);
1338 OSQLParseNode* p2nd = $1->removeAt(2);
1339 OSQLParseNode* p3rd = $1->removeAt(2);
1340 if ( !xxx_pGLOBAL_SQLPARSER->buildLikeRule($1,p2nd,p3rd) )
1342 delete $$;
1343 YYABORT;
1345 $1->append(p3rd);
1347 else
1348 YYERROR;
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));
1357 $$ = SQL_NEW_RULE;
1358 $$->append(pColumnRef);
1359 $$->append($1);
1360 OSQLParseNode* p2nd = $1->removeAt(2);
1361 OSQLParseNode* p3rd = $1->removeAt(2);
1362 if ( !xxx_pGLOBAL_SQLPARSER->buildLikeRule($1,p2nd,p3rd) )
1364 delete $$;
1365 YYABORT;
1367 $1->append(p3rd);
1369 else
1370 YYERROR;
1374 opt_escape:
1375 /* empty */ {$$ = SQL_NEW_RULE;}
1376 | SQL_TOKEN_ESCAPE string_value_exp
1377 {$$ = SQL_NEW_RULE;
1378 $$->append($1);
1379 $$->append($2);}
1380 | '{' SQL_TOKEN_ESCAPE SQL_TOKEN_STRING '}'
1382 $$ = SQL_NEW_RULE;
1383 $$->append(newNode("{", SQL_NODE_PUNCTUATION));
1384 $$->append($2);
1385 $$->append($3);
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
1394 $$->append($1);
1395 $$->append($2);
1396 $$->append($3);
1398 | SQL_TOKEN_IS sql_not SQL_TOKEN_UNKNOWN
1400 $$ = SQL_NEW_RULE; // test_for_null: rule 1
1401 $$->append($1);
1402 $$->append($2);
1403 $$->append($3);
1406 test_for_null:
1407 row_value_constructor null_predicate_part_2
1409 $$ = SQL_NEW_RULE; // test_for_null: rule 1
1410 $$->append($1);
1411 $$->append($2);
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));
1420 $$ = SQL_NEW_RULE;
1421 $$->append(pColumnRef);
1422 $$->append($1);
1424 else
1425 YYERROR;
1428 in_predicate_value:
1429 subquery
1430 {$$ = SQL_NEW_RULE;
1431 $$->append($1);
1433 | '(' value_exp_commalist ')'
1434 {$$ = SQL_NEW_RULE;
1435 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
1436 $$->append($2);
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
1444 $$->append($1);
1445 $$->append($2);
1446 $$->append($3);
1449 in_predicate:
1450 row_value_constructor in_predicate_part_2
1452 $$ = SQL_NEW_RULE;// in_predicate: rule 1
1453 $$->append($1);
1454 $$->append($2);
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));
1463 $$ = SQL_NEW_RULE;
1464 $$->append(pColumnRef);
1465 $$->append($1);
1467 else
1468 YYERROR;
1471 quantified_comparison_predicate_part_2:
1472 comparison any_all_some subquery
1474 $$ = SQL_NEW_RULE;
1475 $$->append($1);
1476 $$->append($2);
1477 $$->append($3);
1480 all_or_any_predicate:
1481 row_value_constructor quantified_comparison_predicate_part_2
1483 $$ = SQL_NEW_RULE;
1484 $$->append($1);
1485 $$->append($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));
1494 $$ = SQL_NEW_RULE;
1495 $$->append(pColumnRef);
1496 $$->append($1);
1498 else
1499 YYERROR;
1503 any_all_some:
1504 SQL_TOKEN_ANY
1505 | SQL_TOKEN_ALL
1506 | SQL_TOKEN_SOME
1509 existence_test:
1510 SQL_TOKEN_EXISTS subquery
1511 {$$ = SQL_NEW_RULE;
1512 $$->append($1);
1513 $$->append($2);}
1515 unique_test:
1516 SQL_TOKEN_UNIQUE subquery
1517 {$$ = SQL_NEW_RULE;
1518 $$->append($1);
1519 $$->append($2);}
1521 subquery:
1522 '(' query_exp ')'
1523 {$$ = SQL_NEW_RULE;
1524 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
1525 $$->append($2);
1526 $$->append(newNode(")", SQL_NODE_PUNCTUATION));}
1529 /* scalar expressions */
1530 scalar_exp_commalist:
1531 select_sublist
1533 $$ = SQL_NEW_COMMALISTRULE;
1534 $$->append($1);
1536 | scalar_exp_commalist ',' select_sublist
1538 $1->append($3);
1539 $$ = $1;
1542 select_sublist:
1543 /* table_node '.' '*'
1545 $$ = SQL_NEW_RULE;
1546 $$->append($1);
1547 $$->append(newNode(".", SQL_NODE_PUNCTUATION));
1548 $$->append(newNode("*", SQL_NODE_PUNCTUATION));
1551 derived_column
1555 parameter_ref:
1556 parameter
1560 op_like:
1563 $$ = newNode("*", SQL_NODE_PUNCTUATION);
1565 | '?'
1567 $$ = newNode("?", SQL_NODE_PUNCTUATION);
1569 | op_like '*'
1571 $$ = SQL_NEW_RULE;
1572 $$->append($1);
1573 $$->append(newNode("*", SQL_NODE_PUNCTUATION));
1574 xxx_pGLOBAL_SQLPARSER->reduceLiteral($$, sal_False);
1576 | op_like '?'
1578 $$ = SQL_NEW_RULE;
1579 $$->append($1);
1580 $$->append(newNode("?", SQL_NODE_PUNCTUATION));
1581 xxx_pGLOBAL_SQLPARSER->reduceLiteral($$, sal_False);
1586 literal:
1587 /* SQL_TOKEN_STRING
1588 | */SQL_TOKEN_INT
1589 | SQL_TOKEN_REAL_NUM
1590 | SQL_TOKEN_INTNUM
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())
1598 $$ = SQL_NEW_RULE;
1599 $$->append($1);
1600 $$->append($2);
1601 xxx_pGLOBAL_SQLPARSER->reduceLiteral($$, sal_True);
1603 else
1604 YYERROR;
1606 | literal SQL_TOKEN_INT
1608 if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck())
1610 $$ = SQL_NEW_RULE;
1611 $$->append($1);
1612 $$->append($2);
1613 xxx_pGLOBAL_SQLPARSER->reduceLiteral($$, sal_True);
1615 else
1616 YYERROR;
1618 | literal SQL_TOKEN_REAL_NUM
1620 if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck())
1622 $$ = SQL_NEW_RULE;
1623 $$->append($1);
1624 $$->append($2);
1625 xxx_pGLOBAL_SQLPARSER->reduceLiteral($$, sal_True);
1627 else
1628 YYERROR;
1630 | literal SQL_TOKEN_APPROXNUM
1632 if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck())
1634 $$ = SQL_NEW_RULE;
1635 $$->append($1);
1636 $$->append($2);
1637 xxx_pGLOBAL_SQLPARSER->reduceLiteral($$, sal_True);
1639 else
1640 YYERROR;
1644 /* miscellaneous */
1645 as_clause:
1646 /* empty */ {$$ = SQL_NEW_RULE;}
1647 | SQL_TOKEN_AS column
1649 $$ = SQL_NEW_RULE;
1650 $$->append($1);
1651 $$->append($2);
1653 | column
1655 position_exp:
1656 SQL_TOKEN_POSITION '(' value_exp SQL_TOKEN_IN value_exp ')'
1658 $$ = SQL_NEW_RULE;
1659 $$->append($1);
1660 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
1661 $$->append($3);
1662 $$->append($4);
1663 $$->append($5);
1664 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
1666 | SQL_TOKEN_POSITION '(' value_exp_commalist ')'
1668 $$ = SQL_NEW_RULE;
1669 $$->append($1);
1670 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
1671 $$->append($3);
1672 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
1675 num_value_fct:
1676 position_exp
1677 | extract_exp
1678 | length_exp
1680 char_length_exp:
1681 SQL_TOKEN_CHAR_LENGTH '(' value_exp ')'
1683 $$ = SQL_NEW_RULE;
1684 $$->append($1);
1685 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
1686 $$->append($3);
1687 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
1689 | SQL_TOKEN_SQL_TOKEN_INTNUM '(' value_exp ')'
1691 $$ = SQL_NEW_RULE;
1692 $$->append($1);
1693 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
1694 $$->append($3);
1695 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
1699 octet_length_exp:
1700 SQL_TOKEN_OCTET_LENGTH '(' value_exp ')'
1702 $$ = SQL_NEW_RULE;
1703 $$->append($1);
1704 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
1705 $$->append($3);
1706 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
1709 bit_length_exp:
1710 SQL_TOKEN_BIT_LENGTH '(' value_exp ')'
1712 $$ = SQL_NEW_RULE;
1713 $$->append($1);
1714 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
1715 $$->append($3);
1716 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
1719 length_exp:
1720 char_length_exp
1722 $$ = SQL_NEW_RULE;
1723 $$->append($1);
1725 | octet_length_exp
1727 $$ = SQL_NEW_RULE;
1728 $$->append($1);
1730 | bit_length_exp
1732 $$ = SQL_NEW_RULE;
1733 $$->append($1);
1736 datetime_field:
1737 non_second_datetime_field
1739 $$ = SQL_NEW_RULE;
1740 $$->append($1);
1742 | SQL_TOKEN_SECOND
1744 $$ = SQL_NEW_RULE;
1745 $$->append($1);
1748 extract_field:
1749 time_zone_field
1750 | datetime_field
1751 | value_exp
1753 time_zone_field:
1754 SQL_TOKEN_TIMEZONE_HOUR
1756 $$ = SQL_NEW_RULE;
1757 $$->append($1);
1759 | SQL_TOKEN_TIMEZONE_MINUTE
1761 $$ = SQL_NEW_RULE;
1762 $$->append($1);
1765 extract_source:
1766 datetime_value_exp
1768 $$ = SQL_NEW_RULE;
1769 $$->append($1);
1771 /* | interval_value_exp
1773 $$ = SQL_NEW_RULE;
1774 $$->append($1);
1775 } */
1777 extract_exp:
1778 SQL_TOKEN_EXTRACT '(' extract_field SQL_TOKEN_FROM value_exp ')'
1780 $$ = SQL_NEW_RULE;
1781 $$->append($1);
1782 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
1783 $$->append($3);
1784 $$->append($4);
1785 $$->append($5);
1786 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
1789 unsigned_value_spec:
1790 general_value_spec
1791 | literal
1793 general_value_spec:
1794 parameter
1795 | SQL_TOKEN_USER
1796 | SQL_TOKEN_NULL
1797 | SQL_TOKEN_FALSE
1798 | SQL_TOKEN_TRUE
1799 | SQL_TOKEN_VALUE
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
1809 set_fct_spec:
1810 general_set_fct
1811 | '{' odbc_fct_spec '}'
1813 $$ = SQL_NEW_RULE;
1814 $$->append(newNode("{", SQL_NODE_PUNCTUATION));
1815 $$->append($2);
1816 $$->append(newNode("}", SQL_NODE_PUNCTUATION));
1818 | function_name '(' ')'
1820 $$ = SQL_NEW_RULE;
1821 $$->append($1);
1822 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
1823 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
1825 | function_name0 '(' ')'
1827 $$ = SQL_NEW_RULE;
1828 $$->append($1);
1829 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
1830 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
1832 | function_name1 '(' function_arg ')'
1834 $$ = SQL_NEW_RULE;
1835 $$->append($1);
1836 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
1837 $$->append($3);
1838 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
1840 | function_name2 '(' function_arg_commalist2 ')'
1842 $$ = SQL_NEW_RULE;
1843 $$->append($1);
1844 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
1845 $$->append($3);
1846 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
1848 | function_name3 '(' function_arg_commalist3 ')'
1850 $$ = SQL_NEW_RULE;
1851 $$->append($1);
1852 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
1853 $$->append($3);
1854 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
1856 | string_function_4Argument '(' function_arg_commalist4 ')'
1858 $$ = SQL_NEW_RULE;
1859 $$->append($1);
1860 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
1861 $$->append($3);
1862 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
1864 | function_name '(' function_args_commalist ')'
1866 $$ = SQL_NEW_RULE;
1867 $$->append($1);
1868 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
1869 $$->append($3);
1870 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
1872 | function_name12 '(' function_args_commalist ')'
1874 if ( $3->count() == 1 || $3->count() == 2 )
1876 $$ = SQL_NEW_RULE;
1877 $$->append($1);
1878 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
1879 $$->append($3);
1880 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
1882 else
1883 YYERROR;
1885 | function_name23 '(' function_args_commalist ')'
1887 if ( $3->count() == 2 || $3->count() == 3)
1889 $$ = SQL_NEW_RULE;
1890 $$->append($1);
1891 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
1892 $$->append($3);
1893 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
1895 else
1896 YYERROR;
1899 function_name0:
1900 date_function_0Argument
1901 | numeric_function_0Argument
1903 function_name1:
1904 string_function_1Argument
1905 | date_function_1Argument
1906 | numeric_function_1Argument
1908 function_name2:
1909 string_function_2Argument
1910 | numeric_function_2Argument
1912 function_name12:
1913 SQL_TOKEN_ROUND
1914 | SQL_TOKEN_WEEK
1915 | SQL_TOKEN_LOGF
1916 | SQL_TOKEN_LOG
1918 function_name23:
1919 SQL_TOKEN_LOCATE
1920 | SQL_TOKEN_DATEDIFF
1922 function_name3:
1923 string_function_3Argument
1925 function_name:
1926 string_function
1927 | date_function
1928 | numeric_function
1929 | SQL_TOKEN_NAME
1931 string_function_1Argument:
1932 SQL_TOKEN_LENGTH
1933 | SQL_TOKEN_ASCII
1934 | SQL_TOKEN_LCASE
1935 | SQL_TOKEN_LTRIM
1936 | SQL_TOKEN_RTRIM
1937 | SQL_TOKEN_SPACE
1938 | SQL_TOKEN_UCASE
1941 string_function_2Argument:
1942 SQL_TOKEN_REPEAT
1943 | SQL_TOKEN_LEFT
1944 | SQL_TOKEN_RIGHT
1946 string_function_3Argument:
1947 SQL_TOKEN_REPLACE
1949 string_function_4Argument:
1950 SQL_TOKEN_INSERT
1953 string_function:
1954 SQL_TOKEN_CHAR
1955 | SQL_TOKEN_CONCAT
1956 | SQL_TOKEN_DIFFERENCE
1957 | SQL_TOKEN_LOCATE_2
1958 | SQL_TOKEN_SOUNDEX
1960 date_function_0Argument:
1961 SQL_TOKEN_CURDATE
1962 | SQL_TOKEN_CURTIME
1963 | SQL_TOKEN_NOW
1965 date_function_1Argument:
1966 SQL_TOKEN_DAYOFWEEK
1967 | SQL_TOKEN_DAYOFMONTH
1968 | SQL_TOKEN_DAYOFYEAR
1969 | SQL_TOKEN_MONTH
1970 | SQL_TOKEN_DAYNAME
1971 | SQL_TOKEN_MONTHNAME
1972 | SQL_TOKEN_QUARTER
1973 | SQL_TOKEN_HOUR
1974 | SQL_TOKEN_MINUTE
1975 | SQL_TOKEN_SECOND
1976 | SQL_TOKEN_YEAR
1977 | SQL_TOKEN_DAY
1978 | SQL_TOKEN_TIMEVALUE
1979 | SQL_TOKEN_DATEVALUE
1982 date_function:
1983 SQL_TOKEN_TIMESTAMPADD
1984 | SQL_TOKEN_TIMESTAMPDIFF
1986 numeric_function_0Argument:
1987 SQL_TOKEN_PI
1989 numeric_function_1Argument:
1990 SQL_TOKEN_ABS
1991 | SQL_TOKEN_ACOS
1992 | SQL_TOKEN_ASIN
1993 | SQL_TOKEN_ATAN
1994 | SQL_TOKEN_CEILING
1995 | SQL_TOKEN_COS
1996 | SQL_TOKEN_COT
1997 | SQL_TOKEN_DEGREES
1998 | SQL_TOKEN_FLOOR
1999 | SQL_TOKEN_SIGN
2000 | SQL_TOKEN_SIN
2001 | SQL_TOKEN_SQRT
2002 | SQL_TOKEN_TAN
2003 | SQL_TOKEN_EXP
2004 | SQL_TOKEN_LOG10
2005 | SQL_TOKEN_LN
2006 | SQL_TOKEN_RADIANS
2007 | SQL_TOKEN_ROUNDMAGIC
2009 numeric_function_2Argument:
2010 SQL_TOKEN_ATAN2
2011 | SQL_TOKEN_MOD
2012 | SQL_TOKEN_POWER
2014 numeric_function:
2015 SQL_TOKEN_RAND
2016 | SQL_TOKEN_TRUNCATE
2019 window_function:
2020 window_function_type SQL_TOKEN_OVER window_name_or_specification
2022 $$ = SQL_NEW_RULE;
2023 $$->append($1);
2024 $$->append($2);
2025 $$->append($3);
2028 window_function_type :
2029 rank_function_type '(' ')'
2031 $$ = SQL_NEW_RULE;
2032 $$->append($1);
2033 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
2034 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
2036 | SQL_TOKEN_ROW_NUMBER '(' ')'
2038 $$ = SQL_NEW_RULE;
2039 $$->append($1);
2040 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
2041 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
2043 | general_set_fct
2044 | ntile_function
2045 | lead_or_lag_function
2046 | first_or_last_value_function
2047 | nth_value_function
2049 ntile_function :
2050 SQL_TOKEN_NTILE '(' number_of_tiles ')'
2052 $$ = SQL_NEW_RULE;
2053 $$->append($1);
2054 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
2055 $$->append($3);
2056 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
2059 dynamic_parameter_specification:
2060 parameter
2062 simple_value_specification:
2063 literal
2065 number_of_tiles :
2066 simple_value_specification
2067 | dynamic_parameter_specification
2069 opt_lead_or_lag_function:
2070 /* empty */ {$$ = SQL_NEW_RULE;}
2071 | ',' offset
2073 $$ = SQL_NEW_RULE;
2074 $$->append(newNode(",", SQL_NODE_PUNCTUATION));
2075 $$->append($2);
2077 | ',' offset ',' default_expression
2079 $$ = SQL_NEW_RULE;
2080 $$->append(newNode(",", SQL_NODE_PUNCTUATION));
2081 $$->append($2);
2082 $$->append(newNode(",", SQL_NODE_PUNCTUATION));
2083 $$->append($4);
2086 opt_null_treatment:
2087 /* empty */ {$$ = SQL_NEW_RULE;}
2088 | null_treatment
2091 lead_or_lag_function:
2092 lead_or_lag '(' lead_or_lag_extent opt_lead_or_lag_function ')' opt_null_treatment
2094 $$ = SQL_NEW_RULE;
2095 $$->append($1);
2096 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
2097 $$->append($3);
2098 $$->append($4);
2099 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
2100 $$->append($6);
2103 lead_or_lag:
2104 SQL_TOKEN_LEAD
2105 | SQL_TOKEN_LAG
2107 lead_or_lag_extent:
2108 value_exp
2110 offset:
2111 SQL_TOKEN_INTNUM
2113 default_expression:
2114 value_exp
2116 null_treatment:
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
2123 $$ = SQL_NEW_RULE;
2124 $$->append($1);
2125 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
2126 $$->append($3);
2127 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
2128 $$->append($5);
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
2139 nth_value_function:
2140 SQL_TOKEN_NTH_VALUE '(' value_exp ',' nth_row ')' opt_from_first_or_last opt_null_treatment
2142 $$ = SQL_NEW_RULE;
2143 $$->append($1);
2144 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
2145 $$->append($3);
2146 $$->append(newNode(",", SQL_NODE_PUNCTUATION));
2147 $$->append($5);
2148 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
2149 $$->append($7);
2150 $$->append($8);
2153 nth_row:
2154 simple_value_specification
2155 | dynamic_parameter_specification
2157 from_first_or_last:
2158 SQL_TOKEN_FROM SQL_TOKEN_FIRST
2160 $$ = SQL_NEW_RULE;
2161 $$->append($1);
2162 $$->append($2);
2164 | SQL_TOKEN_FROM SQL_TOKEN_LAST
2166 $$ = SQL_NEW_RULE;
2167 $$->append($1);
2168 $$->append($2);
2171 window_name:
2172 SQL_TOKEN_NAME
2174 window_name_or_specification:
2175 window_name
2176 | in_line_window_specification
2178 in_line_window_specification:
2179 window_specification
2181 opt_window_clause:
2182 /* empty */ {$$ = SQL_NEW_RULE;}
2183 | window_clause
2185 window_clause:
2186 SQL_TOKEN_WINDOW window_definition_list
2188 $$ = SQL_NEW_RULE;
2189 $$->append($1);
2190 $$->append($2);
2193 window_definition_list:
2194 window_definition_list ',' window_definition
2195 {$1->append($3);
2196 $$ = $1;}
2197 | window_definition
2198 {$$ = SQL_NEW_COMMALISTRULE;
2199 $$->append($1);}
2201 window_definition:
2202 new_window_name SQL_TOKEN_AS window_specification
2204 $$ = SQL_NEW_RULE;
2205 $$->append($1);
2206 $$->append($2);
2207 $$->append($3);
2210 new_window_name:
2211 window_name
2213 window_specification:
2214 '(' window_specification_details ')'
2216 $$ = SQL_NEW_RULE;
2217 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
2218 $$->append($2);
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
2237 opt_order_by_clause
2238 opt_window_frame_clause
2240 existing_window_name:
2241 window_name
2243 window_partition_clause:
2244 SQL_TOKEN_PARTITION SQL_TOKEN_BY window_partition_column_reference_list
2246 $$ = SQL_NEW_RULE;
2247 $$->append($1);
2248 $$->append($2);
2249 $$->append($3);
2252 window_partition_column_reference_list:
2253 window_partition_column_reference_list ',' window_partition_column_reference
2254 {$1->append($3);
2255 $$ = $1;}
2256 | window_partition_column_reference
2257 {$$ = SQL_NEW_COMMALISTRULE;
2258 $$->append($1);}
2260 window_partition_column_reference:
2261 column_ref opt_collate_clause
2263 $$ = SQL_NEW_RULE;
2264 $$->append($1);
2265 $$->append($2);
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
2275 $$ = SQL_NEW_RULE;
2276 $$->append($1);
2277 $$->append($2);
2278 $$->append($3);
2281 window_frame_units:
2282 SQL_TOKEN_ROWS
2283 | SQL_TOKEN_RANGE
2285 window_frame_extent:
2286 window_frame_start
2287 | window_frame_between
2289 window_frame_start:
2290 SQL_TOKEN_UNBOUNDED SQL_TOKEN_PRECEDING
2292 $$ = SQL_NEW_RULE;
2293 $$->append($1);
2294 $$->append($2);
2296 | window_frame_preceding
2297 | SQL_TOKEN_CURRENT SQL_TOKEN_ROW
2299 $$ = SQL_NEW_RULE;
2300 $$->append($1);
2301 $$->append($2);
2304 window_frame_preceding:
2305 unsigned_value_spec SQL_TOKEN_PRECEDING
2307 $$ = SQL_NEW_RULE;
2308 $$->append($1);
2309 $$->append($2);
2312 window_frame_between:
2313 SQL_TOKEN_BETWEEN window_frame_bound_1 SQL_TOKEN_AND window_frame_bound_2
2315 $$ = SQL_NEW_RULE;
2316 $$->append($1);
2317 $$->append($2);
2318 $$->append($3);
2319 $$->append($4);
2322 window_frame_bound_1:
2323 window_frame_bound
2325 window_frame_bound_2:
2326 window_frame_bound
2328 window_frame_bound:
2329 window_frame_start
2330 | SQL_TOKEN_UNBOUNDED SQL_TOKEN_FOLLOWING
2332 $$ = SQL_NEW_RULE;
2333 $$->append($1);
2334 $$->append($2);
2336 | window_frame_following
2338 window_frame_following:
2339 unsigned_value_spec SQL_TOKEN_FOLLOWING
2341 $$ = SQL_NEW_RULE;
2342 $$->append($1);
2343 $$->append($2);
2346 window_frame_exclusion:
2347 SQL_TOKEN_EXCLUDE SQL_TOKEN_CURRENT SQL_TOKEN_ROW
2349 $$ = SQL_NEW_RULE;
2350 $$->append($1);
2351 $$->append($2);
2352 $$->append($3);
2354 | SQL_TOKEN_EXCLUDE SQL_TOKEN_GROUP
2356 $$ = SQL_NEW_RULE;
2357 $$->append($1);
2358 $$->append($2);
2360 | SQL_TOKEN_EXCLUDE SQL_TOKEN_TIES
2362 $$ = SQL_NEW_RULE;
2363 $$->append($1);
2364 $$->append($2);
2366 | SQL_TOKEN_EXCLUDE SQL_TOKEN_NO SQL_TOKEN_OTHERS
2368 $$ = SQL_NEW_RULE;
2369 $$->append($1);
2370 $$->append($2);
2371 $$->append($3);
2374 op_parameter:
2375 {$$ = SQL_NEW_RULE;}
2376 | '?' SQL_EQUAL
2378 $$ = SQL_NEW_RULE;
2379 $$->append(newNode("?", SQL_NODE_PUNCTUATION));
2380 $$->append($2);
2383 odbc_call_spec:
2384 op_parameter SQL_TOKEN_CALL table_node op_odbc_call_parameter
2386 $$ = SQL_NEW_RULE;
2387 $$->append($1);
2388 $$->append($2);
2389 $$->append($3);
2390 $$->append($4);
2394 op_odbc_call_parameter:
2395 {$$ = SQL_NEW_RULE;}
2396 | '(' odbc_parameter_commalist ')'
2398 $$ = SQL_NEW_RULE;
2399 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
2400 $$->append($2);
2401 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
2405 odbc_parameter_commalist:
2406 odbc_parameter
2407 {$$ = SQL_NEW_COMMALISTRULE;
2408 $$->append($1);}
2409 | odbc_parameter_commalist ',' odbc_parameter
2411 $1->append($3);
2412 $$ = $1;
2415 odbc_parameter:
2416 /* empty */ {$$ = SQL_NEW_RULE;}
2417 | literal
2418 | parameter
2421 odbc_fct_spec:
2422 odbc_fct_type SQL_TOKEN_STRING
2424 $$ = SQL_NEW_RULE;
2425 $$->append($1);
2426 $$->append($2);
2428 | SQL_TOKEN_FN set_fct_spec
2430 $$ = SQL_NEW_RULE;
2431 $$->append($1);
2432 $$->append($2);
2436 odbc_fct_type:
2437 SQL_TOKEN_D
2438 | SQL_TOKEN_T
2439 | SQL_TOKEN_TS
2442 general_set_fct:
2443 set_fct_type '(' opt_all_distinct function_arg ')'
2445 $$ = SQL_NEW_RULE;
2446 $$->append($1);
2447 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
2448 $$->append($3);
2449 $$->append($4);
2450 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
2452 | SQL_TOKEN_COUNT '(' '*' ')'
2454 $$ = SQL_NEW_RULE;
2455 $$->append($1);
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 ')'
2462 $$ = SQL_NEW_RULE;
2463 $$->append($1);
2464 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
2465 $$->append($3);
2466 $$->append($4);
2467 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
2469 | ordered_set_function
2470 | array_aggregate_function
2472 set_fct_type:
2473 SQL_TOKEN_AVG
2474 | SQL_TOKEN_MAX
2475 | SQL_TOKEN_MIN
2476 | SQL_TOKEN_SUM
2477 | SQL_TOKEN_EVERY
2478 | SQL_TOKEN_ANY
2479 | SQL_TOKEN_SOME
2480 | SQL_TOKEN_STDDEV_POP
2481 | SQL_TOKEN_STDDEV_SAMP
2482 | SQL_TOKEN_VAR_SAMP
2483 | SQL_TOKEN_VAR_POP
2484 | SQL_TOKEN_COLLECT
2485 | SQL_TOKEN_FUSION
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
2496 $$ = SQL_NEW_RULE;
2497 $$->append($1);
2498 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
2499 $$->append($3);
2500 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
2501 $$->append($5);
2503 | rank_function_type '(' hypothetical_set_function_value_expression_list SQL_TOKEN_BY value_exp_commalist ')' within_group_specification
2505 $$ = SQL_NEW_RULE;
2506 $$->append($1);
2507 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
2508 $$->append($3);
2509 $$->append($4);
2510 $$->append($5);
2511 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
2512 $$->append($7);
2516 within_group_specification:
2518 $$ = SQL_NEW_RULE;
2520 | SQL_TOKEN_WITHIN SQL_TOKEN_GROUP '(' opt_order_by_clause ')'
2522 $$ = SQL_NEW_RULE;
2523 $$->append($1);
2524 $$->append($2);
2525 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
2526 $$->append($4);
2527 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
2530 hypothetical_set_function_value_expression_list:
2531 value_exp_commalist
2534 inverse_distribution_function:
2535 inverse_distribution_function_type '('inverse_distribution_function_argument ')' within_group_specification
2537 $$ = SQL_NEW_RULE;
2538 $$->append($1);
2539 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
2540 $$->append($3);
2541 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
2544 inverse_distribution_function_argument:
2545 num_value_exp
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 ')'
2555 $$ = SQL_NEW_RULE;
2556 $$->append($1);
2557 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
2558 $$->append($3);
2559 $$->append($4);
2560 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
2564 rank_function_type:
2565 SQL_TOKEN_RANK
2566 | SQL_TOKEN_DENSE_RANK
2567 | SQL_TOKEN_PERCENT_RANK
2568 | SQL_TOKEN_CUME_DIST
2570 outer_join_type:
2571 SQL_TOKEN_LEFT %prec SQL_TOKEN_LEFT
2573 $$ = SQL_NEW_RULE;
2574 $$->append($1);
2576 | SQL_TOKEN_RIGHT %prec SQL_TOKEN_RIGHT
2578 $$ = SQL_NEW_RULE;
2579 $$->append($1);
2581 | SQL_TOKEN_FULL %prec SQL_TOKEN_FULL
2583 $$ = SQL_NEW_RULE;
2584 $$->append($1);
2587 join_condition:
2588 SQL_TOKEN_ON search_condition
2590 $$ = SQL_NEW_RULE;
2591 $$->append($1);
2592 $$->append($2);
2595 join_spec:
2596 join_condition
2597 | named_columns_join
2599 join_type:
2600 /* empty */ {$$ = SQL_NEW_RULE;}
2601 | SQL_TOKEN_INNER
2603 $$ = SQL_NEW_RULE;
2604 $$->append($1);
2606 | outer_join_type
2607 | outer_join_type SQL_TOKEN_OUTER
2609 $$ = SQL_NEW_RULE;
2610 $$->append($1);
2611 $$->append($2);
2614 cross_union:
2615 table_ref SQL_TOKEN_CROSS SQL_TOKEN_JOIN table_ref
2617 $$ = SQL_NEW_RULE;
2618 $$->append($1);
2619 $$->append($2);
2620 $$->append($3);
2621 $$->append($4);
2625 qualified_join:
2626 /* wenn SQL_TOKEN_NATURAL, dann keine join_spec */
2627 table_ref SQL_TOKEN_NATURAL join_type SQL_TOKEN_JOIN table_ref
2629 $$ = SQL_NEW_RULE;
2630 $$->append($1);
2631 $$->append($2);
2632 $$->append($3);
2633 $$->append($4);
2634 $$->append($5);
2636 | table_ref join_type SQL_TOKEN_JOIN table_ref join_spec
2638 $$ = SQL_NEW_RULE;
2639 $$->append($1);
2640 $$->append($2);
2641 $$->append($3);
2642 $$->append($4);
2643 $$->append($5);
2645 | cross_union
2647 joined_table:
2648 qualified_join
2650 named_columns_join:
2651 SQL_TOKEN_USING '(' column_commalist ')'
2653 $$ = SQL_NEW_RULE;
2654 $$->append($1);
2655 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
2656 $$->append($3);
2657 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
2660 simple_table:
2661 select_statement
2662 | values_or_query_spec
2665 non_join_query_primary:
2666 simple_table
2667 | '(' non_join_query_exp ')'
2669 $$ = SQL_NEW_RULE;
2670 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
2671 $$->append($2);
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
2679 $$ = SQL_NEW_RULE;
2680 $$->append($1);
2681 $$->append($2);
2682 $$->append($3);
2683 $$->append($4);
2686 query_primary:
2687 non_join_query_primary
2689 non_join_query_exp:
2690 non_join_query_term
2691 | query_exp SQL_TOKEN_UNION all query_term
2693 $$ = SQL_NEW_RULE;
2694 $$->append($1);
2695 $$->append($2);
2696 $$->append($3);
2697 $$->append($4);
2699 | query_exp SQL_TOKEN_EXCEPT all query_term
2701 $$ = SQL_NEW_RULE;
2702 $$->append($1);
2703 $$->append($2);
2704 $$->append($3);
2705 $$->append($4);
2708 all:
2709 /* empty*/ {$$ = SQL_NEW_RULE;}
2710 | SQL_TOKEN_ALL
2712 query_exp:
2713 non_join_query_exp /*[^')']*/
2715 scalar_subquery:
2716 subquery
2718 cast_operand:
2719 value_exp
2721 cast_target:
2722 table_node
2723 | data_type
2725 cast_spec:
2726 SQL_TOKEN_CAST '(' cast_operand SQL_TOKEN_AS cast_target ')'
2728 $$ = SQL_NEW_RULE;
2729 $$->append($1);
2730 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
2731 $$->append($3);
2732 $$->append($4);
2733 $$->append($5);
2734 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
2737 value_exp_primary:
2738 unsigned_value_spec
2739 | column_ref
2740 | set_fct_spec
2741 | scalar_subquery
2742 | case_expression
2743 | window_function
2744 | '(' value_exp ')'
2746 $$ = SQL_NEW_RULE;
2747 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
2748 $$->append($2);
2749 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
2751 | cast_spec
2754 num_primary:
2755 value_exp_primary
2756 | num_value_fct
2758 factor:
2759 num_primary
2760 | '-' num_primary %prec SQL_TOKEN_UMINUS
2762 $$ = SQL_NEW_RULE;
2763 $$->append(newNode("-", SQL_NODE_PUNCTUATION));
2764 $$->append($2);
2766 | '+' num_primary %prec SQL_TOKEN_UMINUS
2768 $$ = SQL_NEW_RULE;
2769 $$->append(newNode("+", SQL_NODE_PUNCTUATION));
2770 $$->append($2);
2774 term:
2775 factor
2776 | term '*' factor
2778 $$ = SQL_NEW_RULE;
2779 $$->append($1);
2780 $$->append(newNode("*", SQL_NODE_PUNCTUATION));
2781 $$->append($3);
2783 | term '/' factor
2785 $$ = SQL_NEW_RULE;
2786 $$->append($1);
2787 $$->append(newNode("/", SQL_NODE_PUNCTUATION));
2788 $$->append($3);
2792 num_value_exp:
2793 term
2794 | num_value_exp '+' term
2796 $$ = SQL_NEW_RULE;
2797 $$->append($1);
2798 $$->append(newNode("+", SQL_NODE_PUNCTUATION));
2799 $$->append($3);
2801 | num_value_exp '-' term
2803 $$ = SQL_NEW_RULE;
2804 $$->append($1);
2805 $$->append(newNode("-", SQL_NODE_PUNCTUATION));
2806 $$->append($3);
2809 datetime_primary:
2810 /* value_exp_primary
2812 $$ = SQL_NEW_RULE;
2813 $$->append($1);
2815 |*/ datetime_value_fct
2817 $$ = SQL_NEW_RULE;
2818 $$->append($1);
2821 datetime_value_fct:
2822 SQL_TOKEN_CURRENT_DATE
2824 $$ = SQL_NEW_RULE;
2825 $$->append($1);
2827 | SQL_TOKEN_CURRENT_TIME
2829 $$ = SQL_NEW_RULE;
2830 $$->append($1);
2832 | SQL_TOKEN_CURRENT_TIMESTAMP
2834 $$ = SQL_NEW_RULE;
2835 $$->append($1);
2838 time_zone:
2839 SQL_TOKEN_AT time_zone_specifier
2841 $$ = SQL_NEW_RULE;
2842 $$->append($1);
2843 $$->append($2);
2846 time_zone_specifier:
2847 SQL_TOKEN_LOCAL
2849 $$ = SQL_NEW_RULE;
2850 $$->append($1);
2852 /* | SQL_TOKEN_TIME SQL_TOKEN_ZONE interval_value_exp
2854 $$ = SQL_NEW_RULE;
2855 $$->append($1);
2856 $$->append($2);
2857 $$->append($3);
2860 datetime_factor:
2861 datetime_primary
2863 $$ = SQL_NEW_RULE;
2864 $$->append($1);
2866 | datetime_primary time_zone
2868 $$ = SQL_NEW_RULE;
2869 $$->append($1);
2870 $$->append($2);
2873 datetime_term:
2874 datetime_factor
2876 $$ = SQL_NEW_RULE;
2877 $$->append($1);
2881 interval_term:
2882 literal
2883 | interval_term '*' factor
2885 $$ = SQL_NEW_RULE;
2886 $$->append($1);
2887 $$->append(newNode("*", SQL_NODE_PUNCTUATION));
2888 $$->append($3);
2890 | interval_term '/' factor
2892 $$ = SQL_NEW_RULE;
2893 $$->append($1);
2894 $$->append(newNode("/", SQL_NODE_PUNCTUATION));
2895 $$->append($3);
2899 datetime_value_exp:
2900 datetime_term
2902 $$ = SQL_NEW_RULE;
2903 $$->append($1);
2905 /* | interval_value_exp '+' datetime_term
2907 $$ = SQL_NEW_RULE;
2908 $$->append($1);
2909 $$->append(newNode("+", SQL_NODE_PUNCTUATION));
2910 $$->append($3);
2912 | datetime_value_exp '+' interval_term
2914 $$ = SQL_NEW_RULE;
2915 $$->append($1);
2916 $$->append(newNode("+", SQL_NODE_PUNCTUATION));
2917 $$->append($3);
2919 | datetime_value_exp '-' interval_term
2921 $$ = SQL_NEW_RULE;
2922 $$->append($1);
2923 $$->append(newNode("-", SQL_NODE_PUNCTUATION));
2924 $$->append($3);
2926 */ ;
2928 interval_value_exp:
2929 interval_term
2931 $$ = SQL_NEW_RULE;
2932 $$->append($1);
2934 | interval_value_exp '+' interval_term
2936 $$ = SQL_NEW_RULE;
2937 $$->append($1);
2938 $$->append(newNode("+", SQL_NODE_PUNCTUATION));
2939 $$->append($3);
2941 | interval_value_exp '-' interval_term
2943 $$ = SQL_NEW_RULE;
2944 $$->append($1);
2945 $$->append(newNode("-", SQL_NODE_PUNCTUATION));
2946 $$->append($3);
2948 | '(' datetime_value_exp '-' datetime_term ')' interval_qualifier
2950 $$ = SQL_NEW_RULE;
2951 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
2952 $$->append($2);
2953 $$->append(newNode("-", SQL_NODE_PUNCTUATION));
2954 $$->append($4);
2955 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
2956 $$->append($6);
2960 non_second_datetime_field:
2961 SQL_TOKEN_YEAR
2962 | SQL_TOKEN_MONTH
2963 | SQL_TOKEN_DAY
2964 | SQL_TOKEN_HOUR
2965 | SQL_TOKEN_MINUTE
2967 start_field:
2968 non_second_datetime_field opt_paren_precision
2970 $$ = SQL_NEW_RULE;
2971 $$->append($1);
2972 $$->append($2);
2975 end_field:
2976 non_second_datetime_field
2977 | SQL_TOKEN_SECOND opt_paren_precision
2979 $$ = SQL_NEW_RULE;
2980 $$->append($1);
2981 $$->append($2);
2985 single_datetime_field:
2986 non_second_datetime_field opt_paren_precision
2988 $$ = SQL_NEW_RULE;
2989 $$->append($1);
2990 $$->append($2);
2992 | SQL_TOKEN_SECOND opt_paren_precision_scale
2994 $$ = SQL_NEW_RULE;
2995 $$->append($1);
2996 $$->append($2);
3000 interval_qualifier:
3001 start_field SQL_TOKEN_TO end_field
3003 $$ = SQL_NEW_RULE;
3004 $$->append($1);
3005 $$->append($2);
3006 $$->append($3);
3008 | single_datetime_field
3011 function_arg_commalist2:
3012 function_arg ',' function_arg
3013 {$$ = SQL_NEW_COMMALISTRULE;
3014 $$->append($1);
3015 $$->append($3);}
3017 function_arg_commalist3:
3018 function_arg ',' function_arg ',' function_arg
3020 $$ = SQL_NEW_COMMALISTRULE;
3021 $$->append($1);
3022 $$->append($3);
3023 $$->append($5);
3026 function_arg_commalist4:
3027 function_arg ',' function_arg ',' function_arg ',' function_arg
3029 $$ = SQL_NEW_COMMALISTRULE;
3030 $$->append($1);
3031 $$->append($3);
3032 $$->append($5);
3033 $$->append($7);
3036 value_exp_commalist:
3037 value_exp
3038 {$$ = SQL_NEW_COMMALISTRULE;
3039 $$->append($1);}
3040 | value_exp_commalist ',' value_exp
3041 {$1->append($3);
3042 $$ = $1;}
3043 /* this rule is only valid if we check predicates */
3044 | value_exp_commalist ';' value_exp
3046 if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck())
3048 $1->append($3);
3049 $$ = $1;
3051 else
3052 YYERROR;
3055 function_arg:
3056 result
3057 | value_exp comparison value_exp
3059 $$ = SQL_NEW_RULE;
3060 $$->append($1);
3061 $$->append($2);
3062 $$->append($3);
3064 | value_exp SQL_TOKEN_USING value_exp comparison value_exp
3066 $$ = SQL_NEW_RULE;
3067 $$->append($1);
3068 $$->append($2);
3069 $$->append($3);
3070 $$->append($4);
3072 | value_exp SQL_TOKEN_BY value_exp_commalist
3074 $$ = SQL_NEW_RULE;
3075 $$->append($1);
3076 $$->append($2);
3077 $$->append($3);
3080 function_args_commalist:
3081 function_arg
3082 {$$ = SQL_NEW_COMMALISTRULE;
3083 $$->append($1);}
3084 | function_args_commalist ',' function_arg
3085 {$1->append($3);
3086 $$ = $1;}
3087 /* this rule is only valid if we check predicates */
3088 | function_args_commalist ';' function_arg
3090 if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck())
3092 $1->append($3);
3093 $$ = $1;
3095 else
3096 YYERROR;
3100 value_exp:
3101 num_value_exp /*[^')']*/
3102 | string_value_exp
3103 | datetime_value_exp
3105 $$ = SQL_NEW_RULE;
3106 $$->append($1);
3109 string_value_exp:
3110 char_value_exp
3111 /* | bit_value_exp
3113 $$ = SQL_NEW_RULE;
3114 $$->append($1);
3116 */ ;
3117 char_value_exp:
3118 char_factor
3119 | concatenation
3121 concatenation:
3122 char_value_exp '+' char_factor
3124 $$ = SQL_NEW_RULE;
3125 $$->append($1);
3126 $$->append(newNode("+", SQL_NODE_PUNCTUATION));
3127 $$->append($3);
3129 | value_exp SQL_CONCAT value_exp
3131 $$ = SQL_NEW_RULE;
3132 $$->append($1);
3133 $$->append($2);
3134 $$->append($3);
3138 char_primary:
3139 SQL_TOKEN_STRING
3140 | string_value_fct
3142 collate_clause:
3143 SQL_TOKEN_COLLATE table_node
3145 $$ = SQL_NEW_RULE;
3146 $$->append($1);
3147 $$->append($2);
3150 char_factor:
3151 char_primary
3152 | char_primary collate_clause
3154 $$ = SQL_NEW_RULE;
3155 $$->append($1);
3156 $$->append($2);
3159 string_value_fct:
3160 char_value_fct
3161 | bit_value_fct
3163 bit_value_fct:
3164 bit_substring_fct
3166 $$ = SQL_NEW_RULE;
3167 $$->append($1);
3170 bit_substring_fct:
3171 SQL_TOKEN_SUBSTRING '(' bit_value_exp SQL_TOKEN_FROM string_value_exp for_length ')'
3173 $$ = SQL_NEW_RULE;
3174 $$->append($1);
3175 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
3176 $$->append($3);
3177 $$->append($4);
3178 $$->append($5);
3179 $$->append($6);
3180 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
3183 bit_value_exp:
3184 bit_factor
3186 $$ = SQL_NEW_RULE;
3187 $$->append($1);
3191 bit_concatenation
3193 $$ = SQL_NEW_RULE;
3194 $$->append($1);
3197 bit_concatenation:
3198 bit_value_exp '+' bit_factor
3200 $$ = SQL_NEW_RULE;
3201 $$->append($1);
3202 $$->append(newNode("+", SQL_NODE_PUNCTUATION));
3203 $$->append($3);
3207 bit_factor:
3208 bit_primary
3210 $$ = SQL_NEW_RULE;
3211 $$->append($1);
3214 bit_primary:
3215 {$$ = SQL_NEW_RULE;}
3216 /* value_exp_primary
3218 $$ = SQL_NEW_RULE;
3219 $$->append($1);
3221 | string_value_fct
3223 $$ = SQL_NEW_RULE;
3224 $$->append($1);
3227 char_value_fct:
3228 char_substring_fct
3229 | fold
3230 | form_conversion
3232 $$ = SQL_NEW_RULE;
3233 $$->append($1);
3235 | char_translation
3237 $$ = SQL_NEW_RULE;
3238 $$->append($1);
3240 | trim_fct
3242 $$ = SQL_NEW_RULE;
3243 $$->append($1);
3246 for_length:
3247 {$$ = SQL_NEW_RULE;}
3248 | SQL_TOKEN_FOR value_exp
3250 $$ = SQL_NEW_RULE;
3251 $$->append($1);
3252 $$->append($2);
3255 char_substring_fct:
3256 SQL_TOKEN_SUBSTRING '(' value_exp SQL_TOKEN_FROM value_exp for_length ')'
3258 $$ = SQL_NEW_RULE;
3259 $$->append($1);
3260 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
3261 $$->append($3);
3262 $$->append($4);
3263 $$->append($5);
3264 $$->append($6);
3265 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
3267 | SQL_TOKEN_SUBSTRING '(' value_exp_commalist ')'
3269 $$ = SQL_NEW_RULE;
3270 $$->append($1);
3271 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
3272 $$->append($3);
3273 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
3276 upper_lower:
3277 SQL_TOKEN_UPPER
3278 | SQL_TOKEN_LOWER
3280 fold:
3281 upper_lower '(' value_exp ')'
3283 $$ = SQL_NEW_RULE;
3284 $$->append($1);
3285 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
3286 $$->append($3);
3287 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
3290 form_conversion:
3291 SQL_TOKEN_CONVERT '(' string_value_exp SQL_TOKEN_USING table_node ')'
3293 $$ = SQL_NEW_RULE;
3294 $$->append($1);
3295 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
3296 $$->append($3);
3297 $$->append($4);
3298 $$->append($5);
3299 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
3301 | SQL_TOKEN_CONVERT '(' cast_operand ',' cast_target ')'
3303 $$ = SQL_NEW_RULE;
3304 $$->append($1);
3305 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
3306 $$->append($3);
3307 $$->append(newNode(",", SQL_NODE_PUNCTUATION));
3308 $$->append($5);
3309 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
3312 char_translation:
3313 SQL_TOKEN_TRANSLATE '(' string_value_exp SQL_TOKEN_USING table_node ')'
3315 $$ = SQL_NEW_RULE;
3316 $$->append($1);
3317 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
3318 $$->append($3);
3319 $$->append($4);
3320 $$->append($5);
3321 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
3324 trim_fct:
3325 SQL_TOKEN_TRIM '(' trim_operands ')'
3327 $$ = SQL_NEW_RULE;
3328 $$->append($1);
3329 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
3330 $$->append($3);
3331 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
3334 trim_operands:
3335 trim_spec value_exp SQL_TOKEN_FROM value_exp
3337 $$ = SQL_NEW_RULE;
3338 $$->append($1);
3339 $$->append($2);
3340 $$->append($3);
3341 $$->append($4);
3343 | trim_spec SQL_TOKEN_FROM value_exp
3345 $$ = SQL_NEW_RULE;
3346 $$->append($1);
3347 $$->append($2);
3348 $$->append($3);
3350 | value_exp SQL_TOKEN_FROM value_exp
3352 $$ = SQL_NEW_RULE;
3353 $$->append($1);
3354 $$->append($2);
3355 $$->append($3);
3357 | SQL_TOKEN_FROM value_exp
3359 $$ = SQL_NEW_RULE;
3360 $$->append($1);
3361 $$->append($2);
3363 | value_exp
3366 trim_spec:
3367 SQL_TOKEN_BOTH
3368 | SQL_TOKEN_LEADING
3369 | SQL_TOKEN_TRAILING
3372 derived_column:
3373 value_exp as_clause
3375 $$ = SQL_NEW_RULE;
3376 $$->append($1);
3377 $$->append($2);
3380 /* Tabellenname */
3381 table_node:
3382 table_name
3383 | schema_name
3384 | catalog_name
3386 catalog_name:
3387 SQL_TOKEN_NAME '.' schema_name
3389 $$ = SQL_NEW_RULE;
3390 $$->append($1);
3391 $$->append(newNode(".", SQL_NODE_PUNCTUATION));
3392 $$->append($3);
3394 | SQL_TOKEN_NAME ':' schema_name
3396 $$ = SQL_NEW_RULE;
3397 $$->append($1);
3398 $$->append(newNode(":", SQL_NODE_PUNCTUATION));
3399 $$->append($3);
3402 schema_name:
3403 SQL_TOKEN_NAME '.' table_name
3405 $$ = SQL_NEW_RULE;
3406 $$->append($1);
3407 $$->append(newNode(".", SQL_NODE_PUNCTUATION));
3408 $$->append($3);
3412 table_name:
3413 SQL_TOKEN_NAME
3414 {$$ = SQL_NEW_RULE;
3415 $$->append($1);}
3417 /* Columns */
3418 column_ref:
3419 column
3420 {$$ = SQL_NEW_RULE;
3421 $$->append($1);}
3422 /* | table_node '.' column_val %prec '.'
3423 {$$ = SQL_NEW_RULE;
3424 $$->append($1);
3425 $$->append(newNode(".", SQL_NODE_PUNCTUATION));
3426 $$->append($3);}
3428 | SQL_TOKEN_NAME '.' column_val %prec '.'
3429 {$$ = SQL_NEW_RULE;
3430 $$->append($1);
3431 $$->append(newNode(".", SQL_NODE_PUNCTUATION));
3432 $$->append($3);
3434 | SQL_TOKEN_NAME '.' SQL_TOKEN_NAME '.' column_val %prec '.'
3435 {$$ = SQL_NEW_RULE;
3436 $$->append($1);
3437 $$->append(newNode(".", SQL_NODE_PUNCTUATION));
3438 $$->append($3);
3439 $$->append(newNode(".", SQL_NODE_PUNCTUATION));
3440 $$->append($5);}
3441 | SQL_TOKEN_NAME '.' SQL_TOKEN_NAME '.' SQL_TOKEN_NAME '.' column_val %prec '.'
3442 {$$ = SQL_NEW_RULE;
3443 $$->append($1);
3444 $$->append(newNode(".", SQL_NODE_PUNCTUATION));
3445 $$->append($3);
3446 $$->append(newNode(".", SQL_NODE_PUNCTUATION));
3447 $$->append($5);
3448 $$->append(newNode(".", SQL_NODE_PUNCTUATION));
3449 $$->append($7);
3451 | SQL_TOKEN_NAME ':' SQL_TOKEN_NAME '.' SQL_TOKEN_NAME '.' column_val %prec '.'
3452 {$$ = SQL_NEW_RULE;
3453 $$->append($1);
3454 $$->append(newNode(":", SQL_NODE_PUNCTUATION));
3455 $$->append($3);
3456 $$->append(newNode(".", SQL_NODE_PUNCTUATION));
3457 $$->append($5);
3458 $$->append(newNode(".", SQL_NODE_PUNCTUATION));
3459 $$->append($7);
3461 /* | SQL_TOKEN_NAME ';' SQL_TOKEN_NAME '.' SQL_TOKEN_NAME '.' column_val
3462 {$$ = SQL_NEW_RULE;
3463 $$->append($1);
3464 $$->append(newNode(";", SQL_NODE_PUNCTUATION));
3465 $$->append($3);
3466 $$->append(newNode(".", SQL_NODE_PUNCTUATION));
3467 $$->append($5);
3468 $$->append(newNode(".", SQL_NODE_PUNCTUATION));
3469 $$->append($7);
3471 */ ;
3473 /* data types */
3474 column_val:
3475 column
3476 {$$ = SQL_NEW_RULE;
3477 $$->append($1);}
3478 | '*'
3480 $$ = SQL_NEW_RULE;
3481 $$->append(newNode("*", SQL_NODE_PUNCTUATION));
3484 data_type:
3485 predefined_type
3487 opt_char_set_spec:
3488 {$$ = SQL_NEW_RULE;}
3489 | SQL_TOKEN_CHARACTER SQL_TOKEN_SET SQL_TOKEN_NAME
3491 $$ = SQL_NEW_RULE;
3492 $$->append($1);
3493 $$->append($2);
3494 $$->append($3);
3497 opt_collate_clause:
3498 {$$ = SQL_NEW_RULE;}
3499 | collate_clause
3501 predefined_type:
3502 character_string_type opt_char_set_spec opt_collate_clause
3504 $$ = SQL_NEW_RULE;
3505 $$->append($1);
3506 $$->append($2);
3507 $$->append($3);
3509 | national_character_string_type opt_collate_clause
3511 $$ = SQL_NEW_RULE;
3512 $$->append($1);
3513 $$->append($2);
3515 | binary_string_type
3516 | numeric_type
3517 | boolean_type
3518 | datetime_type
3519 | interval_type
3521 character_string_type:
3522 SQL_TOKEN_CHARACTER opt_paren_precision
3524 $$ = SQL_NEW_RULE;
3525 $$->append($1);
3526 $$->append($2);
3528 | SQL_TOKEN_CHAR opt_paren_precision
3530 $$ = SQL_NEW_RULE;
3531 $$->append($1);
3532 $$->append($2);
3534 | SQL_TOKEN_CHARACTER SQL_TOKEN_VARYING paren_char_length
3536 $$ = SQL_NEW_RULE;
3537 $$->append($1);
3538 $$->append($2);
3539 $$->append($3);
3541 | SQL_TOKEN_CHAR SQL_TOKEN_VARYING paren_char_length
3543 $$ = SQL_NEW_RULE;
3544 $$->append($1);
3545 $$->append($2);
3546 $$->append($3);
3548 | SQL_TOKEN_VARCHAR paren_char_length
3550 $$ = SQL_NEW_RULE;
3551 $$->append($1);
3552 $$->append($2);
3554 | character_large_object_type
3556 opt_paren_precision:
3557 {$$ = SQL_NEW_RULE;}
3558 | paren_char_length
3560 paren_char_length:
3561 '(' SQL_TOKEN_INTNUM ')'
3563 $$ = SQL_NEW_RULE;
3564 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
3565 $$->append($2);
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 ')'
3576 $$ = SQL_NEW_RULE;
3577 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
3578 $$->append($2);
3579 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
3583 large_object_length:
3584 SQL_TOKEN_INTNUM opt_multiplier
3586 $$ = SQL_NEW_RULE;
3587 $$->append($1);
3588 $$->append($2);
3591 opt_multiplier:
3592 {$$ = SQL_NEW_RULE;}
3593 | 'K'
3595 $$ = SQL_NEW_RULE;
3596 $$->append(newNode("K", SQL_NODE_PUNCTUATION));
3598 | 'M'
3600 $$ = SQL_NEW_RULE;
3601 $$->append(newNode("M", SQL_NODE_PUNCTUATION));
3603 | 'G'
3605 $$ = SQL_NEW_RULE;
3606 $$->append(newNode("G", SQL_NODE_PUNCTUATION));
3608 | 'T'
3610 $$ = SQL_NEW_RULE;
3611 $$->append(newNode("T", SQL_NODE_PUNCTUATION));
3613 | 'P'
3615 $$ = SQL_NEW_RULE;
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
3622 $$ = SQL_NEW_RULE;
3623 $$->append($1);
3624 $$->append($2);
3625 $$->append($3);
3626 $$->append($4);
3628 | SQL_TOKEN_CHAR SQL_TOKEN_LARGE SQL_TOKEN_OBJECT opt_paren_char_large_length
3630 $$ = SQL_NEW_RULE;
3631 $$->append($1);
3632 $$->append($2);
3633 $$->append($3);
3634 $$->append($4);
3636 | SQL_TOKEN_CLOB opt_paren_char_large_length
3638 $$ = SQL_NEW_RULE;
3639 $$->append($1);
3640 $$->append($2);
3643 national_character_string_type:
3644 SQL_TOKEN_NATIONAL SQL_TOKEN_CHARACTER opt_paren_precision
3646 $$ = SQL_NEW_RULE;
3647 $$->append($1);
3648 $$->append($2);
3649 $$->append($3);
3651 | SQL_TOKEN_NATIONAL SQL_TOKEN_CHAR opt_paren_precision
3653 $$ = SQL_NEW_RULE;
3654 $$->append($1);
3655 $$->append($2);
3656 $$->append($3);
3658 | SQL_TOKEN_NCHAR opt_paren_precision
3660 $$ = SQL_NEW_RULE;
3661 $$->append($1);
3662 $$->append($2);
3664 | SQL_TOKEN_NATIONAL SQL_TOKEN_CHARACTER SQL_TOKEN_VARYING paren_char_length
3666 $$ = SQL_NEW_RULE;
3667 $$->append($1);
3668 $$->append($2);
3669 $$->append($3);
3670 $$->append($4);
3672 | SQL_TOKEN_NATIONAL SQL_TOKEN_CHAR SQL_TOKEN_VARYING paren_char_length
3674 $$ = SQL_NEW_RULE;
3675 $$->append($1);
3676 $$->append($2);
3677 $$->append($3);
3678 $$->append($4);
3680 | SQL_TOKEN_NCHAR SQL_TOKEN_VARYING paren_char_length
3682 $$ = SQL_NEW_RULE;
3683 $$->append($1);
3684 $$->append($2);
3685 $$->append($3);
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
3692 $$ = SQL_NEW_RULE;
3693 $$->append($1);
3694 $$->append($2);
3695 $$->append($3);
3696 $$->append($4);
3697 $$->append($5);
3699 | SQL_TOKEN_NCHAR SQL_TOKEN_LARGE SQL_TOKEN_OBJECT opt_paren_char_large_length
3701 $$ = SQL_NEW_RULE;
3702 $$->append($1);
3703 $$->append($2);
3704 $$->append($3);
3705 $$->append($4);
3707 | SQL_TOKEN_NCLOB opt_paren_char_large_length
3709 $$ = SQL_NEW_RULE;
3710 $$->append($1);
3711 $$->append($2);
3714 binary_string_type:
3715 SQL_TOKEN_BINARY opt_paren_precision
3717 $$ = SQL_NEW_RULE;
3718 $$->append($1);
3719 $$->append($2);
3721 | SQL_TOKEN_BINARY SQL_TOKEN_VARYING paren_char_length
3723 $$ = SQL_NEW_RULE;
3724 $$->append($1);
3725 $$->append($2);
3726 $$->append($3);
3728 | SQL_TOKEN_VARBINARY paren_char_length
3730 $$ = SQL_NEW_RULE;
3731 $$->append($1);
3732 $$->append($2);
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
3739 $$ = SQL_NEW_RULE;
3740 $$->append($1);
3741 $$->append($2);
3742 $$->append($3);
3743 $$->append($4);
3745 | SQL_TOKEN_BLOB opt_paren_char_large_length
3747 $$ = SQL_NEW_RULE;
3748 $$->append($1);
3749 $$->append($2);
3752 numeric_type:
3753 exact_numeric_type
3754 | approximate_numeric_type
3756 opt_paren_precision_scale:
3757 {$$ = SQL_NEW_RULE;}
3758 | '(' SQL_TOKEN_INTNUM ')'
3760 $$ = SQL_NEW_RULE;
3761 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
3762 $$->append($2);
3763 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
3765 | '(' SQL_TOKEN_INTNUM ',' SQL_TOKEN_INTNUM ')'
3767 $$ = SQL_NEW_RULE;
3768 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
3769 $$->append($2);
3770 $$->append(newNode(",", SQL_NODE_PUNCTUATION));
3771 $$->append($4);
3772 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
3775 exact_numeric_type:
3776 SQL_TOKEN_NUMERIC opt_paren_precision_scale
3778 $$ = SQL_NEW_RULE;
3779 $$->append($1);
3780 $$->append($2);
3782 | SQL_TOKEN_DECIMAL opt_paren_precision_scale
3784 $$ = SQL_NEW_RULE;
3785 $$->append($1);
3786 $$->append($2);
3788 | SQL_TOKEN_DEC opt_paren_precision_scale
3790 $$ = SQL_NEW_RULE;
3791 $$->append($1);
3792 $$->append($2);
3794 | SQL_TOKEN_SMALLINT
3795 | SQL_TOKEN_INTEGER
3796 | SQL_TOKEN_INT
3797 | SQL_TOKEN_BIGINT
3799 approximate_numeric_type:
3800 SQL_TOKEN_FLOAT '(' SQL_TOKEN_INTNUM ')'
3802 $$ = SQL_NEW_RULE;
3803 $$->append($1);
3804 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
3805 $$->append($3);
3806 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
3808 | SQL_TOKEN_FLOAT
3809 | SQL_TOKEN_REAL
3810 | SQL_TOKEN_DOUBLE
3811 | SQL_TOKEN_DOUBLE SQL_TOKEN_PRECISION
3813 $$ = SQL_NEW_RULE;
3814 $$->append($1);
3815 $$->append($2);
3818 boolean_type:
3819 SQL_TOKEN_BOOLEAN
3821 datetime_type:
3822 SQL_TOKEN_DATE
3823 | SQL_TOKEN_TIME opt_paren_precision opt_with_or_without_time_zone
3825 $$ = SQL_NEW_RULE;
3826 $$->append($1);
3827 $$->append($2);
3828 $$->append($3);
3830 | SQL_TOKEN_TIMESTAMP opt_paren_precision opt_with_or_without_time_zone
3832 $$ = SQL_NEW_RULE;
3833 $$->append($1);
3834 $$->append($2);
3835 $$->append($3);
3838 opt_with_or_without_time_zone:
3839 {$$ = SQL_NEW_RULE;}
3840 | SQL_TOKEN_WITH SQL_TOKEN_TIME SQL_TOKEN_ZONE
3842 $$ = SQL_NEW_RULE;
3843 $$->append($1);
3844 $$->append($2);
3845 $$->append($3);
3847 | SQL_TOKEN_WITHOUT SQL_TOKEN_TIME SQL_TOKEN_ZONE
3849 $$ = SQL_NEW_RULE;
3850 $$->append($1);
3851 $$->append($2);
3852 $$->append($3);
3855 interval_type:
3856 SQL_TOKEN_INTERVAL interval_qualifier
3858 $$ = SQL_NEW_RULE;
3859 $$->append($1);
3860 $$->append($2);
3863 /* the various things you can name */
3865 column:
3866 SQL_TOKEN_NAME
3867 | SQL_TOKEN_POSITION
3869 sal_uInt32 nNod = $$->getRuleID();
3870 delete $$;
3871 $$ = newNode(xxx_pGLOBAL_SQLPARSER->TokenIDToStr(nNod), SQL_NODE_NAME);
3873 | SQL_TOKEN_CHAR_LENGTH
3875 sal_uInt32 nNod = $$->getRuleID();
3876 delete $$;
3877 $$ = newNode(xxx_pGLOBAL_SQLPARSER->TokenIDToStr(nNod), SQL_NODE_NAME);
3879 | SQL_TOKEN_EXTRACT
3881 sal_uInt32 nNod = $$->getRuleID();
3882 delete $$;
3883 $$ = newNode(xxx_pGLOBAL_SQLPARSER->TokenIDToStr(nNod), SQL_NODE_NAME);
3886 case_expression:
3887 case_abbreviation
3888 | case_specification
3890 case_abbreviation:
3891 SQL_TOKEN_NULLIF '(' value_exp_commalist ')'
3893 $$ = SQL_NEW_RULE;
3894 $$->append($1);
3895 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
3896 $$->append($3);
3897 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
3899 | SQL_TOKEN_COALESCE '(' value_exp ')'
3901 $$ = SQL_NEW_RULE;
3902 $$->append($1);
3903 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
3904 $$->append($3);
3905 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
3907 | SQL_TOKEN_COALESCE '(' value_exp_commalist ')'
3909 $$ = SQL_NEW_RULE;
3910 $$->append($1);
3911 $$->append(newNode("(", SQL_NODE_PUNCTUATION));
3912 $$->append($3);
3913 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
3916 case_specification:
3917 simple_case
3918 | searched_case
3920 simple_case:
3921 SQL_TOKEN_CASE case_operand simple_when_clause_list else_clause SQL_TOKEN_END
3923 $$ = SQL_NEW_RULE;
3924 $$->append($1);
3925 $$->append($2);
3926 $$->append($3);
3927 $$->append($4);
3928 $$->append($5);
3931 searched_case:
3932 SQL_TOKEN_CASE searched_when_clause_list else_clause SQL_TOKEN_END
3934 $$ = SQL_NEW_RULE;
3935 $$->append($1);
3936 $$->append($2);
3937 $$->append($3);
3938 $$->append($4);
3941 simple_when_clause_list:
3942 simple_when_clause
3944 $$ = SQL_NEW_LISTRULE;
3945 $$->append($1);
3947 | searched_when_clause_list simple_when_clause
3949 $1->append($2);
3950 $$ = $1;
3953 simple_when_clause:
3954 SQL_TOKEN_WHEN when_operand_list SQL_TOKEN_THEN result
3956 $$ = SQL_NEW_RULE;
3957 $$->append($1);
3958 $$->append($2);
3959 $$->append($3);
3960 $$->append($4);
3963 when_operand_list:
3964 when_operand
3965 {$$ = SQL_NEW_COMMALISTRULE;
3966 $$->append($1);}
3967 | when_operand_list ',' when_operand
3968 {$1->append($3);
3969 $$ = $1;}
3971 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;
3983 $$->append($1);
3985 | searched_when_clause_list searched_when_clause
3987 $1->append($2);
3988 $$ = $1;
3991 searched_when_clause:
3992 SQL_TOKEN_WHEN search_condition SQL_TOKEN_THEN result
3994 $$ = SQL_NEW_RULE;
3995 $$->append($1);
3996 $$->append($2);
3997 $$->append($3);
3998 $$->append($4);
4001 else_clause:
4002 {$$ = SQL_NEW_RULE;}
4003 | SQL_TOKEN_ELSE result
4005 $$ = SQL_NEW_RULE;
4006 $$->append($1);
4007 $$->append($2);
4010 result:
4011 result_expression
4013 result_expression:
4014 value_exp
4016 case_operand:
4017 row_value_constructor_elem
4020 cursor: SQL_TOKEN_NAME
4021 {$$ = SQL_NEW_RULE;
4022 $$->append($1);}
4025 /***
4026 module: SQL_TOKEN_NAME
4027 {$$ = SQL_NEW_RULE;
4028 $$->append($1);}
4030 ***/
4032 parameter:
4033 ':' SQL_TOKEN_NAME
4034 {$$ = SQL_NEW_RULE;
4035 $$->append(newNode(":", SQL_NODE_PUNCTUATION));
4036 $$->append($2);}
4037 | '?'
4038 {$$ = SQL_NEW_RULE; // test
4039 $$->append(newNode("?", SQL_NODE_PUNCTUATION));}
4040 | '[' SQL_TOKEN_NAME ']'
4041 {$$ = SQL_NEW_RULE;
4042 $$->append(newNode("[", SQL_NODE_PUNCTUATION));
4043 $$->append($2);
4044 $$->append(newNode("]", SQL_NODE_PUNCTUATION));}
4047 /***
4048 procedure: SQL_TOKEN_NAME
4049 {$$ = SQL_NEW_RULE;
4050 $$->append($1);}
4052 ***/
4054 range_variable:
4055 {$$ = SQL_NEW_RULE;}
4056 | opt_as SQL_TOKEN_NAME
4057 {$$ = SQL_NEW_RULE;
4058 $$->append($1);
4059 $$->append($2);
4063 user: SQL_TOKEN_NAME
4066 /* PREDICATECHECK RULES */
4067 sql:
4068 search_condition /* checking predicats */
4070 if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck()) // sql: rule 1
4072 $$ = $1;
4073 if ( SQL_ISRULE($$,search_condition) )
4075 $$->insert(0,newNode("(", SQL_NODE_PUNCTUATION));
4076 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
4079 else
4080 YYERROR;
4082 | '(' sql ')' /* checking predicats */
4084 trigger_definition:
4085 SQL_TOKEN_CREATE SQL_TOKEN_TRIGGER trigger_name trigger_action_time trigger_event SQL_TOKEN_ON table_name op_referencing triggered_action
4087 $$ = SQL_NEW_RULE;
4088 $$->append($1);
4089 $$->append($2);
4090 $$->append($3);
4091 $$->append($4);
4092 $$->append($5);
4093 $$->append($6);
4094 $$->append($7);
4095 $$->append($8);
4096 $$->append($9);
4099 op_referencing:
4101 $$ = SQL_NEW_RULE;
4103 | SQL_TOKEN_REFERENCING transition_table_or_variable_list
4105 $$ = SQL_NEW_RULE;
4106 $$->append($1);
4107 $$->append($2);
4110 trigger_action_time:
4111 SQL_TOKEN_BEFORE
4112 | SQL_TOKEN_AFTER
4113 | SQL_TOKEN_INSTEAD SQL_TOKEN_OF
4115 $$ = SQL_NEW_RULE;
4116 $$->append($1);
4117 $$->append($2);
4120 trigger_event:
4121 SQL_TOKEN_INSERT
4122 | SQL_TOKEN_DELETE
4123 | SQL_TOKEN_UPDATE op_trigger_columnlist
4125 $$ = SQL_NEW_RULE;
4126 $$->append($1);
4127 $$->append($2);
4130 op_trigger_columnlist:
4132 $$ = SQL_NEW_RULE;
4134 | SQL_TOKEN_OF trigger_column_list
4136 $$ = SQL_NEW_RULE;
4137 $$->append($1);
4138 $$->append($2);
4141 trigger_column_list:
4142 column_commalist
4144 triggered_action:
4145 op_triggered_action_for triggered_when_clause triggered_SQL_statement
4147 $$ = SQL_NEW_RULE;
4148 $$->append($1);
4149 $$->append($2);
4150 $$->append($3);
4153 op_triggered_action_for:
4155 $$ = SQL_NEW_RULE;
4157 | SQL_TOKEN_FOR SQL_TOKEN_EACH trigger_for
4159 $$ = SQL_NEW_RULE;
4160 $$->append($1);
4161 $$->append($2);
4162 $$->append($3);
4165 trigger_for:
4166 SQL_TOKEN_ROW
4167 | SQL_TOKEN_STATEMENT
4169 triggered_when_clause:
4171 $$ = SQL_NEW_RULE;
4173 | SQL_TOKEN_WHEN parenthesized_boolean_value_expression
4175 $$ = SQL_NEW_RULE;
4176 $$->append($1);
4177 $$->append($2);
4180 triggered_SQL_statement:
4181 SQL_procedure_statement
4182 | SQL_TOKEN_BEGIN SQL_TOKEN_ATOMIC SQL_procedure_statement_list ';' SQL_TOKEN_END
4184 $$ = SQL_NEW_RULE;
4185 $$->append($1);
4186 $$->append($2);
4187 $$->append($3);
4188 $$->append(newNode(";", SQL_NODE_PUNCTUATION));
4189 $$->append($5);
4192 SQL_procedure_statement_list:
4193 SQL_procedure_statement
4195 $$ = SQL_NEW_LISTRULE;
4196 $$->append($1);
4198 | SQL_procedure_statement_list ';' SQL_procedure_statement
4200 $1->append($3);
4201 $$ = $1;
4204 SQL_procedure_statement:
4208 transition_table_or_variable_list:
4209 transition_table_or_variable
4211 $$ = SQL_NEW_LISTRULE;
4212 $$->append($1);
4214 | transition_table_or_variable_list transition_table_or_variable
4216 $1->append($2);
4217 $$ = $1;
4221 transition_table_or_variable:
4222 SQL_TOKEN_OLD opt_row opt_as old_transition_variable_name
4224 $$ = SQL_NEW_RULE;
4225 $$->append($1);
4226 $$->append($2);
4227 $$->append($3);
4228 $$->append($4);
4230 | SQL_TOKEN_NEW opt_row opt_as new_transition_variable_name
4232 $$ = SQL_NEW_RULE;
4233 $$->append($1);
4234 $$->append($2);
4235 $$->append($3);
4236 $$->append($4);
4238 | SQL_TOKEN_OLD SQL_TOKEN_TABLE opt_as old_transition_table_name
4240 $$ = SQL_NEW_RULE;
4241 $$->append($1);
4242 $$->append($2);
4243 $$->append($3);
4244 $$->append($4);
4246 | SQL_TOKEN_NEW SQL_TOKEN_TABLE opt_as new_transition_table_name
4248 $$ = SQL_NEW_RULE;
4249 $$->append($1);
4250 $$->append($2);
4251 $$->append($3);
4252 $$->append($4);
4255 old_transition_table_name:
4256 transition_table_name
4258 new_transition_table_name:
4259 transition_table_name
4261 transition_table_name:
4262 SQL_TOKEN_NAME
4264 old_transition_variable_name:
4265 SQL_TOKEN_NAME
4267 new_transition_variable_name:
4268 SQL_TOKEN_NAME
4270 trigger_name:
4271 SQL_TOKEN_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
4318 OUString aMsg;
4319 switch (_eCode)
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;
4333 default:
4334 OSL_FAIL( "OParseContext::getErrorMessage: unknown error code!" );
4335 break;
4337 return aMsg;
4341 OString OParseContext::getIntlKeywordAscii(InternationalKeyCode _eKey) const
4343 OString aKeyword;
4344 switch (_eKey)
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;
4371 default:
4372 OSL_FAIL( "OParseContext::getIntlKeywordAscii: unknown key!" );
4373 break;
4375 return aKeyword;
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];
4399 return KEY_NONE;
4403 static Locale& impl_getLocaleInstance( )
4405 static Locale s_aLocale( "en", "US", "" );
4406 return s_aLocale;
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
4425 // Member-Variable.
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);
4446 else
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 ']'
4461 if (wasEscape)
4463 wasEscape=false;
4464 continue;
4466 if (c == cEscape)
4468 wasEscape=true;
4469 continue;
4471 int match = -1;
4472 if (c == sSearch[0])
4473 match=0;
4474 else if (c == sSearch[1])
4475 match=1;
4477 if (match != -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)
4519 return rQuery;
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)
4530 if (bComment2)
4532 if ((i+1) < nQueryLen)
4534 if (pCopy[i]=='*' && pCopy[i+1]=='/')
4536 bComment2 = false;
4537 ++i;
4540 else
4542 // comment can't close anymore, actually an error, but..
4544 continue;
4546 if (pCopy[i] == '\n')
4547 bComment = false;
4548 else if (!bComment)
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]=='/'))
4557 bComment = true;
4558 else if ((pCopy[i]=='/' && pCopy[i+1]=='*'))
4559 bComment2 = true;
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());
4576 // must be reset
4577 setParser(this);
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;
4587 // SQLyypvt = NULL;
4588 m_pParseTree = NULL;
4589 m_sErrorMessage = "";
4591 // start parsing
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();
4604 return NULL;
4606 else
4608 (*s_pGarbageCollector)->clear();
4610 // return result:
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)
4622 OString aStr;
4623 if (pContext)
4625 IParseContext::InternationalKeyCode eKeyCode = IParseContext::KEY_NONE;
4626 switch( nTokenID )
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);
4647 if (aStr.isEmpty())
4649 aStr = yytname[YYTRANSLATE(nTokenID)];
4650 if(aStr.startsWith("SQL_TOKEN_"))
4651 aStr = aStr.copy(10);
4652 switch( nTokenID )
4654 case SQL_TOKEN_OJ:
4655 case SQL_TOKEN_TS:
4656 case SQL_TOKEN_T:
4657 case SQL_TOKEN_D:
4658 aStr = aStr.toAsciiLowerCase();
4661 return aStr;
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]);
4670 #endif
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])
4681 return i;
4684 // Not found
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;
4701 else
4702 return i->second;
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));
4718 else
4719 pComp = new OSQLInternalNode("", SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::comparison_predicate));
4721 pComp->append(pColumnRef);
4722 pComp->append(pCompare);
4723 pComp->append(pLiteral);
4724 if ( pLiteral2 )
4726 pComp->append(new OSQLInternalNode("", SQL_NODE_KEYWORD,SQL_TOKEN_AND));
4727 pComp->append(pLiteral2);
4729 pAppend->append(pComp);
4730 return 1;
4733 sal_Int16 OSQLParser::buildStringNodes(OSQLParseNode*& pLiteral)
4735 if(!pLiteral)
4736 return 1;
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);
4748 delete pLiteral;
4749 pLiteral = NULL;
4750 return 1;
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);
4761 return 0;
4763 return 1;
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());
4780 if (bAppendBlank)
4782 aValue.appendAscii(" ");
4785 aValue.append(pLiteral->getChild(1)->getTokenValue());
4787 pLiteral = new OSQLInternalNode(aValue.makeStringAndClear(),SQL_NODE_STRING);
4788 delete pTemp;
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);
4800 if(nPos1 != -1)
4802 OUString sFirst = sStr.copy(0,nPos1);
4803 sal_Int32 nPos2 = sStr.indexOf(sSQL_TOKEN,nPos1+1);
4804 if(nPos2 != -1)
4806 OUString sSecond = sStr.copy(nPos1+sSQL_TOKEN.getLength(),nPos2-nPos1-sSQL_TOKEN.getLength());
4807 sFirst += sSecond;
4808 sFirst += sStr.copy(nPos2+sSQL_TOKEN.getLength());
4810 else
4811 sFirst += sStr.copy(nPos1+sSQL_TOKEN.getLength());
4813 m_sErrorMessage = sFirst;
4815 else
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)
4834 #endif