3 //--------------------------------------------------------------------------
5 // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7 // Copyright 2000, 2010 Oracle and/or its affiliates.
9 // OpenOffice.org - a multi-platform office productivity suite
11 // This file is part of OpenOffice.org.
13 // OpenOffice.org is free software: you can redistribute it and/or modify
14 // it under the terms of the GNU Lesser General Public License version 3
15 // only, as published by the Free Software Foundation.
17 // OpenOffice.org is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU Lesser General Public License version 3 for more details
21 // (a copy is included in the LICENSE file that accompanied this code).
23 // You should have received a copy of the GNU Lesser General Public License
24 // version 3 along with OpenOffice.org. If not, see
25 // <http://www.openoffice.org/license.html>
26 // for a copy of the LGPLv3 License.
28 //--------------------------------------------------------------------------
33 #ifndef _CONNECTIVITY_SQLNODE_HXX
34 #include <connectivity/sqlnode.hxx>
36 #ifndef _CONNECTIVITY_SQLPARSE_HXX
37 #include <connectivity/sqlparse.hxx>
39 #ifndef _CONNECTIVITY_SQLINTERNALNODE_HXX
40 #include <internalnode.hxx>
42 #ifndef _COM_SUN_STAR_LANG_LOCALE_HPP_
43 #include <com/sun/star/lang/Locale.hpp>
45 #ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
46 #include <com/sun/star/sdbc/DataType.hpp>
48 #ifndef _COM_SUN_STAR_UTIL_DATE_HPP_
49 #include <com/sun/star/util/Date.hpp>
51 #ifndef _COM_SUN_STAR_UTIL_DATETIME_HPP_
52 #include <com/sun/star/util/DateTime.hpp>
54 #ifndef _COM_SUN_STAR_UTIL_TIME_HPP_
55 #include <com/sun/star/util/Time.hpp>
57 #ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTER_HPP_
58 #include <com/sun/star/util/XNumberFormatter.hpp>
60 #ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATSSUPPLIER_HPP_
61 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
63 #ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATS_HPP_
64 #include <com/sun/star/util/XNumberFormats.hpp>
66 #ifndef _COM_SUN_STAR_UTIL_NUMBERFORMAT_HPP_
67 #include <com/sun/star/util/NumberFormat.hpp>
69 #ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTYPES_HPP_
70 #include <com/sun/star/util/XNumberFormatTypes.hpp>
72 #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
73 #include <com/sun/star/beans/XPropertySet.hpp>
75 #ifndef _COM_SUN_STAR_I18N_KPARSETYPE_HPP_
76 #include <com/sun/star/i18n/KParseType.hpp>
78 #ifndef _COM_SUN_STAR_I18N_KPARSETOKENS_HPP_
79 #include <com/sun/star/i18n/KParseTokens.hpp>
81 #ifndef _CONNECTIVITY_SQLSCAN_HXX
82 #include "sqlscan.hxx"
84 #ifndef _OSL_DIAGNOSE_H_
85 #include <osl/diagnose.h>
87 #ifndef _DBHELPER_DBCONVERSION_HXX_
88 #include "connectivity/dbconversion.hxx"
90 #include <rtl/ustrbuf.hxx>
91 #include <sal/macros.h>
93 #if defined __SUNPRO_CC
95 #elif defined _MSC_VER
96 #pragma warning(push, 1)
97 #pragma warning(disable:4273 4701 4706)
100 static ::rtl
::OUString aEmptyString
;
102 static connectivity
::OSQLInternalNode
* newNode
(const sal_Char
* pNewValue
,
103 const connectivity
::SQLNodeType eNodeType
,
104 const sal_uInt32 nNodeID
= 0)
106 return new connectivity
::OSQLInternalNode
(pNewValue
, eNodeType
, nNodeID
);
109 static connectivity
::OSQLInternalNode
* newNode
(const ::rtl
::OString
& _NewValue
,
110 const connectivity
::SQLNodeType eNodeType
,
111 const sal_uInt32 nNodeID
= 0)
113 return new connectivity
::OSQLInternalNode
(_NewValue
, eNodeType
, nNodeID
);
116 static connectivity
::OSQLInternalNode
* newNode
(const ::rtl
::OUString
& _NewValue
,
117 const connectivity
::SQLNodeType eNodeType
,
118 const sal_uInt32 nNodeID
= 0)
120 return new connectivity
::OSQLInternalNode
(_NewValue
, eNodeType
, nNodeID
);
124 // yyi ist die interne Nr. der Regel, die gerade reduziert wird.
125 // Ueber die Mapping-Tabelle yyrmap wird daraus eine externe Regel-Nr.
126 #define SQL_NEW_RULE newNode(aEmptyString, SQL_NODE_RULE, yyr1[yyn])
127 #define SQL_NEW_LISTRULE newNode(aEmptyString, SQL_NODE_LISTRULE, yyr1[yyn])
128 #define SQL_NEW_COMMALISTRULE newNode(aEmptyString, SQL_NODE_COMMALISTRULE, yyr1[yyn])
131 connectivity::OSQLParser
* xxx_pGLOBAL_SQLPARSER
;
133 #if !(defined MACOSX && defined PPC)
134 #define YYERROR_VERBOSE
137 #define SQLyyerror(s) \
139 xxx_pGLOBAL_SQLPARSER
->error(s
); \
142 using namespace connectivity
;
143 #define SQLyylex xxx_pGLOBAL_SQLPARSER->SQLlex
145 /* symbolic tokens */
148 connectivity
::OSQLParseNode
* pParseNode
;
150 %type
<pParseNode
> '(' ')' ',' ':' ';' '?' '[' ']' '{' '}' '.' 'K' 'M' 'G' 'T' 'P'
152 %token
<pParseNode
> SQL_TOKEN_STRING SQL_TOKEN_ACCESS_DATE SQL_TOKEN_INT SQL_TOKEN_REAL_NUM
153 %token
<pParseNode
> SQL_TOKEN_INTNUM SQL_TOKEN_APPROXNUM SQL_TOKEN_NOT SQL_TOKEN_NAME
156 %nonassoc
<pParseNode
> SQL_TOKEN_UMINUS
160 /* literal keyword tokens */
162 %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
164 %token
<pParseNode
> SQL_TOKEN_BETWEEN SQL_TOKEN_BIT SQL_TOKEN_BOTH SQL_TOKEN_BY
166 %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
167 %token
<pParseNode
> SQL_TOKEN_CURRENT SQL_TOKEN_CURSOR
169 %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
170 %token
<pParseNode
> SQL_TOKEN_DISTINCT SQL_TOKEN_DOUBLE SQL_TOKEN_DROP
172 %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
174 %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
176 %token
<pParseNode
> SQL_TOKEN_JOIN SQL_TOKEN_KEY SQL_TOKEN_LEADING SQL_TOKEN_LIKE SQL_TOKEN_LOCAL SQL_TOKEN_LOWER
177 %token
<pParseNode
> SQL_TOKEN_MAX SQL_TOKEN_MIN SQL_TOKEN_NATURAL SQL_TOKEN_NCHAR SQL_TOKEN_NULL SQL_TOKEN_NUMERIC
179 %token
<pParseNode
> SQL_TOKEN_OCTET_LENGTH SQL_TOKEN_OF SQL_TOKEN_ON SQL_TOKEN_OPTION SQL_TOKEN_ORDER SQL_TOKEN_OUTER
181 %token
<pParseNode
> SQL_TOKEN_PRECISION SQL_TOKEN_PRIMARY SQL_TOKEN_PRIVILEGES SQL_TOKEN_PROCEDURE SQL_TOKEN_PUBLIC
182 %token
<pParseNode
> SQL_TOKEN_REAL SQL_TOKEN_REFERENCES SQL_TOKEN_ROLLBACK
184 %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
186 %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
187 %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
188 %token
<pParseNode
> SQL_TOKEN_WHERE SQL_TOKEN_WITH SQL_TOKEN_WORK SQL_TOKEN_ZONE
191 %token
<pParseNode
> SQL_TOKEN_CALL SQL_TOKEN_D SQL_TOKEN_FN SQL_TOKEN_T SQL_TOKEN_TS SQL_TOKEN_OJ
192 /* string functions */
193 %token
<pParseNode
> SQL_TOKEN_ASCII SQL_TOKEN_BIT_LENGTH SQL_TOKEN_CHAR SQL_TOKEN_CHAR_LENGTH SQL_TOKEN_SQL_TOKEN_INTNUM
194 %token
<pParseNode
> SQL_TOKEN_CONCAT
195 %token
<pParseNode
> SQL_TOKEN_DIFFERENCE SQL_TOKEN_INSERT SQL_TOKEN_LCASE SQL_TOKEN_LEFT SQL_TOKEN_LENGTH SQL_TOKEN_LOCATE
196 %token
<pParseNode
> SQL_TOKEN_LOCATE_2 SQL_TOKEN_LTRIM SQL_TOKEN_POSITION SQL_TOKEN_REPEAT SQL_TOKEN_REPLACE
197 %token
<pParseNode
> SQL_TOKEN_RIGHT SQL_TOKEN_RTRIM SQL_TOKEN_SOUNDEX SQL_TOKEN_SPACE SQL_TOKEN_SUBSTRING SQL_TOKEN_UCASE
199 /* time and date functions */
200 %token
<pParseNode
> SQL_TOKEN_CURRENT_DATE SQL_TOKEN_CURRENT_TIME SQL_TOKEN_CURRENT_TIMESTAMP SQL_TOKEN_CURDATE SQL_TOKEN_CURTIME
201 %token
<pParseNode
> SQL_TOKEN_DAYNAME SQL_TOKEN_DAYOFMONTH SQL_TOKEN_DAYOFWEEK SQL_TOKEN_DAYOFYEAR SQL_TOKEN_EXTRACT
202 %token
<pParseNode
> SQL_TOKEN_HOUR SQL_TOKEN_MINUTE SQL_TOKEN_MONTH SQL_TOKEN_MONTHNAME SQL_TOKEN_NOW SQL_TOKEN_QUARTER SQL_TOKEN_DATEDIFF
203 %token
<pParseNode
> SQL_TOKEN_SECOND SQL_TOKEN_TIMESTAMPADD SQL_TOKEN_TIMESTAMPDIFF SQL_TOKEN_TIMEVALUE SQL_TOKEN_WEEK SQL_TOKEN_YEAR
205 /* numeric functions */
206 %token
<pParseNode
> SQL_TOKEN_ABS SQL_TOKEN_ACOS SQL_TOKEN_ASIN SQL_TOKEN_ATAN SQL_TOKEN_ATAN2 SQL_TOKEN_CEILING
207 %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
208 %token
<pParseNode
> SQL_TOKEN_LOG10 SQL_TOKEN_MOD SQL_TOKEN_PI SQL_TOKEN_POWER SQL_TOKEN_RADIANS SQL_TOKEN_RAND SQL_TOKEN_ROUNDMAGIC
209 %token
<pParseNode
> SQL_TOKEN_ROUND SQL_TOKEN_SIGN SQL_TOKEN_SIN SQL_TOKEN_SQRT SQL_TOKEN_TAN SQL_TOKEN_TRUNCATE
211 // computational operation
212 %token
<pParseNode
> SQL_TOKEN_EVERY SQL_TOKEN_INTERSECTION SQL_TOKEN_FUSION SQL_TOKEN_COLLECT SQL_TOKEN_VAR_POP SQL_TOKEN_VAR_SAMP
213 %token
<pParseNode
> SQL_TOKEN_STDDEV_SAMP SQL_TOKEN_STDDEV_POP
215 %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
216 %token
<pParseNode
> SQL_TOKEN_CASE SQL_TOKEN_THEN SQL_TOKEN_END SQL_TOKEN_NULLIF SQL_TOKEN_COALESCE SQL_TOKEN_WHEN SQL_TOKEN_ELSE
217 %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
218 %token
<pParseNode
> SQL_TOKEN_NEW SQL_TOKEN_OLD
219 %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
220 %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
221 %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
223 %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
224 %token
<pParseNode
> SQL_TOKEN_FIRST_VALUE SQL_TOKEN_LAST_VALUE SQL_TOKEN_NTH_VALUE SQL_TOKEN_FIRST SQL_TOKEN_LAST
225 %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
226 %token
<pParseNode
> SQL_TOKEN_PARTITION SQL_TOKEN_WINDOW SQL_TOKEN_NO
228 %token
<pParseNode
> SQL_TOKEN_LIMIT SQL_TOKEN_OFFSET SQL_TOKEN_NEXT SQL_TOKEN_ONLY
232 %left
<pParseNode
> SQL_TOKEN_OR
233 %left
<pParseNode
> SQL_TOKEN_AND
235 %left
<pParseNode
> SQL_LESSEQ SQL_GREATEQ SQL_NOTEQUAL SQL_LESS SQL_GREAT SQL_EQUAL
/* '<' '>' = <> < > <= >= != */
236 %left
<pParseNode
> '+' '-' SQL_CONCAT
237 %left
<pParseNode
> '*' '/'
238 %left SQL_TOKEN_NATURAL SQL_TOKEN_CROSS SQL_TOKEN_FULL SQL_TOKEN_LEFT SQL_TOKEN_RIGHT
245 %token
<pParseNode
> SQL_TOKEN_INVALIDSYMBOL
247 /*%type <pParseNode> sql_single_statement */
249 %type
<pParseNode
> sql
/*schema */
250 %type
<pParseNode
> column_def_opt_list column_def_opt table_constraint_def column_commalist
251 %type
<pParseNode
> view_def opt_with_check_option opt_column_commalist privilege_def
252 %type
<pParseNode
> opt_with_grant_option privileges operation_commalist operation
253 %type
<pParseNode
> grantee_commalist grantee opt_order_by_clause ordering_spec_commalist
254 %type
<pParseNode
> ordering_spec opt_asc_desc manipulative_statement commit_statement
255 %type
<pParseNode
> /*delete_statement_positioned*/ delete_statement_searched fetch_statement
256 %type
<pParseNode
> insert_statement values_or_query_spec
257 %type
<pParseNode
> rollback_statement select_statement_into opt_all_distinct
258 %type
<pParseNode
> /*update_statement_positioned*/ assignment_commalist assignment
259 %type
<pParseNode
> update_statement_searched target_commalist target opt_where_clause
260 %type
<pParseNode
> select_statement selection table_exp from_clause table_ref_commalist table_ref
261 %type
<pParseNode
> where_clause opt_group_by_clause column_ref_commalist opt_having_clause
262 %type
<pParseNode
> search_condition predicate comparison_predicate comparison_predicate_part_2 between_predicate between_predicate_part_2
263 %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
264 %type
<pParseNode
> all_or_any_predicate any_all_some existence_test subquery quantified_comparison_predicate_part_2
265 %type
<pParseNode
> scalar_exp_commalist parameter_ref literal parenthesized_boolean_value_expression
266 %type
<pParseNode
> column_ref data_type column cursor parameter range_variable user
/*like_check*/
267 /* neue Regeln bei OJ */
268 %type
<pParseNode
> derived_column as_clause table_name num_primary term num_value_exp
269 %type
<pParseNode
> value_exp_primary num_value_fct unsigned_value_spec cast_spec set_fct_spec scalar_subquery
270 %type
<pParseNode
> position_exp extract_exp length_exp general_value_spec
271 %type
<pParseNode
> general_set_fct set_fct_type query_exp non_join_query_exp joined_table
272 %type
<pParseNode
> non_join_query_term non_join_query_primary simple_table
273 %type
<pParseNode
> table_value_const_list row_value_constructor row_value_const_list row_value_constructor_elem
274 %type
<pParseNode
> qualified_join value_exp query_term join_type outer_join_type join_condition boolean_term
275 %type
<pParseNode
> boolean_factor truth_value boolean_test boolean_primary named_columns_join join_spec
276 %type
<pParseNode
> cast_operand cast_target factor datetime_value_exp
/*interval_value_exp*/ datetime_term datetime_factor
277 %type
<pParseNode
> datetime_primary datetime_value_fct time_zone time_zone_specifier
/*interval_term*/ interval_qualifier
278 %type
<pParseNode
> start_field non_second_datetime_field end_field single_datetime_field extract_field datetime_field time_zone_field
279 %type
<pParseNode
> extract_source char_length_exp octet_length_exp bit_length_exp select_sublist string_value_exp
280 %type
<pParseNode
> char_value_exp concatenation char_factor char_primary string_value_fct char_substring_fct fold
281 %type
<pParseNode
> form_conversion char_translation trim_fct trim_operands trim_spec bit_value_fct bit_substring_fct op_column_commalist
282 %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
283 %type
<pParseNode
> function_arg_commalist3 string_function_3Argument function_arg_commalist4 string_function_4Argument function_arg_commalist2 string_function_1Argument string_function_2Argument
284 %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
285 %type
<pParseNode
> all query_primary sql_not for_length upper_lower comparison column_val cross_union
/*opt_schema_element_list*/
286 %type
<pParseNode
> /*op_authorization op_schema*/ nil_fkt schema_element base_table_def base_table_element base_table_element_commalist
287 %type
<pParseNode
> column_def odbc_fct_spec odbc_call_spec odbc_fct_type op_parameter union_statement
288 %type
<pParseNode
> op_odbc_call_parameter odbc_parameter_commalist odbc_parameter function_args_commalist function_arg
289 %type
<pParseNode
> catalog_name schema_name table_node numeric_function string_function function_name date_function table_primary_as_range_column opt_as
290 %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
291 %type
<pParseNode
> case_expression else_clause result_expression result case_abbreviation case_specification searched_when_clause simple_when_clause searched_case simple_case
292 %type
<pParseNode
> when_operand_list when_operand case_operand
293 %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
294 %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
295 %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
296 %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
297 %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
298 %type
<pParseNode
> approximate_numeric_type exact_numeric_type opt_paren_precision_scale
299 /* window function rules */
300 %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
301 %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
302 %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
303 %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
304 %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
305 %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
306 %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
307 /* LIMIT and OFFSET */
308 %type
<pParseNode
> opt_limit_offset_clause limit_offset_clause opt_fetch_first_clause
311 /* Parse Tree an OSQLParser zurueckliefern
312 * (der Zugriff ueber yyval nach Aufruf des Parsers scheitert,
315 sql_single_statement:
317 { xxx_pGLOBAL_SQLPARSER
->setParseTree
( $1 ); }
319 { xxx_pGLOBAL_SQLPARSER
->setParseTree
( $1 ); }
322 /* schema definition language */
323 /* Note: other ``sql:sal_Unicode() rules appear later in the grammar */
326 manipulative_statement
338 | SQL_TOKEN_AUTHORIZATION user
348 | SQL_TOKEN_NAME '.' SQL_TOKEN_NAME
352 $$->append($2 = newNode(".", SQL_NODE_PUNCTUATION));
358 SQL_TOKEN_CREATE SQL_TOKEN_SCHEMA op_schema op_authorization opt_schema_element_list
369 opt_schema_element_list:
371 | schema_glement_list
376 {$$ = SQL_NEW_LISTRULE;
378 | schema_element_list schema_element
392 SQL_TOKEN_CREATE SQL_TOKEN_TABLE table_node
'(' base_table_element_commalist
')'
397 $$
->append
($4 = newNode
("(", SQL_NODE_PUNCTUATION
));
399 $$
->append
($6 = newNode
(")", SQL_NODE_PUNCTUATION
));}
402 base_table_element_commalist:
404 {$$
= SQL_NEW_COMMALISTRULE
;
406 | base_table_element_commalist
',' base_table_element
413 | table_constraint_def
417 column data_type column_def_opt_list
426 /* empty */ {$$
= SQL_NEW_LISTRULE
;}
427 | column_def_opt_list column_def_opt
437 | SQL_TOKEN_PRIMARY SQL_TOKEN_KEY
445 SQL_TOKEN_NOT SQL_TOKEN_NULL
450 | SQL_TOKEN_DEFAULT literal
454 | SQL_TOKEN_DEFAULT SQL_TOKEN_NULL
458 | SQL_TOKEN_DEFAULT SQL_TOKEN_USER
462 | SQL_TOKEN_DEFAULT nil_fkt
469 | SQL_TOKEN_CHECK
'(' search_condition
')'
472 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
474 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));}
475 | SQL_TOKEN_REFERENCES table_node
479 | SQL_TOKEN_REFERENCES table_node
'(' column_commalist
')'
483 $$
->append
($3 = newNode
("(", SQL_NODE_PUNCTUATION
));
485 $$
->append
($5 = newNode
(")", SQL_NODE_PUNCTUATION
));}
488 table_constraint_def:
489 unique_spec
'(' column_commalist
')'
492 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
494 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));}
495 | SQL_TOKEN_FOREIGN SQL_TOKEN_KEY
'(' column_commalist
')' SQL_TOKEN_REFERENCES table_node
499 $$
->append
($3 = newNode
("(", SQL_NODE_PUNCTUATION
));
501 $$
->append
($5 = newNode
(")", SQL_NODE_PUNCTUATION
));
504 | SQL_TOKEN_FOREIGN SQL_TOKEN_KEY
'(' column_commalist
')' SQL_TOKEN_REFERENCES table_node
'(' column_commalist
')'
508 $$
->append
($3 = newNode
("(", SQL_NODE_PUNCTUATION
));
510 $$
->append
($5 = newNode
(")", SQL_NODE_PUNCTUATION
));
513 $$
->append
($8 = newNode
("(", SQL_NODE_PUNCTUATION
));
515 $$
->append
($10 = newNode
(")", SQL_NODE_PUNCTUATION
));}
516 | SQL_TOKEN_CHECK
'(' search_condition
')'
519 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
521 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));}
524 /* empty */ {$$
= SQL_NEW_RULE
;}
525 |
'(' column_commalist
')'
527 $$
->append
($1 = newNode
("(", SQL_NODE_PUNCTUATION
));
529 $$
->append
($3 = newNode
(")", SQL_NODE_PUNCTUATION
));
533 column_commalist
',' column
537 {$$
= SQL_NEW_COMMALISTRULE
;
542 SQL_TOKEN_CREATE SQL_TOKEN_VIEW table_node opt_column_commalist SQL_TOKEN_AS select_statement opt_with_check_option
553 opt_with_check_option:
554 /* empty */ {$$
= SQL_NEW_RULE
;}
555 | SQL_TOKEN_WITH SQL_TOKEN_CHECK SQL_TOKEN_OPTION
562 opt_column_commalist:
563 /* empty */ {$$
= SQL_NEW_RULE
;}
564 |
'(' column_commalist
')'
566 $$
->append
($1 = newNode
("(", SQL_NODE_PUNCTUATION
));
568 $$
->append
($3 = newNode
(")", SQL_NODE_PUNCTUATION
));}
572 SQL_TOKEN_GRANT privileges SQL_TOKEN_ON table_node SQL_TOKEN_TO grantee_commalist
573 opt_with_grant_option
584 opt_with_grant_option:
585 /* empty */ {$$
= SQL_NEW_RULE
;}
586 | SQL_TOKEN_WITH SQL_TOKEN_GRANT SQL_TOKEN_OPTION
594 SQL_TOKEN_ALL SQL_TOKEN_PRIVILEGES
598 | operation_commalist
603 {$$
= SQL_NEW_COMMALISTRULE
;
605 | operation_commalist
',' operation
612 | SQL_TOKEN_INSERT opt_column_commalist
617 | SQL_TOKEN_UPDATE opt_column_commalist
621 | SQL_TOKEN_REFERENCES opt_column_commalist
631 {$$
= SQL_NEW_COMMALISTRULE
;
633 | grantee_commalist
',' grantee
643 /* module language */
646 /* empty */ {$$
= SQL_NEW_RULE
;}
647 | SQL_TOKEN_ORDER SQL_TOKEN_BY ordering_spec_commalist
654 ordering_spec_commalist:
656 {$$
= SQL_NEW_COMMALISTRULE
;
658 | ordering_spec_commalist
',' ordering_spec
664 /* SQL_TOKEN_INTNUM opt_asc_desc
669 predicate opt_asc_desc
674 | row_value_constructor_elem opt_asc_desc
688 manipulative_statement_list:
689 manipulative_statement
690 {$$ = SQL_NEW_LISTRULE;
692 | manipulative_statement_list manipulative_statement
703 /* manipulative statements */
705 manipulative_statement:
707 /* | delete_statement_positioned*/
708 | delete_statement_searched
712 | select_statement_into
713 /* | update_statement_positioned*/
714 | update_statement_searched
716 |
'{' odbc_call_spec
'}'
719 $$
->append
($1 = newNode
("{", SQL_NODE_PUNCTUATION
));
721 $$
->append
($3 = newNode
("}", SQL_NODE_PUNCTUATION
));
727 | union_statement SQL_TOKEN_UNION all select_statement
737 SQL_TOKEN_COMMIT SQL_TOKEN_WORK
743 delete_statement_positioned:
744 SQL_TOKEN_DELETE SQL_TOKEN_FROM table_node SQL_TOKEN_WHERE SQL_TOKEN_CURRENT SQL_TOKEN_OF cursor
755 delete_statement_searched:
756 SQL_TOKEN_DELETE SQL_TOKEN_FROM table_node opt_where_clause
765 SQL_TOKEN_FETCH cursor SQL_TOKEN_INTO target_commalist
774 SQL_TOKEN_INSERT SQL_TOKEN_INTO table_node opt_column_commalist query_exp
782 values_or_query_spec:
783 SQL_TOKEN_VALUES
'(' table_value_const_list
')'
786 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
788 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));
792 table_value_const_list:
793 row_value_constructor
794 {$$
= SQL_NEW_COMMALISTRULE
;
796 | table_value_const_list
',' row_value_constructor
800 row_value_const_list:
801 row_value_constructor_elem
802 {$$
= SQL_NEW_COMMALISTRULE
;
804 | row_value_const_list
',' row_value_constructor_elem
808 row_value_constructor:
809 row_value_constructor_elem
810 /* | '(' row_value_const_list ')'
813 $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
815 $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
819 row_value_constructor_elem:
826 SQL_TOKEN_ROLLBACK SQL_TOKEN_WORK
833 /* INTO target_commalist herausgenommen */
834 select_statement_into:
835 SQL_TOKEN_SELECT opt_all_distinct selection SQL_TOKEN_INTO target_commalist table_exp
852 update_statement_positioned:
853 SQL_TOKEN_UPDATE table_node SQL_TOKEN_SET assignment_commalist
854 SQL_TOKEN_WHERE SQL_TOKEN_CURRENT SQL_TOKEN_OF cursor
866 assignment_commalist:
868 {$$
= SQL_NEW_COMMALISTRULE
;
870 | assignment_commalist
',' assignment
876 column SQL_EQUAL update_source
886 update_statement_searched:
887 SQL_TOKEN_UPDATE table_node SQL_TOKEN_SET assignment_commalist opt_where_clause
898 {$$
= SQL_NEW_COMMALISTRULE
;
900 | target_commalist
',' target
910 /* empty */ {$$
= SQL_NEW_RULE
;}
914 /* query expressions */
923 /* SELECT STATEMENT */
925 SQL_TOKEN_SELECT opt_all_distinct selection table_exp
939 $$
->append
($1 = newNode
("*", SQL_NODE_PUNCTUATION
));
941 | scalar_exp_commalist
943 opt_result_offset_clause:
944 /* empty */ {$$
= SQL_NEW_RULE
;}
945 | result_offset_clause
947 result_offset_clause:
948 SQL_TOKEN_OFFSET offset_row_count row_or_rows
956 opt_fetch_first_row_count:
957 /* empty */ {$$
= SQL_NEW_RULE
;}
958 | fetch_first_row_count
968 opt_fetch_first_clause:
969 /* empty */ {$$
= SQL_NEW_RULE
;}
973 SQL_TOKEN_FETCH first_or_next opt_fetch_first_row_count row_or_rows SQL_TOKEN_ONLY
986 fetch_first_row_count:
990 opt_limit_offset_clause:
991 /* empty */ {$$
= SQL_NEW_RULE
;}
992 | limit_offset_clause
995 /* empty */ {$$
= SQL_NEW_RULE
;}
996 | SQL_TOKEN_OFFSET SQL_TOKEN_INTNUM
1003 limit_offset_clause:
1004 SQL_TOKEN_LIMIT SQL_TOKEN_INTNUM opt_offset
1013 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
1029 SQL_TOKEN_FROM table_ref_commalist
1035 table_ref_commalist:
1038 {$$
= SQL_NEW_COMMALISTRULE
;
1040 | table_ref_commalist
',' table_ref
1046 /* empty */ {$$
= SQL_NEW_RULE
;}
1050 /* empty */ {$$
= SQL_NEW_RULE
;}
1053 table_primary_as_range_column:
1054 {$$
= SQL_NEW_RULE
;}
1055 | opt_as SQL_TOKEN_NAME op_column_commalist
1063 table_node table_primary_as_range_column
1069 | subquery range_variable op_column_commalist
1077 |
'{' SQL_TOKEN_OJ joined_table
'}'
1080 $$
->append
($1 = newNode
("{", SQL_NODE_PUNCTUATION
));
1083 $$
->append
($4 = newNode
("}", SQL_NODE_PUNCTUATION
));
1085 |
'(' joined_table
')'
1088 $$
->append
($1 = newNode
("(", SQL_NODE_PUNCTUATION
));
1090 $$
->append
($3 = newNode
(")", SQL_NODE_PUNCTUATION
));
1094 SQL_TOKEN_WHERE search_condition
1100 opt_group_by_clause:
1101 /* empty */ {$$
= SQL_NEW_RULE
;}
1102 | SQL_TOKEN_GROUP SQL_TOKEN_BY column_ref_commalist
1109 column_ref_commalist:
1111 {$$
= SQL_NEW_COMMALISTRULE
;
1114 {$$
= SQL_NEW_COMMALISTRULE
;
1116 | column_ref_commalist
',' column_ref
1119 | column_ref_commalist
',' set_fct_spec
1125 /* empty */ {$$
= SQL_NEW_RULE
;}
1126 | SQL_TOKEN_HAVING search_condition
1132 /* search conditions */
1141 |
'(' search_condition
')'
1142 { // boolean_primary: rule 2
1144 $$
->append
($1 = newNode
("(", SQL_NODE_PUNCTUATION
));
1146 $$
->append
($3 = newNode
(")", SQL_NODE_PUNCTUATION
));
1148 | row_value_constructor_elem
/*[^')' ',']*/
1150 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
())// boolean_primary: rule 3
1153 sal_Int16 nErg
= xxx_pGLOBAL_SQLPARSER
->buildComparsionRule
($$
,$1);
1156 OSQLParseNode
* pTemp
= $$
;
1157 $$
= pTemp
->removeAt
((sal_uInt32
)0);
1173 parenthesized_boolean_value_expression:
1174 '(' search_condition
')'
1175 { // boolean_primary: rule 2
1177 $$
->append
($1 = newNode
("(", SQL_NODE_PUNCTUATION
));
1179 $$
->append
($3 = newNode
(")", SQL_NODE_PUNCTUATION
));
1184 | boolean_primary SQL_TOKEN_IS sql_not truth_value
1195 | SQL_TOKEN_NOT boolean_test
1196 { // boolean_factor: rule 1
1204 | boolean_term SQL_TOKEN_AND boolean_factor
1206 $$
= SQL_NEW_RULE
; // boolean_term: rule 1
1214 | search_condition SQL_TOKEN_OR boolean_term
1216 $$
= SQL_NEW_RULE
; // search_condition
1223 comparison_predicate
1225 | all_or_any_predicate
1232 comparison_predicate_part_2:
1233 comparison row_value_constructor
1235 $$
= SQL_NEW_RULE
; // comparison_predicate: rule 1
1239 comparison_predicate:
1240 row_value_constructor comparison row_value_constructor
1242 $$
= SQL_NEW_RULE
; // comparison_predicate: rule 1
1247 | comparison row_value_constructor
1249 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
()) // comparison_predicate: rule 2
1252 sal_Int16 nErg
= xxx_pGLOBAL_SQLPARSER
->buildPredicateRule
($$
,$2,$1);
1255 OSQLParseNode
* pTemp
= $$
;
1256 $$
= pTemp
->removeAt
((sal_uInt32
)0);
1278 | SQL_TOKEN_IS sql_not SQL_TOKEN_DISTINCT SQL_TOKEN_FROM
1286 | SQL_TOKEN_IS sql_not
1293 between_predicate_part_2:
1294 sql_not SQL_TOKEN_BETWEEN row_value_constructor SQL_TOKEN_AND row_value_constructor
1296 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
()) // between_predicate: rule 2
1300 sal_Int16 nErg
= xxx_pGLOBAL_SQLPARSER
->buildPredicateRule
($$
,$3,$2,$5);
1303 OSQLParseNode
* pTemp
= $$
;
1304 $$
= pTemp
->removeAt
((sal_uInt32
)0);
1305 OSQLParseNode
* pColumnRef
= $$
->removeAt
((sal_uInt32
)0);
1307 OSQLParseNode
* pBetween_predicate
= new OSQLInternalNode
(aEmptyString
, SQL_NODE_RULE
,OSQLParser
::RuleID
(OSQLParseNode
::between_predicate
));
1308 pBetween_predicate
->append
(pColumnRef
);
1309 pBetween_predicate
->append
($$
);
1310 $$
= pBetween_predicate
;
1323 $$
= SQL_NEW_RULE
; // between_predicate: rule 1
1332 row_value_constructor between_predicate_part_2
1334 $$
= SQL_NEW_RULE
; // between_predicate: rule 1
1338 | between_predicate_part_2
1340 character_like_predicate_part_2:
1341 sql_not SQL_TOKEN_LIKE string_value_exp opt_escape
1343 $$
= SQL_NEW_RULE
; // like_predicate: rule 1
1350 other_like_predicate_part_2:
1351 sql_not SQL_TOKEN_LIKE value_exp_primary opt_escape
1353 $$
= SQL_NEW_RULE
; // like_predicate: rule 1
1361 row_value_constructor character_like_predicate_part_2
1363 $$
= SQL_NEW_RULE
; // like_predicate: rule 1
1367 | row_value_constructor other_like_predicate_part_2
1369 $$
= SQL_NEW_RULE
; // like_predicate: rule 3
1373 | character_like_predicate_part_2
1375 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
()) // like_predicate: rule 5
1377 OSQLParseNode
* pColumnRef
= newNode
(aEmptyString
, SQL_NODE_RULE
,OSQLParser
::RuleID
(OSQLParseNode
::column_ref
));
1378 pColumnRef
->append
(newNode
(xxx_pGLOBAL_SQLPARSER
->getFieldName
(),SQL_NODE_NAME
));
1381 $$
->append
(pColumnRef
);
1383 OSQLParseNode
* p2nd
= $1->removeAt
(2);
1384 OSQLParseNode
* p3rd
= $1->removeAt
(2);
1385 if
( !xxx_pGLOBAL_SQLPARSER
->buildLikeRule
($1,p2nd
,p3rd
) )
1395 | other_like_predicate_part_2
1397 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
()) // like_predicate: rule 6
1399 OSQLParseNode
* pColumnRef
= newNode
(aEmptyString
, SQL_NODE_RULE
,OSQLParser
::RuleID
(OSQLParseNode
::column_ref
));
1400 pColumnRef
->append
(newNode
(xxx_pGLOBAL_SQLPARSER
->getFieldName
(),SQL_NODE_NAME
));
1403 $$
->append
(pColumnRef
);
1405 OSQLParseNode
* p2nd
= $1->removeAt
(2);
1406 OSQLParseNode
* p3rd
= $1->removeAt
(2);
1407 if
( !xxx_pGLOBAL_SQLPARSER
->buildLikeRule
($1,p2nd
,p3rd
) )
1420 /* empty */ {$$
= SQL_NEW_RULE
;}
1421 | SQL_TOKEN_ESCAPE string_value_exp
1425 |
'{' SQL_TOKEN_ESCAPE SQL_TOKEN_STRING
'}'
1428 $$
->append
($1 = newNode
("{", SQL_NODE_PUNCTUATION
));
1431 $$
->append
($4 = newNode
("}", SQL_NODE_PUNCTUATION
));
1435 null_predicate_part_2:
1436 SQL_TOKEN_IS sql_not SQL_TOKEN_NULL
1438 $$
= SQL_NEW_RULE
; // test_for_null: rule 1
1445 row_value_constructor null_predicate_part_2
1447 $$
= SQL_NEW_RULE
; // test_for_null: rule 1
1451 | null_predicate_part_2
1453 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
())// test_for_null: rule 2
1455 OSQLParseNode
* pColumnRef
= newNode
(aEmptyString
, SQL_NODE_RULE
,OSQLParser
::RuleID
(OSQLParseNode
::column_ref
));
1456 pColumnRef
->append
(newNode
(xxx_pGLOBAL_SQLPARSER
->getFieldName
(),SQL_NODE_NAME
));
1459 $$
->append
(pColumnRef
);
1471 |
'(' value_exp_commalist
')'
1473 $$
->append
($1 = newNode
("(", SQL_NODE_PUNCTUATION
));
1475 $$
->append
($3 = newNode
(")", SQL_NODE_PUNCTUATION
));
1478 in_predicate_part_2:
1479 sql_not SQL_TOKEN_IN in_predicate_value
1481 $$
= SQL_NEW_RULE
;// in_predicate: rule 1
1488 row_value_constructor in_predicate_part_2
1490 $$
= SQL_NEW_RULE
;// in_predicate: rule 1
1494 | in_predicate_part_2
1496 if
( xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
() )// in_predicate: rule 2
1498 OSQLParseNode
* pColumnRef
= newNode
(aEmptyString
, SQL_NODE_RULE
,OSQLParser
::RuleID
(OSQLParseNode
::column_ref
));
1499 pColumnRef
->append
(newNode
(xxx_pGLOBAL_SQLPARSER
->getFieldName
(),SQL_NODE_NAME
));
1502 $$
->append
(pColumnRef
);
1509 quantified_comparison_predicate_part_2:
1510 comparison any_all_some subquery
1518 all_or_any_predicate:
1519 row_value_constructor quantified_comparison_predicate_part_2
1525 | quantified_comparison_predicate_part_2
1527 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
())
1529 OSQLParseNode
* pColumnRef
= newNode
(aEmptyString
, SQL_NODE_RULE
,OSQLParser
::RuleID
(OSQLParseNode
::column_ref
));
1530 pColumnRef
->append
(newNode
(xxx_pGLOBAL_SQLPARSER
->getFieldName
(),SQL_NODE_NAME
));
1533 $$
->append
(pColumnRef
);
1548 SQL_TOKEN_EXISTS subquery
1554 SQL_TOKEN_UNIQUE subquery
1562 $$
->append
($1 = newNode
("(", SQL_NODE_PUNCTUATION
));
1564 $$
->append
($3 = newNode
(")", SQL_NODE_PUNCTUATION
));}
1567 /* scalar expressions */
1568 scalar_exp_commalist:
1571 $$
= SQL_NEW_COMMALISTRULE
;
1574 | scalar_exp_commalist
',' select_sublist
1581 /* table_node '.' '*'
1585 $$->append($2 = newNode(".", SQL_NODE_PUNCTUATION));
1586 $$->append($3 = newNode("*", SQL_NODE_PUNCTUATION));
1601 $$ = newNode("*", SQL_NODE_PUNCTUATION);
1605 $$ = newNode("?", SQL_NODE_PUNCTUATION);
1611 $$->append($2 = newNode("*", SQL_NODE_PUNCTUATION));
1612 xxx_pGLOBAL_SQLPARSER->reduceLiteral($$, sal_False);
1618 $$->append($2 = newNode("?", SQL_NODE_PUNCTUATION));
1619 xxx_pGLOBAL_SQLPARSER->reduceLiteral($$, sal_False);
1627 | SQL_TOKEN_REAL_NUM
1629 | SQL_TOKEN_APPROXNUM
1630 | SQL_TOKEN_ACCESS_DATE
1631 /* rules for predicate check */
1632 | literal SQL_TOKEN_STRING
1634 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
())
1639 xxx_pGLOBAL_SQLPARSER
->reduceLiteral
($$
, sal_True
);
1644 | literal SQL_TOKEN_INT
1646 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
())
1651 xxx_pGLOBAL_SQLPARSER
->reduceLiteral
($$
, sal_True
);
1656 | literal SQL_TOKEN_REAL_NUM
1658 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
())
1663 xxx_pGLOBAL_SQLPARSER
->reduceLiteral
($$
, sal_True
);
1668 | literal SQL_TOKEN_APPROXNUM
1670 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
())
1675 xxx_pGLOBAL_SQLPARSER
->reduceLiteral
($$
, sal_True
);
1684 /* empty */ {$$
= SQL_NEW_RULE
;}
1685 | SQL_TOKEN_AS column
1694 SQL_TOKEN_POSITION
'(' value_exp SQL_TOKEN_IN value_exp
')'
1698 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
1702 $$
->append
($6 = newNode
(")", SQL_NODE_PUNCTUATION
));
1704 | SQL_TOKEN_POSITION
'(' value_exp_commalist
')'
1708 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
1710 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));
1719 SQL_TOKEN_CHAR_LENGTH
'(' value_exp
')'
1723 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
1725 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));
1727 | SQL_TOKEN_SQL_TOKEN_INTNUM
'(' value_exp
')'
1731 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
1733 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));
1738 SQL_TOKEN_OCTET_LENGTH
'(' value_exp
')'
1742 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
1744 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));
1748 SQL_TOKEN_BIT_LENGTH
'(' value_exp
')'
1752 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
1754 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));
1775 non_second_datetime_field
1792 SQL_TOKEN_TIMEZONE_HOUR
1797 | SQL_TOKEN_TIMEZONE_MINUTE
1809 /* | interval_value_exp
1816 SQL_TOKEN_EXTRACT
'(' extract_field SQL_TOKEN_FROM value_exp
')'
1820 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
1824 $$
->append
($6 = newNode
(")", SQL_NODE_PUNCTUATION
));
1827 unsigned_value_spec:
1838 | SQL_TOKEN_CURRENT_CATALOG
1839 | SQL_TOKEN_CURRENT_DEFAULT_TRANSFORM_GROUP
1840 | SQL_TOKEN_CURRENT_PATH
1841 | SQL_TOKEN_CURRENT_ROLE
1842 | SQL_TOKEN_CURRENT_SCHEMA
1843 | SQL_TOKEN_CURRENT_USER
1844 | SQL_TOKEN_SESSION_USER
1845 | SQL_TOKEN_SYSTEM_USER
1849 |
'{' odbc_fct_spec
'}'
1852 $$
->append
($1 = newNode
("{", SQL_NODE_PUNCTUATION
));
1854 $$
->append
($3 = newNode
("}", SQL_NODE_PUNCTUATION
));
1856 | function_name
'(' ')'
1860 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
1861 $$
->append
($3 = newNode
(")", SQL_NODE_PUNCTUATION
));
1863 | function_name0
'(' ')'
1867 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
1868 $$
->append
($3 = newNode
(")", SQL_NODE_PUNCTUATION
));
1870 | function_name1
'(' function_arg
')'
1874 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
1876 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));
1878 | function_name2
'(' function_arg_commalist2
')'
1882 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
1884 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));
1886 | function_name3
'(' function_arg_commalist3
')'
1890 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
1892 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));
1894 | string_function_4Argument
'(' function_arg_commalist4
')'
1898 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
1900 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));
1902 | function_name
'(' function_args_commalist
')'
1906 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
1908 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));
1910 | function_name12
'(' function_args_commalist
')'
1912 if
( $3->count
() == 1 ||
$3->count
() == 2 )
1916 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
1918 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));
1923 | function_name23
'(' function_args_commalist
')'
1925 if
( $3->count
() == 2 ||
$3->count
() == 3)
1929 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
1931 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));
1938 date_function_0Argument
1939 | numeric_function_0Argument
1942 string_function_1Argument
1943 | date_function_1Argument
1944 | numeric_function_1Argument
1947 string_function_2Argument
1948 | numeric_function_2Argument
1958 | SQL_TOKEN_DATEDIFF
1961 string_function_3Argument
1969 string_function_1Argument:
1979 string_function_2Argument:
1984 string_function_3Argument:
1987 string_function_4Argument:
1994 | SQL_TOKEN_DIFFERENCE
1995 | SQL_TOKEN_LOCATE_2
1998 date_function_0Argument:
2003 date_function_1Argument:
2005 | SQL_TOKEN_DAYOFMONTH
2006 | SQL_TOKEN_DAYOFYEAR
2009 | SQL_TOKEN_MONTHNAME
2016 | SQL_TOKEN_TIMEVALUE
2017 | SQL_TOKEN_DATEVALUE
2021 SQL_TOKEN_TIMESTAMPADD
2022 | SQL_TOKEN_TIMESTAMPDIFF
2024 numeric_function_0Argument:
2027 numeric_function_1Argument:
2045 | SQL_TOKEN_ROUNDMAGIC
2047 numeric_function_2Argument:
2054 | SQL_TOKEN_TRUNCATE
2058 window_function_type SQL_TOKEN_OVER window_name_or_specification
2066 window_function_type
:
2067 rank_function_type
'(' ')'
2071 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
2072 $$
->append
($3 = newNode
(")", SQL_NODE_PUNCTUATION
));
2074 | SQL_TOKEN_ROW_NUMBER
'(' ')'
2078 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
2079 $$
->append
($3 = newNode
(")", SQL_NODE_PUNCTUATION
));
2083 | lead_or_lag_function
2084 | first_or_last_value_function
2085 | nth_value_function
2088 SQL_TOKEN_NTILE
'(' number_of_tiles
')'
2092 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
2094 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));
2097 dynamic_parameter_specification:
2100 simple_value_specification:
2104 simple_value_specification
2105 | dynamic_parameter_specification
2107 opt_lead_or_lag_function:
2108 /* empty */ {$$
= SQL_NEW_RULE
;}
2112 $$
->append
($1 = newNode
(",", SQL_NODE_PUNCTUATION
));
2115 |
',' offset
',' default_expression
2118 $$
->append
($1 = newNode
(",", SQL_NODE_PUNCTUATION
));
2120 $$
->append
($3 = newNode
(",", SQL_NODE_PUNCTUATION
));
2125 /* empty */ {$$
= SQL_NEW_RULE
;}
2129 lead_or_lag_function:
2130 lead_or_lag
'(' lead_or_lag_extent opt_lead_or_lag_function
')' opt_null_treatment
2134 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
2137 $$
->append
($5 = newNode
(")", SQL_NODE_PUNCTUATION
));
2155 SQL_TOKEN_RESPECT SQL_TOKEN_NULLS
2156 | SQL_TOKEN_IGNORE SQL_TOKEN_NULLS
2158 first_or_last_value_function:
2159 first_or_last_value
'(' value_exp
')' opt_null_treatment
2163 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
2165 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));
2169 first_or_last_value
:
2170 SQL_TOKEN_FIRST_VALUE
2171 | SQL_TOKEN_LAST_VALUE
2173 opt_from_first_or_last:
2174 /* empty */ {$$
= SQL_NEW_RULE
;}
2175 | from_first_or_last
2178 SQL_TOKEN_NTH_VALUE
'(' value_exp
',' nth_row
')' opt_from_first_or_last opt_null_treatment
2182 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
2184 $$
->append
($4 = newNode
(",", SQL_NODE_PUNCTUATION
));
2186 $$
->append
($6 = newNode
(")", SQL_NODE_PUNCTUATION
));
2192 simple_value_specification
2193 | dynamic_parameter_specification
2196 SQL_TOKEN_FROM SQL_TOKEN_FIRST
2202 | SQL_TOKEN_FROM SQL_TOKEN_LAST
2212 window_name_or_specification:
2214 | in_line_window_specification
2216 in_line_window_specification:
2217 window_specification
2220 /* empty */ {$$
= SQL_NEW_RULE
;}
2224 SQL_TOKEN_WINDOW window_definition_list
2231 window_definition_list:
2232 window_definition_list
',' window_definition
2236 {$$
= SQL_NEW_COMMALISTRULE
;
2240 new_window_name SQL_TOKEN_AS window_specification
2251 window_specification:
2252 '(' window_specification_details
')'
2255 $$
->append
($1 = newNode
("(", SQL_NODE_PUNCTUATION
));
2257 $$
->append
($3 = newNode
(")", SQL_NODE_PUNCTUATION
));
2260 opt_existing_window_name:
2261 /* empty */ {$$
= SQL_NEW_RULE
;}
2262 | existing_window_name
2264 opt_window_partition_clause:
2265 /* empty */ {$$
= SQL_NEW_RULE
;}
2266 | window_partition_clause
2268 opt_window_frame_clause:
2269 /* empty */ {$$
= SQL_NEW_RULE
;}
2270 | window_frame_clause
2272 window_specification_details:
2273 opt_existing_window_name
2274 opt_window_partition_clause
2276 opt_window_frame_clause
2278 existing_window_name:
2281 window_partition_clause:
2282 SQL_TOKEN_PARTITION SQL_TOKEN_BY window_partition_column_reference_list
2290 window_partition_column_reference_list:
2291 window_partition_column_reference_list
',' window_partition_column_reference
2294 | window_partition_column_reference
2295 {$$
= SQL_NEW_COMMALISTRULE
;
2298 window_partition_column_reference:
2299 column_ref opt_collate_clause
2306 opt_window_frame_exclusion:
2307 /* empty */ {$$
= SQL_NEW_RULE
;}
2308 | window_frame_exclusion
2310 window_frame_clause:
2311 window_frame_units window_frame_extent opt_window_frame_exclusion
2323 window_frame_extent:
2325 | window_frame_between
2328 SQL_TOKEN_UNBOUNDED SQL_TOKEN_PRECEDING
2334 | window_frame_preceding
2335 | SQL_TOKEN_CURRENT SQL_TOKEN_ROW
2342 window_frame_preceding:
2343 unsigned_value_spec SQL_TOKEN_PRECEDING
2350 window_frame_between:
2351 SQL_TOKEN_BETWEEN window_frame_bound_1 SQL_TOKEN_AND window_frame_bound_2
2360 window_frame_bound_1:
2363 window_frame_bound_2:
2368 | SQL_TOKEN_UNBOUNDED SQL_TOKEN_FOLLOWING
2374 | window_frame_following
2376 window_frame_following:
2377 unsigned_value_spec SQL_TOKEN_FOLLOWING
2384 window_frame_exclusion:
2385 SQL_TOKEN_EXCLUDE SQL_TOKEN_CURRENT SQL_TOKEN_ROW
2392 | SQL_TOKEN_EXCLUDE SQL_TOKEN_GROUP
2398 | SQL_TOKEN_EXCLUDE SQL_TOKEN_TIES
2404 | SQL_TOKEN_EXCLUDE SQL_TOKEN_NO SQL_TOKEN_OTHERS
2413 {$$
= SQL_NEW_RULE
;}
2417 $$
->append
($1 = newNode
("?", SQL_NODE_PUNCTUATION
));
2422 op_parameter SQL_TOKEN_CALL table_node op_odbc_call_parameter
2432 op_odbc_call_parameter:
2433 {$$
= SQL_NEW_RULE
;}
2434 |
'(' odbc_parameter_commalist
')'
2437 $$
->append
($1 = newNode
("(", SQL_NODE_PUNCTUATION
));
2439 $$
->append
($3 = newNode
(")", SQL_NODE_PUNCTUATION
));
2443 odbc_parameter_commalist:
2445 {$$
= SQL_NEW_COMMALISTRULE
;
2447 | odbc_parameter_commalist
',' odbc_parameter
2454 /* empty */ {$$
= SQL_NEW_RULE
;}
2460 odbc_fct_type SQL_TOKEN_STRING
2466 | SQL_TOKEN_FN set_fct_spec
2481 set_fct_type
'(' opt_all_distinct function_arg
')'
2485 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
2488 $$
->append
($5 = newNode
(")", SQL_NODE_PUNCTUATION
));
2490 | SQL_TOKEN_COUNT
'(' '*' ')'
2494 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
2495 $$
->append
($3 = newNode
("*", SQL_NODE_PUNCTUATION
));
2496 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));
2498 | SQL_TOKEN_COUNT
'(' opt_all_distinct function_arg
')'
2502 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
2505 $$
->append
($5 = newNode
(")", SQL_NODE_PUNCTUATION
));
2507 | ordered_set_function
2508 | array_aggregate_function
2518 | SQL_TOKEN_STDDEV_POP
2519 | SQL_TOKEN_STDDEV_SAMP
2520 | SQL_TOKEN_VAR_SAMP
2524 | SQL_TOKEN_INTERSECTION
2527 ordered_set_function:
2528 hypothetical_set_function
2529 | inverse_distribution_function
2531 hypothetical_set_function:
2532 rank_function_type
'(' hypothetical_set_function_value_expression_list
')' within_group_specification
2536 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
2538 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));
2541 | rank_function_type
'(' hypothetical_set_function_value_expression_list SQL_TOKEN_BY value_exp_commalist
')' within_group_specification
2545 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
2549 $$
->append
($6 = newNode
(")", SQL_NODE_PUNCTUATION
));
2554 within_group_specification:
2558 | SQL_TOKEN_WITHIN SQL_TOKEN_GROUP
'(' opt_order_by_clause
')'
2563 $$
->append
($3 = newNode
("(", SQL_NODE_PUNCTUATION
));
2565 $$
->append
($5 = newNode
(")", SQL_NODE_PUNCTUATION
));
2568 hypothetical_set_function_value_expression_list:
2572 inverse_distribution_function:
2573 inverse_distribution_function_type
'('inverse_distribution_function_argument
')' within_group_specification
2577 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
2579 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));
2582 inverse_distribution_function_argument:
2585 inverse_distribution_function_type:
2586 SQL_TOKEN_PERCENTILE_CONT
2587 | SQL_TOKEN_PERCENTILE_DISC
2590 array_aggregate_function:
2591 SQL_TOKEN_ARRAY_AGG
'(' value_exp opt_order_by_clause
')'
2595 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
2598 $$
->append
($5 = newNode
(")", SQL_NODE_PUNCTUATION
));
2604 | SQL_TOKEN_DENSE_RANK
2605 | SQL_TOKEN_PERCENT_RANK
2606 | SQL_TOKEN_CUME_DIST
2609 SQL_TOKEN_LEFT %prec SQL_TOKEN_LEFT
2614 | SQL_TOKEN_RIGHT %prec SQL_TOKEN_RIGHT
2619 | SQL_TOKEN_FULL %prec SQL_TOKEN_FULL
2626 SQL_TOKEN_ON search_condition
2635 | named_columns_join
2638 /* empty */ {$$
= SQL_NEW_RULE
;}
2645 | outer_join_type SQL_TOKEN_OUTER
2653 table_ref SQL_TOKEN_CROSS SQL_TOKEN_JOIN table_ref
2664 /* wenn SQL_TOKEN_NATURAL, dann keine join_spec */
2665 table_ref SQL_TOKEN_NATURAL join_type SQL_TOKEN_JOIN table_ref
2674 | table_ref join_type SQL_TOKEN_JOIN table_ref join_spec
2689 SQL_TOKEN_USING
'(' column_commalist
')'
2693 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
2695 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));
2700 | values_or_query_spec
2703 non_join_query_primary:
2705 |
'(' non_join_query_exp
')'
2708 $$
->append
($1 = newNode
("(", SQL_NODE_PUNCTUATION
));
2710 $$
->append
($3 = newNode
(")", SQL_NODE_PUNCTUATION
));
2713 non_join_query_term:
2714 non_join_query_primary
2715 | query_term SQL_TOKEN_INTERSECT all query_primary
2725 non_join_query_primary
2729 | query_exp SQL_TOKEN_UNION all query_term
2737 | query_exp SQL_TOKEN_EXCEPT all query_term
2747 /* empty*/ {$$
= SQL_NEW_RULE
;}
2751 non_join_query_exp
/*[^')']*/
2764 SQL_TOKEN_CAST
'(' cast_operand SQL_TOKEN_AS cast_target
')'
2768 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
2772 $$
->append
($6 = newNode
(")", SQL_NODE_PUNCTUATION
));
2785 $$
->append
($1 = newNode
("(", SQL_NODE_PUNCTUATION
));
2787 $$
->append
($3 = newNode
(")", SQL_NODE_PUNCTUATION
));
2798 |
'-' num_primary %prec SQL_TOKEN_UMINUS
2801 $$
->append
($1 = newNode
("-", SQL_NODE_PUNCTUATION
));
2804 |
'+' num_primary %prec SQL_TOKEN_UMINUS
2807 $$
->append
($1 = newNode
("+", SQL_NODE_PUNCTUATION
));
2818 $$
->append
($2 = newNode
("*", SQL_NODE_PUNCTUATION
));
2825 $$
->append
($2 = newNode
("/", SQL_NODE_PUNCTUATION
));
2832 | num_value_exp
'+' term
2836 $$
->append
($2 = newNode
("+", SQL_NODE_PUNCTUATION
));
2839 | num_value_exp
'-' term
2843 $$
->append
($2 = newNode
("-", SQL_NODE_PUNCTUATION
));
2848 /* value_exp_primary
2853 |*/ datetime_value_fct
2860 SQL_TOKEN_CURRENT_DATE
2865 | SQL_TOKEN_CURRENT_TIME
2870 | SQL_TOKEN_CURRENT_TIMESTAMP
2877 SQL_TOKEN_AT time_zone_specifier
2884 time_zone_specifier:
2890 /* | SQL_TOKEN_TIME SQL_TOKEN_ZONE interval_value_exp
2904 | datetime_primary time_zone
2921 | interval_term '*' factor
2925 $$->append($2 = newNode("*", SQL_NODE_PUNCTUATION));
2928 | interval_term '/' factor
2932 $$->append($2 = newNode("/", SQL_NODE_PUNCTUATION));
2943 /* | interval_value_exp '+' datetime_term
2947 $$->append($2 = newNode("+", SQL_NODE_PUNCTUATION));
2950 | datetime_value_exp '+' interval_term
2954 $$->append($2 = newNode("+", SQL_NODE_PUNCTUATION));
2957 | datetime_value_exp '-' interval_term
2961 $$->append($2 = newNode("-", SQL_NODE_PUNCTUATION));
2972 | interval_value_exp '+' interval_term
2976 $$->append($2 = newNode("+", SQL_NODE_PUNCTUATION));
2979 | interval_value_exp '-' interval_term
2983 $$->append($2 = newNode("-", SQL_NODE_PUNCTUATION));
2986 | '(' datetime_value_exp '-' datetime_term ')' interval_qualifier
2989 $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
2991 $$->append($3 = newNode("-", SQL_NODE_PUNCTUATION));
2993 $$->append($5 = newNode(")", SQL_NODE_PUNCTUATION));
2998 non_second_datetime_field:
3006 non_second_datetime_field opt_paren_precision
3014 non_second_datetime_field
3015 | SQL_TOKEN_SECOND opt_paren_precision
3023 single_datetime_field:
3024 non_second_datetime_field opt_paren_precision
3030 | SQL_TOKEN_SECOND opt_paren_precision_scale
3039 start_field SQL_TOKEN_TO end_field
3046 | single_datetime_field
3049 function_arg_commalist2:
3050 function_arg
',' function_arg
3051 {$$
= SQL_NEW_COMMALISTRULE
;
3055 function_arg_commalist3:
3056 function_arg
',' function_arg
',' function_arg
3058 $$
= SQL_NEW_COMMALISTRULE
;
3064 function_arg_commalist4:
3065 function_arg
',' function_arg
',' function_arg
',' function_arg
3067 $$
= SQL_NEW_COMMALISTRULE
;
3074 value_exp_commalist:
3076 {$$
= SQL_NEW_COMMALISTRULE
;
3078 | value_exp_commalist
',' value_exp
3081 /* this rule is only valid if we check predicates */
3082 | value_exp_commalist
';' value_exp
3084 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
())
3095 | value_exp comparison value_exp
3102 | value_exp SQL_TOKEN_USING value_exp comparison value_exp
3110 | value_exp SQL_TOKEN_BY value_exp_commalist
3118 function_args_commalist:
3120 {$$
= SQL_NEW_COMMALISTRULE
;
3122 | function_args_commalist
',' function_arg
3125 /* this rule is only valid if we check predicates */
3126 | function_args_commalist
';' function_arg
3128 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
())
3139 num_value_exp
/*[^')']*/
3141 | datetime_value_exp
3160 char_value_exp
'+' char_factor
3164 $$
->append
($2 = newNode
("+", SQL_NODE_PUNCTUATION
));
3167 | value_exp SQL_CONCAT value_exp
3181 SQL_TOKEN_COLLATE table_node
3190 | char_primary collate_clause
3209 SQL_TOKEN_SUBSTRING
'(' bit_value_exp SQL_TOKEN_FROM string_value_exp for_length
')'
3213 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
3218 $$
->append
($7 = newNode
(")", SQL_NODE_PUNCTUATION
));
3236 bit_value_exp '+' bit_factor
3240 $$->append($2 = newNode("+", SQL_NODE_PUNCTUATION));
3253 {$$
= SQL_NEW_RULE
;}
3254 /* value_exp_primary
3285 {$$
= SQL_NEW_RULE
;}
3286 | SQL_TOKEN_FOR value_exp
3294 SQL_TOKEN_SUBSTRING
'(' value_exp SQL_TOKEN_FROM value_exp for_length
')'
3298 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
3303 $$
->append
($7 = newNode
(")", SQL_NODE_PUNCTUATION
));
3305 | SQL_TOKEN_SUBSTRING
'(' value_exp_commalist
')'
3309 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
3311 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));
3319 upper_lower
'(' value_exp
')'
3323 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
3325 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));
3329 SQL_TOKEN_CONVERT
'(' string_value_exp SQL_TOKEN_USING table_node
')'
3333 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
3337 $$
->append
($6 = newNode
(")", SQL_NODE_PUNCTUATION
));
3339 | SQL_TOKEN_CONVERT
'(' cast_operand
',' cast_target
')'
3343 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
3345 $$
->append
($2 = newNode
(",", SQL_NODE_PUNCTUATION
));
3347 $$
->append
($6 = newNode
(")", SQL_NODE_PUNCTUATION
));
3351 SQL_TOKEN_TRANSLATE
'(' string_value_exp SQL_TOKEN_USING table_node
')'
3355 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
3359 $$
->append
($6 = newNode
(")", SQL_NODE_PUNCTUATION
));
3363 SQL_TOKEN_TRIM
'(' trim_operands
')'
3367 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
3369 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));
3373 trim_spec value_exp SQL_TOKEN_FROM value_exp
3381 | trim_spec SQL_TOKEN_FROM value_exp
3388 | value_exp SQL_TOKEN_FROM value_exp
3395 | SQL_TOKEN_FROM value_exp
3407 | SQL_TOKEN_TRAILING
3425 SQL_TOKEN_NAME
'.' schema_name
3429 $$
->append
($2 = newNode
(".", SQL_NODE_PUNCTUATION
));
3432 | SQL_TOKEN_NAME
':' schema_name
3436 $$
->append
($2 = newNode
(":", SQL_NODE_PUNCTUATION
));
3441 SQL_TOKEN_NAME
'.' table_name
3445 $$
->append
($2 = newNode
(".", SQL_NODE_PUNCTUATION
));
3460 /* | table_node '.' column_val %prec '.'
3463 $$->append($2 = newNode(".", SQL_NODE_PUNCTUATION));
3466 | SQL_TOKEN_NAME
'.' column_val %prec
'.'
3469 $$
->append
($2 = newNode
(".", SQL_NODE_PUNCTUATION
));
3472 | SQL_TOKEN_NAME
'.' SQL_TOKEN_NAME
'.' column_val %prec
'.'
3475 $$
->append
($2 = newNode
(".", SQL_NODE_PUNCTUATION
));
3477 $$
->append
($4 = newNode
(".", SQL_NODE_PUNCTUATION
));
3479 | SQL_TOKEN_NAME
'.' SQL_TOKEN_NAME
'.' SQL_TOKEN_NAME
'.' column_val %prec
'.'
3482 $$
->append
($2= newNode
(".", SQL_NODE_PUNCTUATION
));
3484 $$
->append
($4 = newNode
(".", SQL_NODE_PUNCTUATION
));
3486 $$
->append
($6 = newNode
(".", SQL_NODE_PUNCTUATION
));
3489 | SQL_TOKEN_NAME
':' SQL_TOKEN_NAME
'.' SQL_TOKEN_NAME
'.' column_val %prec
'.'
3492 $$
->append
($2= newNode
(":", SQL_NODE_PUNCTUATION
));
3494 $$
->append
($4 = newNode
(".", SQL_NODE_PUNCTUATION
));
3496 $$
->append
($6 = newNode
(".", SQL_NODE_PUNCTUATION
));
3499 /* | SQL_TOKEN_NAME ';' SQL_TOKEN_NAME '.' SQL_TOKEN_NAME '.' column_val
3502 $$->append($2= newNode(";", SQL_NODE_PUNCTUATION));
3504 $$->append($4 = newNode(".", SQL_NODE_PUNCTUATION));
3506 $$->append($6 = newNode(".", SQL_NODE_PUNCTUATION));
3519 $$
->append
($1 = newNode
("*", SQL_NODE_PUNCTUATION
));
3526 {$$
= SQL_NEW_RULE
;}
3527 | SQL_TOKEN_CHARACTER SQL_TOKEN_SET SQL_TOKEN_NAME
3536 {$$
= SQL_NEW_RULE
;}
3540 character_string_type opt_char_set_spec opt_collate_clause
3547 | national_character_string_type opt_collate_clause
3553 | binary_string_type
3559 character_string_type:
3560 SQL_TOKEN_CHARACTER opt_paren_precision
3566 | SQL_TOKEN_CHAR opt_paren_precision
3572 | SQL_TOKEN_CHARACTER SQL_TOKEN_VARYING paren_char_length
3579 | SQL_TOKEN_CHAR SQL_TOKEN_VARYING paren_char_length
3586 | SQL_TOKEN_VARCHAR paren_char_length
3592 | character_large_object_type
3594 opt_paren_precision:
3595 {$$
= SQL_NEW_RULE
;}
3599 '(' SQL_TOKEN_INTNUM
')'
3602 $$
->append
($1 = newNode
("(", SQL_NODE_PUNCTUATION
));
3604 $$
->append
($3 = newNode
(")", SQL_NODE_PUNCTUATION
));
3607 opt_paren_char_large_length:
3608 {$$
= SQL_NEW_RULE
;}
3609 | paren_character_large_object_length
3611 paren_character_large_object_length:
3612 '(' large_object_length
')'
3615 $$
->append
($1 = newNode
("(", SQL_NODE_PUNCTUATION
));
3617 $$
->append
($3 = newNode
(")", SQL_NODE_PUNCTUATION
));
3621 large_object_length:
3622 SQL_TOKEN_INTNUM opt_multiplier
3630 {$$
= SQL_NEW_RULE
;}
3634 $$
->append
($1 = newNode
("K", SQL_NODE_PUNCTUATION
));
3639 $$
->append
($1 = newNode
("M", SQL_NODE_PUNCTUATION
));
3644 $$
->append
($1 = newNode
("G", SQL_NODE_PUNCTUATION
));
3649 $$
->append
($1 = newNode
("T", SQL_NODE_PUNCTUATION
));
3654 $$
->append
($1 = newNode
("P", SQL_NODE_PUNCTUATION
));
3657 character_large_object_type:
3658 SQL_TOKEN_CHARACTER SQL_TOKEN_LARGE SQL_TOKEN_OBJECT opt_paren_char_large_length
3666 | SQL_TOKEN_CHAR SQL_TOKEN_LARGE SQL_TOKEN_OBJECT opt_paren_char_large_length
3674 | SQL_TOKEN_CLOB opt_paren_char_large_length
3681 national_character_string_type:
3682 SQL_TOKEN_NATIONAL SQL_TOKEN_CHARACTER opt_paren_precision
3689 | SQL_TOKEN_NATIONAL SQL_TOKEN_CHAR opt_paren_precision
3696 | SQL_TOKEN_NCHAR opt_paren_precision
3702 | SQL_TOKEN_NATIONAL SQL_TOKEN_CHARACTER SQL_TOKEN_VARYING paren_char_length
3710 | SQL_TOKEN_NATIONAL SQL_TOKEN_CHAR SQL_TOKEN_VARYING paren_char_length
3718 | SQL_TOKEN_NCHAR SQL_TOKEN_VARYING paren_char_length
3725 | national_character_large_object_type
3727 national_character_large_object_type:
3728 SQL_TOKEN_NATIONAL SQL_TOKEN_CHARACTER SQL_TOKEN_LARGE SQL_TOKEN_OBJECT opt_paren_char_large_length
3737 | SQL_TOKEN_NCHAR SQL_TOKEN_LARGE SQL_TOKEN_OBJECT opt_paren_char_large_length
3745 | SQL_TOKEN_NCLOB opt_paren_char_large_length
3753 SQL_TOKEN_BINARY opt_paren_precision
3759 | SQL_TOKEN_BINARY SQL_TOKEN_VARYING paren_char_length
3766 | SQL_TOKEN_VARBINARY paren_char_length
3772 | binary_large_object_string_type
3774 binary_large_object_string_type:
3775 SQL_TOKEN_BINARY SQL_TOKEN_LARGE SQL_TOKEN_OBJECT opt_paren_char_large_length
3783 | SQL_TOKEN_BLOB opt_paren_char_large_length
3792 | approximate_numeric_type
3794 opt_paren_precision_scale:
3795 {$$
= SQL_NEW_RULE
;}
3796 |
'(' SQL_TOKEN_INTNUM
')'
3799 $$
->append
($1 = newNode
("(", SQL_NODE_PUNCTUATION
));
3801 $$
->append
($3 = newNode
(")", SQL_NODE_PUNCTUATION
));
3803 |
'(' SQL_TOKEN_INTNUM
',' SQL_TOKEN_INTNUM
')'
3806 $$
->append
($1 = newNode
("(", SQL_NODE_PUNCTUATION
));
3808 $$
->append
($3 = newNode
(",", SQL_NODE_PUNCTUATION
));
3810 $$
->append
($5 = newNode
(")", SQL_NODE_PUNCTUATION
));
3814 SQL_TOKEN_NUMERIC opt_paren_precision_scale
3820 | SQL_TOKEN_DECIMAL opt_paren_precision_scale
3826 | SQL_TOKEN_DEC opt_paren_precision_scale
3832 | SQL_TOKEN_SMALLINT
3837 approximate_numeric_type:
3838 SQL_TOKEN_FLOAT
'(' SQL_TOKEN_INTNUM
')'
3842 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
3844 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));
3849 | SQL_TOKEN_DOUBLE SQL_TOKEN_PRECISION
3861 | SQL_TOKEN_TIME opt_paren_precision opt_with_or_without_time_zone
3868 | SQL_TOKEN_TIMESTAMP opt_paren_precision opt_with_or_without_time_zone
3876 opt_with_or_without_time_zone:
3877 {$$
= SQL_NEW_RULE
;}
3878 | SQL_TOKEN_WITH SQL_TOKEN_TIME SQL_TOKEN_ZONE
3885 | SQL_TOKEN_WITHOUT SQL_TOKEN_TIME SQL_TOKEN_ZONE
3894 SQL_TOKEN_INTERVAL interval_qualifier
3901 /* the various things you can name */
3905 | SQL_TOKEN_POSITION
3907 sal_uInt32 nNod
= $$
->getRuleID
();
3909 $$
= newNode
(xxx_pGLOBAL_SQLPARSER
->TokenIDToStr
(nNod
), SQL_NODE_NAME
);
3911 | SQL_TOKEN_CHAR_LENGTH
3913 sal_uInt32 nNod
= $$
->getRuleID
();
3915 $$
= newNode
(xxx_pGLOBAL_SQLPARSER
->TokenIDToStr
(nNod
), SQL_NODE_NAME
);
3919 sal_uInt32 nNod
= $$
->getRuleID
();
3921 $$
= newNode
(xxx_pGLOBAL_SQLPARSER
->TokenIDToStr
(nNod
), SQL_NODE_NAME
);
3926 | case_specification
3929 SQL_TOKEN_NULLIF
'(' value_exp_commalist
')'
3933 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
3935 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));
3937 | SQL_TOKEN_COALESCE
'(' value_exp
')'
3941 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
3943 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));
3945 | SQL_TOKEN_COALESCE
'(' value_exp_commalist
')'
3949 $$
->append
($2 = newNode
("(", SQL_NODE_PUNCTUATION
));
3951 $$
->append
($4 = newNode
(")", SQL_NODE_PUNCTUATION
));
3959 SQL_TOKEN_CASE case_operand simple_when_clause_list else_clause SQL_TOKEN_END
3970 SQL_TOKEN_CASE searched_when_clause_list else_clause SQL_TOKEN_END
3979 simple_when_clause_list:
3982 $$
= SQL_NEW_LISTRULE
;
3985 | searched_when_clause_list simple_when_clause
3992 SQL_TOKEN_WHEN when_operand_list SQL_TOKEN_THEN result
4003 {$$
= SQL_NEW_COMMALISTRULE
;
4005 | when_operand_list
',' when_operand
4010 row_value_constructor_elem
4011 | comparison_predicate_part_2
4012 | between_predicate_part_2
4013 | in_predicate_part_2
4014 | character_like_predicate_part_2
4015 | null_predicate_part_2
4017 searched_when_clause_list:
4018 searched_when_clause
4020 $$
= SQL_NEW_LISTRULE
;
4023 | searched_when_clause_list searched_when_clause
4029 searched_when_clause:
4030 SQL_TOKEN_WHEN search_condition SQL_TOKEN_THEN result
4040 {$$
= SQL_NEW_RULE
;}
4041 | SQL_TOKEN_ELSE result
4055 row_value_constructor_elem
4058 cursor: SQL_TOKEN_NAME
4064 module: SQL_TOKEN_NAME
4073 $$
->append
($1 = newNode
(":", SQL_NODE_PUNCTUATION
));
4076 {$$
= SQL_NEW_RULE
; // test
4077 $$
->append
($1 = newNode
("?", SQL_NODE_PUNCTUATION
));}
4078 |
'[' SQL_TOKEN_NAME
']'
4080 $$
->append
($1 = newNode
("[", SQL_NODE_PUNCTUATION
));
4082 $$
->append
($3 = newNode
("]", SQL_NODE_PUNCTUATION
));}
4086 procedure: SQL_TOKEN_NAME
4093 {$$
= SQL_NEW_RULE
;}
4094 | opt_as SQL_TOKEN_NAME
4101 user: SQL_TOKEN_NAME
4104 /* PREDICATECHECK RULES */
4106 search_condition
/* checking predicats */
4108 if
(xxx_pGLOBAL_SQLPARSER
->inPredicateCheck
()) // sql: rule 1
4111 if
( SQL_ISRULE
($$
,search_condition
) )
4113 $$
->insert
(0,newNode
("(", SQL_NODE_PUNCTUATION
));
4114 $$
->append
(newNode
(")", SQL_NODE_PUNCTUATION
));
4120 |
'(' sql
')' /* checking predicats */
4123 SQL_TOKEN_CREATE SQL_TOKEN_TRIGGER trigger_name trigger_action_time trigger_event SQL_TOKEN_ON table_name op_referencing triggered_action
4141 | SQL_TOKEN_REFERENCING transition_table_or_variable_list
4148 trigger_action_time:
4151 | SQL_TOKEN_INSTEAD SQL_TOKEN_OF
4161 | SQL_TOKEN_UPDATE op_trigger_columnlist
4168 op_trigger_columnlist:
4172 | SQL_TOKEN_OF trigger_column_list
4179 trigger_column_list:
4183 op_triggered_action_for triggered_when_clause triggered_SQL_statement
4191 op_triggered_action_for:
4195 | SQL_TOKEN_FOR SQL_TOKEN_EACH trigger_for
4205 | SQL_TOKEN_STATEMENT
4207 triggered_when_clause:
4211 | SQL_TOKEN_WHEN parenthesized_boolean_value_expression
4218 triggered_SQL_statement:
4219 SQL_procedure_statement
4220 | SQL_TOKEN_BEGIN SQL_TOKEN_ATOMIC SQL_procedure_statement_list
';' SQL_TOKEN_END
4226 $$
->append
($4 = newNode
(";", SQL_NODE_PUNCTUATION
));
4230 SQL_procedure_statement_list:
4231 SQL_procedure_statement
4233 $$
= SQL_NEW_LISTRULE
;
4236 | SQL_procedure_statement_list
';' SQL_procedure_statement
4242 SQL_procedure_statement:
4246 transition_table_or_variable_list:
4247 transition_table_or_variable
4249 $$
= SQL_NEW_LISTRULE
;
4252 | transition_table_or_variable_list transition_table_or_variable
4259 transition_table_or_variable:
4260 SQL_TOKEN_OLD opt_row opt_as old_transition_variable_name
4268 | SQL_TOKEN_NEW opt_row opt_as new_transition_variable_name
4276 | SQL_TOKEN_OLD SQL_TOKEN_TABLE opt_as old_transition_table_name
4284 | SQL_TOKEN_NEW SQL_TOKEN_TABLE opt_as new_transition_table_name
4293 old_transition_table_name:
4294 transition_table_name
4296 new_transition_table_name:
4297 transition_table_name
4299 transition_table_name:
4302 old_transition_variable_name:
4305 new_transition_variable_name:
4314 using namespace
::com
::sun
::star
::sdbc
;
4315 using namespace
::com
::sun
::star
::beans
;
4316 using namespace
::com
::sun
::star
::uno
;
4317 using namespace
::com
::sun
::star
::i18n
;
4318 using namespace
::com
::sun
::star
::lang
;
4319 using namespace
::com
::sun
::star
::util
;
4320 using namespace
::osl
;
4321 using namespace
::dbtools
;
4323 //============================================================
4324 //= a helper for static ascii pseudo-unicode strings
4325 //============================================================
4327 struct _ConstAsciiString_
4330 sal_Char
const* str
;
4332 operator rtl
::OUString
() const { return rtl
::OUString
(str
, length
, RTL_TEXTENCODING_ASCII_US
); }
4333 operator
const sal_Char
* () const { return str
; }
4334 operator
::rtl
::OString
() const { return str
; }
4337 #define IMPLEMENT_CONSTASCII_STRING( name, string ) \
4338 _ConstAsciiString_
const name
= { sizeof
(string)-1, string }
4340 IMPLEMENT_CONSTASCII_STRING
(ERROR_STR_GENERAL
, "Syntax error in SQL expression");
4341 IMPLEMENT_CONSTASCII_STRING
(ERROR_STR_VALUE_NO_LIKE
, "The value #1 can not be used with LIKE.");
4342 IMPLEMENT_CONSTASCII_STRING
(ERROR_STR_FIELD_NO_LIKE
, "LIKE can not be used with this field.");
4343 IMPLEMENT_CONSTASCII_STRING
(ERROR_STR_INVALID_COMPARE
, "The entered criterion can not be compared with this field.");
4344 IMPLEMENT_CONSTASCII_STRING
(ERROR_STR_INVALID_DATE_COMPARE
, "The field can not be compared with a date.");
4345 IMPLEMENT_CONSTASCII_STRING
(ERROR_STR_INVALID_REAL_COMPARE
, "The field can not be compared with a floating point number.");
4346 IMPLEMENT_CONSTASCII_STRING
(ERROR_STR_INVALID_INT_COMPARE
, "The field can not be compared with a number.");
4347 IMPLEMENT_CONSTASCII_STRING
(ERROR_STR_INVALID_TABLE
, "The database does not contain a table named \"#\".");
4348 IMPLEMENT_CONSTASCII_STRING
(ERROR_STR_INVALID_TABLE_OR_QUERY
, "The database does contain neither a table nor a query named \"#\".");
4349 IMPLEMENT_CONSTASCII_STRING
(ERROR_STR_INVALID_COLUMN
, "The column \"#1\" is unknown in the table \"#2\".");
4350 IMPLEMENT_CONSTASCII_STRING
(ERROR_STR_INVALID_TABLE_EXIST
, "The database already contains a table or view with name \"#\".");
4351 IMPLEMENT_CONSTASCII_STRING
(ERROR_STR_INVALID_QUERY_EXIST
, "The database already contains a query with name \"#\".");
4353 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_LIKE
, "LIKE");
4354 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_NOT
, "NOT");
4355 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_NULL
, "NULL");
4356 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_TRUE
, "True");
4357 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_FALSE
, "False");
4358 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_IS
, "IS");
4359 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_BETWEEN
, "BETWEEN");
4360 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_OR
, "OR");
4361 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_AND
, "AND");
4362 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_AVG
, "AVG");
4363 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_COUNT
, "COUNT");
4364 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_MAX
, "MAX");
4365 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_MIN
, "MIN");
4366 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_SUM
, "SUM");
4367 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_EVERY
, "EVERY");
4368 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_ANY
, "ANY");
4369 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_SOME
, "SOME");
4370 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_STDDEV_POP
, "STDDEV_POP");
4371 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_STDDEV_SAMP
, "STDDEV_SAMP");
4372 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_VAR_SAMP
, "VAR_SAMP");
4373 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_VAR_POP
, "VAR_POP");
4374 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_COLLECT
, "COLLECT");
4375 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_FUSION
, "FUSION");
4376 IMPLEMENT_CONSTASCII_STRING
(KEY_STR_INTERSECTION
, "INTERSECTION");
4378 IMPLEMENT_CONSTASCII_STRING
(FIELD_STR_NULLDATE
, "NullDate");
4380 IMPLEMENT_CONSTASCII_STRING
(STR_SQL_TOKEN
, "SQL_TOKEN_");
4382 //==========================================================================
4384 //==========================================================================
4385 //-----------------------------------------------------------------------------
4386 OParseContext::OParseContext
()
4390 //-----------------------------------------------------------------------------
4391 OParseContext::~OParseContext
()
4395 //-----------------------------------------------------------------------------
4396 ::rtl
::OUString OParseContext
::getErrorMessage
(ErrorCode _eCode
) const
4398 ::rtl
::OUString aMsg
;
4401 case ERROR_GENERAL
: aMsg
= ERROR_STR_GENERAL
; break
;
4402 case ERROR_VALUE_NO_LIKE
: aMsg
= ERROR_STR_VALUE_NO_LIKE
; break
;
4403 case ERROR_FIELD_NO_LIKE
: aMsg
= ERROR_STR_FIELD_NO_LIKE
; break
;
4404 case ERROR_INVALID_COMPARE
: aMsg
= ERROR_STR_INVALID_COMPARE
; break
;
4405 case ERROR_INVALID_INT_COMPARE
: aMsg
= ERROR_STR_INVALID_INT_COMPARE
; break
;
4406 case ERROR_INVALID_DATE_COMPARE
: aMsg
= ERROR_STR_INVALID_DATE_COMPARE
; break
;
4407 case ERROR_INVALID_REAL_COMPARE
: aMsg
= ERROR_STR_INVALID_REAL_COMPARE
; break
;
4408 case ERROR_INVALID_TABLE
: aMsg
= ERROR_STR_INVALID_TABLE
; break
;
4409 case ERROR_INVALID_TABLE_OR_QUERY
: aMsg
= ERROR_STR_INVALID_TABLE_OR_QUERY
; break
;
4410 case ERROR_INVALID_COLUMN
: aMsg
= ERROR_STR_INVALID_COLUMN
; break
;
4411 case ERROR_INVALID_TABLE_EXIST
: aMsg
= ERROR_STR_INVALID_TABLE_EXIST
; break
;
4412 case ERROR_INVALID_QUERY_EXIST
: aMsg
= ERROR_STR_INVALID_QUERY_EXIST
; break
;
4414 OSL_FAIL
( "OParseContext::getErrorMessage: unknown error code!" );
4420 //-----------------------------------------------------------------------------
4421 ::rtl
::OString OParseContext
::getIntlKeywordAscii
(InternationalKeyCode _eKey
) const
4423 ::rtl
::OString aKeyword
;
4426 case KEY_LIKE
: aKeyword
= KEY_STR_LIKE
; break
;
4427 case KEY_NOT
: aKeyword
= KEY_STR_NOT
; break
;
4428 case KEY_NULL
: aKeyword
= KEY_STR_NULL
; break
;
4429 case KEY_TRUE
: aKeyword
= KEY_STR_TRUE
; break
;
4430 case KEY_FALSE
: aKeyword
= KEY_STR_FALSE
; break
;
4431 case KEY_IS
: aKeyword
= KEY_STR_IS
; break
;
4432 case KEY_BETWEEN
: aKeyword
= KEY_STR_BETWEEN
; break
;
4433 case KEY_OR
: aKeyword
= KEY_STR_OR
; break
;
4434 case KEY_AND
: aKeyword
= KEY_STR_AND
; break
;
4435 case KEY_AVG
: aKeyword
= KEY_STR_AVG
; break
;
4436 case KEY_COUNT
: aKeyword
= KEY_STR_COUNT
; break
;
4437 case KEY_MAX
: aKeyword
= KEY_STR_MAX
; break
;
4438 case KEY_MIN
: aKeyword
= KEY_STR_MIN
; break
;
4439 case KEY_SUM
: aKeyword
= KEY_STR_SUM
; break
;
4440 case KEY_EVERY
: aKeyword
= KEY_STR_EVERY
; break
;
4441 case KEY_ANY
: aKeyword
= KEY_STR_ANY
; break
;
4442 case KEY_SOME
: aKeyword
= KEY_STR_SOME
; break
;
4443 case KEY_STDDEV_POP
: aKeyword
= KEY_STR_STDDEV_POP
; break
;
4444 case KEY_STDDEV_SAMP
: aKeyword
= KEY_STR_STDDEV_SAMP
; break
;
4445 case KEY_VAR_SAMP
: aKeyword
= KEY_STR_VAR_SAMP
; break
;
4446 case KEY_VAR_POP
: aKeyword
= KEY_STR_VAR_POP
; break
;
4447 case KEY_COLLECT
: aKeyword
= KEY_STR_COLLECT
; break
;
4448 case KEY_FUSION
: aKeyword
= KEY_STR_FUSION
; break
;
4449 case KEY_INTERSECTION
:aKeyword
= KEY_STR_INTERSECTION
; break
;
4450 case KEY_NONE
: break
;
4452 OSL_FAIL
( "OParseContext::getIntlKeywordAscii: unknown key!" );
4458 //-----------------------------------------------------------------------------
4459 IParseContext::InternationalKeyCode OParseContext
::getIntlKeyCode
(const ::rtl
::OString
& rToken
) const
4461 static IParseContext
::InternationalKeyCode Intl_TokenID
[] =
4463 KEY_LIKE
, KEY_NOT
, KEY_NULL
, KEY_TRUE
,
4464 KEY_FALSE
, KEY_IS
, KEY_BETWEEN
, KEY_OR
,
4465 KEY_AND
, KEY_AVG
, KEY_COUNT
, KEY_MAX
,
4466 KEY_MIN
, KEY_SUM
, KEY_EVERY
,KEY_ANY
,KEY_SOME
,
4467 KEY_STDDEV_POP
,KEY_STDDEV_SAMP
,KEY_VAR_SAMP
,
4468 KEY_VAR_POP
,KEY_COLLECT
,KEY_FUSION
,KEY_INTERSECTION
4471 sal_uInt32 nCount
= SAL_N_ELEMENTS
( Intl_TokenID
);
4472 for
(sal_uInt32 i
= 0; i
< nCount
; i
++)
4474 ::rtl
::OString aKey
= getIntlKeywordAscii
(Intl_TokenID
[i
]);
4475 if
(rToken.equalsIgnoreAsciiCase
(aKey
))
4476 return Intl_TokenID
[i
];
4482 //------------------------------------------------------------------------------
4483 static Locale
& impl_getLocaleInstance
( )
4485 static Locale s_aLocale
(
4486 ::rtl
::OUString
( "en" ),
4487 ::rtl
::OUString
( "US" ),
4493 //------------------------------------------------------------------------------
4494 Locale OParseContext
::getPreferredLocale
( ) const
4496 return getDefaultLocale
();
4499 //------------------------------------------------------------------------------
4500 const Locale
& OParseContext
::getDefaultLocale
()
4502 return impl_getLocaleInstance
();
4505 //==========================================================================
4507 //==========================================================================
4508 // Der (leider globale) yylval fuer die Uebergabe von
4509 // Werten vom Scanner an den Parser. Die globale Variable
4510 // wird nur kurzzeitig verwendet, der Parser liest die Variable
4511 // sofort nach dem Scanner-Aufruf in eine gleichnamige eigene
4514 const double fMilliSecondsPerDay
= 86400000.0;
4516 //------------------------------------------------------------------------------
4519 //------------------------------------------------------------------
4520 ::rtl
::OUString ConvertLikeToken
(const OSQLParseNode
* pTokenNode
, const OSQLParseNode
* pEscapeNode
, sal_Bool bInternational
)
4522 ::rtl
::OUStringBuffer aMatchStr
(0);
4523 if
(pTokenNode
->isToken
())
4525 sal_Unicode cEscape
= 0;
4526 if
(pEscapeNode
->count
())
4527 cEscape
= pEscapeNode
->getChild
(1)->getTokenValue
().toChar
();
4529 // Platzhalter austauschen
4530 aMatchStr
= pTokenNode
->getTokenValue
();
4531 const sal_Int32 nLen
= aMatchStr.getLength
();
4532 ::rtl
::OUStringBuffer sSearch
,sReplace
;
4533 if
( bInternational
)
4535 sSearch.appendAscii
("%_",2);
4536 sReplace.appendAscii
("*?",2);
4540 sSearch.appendAscii
("*?",2);
4541 sReplace.appendAscii
("%_",2);
4544 bool wasEscape
= false
;
4545 for
(sal_Int32 i
= 0; i
< nLen
; i
++)
4547 const sal_Unicode c
= aMatchStr
[i
];
4548 // SQL standard requires the escape to be followed
4549 // by a meta-character ('%', '_' or itself), else error
4550 // We are more lenient here and let it escape anything.
4551 // Especially since some databases (e.g. Microsoft SQL Server)
4552 // have more meta-characters than the standard, such as e.g. '[' and ']'
4564 if
(c
== sSearch
[0])
4566 else if
(c
== sSearch
[1])
4571 aMatchStr
[i
] = sReplace
[match
];
4575 return aMatchStr.makeStringAndClear
();
4578 //==========================================================================
4580 //==========================================================================
4582 sal_uInt32 OSQLParser
::s_nRuleIDs
[OSQLParseNode
::rule_count
+ 1];
4583 OSQLParser::RuleIDMap OSQLParser
::s_aReverseRuleIDLookup
;
4584 OParseContext OSQLParser
::s_aDefaultContext
;
4586 sal_Int32 OSQLParser
::s_nRefCount
= 0;
4587 // ::osl::Mutex OSQLParser::s_aMutex;
4588 OSQLScanner
* OSQLParser
::s_pScanner
= 0;
4589 OSQLParseNodesGarbageCollector
* OSQLParser
::s_pGarbageCollector
= 0;
4590 ::com
::sun
::star
::uno
::Reference
< ::com
::sun
::star
::i18n
::XLocaleData
> OSQLParser
::s_xLocaleData
= NULL
;
4591 //-----------------------------------------------------------------------------
4592 void setParser
(OSQLParser
* _pParser
)
4594 xxx_pGLOBAL_SQLPARSER
= _pParser
;
4596 // -------------------------------------------------------------------------
4597 void OSQLParser
::setParseTree
(OSQLParseNode
* pNewParseTree
)
4599 ::osl
::MutexGuard aGuard
(getMutex
());
4600 m_pParseTree
= pNewParseTree
;
4602 //-----------------------------------------------------------------------------
4604 /** Delete all comments in a query.
4606 See also getComment()/concatComment() implementation for
4607 OQueryController::translateStatement().
4609 static ::rtl
::OUString delComment
( const ::rtl
::OUString
& rQuery
)
4611 // First a quick search if there is any "--" or "//" or "/*", if not then the whole
4612 // copying loop is pointless.
4613 if
(rQuery.indexOfAsciiL
( "--", 2, 0) < 0 && rQuery.indexOfAsciiL
( "//", 2, 0) < 0 &&
4614 rQuery.indexOfAsciiL
( "/*", 2, 0) < 0)
4617 const sal_Unicode
* pCopy
= rQuery.getStr
();
4618 sal_Int32 nQueryLen
= rQuery.getLength
();
4619 bool bIsText1
= false
; // "text"
4620 bool bIsText2
= false
; // 'text'
4621 bool bComment2
= false
; // /* comment */
4622 bool bComment
= false
; // -- or // comment
4623 ::rtl
::OUStringBuffer aBuf
(nQueryLen
);
4624 for
(sal_Int32 i
=0; i
< nQueryLen
; ++i
)
4628 if
((i
+1) < nQueryLen
)
4630 if
(pCopy
[i
]=='*' && pCopy
[i
+1]=='/')
4638 // comment can't close anymore, actually an error, but..
4642 if
(pCopy
[i
] == '\n')
4646 if
(pCopy
[i
] == '\"' && !bIsText2
)
4647 bIsText1
= !bIsText1
;
4648 else if
(pCopy
[i
] == '\'' && !bIsText1
)
4649 bIsText2
= !bIsText2
;
4650 if
(!bIsText1
&& !bIsText2
&& (i
+1) < nQueryLen
)
4652 if
((pCopy
[i
]=='-' && pCopy
[i
+1]=='-') ||
(pCopy
[i
]=='/' && pCopy
[i
+1]=='/'))
4654 else if
((pCopy
[i
]=='/' && pCopy
[i
+1]=='*'))
4658 if
(!bComment
&& !bComment2
)
4659 aBuf.append
( &pCopy
[i
], 1);
4661 return aBuf.makeStringAndClear
();
4663 //-----------------------------------------------------------------------------
4664 OSQLParseNode
* OSQLParser
::parseTree
(::rtl
::OUString
& rErrorMessage
,
4665 const ::rtl
::OUString
& rStatement
,
4666 sal_Bool bInternational
)
4670 // Guard the parsing
4671 ::osl
::MutexGuard aGuard
(getMutex
());
4675 // delete comments before parsing
4676 ::rtl
::OUString sTemp
= delComment
(rStatement
);
4678 // defines how to scan
4679 s_pScanner
->SetRule
(s_pScanner
->GetSQLRule
()); // initial
4680 s_pScanner
->prepareScan
(sTemp
, m_pContext
, bInternational
);
4682 SQLyylval.pParseNode
= NULL
;
4684 m_pParseTree
= NULL
;
4685 m_sErrorMessage
= ::rtl
::OUString
();
4687 // ... und den Parser anwerfen ...
4688 if
(SQLyyparse
() != 0)
4690 // only set the error message, if it's not already set
4691 if
(!m_sErrorMessage.getLength
())
4692 m_sErrorMessage
= s_pScanner
->getErrorMessage
();
4693 if
(!m_sErrorMessage.getLength
())
4694 m_sErrorMessage
= m_pContext
->getErrorMessage
(IParseContext
::ERROR_GENERAL
);
4696 rErrorMessage
= m_sErrorMessage
;
4698 // clear the garbage collector
4699 (*s_pGarbageCollector
)->clearAndDelete
();
4704 (*s_pGarbageCollector
)->clear
();
4706 // Das Ergebnis liefern (den Root Parse Node):
4708 // OSL_ENSURE(Sdbyyval.pParseNode != NULL,"OSQLParser: Parser hat keinen ParseNode geliefert");
4709 // return Sdbyyval.pParseNode;
4710 // geht nicht wegen Bug in MKS YACC-erzeugtem Code (es wird ein falscher ParseNode
4713 // Stattdessen setzt die Parse-Routine jetzt den Member pParseTree
4714 // - einfach diesen zurueckliefern:
4715 OSL_ENSURE
(m_pParseTree
!= NULL
,"OSQLParser: Parser hat keinen ParseTree geliefert");
4716 return m_pParseTree
;
4719 //-----------------------------------------------------------------------------
4720 ::rtl
::OString OSQLParser
::TokenIDToStr
(sal_uInt32 nTokenID
, const IParseContext
* pContext
)
4722 ::rtl
::OString aStr
;
4725 IParseContext
::InternationalKeyCode eKeyCode
= IParseContext
::KEY_NONE
;
4728 case SQL_TOKEN_LIKE
: eKeyCode
= IParseContext
::KEY_LIKE
; break
;
4729 case SQL_TOKEN_NOT
: eKeyCode
= IParseContext
::KEY_NOT
; break
;
4730 case SQL_TOKEN_NULL
: eKeyCode
= IParseContext
::KEY_NULL
; break
;
4731 case SQL_TOKEN_TRUE
: eKeyCode
= IParseContext
::KEY_TRUE
; break
;
4732 case SQL_TOKEN_FALSE
: eKeyCode
= IParseContext
::KEY_FALSE
; break
;
4733 case SQL_TOKEN_IS
: eKeyCode
= IParseContext
::KEY_IS
; break
;
4734 case SQL_TOKEN_BETWEEN
: eKeyCode
= IParseContext
::KEY_BETWEEN
; break
;
4735 case SQL_TOKEN_OR
: eKeyCode
= IParseContext
::KEY_OR
; break
;
4736 case SQL_TOKEN_AND
: eKeyCode
= IParseContext
::KEY_AND
; break
;
4737 case SQL_TOKEN_AVG
: eKeyCode
= IParseContext
::KEY_AVG
; break
;
4738 case SQL_TOKEN_COUNT
: eKeyCode
= IParseContext
::KEY_COUNT
; break
;
4739 case SQL_TOKEN_MAX
: eKeyCode
= IParseContext
::KEY_MAX
; break
;
4740 case SQL_TOKEN_MIN
: eKeyCode
= IParseContext
::KEY_MIN
; break
;
4741 case SQL_TOKEN_SUM
: eKeyCode
= IParseContext
::KEY_SUM
; break
;
4743 if
( eKeyCode
!= IParseContext
::KEY_NONE
)
4744 aStr
= pContext
->getIntlKeywordAscii
(eKeyCode
);
4747 if
(!aStr.getLength
())
4749 aStr
= yytname
[YYTRANSLATE
(nTokenID
)];
4750 if
(!aStr.compareTo
("SQL_TOKEN_",10))
4751 aStr
= aStr.copy
(10);
4756 #if OSL_DEBUG_LEVEL > 1
4757 ::rtl
::OUString OSQLParser
::RuleIDToStr
(sal_uInt32 nRuleID
)
4759 OSL_ENSURE
(nRuleID
< SAL_N_ELEMENTS
(yytname
), "OSQLParser::RuleIDToStr: Invalid nRuleId!");
4760 return
::rtl
::OUString
::createFromAscii
(yytname
[nRuleID
]);
4764 //-----------------------------------------------------------------------------
4765 sal_uInt32 OSQLParser
::StrToRuleID
(const ::rtl
::OString
& rValue
)
4767 // Search for the given name in yytname and return the index
4768 // (or UNKNOWN_RULE, if not found)
4769 static sal_uInt32 nLen
= SAL_N_ELEMENTS
(yytname
);
4770 for
(sal_uInt32 i
= YYTRANSLATE
(SQL_TOKEN_INVALIDSYMBOL
); i
< (nLen
-1); i
++)
4772 if
(rValue
== yytname
[i
])
4777 return OSQLParseNode
::UNKNOWN_RULE
;
4780 //-----------------------------------------------------------------------------
4781 OSQLParseNode::Rule OSQLParser
::RuleIDToRule
( sal_uInt32 _nRule
)
4783 return s_aReverseRuleIDLookup
[ _nRule
];
4786 //-----------------------------------------------------------------------------
4787 sal_uInt32 OSQLParser
::RuleID
(OSQLParseNode
::Rule eRule
)
4789 return s_nRuleIDs
[(sal_uInt16
)eRule
];
4791 // -------------------------------------------------------------------------
4792 sal_Int16 OSQLParser
::buildNode
(OSQLParseNode
*& pAppend
,OSQLParseNode
* pCompare
,OSQLParseNode
* pLiteral
,OSQLParseNode
* pLiteral2
)
4794 OSQLParseNode
* pColumnRef
= new OSQLInternalNode
(aEmptyString
, SQL_NODE_RULE
,OSQLParser
::RuleID
(OSQLParseNode
::column_ref
));
4795 pColumnRef
->append
(new OSQLInternalNode
(m_sFieldName
,SQL_NODE_NAME
));
4796 OSQLParseNode
* pComp
= NULL
;
4797 if
( SQL_ISTOKEN
( pCompare
, BETWEEN
) && pLiteral2
)
4798 pComp
= new OSQLInternalNode
(aEmptyString
, SQL_NODE_RULE
,OSQLParser
::RuleID
(OSQLParseNode
::between_predicate_part_2
));
4800 pComp
= new OSQLInternalNode
(aEmptyString
, SQL_NODE_RULE
,OSQLParser
::RuleID
(OSQLParseNode
::comparison_predicate
));
4802 pComp
->append
(pColumnRef
);
4803 pComp
->append
(pCompare
);
4804 pComp
->append
(pLiteral
);
4807 pComp
->append
(new OSQLInternalNode
(aEmptyString
, SQL_NODE_KEYWORD
,SQL_TOKEN_AND
));
4808 pComp
->append
(pLiteral2
);
4810 pAppend
->append
(pComp
);
4813 //-----------------------------------------------------------------------------
4814 sal_Int16 OSQLParser
::buildStringNodes
(OSQLParseNode
*& pLiteral
)
4819 if
(SQL_ISRULE
(pLiteral
,set_fct_spec
) || SQL_ISRULE
(pLiteral
,general_set_fct
) || SQL_ISRULE
(pLiteral
,column_ref
)
4820 || SQL_ISRULE
(pLiteral
,subquery
))
4821 return
1; // here I have a function that I can't transform into a string
4823 if
(pLiteral
->getNodeType
() == SQL_NODE_INTNUM || pLiteral
->getNodeType
() == SQL_NODE_APPROXNUM || pLiteral
->getNodeType
() == SQL_NODE_ACCESS_DATE
)
4825 OSQLParseNode
* pParent
= pLiteral
->getParent
();
4827 OSQLParseNode
* pNewNode
= new OSQLInternalNode
(pLiteral
->getTokenValue
(), SQL_NODE_STRING
);
4828 pParent
->replace
(pLiteral
, pNewNode
);
4834 for
(sal_uInt32 i
=0;i
<pLiteral
->count
();++i
)
4836 OSQLParseNode
* pChild
= pLiteral
->getChild
(i
);
4837 buildStringNodes
(pChild
);
4839 if
(SQL_ISRULE
(pLiteral
,term
) || SQL_ISRULE
(pLiteral
,value_exp_primary
))
4841 m_sErrorMessage
= m_pContext
->getErrorMessage
(IParseContext
::ERROR_INVALID_COMPARE
);
4846 //-----------------------------------------------------------------------------
4847 sal_Int16 OSQLParser
::buildComparsionRule
(OSQLParseNode
*& pAppend
,OSQLParseNode
* pLiteral
)
4849 OSQLParseNode
* pComp
= new OSQLInternalNode
(::rtl
::OUString
("="), SQL_NODE_EQUAL
);
4850 return buildPredicateRule
(pAppend
,pLiteral
,pComp
);
4854 //-----------------------------------------------------------------------------
4855 void OSQLParser
::reduceLiteral
(OSQLParseNode
*& pLiteral
, sal_Bool bAppendBlank
)
4857 OSL_ENSURE
(pLiteral
->isRule
(), "This is no ::com::sun::star::chaos::Rule");
4858 OSL_ENSURE
(pLiteral
->count
() == 2, "OSQLParser::ReduceLiteral() Invalid count");
4859 OSQLParseNode
* pTemp
= pLiteral
;
4860 ::rtl
::OUStringBuffer aValue
(pLiteral
->getChild
(0)->getTokenValue
());
4863 aValue.appendAscii
(" ");
4866 aValue.append
(pLiteral
->getChild
(1)->getTokenValue
());
4868 pLiteral
= new OSQLInternalNode
(aValue.makeStringAndClear
(),SQL_NODE_STRING
);
4872 // -------------------------------------------------------------------------
4873 void OSQLParser
::error(const sal_Char
*fmt
)
4875 if
(!m_sErrorMessage.getLength
())
4877 ::rtl
::OUString sStr
(fmt
,strlen
(fmt
),RTL_TEXTENCODING_UTF8
);
4878 ::rtl
::OUString sSQL_TOKEN
("SQL_TOKEN_");
4880 sal_Int32 nPos1
= sStr.indexOf
(sSQL_TOKEN
);
4883 ::rtl
::OUString sFirst
= sStr.copy
(0,nPos1
);
4884 sal_Int32 nPos2
= sStr.indexOf
(sSQL_TOKEN
,nPos1
+1);
4887 ::rtl
::OUString sSecond
= sStr.copy
(nPos1
+sSQL_TOKEN.getLength
(),nPos2
-nPos1
-sSQL_TOKEN.getLength
());
4889 sFirst
+= sStr.copy
(nPos2
+sSQL_TOKEN.getLength
());
4892 sFirst
+= sStr.copy
(nPos1
+sSQL_TOKEN.getLength
());
4894 m_sErrorMessage
= sFirst
;
4897 m_sErrorMessage
= sStr
;
4899 ::rtl
::OUString aError
= s_pScanner
->getErrorMessage
();
4900 if
(aError.getLength
())
4902 m_sErrorMessage
+= ::rtl
::OUString
(", ");
4903 m_sErrorMessage
+= aError
;
4907 // -------------------------------------------------------------------------
4908 int OSQLParser
::SQLlex
()
4910 return s_pScanner
->SQLlex
();
4913 #if defined __SUNPRO_CC
4915 #elif defined _MSC_VER
4916 #pragma warning(pop)