Bump for 3.6-28
[LibreOffice.git] / connectivity / source / parse / sqlbison.y
blob00fb0b3b423e850e3d27448eee001f8b647f38c1
1 %token-table
2 %{
3 //--------------------------------------------------------------------------
4 //
5 // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 //
7 // Copyright 2000, 2010 Oracle and/or its affiliates.
8 //
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 //--------------------------------------------------------------------------
30 #include <vector>
31 #include <string.h>
33 #ifndef _CONNECTIVITY_SQLNODE_HXX
34 #include <connectivity/sqlnode.hxx>
35 #endif
36 #ifndef _CONNECTIVITY_SQLPARSE_HXX
37 #include <connectivity/sqlparse.hxx>
38 #endif
39 #ifndef _CONNECTIVITY_SQLINTERNALNODE_HXX
40 #include <internalnode.hxx>
41 #endif
42 #ifndef _COM_SUN_STAR_LANG_LOCALE_HPP_
43 #include <com/sun/star/lang/Locale.hpp>
44 #endif
45 #ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
46 #include <com/sun/star/sdbc/DataType.hpp>
47 #endif
48 #ifndef _COM_SUN_STAR_UTIL_DATE_HPP_
49 #include <com/sun/star/util/Date.hpp>
50 #endif
51 #ifndef _COM_SUN_STAR_UTIL_DATETIME_HPP_
52 #include <com/sun/star/util/DateTime.hpp>
53 #endif
54 #ifndef _COM_SUN_STAR_UTIL_TIME_HPP_
55 #include <com/sun/star/util/Time.hpp>
56 #endif
57 #ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTER_HPP_
58 #include <com/sun/star/util/XNumberFormatter.hpp>
59 #endif
60 #ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATSSUPPLIER_HPP_
61 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
62 #endif
63 #ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATS_HPP_
64 #include <com/sun/star/util/XNumberFormats.hpp>
65 #endif
66 #ifndef _COM_SUN_STAR_UTIL_NUMBERFORMAT_HPP_
67 #include <com/sun/star/util/NumberFormat.hpp>
68 #endif
69 #ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTYPES_HPP_
70 #include <com/sun/star/util/XNumberFormatTypes.hpp>
71 #endif
72 #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
73 #include <com/sun/star/beans/XPropertySet.hpp>
74 #endif
75 #ifndef _COM_SUN_STAR_I18N_KPARSETYPE_HPP_
76 #include <com/sun/star/i18n/KParseType.hpp>
77 #endif
78 #ifndef _COM_SUN_STAR_I18N_KPARSETOKENS_HPP_
79 #include <com/sun/star/i18n/KParseTokens.hpp>
80 #endif
81 #ifndef _CONNECTIVITY_SQLSCAN_HXX
82 #include "sqlscan.hxx"
83 #endif
84 #ifndef _OSL_DIAGNOSE_H_
85 #include <osl/diagnose.h>
86 #endif
87 #ifndef _DBHELPER_DBCONVERSION_HXX_
88 #include "connectivity/dbconversion.hxx"
89 #endif
90 #include <rtl/ustrbuf.hxx>
91 #include <sal/macros.h>
93 #if defined __SUNPRO_CC
94 #pragma disable_warn
95 #elif defined _MSC_VER
96 #pragma warning(push, 1)
97 #pragma warning(disable:4273 4701 4706)
98 #endif
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
135 #endif
137 #define SQLyyerror(s) \
139 xxx_pGLOBAL_SQLPARSER->error(s); \
142 using namespace connectivity;
143 #define SQLyylex xxx_pGLOBAL_SQLPARSER->SQLlex
145 /* symbolic tokens */
147 %union {
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
190 /* ODBC KEYWORDS */
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
222 // window function
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
227 // LIMIT and OFFSEt
228 %token <pParseNode> SQL_TOKEN_LIMIT SQL_TOKEN_OFFSET SQL_TOKEN_NEXT SQL_TOKEN_ONLY
230 /* operators */
231 %left SQL_TOKEN_NAME
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
239 %left ')'
240 %right '='
241 %right '.'
242 %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 ); }
318 | sql ';'
319 { xxx_pGLOBAL_SQLPARSER->setParseTree( $1 ); }
322 /* schema definition language */
323 /* Note: other ``sql:sal_Unicode() rules appear later in the grammar */
325 sql:
326 manipulative_statement
327 | schema_element
329 $$ = SQL_NEW_RULE;
330 $$->append($1);
334 /***
336 op_authorization:
337 {$$ = SQL_NEW_RULE;}
338 | SQL_TOKEN_AUTHORIZATION user
340 $$ = SQL_NEW_RULE;
341 $$->append($1);
342 $$->append($2);
345 op_schema:
346 {$$ = SQL_NEW_RULE;}
347 | SQL_TOKEN_NAME
348 | SQL_TOKEN_NAME '.' SQL_TOKEN_NAME
350 $$ = SQL_NEW_RULE;
351 $$->append($1);
352 $$->append($2 = newNode(".", SQL_NODE_PUNCTUATION));
353 $$->append($3);
357 schema:
358 SQL_TOKEN_CREATE SQL_TOKEN_SCHEMA op_schema op_authorization opt_schema_element_list
360 $$ = SQL_NEW_RULE;
361 $$->append($1);
362 $$->append($2);
363 $$->append($3);
364 $$->append($4);
365 $$->append($5);
369 opt_schema_element_list:
370 {$$ = SQL_NEW_RULE;}
371 | schema_glement_list
374 schema_element_list:
375 schema_element
376 {$$ = SQL_NEW_LISTRULE;
377 $$->append($1);}
378 | schema_element_list schema_element
379 {$1->append($2);
380 $$ = $1;}
384 schema_element:
385 base_table_def
386 | view_def
387 | privilege_def
388 | trigger_definition
391 base_table_def:
392 SQL_TOKEN_CREATE SQL_TOKEN_TABLE table_node '(' base_table_element_commalist ')'
393 {$$ = SQL_NEW_RULE;
394 $$->append($1);
395 $$->append($2);
396 $$->append($3);
397 $$->append($4 = newNode("(", SQL_NODE_PUNCTUATION));
398 $$->append($5);
399 $$->append($6 = newNode(")", SQL_NODE_PUNCTUATION));}
402 base_table_element_commalist:
403 base_table_element
404 {$$ = SQL_NEW_COMMALISTRULE;
405 $$->append($1);}
406 | base_table_element_commalist ',' base_table_element
407 {$1->append($3);
408 $$ = $1;}
411 base_table_element:
412 column_def
413 | table_constraint_def
416 column_def:
417 column data_type column_def_opt_list
418 {$$ = SQL_NEW_RULE;
419 $$->append($1);
420 $$->append($2);
421 $$->append($3);
425 column_def_opt_list:
426 /* empty */ {$$ = SQL_NEW_LISTRULE;}
427 | column_def_opt_list column_def_opt
428 {$1->append($2);
429 $$ = $1;}
432 nil_fkt:
433 datetime_value_fct
435 unique_spec:
436 SQL_TOKEN_UNIQUE
437 | SQL_TOKEN_PRIMARY SQL_TOKEN_KEY
439 $$ = SQL_NEW_RULE;
440 $$->append($1);
441 $$->append($2);
444 column_def_opt:
445 SQL_TOKEN_NOT SQL_TOKEN_NULL
446 {$$ = SQL_NEW_RULE;
447 $$->append($1);
448 $$->append($2);}
449 | unique_spec
450 | SQL_TOKEN_DEFAULT literal
451 {$$ = SQL_NEW_RULE;
452 $$->append($1);
453 $$->append($2);}
454 | SQL_TOKEN_DEFAULT SQL_TOKEN_NULL
455 {$$ = SQL_NEW_RULE;
456 $$->append($1);
457 $$->append($2);}
458 | SQL_TOKEN_DEFAULT SQL_TOKEN_USER
459 {$$ = SQL_NEW_RULE;
460 $$->append($1);
461 $$->append($2);}
462 | SQL_TOKEN_DEFAULT nil_fkt
464 $$ = SQL_NEW_RULE;
465 $$->append($1);
466 $$->append($2);
468 | SQL_TOKEN_CHECK
469 | SQL_TOKEN_CHECK '(' search_condition ')'
470 {$$ = SQL_NEW_RULE;
471 $$->append($1);
472 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
473 $$->append($3);
474 $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));}
475 | SQL_TOKEN_REFERENCES table_node
476 {$$ = SQL_NEW_RULE;
477 $$->append($1);
478 $$->append($2);}
479 | SQL_TOKEN_REFERENCES table_node '(' column_commalist ')'
480 {$$ = SQL_NEW_RULE;
481 $$->append($1);
482 $$->append($2);
483 $$->append($3 = newNode("(", SQL_NODE_PUNCTUATION));
484 $$->append($4);
485 $$->append($5 = newNode(")", SQL_NODE_PUNCTUATION));}
488 table_constraint_def:
489 unique_spec '(' column_commalist ')'
490 {$$ = SQL_NEW_RULE;
491 $$->append($1);
492 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
493 $$->append($3);
494 $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));}
495 | SQL_TOKEN_FOREIGN SQL_TOKEN_KEY '(' column_commalist ')' SQL_TOKEN_REFERENCES table_node
496 {$$ = SQL_NEW_RULE;
497 $$->append($1);
498 $$->append($2);
499 $$->append($3 = newNode("(", SQL_NODE_PUNCTUATION));
500 $$->append($4);
501 $$->append($5 = newNode(")", SQL_NODE_PUNCTUATION));
502 $$->append($6);
503 $$->append($7);}
504 | SQL_TOKEN_FOREIGN SQL_TOKEN_KEY '(' column_commalist ')' SQL_TOKEN_REFERENCES table_node '(' column_commalist ')'
505 {$$ = SQL_NEW_RULE;
506 $$->append($1);
507 $$->append($2);
508 $$->append($3 = newNode("(", SQL_NODE_PUNCTUATION));
509 $$->append($4);
510 $$->append($5 = newNode(")", SQL_NODE_PUNCTUATION));
511 $$->append($6);
512 $$->append($7);
513 $$->append($8 = newNode("(", SQL_NODE_PUNCTUATION));
514 $$->append($9);
515 $$->append($10 = newNode(")", SQL_NODE_PUNCTUATION));}
516 | SQL_TOKEN_CHECK '(' search_condition ')'
517 {$$ = SQL_NEW_RULE;
518 $$->append($1);
519 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
520 $$->append($3);
521 $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));}
523 op_column_commalist:
524 /* empty */ {$$ = SQL_NEW_RULE;}
525 | '(' column_commalist ')'
526 {$$ = SQL_NEW_RULE;
527 $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
528 $$->append($2);
529 $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
532 column_commalist:
533 column_commalist ',' column
534 {$1->append($3);
535 $$ = $1;}
536 | column
537 {$$ = SQL_NEW_COMMALISTRULE;
538 $$->append($1);}
541 view_def:
542 SQL_TOKEN_CREATE SQL_TOKEN_VIEW table_node opt_column_commalist SQL_TOKEN_AS select_statement opt_with_check_option
543 {$$ = SQL_NEW_RULE;
544 $$->append($1);
545 $$->append($2);
546 $$->append($3);
547 $$->append($4);
548 $$->append($5);
549 $$->append($6);
550 $$->append($7);}
553 opt_with_check_option:
554 /* empty */ {$$ = SQL_NEW_RULE;}
555 | SQL_TOKEN_WITH SQL_TOKEN_CHECK SQL_TOKEN_OPTION
556 {$$ = SQL_NEW_RULE;
557 $$->append($1);
558 $$->append($2);
559 $$->append($3);}
562 opt_column_commalist:
563 /* empty */ {$$ = SQL_NEW_RULE;}
564 | '(' column_commalist ')'
565 {$$ = SQL_NEW_RULE;
566 $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
567 $$->append($2);
568 $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));}
571 privilege_def:
572 SQL_TOKEN_GRANT privileges SQL_TOKEN_ON table_node SQL_TOKEN_TO grantee_commalist
573 opt_with_grant_option
574 {$$ = SQL_NEW_RULE;
575 $$->append($1);
576 $$->append($2);
577 $$->append($3);
578 $$->append($4);
579 $$->append($5);
580 $$->append($6);
581 $$->append($7);}
584 opt_with_grant_option:
585 /* empty */ {$$ = SQL_NEW_RULE;}
586 | SQL_TOKEN_WITH SQL_TOKEN_GRANT SQL_TOKEN_OPTION
587 {$$ = SQL_NEW_RULE;
588 $$->append($1);
589 $$->append($2);
590 $$->append($3);}
593 privileges:
594 SQL_TOKEN_ALL SQL_TOKEN_PRIVILEGES
595 {$$ = SQL_NEW_RULE;
596 $$->append($1);
597 $$->append($2);}
598 | operation_commalist
601 operation_commalist:
602 operation
603 {$$ = SQL_NEW_COMMALISTRULE;
604 $$->append($1);}
605 | operation_commalist ',' operation
606 {$1->append($3);
607 $$ = $1;}
610 operation:
611 SQL_TOKEN_SELECT
612 | SQL_TOKEN_INSERT opt_column_commalist
613 {$$ = SQL_NEW_RULE;
614 $$->append($1);
615 $$->append($2);}
616 | SQL_TOKEN_DELETE
617 | SQL_TOKEN_UPDATE opt_column_commalist
618 {$$ = SQL_NEW_RULE;
619 $$->append($1);
620 $$->append($2);}
621 | SQL_TOKEN_REFERENCES opt_column_commalist
622 {$$ = SQL_NEW_RULE;
623 $$->append($1);
624 $$->append($2);}
625 | SQL_TOKEN_USAGE
629 grantee_commalist:
630 grantee
631 {$$ = SQL_NEW_COMMALISTRULE;
632 $$->append($1);}
633 | grantee_commalist ',' grantee
634 {$1->append($3);
635 $$ = $1;}
638 grantee:
639 SQL_TOKEN_PUBLIC
640 | user
643 /* module language */
645 opt_order_by_clause:
646 /* empty */ {$$ = SQL_NEW_RULE;}
647 | SQL_TOKEN_ORDER SQL_TOKEN_BY ordering_spec_commalist
648 {$$ = SQL_NEW_RULE;
649 $$->append($1);
650 $$->append($2);
651 $$->append($3);}
654 ordering_spec_commalist:
655 ordering_spec
656 {$$ = SQL_NEW_COMMALISTRULE;
657 $$->append($1);}
658 | ordering_spec_commalist ',' ordering_spec
659 {$1->append($3);
660 $$ = $1;}
663 ordering_spec:
664 /* SQL_TOKEN_INTNUM opt_asc_desc
665 {$$ = SQL_NEW_RULE;
666 $$->append($1);
667 $$->append($2);}
669 predicate opt_asc_desc
670 {$$ = SQL_NEW_RULE;
671 $$->append($1);
672 $$->append($2);}
674 | row_value_constructor_elem opt_asc_desc
675 {$$ = SQL_NEW_RULE;
676 $$->append($1);
677 $$->append($2);}
680 opt_asc_desc:
681 {$$ = SQL_NEW_RULE;}
682 | SQL_TOKEN_ASC
683 | SQL_TOKEN_DESC
687 /***
688 manipulative_statement_list:
689 manipulative_statement
690 {$$ = SQL_NEW_LISTRULE;
691 $$->append($1);}
692 | manipulative_statement_list manipulative_statement
693 {$1->append($2);
694 $$ = $1;}
696 ***/
698 sql_not:
699 {$$ = SQL_NEW_RULE;}
700 | SQL_TOKEN_NOT
703 /* manipulative statements */
705 manipulative_statement:
706 commit_statement
707 /* | delete_statement_positioned*/
708 | delete_statement_searched
709 | fetch_statement
710 | insert_statement
711 | rollback_statement
712 | select_statement_into
713 /* | update_statement_positioned*/
714 | update_statement_searched
715 | union_statement
716 | '{' odbc_call_spec '}'
718 $$ = SQL_NEW_RULE;
719 $$->append($1 = newNode("{", SQL_NODE_PUNCTUATION));
720 $$->append($2);
721 $$->append($3 = newNode("}", SQL_NODE_PUNCTUATION));
725 union_statement:
726 select_statement
727 | union_statement SQL_TOKEN_UNION all select_statement
729 $$ = SQL_NEW_RULE;
730 $$->append($1);
731 $$->append($2);
732 $$->append($3);
733 $$->append($4);
736 commit_statement:
737 SQL_TOKEN_COMMIT SQL_TOKEN_WORK
738 {$$ = SQL_NEW_RULE;
739 $$->append($1);
740 $$->append($2);}
743 delete_statement_positioned:
744 SQL_TOKEN_DELETE SQL_TOKEN_FROM table_node SQL_TOKEN_WHERE SQL_TOKEN_CURRENT SQL_TOKEN_OF cursor
745 {$$ = SQL_NEW_RULE;
746 $$->append($1);
747 $$->append($2);
748 $$->append($3);
749 $$->append($4);
750 $$->append($5);
751 $$->append($6);
752 $$->append($7);}
755 delete_statement_searched:
756 SQL_TOKEN_DELETE SQL_TOKEN_FROM table_node opt_where_clause
757 {$$ = SQL_NEW_RULE;
758 $$->append($1);
759 $$->append($2);
760 $$->append($3);
761 $$->append($4);}
764 fetch_statement:
765 SQL_TOKEN_FETCH cursor SQL_TOKEN_INTO target_commalist
766 {$$ = SQL_NEW_RULE;
767 $$->append($1);
768 $$->append($2);
769 $$->append($3);
770 $$->append($4);}
773 insert_statement:
774 SQL_TOKEN_INSERT SQL_TOKEN_INTO table_node opt_column_commalist query_exp
775 {$$ = SQL_NEW_RULE;
776 $$->append($1);
777 $$->append($2);
778 $$->append($3);
779 $$->append($4);
780 $$->append($5);}
782 values_or_query_spec:
783 SQL_TOKEN_VALUES '(' table_value_const_list ')'
784 {$$ = SQL_NEW_RULE;
785 $$->append($1);
786 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
787 $$->append($3);
788 $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
792 table_value_const_list:
793 row_value_constructor
794 {$$ = SQL_NEW_COMMALISTRULE;
795 $$->append($1);}
796 | table_value_const_list ',' row_value_constructor
797 {$1->append($3);
798 $$ = $1;}
800 row_value_const_list:
801 row_value_constructor_elem
802 {$$ = SQL_NEW_COMMALISTRULE;
803 $$->append($1);}
804 | row_value_const_list ',' row_value_constructor_elem
805 {$1->append($3);
806 $$ = $1;}
808 row_value_constructor:
809 row_value_constructor_elem
810 /* | '(' row_value_const_list ')'
812 $$ = SQL_NEW_RULE;
813 $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
814 $$->append($2);
815 $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
819 row_value_constructor_elem:
820 value_exp /*[^')']*/
821 | SQL_TOKEN_DEFAULT
825 rollback_statement:
826 SQL_TOKEN_ROLLBACK SQL_TOKEN_WORK
827 {$$ = SQL_NEW_RULE;
828 $$->append($1);
829 $$->append($2);}
833 /* INTO target_commalist herausgenommen */
834 select_statement_into:
835 SQL_TOKEN_SELECT opt_all_distinct selection SQL_TOKEN_INTO target_commalist table_exp
836 {$$ = SQL_NEW_RULE;
837 $$->append($1);
838 $$->append($2);
839 $$->append($3);
840 $$->append($4);
841 $$->append($5);
842 $$->append($6); }
845 opt_all_distinct:
846 {$$ = SQL_NEW_RULE;}
847 | SQL_TOKEN_ALL
848 | SQL_TOKEN_DISTINCT
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
855 {$$ = SQL_NEW_RULE;
856 $$->append($1);
857 $$->append($2);
858 $$->append($3);
859 $$->append($4);
860 $$->append($5);
861 $$->append($6);
862 $$->append($7);
863 $$->append($8);}
866 assignment_commalist:
867 assignment
868 {$$ = SQL_NEW_COMMALISTRULE;
869 $$->append($1);}
870 | assignment_commalist ',' assignment
871 {$1->append($3);
872 $$ = $1;}
875 assignment:
876 column SQL_EQUAL update_source
877 {$$ = SQL_NEW_RULE;
878 $$->append($1);
879 $$->append($2);
880 $$->append($3);}
882 update_source:
883 value_exp
884 | SQL_TOKEN_DEFAULT
886 update_statement_searched:
887 SQL_TOKEN_UPDATE table_node SQL_TOKEN_SET assignment_commalist opt_where_clause
888 {$$ = SQL_NEW_RULE;
889 $$->append($1);
890 $$->append($2);
891 $$->append($3);
892 $$->append($4);
893 $$->append($5);}
896 target_commalist:
897 target
898 {$$ = SQL_NEW_COMMALISTRULE;
899 $$->append($1);}
900 | target_commalist ',' target
901 {$1->append($3);
902 $$ = $1;}
905 target:
906 parameter_ref
909 opt_where_clause:
910 /* empty */ {$$ = SQL_NEW_RULE;}
911 | where_clause
914 /* query expressions */
916 query_term:
917 non_join_query_term
919 $$ = SQL_NEW_RULE;
920 $$->append($1);
923 /* SELECT STATEMENT */
924 select_statement:
925 SQL_TOKEN_SELECT opt_all_distinct selection table_exp
927 $$ = SQL_NEW_RULE;
928 $$->append($1);
929 $$->append($2);
930 $$->append($3);
931 $$->append($4);
935 selection:
938 $$ = SQL_NEW_RULE;
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
950 $$ = SQL_NEW_RULE;
951 $$->append($1);
952 $$->append($2);
953 $$->append($3);
956 opt_fetch_first_row_count:
957 /* empty */ {$$ = SQL_NEW_RULE;}
958 | fetch_first_row_count
960 first_or_next:
961 SQL_TOKEN_FIRST
962 | SQL_TOKEN_NEXT
964 row_or_rows:
965 SQL_TOKEN_ROW
966 | SQL_TOKEN_ROWS
968 opt_fetch_first_clause:
969 /* empty */ {$$ = SQL_NEW_RULE;}
970 | fetch_first_clause
972 fetch_first_clause:
973 SQL_TOKEN_FETCH first_or_next opt_fetch_first_row_count row_or_rows SQL_TOKEN_ONLY
975 $$ = SQL_NEW_RULE;
976 $$->append($1);
977 $$->append($2);
978 $$->append($3);
979 $$->append($4);
980 $$->append($5);
983 offset_row_count:
984 literal
986 fetch_first_row_count:
987 literal
990 opt_limit_offset_clause:
991 /* empty */ {$$ = SQL_NEW_RULE;}
992 | limit_offset_clause
994 opt_offset:
995 /* empty */ {$$ = SQL_NEW_RULE;}
996 | SQL_TOKEN_OFFSET SQL_TOKEN_INTNUM
998 $$ = SQL_NEW_RULE;
999 $$->append($1);
1000 $$->append($2);
1003 limit_offset_clause:
1004 SQL_TOKEN_LIMIT SQL_TOKEN_INTNUM opt_offset
1006 $$ = SQL_NEW_RULE;
1007 $$->append($1);
1008 $$->append($2);
1009 $$->append($3);
1012 table_exp:
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
1015 $$ = SQL_NEW_RULE;
1016 $$->append($1);
1017 $$->append($2);
1018 $$->append($3);
1019 $$->append($4);
1020 $$->append($5);
1021 $$->append($6);
1022 $$->append($7);
1023 $$->append($8);
1024 $$->append($9);
1028 from_clause:
1029 SQL_TOKEN_FROM table_ref_commalist
1030 {$$ = SQL_NEW_RULE;
1031 $$->append($1);
1032 $$->append($2);}
1035 table_ref_commalist:
1037 table_ref
1038 {$$ = SQL_NEW_COMMALISTRULE;
1039 $$->append($1);}
1040 | table_ref_commalist ',' table_ref
1041 {$1->append($3);
1042 $$ = $1;}
1045 opt_as:
1046 /* empty */ {$$ = SQL_NEW_RULE;}
1047 | SQL_TOKEN_AS
1049 opt_row:
1050 /* empty */ {$$ = SQL_NEW_RULE;}
1051 | SQL_TOKEN_ROW
1053 table_primary_as_range_column:
1054 {$$ = SQL_NEW_RULE;}
1055 | opt_as SQL_TOKEN_NAME op_column_commalist
1056 {$$ = SQL_NEW_RULE;
1057 $$->append($1);
1058 $$->append($2);
1059 $$->append($3);
1062 table_ref:
1063 table_node table_primary_as_range_column
1065 $$ = SQL_NEW_RULE;
1066 $$->append($1);
1067 $$->append($2);
1069 | subquery range_variable op_column_commalist
1071 $$ = SQL_NEW_RULE;
1072 $$->append($1);
1073 $$->append($2);
1074 $$->append($3);
1076 | joined_table
1077 | '{' SQL_TOKEN_OJ joined_table '}'
1079 $$ = SQL_NEW_RULE;
1080 $$->append($1 = newNode("{", SQL_NODE_PUNCTUATION));
1081 $$->append($2);
1082 $$->append($3);
1083 $$->append($4 = newNode("}", SQL_NODE_PUNCTUATION));
1085 | '(' joined_table ')'
1087 $$ = SQL_NEW_RULE;
1088 $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
1089 $$->append($2);
1090 $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
1093 where_clause:
1094 SQL_TOKEN_WHERE search_condition
1095 {$$ = SQL_NEW_RULE;
1096 $$->append($1);
1097 $$->append($2);}
1100 opt_group_by_clause:
1101 /* empty */ {$$ = SQL_NEW_RULE;}
1102 | SQL_TOKEN_GROUP SQL_TOKEN_BY column_ref_commalist
1103 {$$ = SQL_NEW_RULE;
1104 $$->append($1);
1105 $$->append($2);
1106 $$->append($3);}
1109 column_ref_commalist:
1110 column_ref
1111 {$$ = SQL_NEW_COMMALISTRULE;
1112 $$->append($1);}
1113 | set_fct_spec
1114 {$$ = SQL_NEW_COMMALISTRULE;
1115 $$->append($1);}
1116 | column_ref_commalist ',' column_ref
1117 {$1->append($3);
1118 $$ = $1;}
1119 | column_ref_commalist ',' set_fct_spec
1120 {$1->append($3);
1121 $$ = $1;}
1124 opt_having_clause:
1125 /* empty */ {$$ = SQL_NEW_RULE;}
1126 | SQL_TOKEN_HAVING search_condition
1127 {$$ = SQL_NEW_RULE;
1128 $$->append($1);
1129 $$->append($2);}
1132 /* search conditions */
1133 truth_value:
1134 SQL_TOKEN_TRUE
1135 | SQL_TOKEN_FALSE
1136 | SQL_TOKEN_UNKNOWN
1137 | SQL_TOKEN_NULL
1139 boolean_primary:
1140 predicate
1141 | '(' search_condition ')'
1142 { // boolean_primary: rule 2
1143 $$ = SQL_NEW_RULE;
1144 $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
1145 $$->append($2);
1146 $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
1148 | row_value_constructor_elem /*[^')' ',']*/
1150 if(xxx_pGLOBAL_SQLPARSER->inPredicateCheck())// boolean_primary: rule 3
1152 $$ = SQL_NEW_RULE;
1153 sal_Int16 nErg = xxx_pGLOBAL_SQLPARSER->buildComparsionRule($$,$1);
1154 if(nErg == 1)
1156 OSQLParseNode* pTemp = $$;
1157 $$ = pTemp->removeAt((sal_uInt32)0);
1158 delete pTemp;
1160 else
1162 delete $$;
1163 if(nErg)
1164 YYERROR;
1165 else
1166 YYABORT;
1169 else
1170 YYERROR;
1173 parenthesized_boolean_value_expression:
1174 '(' search_condition ')'
1175 { // boolean_primary: rule 2
1176 $$ = SQL_NEW_RULE;
1177 $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
1178 $$->append($2);
1179 $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
1182 boolean_test:
1183 boolean_primary
1184 | boolean_primary SQL_TOKEN_IS sql_not truth_value
1186 $$ = SQL_NEW_RULE;
1187 $$->append($1);
1188 $$->append($2);
1189 $$->append($3);
1190 $$->append($4);
1193 boolean_factor:
1194 boolean_test
1195 | SQL_TOKEN_NOT boolean_test
1196 { // boolean_factor: rule 1
1197 $$ = SQL_NEW_RULE;
1198 $$->append($1);
1199 $$->append($2);
1202 boolean_term:
1203 boolean_factor
1204 | boolean_term SQL_TOKEN_AND boolean_factor
1206 $$ = SQL_NEW_RULE; // boolean_term: rule 1
1207 $$->append($1);
1208 $$->append($2);
1209 $$->append($3);
1212 search_condition:
1213 boolean_term
1214 | search_condition SQL_TOKEN_OR boolean_term
1216 $$ = SQL_NEW_RULE; // search_condition
1217 $$->append($1);
1218 $$->append($2);
1219 $$->append($3);
1222 predicate:
1223 comparison_predicate
1224 | between_predicate
1225 | all_or_any_predicate
1226 | existence_test
1227 | unique_test
1228 | test_for_null
1229 | in_predicate
1230 | like_predicate
1232 comparison_predicate_part_2:
1233 comparison row_value_constructor
1235 $$ = SQL_NEW_RULE; // comparison_predicate: rule 1
1236 $$->append($1);
1237 $$->append($2);
1239 comparison_predicate:
1240 row_value_constructor comparison row_value_constructor
1242 $$ = SQL_NEW_RULE; // comparison_predicate: rule 1
1243 $$->append($1);
1244 $$->append($2);
1245 $$->append($3);
1247 | comparison row_value_constructor
1249 if(xxx_pGLOBAL_SQLPARSER->inPredicateCheck()) // comparison_predicate: rule 2
1251 $$ = SQL_NEW_RULE;
1252 sal_Int16 nErg = xxx_pGLOBAL_SQLPARSER->buildPredicateRule($$,$2,$1);
1253 if(nErg == 1)
1255 OSQLParseNode* pTemp = $$;
1256 $$ = pTemp->removeAt((sal_uInt32)0);
1257 delete pTemp;
1259 else
1261 delete $$;
1262 YYABORT;
1265 else
1267 YYERROR;
1271 comparison:
1272 SQL_LESS
1273 | SQL_NOTEQUAL
1274 | SQL_EQUAL
1275 | SQL_GREAT
1276 | SQL_LESSEQ
1277 | SQL_GREATEQ
1278 | SQL_TOKEN_IS sql_not SQL_TOKEN_DISTINCT SQL_TOKEN_FROM
1280 $$ = SQL_NEW_RULE;
1281 $$->append($1);
1282 $$->append($2);
1283 $$->append($3);
1284 $$->append($4);
1286 | SQL_TOKEN_IS sql_not
1288 $$ = SQL_NEW_RULE;
1289 $$->append($1);
1290 $$->append($2);
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
1298 $$ = SQL_NEW_RULE;
1300 sal_Int16 nErg = xxx_pGLOBAL_SQLPARSER->buildPredicateRule($$,$3,$2,$5);
1301 if(nErg == 1)
1303 OSQLParseNode* pTemp = $$;
1304 $$ = pTemp->removeAt((sal_uInt32)0);
1305 OSQLParseNode* pColumnRef = $$->removeAt((sal_uInt32)0);
1306 $$->insert(0,$1);
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;
1312 delete pTemp;
1313 delete $4;
1315 else
1317 delete $$;
1318 YYABORT;
1321 else
1323 $$ = SQL_NEW_RULE; // between_predicate: rule 1
1324 $$->append($1);
1325 $$->append($2);
1326 $$->append($3);
1327 $$->append($4);
1328 $$->append($5);
1331 between_predicate:
1332 row_value_constructor between_predicate_part_2
1334 $$ = SQL_NEW_RULE; // between_predicate: rule 1
1335 $$->append($1);
1336 $$->append($2);
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
1344 $$->append($1);
1345 $$->append($2);
1346 $$->append($3);
1347 $$->append($4);
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
1354 $$->append($1);
1355 $$->append($2);
1356 $$->append($3);
1357 $$->append($4);
1360 like_predicate:
1361 row_value_constructor character_like_predicate_part_2
1363 $$ = SQL_NEW_RULE; // like_predicate: rule 1
1364 $$->append($1);
1365 $$->append($2);
1367 | row_value_constructor other_like_predicate_part_2
1369 $$ = SQL_NEW_RULE; // like_predicate: rule 3
1370 $$->append($1);
1371 $$->append($2);
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));
1380 $$ = SQL_NEW_RULE;
1381 $$->append(pColumnRef);
1382 $$->append($1);
1383 OSQLParseNode* p2nd = $1->removeAt(2);
1384 OSQLParseNode* p3rd = $1->removeAt(2);
1385 if ( !xxx_pGLOBAL_SQLPARSER->buildLikeRule($1,p2nd,p3rd) )
1387 delete $$;
1388 YYABORT;
1390 $1->append(p3rd);
1392 else
1393 YYERROR;
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));
1402 $$ = SQL_NEW_RULE;
1403 $$->append(pColumnRef);
1404 $$->append($1);
1405 OSQLParseNode* p2nd = $1->removeAt(2);
1406 OSQLParseNode* p3rd = $1->removeAt(2);
1407 if ( !xxx_pGLOBAL_SQLPARSER->buildLikeRule($1,p2nd,p3rd) )
1409 delete $$;
1410 YYABORT;
1412 $1->append(p3rd);
1414 else
1415 YYERROR;
1419 opt_escape:
1420 /* empty */ {$$ = SQL_NEW_RULE;}
1421 | SQL_TOKEN_ESCAPE string_value_exp
1422 {$$ = SQL_NEW_RULE;
1423 $$->append($1);
1424 $$->append($2);}
1425 | '{' SQL_TOKEN_ESCAPE SQL_TOKEN_STRING '}'
1427 $$ = SQL_NEW_RULE;
1428 $$->append($1 = newNode("{", SQL_NODE_PUNCTUATION));
1429 $$->append($2);
1430 $$->append($3);
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
1439 $$->append($1);
1440 $$->append($2);
1441 $$->append($3);
1444 test_for_null:
1445 row_value_constructor null_predicate_part_2
1447 $$ = SQL_NEW_RULE; // test_for_null: rule 1
1448 $$->append($1);
1449 $$->append($2);
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));
1458 $$ = SQL_NEW_RULE;
1459 $$->append(pColumnRef);
1460 $$->append($1);
1462 else
1463 YYERROR;
1466 in_predicate_value:
1467 subquery
1468 {$$ = SQL_NEW_RULE;
1469 $$->append($1);
1471 | '(' value_exp_commalist ')'
1472 {$$ = SQL_NEW_RULE;
1473 $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
1474 $$->append($2);
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
1482 $$->append($1);
1483 $$->append($2);
1484 $$->append($3);
1487 in_predicate:
1488 row_value_constructor in_predicate_part_2
1490 $$ = SQL_NEW_RULE;// in_predicate: rule 1
1491 $$->append($1);
1492 $$->append($2);
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));
1501 $$ = SQL_NEW_RULE;
1502 $$->append(pColumnRef);
1503 $$->append($1);
1505 else
1506 YYERROR;
1509 quantified_comparison_predicate_part_2:
1510 comparison any_all_some subquery
1512 $$ = SQL_NEW_RULE;
1513 $$->append($1);
1514 $$->append($2);
1515 $$->append($3);
1518 all_or_any_predicate:
1519 row_value_constructor quantified_comparison_predicate_part_2
1521 $$ = SQL_NEW_RULE;
1522 $$->append($1);
1523 $$->append($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));
1532 $$ = SQL_NEW_RULE;
1533 $$->append(pColumnRef);
1534 $$->append($1);
1536 else
1537 YYERROR;
1541 any_all_some:
1542 SQL_TOKEN_ANY
1543 | SQL_TOKEN_ALL
1544 | SQL_TOKEN_SOME
1547 existence_test:
1548 SQL_TOKEN_EXISTS subquery
1549 {$$ = SQL_NEW_RULE;
1550 $$->append($1);
1551 $$->append($2);}
1553 unique_test:
1554 SQL_TOKEN_UNIQUE subquery
1555 {$$ = SQL_NEW_RULE;
1556 $$->append($1);
1557 $$->append($2);}
1559 subquery:
1560 '(' query_exp ')'
1561 {$$ = SQL_NEW_RULE;
1562 $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
1563 $$->append($2);
1564 $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));}
1567 /* scalar expressions */
1568 scalar_exp_commalist:
1569 select_sublist
1571 $$ = SQL_NEW_COMMALISTRULE;
1572 $$->append($1);
1574 | scalar_exp_commalist ',' select_sublist
1576 $1->append($3);
1577 $$ = $1;
1580 select_sublist:
1581 /* table_node '.' '*'
1583 $$ = SQL_NEW_RULE;
1584 $$->append($1);
1585 $$->append($2 = newNode(".", SQL_NODE_PUNCTUATION));
1586 $$->append($3 = newNode("*", SQL_NODE_PUNCTUATION));
1589 derived_column
1593 parameter_ref:
1594 parameter
1598 op_like:
1601 $$ = newNode("*", SQL_NODE_PUNCTUATION);
1603 | '?'
1605 $$ = newNode("?", SQL_NODE_PUNCTUATION);
1607 | op_like '*'
1609 $$ = SQL_NEW_RULE;
1610 $$->append($1);
1611 $$->append($2 = newNode("*", SQL_NODE_PUNCTUATION));
1612 xxx_pGLOBAL_SQLPARSER->reduceLiteral($$, sal_False);
1614 | op_like '?'
1616 $$ = SQL_NEW_RULE;
1617 $$->append($1);
1618 $$->append($2 = newNode("?", SQL_NODE_PUNCTUATION));
1619 xxx_pGLOBAL_SQLPARSER->reduceLiteral($$, sal_False);
1624 literal:
1625 /* SQL_TOKEN_STRING
1626 | */SQL_TOKEN_INT
1627 | SQL_TOKEN_REAL_NUM
1628 | SQL_TOKEN_INTNUM
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())
1636 $$ = SQL_NEW_RULE;
1637 $$->append($1);
1638 $$->append($2);
1639 xxx_pGLOBAL_SQLPARSER->reduceLiteral($$, sal_True);
1641 else
1642 YYERROR;
1644 | literal SQL_TOKEN_INT
1646 if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck())
1648 $$ = SQL_NEW_RULE;
1649 $$->append($1);
1650 $$->append($2);
1651 xxx_pGLOBAL_SQLPARSER->reduceLiteral($$, sal_True);
1653 else
1654 YYERROR;
1656 | literal SQL_TOKEN_REAL_NUM
1658 if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck())
1660 $$ = SQL_NEW_RULE;
1661 $$->append($1);
1662 $$->append($2);
1663 xxx_pGLOBAL_SQLPARSER->reduceLiteral($$, sal_True);
1665 else
1666 YYERROR;
1668 | literal SQL_TOKEN_APPROXNUM
1670 if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck())
1672 $$ = SQL_NEW_RULE;
1673 $$->append($1);
1674 $$->append($2);
1675 xxx_pGLOBAL_SQLPARSER->reduceLiteral($$, sal_True);
1677 else
1678 YYERROR;
1682 /* miscellaneous */
1683 as_clause:
1684 /* empty */ {$$ = SQL_NEW_RULE;}
1685 | SQL_TOKEN_AS column
1687 $$ = SQL_NEW_RULE;
1688 $$->append($1);
1689 $$->append($2);
1691 | column
1693 position_exp:
1694 SQL_TOKEN_POSITION '(' value_exp SQL_TOKEN_IN value_exp ')'
1696 $$ = SQL_NEW_RULE;
1697 $$->append($1);
1698 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
1699 $$->append($3);
1700 $$->append($4);
1701 $$->append($5);
1702 $$->append($6 = newNode(")", SQL_NODE_PUNCTUATION));
1704 | SQL_TOKEN_POSITION '(' value_exp_commalist ')'
1706 $$ = SQL_NEW_RULE;
1707 $$->append($1);
1708 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
1709 $$->append($3);
1710 $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
1713 num_value_fct:
1714 position_exp
1715 | extract_exp
1716 | length_exp
1718 char_length_exp:
1719 SQL_TOKEN_CHAR_LENGTH '(' value_exp ')'
1721 $$ = SQL_NEW_RULE;
1722 $$->append($1);
1723 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
1724 $$->append($3);
1725 $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
1727 | SQL_TOKEN_SQL_TOKEN_INTNUM '(' value_exp ')'
1729 $$ = SQL_NEW_RULE;
1730 $$->append($1);
1731 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
1732 $$->append($3);
1733 $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
1737 octet_length_exp:
1738 SQL_TOKEN_OCTET_LENGTH '(' value_exp ')'
1740 $$ = SQL_NEW_RULE;
1741 $$->append($1);
1742 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
1743 $$->append($3);
1744 $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
1747 bit_length_exp:
1748 SQL_TOKEN_BIT_LENGTH '(' value_exp ')'
1750 $$ = SQL_NEW_RULE;
1751 $$->append($1);
1752 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
1753 $$->append($3);
1754 $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
1757 length_exp:
1758 char_length_exp
1760 $$ = SQL_NEW_RULE;
1761 $$->append($1);
1763 | octet_length_exp
1765 $$ = SQL_NEW_RULE;
1766 $$->append($1);
1768 | bit_length_exp
1770 $$ = SQL_NEW_RULE;
1771 $$->append($1);
1774 datetime_field:
1775 non_second_datetime_field
1777 $$ = SQL_NEW_RULE;
1778 $$->append($1);
1780 | SQL_TOKEN_SECOND
1782 $$ = SQL_NEW_RULE;
1783 $$->append($1);
1786 extract_field:
1787 time_zone_field
1788 | datetime_field
1789 | value_exp
1791 time_zone_field:
1792 SQL_TOKEN_TIMEZONE_HOUR
1794 $$ = SQL_NEW_RULE;
1795 $$->append($1);
1797 | SQL_TOKEN_TIMEZONE_MINUTE
1799 $$ = SQL_NEW_RULE;
1800 $$->append($1);
1803 extract_source:
1804 datetime_value_exp
1806 $$ = SQL_NEW_RULE;
1807 $$->append($1);
1809 /* | interval_value_exp
1811 $$ = SQL_NEW_RULE;
1812 $$->append($1);
1813 } */
1815 extract_exp:
1816 SQL_TOKEN_EXTRACT '(' extract_field SQL_TOKEN_FROM value_exp ')'
1818 $$ = SQL_NEW_RULE;
1819 $$->append($1);
1820 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
1821 $$->append($3);
1822 $$->append($4);
1823 $$->append($5);
1824 $$->append($6 = newNode(")", SQL_NODE_PUNCTUATION));
1827 unsigned_value_spec:
1828 general_value_spec
1829 | literal
1831 general_value_spec:
1832 parameter
1833 | SQL_TOKEN_USER
1834 | SQL_TOKEN_NULL
1835 | SQL_TOKEN_FALSE
1836 | SQL_TOKEN_TRUE
1837 | SQL_TOKEN_VALUE
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
1847 set_fct_spec:
1848 general_set_fct
1849 | '{' odbc_fct_spec '}'
1851 $$ = SQL_NEW_RULE;
1852 $$->append($1 = newNode("{", SQL_NODE_PUNCTUATION));
1853 $$->append($2);
1854 $$->append($3 = newNode("}", SQL_NODE_PUNCTUATION));
1856 | function_name '(' ')'
1858 $$ = SQL_NEW_RULE;
1859 $$->append($1);
1860 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
1861 $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
1863 | function_name0 '(' ')'
1865 $$ = SQL_NEW_RULE;
1866 $$->append($1);
1867 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
1868 $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
1870 | function_name1 '(' function_arg ')'
1872 $$ = SQL_NEW_RULE;
1873 $$->append($1);
1874 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
1875 $$->append($3);
1876 $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
1878 | function_name2 '(' function_arg_commalist2 ')'
1880 $$ = SQL_NEW_RULE;
1881 $$->append($1);
1882 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
1883 $$->append($3);
1884 $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
1886 | function_name3 '(' function_arg_commalist3 ')'
1888 $$ = SQL_NEW_RULE;
1889 $$->append($1);
1890 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
1891 $$->append($3);
1892 $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
1894 | string_function_4Argument '(' function_arg_commalist4 ')'
1896 $$ = SQL_NEW_RULE;
1897 $$->append($1);
1898 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
1899 $$->append($3);
1900 $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
1902 | function_name '(' function_args_commalist ')'
1904 $$ = SQL_NEW_RULE;
1905 $$->append($1);
1906 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
1907 $$->append($3);
1908 $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
1910 | function_name12 '(' function_args_commalist ')'
1912 if ( $3->count() == 1 || $3->count() == 2 )
1914 $$ = SQL_NEW_RULE;
1915 $$->append($1);
1916 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
1917 $$->append($3);
1918 $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
1920 else
1921 YYERROR;
1923 | function_name23 '(' function_args_commalist ')'
1925 if ( $3->count() == 2 || $3->count() == 3)
1927 $$ = SQL_NEW_RULE;
1928 $$->append($1);
1929 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
1930 $$->append($3);
1931 $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
1933 else
1934 YYERROR;
1937 function_name0:
1938 date_function_0Argument
1939 | numeric_function_0Argument
1941 function_name1:
1942 string_function_1Argument
1943 | date_function_1Argument
1944 | numeric_function_1Argument
1946 function_name2:
1947 string_function_2Argument
1948 | numeric_function_2Argument
1950 function_name12:
1951 SQL_TOKEN_ROUND
1952 | SQL_TOKEN_WEEK
1953 | SQL_TOKEN_LOGF
1954 | SQL_TOKEN_LOG
1956 function_name23:
1957 SQL_TOKEN_LOCATE
1958 | SQL_TOKEN_DATEDIFF
1960 function_name3:
1961 string_function_3Argument
1963 function_name:
1964 string_function
1965 | date_function
1966 | numeric_function
1967 | SQL_TOKEN_NAME
1969 string_function_1Argument:
1970 SQL_TOKEN_LENGTH
1971 | SQL_TOKEN_ASCII
1972 | SQL_TOKEN_LCASE
1973 | SQL_TOKEN_LTRIM
1974 | SQL_TOKEN_RTRIM
1975 | SQL_TOKEN_SPACE
1976 | SQL_TOKEN_UCASE
1979 string_function_2Argument:
1980 SQL_TOKEN_REPEAT
1981 | SQL_TOKEN_LEFT
1982 | SQL_TOKEN_RIGHT
1984 string_function_3Argument:
1985 SQL_TOKEN_REPLACE
1987 string_function_4Argument:
1988 SQL_TOKEN_INSERT
1991 string_function:
1992 SQL_TOKEN_CHAR
1993 | SQL_TOKEN_CONCAT
1994 | SQL_TOKEN_DIFFERENCE
1995 | SQL_TOKEN_LOCATE_2
1996 | SQL_TOKEN_SOUNDEX
1998 date_function_0Argument:
1999 SQL_TOKEN_CURDATE
2000 | SQL_TOKEN_CURTIME
2001 | SQL_TOKEN_NOW
2003 date_function_1Argument:
2004 SQL_TOKEN_DAYOFWEEK
2005 | SQL_TOKEN_DAYOFMONTH
2006 | SQL_TOKEN_DAYOFYEAR
2007 | SQL_TOKEN_MONTH
2008 | SQL_TOKEN_DAYNAME
2009 | SQL_TOKEN_MONTHNAME
2010 | SQL_TOKEN_QUARTER
2011 | SQL_TOKEN_HOUR
2012 | SQL_TOKEN_MINUTE
2013 | SQL_TOKEN_SECOND
2014 | SQL_TOKEN_YEAR
2015 | SQL_TOKEN_DAY
2016 | SQL_TOKEN_TIMEVALUE
2017 | SQL_TOKEN_DATEVALUE
2020 date_function:
2021 SQL_TOKEN_TIMESTAMPADD
2022 | SQL_TOKEN_TIMESTAMPDIFF
2024 numeric_function_0Argument:
2025 SQL_TOKEN_PI
2027 numeric_function_1Argument:
2028 SQL_TOKEN_ABS
2029 | SQL_TOKEN_ACOS
2030 | SQL_TOKEN_ASIN
2031 | SQL_TOKEN_ATAN
2032 | SQL_TOKEN_CEILING
2033 | SQL_TOKEN_COS
2034 | SQL_TOKEN_COT
2035 | SQL_TOKEN_DEGREES
2036 | SQL_TOKEN_FLOOR
2037 | SQL_TOKEN_SIGN
2038 | SQL_TOKEN_SIN
2039 | SQL_TOKEN_SQRT
2040 | SQL_TOKEN_TAN
2041 | SQL_TOKEN_EXP
2042 | SQL_TOKEN_LOG10
2043 | SQL_TOKEN_LN
2044 | SQL_TOKEN_RADIANS
2045 | SQL_TOKEN_ROUNDMAGIC
2047 numeric_function_2Argument:
2048 SQL_TOKEN_ATAN2
2049 | SQL_TOKEN_MOD
2050 | SQL_TOKEN_POWER
2052 numeric_function:
2053 SQL_TOKEN_RAND
2054 | SQL_TOKEN_TRUNCATE
2057 window_function:
2058 window_function_type SQL_TOKEN_OVER window_name_or_specification
2060 $$ = SQL_NEW_RULE;
2061 $$->append($1);
2062 $$->append($2);
2063 $$->append($3);
2066 window_function_type :
2067 rank_function_type '(' ')'
2069 $$ = SQL_NEW_RULE;
2070 $$->append($1);
2071 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
2072 $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
2074 | SQL_TOKEN_ROW_NUMBER '(' ')'
2076 $$ = SQL_NEW_RULE;
2077 $$->append($1);
2078 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
2079 $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
2081 | general_set_fct
2082 | ntile_function
2083 | lead_or_lag_function
2084 | first_or_last_value_function
2085 | nth_value_function
2087 ntile_function :
2088 SQL_TOKEN_NTILE '(' number_of_tiles ')'
2090 $$ = SQL_NEW_RULE;
2091 $$->append($1);
2092 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
2093 $$->append($3);
2094 $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
2097 dynamic_parameter_specification:
2098 parameter
2100 simple_value_specification:
2101 literal
2103 number_of_tiles :
2104 simple_value_specification
2105 | dynamic_parameter_specification
2107 opt_lead_or_lag_function:
2108 /* empty */ {$$ = SQL_NEW_RULE;}
2109 | ',' offset
2111 $$ = SQL_NEW_RULE;
2112 $$->append($1 = newNode(",", SQL_NODE_PUNCTUATION));
2113 $$->append($2);
2115 | ',' offset ',' default_expression
2117 $$ = SQL_NEW_RULE;
2118 $$->append($1 = newNode(",", SQL_NODE_PUNCTUATION));
2119 $$->append($2);
2120 $$->append($3 = newNode(",", SQL_NODE_PUNCTUATION));
2121 $$->append($4);
2124 opt_null_treatment:
2125 /* empty */ {$$ = SQL_NEW_RULE;}
2126 | null_treatment
2129 lead_or_lag_function:
2130 lead_or_lag '(' lead_or_lag_extent opt_lead_or_lag_function ')' opt_null_treatment
2132 $$ = SQL_NEW_RULE;
2133 $$->append($1);
2134 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
2135 $$->append($3);
2136 $$->append($4);
2137 $$->append($5 = newNode(")", SQL_NODE_PUNCTUATION));
2138 $$->append($6);
2141 lead_or_lag:
2142 SQL_TOKEN_LEAD
2143 | SQL_TOKEN_LAG
2145 lead_or_lag_extent:
2146 value_exp
2148 offset:
2149 SQL_TOKEN_INTNUM
2151 default_expression:
2152 value_exp
2154 null_treatment:
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
2161 $$ = SQL_NEW_RULE;
2162 $$->append($1);
2163 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
2164 $$->append($3);
2165 $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
2166 $$->append($5);
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
2177 nth_value_function:
2178 SQL_TOKEN_NTH_VALUE '(' value_exp ',' nth_row ')' opt_from_first_or_last opt_null_treatment
2180 $$ = SQL_NEW_RULE;
2181 $$->append($1);
2182 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
2183 $$->append($3);
2184 $$->append($4 = newNode(",", SQL_NODE_PUNCTUATION));
2185 $$->append($5);
2186 $$->append($6 = newNode(")", SQL_NODE_PUNCTUATION));
2187 $$->append($7);
2188 $$->append($8);
2191 nth_row:
2192 simple_value_specification
2193 | dynamic_parameter_specification
2195 from_first_or_last:
2196 SQL_TOKEN_FROM SQL_TOKEN_FIRST
2198 $$ = SQL_NEW_RULE;
2199 $$->append($1);
2200 $$->append($2);
2202 | SQL_TOKEN_FROM SQL_TOKEN_LAST
2204 $$ = SQL_NEW_RULE;
2205 $$->append($1);
2206 $$->append($2);
2209 window_name:
2210 SQL_TOKEN_NAME
2212 window_name_or_specification:
2213 window_name
2214 | in_line_window_specification
2216 in_line_window_specification:
2217 window_specification
2219 opt_window_clause:
2220 /* empty */ {$$ = SQL_NEW_RULE;}
2221 | window_clause
2223 window_clause:
2224 SQL_TOKEN_WINDOW window_definition_list
2226 $$ = SQL_NEW_RULE;
2227 $$->append($1);
2228 $$->append($2);
2231 window_definition_list:
2232 window_definition_list ',' window_definition
2233 {$1->append($3);
2234 $$ = $1;}
2235 | window_definition
2236 {$$ = SQL_NEW_COMMALISTRULE;
2237 $$->append($1);}
2239 window_definition:
2240 new_window_name SQL_TOKEN_AS window_specification
2242 $$ = SQL_NEW_RULE;
2243 $$->append($1);
2244 $$->append($2);
2245 $$->append($3);
2248 new_window_name:
2249 window_name
2251 window_specification:
2252 '(' window_specification_details ')'
2254 $$ = SQL_NEW_RULE;
2255 $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
2256 $$->append($2);
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
2275 opt_order_by_clause
2276 opt_window_frame_clause
2278 existing_window_name:
2279 window_name
2281 window_partition_clause:
2282 SQL_TOKEN_PARTITION SQL_TOKEN_BY window_partition_column_reference_list
2284 $$ = SQL_NEW_RULE;
2285 $$->append($1);
2286 $$->append($2);
2287 $$->append($3);
2290 window_partition_column_reference_list:
2291 window_partition_column_reference_list ',' window_partition_column_reference
2292 {$1->append($3);
2293 $$ = $1;}
2294 | window_partition_column_reference
2295 {$$ = SQL_NEW_COMMALISTRULE;
2296 $$->append($1);}
2298 window_partition_column_reference:
2299 column_ref opt_collate_clause
2301 $$ = SQL_NEW_RULE;
2302 $$->append($1);
2303 $$->append($2);
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
2313 $$ = SQL_NEW_RULE;
2314 $$->append($1);
2315 $$->append($2);
2316 $$->append($3);
2319 window_frame_units:
2320 SQL_TOKEN_ROWS
2321 | SQL_TOKEN_RANGE
2323 window_frame_extent:
2324 window_frame_start
2325 | window_frame_between
2327 window_frame_start:
2328 SQL_TOKEN_UNBOUNDED SQL_TOKEN_PRECEDING
2330 $$ = SQL_NEW_RULE;
2331 $$->append($1);
2332 $$->append($2);
2334 | window_frame_preceding
2335 | SQL_TOKEN_CURRENT SQL_TOKEN_ROW
2337 $$ = SQL_NEW_RULE;
2338 $$->append($1);
2339 $$->append($2);
2342 window_frame_preceding:
2343 unsigned_value_spec SQL_TOKEN_PRECEDING
2345 $$ = SQL_NEW_RULE;
2346 $$->append($1);
2347 $$->append($2);
2350 window_frame_between:
2351 SQL_TOKEN_BETWEEN window_frame_bound_1 SQL_TOKEN_AND window_frame_bound_2
2353 $$ = SQL_NEW_RULE;
2354 $$->append($1);
2355 $$->append($2);
2356 $$->append($3);
2357 $$->append($4);
2360 window_frame_bound_1:
2361 window_frame_bound
2363 window_frame_bound_2:
2364 window_frame_bound
2366 window_frame_bound:
2367 window_frame_start
2368 | SQL_TOKEN_UNBOUNDED SQL_TOKEN_FOLLOWING
2370 $$ = SQL_NEW_RULE;
2371 $$->append($1);
2372 $$->append($2);
2374 | window_frame_following
2376 window_frame_following:
2377 unsigned_value_spec SQL_TOKEN_FOLLOWING
2379 $$ = SQL_NEW_RULE;
2380 $$->append($1);
2381 $$->append($2);
2384 window_frame_exclusion:
2385 SQL_TOKEN_EXCLUDE SQL_TOKEN_CURRENT SQL_TOKEN_ROW
2387 $$ = SQL_NEW_RULE;
2388 $$->append($1);
2389 $$->append($2);
2390 $$->append($3);
2392 | SQL_TOKEN_EXCLUDE SQL_TOKEN_GROUP
2394 $$ = SQL_NEW_RULE;
2395 $$->append($1);
2396 $$->append($2);
2398 | SQL_TOKEN_EXCLUDE SQL_TOKEN_TIES
2400 $$ = SQL_NEW_RULE;
2401 $$->append($1);
2402 $$->append($2);
2404 | SQL_TOKEN_EXCLUDE SQL_TOKEN_NO SQL_TOKEN_OTHERS
2406 $$ = SQL_NEW_RULE;
2407 $$->append($1);
2408 $$->append($2);
2409 $$->append($3);
2412 op_parameter:
2413 {$$ = SQL_NEW_RULE;}
2414 | '?' SQL_EQUAL
2416 $$ = SQL_NEW_RULE;
2417 $$->append($1 = newNode("?", SQL_NODE_PUNCTUATION));
2418 $$->append($2);
2421 odbc_call_spec:
2422 op_parameter SQL_TOKEN_CALL table_node op_odbc_call_parameter
2424 $$ = SQL_NEW_RULE;
2425 $$->append($1);
2426 $$->append($2);
2427 $$->append($3);
2428 $$->append($4);
2432 op_odbc_call_parameter:
2433 {$$ = SQL_NEW_RULE;}
2434 | '(' odbc_parameter_commalist ')'
2436 $$ = SQL_NEW_RULE;
2437 $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
2438 $$->append($2);
2439 $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
2443 odbc_parameter_commalist:
2444 odbc_parameter
2445 {$$ = SQL_NEW_COMMALISTRULE;
2446 $$->append($1);}
2447 | odbc_parameter_commalist ',' odbc_parameter
2449 $1->append($3);
2450 $$ = $1;
2453 odbc_parameter:
2454 /* empty */ {$$ = SQL_NEW_RULE;}
2455 | literal
2456 | parameter
2459 odbc_fct_spec:
2460 odbc_fct_type SQL_TOKEN_STRING
2462 $$ = SQL_NEW_RULE;
2463 $$->append($1);
2464 $$->append($2);
2466 | SQL_TOKEN_FN set_fct_spec
2468 $$ = SQL_NEW_RULE;
2469 $$->append($1);
2470 $$->append($2);
2474 odbc_fct_type:
2475 SQL_TOKEN_D
2476 | SQL_TOKEN_T
2477 | SQL_TOKEN_TS
2480 general_set_fct:
2481 set_fct_type '(' opt_all_distinct function_arg ')'
2483 $$ = SQL_NEW_RULE;
2484 $$->append($1);
2485 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
2486 $$->append($3);
2487 $$->append($4);
2488 $$->append($5 = newNode(")", SQL_NODE_PUNCTUATION));
2490 | SQL_TOKEN_COUNT '(' '*' ')'
2492 $$ = SQL_NEW_RULE;
2493 $$->append($1);
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 ')'
2500 $$ = SQL_NEW_RULE;
2501 $$->append($1);
2502 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
2503 $$->append($3);
2504 $$->append($4);
2505 $$->append($5 = newNode(")", SQL_NODE_PUNCTUATION));
2507 | ordered_set_function
2508 | array_aggregate_function
2510 set_fct_type:
2511 SQL_TOKEN_AVG
2512 | SQL_TOKEN_MAX
2513 | SQL_TOKEN_MIN
2514 | SQL_TOKEN_SUM
2515 | SQL_TOKEN_EVERY
2516 | SQL_TOKEN_ANY
2517 | SQL_TOKEN_SOME
2518 | SQL_TOKEN_STDDEV_POP
2519 | SQL_TOKEN_STDDEV_SAMP
2520 | SQL_TOKEN_VAR_SAMP
2521 | SQL_TOKEN_VAR_POP
2522 | SQL_TOKEN_COLLECT
2523 | SQL_TOKEN_FUSION
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
2534 $$ = SQL_NEW_RULE;
2535 $$->append($1);
2536 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
2537 $$->append($3);
2538 $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
2539 $$->append($5);
2541 | rank_function_type '(' hypothetical_set_function_value_expression_list SQL_TOKEN_BY value_exp_commalist ')' within_group_specification
2543 $$ = SQL_NEW_RULE;
2544 $$->append($1);
2545 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
2546 $$->append($3);
2547 $$->append($4);
2548 $$->append($5);
2549 $$->append($6 = newNode(")", SQL_NODE_PUNCTUATION));
2550 $$->append($7);
2554 within_group_specification:
2556 $$ = SQL_NEW_RULE;
2558 | SQL_TOKEN_WITHIN SQL_TOKEN_GROUP '(' opt_order_by_clause ')'
2560 $$ = SQL_NEW_RULE;
2561 $$->append($1);
2562 $$->append($2);
2563 $$->append($3 = newNode("(", SQL_NODE_PUNCTUATION));
2564 $$->append($4);
2565 $$->append($5 = newNode(")", SQL_NODE_PUNCTUATION));
2568 hypothetical_set_function_value_expression_list:
2569 value_exp_commalist
2572 inverse_distribution_function:
2573 inverse_distribution_function_type '('inverse_distribution_function_argument ')' within_group_specification
2575 $$ = SQL_NEW_RULE;
2576 $$->append($1);
2577 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
2578 $$->append($3);
2579 $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
2582 inverse_distribution_function_argument:
2583 num_value_exp
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 ')'
2593 $$ = SQL_NEW_RULE;
2594 $$->append($1);
2595 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
2596 $$->append($3);
2597 $$->append($4);
2598 $$->append($5 = newNode(")", SQL_NODE_PUNCTUATION));
2602 rank_function_type:
2603 SQL_TOKEN_RANK
2604 | SQL_TOKEN_DENSE_RANK
2605 | SQL_TOKEN_PERCENT_RANK
2606 | SQL_TOKEN_CUME_DIST
2608 outer_join_type:
2609 SQL_TOKEN_LEFT %prec SQL_TOKEN_LEFT
2611 $$ = SQL_NEW_RULE;
2612 $$->append($1);
2614 | SQL_TOKEN_RIGHT %prec SQL_TOKEN_RIGHT
2616 $$ = SQL_NEW_RULE;
2617 $$->append($1);
2619 | SQL_TOKEN_FULL %prec SQL_TOKEN_FULL
2621 $$ = SQL_NEW_RULE;
2622 $$->append($1);
2625 join_condition:
2626 SQL_TOKEN_ON search_condition
2628 $$ = SQL_NEW_RULE;
2629 $$->append($1);
2630 $$->append($2);
2633 join_spec:
2634 join_condition
2635 | named_columns_join
2637 join_type:
2638 /* empty */ {$$ = SQL_NEW_RULE;}
2639 | SQL_TOKEN_INNER
2641 $$ = SQL_NEW_RULE;
2642 $$->append($1);
2644 | outer_join_type
2645 | outer_join_type SQL_TOKEN_OUTER
2647 $$ = SQL_NEW_RULE;
2648 $$->append($1);
2649 $$->append($2);
2652 cross_union:
2653 table_ref SQL_TOKEN_CROSS SQL_TOKEN_JOIN table_ref
2655 $$ = SQL_NEW_RULE;
2656 $$->append($1);
2657 $$->append($2);
2658 $$->append($3);
2659 $$->append($4);
2663 qualified_join:
2664 /* wenn SQL_TOKEN_NATURAL, dann keine join_spec */
2665 table_ref SQL_TOKEN_NATURAL join_type SQL_TOKEN_JOIN table_ref
2667 $$ = SQL_NEW_RULE;
2668 $$->append($1);
2669 $$->append($2);
2670 $$->append($3);
2671 $$->append($4);
2672 $$->append($5);
2674 | table_ref join_type SQL_TOKEN_JOIN table_ref join_spec
2676 $$ = SQL_NEW_RULE;
2677 $$->append($1);
2678 $$->append($2);
2679 $$->append($3);
2680 $$->append($4);
2681 $$->append($5);
2683 | cross_union
2685 joined_table:
2686 qualified_join
2688 named_columns_join:
2689 SQL_TOKEN_USING '(' column_commalist ')'
2691 $$ = SQL_NEW_RULE;
2692 $$->append($1);
2693 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
2694 $$->append($3);
2695 $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
2698 simple_table:
2699 select_statement
2700 | values_or_query_spec
2703 non_join_query_primary:
2704 simple_table
2705 | '(' non_join_query_exp ')'
2707 $$ = SQL_NEW_RULE;
2708 $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
2709 $$->append($2);
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
2717 $$ = SQL_NEW_RULE;
2718 $$->append($1);
2719 $$->append($2);
2720 $$->append($3);
2721 $$->append($4);
2724 query_primary:
2725 non_join_query_primary
2727 non_join_query_exp:
2728 non_join_query_term
2729 | query_exp SQL_TOKEN_UNION all query_term
2731 $$ = SQL_NEW_RULE;
2732 $$->append($1);
2733 $$->append($2);
2734 $$->append($3);
2735 $$->append($4);
2737 | query_exp SQL_TOKEN_EXCEPT all query_term
2739 $$ = SQL_NEW_RULE;
2740 $$->append($1);
2741 $$->append($2);
2742 $$->append($3);
2743 $$->append($4);
2746 all:
2747 /* empty*/ {$$ = SQL_NEW_RULE;}
2748 | SQL_TOKEN_ALL
2750 query_exp:
2751 non_join_query_exp /*[^')']*/
2753 scalar_subquery:
2754 subquery
2756 cast_operand:
2757 value_exp
2759 cast_target:
2760 table_node
2761 | data_type
2763 cast_spec:
2764 SQL_TOKEN_CAST '(' cast_operand SQL_TOKEN_AS cast_target ')'
2766 $$ = SQL_NEW_RULE;
2767 $$->append($1);
2768 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
2769 $$->append($3);
2770 $$->append($4);
2771 $$->append($5);
2772 $$->append($6 = newNode(")", SQL_NODE_PUNCTUATION));
2775 value_exp_primary:
2776 unsigned_value_spec
2777 | column_ref
2778 | set_fct_spec
2779 | scalar_subquery
2780 | case_expression
2781 | window_function
2782 | '(' value_exp ')'
2784 $$ = SQL_NEW_RULE;
2785 $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
2786 $$->append($2);
2787 $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
2789 | cast_spec
2792 num_primary:
2793 value_exp_primary
2794 | num_value_fct
2796 factor:
2797 num_primary
2798 | '-' num_primary %prec SQL_TOKEN_UMINUS
2800 $$ = SQL_NEW_RULE;
2801 $$->append($1 = newNode("-", SQL_NODE_PUNCTUATION));
2802 $$->append($2);
2804 | '+' num_primary %prec SQL_TOKEN_UMINUS
2806 $$ = SQL_NEW_RULE;
2807 $$->append($1 = newNode("+", SQL_NODE_PUNCTUATION));
2808 $$->append($2);
2812 term:
2813 factor
2814 | term '*' factor
2816 $$ = SQL_NEW_RULE;
2817 $$->append($1);
2818 $$->append($2 = newNode("*", SQL_NODE_PUNCTUATION));
2819 $$->append($3);
2821 | term '/' factor
2823 $$ = SQL_NEW_RULE;
2824 $$->append($1);
2825 $$->append($2 = newNode("/", SQL_NODE_PUNCTUATION));
2826 $$->append($3);
2830 num_value_exp:
2831 term
2832 | num_value_exp '+' term
2834 $$ = SQL_NEW_RULE;
2835 $$->append($1);
2836 $$->append($2 = newNode("+", SQL_NODE_PUNCTUATION));
2837 $$->append($3);
2839 | num_value_exp '-' term
2841 $$ = SQL_NEW_RULE;
2842 $$->append($1);
2843 $$->append($2 = newNode("-", SQL_NODE_PUNCTUATION));
2844 $$->append($3);
2847 datetime_primary:
2848 /* value_exp_primary
2850 $$ = SQL_NEW_RULE;
2851 $$->append($1);
2853 |*/ datetime_value_fct
2855 $$ = SQL_NEW_RULE;
2856 $$->append($1);
2859 datetime_value_fct:
2860 SQL_TOKEN_CURRENT_DATE
2862 $$ = SQL_NEW_RULE;
2863 $$->append($1);
2865 | SQL_TOKEN_CURRENT_TIME
2867 $$ = SQL_NEW_RULE;
2868 $$->append($1);
2870 | SQL_TOKEN_CURRENT_TIMESTAMP
2872 $$ = SQL_NEW_RULE;
2873 $$->append($1);
2876 time_zone:
2877 SQL_TOKEN_AT time_zone_specifier
2879 $$ = SQL_NEW_RULE;
2880 $$->append($1);
2881 $$->append($2);
2884 time_zone_specifier:
2885 SQL_TOKEN_LOCAL
2887 $$ = SQL_NEW_RULE;
2888 $$->append($1);
2890 /* | SQL_TOKEN_TIME SQL_TOKEN_ZONE interval_value_exp
2892 $$ = SQL_NEW_RULE;
2893 $$->append($1);
2894 $$->append($2);
2895 $$->append($3);
2898 datetime_factor:
2899 datetime_primary
2901 $$ = SQL_NEW_RULE;
2902 $$->append($1);
2904 | datetime_primary time_zone
2906 $$ = SQL_NEW_RULE;
2907 $$->append($1);
2908 $$->append($2);
2911 datetime_term:
2912 datetime_factor
2914 $$ = SQL_NEW_RULE;
2915 $$->append($1);
2919 interval_term:
2920 literal
2921 | interval_term '*' factor
2923 $$ = SQL_NEW_RULE;
2924 $$->append($1);
2925 $$->append($2 = newNode("*", SQL_NODE_PUNCTUATION));
2926 $$->append($3);
2928 | interval_term '/' factor
2930 $$ = SQL_NEW_RULE;
2931 $$->append($1);
2932 $$->append($2 = newNode("/", SQL_NODE_PUNCTUATION));
2933 $$->append($3);
2937 datetime_value_exp:
2938 datetime_term
2940 $$ = SQL_NEW_RULE;
2941 $$->append($1);
2943 /* | interval_value_exp '+' datetime_term
2945 $$ = SQL_NEW_RULE;
2946 $$->append($1);
2947 $$->append($2 = newNode("+", SQL_NODE_PUNCTUATION));
2948 $$->append($3);
2950 | datetime_value_exp '+' interval_term
2952 $$ = SQL_NEW_RULE;
2953 $$->append($1);
2954 $$->append($2 = newNode("+", SQL_NODE_PUNCTUATION));
2955 $$->append($3);
2957 | datetime_value_exp '-' interval_term
2959 $$ = SQL_NEW_RULE;
2960 $$->append($1);
2961 $$->append($2 = newNode("-", SQL_NODE_PUNCTUATION));
2962 $$->append($3);
2964 */ ;
2966 interval_value_exp:
2967 interval_term
2969 $$ = SQL_NEW_RULE;
2970 $$->append($1);
2972 | interval_value_exp '+' interval_term
2974 $$ = SQL_NEW_RULE;
2975 $$->append($1);
2976 $$->append($2 = newNode("+", SQL_NODE_PUNCTUATION));
2977 $$->append($3);
2979 | interval_value_exp '-' interval_term
2981 $$ = SQL_NEW_RULE;
2982 $$->append($1);
2983 $$->append($2 = newNode("-", SQL_NODE_PUNCTUATION));
2984 $$->append($3);
2986 | '(' datetime_value_exp '-' datetime_term ')' interval_qualifier
2988 $$ = SQL_NEW_RULE;
2989 $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
2990 $$->append($2);
2991 $$->append($3 = newNode("-", SQL_NODE_PUNCTUATION));
2992 $$->append($4);
2993 $$->append($5 = newNode(")", SQL_NODE_PUNCTUATION));
2994 $$->append($6);
2998 non_second_datetime_field:
2999 SQL_TOKEN_YEAR
3000 | SQL_TOKEN_MONTH
3001 | SQL_TOKEN_DAY
3002 | SQL_TOKEN_HOUR
3003 | SQL_TOKEN_MINUTE
3005 start_field:
3006 non_second_datetime_field opt_paren_precision
3008 $$ = SQL_NEW_RULE;
3009 $$->append($1);
3010 $$->append($2);
3013 end_field:
3014 non_second_datetime_field
3015 | SQL_TOKEN_SECOND opt_paren_precision
3017 $$ = SQL_NEW_RULE;
3018 $$->append($1);
3019 $$->append($2);
3023 single_datetime_field:
3024 non_second_datetime_field opt_paren_precision
3026 $$ = SQL_NEW_RULE;
3027 $$->append($1);
3028 $$->append($2);
3030 | SQL_TOKEN_SECOND opt_paren_precision_scale
3032 $$ = SQL_NEW_RULE;
3033 $$->append($1);
3034 $$->append($2);
3038 interval_qualifier:
3039 start_field SQL_TOKEN_TO end_field
3041 $$ = SQL_NEW_RULE;
3042 $$->append($1);
3043 $$->append($2);
3044 $$->append($3);
3046 | single_datetime_field
3049 function_arg_commalist2:
3050 function_arg ',' function_arg
3051 {$$ = SQL_NEW_COMMALISTRULE;
3052 $$->append($1);
3053 $$->append($3);}
3055 function_arg_commalist3:
3056 function_arg ',' function_arg ',' function_arg
3058 $$ = SQL_NEW_COMMALISTRULE;
3059 $$->append($1);
3060 $$->append($3);
3061 $$->append($5);
3064 function_arg_commalist4:
3065 function_arg ',' function_arg ',' function_arg ',' function_arg
3067 $$ = SQL_NEW_COMMALISTRULE;
3068 $$->append($1);
3069 $$->append($3);
3070 $$->append($5);
3071 $$->append($7);
3074 value_exp_commalist:
3075 value_exp
3076 {$$ = SQL_NEW_COMMALISTRULE;
3077 $$->append($1);}
3078 | value_exp_commalist ',' value_exp
3079 {$1->append($3);
3080 $$ = $1;}
3081 /* this rule is only valid if we check predicates */
3082 | value_exp_commalist ';' value_exp
3084 if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck())
3086 $1->append($3);
3087 $$ = $1;
3089 else
3090 YYERROR;
3093 function_arg:
3094 result
3095 | value_exp comparison value_exp
3097 $$ = SQL_NEW_RULE;
3098 $$->append($1);
3099 $$->append($2);
3100 $$->append($3);
3102 | value_exp SQL_TOKEN_USING value_exp comparison value_exp
3104 $$ = SQL_NEW_RULE;
3105 $$->append($1);
3106 $$->append($2);
3107 $$->append($3);
3108 $$->append($4);
3110 | value_exp SQL_TOKEN_BY value_exp_commalist
3112 $$ = SQL_NEW_RULE;
3113 $$->append($1);
3114 $$->append($2);
3115 $$->append($3);
3118 function_args_commalist:
3119 function_arg
3120 {$$ = SQL_NEW_COMMALISTRULE;
3121 $$->append($1);}
3122 | function_args_commalist ',' function_arg
3123 {$1->append($3);
3124 $$ = $1;}
3125 /* this rule is only valid if we check predicates */
3126 | function_args_commalist ';' function_arg
3128 if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck())
3130 $1->append($3);
3131 $$ = $1;
3133 else
3134 YYERROR;
3138 value_exp:
3139 num_value_exp /*[^')']*/
3140 | string_value_exp
3141 | datetime_value_exp
3143 $$ = SQL_NEW_RULE;
3144 $$->append($1);
3147 string_value_exp:
3148 char_value_exp
3149 /* | bit_value_exp
3151 $$ = SQL_NEW_RULE;
3152 $$->append($1);
3154 */ ;
3155 char_value_exp:
3156 char_factor
3157 | concatenation
3159 concatenation:
3160 char_value_exp '+' char_factor
3162 $$ = SQL_NEW_RULE;
3163 $$->append($1);
3164 $$->append($2 = newNode("+", SQL_NODE_PUNCTUATION));
3165 $$->append($3);
3167 | value_exp SQL_CONCAT value_exp
3169 $$ = SQL_NEW_RULE;
3170 $$->append($1);
3171 $$->append($2);
3172 $$->append($3);
3176 char_primary:
3177 SQL_TOKEN_STRING
3178 | string_value_fct
3180 collate_clause:
3181 SQL_TOKEN_COLLATE table_node
3183 $$ = SQL_NEW_RULE;
3184 $$->append($1);
3185 $$->append($2);
3188 char_factor:
3189 char_primary
3190 | char_primary collate_clause
3192 $$ = SQL_NEW_RULE;
3193 $$->append($1);
3194 $$->append($2);
3197 string_value_fct:
3198 char_value_fct
3199 | bit_value_fct
3201 bit_value_fct:
3202 bit_substring_fct
3204 $$ = SQL_NEW_RULE;
3205 $$->append($1);
3208 bit_substring_fct:
3209 SQL_TOKEN_SUBSTRING '(' bit_value_exp SQL_TOKEN_FROM string_value_exp for_length ')'
3211 $$ = SQL_NEW_RULE;
3212 $$->append($1);
3213 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
3214 $$->append($3);
3215 $$->append($4);
3216 $$->append($5);
3217 $$->append($6);
3218 $$->append($7 = newNode(")", SQL_NODE_PUNCTUATION));
3221 bit_value_exp:
3222 bit_factor
3224 $$ = SQL_NEW_RULE;
3225 $$->append($1);
3229 bit_concatenation
3231 $$ = SQL_NEW_RULE;
3232 $$->append($1);
3235 bit_concatenation:
3236 bit_value_exp '+' bit_factor
3238 $$ = SQL_NEW_RULE;
3239 $$->append($1);
3240 $$->append($2 = newNode("+", SQL_NODE_PUNCTUATION));
3241 $$->append($3);
3245 bit_factor:
3246 bit_primary
3248 $$ = SQL_NEW_RULE;
3249 $$->append($1);
3252 bit_primary:
3253 {$$ = SQL_NEW_RULE;}
3254 /* value_exp_primary
3256 $$ = SQL_NEW_RULE;
3257 $$->append($1);
3259 | string_value_fct
3261 $$ = SQL_NEW_RULE;
3262 $$->append($1);
3265 char_value_fct:
3266 char_substring_fct
3267 | fold
3268 | form_conversion
3270 $$ = SQL_NEW_RULE;
3271 $$->append($1);
3273 | char_translation
3275 $$ = SQL_NEW_RULE;
3276 $$->append($1);
3278 | trim_fct
3280 $$ = SQL_NEW_RULE;
3281 $$->append($1);
3284 for_length:
3285 {$$ = SQL_NEW_RULE;}
3286 | SQL_TOKEN_FOR value_exp
3288 $$ = SQL_NEW_RULE;
3289 $$->append($1);
3290 $$->append($2);
3293 char_substring_fct:
3294 SQL_TOKEN_SUBSTRING '(' value_exp SQL_TOKEN_FROM value_exp for_length ')'
3296 $$ = SQL_NEW_RULE;
3297 $$->append($1);
3298 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
3299 $$->append($3);
3300 $$->append($4);
3301 $$->append($5);
3302 $$->append($6);
3303 $$->append($7 = newNode(")", SQL_NODE_PUNCTUATION));
3305 | SQL_TOKEN_SUBSTRING '(' value_exp_commalist ')'
3307 $$ = SQL_NEW_RULE;
3308 $$->append($1);
3309 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
3310 $$->append($3);
3311 $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
3314 upper_lower:
3315 SQL_TOKEN_UPPER
3316 | SQL_TOKEN_LOWER
3318 fold:
3319 upper_lower '(' value_exp ')'
3321 $$ = SQL_NEW_RULE;
3322 $$->append($1);
3323 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
3324 $$->append($3);
3325 $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
3328 form_conversion:
3329 SQL_TOKEN_CONVERT '(' string_value_exp SQL_TOKEN_USING table_node ')'
3331 $$ = SQL_NEW_RULE;
3332 $$->append($1);
3333 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
3334 $$->append($3);
3335 $$->append($4);
3336 $$->append($5);
3337 $$->append($6 = newNode(")", SQL_NODE_PUNCTUATION));
3339 | SQL_TOKEN_CONVERT '(' cast_operand ',' cast_target ')'
3341 $$ = SQL_NEW_RULE;
3342 $$->append($1);
3343 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
3344 $$->append($3);
3345 $$->append($2 = newNode(",", SQL_NODE_PUNCTUATION));
3346 $$->append($5);
3347 $$->append($6 = newNode(")", SQL_NODE_PUNCTUATION));
3350 char_translation:
3351 SQL_TOKEN_TRANSLATE '(' string_value_exp SQL_TOKEN_USING table_node ')'
3353 $$ = SQL_NEW_RULE;
3354 $$->append($1);
3355 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
3356 $$->append($3);
3357 $$->append($4);
3358 $$->append($5);
3359 $$->append($6 = newNode(")", SQL_NODE_PUNCTUATION));
3362 trim_fct:
3363 SQL_TOKEN_TRIM '(' trim_operands ')'
3365 $$ = SQL_NEW_RULE;
3366 $$->append($1);
3367 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
3368 $$->append($3);
3369 $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
3372 trim_operands:
3373 trim_spec value_exp SQL_TOKEN_FROM value_exp
3375 $$ = SQL_NEW_RULE;
3376 $$->append($1);
3377 $$->append($2);
3378 $$->append($3);
3379 $$->append($4);
3381 | trim_spec SQL_TOKEN_FROM value_exp
3383 $$ = SQL_NEW_RULE;
3384 $$->append($1);
3385 $$->append($2);
3386 $$->append($3);
3388 | value_exp SQL_TOKEN_FROM value_exp
3390 $$ = SQL_NEW_RULE;
3391 $$->append($1);
3392 $$->append($2);
3393 $$->append($3);
3395 | SQL_TOKEN_FROM value_exp
3397 $$ = SQL_NEW_RULE;
3398 $$->append($1);
3399 $$->append($2);
3401 | value_exp
3404 trim_spec:
3405 SQL_TOKEN_BOTH
3406 | SQL_TOKEN_LEADING
3407 | SQL_TOKEN_TRAILING
3410 derived_column:
3411 value_exp as_clause
3413 $$ = SQL_NEW_RULE;
3414 $$->append($1);
3415 $$->append($2);
3418 /* Tabellenname */
3419 table_node:
3420 table_name
3421 | schema_name
3422 | catalog_name
3424 catalog_name:
3425 SQL_TOKEN_NAME '.' schema_name
3427 $$ = SQL_NEW_RULE;
3428 $$->append($1);
3429 $$->append($2 = newNode(".", SQL_NODE_PUNCTUATION));
3430 $$->append($3);
3432 | SQL_TOKEN_NAME ':' schema_name
3434 $$ = SQL_NEW_RULE;
3435 $$->append($1);
3436 $$->append($2 = newNode(":", SQL_NODE_PUNCTUATION));
3437 $$->append($3);
3440 schema_name:
3441 SQL_TOKEN_NAME '.' table_name
3443 $$ = SQL_NEW_RULE;
3444 $$->append($1);
3445 $$->append($2 = newNode(".", SQL_NODE_PUNCTUATION));
3446 $$->append($3);
3450 table_name:
3451 SQL_TOKEN_NAME
3452 {$$ = SQL_NEW_RULE;
3453 $$->append($1);}
3455 /* Columns */
3456 column_ref:
3457 column
3458 {$$ = SQL_NEW_RULE;
3459 $$->append($1);}
3460 /* | table_node '.' column_val %prec '.'
3461 {$$ = SQL_NEW_RULE;
3462 $$->append($1);
3463 $$->append($2 = newNode(".", SQL_NODE_PUNCTUATION));
3464 $$->append($3);}
3466 | SQL_TOKEN_NAME '.' column_val %prec '.'
3467 {$$ = SQL_NEW_RULE;
3468 $$->append($1);
3469 $$->append($2 = newNode(".", SQL_NODE_PUNCTUATION));
3470 $$->append($3);
3472 | SQL_TOKEN_NAME '.' SQL_TOKEN_NAME '.' column_val %prec '.'
3473 {$$ = SQL_NEW_RULE;
3474 $$->append($1);
3475 $$->append($2 = newNode(".", SQL_NODE_PUNCTUATION));
3476 $$->append($3);
3477 $$->append($4 = newNode(".", SQL_NODE_PUNCTUATION));
3478 $$->append($5);}
3479 | SQL_TOKEN_NAME '.' SQL_TOKEN_NAME '.' SQL_TOKEN_NAME '.' column_val %prec '.'
3480 {$$ = SQL_NEW_RULE;
3481 $$->append($1);
3482 $$->append($2= newNode(".", SQL_NODE_PUNCTUATION));
3483 $$->append($3);
3484 $$->append($4 = newNode(".", SQL_NODE_PUNCTUATION));
3485 $$->append($5);
3486 $$->append($6 = newNode(".", SQL_NODE_PUNCTUATION));
3487 $$->append($7);
3489 | SQL_TOKEN_NAME ':' SQL_TOKEN_NAME '.' SQL_TOKEN_NAME '.' column_val %prec '.'
3490 {$$ = SQL_NEW_RULE;
3491 $$->append($1);
3492 $$->append($2= newNode(":", SQL_NODE_PUNCTUATION));
3493 $$->append($3);
3494 $$->append($4 = newNode(".", SQL_NODE_PUNCTUATION));
3495 $$->append($5);
3496 $$->append($6 = newNode(".", SQL_NODE_PUNCTUATION));
3497 $$->append($7);
3499 /* | SQL_TOKEN_NAME ';' SQL_TOKEN_NAME '.' SQL_TOKEN_NAME '.' column_val
3500 {$$ = SQL_NEW_RULE;
3501 $$->append($1);
3502 $$->append($2= newNode(";", SQL_NODE_PUNCTUATION));
3503 $$->append($3);
3504 $$->append($4 = newNode(".", SQL_NODE_PUNCTUATION));
3505 $$->append($5);
3506 $$->append($6 = newNode(".", SQL_NODE_PUNCTUATION));
3507 $$->append($7);
3509 */ ;
3511 /* data types */
3512 column_val:
3513 column
3514 {$$ = SQL_NEW_RULE;
3515 $$->append($1);}
3516 | '*'
3518 $$ = SQL_NEW_RULE;
3519 $$->append($1 = newNode("*", SQL_NODE_PUNCTUATION));
3522 data_type:
3523 predefined_type
3525 opt_char_set_spec:
3526 {$$ = SQL_NEW_RULE;}
3527 | SQL_TOKEN_CHARACTER SQL_TOKEN_SET SQL_TOKEN_NAME
3529 $$ = SQL_NEW_RULE;
3530 $$->append($1);
3531 $$->append($2);
3532 $$->append($3);
3535 opt_collate_clause:
3536 {$$ = SQL_NEW_RULE;}
3537 | collate_clause
3539 predefined_type:
3540 character_string_type opt_char_set_spec opt_collate_clause
3542 $$ = SQL_NEW_RULE;
3543 $$->append($1);
3544 $$->append($2);
3545 $$->append($3);
3547 | national_character_string_type opt_collate_clause
3549 $$ = SQL_NEW_RULE;
3550 $$->append($1);
3551 $$->append($2);
3553 | binary_string_type
3554 | numeric_type
3555 | boolean_type
3556 | datetime_type
3557 | interval_type
3559 character_string_type:
3560 SQL_TOKEN_CHARACTER opt_paren_precision
3562 $$ = SQL_NEW_RULE;
3563 $$->append($1);
3564 $$->append($2);
3566 | SQL_TOKEN_CHAR opt_paren_precision
3568 $$ = SQL_NEW_RULE;
3569 $$->append($1);
3570 $$->append($2);
3572 | SQL_TOKEN_CHARACTER SQL_TOKEN_VARYING paren_char_length
3574 $$ = SQL_NEW_RULE;
3575 $$->append($1);
3576 $$->append($2);
3577 $$->append($3);
3579 | SQL_TOKEN_CHAR SQL_TOKEN_VARYING paren_char_length
3581 $$ = SQL_NEW_RULE;
3582 $$->append($1);
3583 $$->append($2);
3584 $$->append($3);
3586 | SQL_TOKEN_VARCHAR paren_char_length
3588 $$ = SQL_NEW_RULE;
3589 $$->append($1);
3590 $$->append($2);
3592 | character_large_object_type
3594 opt_paren_precision:
3595 {$$ = SQL_NEW_RULE;}
3596 | paren_char_length
3598 paren_char_length:
3599 '(' SQL_TOKEN_INTNUM ')'
3601 $$ = SQL_NEW_RULE;
3602 $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
3603 $$->append($2);
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 ')'
3614 $$ = SQL_NEW_RULE;
3615 $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
3616 $$->append($2);
3617 $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
3621 large_object_length:
3622 SQL_TOKEN_INTNUM opt_multiplier
3624 $$ = SQL_NEW_RULE;
3625 $$->append($1);
3626 $$->append($2);
3629 opt_multiplier:
3630 {$$ = SQL_NEW_RULE;}
3631 | 'K'
3633 $$ = SQL_NEW_RULE;
3634 $$->append($1 = newNode("K", SQL_NODE_PUNCTUATION));
3636 | 'M'
3638 $$ = SQL_NEW_RULE;
3639 $$->append($1 = newNode("M", SQL_NODE_PUNCTUATION));
3641 | 'G'
3643 $$ = SQL_NEW_RULE;
3644 $$->append($1 = newNode("G", SQL_NODE_PUNCTUATION));
3646 | 'T'
3648 $$ = SQL_NEW_RULE;
3649 $$->append($1 = newNode("T", SQL_NODE_PUNCTUATION));
3651 | 'P'
3653 $$ = SQL_NEW_RULE;
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
3660 $$ = SQL_NEW_RULE;
3661 $$->append($1);
3662 $$->append($2);
3663 $$->append($3);
3664 $$->append($4);
3666 | SQL_TOKEN_CHAR SQL_TOKEN_LARGE SQL_TOKEN_OBJECT opt_paren_char_large_length
3668 $$ = SQL_NEW_RULE;
3669 $$->append($1);
3670 $$->append($2);
3671 $$->append($3);
3672 $$->append($4);
3674 | SQL_TOKEN_CLOB opt_paren_char_large_length
3676 $$ = SQL_NEW_RULE;
3677 $$->append($1);
3678 $$->append($2);
3681 national_character_string_type:
3682 SQL_TOKEN_NATIONAL SQL_TOKEN_CHARACTER opt_paren_precision
3684 $$ = SQL_NEW_RULE;
3685 $$->append($1);
3686 $$->append($2);
3687 $$->append($3);
3689 | SQL_TOKEN_NATIONAL SQL_TOKEN_CHAR opt_paren_precision
3691 $$ = SQL_NEW_RULE;
3692 $$->append($1);
3693 $$->append($2);
3694 $$->append($3);
3696 | SQL_TOKEN_NCHAR opt_paren_precision
3698 $$ = SQL_NEW_RULE;
3699 $$->append($1);
3700 $$->append($2);
3702 | SQL_TOKEN_NATIONAL SQL_TOKEN_CHARACTER SQL_TOKEN_VARYING paren_char_length
3704 $$ = SQL_NEW_RULE;
3705 $$->append($1);
3706 $$->append($2);
3707 $$->append($3);
3708 $$->append($4);
3710 | SQL_TOKEN_NATIONAL SQL_TOKEN_CHAR SQL_TOKEN_VARYING paren_char_length
3712 $$ = SQL_NEW_RULE;
3713 $$->append($1);
3714 $$->append($2);
3715 $$->append($3);
3716 $$->append($4);
3718 | SQL_TOKEN_NCHAR SQL_TOKEN_VARYING paren_char_length
3720 $$ = SQL_NEW_RULE;
3721 $$->append($1);
3722 $$->append($2);
3723 $$->append($3);
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
3730 $$ = SQL_NEW_RULE;
3731 $$->append($1);
3732 $$->append($2);
3733 $$->append($3);
3734 $$->append($4);
3735 $$->append($5);
3737 | SQL_TOKEN_NCHAR 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_NCLOB opt_paren_char_large_length
3747 $$ = SQL_NEW_RULE;
3748 $$->append($1);
3749 $$->append($2);
3752 binary_string_type:
3753 SQL_TOKEN_BINARY opt_paren_precision
3755 $$ = SQL_NEW_RULE;
3756 $$->append($1);
3757 $$->append($2);
3759 | SQL_TOKEN_BINARY SQL_TOKEN_VARYING paren_char_length
3761 $$ = SQL_NEW_RULE;
3762 $$->append($1);
3763 $$->append($2);
3764 $$->append($3);
3766 | SQL_TOKEN_VARBINARY paren_char_length
3768 $$ = SQL_NEW_RULE;
3769 $$->append($1);
3770 $$->append($2);
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
3777 $$ = SQL_NEW_RULE;
3778 $$->append($1);
3779 $$->append($2);
3780 $$->append($3);
3781 $$->append($4);
3783 | SQL_TOKEN_BLOB opt_paren_char_large_length
3785 $$ = SQL_NEW_RULE;
3786 $$->append($1);
3787 $$->append($2);
3790 numeric_type:
3791 exact_numeric_type
3792 | approximate_numeric_type
3794 opt_paren_precision_scale:
3795 {$$ = SQL_NEW_RULE;}
3796 | '(' SQL_TOKEN_INTNUM ')'
3798 $$ = SQL_NEW_RULE;
3799 $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
3800 $$->append($2);
3801 $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
3803 | '(' SQL_TOKEN_INTNUM ',' SQL_TOKEN_INTNUM ')'
3805 $$ = SQL_NEW_RULE;
3806 $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
3807 $$->append($2);
3808 $$->append($3 = newNode(",", SQL_NODE_PUNCTUATION));
3809 $$->append($4);
3810 $$->append($5 = newNode(")", SQL_NODE_PUNCTUATION));
3813 exact_numeric_type:
3814 SQL_TOKEN_NUMERIC opt_paren_precision_scale
3816 $$ = SQL_NEW_RULE;
3817 $$->append($1);
3818 $$->append($2);
3820 | SQL_TOKEN_DECIMAL opt_paren_precision_scale
3822 $$ = SQL_NEW_RULE;
3823 $$->append($1);
3824 $$->append($2);
3826 | SQL_TOKEN_DEC opt_paren_precision_scale
3828 $$ = SQL_NEW_RULE;
3829 $$->append($1);
3830 $$->append($2);
3832 | SQL_TOKEN_SMALLINT
3833 | SQL_TOKEN_INTEGER
3834 | SQL_TOKEN_INT
3835 | SQL_TOKEN_BIGINT
3837 approximate_numeric_type:
3838 SQL_TOKEN_FLOAT '(' SQL_TOKEN_INTNUM ')'
3840 $$ = SQL_NEW_RULE;
3841 $$->append($1);
3842 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
3843 $$->append($3);
3844 $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
3846 | SQL_TOKEN_FLOAT
3847 | SQL_TOKEN_REAL
3848 | SQL_TOKEN_DOUBLE
3849 | SQL_TOKEN_DOUBLE SQL_TOKEN_PRECISION
3851 $$ = SQL_NEW_RULE;
3852 $$->append($1);
3853 $$->append($2);
3856 boolean_type:
3857 SQL_TOKEN_BOOLEAN
3859 datetime_type:
3860 SQL_TOKEN_DATE
3861 | SQL_TOKEN_TIME opt_paren_precision opt_with_or_without_time_zone
3863 $$ = SQL_NEW_RULE;
3864 $$->append($1);
3865 $$->append($2);
3866 $$->append($3);
3868 | SQL_TOKEN_TIMESTAMP opt_paren_precision opt_with_or_without_time_zone
3870 $$ = SQL_NEW_RULE;
3871 $$->append($1);
3872 $$->append($2);
3873 $$->append($3);
3876 opt_with_or_without_time_zone:
3877 {$$ = SQL_NEW_RULE;}
3878 | SQL_TOKEN_WITH SQL_TOKEN_TIME SQL_TOKEN_ZONE
3880 $$ = SQL_NEW_RULE;
3881 $$->append($1);
3882 $$->append($2);
3883 $$->append($3);
3885 | SQL_TOKEN_WITHOUT SQL_TOKEN_TIME SQL_TOKEN_ZONE
3887 $$ = SQL_NEW_RULE;
3888 $$->append($1);
3889 $$->append($2);
3890 $$->append($3);
3893 interval_type:
3894 SQL_TOKEN_INTERVAL interval_qualifier
3896 $$ = SQL_NEW_RULE;
3897 $$->append($1);
3898 $$->append($2);
3901 /* the various things you can name */
3903 column:
3904 SQL_TOKEN_NAME
3905 | SQL_TOKEN_POSITION
3907 sal_uInt32 nNod = $$->getRuleID();
3908 delete $$;
3909 $$ = newNode(xxx_pGLOBAL_SQLPARSER->TokenIDToStr(nNod), SQL_NODE_NAME);
3911 | SQL_TOKEN_CHAR_LENGTH
3913 sal_uInt32 nNod = $$->getRuleID();
3914 delete $$;
3915 $$ = newNode(xxx_pGLOBAL_SQLPARSER->TokenIDToStr(nNod), SQL_NODE_NAME);
3917 | SQL_TOKEN_EXTRACT
3919 sal_uInt32 nNod = $$->getRuleID();
3920 delete $$;
3921 $$ = newNode(xxx_pGLOBAL_SQLPARSER->TokenIDToStr(nNod), SQL_NODE_NAME);
3924 case_expression:
3925 case_abbreviation
3926 | case_specification
3928 case_abbreviation:
3929 SQL_TOKEN_NULLIF '(' value_exp_commalist ')'
3931 $$ = SQL_NEW_RULE;
3932 $$->append($1);
3933 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
3934 $$->append($3);
3935 $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
3937 | SQL_TOKEN_COALESCE '(' value_exp ')'
3939 $$ = SQL_NEW_RULE;
3940 $$->append($1);
3941 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
3942 $$->append($3);
3943 $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
3945 | SQL_TOKEN_COALESCE '(' value_exp_commalist ')'
3947 $$ = SQL_NEW_RULE;
3948 $$->append($1);
3949 $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
3950 $$->append($3);
3951 $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
3954 case_specification:
3955 simple_case
3956 | searched_case
3958 simple_case:
3959 SQL_TOKEN_CASE case_operand simple_when_clause_list else_clause SQL_TOKEN_END
3961 $$ = SQL_NEW_RULE;
3962 $$->append($1);
3963 $$->append($2);
3964 $$->append($3);
3965 $$->append($4);
3966 $$->append($5);
3969 searched_case:
3970 SQL_TOKEN_CASE searched_when_clause_list else_clause SQL_TOKEN_END
3972 $$ = SQL_NEW_RULE;
3973 $$->append($1);
3974 $$->append($2);
3975 $$->append($3);
3976 $$->append($4);
3979 simple_when_clause_list:
3980 simple_when_clause
3982 $$ = SQL_NEW_LISTRULE;
3983 $$->append($1);
3985 | searched_when_clause_list simple_when_clause
3987 $1->append($2);
3988 $$ = $1;
3991 simple_when_clause:
3992 SQL_TOKEN_WHEN when_operand_list SQL_TOKEN_THEN result
3994 $$ = SQL_NEW_RULE;
3995 $$->append($1);
3996 $$->append($2);
3997 $$->append($3);
3998 $$->append($4);
4001 when_operand_list:
4002 when_operand
4003 {$$ = SQL_NEW_COMMALISTRULE;
4004 $$->append($1);}
4005 | when_operand_list ',' when_operand
4006 {$1->append($3);
4007 $$ = $1;}
4009 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;
4021 $$->append($1);
4023 | searched_when_clause_list searched_when_clause
4025 $1->append($2);
4026 $$ = $1;
4029 searched_when_clause:
4030 SQL_TOKEN_WHEN search_condition SQL_TOKEN_THEN result
4032 $$ = SQL_NEW_RULE;
4033 $$->append($1);
4034 $$->append($2);
4035 $$->append($3);
4036 $$->append($4);
4039 else_clause:
4040 {$$ = SQL_NEW_RULE;}
4041 | SQL_TOKEN_ELSE result
4043 $$ = SQL_NEW_RULE;
4044 $$->append($1);
4045 $$->append($2);
4048 result:
4049 result_expression
4051 result_expression:
4052 value_exp
4054 case_operand:
4055 row_value_constructor_elem
4058 cursor: SQL_TOKEN_NAME
4059 {$$ = SQL_NEW_RULE;
4060 $$->append($1);}
4063 /***
4064 module: SQL_TOKEN_NAME
4065 {$$ = SQL_NEW_RULE;
4066 $$->append($1);}
4068 ***/
4070 parameter:
4071 ':' SQL_TOKEN_NAME
4072 {$$ = SQL_NEW_RULE;
4073 $$->append($1 = newNode(":", SQL_NODE_PUNCTUATION));
4074 $$->append($2);}
4075 | '?'
4076 {$$ = SQL_NEW_RULE; // test
4077 $$->append($1 = newNode("?", SQL_NODE_PUNCTUATION));}
4078 | '[' SQL_TOKEN_NAME ']'
4079 {$$ = SQL_NEW_RULE;
4080 $$->append($1 = newNode("[", SQL_NODE_PUNCTUATION));
4081 $$->append($2);
4082 $$->append($3 = newNode("]", SQL_NODE_PUNCTUATION));}
4085 /***
4086 procedure: SQL_TOKEN_NAME
4087 {$$ = SQL_NEW_RULE;
4088 $$->append($1);}
4090 ***/
4092 range_variable:
4093 {$$ = SQL_NEW_RULE;}
4094 | opt_as SQL_TOKEN_NAME
4095 {$$ = SQL_NEW_RULE;
4096 $$->append($1);
4097 $$->append($2);
4101 user: SQL_TOKEN_NAME
4104 /* PREDICATECHECK RULES */
4105 sql:
4106 search_condition /* checking predicats */
4108 if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck()) // sql: rule 1
4110 $$ = $1;
4111 if ( SQL_ISRULE($$,search_condition) )
4113 $$->insert(0,newNode("(", SQL_NODE_PUNCTUATION));
4114 $$->append(newNode(")", SQL_NODE_PUNCTUATION));
4117 else
4118 YYERROR;
4120 | '(' sql ')' /* checking predicats */
4122 trigger_definition:
4123 SQL_TOKEN_CREATE SQL_TOKEN_TRIGGER trigger_name trigger_action_time trigger_event SQL_TOKEN_ON table_name op_referencing triggered_action
4125 $$ = SQL_NEW_RULE;
4126 $$->append($1);
4127 $$->append($2);
4128 $$->append($3);
4129 $$->append($4);
4130 $$->append($5);
4131 $$->append($6);
4132 $$->append($7);
4133 $$->append($8);
4134 $$->append($9);
4137 op_referencing:
4139 $$ = SQL_NEW_RULE;
4141 | SQL_TOKEN_REFERENCING transition_table_or_variable_list
4143 $$ = SQL_NEW_RULE;
4144 $$->append($1);
4145 $$->append($2);
4148 trigger_action_time:
4149 SQL_TOKEN_BEFORE
4150 | SQL_TOKEN_AFTER
4151 | SQL_TOKEN_INSTEAD SQL_TOKEN_OF
4153 $$ = SQL_NEW_RULE;
4154 $$->append($1);
4155 $$->append($2);
4158 trigger_event:
4159 SQL_TOKEN_INSERT
4160 | SQL_TOKEN_DELETE
4161 | SQL_TOKEN_UPDATE op_trigger_columnlist
4163 $$ = SQL_NEW_RULE;
4164 $$->append($1);
4165 $$->append($2);
4168 op_trigger_columnlist:
4170 $$ = SQL_NEW_RULE;
4172 | SQL_TOKEN_OF trigger_column_list
4174 $$ = SQL_NEW_RULE;
4175 $$->append($1);
4176 $$->append($2);
4179 trigger_column_list:
4180 column_commalist
4182 triggered_action:
4183 op_triggered_action_for triggered_when_clause triggered_SQL_statement
4185 $$ = SQL_NEW_RULE;
4186 $$->append($1);
4187 $$->append($2);
4188 $$->append($3);
4191 op_triggered_action_for:
4193 $$ = SQL_NEW_RULE;
4195 | SQL_TOKEN_FOR SQL_TOKEN_EACH trigger_for
4197 $$ = SQL_NEW_RULE;
4198 $$->append($1);
4199 $$->append($2);
4200 $$->append($3);
4203 trigger_for:
4204 SQL_TOKEN_ROW
4205 | SQL_TOKEN_STATEMENT
4207 triggered_when_clause:
4209 $$ = SQL_NEW_RULE;
4211 | SQL_TOKEN_WHEN parenthesized_boolean_value_expression
4213 $$ = SQL_NEW_RULE;
4214 $$->append($1);
4215 $$->append($2);
4218 triggered_SQL_statement:
4219 SQL_procedure_statement
4220 | SQL_TOKEN_BEGIN SQL_TOKEN_ATOMIC SQL_procedure_statement_list ';' SQL_TOKEN_END
4222 $$ = SQL_NEW_RULE;
4223 $$->append($1);
4224 $$->append($2);
4225 $$->append($3);
4226 $$->append($4 = newNode(";", SQL_NODE_PUNCTUATION));
4227 $$->append($5);
4230 SQL_procedure_statement_list:
4231 SQL_procedure_statement
4233 $$ = SQL_NEW_LISTRULE;
4234 $$->append($1);
4236 | SQL_procedure_statement_list ';' SQL_procedure_statement
4238 $1->append($3);
4239 $$ = $1;
4242 SQL_procedure_statement:
4246 transition_table_or_variable_list:
4247 transition_table_or_variable
4249 $$ = SQL_NEW_LISTRULE;
4250 $$->append($1);
4252 | transition_table_or_variable_list transition_table_or_variable
4254 $1->append($2);
4255 $$ = $1;
4259 transition_table_or_variable:
4260 SQL_TOKEN_OLD opt_row opt_as old_transition_variable_name
4262 $$ = SQL_NEW_RULE;
4263 $$->append($1);
4264 $$->append($2);
4265 $$->append($3);
4266 $$->append($4);
4268 | SQL_TOKEN_NEW opt_row opt_as new_transition_variable_name
4270 $$ = SQL_NEW_RULE;
4271 $$->append($1);
4272 $$->append($2);
4273 $$->append($3);
4274 $$->append($4);
4276 | SQL_TOKEN_OLD SQL_TOKEN_TABLE opt_as old_transition_table_name
4278 $$ = SQL_NEW_RULE;
4279 $$->append($1);
4280 $$->append($2);
4281 $$->append($3);
4282 $$->append($4);
4284 | SQL_TOKEN_NEW SQL_TOKEN_TABLE opt_as new_transition_table_name
4286 $$ = SQL_NEW_RULE;
4287 $$->append($1);
4288 $$->append($2);
4289 $$->append($3);
4290 $$->append($4);
4293 old_transition_table_name:
4294 transition_table_name
4296 new_transition_table_name:
4297 transition_table_name
4299 transition_table_name:
4300 SQL_TOKEN_NAME
4302 old_transition_variable_name:
4303 SQL_TOKEN_NAME
4305 new_transition_variable_name:
4306 SQL_TOKEN_NAME
4308 trigger_name:
4309 SQL_TOKEN_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 //============================================================
4326 // string constants
4327 struct _ConstAsciiString_
4329 sal_Int32 length;
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 //==========================================================================
4383 //= OParseContext
4384 //==========================================================================
4385 //-----------------------------------------------------------------------------
4386 OParseContext::OParseContext()
4390 //-----------------------------------------------------------------------------
4391 OParseContext::~OParseContext()
4395 //-----------------------------------------------------------------------------
4396 ::rtl::OUString OParseContext::getErrorMessage(ErrorCode _eCode) const
4398 ::rtl::OUString aMsg;
4399 switch (_eCode)
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;
4413 default:
4414 OSL_FAIL( "OParseContext::getErrorMessage: unknown error code!" );
4415 break;
4417 return aMsg;
4420 //-----------------------------------------------------------------------------
4421 ::rtl::OString OParseContext::getIntlKeywordAscii(InternationalKeyCode _eKey) const
4423 ::rtl::OString aKeyword;
4424 switch (_eKey)
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;
4451 default:
4452 OSL_FAIL( "OParseContext::getIntlKeywordAscii: unknown key!" );
4453 break;
4455 return aKeyword;
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];
4479 return KEY_NONE;
4482 //------------------------------------------------------------------------------
4483 static Locale& impl_getLocaleInstance( )
4485 static Locale s_aLocale(
4486 ::rtl::OUString( "en" ),
4487 ::rtl::OUString( "US" ),
4488 ::rtl::OUString( )
4490 return s_aLocale;
4493 //------------------------------------------------------------------------------
4494 Locale OParseContext::getPreferredLocale( ) const
4496 return getDefaultLocale();
4499 //------------------------------------------------------------------------------
4500 const Locale& OParseContext::getDefaultLocale()
4502 return impl_getLocaleInstance();
4505 //==========================================================================
4506 //= misc
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
4512 // Member-Variable.
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);
4538 else
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 ']'
4553 if (wasEscape)
4555 wasEscape=false;
4556 continue;
4558 if (c == cEscape)
4560 wasEscape=true;
4561 continue;
4563 int match = -1;
4564 if (c == sSearch[0])
4565 match=0;
4566 else if (c == sSearch[1])
4567 match=1;
4569 if (match != -1)
4571 aMatchStr[i] = sReplace[match];
4575 return aMatchStr.makeStringAndClear();
4578 //==========================================================================
4579 //= OSQLParser
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)
4615 return rQuery;
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)
4626 if (bComment2)
4628 if ((i+1) < nQueryLen)
4630 if (pCopy[i]=='*' && pCopy[i+1]=='/')
4632 bComment2 = false;
4633 ++i;
4636 else
4638 // comment can't close anymore, actually an error, but..
4640 continue;
4642 if (pCopy[i] == '\n')
4643 bComment = false;
4644 else if (!bComment)
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]=='/'))
4653 bComment = true;
4654 else if ((pCopy[i]=='/' && pCopy[i+1]=='*'))
4655 bComment2 = true;
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());
4672 // must be reset
4673 setParser(this);
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;
4683 // SQLyypvt = 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();
4700 return NULL;
4702 else
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
4711 // geliefert).
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;
4723 if (pContext)
4725 IParseContext::InternationalKeyCode eKeyCode = IParseContext::KEY_NONE;
4726 switch( nTokenID )
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);
4753 return aStr;
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]);
4762 #endif
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])
4773 return i;
4776 // Not found
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));
4799 else
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);
4805 if ( pLiteral2 )
4807 pComp->append(new OSQLInternalNode(aEmptyString, SQL_NODE_KEYWORD,SQL_TOKEN_AND));
4808 pComp->append(pLiteral2);
4810 pAppend->append(pComp);
4811 return 1;
4813 //-----------------------------------------------------------------------------
4814 sal_Int16 OSQLParser::buildStringNodes(OSQLParseNode*& pLiteral)
4816 if(!pLiteral)
4817 return 1;
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);
4829 delete pLiteral;
4830 pLiteral = NULL;
4831 return 1;
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);
4842 return 0;
4844 return 1;
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());
4861 if (bAppendBlank)
4863 aValue.appendAscii(" ");
4866 aValue.append(pLiteral->getChild(1)->getTokenValue());
4868 pLiteral = new OSQLInternalNode(aValue.makeStringAndClear(),SQL_NODE_STRING);
4869 delete pTemp;
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);
4881 if(nPos1 != -1)
4883 ::rtl::OUString sFirst = sStr.copy(0,nPos1);
4884 sal_Int32 nPos2 = sStr.indexOf(sSQL_TOKEN,nPos1+1);
4885 if(nPos2 != -1)
4887 ::rtl::OUString sSecond = sStr.copy(nPos1+sSQL_TOKEN.getLength(),nPos2-nPos1-sSQL_TOKEN.getLength());
4888 sFirst += sSecond;
4889 sFirst += sStr.copy(nPos2+sSQL_TOKEN.getLength());
4891 else
4892 sFirst += sStr.copy(nPos1+sSQL_TOKEN.getLength());
4894 m_sErrorMessage = sFirst;
4896 else
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
4914 #pragma enable_warn
4915 #elif defined _MSC_VER
4916 #pragma warning(pop)
4917 #endif