CUBRID Engine  latest
csql_grammar.y
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Search Solution Corporation
3  * Copyright 2016 CUBRID Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 /*
20  * csql_grammar.y - SQL grammar file
21  */
22 
23 
24 
25 %{/*%CODE_REQUIRES_START%*/
26 #include "json_table_def.h"
27 #include "parser.h"
28 
29 /*
30  * The default YYLTYPE structure is extended so that locations can hold
31  * context information
32  */
33 typedef struct YYLTYPE
34 {
35 
36  int first_line;
37  int first_column;
38  int last_line;
39  int last_column;
40  int buffer_pos; /* position in the buffer being parsed */
41 
42 } YYLTYPE;
43 #define YYLTYPE_IS_DECLARED 1
44 
45 typedef struct
46 {
47  PT_NODE *c1;
48  PT_NODE *c2;
49 } container_2;
50 
51 typedef struct
52 {
53  PT_NODE *c1;
54  PT_NODE *c2;
55  PT_NODE *c3;
56 } container_3;
57 
58 typedef struct
59 {
60  PT_NODE *c1;
61  PT_NODE *c2;
62  PT_NODE *c3;
63  PT_NODE *c4;
64 } container_4;
65 
66 typedef struct
67 {
68  PT_NODE *c1;
69  PT_NODE *c2;
70  PT_NODE *c3;
71  PT_NODE *c4;
72  PT_NODE *c5;
73  PT_NODE *c6;
74  PT_NODE *c7;
75  PT_NODE *c8;
76  PT_NODE *c9;
77  PT_NODE *c10;
78 } container_10;
79 
80 void csql_yyerror_explicit (int line, int column);
81 void csql_yyerror (const char *s);
82 
83 extern int g_msg[1024];
84 extern int msg_ptr;
85 extern int yybuffer_pos;
86 /*%CODE_END%*/%}
87 
88 %{
89 #define YYMAXDEPTH 1000000
90 
91 /* #define PARSER_DEBUG */
92 
93 #include "config.h"
94 
95 #include <stdio.h>
96 #include <stdlib.h>
97 #include <string.h>
98 #include <ctype.h>
99 #include <math.h>
100 #include <errno.h>
101 #include <float.h>
102 
103 #include "chartype.h"
104 #include "parser.h"
105 #include "parser_message.h"
106 #include "language_support.h"
107 #include "unicode_support.h"
108 #include "environment_variable.h"
109 #include "dbtype.h"
110 #include "transaction_cl.h"
111 #include "csql_grammar_scan.h"
112 #include "system_parameter.h"
113 #define JP_MAXNAME 256
114 #if defined(WINDOWS)
115 #define snprintf _sprintf_p
116 #endif /* WINDOWS */
117 #include "memory_alloc.h"
118 #include "db_elo.h"
119 #include "storage_common.h"
120 
121 #if defined (SUPPRESS_STRLEN_WARNING)
122 #define strlen(s1) ((int) strlen(s1))
123 #endif /* defined (SUPPRESS_STRLEN_WARNING) */
124 
125 /* Bit mask to be used to check constraints of a column.
126  * COLUMN_CONSTRAINT_SHARED_DEFAULT_AI is special-purpose mask
127  * to identify duplication of SHARED, DEFAULT and AUTO_INCREMENT.
128  */
129 #define COLUMN_CONSTRAINT_UNIQUE (0x01)
130 #define COLUMN_CONSTRAINT_PRIMARY_KEY (0x02)
131 #define COLUMN_CONSTRAINT_NULL (0x04)
132 #define COLUMN_CONSTRAINT_OTHERS (0x08)
133 #define COLUMN_CONSTRAINT_SHARED (0x10)
134 #define COLUMN_CONSTRAINT_DEFAULT (0x20)
135 #define COLUMN_CONSTRAINT_AUTO_INCREMENT (0x40)
136 #define COLUMN_CONSTRAINT_SHARED_DEFAULT_AI (0x70)
137 #define COLUMN_CONSTRAINT_COMMENT (0x80)
138 #define COLUMN_CONSTRAINT_ON_UPDATE (0x100)
139 
140 #ifdef PARSER_DEBUG
141 #define DBG_PRINT printf("rule matched at line: %d\n", __LINE__);
142 #define PRINT_(a) printf(a)
143 #define PRINT_1(a, b) printf(a, b)
144 #define PRINT_2(a, b, c) printf(a, b, c)
145 #else
146 #define DBG_PRINT
147 #define PRINT_(a)
148 #define PRINT_1(a, b)
149 #define PRINT_2(a, b, c)
150 #endif
151 
152 #define STACK_SIZE 128
153 
154 typedef struct function_map FUNCTION_MAP;
155 struct function_map
156 {
157  const char *keyword;
158  int op;
159 };
160 
161 
162 static FUNCTION_MAP functions[] = {
163  {"abs", PT_ABS},
164  {"acos", PT_ACOS},
165  {"addtime", PT_ADDTIME},
166  {"asin", PT_ASIN},
167  {"atan", PT_ATAN},
168  {"atan2", PT_ATAN2},
169  {"bin", PT_BIN},
170  {"bit_count", PT_BIT_COUNT},
171  {"bit_to_blob", PT_BIT_TO_BLOB},
172  {"blob_from_file", PT_BLOB_FROM_FILE},
173  {"blob_length", PT_BLOB_LENGTH},
174  {"blob_to_bit", PT_BLOB_TO_BIT},
175  {"ceil", PT_CEIL},
176  {"ceiling", PT_CEIL},
177  {"char_length", PT_CHAR_LENGTH},
178  {"char_to_blob", PT_CHAR_TO_BLOB},
179  {"char_to_clob", PT_CHAR_TO_CLOB},
180  {"character_length", PT_CHAR_LENGTH},
181  {"clob_from_file", PT_CLOB_FROM_FILE},
182  {"clob_length", PT_CLOB_LENGTH},
183  {"concat", PT_CONCAT},
184  {"concat_ws", PT_CONCAT_WS},
185  {"cos", PT_COS},
186  {"cot", PT_COT},
187  {"cume_dist", PT_CUME_DIST},
188  {"curtime", PT_CURRENT_TIME},
189  {"curdate", PT_CURRENT_DATE},
190  {"utc_time", PT_UTC_TIME},
191  {"utc_date", PT_UTC_DATE},
192  {"datediff", PT_DATEDIFF},
193  {"timediff",PT_TIMEDIFF},
194  {"date_format", PT_DATE_FORMAT},
195  {"dayofmonth", PT_DAYOFMONTH},
196  {"dayofyear", PT_DAYOFYEAR},
197  {"decode", PT_DECODE},
198  {"decr", PT_DECR},
199  {"degrees", PT_DEGREES},
200  {"drand", PT_DRAND},
201  {"drandom", PT_DRANDOM},
202  {"exec_stats", PT_EXEC_STATS},
203  {"exp", PT_EXP},
204  {"field", PT_FIELD},
205  {"floor", PT_FLOOR},
206  {"from_days", PT_FROMDAYS},
207  {"greatest", PT_GREATEST},
208  {"groupby_num", PT_GROUPBY_NUM},
209  {"incr", PT_INCR},
210  {"index_cardinality", PT_INDEX_CARDINALITY},
211  {"inst_num", PT_INST_NUM},
212  {"instr", PT_INSTR},
213  {"instrb", PT_INSTR},
214  {"last_day", PT_LAST_DAY},
215  {"length", PT_CHAR_LENGTH},
216  {"lengthb", PT_CHAR_LENGTH},
217  {"least", PT_LEAST},
218  {"like_match_lower_bound", PT_LIKE_LOWER_BOUND},
219  {"like_match_upper_bound", PT_LIKE_UPPER_BOUND},
220  {"list_dbs", PT_LIST_DBS},
221  {"locate", PT_LOCATE},
222  {"ln", PT_LN},
223  {"log2", PT_LOG2},
224  {"log10", PT_LOG10},
225  {"log", PT_LOG},
226  {"lpad", PT_LPAD},
227  {"ltrim", PT_LTRIM},
228  {"makedate", PT_MAKEDATE},
229  {"maketime", PT_MAKETIME},
230  {"mid", PT_MID},
231  {"months_between", PT_MONTHS_BETWEEN},
232  {"new_time", PT_NEW_TIME},
233  {"format", PT_FORMAT},
234  {"now", PT_CURRENT_DATETIME},
235  {"nvl", PT_NVL},
236  {"nvl2", PT_NVL2},
237  {"orderby_num", PT_ORDERBY_NUM},
238  {"percent_rank", PT_PERCENT_RANK},
239  {"power", PT_POWER},
240  {"pow", PT_POWER},
241  {"pi", PT_PI},
242  {"radians", PT_RADIANS},
243  {"rand", PT_RAND},
244  {"random", PT_RANDOM},
245  {"repeat", PT_REPEAT},
246  {"space", PT_SPACE},
247  {"reverse", PT_REVERSE},
248  {"disk_size", PT_DISK_SIZE},
249  {"round", PT_ROUND},
250  {"row_count", PT_ROW_COUNT},
251  {"last_insert_id", PT_LAST_INSERT_ID},
252  {"rpad", PT_RPAD},
253  {"rtrim", PT_RTRIM},
254  {"sec_to_time", PT_SECTOTIME},
255  {"serial_current_value", PT_CURRENT_VALUE},
256  {"serial_next_value", PT_NEXT_VALUE},
257  {"sign", PT_SIGN},
258  {"sin", PT_SIN},
259  {"sqrt", PT_SQRT},
260  {"strcmp", PT_STRCMP},
261  {"substr", PT_SUBSTRING},
262  {"substring_index", PT_SUBSTRING_INDEX},
263  {"find_in_set", PT_FINDINSET},
264  {"md5", PT_MD5},
265 /*
266  * temporarily block aes_encrypt and aes_decrypt functions until binary string charset is available.
267  *
268  * {"aes_encrypt", PT_AES_ENCRYPT},
269  * {"aes_decrypt", PT_AES_DECRYPT},
270  */
271  {"sha1", PT_SHA_ONE},
272  {"sha2", PT_SHA_TWO},
273  {"substrb", PT_SUBSTRING},
274  {"tan", PT_TAN},
275  {"time_format", PT_TIME_FORMAT},
276  {"to_char", PT_TO_CHAR},
277  {"to_date", PT_TO_DATE},
278  {"to_datetime", PT_TO_DATETIME},
279  {"to_days", PT_TODAYS},
280  {"time_to_sec", PT_TIMETOSEC},
281  {"to_number", PT_TO_NUMBER},
282  {"to_time", PT_TO_TIME},
283  {"to_timestamp", PT_TO_TIMESTAMP},
284  {"trunc", PT_TRUNC},
285  {"tz_offset", PT_TZ_OFFSET},
286  {"unix_timestamp", PT_UNIX_TIMESTAMP},
287  {"typeof", PT_TYPEOF},
288  {"from_unixtime", PT_FROM_UNIXTIME},
289  {"from_tz", PT_FROM_TZ},
290  {"weekday", PT_WEEKDAY},
291  {"dayofweek", PT_DAYOFWEEK},
292  {"version", PT_VERSION},
293  {"quarter", PT_QUARTERF},
294  {"week", PT_WEEKF},
295  {"hex", PT_HEX},
296  {"ascii", PT_ASCII},
297  {"conv", PT_CONV},
298  {"inet_aton", PT_INET_ATON},
299  {"inet_ntoa", PT_INET_NTOA},
300  {"coercibility", PT_COERCIBILITY},
301  {"width_bucket", PT_WIDTH_BUCKET},
302  {"trace_stats", PT_TRACE_STATS},
303  {"str_to_date", PT_STR_TO_DATE},
304  {"to_base64", PT_TO_BASE64},
305  {"from_base64", PT_FROM_BASE64},
306  {"sys_guid", PT_SYS_GUID},
307  {"sleep", PT_SLEEP},
308  {"to_datetime_tz", PT_TO_DATETIME_TZ},
309  {"to_timestamp_tz", PT_TO_TIMESTAMP_TZ},
310  {"utc_timestamp", PT_UTC_TIMESTAMP},
311  {"crc32", PT_CRC32},
312  {"schema_def", PT_SCHEMA_DEF},
313  {"conv_tz", PT_CONV_TZ},
314 };
315 
316 
317 static int parser_groupby_exception = 0;
318 
319 
320 
321 
322 /* xxxnum_check: 0 not allowed, no compatibility check
323  1 allowed, compatibility check (search_condition)
324  2 allowed, no compatibility check (select_list) */
325 static int parser_instnum_check = 0;
326 static int parser_groupbynum_check = 0;
327 static int parser_orderbynum_check = 0;
328 static int parser_within_join_condition = 0;
329 
330 /* xxx_check: 0 not allowed
331  1 allowed */
332 static int parser_sysconnectbypath_check = 0;
333 static int parser_prior_check = 0;
334 static int parser_connectbyroot_check = 0;
335 static int parser_serial_check = 1;
336 static int parser_pseudocolumn_check = 1;
337 static int parser_subquery_check = 1;
338 static int parser_hostvar_check = 1;
339 
340 /* check Oracle style outer-join operator: '(+)' */
341 static bool parser_found_Oracle_outer = false;
342 
343 /* check sys_date, sys_time, sys_timestamp, sys_datetime local_transaction_id */
344 static bool parser_si_datetime = false;
345 static bool parser_si_tran_id = false;
346 
347 /* check the condition that the statment is not able to be prepared */
348 static bool parser_cannot_prepare = false;
349 
350 /* check the condition that the result of a query is not able to be cached */
351 static bool parser_cannot_cache = false;
352 
353 /* check if INCR is used legally */
354 static int parser_select_level = -1;
355 
356 /* handle inner increment exprs in select list */
357 static PT_NODE *parser_hidden_incr_list = NULL;
358 
359 /* for opt_over_analytic_partition_by */
360 static bool is_analytic_function = false;
361 
362 #define PT_EMPTY INT_MAX
363 
364 
365 #define TO_NUMBER(a) ((UINTPTR)(a))
366 #define FROM_NUMBER(a) ((PT_NODE*)(UINTPTR)(a))
367 
368 
369 #define SET_CONTAINER_2(a, i, j) a.c1 = i, a.c2 = j
370 #define SET_CONTAINER_3(a, i, j, k) a.c1 = i, a.c2 = j, a.c3 = k
371 #define SET_CONTAINER_4(a, i, j, k, l) a.c1 = i, a.c2 = j, a.c3 = k, a.c4 = l
372 
373 #define CONTAINER_AT_0(a) (a).c1
374 #define CONTAINER_AT_1(a) (a).c2
375 #define CONTAINER_AT_2(a) (a).c3
376 #define CONTAINER_AT_3(a) (a).c4
377 #define CONTAINER_AT_4(a) (a).c5
378 #define CONTAINER_AT_5(a) (a).c6
379 #define CONTAINER_AT_6(a) (a).c7
380 #define CONTAINER_AT_7(a) (a).c8
381 #define CONTAINER_AT_8(a) (a).c9
382 #define CONTAINER_AT_9(a) (a).c10
383 
384 #define YEN_SIGN_TEXT "(\0xa1\0xef)"
385 #define DOLLAR_SIGN_TEXT "$"
386 #define WON_SIGN_TEXT "\\"
387 #define TURKISH_LIRA_TEXT "TL"
388 #define BRITISH_POUND_TEXT "GBP"
389 #define CAMBODIAN_RIEL_TEXT "KHR"
390 #define CHINESE_RENMINBI_TEXT "CNY"
391 #define INDIAN_RUPEE_TEXT "INR"
392 #define RUSSIAN_RUBLE_TEXT "RUB"
393 #define AUSTRALIAN_DOLLAR_TEXT "AUD"
394 #define CANADIAN_DOLLAR_TEXT "CAD"
395 #define BRASILIAN_REAL_TEXT "BRL"
396 #define ROMANIAN_LEU_TEXT "RON"
397 #define EURO_TEXT "EUR"
398 #define SWISS_FRANC_TEXT "CHF"
399 #define DANISH_KRONE_TEXT "DKK"
400 #define NORWEGIAN_KRONE_TEXT "NOK"
401 #define BULGARIAN_LEV_TEXT "BGN"
402 #define VIETNAMESE_DONG_TEXT "VND"
403 #define CZECH_KORUNA_TEXT "CZK"
404 #define POLISH_ZLOTY_TEXT "PLN"
405 #define SWEDISH_KRONA_TEXT "SEK"
406 #define CROATIAN_KUNA_TEXT "HRK"
407 #define SERBIAN_DINAR_TEXT "RSD"
408 
409 #define PARSER_SAVE_ERR_CONTEXT(node, context) \
410  if ((node) && (node)->buffer_pos == -1) \
411  { \
412  (node)->buffer_pos = context; \
413  }
414 
415 typedef enum
416 {
417  SERIAL_START,
418  SERIAL_INC,
419  SERIAL_MAX,
420  SERIAL_MIN,
421  SERIAL_CYCLE,
422  SERIAL_CACHE,
423 } SERIAL_DEFINE;
424 
425 FUNCTION_MAP *keyword_offset (const char *name);
426 
427 static PT_NODE *parser_make_expr_with_func (PARSER_CONTEXT * parser, FUNC_TYPE func_code, PT_NODE * args_list);
428 static PT_NODE *parser_make_func_with_arg_count (PARSER_CONTEXT * parser, FUNC_TYPE func_code, PT_NODE * args_list,
429  size_t min_args, size_t max_args);
430 static PT_NODE *parser_make_func_with_arg_count_mod2 (PARSER_CONTEXT * parser, FUNC_TYPE func_code, PT_NODE * args_list,
431  size_t min_args, size_t max_args, size_t mod2);
432 static PT_NODE *parser_make_link (PT_NODE * list, PT_NODE * node);
433 static PT_NODE *parser_make_link_or (PT_NODE * list, PT_NODE * node);
434 
435 
436 
437 static void parser_save_and_set_cannot_cache (bool value);
438 static void parser_restore_cannot_cache (void);
439 
440 static void parser_save_and_set_si_datetime (int value);
441 static void parser_restore_si_datetime (void);
442 
443 static void parser_save_and_set_si_tran_id (int value);
444 static void parser_restore_si_tran_id (void);
445 
446 static void parser_save_and_set_cannot_prepare (bool value);
447 static void parser_restore_cannot_prepare (void);
448 
449 static void parser_save_and_set_wjc (int value);
450 static void parser_restore_wjc (void);
451 
452 static void parser_save_and_set_ic (int value);
453 static void parser_restore_ic (void);
454 
455 static void parser_save_and_set_gc (int value);
456 static void parser_restore_gc (void);
457 
458 static void parser_save_and_set_oc (int value);
459 static void parser_restore_oc (void);
460 
461 static void parser_save_and_set_sysc (int value);
462 static void parser_restore_sysc (void);
463 
464 static void parser_save_and_set_prc (int value);
465 static void parser_restore_prc (void);
466 
467 static void parser_save_and_set_cbrc (int value);
468 static void parser_restore_cbrc (void);
469 
470 static void parser_save_and_set_serc (int value);
471 static void parser_restore_serc (void);
472 
473 static void parser_save_and_set_pseudoc (int value);
474 static void parser_restore_pseudoc (void);
475 
476 static void parser_save_and_set_sqc (int value);
477 static void parser_restore_sqc (void);
478 
479 static void parser_save_and_set_hvar (int value);
480 static void parser_restore_hvar (void);
481 
482 static void parser_save_found_Oracle_outer (void);
483 static void parser_restore_found_Oracle_outer (void);
484 
485 static void parser_save_alter_node (PT_NODE * node);
486 static PT_NODE *parser_get_alter_node (void);
487 
488 static void parser_save_attr_def_one (PT_NODE * node);
489 static PT_NODE *parser_get_attr_def_one (void);
490 
491 static void parser_push_orderby_node (PT_NODE * node);
492 static PT_NODE *parser_top_orderby_node (void);
493 static PT_NODE *parser_pop_orderby_node (void);
494 
495 static void parser_push_select_stmt_node (PT_NODE * node);
496 static PT_NODE *parser_top_select_stmt_node (void);
497 static PT_NODE *parser_pop_select_stmt_node (void);
498 static bool parser_is_select_stmt_node_empty (void);
499 
500 static void parser_push_hint_node (PT_NODE * node);
501 static PT_NODE *parser_top_hint_node (void);
502 static PT_NODE *parser_pop_hint_node (void);
503 static bool parser_is_hint_node_empty (void);
504 
505 static void parser_push_join_type (int v);
506 static int parser_top_join_type (void);
507 static int parser_pop_join_type (void);
508 
509 static void parser_save_is_reverse (bool v);
510 static bool parser_get_is_reverse (void);
511 
512 static void parser_initialize_parser_context (void);
513 static PT_NODE *parser_make_date_lang (int arg_cnt, PT_NODE * arg3);
514 static PT_NODE *parser_make_number_lang (const int argc);
515 static void parser_remove_dummy_select (PT_NODE ** node);
516 static int parser_count_list (PT_NODE * list);
517 static int parser_count_prefix_columns (PT_NODE * list, int * arg_count);
518 
519 static void resolve_alias_in_expr_node (PT_NODE * node, PT_NODE * list);
520 static void resolve_alias_in_name_node (PT_NODE ** node, PT_NODE * list);
521 static char * pt_check_identifier (PARSER_CONTEXT *parser, PT_NODE *p,
522  const char *str, const int str_size);
523 static PT_NODE * pt_create_char_string_literal (PARSER_CONTEXT *parser,
524  const PT_TYPE_ENUM char_type,
525  const char *str,
526  const INTL_CODESET codeset);
527 static PT_NODE * pt_create_date_value (PARSER_CONTEXT *parser,
528  const PT_TYPE_ENUM type,
529  const char *str);
530 static PT_NODE * pt_create_json_value (PARSER_CONTEXT *parser,
531  const char *str);
532 static void pt_jt_append_column_or_nested_node (PT_NODE * jt_node, PT_NODE * jt_col_or_nested);
533 static void pt_value_set_charset_coll (PARSER_CONTEXT *parser,
534  PT_NODE *node,
535  const int codeset_id,
536  const int collation_id, bool force);
537 static void pt_value_set_collation_info (PARSER_CONTEXT *parser,
538  PT_NODE *node,
539  PT_NODE *coll_node);
540 static void pt_value_set_monetary (PARSER_CONTEXT *parser, PT_NODE *node,
541  const char *str, const char *txt, DB_CURRENCY type);
542 static PT_NODE * pt_create_paren_expr_list (PT_NODE * exp);
543 static PT_MISC_TYPE parser_attr_type;
544 
545 static bool allow_attribute_ordering;
546 
547 int parse_one_statement (int state);
548 static PT_NODE *pt_set_collation_modifier (PARSER_CONTEXT *parser,
549  PT_NODE *node, PT_NODE *coll_node);
550 
551 
552 #define push_msg(a) _push_msg(a, __LINE__)
553 
554 void _push_msg (int code, int line);
555 void pop_msg (void);
556 
557 char *g_query_string;
558 int g_query_string_len;
559 int g_original_buffer_len;
560 
561 
562 /*
563  * The behavior of location propagation when a rule is matched must
564  * take into account the context information. The left-side symbol in a rule
565  * will have the same context information as the last symbol from its
566  * right side
567  */
568 #define YYLLOC_DEFAULT(Current, Rhs, N) \
569  do \
570  if (N) \
571  { \
572  (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
573  (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
574  (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
575  (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
576  (Current).buffer_pos = YYRHSLOC (Rhs, N).buffer_pos; \
577  } \
578  else \
579  { \
580  (Current).first_line = (Current).last_line = \
581  YYRHSLOC (Rhs, 0).last_line; \
582  (Current).first_column = (Current).last_column = \
583  YYRHSLOC (Rhs, 0).last_column; \
584  (Current).buffer_pos = YYRHSLOC (Rhs, 0).buffer_pos; \
585  } \
586  while (0)
587 
588 /*
589  * YY_LOCATION_PRINT -- Print the location on the stream.
590  * This macro was not mandated originally: define only if we know
591  * we won't break user code: when these are the locations we know.
592  */
593 
594 #define YY_LOCATION_PRINT(File, Loc) \
595  fprintf (File, "%d.%d-%d.%d", \
596  (Loc).first_line, (Loc).first_column, \
597  (Loc).last_line, (Loc).last_column)
598 
599 %}
600 
601 %initial-action {yybuffer_pos = 0;}
602 %locations
603 %glr-parser
604 %define parse.error verbose
605 
606 
607 %union
608 {
609  int number;
610  bool boolean;
611  PT_NODE *node;
612  char *cptr;
613  container_2 c2;
614  container_3 c3;
615  container_4 c4;
616  container_10 c10;
617  struct json_table_column_behavior jtcb;
618 }
619 
620 
621 /* define rule type (number) */
622 /*{{{*/
623 %type <boolean> opt_reverse
624 %type <boolean> opt_unique
625 %type <boolean> opt_cascade_constraints
626 %type <number> opt_replace
627 %type <number> opt_of_inner_left_right
628 %type <number> opt_class_type
629 %type <number> opt_of_attr_column_method
630 %type <number> opt_class
631 %type <number> isolation_level_name
632 %type <number> opt_status
633 %type <number> trigger_status
634 %type <number> trigger_time
635 %type <number> opt_trigger_action_time
636 %type <number> event_type
637 %type <number> opt_of_data_type_cursor
638 %type <number> all_distinct
639 %type <number> of_avg_max_etc
640 %type <number> of_leading_trailing_both
641 %type <number> datetime_field
642 %type <boolean> opt_invisible
643 %type <number> opt_paren_plus
644 %type <number> opt_with_fullscan
645 %type <number> opt_with_online
646 %type <number> comp_op
647 %type <number> opt_of_all_some_any
648 %type <number> set_op
649 %type <number> char_bit_type
650 %type <number> opt_internal_external
651 %type <number> opt_identity
652 %type <number> set_type
653 %type <number> opt_of_container
654 %type <number> of_container
655 %type <number> opt_with_levels_clause
656 %type <number> of_class_table_type
657 %type <number> opt_with_grant_option
658 %type <number> opt_sp_in_out
659 %type <number> opt_in_out
660 %type <number> like_op
661 %type <number> rlike_op
662 %type <number> null_op
663 %type <number> is_op
664 %type <number> in_op
665 %type <number> between_op
666 %type <number> opt_varying
667 %type <number> nested_set
668 %type <number> opt_asc_or_desc
669 %type <number> opt_with_rollup
670 %type <number> opt_table_type
671 %type <number> opt_or_replace
672 %type <number> column_constraint_and_comment_def
673 %type <number> constraint_list_and_column_comment
674 %type <number> opt_constraint_list_and_opt_column_comment
675 %type <number> opt_full
676 %type <number> of_analytic
677 %type <number> of_analytic_first_last
678 %type <number> of_analytic_nth_value
679 %type <number> of_analytic_lead_lag
680 %type <number> of_percentile
681 %type <number> of_analytic_no_args
682 %type <number> of_cume_dist_percent_rank_function
683 %type <number> negative_prec_cast_type
684 %type <number> opt_nulls_first_or_last
685 %type <number> query_trace_spec
686 %type <number> opt_trace_output_format
687 %type <number> opt_if_not_exists
688 %type <number> opt_if_exists
689 %type <number> opt_recursive
690 %type <number> show_type
691 %type <number> show_type_of_like
692 %type <number> show_type_of_where
693 %type <number> show_type_arg1
694 %type <number> show_type_arg1_opt
695 %type <number> show_type_arg_named
696 %type <number> show_type_id_dot_id
697 %type <number> kill_type
698 %type <number> procedure_or_function
699 %type <boolean> opt_analytic_from_last
700 %type <boolean> opt_analytic_ignore_nulls
701 %type <number> opt_encrypt_algorithm
702 /*}}}*/
703 
704 /* define rule type (node) */
705 /*{{{*/
706 %type <node> stmt
707 %type <node> stmt_
708 %type <node> create_stmt
709 %type <node> set_stmt
710 %type <node> get_stmt
711 %type <node> auth_stmt
712 %type <node> transaction_stmt
713 %type <node> alter_stmt
714 %type <node> alter_clause_list
715 %type <node> rename_stmt
716 %type <node> rename_class_list
717 %type <node> rename_class_pair
718 %type <node> drop_stmt
719 %type <node> opt_index_column_name_list
720 %type <node> index_column_name_list
721 %type <node> update_statistics_stmt
722 %type <node> only_class_name_list
723 %type <node> opt_level_spec
724 %type <node> char_string_literal_list
725 %type <node> table_spec_list
726 %type <node> join_table_spec
727 %type <node> table_spec
728 %type <node> original_table_spec
729 %type <node> join_condition
730 %type <node> class_spec_list
731 %type <node> class_spec
732 %type <node> only_all_class_spec_list
733 %type <node> meta_class_spec
734 %type <node> only_all_class_spec
735 %type <node> class_name
736 %type <node> class_name_list
737 %type <node> opt_identifier
738 %type <node> normal_or_class_attr_list_with_commas
739 %type <node> normal_or_class_attr
740 %type <node> normal_column_or_class_attribute
741 %type <node> query_number_list
742 %type <node> insert_or_replace_stmt
743 %type <node> insert_set_stmt
744 %type <node> replace_set_stmt
745 %type <node> insert_set_stmt_header
746 %type <node> insert_expression
747 %type <node> opt_attr_list
748 %type <node> opt_path_attr_list
749 %type <node> into_clause_opt
750 %type <node> insert_value_clause
751 %type <node> insert_value_clause_list
752 %type <node> insert_stmt_value_clause
753 %type <node> select_or_subquery_without_values_query_no_with_clause
754 %type <node> csql_query_without_values_query_no_with_clause
755 %type <node> select_expression_without_values_query_no_with_clause
756 %type <node> csql_query_without_subquery_and_with_clause
757 %type <node> select_expression_without_subquery
758 %type <node> select_or_values_query
759 %type <node> subquery_without_subquery_and_with_clause
760 %type <node> select_or_nested_values_query
761 %type <node> csql_query_without_values_and_single_subquery
762 %type <node> select_expression_without_values_and_single_subquery
763 %type <node> insert_expression_value_clause
764 %type <node> insert_value_list
765 %type <node> insert_value
766 %type <node> update_stmt
767 %type <node> of_class_spec_meta_class_spec
768 %type <node> opt_as_identifier
769 %type <node> update_assignment_list
770 %type <node> update_assignment
771 %type <node> paren_path_expression_set
772 %type <node> path_expression_list
773 %type <node> delete_stmt
774 %type <node> author_cmd_list
775 %type <node> authorized_cmd
776 %type <node> opt_password
777 %type <node> opt_groups
778 %type <node> opt_members
779 %type <node> call_stmt
780 %type <node> opt_class_or_normal_attr_def_list
781 %type <node> opt_method_def_list
782 %type <node> opt_method_files
783 %type <node> opt_inherit_resolution_list
784 %type <node> opt_partition_clause
785 %type <node> opt_paren_view_attr_def_list
786 %type <node> opt_as_query_list
787 %type <node> opt_group_concat_separator
788 %type <node> opt_agg_order_by
789 %type <node> query_list
790 %type <node> inherit_resolution_list
791 %type <node> inherit_resolution
792 %type <node> opt_table_option_list
793 %type <node> table_option_list
794 %type <node> table_option
795 %type <node> opt_subtable_clause
796 %type <node> opt_constraint_id
797 %type <node> opt_constraint_opt_id
798 %type <node> of_unique_foreign_check
799 %type <node> unique_constraint
800 %type <node> foreign_key_constraint
801 %type <node> opt_paren_attr_list
802 %type <node> check_constraint
803 %type <node> method_def_list
804 %type <node> method_def
805 %type <node> opt_method_def_arg_list
806 %type <node> arg_type_list
807 %type <node> inout_data_type
808 %type <node> opt_function_identifier
809 %type <node> opt_class_attr_def_list
810 %type <node> class_or_normal_attr_def_list
811 %type <node> view_attr_def_list
812 %type <node> attr_def_comment_list
813 %type <node> attr_def_comment
814 %type <node> attr_def_list
815 %type <node> attr_def_list_with_commas
816 %type <node> attr_def
817 %type <node> attr_constraint_def
818 %type <node> attr_index_def
819 %type <node> attr_def_one
820 %type <node> view_attr_def
821 %type <node> transaction_mode_list
822 %type <node> transaction_mode
823 %type <node> timeout_spec
824 %type <node> evaluate_stmt
825 %type <node> prepare_stmt
826 %type <node> execute_stmt
827 %type <node> opt_using
828 %type <node> execute_using_list;
829 %type <node> opt_priority
830 %type <node> opt_if_trigger_condition
831 %type <node> event_spec
832 %type <node> event_target
833 %type <node> trigger_condition
834 %type <node> trigger_action
835 %type <node> trigger_spec_list
836 %type <node> trace_spec
837 %type <node> depth_spec
838 %type <node> serial_start
839 %type <node> serial_increment
840 %type <node> opt_sp_param_list
841 %type <node> sp_param_list
842 %type <node> sp_param_def
843 %type <node> esql_query_stmt
844 %type <node> csql_query
845 %type <node> csql_query_select_has_no_with_clause
846 %type <node> csql_query_without_values_query
847 %type <node> select_expression_opt_with
848 %type <node> select_expression
849 %type <node> select_expression_without_values_query
850 %type <node> table_op
851 %type <node> select_or_subquery
852 %type <node> select_or_subquery_without_values_query
853 %type <node> select_stmt
854 %type <node> opt_with_clause
855 %type <node> opt_select_param_list
856 %type <node> opt_from_clause
857 %type <node> select_list
858 %type <node> alias_enabled_expression_list_top
859 %type <node> alias_enabled_expression_list
860 %type <node> alias_enabled_expression_
861 %type <node> expression_list
862 %type <node> to_param_list
863 %type <node> to_param
864 %type <node> from_param
865 %type <node> host_param_input
866 %type <node> host_param_output
867 %type <node> param_
868 %type <node> opt_where_clause
869 %type <node> startwith_clause
870 %type <node> connectby_clause
871 %type <node> opt_groupby_clause
872 %type <node> group_spec_list
873 %type <node> group_spec
874 %type <node> opt_having_clause
875 %type <node> index_name
876 %type <node> index_name_keylimit
877 %type <node> opt_using_index_clause
878 %type <node> index_name_list
879 %type <node> index_name_keylimit_list
880 %type <node> opt_with_increment_clause
881 %type <node> opt_update_orderby_clause
882 %type <node> opt_orderby_clause
883 %type <node> sort_spec_list
884 %type <node> expression_
885 %type <node> normal_expression
886 %type <node> expression_strcat
887 %type <node> expression_add_sub
888 %type <node> expression_bitshift
889 %type <node> expression_bitand
890 %type <node> expression_bitor
891 %type <node> term
892 %type <node> factor
893 %type <node> factor_
894 %type <node> primary
895 %type <node> primary_w_collate
896 %type <node> boolean
897 %type <node> case_expr
898 %type <node> opt_else_expr
899 %type <node> simple_when_clause_list
900 %type <node> simple_when_clause
901 %type <node> searched_when_clause_list
902 %type <node> searched_when_clause
903 %type <node> extract_expr
904 %type <node> opt_expression_list
905 %type <node> table_set_function_call
906 %type <node> search_condition
907 %type <node> boolean_term
908 %type <node> boolean_term_is
909 %type <node> boolean_term_xor
910 %type <node> boolean_factor
911 %type <node> predicate
912 %type <node> predicate_expression
913 %type <node> predicate_expr_sub
914 %type <node> range_list
915 %type <node> range_
916 %type <node> subquery
917 %type <node> path_expression
918 %type <node> data_type_list
919 %type <node> opt_prec_1
920 %type <node> opt_padding
921 %type <node> signed_literal_
922 %type <node> literal_
923 %type <node> literal_w_o_param
924 %type <node> constant_set
925 %type <node> file_path_name
926 %type <node> identifier_list
927 %type <node> opt_bracketed_identifier_list
928 %type <node> index_column_identifier_list
929 %type <node> identifier
930 %type <node> index_column_identifier
931 %type <node> string_literal_or_input_hv
932 %type <node> escape_literal
933 %type <node> char_string_literal
934 %type <node> char_string
935 %type <node> bit_string_literal
936 %type <node> bit_string
937 %type <node> unsigned_integer
938 %type <node> unsigned_int32
939 %type <node> unsigned_real
940 %type <node> monetary_literal
941 %type <node> date_or_time_literal
942 %type <node> json_literal
943 %type <node> partition_clause
944 %type <node> partition_def_list
945 %type <node> partition_def
946 %type <node> signed_literal_list
947 %type <node> insert_name_clause
948 %type <node> replace_name_clause
949 %type <node> insert_name_clause_header
950 %type <node> opt_for_search_condition
951 %type <node> path_header
952 %type <node> path_id_list
953 %type <node> path_id
954 %type <node> simple_path_id
955 %type <node> simple_path_id_list
956 %type <node> generic_function
957 %type <node> opt_on_target
958 %type <node> generic_function_id
959 %type <node> pred_lhs
960 %type <node> pseudo_column
961 %type <node> reserved_func
962 %type <node> sort_spec
963 %type <node> trigger_priority
964 %type <node> class_or_normal_attr_def
965 %type <node> on_class_list
966 %type <node> from_id_list
967 %type <node> to_id_list
968 %type <node> only_class_name
969 %type <node> grant_head
970 %type <node> grant_cmd
971 %type <node> revoke_cmd
972 %type <node> opt_from_table_spec_list
973 %type <node> method_file_list
974 %type <node> incr_arg_name_list__inc
975 %type <node> incr_arg_name__inc
976 %type <node> incr_arg_name_list__dec
977 %type <node> incr_arg_name__dec
978 %type <node> search_condition_query
979 %type <node> search_condition_expression
980 %type <node> opt_select_limit_clause
981 %type <node> limit_options
982 %type <node> opt_upd_del_limit_clause
983 %type <node> truncate_stmt
984 %type <node> do_stmt
985 %type <node> on_duplicate_key_update
986 %type <node> opt_attr_ordering_info
987 %type <node> show_stmt
988 %type <node> session_variable;
989 %type <node> session_variable_assignment_list
990 %type <node> session_variable_assignment
991 %type <node> session_variable_definition
992 %type <node> session_variable_expression
993 %type <node> session_variable_list
994 %type <node> opt_analytic_partition_by
995 %type <node> opt_over_analytic_partition_by
996 %type <node> opt_analytic_order_by
997 %type <node> opt_table_spec_index_hint
998 %type <node> opt_table_spec_index_hint_list
999 %type <node> merge_stmt
1000 %type <node> merge_update_insert_clause
1001 %type <node> merge_update_clause
1002 %type <node> merge_insert_clause
1003 %type <node> opt_merge_delete_clause
1004 %type <node> delete_name
1005 %type <node> delete_name_list
1006 %type <node> collation_spec
1007 %type <node> charset_spec
1008 %type <node> class_comment_spec
1009 %type <node> class_encrypt_spec
1010 %type <node> opt_vclass_comment_spec
1011 %type <node> comment_value
1012 %type <node> opt_comment_spec
1013 %type <node> opt_collation
1014 %type <node> opt_charset
1015 %type <node> opt_using_charset
1016 %type <node> values_query
1017 %type <node> values_expression
1018 %type <node> values_expr_item
1019 %type <node> opt_partition_spec
1020 %type <node> opt_for_update_clause
1021 %type <node> of_or_where
1022 %type <node> named_arg
1023 %type <node> named_args
1024 %type <node> opt_arg_value
1025 %type <node> arg_value
1026 %type <node> arg_value_list
1027 %type <node> kill_stmt
1028 %type <node> vacuum_stmt
1029 %type <node> opt_owner_clause
1030 %type <node> cte_definition_list
1031 %type <node> cte_definition
1032 %type <node> cte_query_list
1033 %type <node> limit_expr
1034 %type <node> limit_term
1035 %type <node> limit_factor
1036 %type <node> json_table_rule
1037 %type <node> json_table_node_rule
1038 %type <node> json_table_column_rule
1039 %type <node> json_table_column_list_rule
1040 /*}}}*/
1041 
1042 /* define rule type (cptr) */
1043 /*{{{*/
1044 %type <cptr> uint_text
1045 %type <cptr> of_integer_real_literal
1046 %type <cptr> integer_text
1047 %type <cptr> json_schema
1048 /*}}}*/
1049 
1050 /* define rule type (container) */
1051 /*{{{*/
1052 %type <c10> opt_serial_option_list
1053 %type <c10> serial_option_list
1054 
1055 %type <c4> isolation_level_spec
1056 %type <c4> opt_constraint_attr_list
1057 %type <c4> constraint_attr_list
1058 %type <c4> constraint_attr
1059 
1060 %type <c3> ref_rule_list
1061 %type <c3> opt_ref_rule_list
1062 %type <c3> of_serial_option
1063 %type <c3> delete_from_using
1064 %type <c3> trigger_status_or_priority_or_change_owner
1065 
1066 %type <c2> extended_table_spec_list
1067 %type <c2> opt_startwith_connectby_clause
1068 %type <c2> opt_of_where_cursor
1069 %type <c2> opt_data_type
1070 %type <c2> opt_create_as_clause
1071 %type <c2> create_as_clause
1072 %type <c2> serial_min
1073 %type <c2> serial_max
1074 %type <c2> of_cached_num
1075 %type <c2> of_cycle_nocycle
1076 %type <c2> data_type
1077 %type <c2> primitive_type
1078 %type <c2> opt_prec_2
1079 %type <c2> in_pred_operand
1080 %type <c2> opt_as_identifier_attr_name
1081 %type <c2> insert_assignment_list
1082 %type <c2> expression_queue
1083 %type <c2> of_cast_data_type
1084 /*}}}*/
1085 
1086 /* define rule type (json_table_column_behavior) */
1087 /*{{{*/
1088 %type <jtcb> json_table_column_behavior_rule
1089 %type <jtcb> json_table_on_error_rule_optional
1090 %type <jtcb> json_table_on_empty_rule_optional
1091 /*}}}*/
1092 
1093 /* Token define */
1094 /*{{{*/
1095 %token ABSOLUTE_
1096 %token ACTION
1097 %token ADD
1098 %token ADD_MONTHS
1099 %token AES
1100 %token AFTER
1101 %token ALL
1102 %token ALLOCATE
1103 %token ALTER
1104 %token AND
1105 %token ANY
1106 %token ARE
1107 %token ARIA
1108 %token AS
1109 %token ASC
1110 %token ASSERTION
1111 %token ASYNC
1112 %token AT
1113 %token ATTACH
1114 %token ATTRIBUTE
1115 %token AVG
1116 %token BEFORE
1117 %token BEGIN_
1118 %token BENCHMARK
1119 %token BETWEEN
1120 %token BIGINT
1121 %token BINARY
1122 %token BIT
1123 %token BIT_LENGTH
1124 %token BITSHIFT_LEFT
1125 %token BITSHIFT_RIGHT
1126 %token BLOB_
1127 %token BOOLEAN_
1128 %token BOTH_
1129 %token BREADTH
1130 %token BY
1131 %token CALL
1132 %token CASCADE
1133 %token CASCADED
1134 %token CASE
1135 %token CAST
1136 %token CATALOG
1137 %token CHANGE
1138 %token CHAR_
1139 %token CHECK
1140 %token CLASS
1141 %token CLASSES
1142 %token CLOB_
1143 %token COALESCE
1144 %token COLLATE
1145 %token COLUMN
1146 %token COMMIT
1147 %token COMP_NULLSAFE_EQ
1148 %token CONNECT
1149 %token CONNECT_BY_ISCYCLE
1150 %token CONNECT_BY_ISLEAF
1151 %token CONNECT_BY_ROOT
1152 %token CONNECTION
1153 %token CONSTRAINT
1154 %token CONSTRAINTS
1155 %token CONTINUE
1156 %token CONVERT
1157 %token CORRESPONDING
1158 %token COUNT
1159 %token CREATE
1160 %token CROSS
1161 %token CURRENT
1162 %token CURRENT_DATE
1163 %token CURRENT_DATETIME
1164 %token CURRENT_TIME
1165 %token CURRENT_TIMESTAMP
1166 %token CURRENT_USER
1167 %token CURSOR
1168 %token CYCLE
1169 %token DATA
1170 %token DATABASE
1171 %token DATA_TYPE___
1172 %token Date
1173 %token DATETIME
1174 %token DATETIMETZ
1175 %token DATETIMELTZ
1176 %token DAY_
1177 %token DAY_MILLISECOND
1178 %token DAY_SECOND
1179 %token DAY_MINUTE
1180 %token DAY_HOUR
1181 %token DB_TIMEZONE
1182 %token DEALLOCATE
1183 %token DECLARE
1184 %token DEFAULT
1185 %token ON_UPDATE
1186 %token DEFERRABLE
1187 %token DEFERRED
1188 %token DELETE_
1189 %token DEPTH
1190 %token DESC
1191 %token DESCRIBE
1192 %token DESCRIPTOR
1193 %token DIAGNOSTICS
1194 %token DIFFERENCE_
1195 %token DISCONNECT
1196 %token DISTINCT
1197 %token DIV
1198 %token DO
1199 %token Domain
1200 %token Double
1201 %token DROP
1202 %token DUPLICATE_
1203 %token EACH
1204 %token ELSE
1205 %token ELSEIF
1206 %token EMPTY
1207 %token ENCRYPT
1208 %token END
1209 %token ENUM
1210 %token EQUALS
1211 %token ERROR_
1212 %token ESCAPE
1213 %token EVALUATE
1214 %token EXCEPT
1215 %token EXCEPTION
1216 %token EXEC
1217 %token EXECUTE
1218 %token EXISTS
1219 %token EXTERNAL
1220 %token EXTRACT
1221 %token False
1222 %token FETCH
1223 %token File
1224 %token FIRST
1225 %token FLOAT_
1226 %token For
1227 %token FORCE
1228 %token FOREIGN
1229 %token FOUND
1230 %token FROM
1231 %token FULL
1232 %token FUNCTION
1233 %token GENERAL
1234 %token GET
1235 %token GLOBAL
1236 %token GO
1237 %token GOTO
1238 %token GRANT
1239 %token GROUP_
1240 %token HAVING
1241 %token HOUR_
1242 %token HOUR_MILLISECOND
1243 %token HOUR_SECOND
1244 %token HOUR_MINUTE
1245 %token IDENTITY
1246 %token IF
1247 %token IGNORE_
1248 %token IMMEDIATE
1249 %token IN_
1250 %token INDEX
1251 %token INDICATOR
1252 %token INHERIT
1253 %token INITIALLY
1254 %token INNER
1255 %token INOUT
1256 %token INPUT_
1257 %token INSERT
1258 %token INTEGER
1259 %token INTERNAL
1260 %token INTERSECT
1261 %token INTERSECTION
1262 %token INTERVAL
1263 %token INTO
1264 %token IS
1265 %token ISOLATION
1266 %token JOIN
1267 %token JSON
1268 %token KEY
1269 %token KEYLIMIT
1270 %token LANGUAGE
1271 %token LAST
1272 %token LEADING_
1273 %token LEAVE
1274 %token LEFT
1275 %token LESS
1276 %token LEVEL
1277 %token LIKE
1278 %token LIMIT
1279 %token LIST
1280 %token LOCAL
1281 %token LOCAL_TRANSACTION_ID
1282 %token LOCALTIME
1283 %token LOCALTIMESTAMP
1284 %token LOOP
1285 %token LOWER
1286 %token MATCH
1287 %token MATCHED
1288 %token Max
1289 %token MERGE
1290 %token METHOD
1291 %token MILLISECOND_
1292 %token Min
1293 %token MINUTE_
1294 %token MINUTE_MILLISECOND
1295 %token MINUTE_SECOND
1296 %token MOD
1297 %token MODIFY
1298 %token MODULE
1299 %token Monetary
1300 %token MONTH_
1301 %token MULTISET
1302 %token MULTISET_OF
1303 %token NA
1304 %token NAMES
1305 %token NATIONAL
1306 %token NATURAL
1307 %token NCHAR
1308 %token NESTED
1309 %token NEXT
1310 %token NO
1311 %token NOT
1312 %token Null
1313 %token NULLIF
1314 %token NUMERIC
1315 %token OBJECT
1316 %token OCTET_LENGTH
1317 %token OF
1318 %token OFF_
1319 %token ONLINE
1320 %token ON_
1321 %token ONLY
1322 %token OPTIMIZATION
1323 %token OPTION
1324 %token OR
1325 %token ORDER
1326 %token ORDINALITY
1327 %token OUT_
1328 %token OUTER
1329 %token OUTPUT
1330 %token OVER
1331 %token OVERLAPS
1332 %token PARALLEL
1333 %token PARAMETERS
1334 %token PARTIAL
1335 %token PARTITION
1336 %token POSITION
1337 %token PRECISION
1338 %token PREPARE
1339 %token PRESERVE
1340 %token PRIMARY
1341 %token PRIOR
1342 %token PRIVILEGES
1343 %token PROCEDURE
1344 %token PROMOTE
1345 %token QUERY
1346 %token READ
1347 %token REBUILD
1348 %token RECURSIVE
1349 %token REF
1350 %token REFERENCES
1351 %token REFERENCING
1352 %token REGEXP
1353 %token REGEXP_COUNT
1354 %token REGEXP_INSTR
1355 %token REGEXP_LIKE
1356 %token REGEXP_REPLACE
1357 %token REGEXP_SUBSTR
1358 %token RELATIVE_
1359 %token RENAME
1360 %token REPLACE
1361 %token RESIGNAL
1362 %token RESTRICT
1363 %token RETURN
1364 %token RETURNS
1365 %token REVOKE
1366 %token RIGHT
1367 %token RLIKE
1368 %token ROLE
1369 %token ROLLBACK
1370 %token ROLLUP
1371 %token ROUTINE
1372 %token ROW
1373 %token ROWNUM
1374 %token ROWS
1375 %token SAVEPOINT
1376 %token SCHEMA
1377 %token SCOPE
1378 %token SCROLL
1379 %token SEARCH
1380 %token SECOND_
1381 %token SECOND_MILLISECOND
1382 %token SECTION
1383 %token SELECT
1384 %token SENSITIVE
1385 %token SEQUENCE
1386 %token SEQUENCE_OF
1387 %token SERIALIZABLE
1388 %token SESSION
1389 %token SESSION_TIMEZONE
1390 %token SESSION_USER
1391 %token SET
1392 %token SET_OF
1393 %token SETEQ
1394 %token SETNEQ
1395 %token SHARED
1396 %token SIBLINGS
1397 %token SIGNAL
1398 %token SIMILAR
1399 %token SIZE_
1400 %token SmallInt
1401 %token SOME
1402 %token SQL
1403 %token SQLCODE
1404 %token SQLERROR
1405 %token SQLEXCEPTION
1406 %token SQLSTATE
1407 %token SQLWARNING
1408 %token STATISTICS
1409 %token String
1410 %token SUBCLASS
1411 %token SUBSET
1412 %token SUBSETEQ
1413 %token SUBSTRING_
1414 %token SUM
1415 %token SUPERCLASS
1416 %token SUPERSET
1417 %token SUPERSETEQ
1418 %token SYS_CONNECT_BY_PATH
1419 %token SYS_DATE
1420 %token SYS_DATETIME
1421 %token SYS_TIME_
1422 %token SYS_TIMESTAMP
1423 %token SYSTEM_USER
1424 %token TABLE
1425 %token TEMPORARY
1426 %token THEN
1427 %token Time
1428 %token TIMESTAMP
1429 %token TIMESTAMPTZ
1430 %token TIMESTAMPLTZ
1431 %token TIMEZONE
1432 %token TIMEZONE_HOUR
1433 %token TIMEZONE_MINUTE
1434 %token TO
1435 %token TRAILING_
1436 %token TRANSACTION
1437 %token TRANSLATE
1438 %token TRANSLATION
1439 %token TRIGGER
1440 %token TRIM
1441 %token True
1442 %token TRUNCATE
1443 %token UNDER
1444 %token Union
1445 %token UNIQUE
1446 %token UNKNOWN
1447 %token UNTERMINATED_STRING
1448 %token UNTERMINATED_IDENTIFIER
1449 %token UPDATE
1450 %token UPPER
1451 %token USAGE
1452 %token USE
1453 %token USER
1454 %token USING
1455 %token Utime
1456 %token VACUUM
1457 %token VALUE
1458 %token VALUES
1459 %token VAR_ASSIGN
1460 %token VARCHAR
1461 %token VARIABLE_
1462 %token VARYING
1463 %token VCLASS
1464 %token VIEW
1465 %token WHEN
1466 %token WHENEVER
1467 %token WHERE
1468 %token WHILE
1469 %token WITH
1470 %token WITHOUT
1471 %token WORK
1472 %token WRITE
1473 %token XOR
1474 %token YEAR_
1475 %token YEAR_MONTH
1476 %token ZONE
1477 
1478 %token YEN_SIGN
1479 %token DOLLAR_SIGN
1480 %token WON_SIGN
1481 %token TURKISH_LIRA_SIGN
1482 %token BRITISH_POUND_SIGN
1483 %token CAMBODIAN_RIEL_SIGN
1484 %token CHINESE_RENMINBI_SIGN
1485 %token INDIAN_RUPEE_SIGN
1486 %token RUSSIAN_RUBLE_SIGN
1487 %token AUSTRALIAN_DOLLAR_SIGN
1488 %token CANADIAN_DOLLAR_SIGN
1489 %token BRASILIAN_REAL_SIGN
1490 %token ROMANIAN_LEU_SIGN
1491 %token EURO_SIGN
1492 %token SWISS_FRANC_SIGN
1493 %token DANISH_KRONE_SIGN
1494 %token NORWEGIAN_KRONE_SIGN
1495 %token BULGARIAN_LEV_SIGN
1496 %token VIETNAMESE_DONG_SIGN
1497 %token CZECH_KORUNA_SIGN
1498 %token POLISH_ZLOTY_SIGN
1499 %token SWEDISH_KRONA_SIGN
1500 %token CROATIAN_KUNA_SIGN
1501 %token SERBIAN_DINAR_SIGN
1502 
1503 %token DOT
1504 %token RIGHT_ARROW
1505 %token DOUBLE_RIGHT_ARROW
1506 %token STRCAT
1507 %token COMP_NOT_EQ
1508 %token COMP_GE
1509 %token COMP_LE
1510 %token PARAM_HEADER
1511 
1512 %token <cptr> ACCESS
1513 %token <cptr> ACTIVE
1514 %token <cptr> ADDDATE
1515 %token <cptr> ANALYZE
1516 %token <cptr> ARCHIVE
1517 %token <cptr> AUTO_INCREMENT
1518 %token <cptr> BIT_AND
1519 %token <cptr> BIT_OR
1520 %token <cptr> BIT_XOR
1521 %token <cptr> BUFFER
1522 %token <cptr> CACHE
1523 %token <cptr> CAPACITY
1524 %token <cptr> CHARACTER_SET_
1525 %token <cptr> CHARSET
1526 %token <cptr> CHR
1527 %token <cptr> CLOB_TO_CHAR
1528 %token <cptr> CLOSE
1529 %token <cptr> COLLATION
1530 %token <cptr> COLUMNS
1531 %token <cptr> COMMENT
1532 %token <cptr> COMMITTED
1533 %token <cptr> COST
1534 %token <cptr> CRITICAL
1535 %token <cptr> CUME_DIST
1536 %token <cptr> DATE_ADD
1537 %token <cptr> DATE_SUB
1538 %token <cptr> DECREMENT
1539 %token <cptr> DENSE_RANK
1540 %token <cptr> DONT_REUSE_OID
1541 %token <cptr> ELT
1542 %token <cptr> EXPLAIN
1543 %token <cptr> FIRST_VALUE
1544 %token <cptr> FULLSCAN
1545 %token <cptr> GE_INF_
1546 %token <cptr> GE_LE_
1547 %token <cptr> GE_LT_
1548 %token <cptr> GRANTS
1549 %token <cptr> GROUP_CONCAT
1550 %token <cptr> GROUPS
1551 %token <cptr> GT_INF_
1552 %token <cptr> GT_LE_
1553 %token <cptr> GT_LT_
1554 %token <cptr> HASH
1555 %token <cptr> HEADER
1556 %token <cptr> HEAP
1557 %token <cptr> IFNULL
1558 %token <cptr> INACTIVE
1559 %token <cptr> INCREMENT
1560 %token <cptr> INDEXES
1561 %token <cptr> INDEX_PREFIX
1562 %token <cptr> INF_LE_
1563 %token <cptr> INF_LT_
1564 %token <cptr> INFINITE_
1565 %token <cptr> INSTANCES
1566 %token <cptr> INVALIDATE
1567 %token <cptr> INVISIBLE
1568 %token <cptr> ISNULL
1569 %token <cptr> KEYS
1570 %token <cptr> KILL
1571 %token <cptr> JAVA
1572 %token <cptr> JSON_ARRAYAGG
1573 %token <cptr> JSON_ARRAY_LEX
1574 %token <cptr> JSON_ARRAY_APPEND
1575 %token <cptr> JSON_ARRAY_INSERT
1576 %token <cptr> JSON_CONTAINS
1577 %token <cptr> JSON_CONTAINS_PATH
1578 %token <cptr> JSON_DEPTH
1579 %token <cptr> JSON_EXTRACT
1580 %token <cptr> JSON_GET_ALL_PATHS
1581 %token <cptr> JSON_INSERT
1582 %token <cptr> JSON_KEYS
1583 %token <cptr> JSON_LENGTH
1584 %token <cptr> JSON_MERGE
1585 %token <cptr> JSON_MERGE_PATCH
1586 %token <cptr> JSON_MERGE_PRESERVE
1587 %token <cptr> JSON_OBJECTAGG
1588 %token <cptr> JSON_OBJECT_LEX
1589 %token <cptr> JSON_PRETTY
1590 %token <cptr> JSON_QUOTE
1591 %token <cptr> JSON_REMOVE
1592 %token <cptr> JSON_REPLACE
1593 %token <cptr> JSON_SEARCH
1594 %token <cptr> JSON_SET
1595 %token <cptr> JSON_TABLE
1596 %token <cptr> JSON_TYPE
1597 %token <cptr> JSON_UNQUOTE
1598 %token <cptr> JSON_VALID
1599 %token <cptr> JOB
1600 %token <cptr> LAG
1601 %token <cptr> LAST_VALUE
1602 %token <cptr> LCASE
1603 %token <cptr> LEAD
1604 %token <cptr> LOCK_
1605 %token <cptr> LOG
1606 %token <cptr> MAXIMUM
1607 %token <cptr> MAXVALUE
1608 %token <cptr> MEDIAN
1609 %token <cptr> MEMBERS
1610 %token <cptr> MINVALUE
1611 %token <cptr> NAME
1612 %token <cptr> NOCYCLE
1613 %token <cptr> NOCACHE
1614 %token <cptr> NOMAXVALUE
1615 %token <cptr> NOMINVALUE
1616 %token <cptr> NONE
1617 %token <cptr> NTH_VALUE
1618 %token <cptr> NTILE
1619 %token <cptr> NULLS
1620 %token <cptr> OFFSET
1621 %token <cptr> OPEN
1622 %token <cptr> PATH
1623 %token <cptr> OWNER
1624 %token <cptr> PAGE
1625 %token <cptr> PARTITIONING
1626 %token <cptr> PARTITIONS
1627 %token <cptr> PASSWORD
1628 %token <cptr> PERCENT_RANK
1629 %token <cptr> PERCENTILE_CONT
1630 %token <cptr> PERCENTILE_DISC
1631 %token <cptr> PRINT
1632 %token <cptr> PRIORITY
1633 %token <cptr> QUARTER
1634 %token <cptr> QUEUES
1635 %token <cptr> RANGE_
1636 %token <cptr> RANK
1637 %token <cptr> REJECT_
1638 %token <cptr> REMOVE
1639 %token <cptr> REORGANIZE
1640 %token <cptr> REPEATABLE
1641 %token <cptr> RESPECT
1642 %token <cptr> RETAIN
1643 %token <cptr> REUSE_OID
1644 %token <cptr> REVERSE
1645 %token <cptr> DISK_SIZE
1646 %token <cptr> ROW_NUMBER
1647 %token <cptr> SECTIONS
1648 %token <cptr> SEPARATOR
1649 %token <cptr> SERIAL
1650 %token <cptr> SHOW
1651 %token <cptr> SLEEP
1652 %token <cptr> SLOTS
1653 %token <cptr> SLOTTED
1654 %token <cptr> STABILITY
1655 %token <cptr> START_
1656 %token <cptr> STATEMENT
1657 %token <cptr> STATUS
1658 %token <cptr> STDDEV
1659 %token <cptr> STDDEV_POP
1660 %token <cptr> STDDEV_SAMP
1661 %token <cptr> STR_TO_DATE
1662 %token <cptr> SUBDATE
1663 %token <cptr> SYSTEM
1664 %token <cptr> TABLES
1665 %token <cptr> TEXT
1666 %token <cptr> THAN
1667 %token <cptr> THREADS
1668 %token <cptr> TIMEOUT
1669 %token <cptr> TRACE
1670 %token <cptr> TRAN
1671 %token <cptr> TRIGGERS
1672 %token <cptr> UCASE
1673 %token <cptr> UNCOMMITTED
1674 %token <cptr> VAR_POP
1675 %token <cptr> VAR_SAMP
1676 %token <cptr> VARIANCE
1677 %token <cptr> VISIBLE
1678 %token <cptr> VOLUME
1679 %token <cptr> WEEK
1680 %token <cptr> WITHIN
1681 %token <cptr> WORKSPACE
1682 %token <cptr> TIMEZONES
1683 
1684 
1685 %token <cptr> IdName
1686 %token <cptr> BracketDelimitedIdName
1687 %token <cptr> BacktickDelimitedIdName
1688 %token <cptr> DelimitedIdName
1689 %token <cptr> UNSIGNED_INTEGER
1690 %token <cptr> UNSIGNED_REAL
1691 %token <cptr> CHAR_STRING
1692 %token <cptr> NCHAR_STRING
1693 %token <cptr> BIT_STRING
1694 %token <cptr> HEX_STRING
1695 %token <cptr> CPP_STYLE_HINT
1696 %token <cptr> C_STYLE_HINT
1697 %token <cptr> SQL_STYLE_HINT
1698 %token <cptr> BINARY_STRING
1699 %token <cptr> EUCKR_STRING
1700 %token <cptr> ISO_STRING
1701 %token <cptr> UTF8_STRING
1702 
1703 /*}}}*/
1704 
1705 %%
1706 
1707 stmt_done
1708  : stmt_list
1709  | /* empty */
1710  ;
1711 
1712 stmt_list
1713  : stmt_list stmt %dprec 1
1714  {{
1715 
1716  if ($2 != NULL)
1717  {
1718  if (parser_statement_OK)
1719  {
1720  this_parser->statement_number++;
1721  }
1722  else
1723  {
1724  parser_statement_OK = 1;
1725  }
1726 
1727  pt_push (this_parser, $2);
1728 
1729  #ifdef PARSER_DEBUG
1730  printf ("node: %s\n", parser_print_tree (this_parser, $2));
1731  #endif
1732  }
1733 
1734  DBG_PRINT}}
1735  | stmt %dprec 2
1736  {{
1737 
1738  if ($1 != NULL)
1739  {
1740  if (parser_statement_OK)
1741  {
1742  this_parser->statement_number++;
1743  }
1744  else
1745  {
1746  parser_statement_OK = 1;
1747  }
1748 
1749  pt_push (this_parser, $1);
1750 
1751  #ifdef PARSER_DEBUG
1752  printf ("node: %s\n", parser_print_tree (this_parser, $1));
1753  #endif
1754  }
1755 
1756  DBG_PRINT}}
1757  ;
1758 
1759 
1760 
1761 stmt
1762  :
1763  {{
1764  msg_ptr = 0;
1765 
1766  if (this_parser->original_buffer)
1767  {
1768  int pos = @$.buffer_pos;
1769  int stmt_n = this_parser->statement_number;
1770 
1771  if (g_original_buffer_len == 0)
1772  {
1773  g_original_buffer_len = strlen (this_parser->original_buffer);
1774  }
1775 
1776  /* below assert & defence code is for yybuffer_pos mismatch
1777  * (like unput in lexer and do not modify yybuffer_pos)
1778  */
1779  assert (pos <= g_original_buffer_len);
1780 
1781  if (pos > g_original_buffer_len)
1782  {
1783  pos = g_original_buffer_len;
1784  }
1785 
1786  g_query_string = (char*) (this_parser->original_buffer + pos);
1787 
1788  while (char_isspace (*g_query_string))
1789  {
1790  g_query_string++;
1791  }
1792  }
1793 
1794  DBG_PRINT}}
1795  {{
1796 
1797  parser_initialize_parser_context ();
1798 
1799  parser_statement_OK = 1;
1800  parser_instnum_check = 0;
1801  parser_groupbynum_check = 0;
1802  parser_orderbynum_check = 0;
1803 
1804  parser_sysconnectbypath_check = 0;
1805  parser_prior_check = 0;
1806  parser_connectbyroot_check = 0;
1807  parser_serial_check = 1;
1808  parser_subquery_check = 1;
1809  parser_pseudocolumn_check = 1;
1810  parser_hostvar_check = 1;
1811 
1812  parser_select_level = -1;
1813 
1814  parser_within_join_condition = 0;
1815  parser_found_Oracle_outer = false;
1816 
1817  parser_save_and_set_si_datetime (false);
1818  parser_save_and_set_si_tran_id (false);
1819  parser_save_and_set_cannot_prepare (false);
1820 
1821  parser_attr_type = PT_NORMAL;
1822  allow_attribute_ordering = false;
1823  parser_hidden_incr_list = NULL;
1824 
1825  DBG_PRINT}}
1826  stmt_
1827  {{
1828 
1829  #ifdef PARSER_DEBUG
1830  if (msg_ptr == 0)
1831  printf ("Good!!!\n");
1832  #endif
1833 
1834  if (msg_ptr > 0)
1835  {
1836  csql_yyerror (NULL);
1837  }
1838 
1839  /* set query length of last statement (but do it every time)
1840  * Not last statement's length will be updated later.
1841  */
1842  if (this_parser->original_buffer)
1843  {
1844  int pos = @$.buffer_pos;
1845  PT_NODE *node = $3;
1846 
1847  if (g_original_buffer_len == 0)
1848  {
1849  g_original_buffer_len = strlen (this_parser->original_buffer);
1850  }
1851 
1852  /* below assert & defence code is for yybuffer_pos mismatch
1853  * (like unput in lexer and do not modify yybuffer_pos)
1854  */
1855  assert (pos <= g_original_buffer_len);
1856 
1857  if (pos > g_original_buffer_len)
1858  {
1859  pos = g_original_buffer_len;
1860  }
1861 
1862  if (node)
1863  {
1864  const char *curr_ptr = this_parser->original_buffer + pos;
1865  int len = (int) (curr_ptr - g_query_string);
1866  node->sql_user_text_len = len;
1867  g_query_string_len = len;
1868  }
1869  }
1870 
1871  DBG_PRINT}}
1872  {{
1873 
1874  PT_NODE *node = $3;
1875 
1876  if (node)
1877  {
1878  node->flag.si_datetime = (parser_si_datetime == true) ? 1 : 0;
1879  node->flag.si_tran_id = (parser_si_tran_id == true) ? 1 : 0;
1880  node->flag.cannot_prepare = (parser_cannot_prepare == true) ? 1 : 0;
1881  }
1882 
1883  parser_restore_si_datetime ();
1884  parser_restore_si_tran_id ();
1885  parser_restore_cannot_prepare ();
1886 
1887  $$ = node;
1888  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
1889 
1890  DBG_PRINT}}
1891  | ';'
1892  {{
1893 
1894  $$ = NULL;
1895 
1896  DBG_PRINT}}
1897  ;
1898 stmt_
1899  : create_stmt
1900  { $$ = $1; }
1901  | alter_stmt
1902  { $$ = $1; }
1903  | rename_stmt
1904  { $$ = $1; }
1905  | update_statistics_stmt
1906  { $$ = $1; }
1907  | drop_stmt
1908  { $$ = $1; }
1909  | do_stmt
1910  { $$ = $1; }
1911  | opt_with_clause
1912  esql_query_stmt
1913  {{
1914  PT_NODE *with_clause = $1;
1915  PT_NODE *stmt = $2;
1916  if (stmt && with_clause)
1917  {
1918  stmt->info.query.with = with_clause;
1919  }
1920  $$ = stmt;
1921  DBG_PRINT}}
1922  | evaluate_stmt
1923  { $$ = $1; }
1924  | prepare_stmt
1925  { $$ = $1; }
1926  | execute_stmt
1927  { $$ = $1; }
1928  | insert_or_replace_stmt
1929  { $$ = $1; }
1930  | opt_with_clause
1931  update_stmt
1932  {{
1933  PT_NODE *with_clause = $1;
1934  PT_NODE *stmt = $2;
1935  if (stmt && with_clause)
1936  {
1937  stmt->info.update.with = with_clause;
1938  }
1939  $$ = stmt;
1940  DBG_PRINT}}
1941  | opt_with_clause
1942  delete_stmt
1943  {{
1944  PT_NODE *with_clause = $1;
1945  PT_NODE *stmt = $2;
1946  if (stmt && with_clause)
1947  {
1948  stmt->info.delete_.with = with_clause;
1949  }
1950  $$ = stmt;
1951  DBG_PRINT}}
1952  | show_stmt
1953  { $$ = $1; }
1954  | call_stmt
1955  { $$ = $1; }
1956  | auth_stmt
1957  { $$ = $1; }
1958  | transaction_stmt
1959  { $$ = $1; }
1960  | truncate_stmt
1961  { $$ = $1; }
1962  | merge_stmt
1963  { $$ = $1; }
1964  | set_stmt
1965  { $$ = $1; }
1966  | get_stmt
1967  { $$ = $1; }
1968  | kill_stmt
1969  { $$ = $1; }
1970  | DATA_TYPE___ data_type
1971  {{
1972 
1973  PT_NODE *dt, *set_dt;
1974  PT_TYPE_ENUM typ;
1975 
1976  typ = (PT_TYPE_ENUM) TO_NUMBER (CONTAINER_AT_0 ($2));
1977  dt = CONTAINER_AT_1 ($2);
1978 
1979  if (!dt)
1980  {
1981  dt = parser_new_node (this_parser, PT_DATA_TYPE);
1982  if (dt)
1983  {
1984  dt->type_enum = typ;
1985  dt->data_type = NULL;
1986  }
1987  }
1988  else
1989  {
1990  if ((typ == PT_TYPE_SET) ||
1991  (typ == PT_TYPE_MULTISET) || (typ == PT_TYPE_SEQUENCE))
1992  {
1993  set_dt = parser_new_node (this_parser, PT_DATA_TYPE);
1994  if (set_dt)
1995  {
1996  set_dt->type_enum = typ;
1997  set_dt->data_type = dt;
1998  dt = set_dt;
1999  }
2000  }
2001  }
2002 
2003  if (PT_HAS_COLLATION (typ))
2004  {
2005  dt->info.data_type.units = LANG_SYS_CODESET;
2006  dt->info.data_type.collation_id = LANG_SYS_COLLATION;
2007  }
2008 
2009  $$ = dt;
2010  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
2011 
2012  DBG_PRINT}}
2013  | ATTACH
2014  { push_msg(MSGCAT_SYNTAX_INVALID_ATTACH); }
2015  unsigned_integer
2016  { pop_msg(); }
2017  {{
2018 
2019  PT_NODE *node = parser_new_node (this_parser, PT_2PC_ATTACH);
2020 
2021  if (node)
2022  {
2023  node->info.attach.trans_id = $3->info.value.data_value.i;
2024  }
2025 
2026  $$ = node;
2027  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
2028 
2029  DBG_PRINT}}
2030  | PREPARE
2031  { push_msg(MSGCAT_SYNTAX_INVALID_PREPARE); }
2032  opt_to COMMIT unsigned_integer
2033  { pop_msg(); }
2034  {{
2035 
2036  PT_NODE *node = parser_new_node (this_parser, PT_PREPARE_TO_COMMIT);
2037 
2038  if (node)
2039  {
2040  node->info.prepare_to_commit.trans_id = $5->info.value.data_value.i;
2041  }
2042 
2043  $$ = node;
2044  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
2045 
2046  DBG_PRINT}}
2047  | EXECUTE
2048  { push_msg(MSGCAT_SYNTAX_INVALID_EXECUTE); }
2049  DEFERRED TRIGGER trigger_spec_list
2050  { pop_msg(); }
2051  {{
2052 
2053  PT_NODE *node = parser_new_node (this_parser, PT_EXECUTE_TRIGGER);
2054 
2055  if (node)
2056  {
2057  node->info.execute_trigger.trigger_spec_list = $5;
2058  }
2059 
2060  $$ = node;
2061  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
2062 
2063  DBG_PRINT}}
2064  | SCOPE
2065  { push_msg(MSGCAT_SYNTAX_INVALID_SCOPE); }
2066  trigger_action opt_from_table_spec_list
2067  { pop_msg(); }
2068  {{
2069 
2070  PT_NODE *node = parser_new_node (this_parser, PT_SCOPE);
2071 
2072  if (node)
2073  {
2074  node->info.scope.stmt = $3;
2075  node->info.scope.from = $4;
2076  }
2077 
2078  $$ = node;
2079  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
2080 
2081  DBG_PRINT}}
2082  | vacuum_stmt
2083  { $$ = $1; }
2084 
2085  | SET TIMEZONE
2086  { push_msg(MSGCAT_SYNTAX_INVALID_SET_TIMEZONE); }
2087  char_string_literal
2088  { pop_msg(); }
2089  {{
2090  PT_NODE *node = parser_new_node (this_parser, PT_SET_TIMEZONE);
2091  if (node)
2092  {
2093  node->info.set_timezone.timezone_node = $4;
2094  }
2095 
2096  $$ = node;
2097  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
2098 
2099  DBG_PRINT}}
2100  | SET Time ZONE
2101  { push_msg(MSGCAT_SYNTAX_INVALID_SET_TIMEZONE); }
2102  char_string_literal
2103  { pop_msg(); }
2104  {{
2105  PT_NODE *node = parser_new_node (this_parser, PT_SET_TIMEZONE);
2106  if (node)
2107  {
2108  node->info.set_timezone.timezone_node = $5;
2109  }
2110 
2111  $$ = node;
2112  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
2113 
2114  DBG_PRINT}}
2115  ;
2116 
2117 
2118 opt_from_table_spec_list
2119  : /* empty */
2120  { $$ = NULL; }
2121  | FROM ON_ table_spec_list
2122  { $$ = $3; }
2123  ;
2124 
2125 
2126 set_stmt
2127  : SET OPTIMIZATION
2128  { push_msg(MSGCAT_SYNTAX_INVALID_SET_OPT_LEVEL); }
2129  LEVEL opt_of_to_eq opt_level_spec
2130  { pop_msg(); }
2131  {{
2132 
2133  PT_NODE *node = parser_new_node (this_parser, PT_SET_OPT_LVL);
2134  if (node)
2135  {
2136  node->info.set_opt_lvl.option = PT_OPT_LVL;
2137  node->info.set_opt_lvl.val = $6;
2138  }
2139 
2140  $$ = node;
2141  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
2142 
2143  DBG_PRINT}}
2144  | SET OPTIMIZATION
2145  { push_msg(MSGCAT_SYNTAX_INVALID_SET_OPT_COST); }
2146  COST opt_of char_string_literal opt_of_to_eq literal_
2147  { pop_msg(); }
2148  {{
2149 
2150  PT_NODE *node = parser_new_node (this_parser, PT_SET_OPT_LVL);
2151  if (node)
2152  {
2153  node->info.set_opt_lvl.option = PT_OPT_COST;
2154  if ($6)
2155  ($6)->next = $8;
2156  node->info.set_opt_lvl.val = $6;
2157  }
2158 
2159  $$ = node;
2160  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
2161 
2162  DBG_PRINT}}
2163  | SET
2164  { push_msg(MSGCAT_SYNTAX_INVALID_SET_SYS_PARAM); }
2165  SYSTEM PARAMETERS char_string_literal_list
2166  { pop_msg(); }
2167  {{
2168 
2169  PT_NODE *node = parser_new_node (this_parser, PT_SET_SYS_PARAMS);
2170  if (node)
2171  node->info.set_sys_params.val = $5;
2172  $$ = node;
2173  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
2174 
2175  DBG_PRINT}}
2176  | SET
2177  { push_msg(MSGCAT_SYNTAX_INVALID_SET_TRAN); }
2178  TRANSACTION transaction_mode_list
2179  { pop_msg(); }
2180  {{
2181 
2182  PT_NODE *node = parser_new_node (this_parser, PT_SET_XACTION);
2183 
2184  if (node)
2185  {
2186  node->info.set_xaction.xaction_modes = $4;
2187  }
2188 
2189  $$ = node;
2190  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
2191 
2192  DBG_PRINT}}
2193  | SET TRIGGER
2194  { push_msg(MSGCAT_SYNTAX_INVALID_SET_TRIGGER_TRACE); }
2195  TRACE trace_spec
2196  { pop_msg(); }
2197  {{
2198 
2199  PT_NODE *node = parser_new_node (this_parser, PT_SET_TRIGGER);
2200 
2201  if (node)
2202  {
2203  node->info.set_trigger.option = PT_TRIGGER_TRACE;
2204  node->info.set_trigger.val = $5;
2205  }
2206 
2207  $$ = node;
2208  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
2209 
2210  DBG_PRINT}}
2211  | SET TRIGGER
2212  { push_msg(MSGCAT_SYNTAX_INVALID_SET_TRIGGER_DEPTH); }
2213  opt_maximum DEPTH depth_spec
2214  { pop_msg(); }
2215  {{
2216 
2217  PT_NODE *node = parser_new_node (this_parser, PT_SET_TRIGGER);
2218 
2219  if (node)
2220  {
2221  node->info.set_trigger.option = PT_TRIGGER_DEPTH;
2222  node->info.set_trigger.val = $6;
2223  }
2224 
2225  $$ = node;
2226  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
2227 
2228  DBG_PRINT}}
2229  | SET session_variable_assignment_list
2230  {{
2231 
2232  PT_NODE *node =
2233  parser_new_node (this_parser, PT_SET_SESSION_VARIABLES);
2234  if (node)
2235  {
2236  node->info.set_variables.assignments = $2;
2237  }
2238  $$ = node;
2239  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
2240 
2241  DBG_PRINT}}
2242  | SET NAMES BINARY
2243  {{
2244 
2245  PT_NODE *node = NULL;
2246  PT_NODE *charset_node = NULL;
2247 
2248  charset_node = parser_new_node (this_parser, PT_VALUE);
2249 
2250  if (charset_node)
2251  {
2252  charset_node->type_enum = PT_TYPE_CHAR;
2253  charset_node->info.value.string_type = ' ';
2254  charset_node->info.value.data_value.str =
2255  pt_append_bytes (this_parser, NULL, "binary", strlen ("binary"));
2256  PT_NODE_PRINT_VALUE_TO_TEXT (this_parser, charset_node);
2257  }
2258 
2259  node = parser_new_node (this_parser, PT_SET_NAMES);
2260  if (node)
2261  {
2262  node->info.set_names.charset_node = charset_node;
2263  node->info.set_names.collation_node = NULL;
2264  }
2265  $$ = node;
2266  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
2267 
2268  DBG_PRINT}}
2269  | SET
2270  { push_msg(MSGCAT_SYNTAX_INVALID_SET_NAMES); }
2271  NAMES char_string_literal
2272  opt_collation
2273  { pop_msg(); }
2274  {{
2275 
2276  PT_NODE *node = parser_new_node (this_parser, PT_SET_NAMES);
2277  if (node)
2278  {
2279  node->info.set_names.charset_node = $4;
2280  node->info.set_names.collation_node = $5;
2281  }
2282 
2283  $$ = node;
2284  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
2285 
2286  DBG_PRINT}}
2287  | SET
2288  { push_msg(MSGCAT_SYNTAX_INVALID_SET_NAMES); }
2289  NAMES IdName
2290  opt_collation
2291  { pop_msg(); }
2292  {{
2293 
2294  PT_NODE *node = NULL;
2295  PT_NODE *charset_node = NULL;
2296 
2297  charset_node = parser_new_node (this_parser, PT_VALUE);
2298 
2299  if (charset_node)
2300  {
2301  charset_node->type_enum = PT_TYPE_CHAR;
2302  charset_node->info.value.string_type = ' ';
2303  charset_node->info.value.data_value.str =
2304  pt_append_bytes (this_parser, NULL, $4, strlen ($4));
2305  PT_NODE_PRINT_VALUE_TO_TEXT (this_parser, charset_node);
2306  }
2307 
2308  node = parser_new_node (this_parser, PT_SET_NAMES);
2309  if (node)
2310  {
2311  node->info.set_names.charset_node = charset_node;
2312  node->info.set_names.collation_node = $5;
2313  }
2314  $$ = node;
2315  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
2316 
2317  DBG_PRINT}}
2318  | SET TRACE query_trace_spec opt_trace_output_format
2319  {{
2320 
2321  PT_NODE *node = parser_new_node (this_parser, PT_QUERY_TRACE);
2322 
2323  if (node)
2324  {
2325  node->info.trace.on_off = $3;
2326  node->info.trace.format = $4;
2327  }
2328 
2329  $$ = node;
2330 
2331  DBG_PRINT}}
2332  ;
2333 
2334 query_trace_spec
2335  : ON_
2336  {{
2337  $$ = PT_TRACE_ON;
2338  DBG_PRINT}}
2339  | OFF_
2340  {{
2341  $$ = PT_TRACE_OFF;
2342  DBG_PRINT}}
2343  ;
2344 
2345 opt_trace_output_format
2346  : /* empty */
2347  {{
2348  $$ = PT_TRACE_FORMAT_TEXT;
2349  DBG_PRINT}}
2350  | OUTPUT TEXT
2351  {{
2352  $$ = PT_TRACE_FORMAT_TEXT;
2353  DBG_PRINT}}
2354  | OUTPUT JSON
2355  {{
2356  $$ = PT_TRACE_FORMAT_JSON;
2357  DBG_PRINT}}
2358  ;
2359 
2360 session_variable_assignment_list
2361  : session_variable_assignment_list ',' session_variable_assignment
2362  {{
2363 
2364  $$ = parser_make_link ($1, $3);
2365  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
2366 
2367  DBG_PRINT}}
2368 
2369  | session_variable_assignment
2370  {{
2371 
2372  $$ = $1;
2373  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
2374 
2375  DBG_PRINT}}
2376  ;
2377 
2378 session_variable_assignment
2379  : session_variable '=' expression_
2380  {{
2381 
2382  PT_NODE* expr =
2383  parser_make_expression (this_parser, PT_DEFINE_VARIABLE, $1, $3, NULL);
2384  expr->flag.do_not_fold = 1;
2385  $$ = expr;
2386  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
2387 
2388  DBG_PRINT}}
2389  | session_variable_definition
2390  {{
2391 
2392  $$ = $1;
2393  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
2394 
2395  DBG_PRINT}}
2396  ;
2397 
2398 session_variable_definition
2399  : session_variable VAR_ASSIGN expression_
2400  {{
2401 
2402  PT_NODE* expr =
2403  parser_make_expression (this_parser, PT_DEFINE_VARIABLE, $1, $3, NULL);
2404  expr->flag.do_not_fold = 1;
2405  $$ = expr;
2406  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
2407 
2408  DBG_PRINT}}
2409  ;
2410 
2411 session_variable_expression
2412  : session_variable
2413  {{
2414 
2415  PT_NODE *expr = NULL;
2416  expr = parser_make_expression (this_parser, PT_EVALUATE_VARIABLE, $1, NULL,
2417  NULL);
2418  expr->flag.do_not_fold = 1;
2419  $$ = expr;
2420  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
2421 
2422  DBG_PRINT}}
2423  ;
2424 
2425 session_variable_list
2426  : session_variable_list ',' session_variable
2427  {{
2428 
2429  $$ = parser_make_link ($1, $3);
2430  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
2431 
2432  DBG_PRINT}}
2433  | session_variable
2434  {{
2435 
2436  $$ = $1;
2437  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
2438 
2439  DBG_PRINT}}
2440  ;
2441 
2442 session_variable
2443  : '@' identifier
2444  {{
2445 
2446  PT_NODE *node = parser_new_node (this_parser, PT_VALUE);
2447  PT_NODE *id = $2;
2448 
2449  if (node != NULL && id != NULL)
2450  {
2451  node->type_enum = PT_TYPE_CHAR;
2452  node->info.value.string_type = ' ';
2453  node->info.value.data_value.str =
2454  pt_append_bytes (this_parser, NULL,
2455  id->info.name.original,
2456  strlen (id->info.name.original));
2457  node->info.value.text = (const char *) node->info.value.data_value.str->bytes;
2458  }
2459 
2460  $$ = node;
2461  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
2462 
2463  DBG_PRINT}}
2464  ;
2465 
2466 get_stmt
2467  : GET
2468  { push_msg(MSGCAT_SYNTAX_INVALID_GET_STAT); }
2469  STATISTICS char_string_literal OF class_name into_clause_opt
2470  { pop_msg(); }
2471  {{
2472 
2473  PT_NODE *node = parser_new_node (this_parser, PT_GET_STATS);
2474  if (node)
2475  {
2476  node->info.get_stats.into_var = $7;
2477  node->info.get_stats.class_ = $6;
2478  node->info.get_stats.args = $4;
2479  }
2480  $$ = node;
2481  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
2482 
2483  DBG_PRINT}}
2484  | GET OPTIMIZATION
2485  { push_msg(MSGCAT_SYNTAX_INVALID_GET_OPT_LEVEL); }
2486  LEVEL into_clause_opt
2487  { pop_msg(); }
2488  {{
2489 
2490  PT_NODE *node = parser_new_node (this_parser, PT_GET_OPT_LVL);
2491  if (node)
2492  {
2493  node->info.get_opt_lvl.into_var = $5;
2494  node->info.get_opt_lvl.option = PT_OPT_LVL;
2495  node->info.get_opt_lvl.args = NULL;
2496  }
2497  $$ = node;
2498  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
2499 
2500  DBG_PRINT}}
2501  | GET OPTIMIZATION
2502  { push_msg(MSGCAT_SYNTAX_INVALID_GET_OPT_COST); }
2503  COST opt_of char_string_literal into_clause_opt
2504  { pop_msg(); }
2505  {{
2506 
2507  PT_NODE *node = parser_new_node (this_parser, PT_GET_OPT_LVL);
2508  if (node)
2509  {
2510  node->info.get_opt_lvl.into_var = $7;
2511  node->info.get_opt_lvl.option = PT_OPT_COST;
2512  node->info.get_opt_lvl.args = $6;
2513  }
2514  $$ = node;
2515  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
2516 
2517  DBG_PRINT}}
2518  | GET TRANSACTION
2519  { push_msg(MSGCAT_SYNTAX_INVALID_GET_TRAN_ISOL); }
2520  ISOLATION LEVEL into_clause_opt
2521  { pop_msg(); }
2522  {{
2523 
2524  PT_NODE *node = parser_new_node (this_parser, PT_GET_XACTION);
2525 
2526  if (node)
2527  {
2528  node->info.get_xaction.into_var = $6;
2529  node->info.get_xaction.option = PT_ISOLATION_LEVEL;
2530  }
2531 
2532  $$ = node;
2533  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
2534 
2535  DBG_PRINT}}
2536  | GET TRANSACTION
2537  { push_msg(MSGCAT_SYNTAX_INVALID_GET_TRAN_LOCK); }
2538  LOCK_ TIMEOUT into_clause_opt
2539  { pop_msg(); }
2540  {{
2541 
2542  PT_NODE *node = parser_new_node (this_parser, PT_GET_XACTION);
2543 
2544  if (node)
2545  {
2546  node->info.get_xaction.into_var = $6;
2547  node->info.get_xaction.option = PT_LOCK_TIMEOUT;
2548  }
2549 
2550  $$ = node;
2551  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
2552 
2553  DBG_PRINT}}
2554  | GET TRIGGER
2555  { push_msg(MSGCAT_SYNTAX_INVALID_GET_TRIGGER_TRACE); }
2556  TRACE into_clause_opt
2557  { pop_msg(); }
2558  {{
2559 
2560  PT_NODE *node = parser_new_node (this_parser, PT_GET_TRIGGER);
2561 
2562  if (node)
2563  {
2564  node->info.get_trigger.into_var = $5;
2565  node->info.get_trigger.option = PT_TRIGGER_TRACE;
2566  }
2567 
2568  $$ = node;
2569  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
2570 
2571  DBG_PRINT}}
2572  | GET TRIGGER
2573  { push_msg(MSGCAT_SYNTAX_INVALID_GET_TRIGGER_DEPTH); }
2574  opt_maximum DEPTH into_clause_opt
2575  { pop_msg(); }
2576  {{
2577 
2578  PT_NODE *node = parser_new_node (this_parser, PT_GET_TRIGGER);
2579 
2580  if (node)
2581  {
2582  node->info.get_trigger.into_var = $6;
2583  node->info.get_trigger.option = PT_TRIGGER_DEPTH;
2584  }
2585 
2586  $$ = node;
2587  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
2588 
2589  DBG_PRINT}}
2590  ;
2591 
2592 
2593 
2594 
2595 create_stmt
2596  : CREATE /* 1 */
2597  { /* 2 */
2598  PT_NODE* qc = parser_new_node(this_parser, PT_CREATE_ENTITY);
2599  parser_push_hint_node(qc);
2600  }
2601  opt_hint_list /* 3 */
2602  of_class_table_type /* 4 */
2603  opt_if_not_exists /* 5 */
2604  class_name /* 6 */
2605  opt_subtable_clause /* 7 */
2606  opt_class_attr_def_list /* 8 */
2607  opt_class_or_normal_attr_def_list /* 9 */
2608  opt_table_option_list /* 10 */
2609  opt_method_def_list /* 11 */
2610  opt_method_files /* 12 */
2611  opt_inherit_resolution_list /* 13 */
2612  opt_partition_clause /* 14 */
2613  opt_create_as_clause /* 15 */
2614  {{
2615 
2616  PT_NODE *qc = parser_pop_hint_node ();
2617  PARSER_SAVE_ERR_CONTEXT (qc, @$.buffer_pos)
2618 
2619  if (CONTAINER_AT_1 ($15) != NULL)
2620  {
2621  if ($7 != NULL || $8 != NULL || $11 != NULL
2622  || $12 != NULL || $13 != NULL)
2623  {
2624  PT_ERRORf (this_parser, qc, "check syntax at %s",
2625  parser_print_tree (this_parser, qc));
2626  }
2627  }
2628 
2629  if (qc)
2630  {
2631  qc->info.create_entity.if_not_exists = $5;
2632  qc->info.create_entity.entity_name = $6;
2633  qc->info.create_entity.entity_type = (PT_MISC_TYPE) $4;
2634  qc->info.create_entity.supclass_list = $7;
2635  qc->info.create_entity.class_attr_def_list = $8;
2636  qc->info.create_entity.attr_def_list = $9;
2637  qc->info.create_entity.table_option_list = $10;
2638  qc->info.create_entity.method_def_list = $11;
2639  qc->info.create_entity.method_file_list = $12;
2640  qc->info.create_entity.resolution_list = $13;
2641  qc->info.create_entity.partition_info = $14;
2642  if (CONTAINER_AT_1 ($15) != NULL)
2643  {
2644  qc->info.create_entity.create_select_action = TO_NUMBER(CONTAINER_AT_0 ($15));
2645  qc->info.create_entity.create_select = CONTAINER_AT_1 ($15);
2646  }
2647 
2648  pt_gather_constraints (this_parser, qc);
2649  }
2650 
2651  $$ = qc;
2652 
2653  DBG_PRINT}}
2654  | CREATE /* 1 */
2655  opt_or_replace /* 2 */
2656  of_view_vclass /* 3 */
2657  class_name /* 4 */
2658  opt_subtable_clause /* 5 */
2659  opt_class_attr_def_list /* 6 */
2660  opt_paren_view_attr_def_list /* 7 */
2661  opt_method_def_list /* 8 */
2662  opt_method_files /* 9 */
2663  opt_inherit_resolution_list /* 10 */
2664  opt_as_query_list /* 11 */
2665  opt_with_levels_clause /* 12 */
2666  opt_vclass_comment_spec /* 13 */
2667  {{
2668 
2669  PT_NODE *qc = parser_new_node (this_parser, PT_CREATE_ENTITY);
2670 
2671  if (qc)
2672  {
2673  qc->info.create_entity.or_replace = $2;
2674 
2675  qc->info.create_entity.entity_name = $4;
2676  qc->info.create_entity.entity_type = PT_VCLASS;
2677 
2678  qc->info.create_entity.supclass_list = $5;
2679  qc->info.create_entity.class_attr_def_list = $6;
2680  qc->info.create_entity.attr_def_list = $7;
2681  qc->info.create_entity.method_def_list = $8;
2682  qc->info.create_entity.method_file_list = $9;
2683  qc->info.create_entity.resolution_list = $10;
2684  qc->info.create_entity.as_query_list = $11;
2685  qc->info.create_entity.with_check_option = $12;
2686  qc->info.create_entity.vclass_comment = $13;
2687 
2688  pt_gather_constraints (this_parser, qc);
2689  }
2690 
2691 
2692  $$ = qc;
2693  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
2694 
2695  DBG_PRINT}}
2696  | CREATE /* 1 */
2697  { /* 2 */
2698  PT_NODE* node = parser_new_node (this_parser, PT_CREATE_INDEX);
2699  parser_push_hint_node (node);
2700  push_msg (MSGCAT_SYNTAX_INVALID_CREATE_INDEX);
2701  }
2702  opt_hint_list /* 3 */
2703  opt_reverse /* 4 */
2704  opt_unique /* 5 */
2705  INDEX /* 6 */
2706  { pop_msg(); } /* 7 */
2707  identifier /* 8 */
2708  ON_ /* 9 */
2709  only_class_name /* 10 */
2710  index_column_name_list /* 11 */
2711  opt_where_clause /* 12 */
2712  opt_comment_spec /* 13 */
2713  opt_with_online /* 14 */
2714  opt_invisible /* 15 */
2715  {{
2716 
2717  PT_NODE *node = parser_pop_hint_node ();
2718  PT_NODE *ocs = parser_new_node(this_parser, PT_SPEC);
2719  PARSER_SAVE_ERR_CONTEXT (node, @$.buffer_pos)
2720 
2721  if ($5 && $12)
2722  {
2723  /* Currently, not allowed unique with filter/function index.
2724  However, may be introduced later, if it will be usefull.
2725  Unique filter/function index code is removed from
2726  grammar module only. It is kept yet in the others modules.
2727  This will allow us to easily support this feature later by
2728  adding in grammar only. If no need such feature,
2729  filter/function code must be removed from all modules. */
2730  PT_ERRORm (this_parser, node,
2731  MSGCAT_SET_PARSER_SYNTAX,
2732  MSGCAT_SYNTAX_INVALID_CREATE_INDEX);
2733  }
2734  if (node && ocs)
2735  {
2736  PT_NODE *col, *temp;
2737  int arg_count = 0, prefix_col_count = 0;
2738 
2739  ocs->info.spec.entity_name = $10;
2740  ocs->info.spec.only_all = PT_ONLY;
2741  ocs->info.spec.meta_class = PT_CLASS;
2742 
2743  PARSER_SAVE_ERR_CONTEXT (ocs, @10.buffer_pos)
2744 
2745  node->info.index.indexed_class = ocs;
2746  node->info.index.reverse = $4;
2747  node->info.index.unique = $5;
2748  node->info.index.index_name = $8;
2749  if (node->info.index.index_name)
2750  {
2751  node->info.index.index_name->info.name.meta_class = PT_INDEX_NAME;
2752  }
2753 
2754  col = $11;
2755  if (node->info.index.unique)
2756  {
2757  for (temp = col; temp != NULL; temp = temp->next)
2758  {
2759  if (temp->info.sort_spec.expr->node_type == PT_EXPR)
2760  {
2761  /* Currently, not allowed unique with
2762  filter/function index. However, may be
2763  introduced later, if it will be usefull.
2764  Unique filter/function index code is removed
2765  from grammar module only. It is kept yet in
2766  the others modules. This will allow us to
2767  easily support this feature later by adding in
2768  grammar only. If no need such feature,
2769  filter/function code must be removed from all
2770  modules. */
2771  PT_ERRORm (this_parser, node,
2772  MSGCAT_SET_PARSER_SYNTAX,
2773  MSGCAT_SYNTAX_INVALID_CREATE_INDEX);
2774  }
2775  }
2776  }
2777 
2778  prefix_col_count =
2779  parser_count_prefix_columns (col, &arg_count);
2780 
2781  if (prefix_col_count > 1 ||
2782  (prefix_col_count == 1 && arg_count > 1))
2783  {
2784  PT_ERRORm (this_parser, node,
2785  MSGCAT_SET_PARSER_SEMANTIC,
2786  MSGCAT_SEMANTIC_MULTICOL_PREFIX_INDX_NOT_ALLOWED);
2787  }
2788  else
2789  {
2790  if (arg_count == 1 && (prefix_col_count == 1
2791  || col->info.sort_spec.expr->node_type == PT_FUNCTION))
2792  {
2793  PT_NODE *expr = col->info.sort_spec.expr;
2794  PT_NODE *arg_list = expr->info.function.arg_list;
2795  if ((arg_list != NULL)
2796  && (arg_list->next == NULL)
2797  && (arg_list->node_type == PT_VALUE))
2798  {
2799  if (node->info.index.reverse
2800  || node->info.index.unique)
2801  {
2802  PT_ERRORm (this_parser, node,
2803  MSGCAT_SET_PARSER_SYNTAX,
2804  MSGCAT_SYNTAX_INVALID_CREATE_INDEX);
2805  }
2806  else
2807  {
2808  PT_NODE *p = parser_new_node (this_parser,
2809  PT_NAME);
2810  if (p)
2811  {
2812  p->info.name.original =
2813  expr->info.function.generic_name;
2814  }
2815  node->info.index.prefix_length =
2816  expr->info.function.arg_list;
2817  col->info.sort_spec.expr = p;
2818  }
2819  }
2820  else
2821  {
2822  PT_ERRORmf (this_parser, col->info.sort_spec.expr,
2823  MSGCAT_SET_PARSER_SEMANTIC,
2824  MSGCAT_SEMANTIC_FUNCTION_CANNOT_BE_USED_FOR_INDEX,
2825  fcode_get_lowercase_name (col->info.sort_spec.expr->info.function.
2826  function_type));
2827  }
2828  }
2829  }
2830  node->info.index.where = $12;
2831  node->info.index.column_names = col;
2832  node->info.index.comment = $13;
2833 
2834  int with_online_ret = $14; // 0 for normal, 1 for online no parallel,
2835  // thread_count + 1 for parallel
2836  bool is_online = with_online_ret > 0;
2837  bool is_invisible = $15;
2838 
2839  if (is_online && is_invisible)
2840  {
2841  /* We do not allow invisible and online index at the same time. */
2842  PT_ERRORm (this_parser, node, MSGCAT_SET_PARSER_SYNTAX,
2843  MSGCAT_SYNTAX_INVALID_CREATE_INDEX);
2844  }
2845  node->info.index.index_status = SM_NORMAL_INDEX;
2846  if (is_invisible)
2847  {
2848  /* Invisible index. */
2849  node->info.index.index_status = SM_INVISIBLE_INDEX;
2850  }
2851  else if (is_online)
2852  {
2853  /* Online index. */
2854  node->info.index.index_status = SM_ONLINE_INDEX_BUILDING_IN_PROGRESS;
2855  node->info.index.ib_threads = with_online_ret - 1;
2856  }
2857  }
2858  $$ = node;
2859 
2860  DBG_PRINT}}
2861  | CREATE
2862  { push_msg(MSGCAT_SYNTAX_INVALID_CREATE_USER); }
2863  USER
2864  identifier
2865  opt_password
2866  opt_groups
2867  opt_members
2868  opt_comment_spec
2869  { pop_msg(); }
2870  {{
2871 
2872  PT_NODE *node = parser_new_node (this_parser, PT_CREATE_USER);
2873 
2874  if (node)
2875  {
2876  node->info.create_user.user_name = $4;
2877  node->info.create_user.password = $5;
2878  node->info.create_user.groups = $6;
2879  node->info.create_user.members = $7;
2880  node->info.create_user.comment = $8;
2881  }
2882 
2883  $$ = node;
2884  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
2885 
2886  DBG_PRINT}}
2887  | CREATE /* 1 */
2888  { push_msg(MSGCAT_SYNTAX_INVALID_CREATE_TRIGGER); } /* 2 */
2889  TRIGGER /* 3 */
2890  identifier /* 4 */
2891  opt_status /* 5 */
2892  opt_priority /* 6 */
2893  trigger_time /* 7 */
2894  { pop_msg(); } /* 8 */
2895  event_spec /* 9 */
2896  opt_if_trigger_condition /* 10 */
2897  EXECUTE /* 11 */
2898  opt_trigger_action_time /* 12 */
2899  trigger_action /* 13 */
2900  opt_comment_spec /* 14 */
2901  {{
2902 
2903  PT_NODE *node = parser_new_node (this_parser, PT_CREATE_TRIGGER);
2904 
2905  if (node)
2906  {
2907  node->info.create_trigger.trigger_name = $4;
2908  node->info.create_trigger.trigger_status = $5;
2909  node->info.create_trigger.trigger_priority = $6;
2910  node->info.create_trigger.condition_time = $7;
2911  node->info.create_trigger.trigger_event = $9;
2912  node->info.create_trigger.trigger_reference = NULL;
2913  node->info.create_trigger.trigger_condition = $10;
2914  node->info.create_trigger.action_time = $12;
2915  node->info.create_trigger.trigger_action = $13;
2916  node->info.create_trigger.comment = $14;
2917  }
2918 
2919  $$ = node;
2920  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
2921 
2922  DBG_PRINT}}
2923  | CREATE /* 1 */
2924  { push_msg(MSGCAT_SYNTAX_INVALID_CREATE_SERIAL); } /* 2 */
2925  SERIAL /* 3 */
2926  { pop_msg(); } /* 4 */
2927  identifier /* 5 */
2928  opt_serial_option_list /* 6 */
2929  opt_comment_spec /* 7 */
2930  {{
2931 
2932  PT_NODE *node = parser_new_node (this_parser, PT_CREATE_SERIAL);
2933 
2934  if (node)
2935  {
2936  node->info.serial.serial_name = $5;
2937 
2938  /* container order
2939  * 0: start_val
2940  * 1: increment_val,
2941  * 2: max_val,
2942  * 3: no_max,
2943  * 4: min_val,
2944  * 5: no_min,
2945  * 6: cyclic,
2946  * 7: no_cyclic,
2947  * 8: cached_num_val,
2948  * 9: no_cache,
2949  */
2950 
2951  node->info.serial.start_val = CONTAINER_AT_0($6);
2952  node->info.serial.increment_val = CONTAINER_AT_1($6);
2953  node->info.serial.max_val = CONTAINER_AT_2 ($6);
2954  node->info.serial.no_max = (int) TO_NUMBER (CONTAINER_AT_3 ($6));
2955  node->info.serial.min_val = CONTAINER_AT_4 ($6);
2956  node->info.serial.no_min = (int) TO_NUMBER (CONTAINER_AT_5 ($6));
2957  node->info.serial.cyclic = (int) TO_NUMBER (CONTAINER_AT_6 ($6));
2958  node->info.serial.no_cyclic = (int) TO_NUMBER (CONTAINER_AT_7 ($6));
2959  node->info.serial.cached_num_val = CONTAINER_AT_8 ($6);
2960  node->info.serial.no_cache = (int) TO_NUMBER (CONTAINER_AT_9 ($6));
2961  node->info.serial.comment = $7;
2962  }
2963 
2964  $$ = node;
2965  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
2966 
2967  DBG_PRINT}}
2968  | CREATE /* 1 */
2969  opt_or_replace /* 2 */
2970  { push_msg(MSGCAT_SYNTAX_INVALID_CREATE_PROCEDURE); } /* 3 */
2971  PROCEDURE /* 4 */
2972  identifier '(' opt_sp_param_list ')' /* 5, 6, 7, 8 */
2973  opt_of_is_as LANGUAGE JAVA /* 9, 10, 11 */
2974  NAME char_string_literal /* 12, 13 */
2975  opt_comment_spec /* 14 */
2976  { pop_msg(); }
2977  {{
2978 
2979  PT_NODE *node = parser_new_node (this_parser, PT_CREATE_STORED_PROCEDURE);
2980  if (node)
2981  {
2982  node->info.sp.or_replace = $2;
2983  node->info.sp.name = $5;
2984  node->info.sp.type = PT_SP_PROCEDURE;
2985  node->info.sp.param_list = $7;
2986  node->info.sp.ret_type = PT_TYPE_NONE;
2987  node->info.sp.java_method = $13;
2988  node->info.sp.comment = $14;
2989  }
2990 
2991  $$ = node;
2992  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
2993 
2994  DBG_PRINT}}
2995  | CREATE /* 1 */
2996  opt_or_replace /* 2 */
2997  { push_msg(MSGCAT_SYNTAX_INVALID_CREATE_FUNCTION); } /* 3 */
2998  FUNCTION /* 4 */
2999  identifier '(' opt_sp_param_list ')' /* 5, 6, 7, 8 */
3000  RETURN opt_of_data_type_cursor /* 9, 10 */
3001  opt_of_is_as LANGUAGE JAVA /* 11, 12, 13 */
3002  NAME char_string_literal /* 14, 15 */
3003  opt_comment_spec /* 16 */
3004  { pop_msg(); }
3005  {{
3006 
3007  PT_NODE *node = parser_new_node (this_parser, PT_CREATE_STORED_PROCEDURE);
3008  if (node)
3009  {
3010  node->info.sp.or_replace = $2;
3011  node->info.sp.name = $5;
3012  node->info.sp.type = PT_SP_FUNCTION;
3013  node->info.sp.param_list = $7;
3014  node->info.sp.ret_type = $10;
3015  node->info.sp.java_method = $15;
3016  node->info.sp.comment = $16;
3017  }
3018 
3019  $$ = node;
3020  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
3021 
3022  DBG_PRINT}}
3023  | CREATE IdName
3024  {{
3025 
3026  push_msg (MSGCAT_SYNTAX_INVALID_CREATE);
3027  csql_yyerror_explicit (@2.first_line, @2.first_column);
3028 
3029  DBG_PRINT}}
3030  | CREATE /* 1 */
3031  { /* 2 */
3032  PT_NODE* qc = parser_new_node(this_parser, PT_CREATE_ENTITY);
3033  parser_push_hint_node(qc);
3034  }
3035  opt_hint_list /* 3 */
3036  of_class_table_type /* 4 */
3037  opt_if_not_exists /* 5 */
3038  class_name /* 6 */
3039  LIKE /* 7 */
3040  class_name /* 8 */
3041  {{
3042 
3043  PT_NODE *qc = parser_pop_hint_node ();
3044 
3045  if (qc)
3046  {
3047  qc->info.create_entity.if_not_exists = $5;
3048  qc->info.create_entity.entity_name = $6;
3049  qc->info.create_entity.entity_type = PT_CLASS;
3050  qc->info.create_entity.create_like = $8;
3051  }
3052 
3053  $$ = qc;
3054  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
3055 
3056  DBG_PRINT}}
3057  | CREATE /* 1 */
3058  { /* 2 */
3059  PT_NODE* qc = parser_new_node(this_parser, PT_CREATE_ENTITY);
3060  parser_push_hint_node(qc);
3061  }
3062  opt_hint_list /* 3 */
3063  of_class_table_type /* 4 */
3064  opt_if_not_exists /* 5 */
3065  class_name /* 6 */
3066  '(' /* 7 */
3067  LIKE /* 8 */
3068  class_name /* 9 */
3069  ')' /* 10 */
3070  {{
3071 
3072  PT_NODE *qc = parser_pop_hint_node ();
3073 
3074  if (qc)
3075  {
3076  qc->info.create_entity.if_not_exists = $5;
3077  qc->info.create_entity.entity_name = $6;
3078  qc->info.create_entity.entity_type = PT_CLASS;
3079  qc->info.create_entity.create_like = $9;
3080  }
3081 
3082  $$ = qc;
3083  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
3084 
3085  DBG_PRINT}}
3086  ;
3087 
3088 opt_serial_option_list
3089  : /* empty */
3090  {{
3091  container_10 ctn;
3092  memset(&ctn, 0x00, sizeof(container_10));
3093  $$ = ctn;
3094  }}
3095  | serial_option_list
3096  {{
3097  $$ = $1;
3098  }}
3099  ;
3100 
3101 serial_option_list
3102  : serial_option_list of_serial_option
3103  {{
3104  /* container order
3105  * 1: start_val
3106  *
3107  * 2: increment_val,
3108  *
3109  * 3: max_val,
3110  * 4: no_max,
3111  *
3112  * 5: min_val,
3113  * 6: no_min,
3114  *
3115  * 7: cyclic,
3116  * 8: no_cyclic,
3117  *
3118  * 9: cached_num_val,
3119  * 10: no_cache,
3120  */
3121 
3122  container_10 ctn = $1;
3123 
3124  PT_NODE* node = pt_top(this_parser);
3125  PARSER_SAVE_ERR_CONTEXT (node, @$.buffer_pos)
3126 
3127  switch(TO_NUMBER (CONTAINER_AT_0($2)))
3128  {
3129  case SERIAL_START:
3130  if (ctn.c1 != NULL)
3131  {
3132  PT_ERRORmf (this_parser, node, MSGCAT_SET_PARSER_SEMANTIC,
3133  MSGCAT_SEMANTIC_SERIAL_DUPLICATE_ATTR, "start");
3134  }
3135 
3136  ctn.c1 = CONTAINER_AT_1($2);
3137  break;
3138 
3139  case SERIAL_INC:
3140  if (ctn.c2 != NULL)
3141  {
3142  PT_ERRORmf (this_parser, node, MSGCAT_SET_PARSER_SEMANTIC,
3143  MSGCAT_SEMANTIC_SERIAL_DUPLICATE_ATTR, "increment");
3144  }
3145 
3146  ctn.c2 = CONTAINER_AT_1($2);
3147  break;
3148 
3149  case SERIAL_MAX:
3150  if (ctn.c3 != NULL || TO_NUMBER(ctn.c4) != 0)
3151  {
3152  PT_ERRORmf (this_parser, node, MSGCAT_SET_PARSER_SEMANTIC,
3153  MSGCAT_SEMANTIC_SERIAL_DUPLICATE_ATTR, "max");
3154  }
3155 
3156  ctn.c3 = CONTAINER_AT_1($2);
3157  ctn.c4 = CONTAINER_AT_2($2);
3158  break;
3159 
3160  case SERIAL_MIN:
3161  if (ctn.c5 != NULL || TO_NUMBER(ctn.c6) != 0)
3162  {
3163  PT_ERRORmf (this_parser, node, MSGCAT_SET_PARSER_SEMANTIC,
3164  MSGCAT_SEMANTIC_SERIAL_DUPLICATE_ATTR, "min");
3165  }
3166 
3167  ctn.c5 = CONTAINER_AT_1($2);
3168  ctn.c6 = CONTAINER_AT_2($2);
3169  break;
3170 
3171  case SERIAL_CYCLE:
3172  if (TO_NUMBER(ctn.c7) != 0 || TO_NUMBER(ctn.c8) != 0)
3173  {
3174  PT_ERRORmf (this_parser, node, MSGCAT_SET_PARSER_SEMANTIC,
3175  MSGCAT_SEMANTIC_SERIAL_DUPLICATE_ATTR, "cycle");
3176  }
3177 
3178  ctn.c7 = CONTAINER_AT_1($2);
3179  ctn.c8 = CONTAINER_AT_2($2);
3180  break;
3181 
3182  case SERIAL_CACHE:
3183  if (TO_NUMBER(ctn.c9) != 0 || TO_NUMBER(ctn.c10) != 0)
3184  {
3185  PT_ERRORmf (this_parser, node, MSGCAT_SET_PARSER_SEMANTIC,
3186  MSGCAT_SEMANTIC_SERIAL_DUPLICATE_ATTR, "cache");
3187  }
3188 
3189  ctn.c9 = CONTAINER_AT_1($2);
3190  ctn.c10 = CONTAINER_AT_2($2);
3191  break;
3192  }
3193 
3194  $$ = ctn;
3195 
3196  DBG_PRINT}}
3197  | of_serial_option
3198  {{
3199  /* container order
3200  * 1: start_val
3201  *
3202  * 2: increment_val,
3203  *
3204  * 3: max_val,
3205  * 4: no_max,
3206  *
3207  * 5: min_val,
3208  * 6: no_min,
3209  *
3210  * 7: cyclic,
3211  * 8: no_cyclic,
3212  *
3213  * 9: cached_num_val,
3214  * 10: no_cache,
3215  */
3216 
3217  container_10 ctn;
3218  memset(&ctn, 0x00, sizeof(container_10));
3219 
3220  switch(TO_NUMBER (CONTAINER_AT_0($1)))
3221  {
3222  case SERIAL_START:
3223  ctn.c1 = CONTAINER_AT_1($1);
3224  break;
3225 
3226  case SERIAL_INC:
3227  ctn.c2 = CONTAINER_AT_1($1);
3228  break;
3229 
3230  case SERIAL_MAX:
3231  ctn.c3 = CONTAINER_AT_1($1);
3232  ctn.c4 = CONTAINER_AT_2($1);
3233  break;
3234 
3235  case SERIAL_MIN:
3236  ctn.c5 = CONTAINER_AT_1($1);
3237  ctn.c6 = CONTAINER_AT_2($1);
3238  break;
3239 
3240  case SERIAL_CYCLE:
3241  ctn.c7 = CONTAINER_AT_1($1);
3242  ctn.c8 = CONTAINER_AT_2($1);
3243  break;
3244 
3245  case SERIAL_CACHE:
3246  ctn.c9 = CONTAINER_AT_1($1);
3247  ctn.c10 = CONTAINER_AT_2($1);
3248  break;
3249  }
3250 
3251  $$ = ctn;
3252 
3253  DBG_PRINT}}
3254  ;
3255 
3256 of_serial_option
3257  : serial_start
3258  {{
3259  container_3 ctn;
3260  SET_CONTAINER_3(ctn, FROM_NUMBER(SERIAL_START), $1, NULL);
3261  $$ = ctn;
3262  DBG_PRINT}}
3263  | serial_increment
3264  {{
3265  container_3 ctn;
3266  SET_CONTAINER_3(ctn, FROM_NUMBER(SERIAL_INC), $1, NULL);
3267  $$ = ctn;
3268  DBG_PRINT}}
3269  | serial_min
3270  {{
3271  container_3 ctn;
3272  SET_CONTAINER_3(ctn, FROM_NUMBER(SERIAL_MIN), CONTAINER_AT_0($1), CONTAINER_AT_1($1));
3273  $$ = ctn;
3274  DBG_PRINT}}
3275  | serial_max
3276  {{
3277  container_3 ctn;
3278  SET_CONTAINER_3(ctn, FROM_NUMBER(SERIAL_MAX), CONTAINER_AT_0($1), CONTAINER_AT_1($1));
3279  $$ = ctn;
3280  DBG_PRINT}}
3281  | of_cycle_nocycle
3282  {{
3283  container_3 ctn;
3284  SET_CONTAINER_3(ctn, FROM_NUMBER(SERIAL_CYCLE), CONTAINER_AT_0($1), CONTAINER_AT_1($1));
3285  $$ = ctn;
3286  DBG_PRINT}}
3287  | of_cached_num
3288  {{
3289  container_3 ctn;
3290  SET_CONTAINER_3(ctn, FROM_NUMBER(SERIAL_CACHE), CONTAINER_AT_0($1), CONTAINER_AT_1($1));
3291  $$ = ctn;
3292  DBG_PRINT}}
3293  ;
3294 
3295 
3296 opt_replace
3297  : /* empty */
3298  {{
3299 
3300  $$ = PT_CREATE_SELECT_NO_ACTION;
3301 
3302  DBG_PRINT}}
3303  | REPLACE
3304  {{
3305 
3306  $$ = PT_CREATE_SELECT_REPLACE;
3307 
3308  DBG_PRINT}}
3309  ;
3310 
3311 alter_stmt
3312  : ALTER /* 1 */
3313  { /* 2 */
3314  PT_NODE* node = parser_new_node(this_parser, PT_ALTER);
3315  parser_push_hint_node(node);
3316  }
3317  opt_hint_list /* 3 */
3318  opt_class_type /* 4 */
3319  only_class_name /* 5 */
3320  {{
3321 
3322  PT_NODE *node = parser_pop_hint_node ();
3323  int entity_type = ($4 == PT_EMPTY ? PT_MISC_DUMMY : $4);
3324 
3325  if (node)
3326  {
3327  node->info.alter.entity_type = entity_type;
3328  node->info.alter.entity_name = $5;
3329  }
3330 
3331  parser_save_alter_node (node);
3332 
3333  DBG_PRINT}}
3334  alter_clause_cubrid_specific
3335  {{
3336 
3337  PT_NODE *node = parser_get_alter_node ();
3338 
3339  if (node)
3340  {
3341  pt_gather_constraints (this_parser, node);
3342  }
3343  $$ = node;
3344  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
3345 
3346  DBG_PRINT}}
3347  | ALTER /* 1 */
3348  { /* 2 */
3349  PT_NODE* node = parser_new_node(this_parser, PT_ALTER);
3350  parser_push_hint_node(node);
3351  }
3352  opt_hint_list /* 3 */
3353  opt_class_type /* 4 */
3354  only_class_name /* 5 */
3355  alter_clause_list /* 6 */ %dprec 2
3356  {{
3357 
3358  PT_NODE *node = NULL;
3359  int entity_type = ($4 == PT_EMPTY ? PT_MISC_DUMMY : $4);
3360 
3361  for (node = $6; node != NULL; node = node->next)
3362  {
3363  node->info.alter.entity_type = entity_type;
3364  node->info.alter.entity_name = parser_copy_tree (this_parser, $5);
3365  pt_gather_constraints (this_parser, node);
3366  if (node->info.alter.code == PT_RENAME_ENTITY)
3367  {
3368  node->info.alter.alter_clause.rename.element_type = entity_type;
3369  /* We can get the original name from info.alter.entity_name */
3370  node->info.alter.alter_clause.rename.old_name = NULL;
3371  }
3372  else
3373  {
3374  if (node->info.alter.code == PT_ADD_ATTR_MTHD)
3375  {
3376  PT_NODE *p = node->info.alter.create_index;
3377  if (p)
3378  {
3379  node->info.alter.code = PT_ADD_INDEX_CLAUSE;
3380  }
3381  /* add the table spec to each ALTER TABLE ADD INDEX
3382  * clause in the ALTER statement */
3383  while (p)
3384  {
3385  PT_NODE *ocs = parser_new_node(this_parser, PT_SPEC);
3386 
3387  if (ocs)
3388  {
3389  ocs->info.spec.entity_name = parser_copy_tree(this_parser, $5);
3390  ocs->info.spec.only_all = PT_ONLY;
3391  ocs->info.spec.meta_class = PT_CLASS;
3392 
3393  p->info.index.indexed_class = ocs;
3394  p = p->next;
3395  }
3396  else
3397  {
3398  break;
3399  }
3400  }
3401  }
3402  }
3403  }
3404  parser_free_tree (this_parser, $5);
3405 
3406  $$ = $6;
3407  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
3408 
3409  DBG_PRINT}}
3410  | ALTER
3411  USER
3412  identifier
3413  opt_password
3414  opt_comment_spec
3415  {{
3416 
3417  PT_NODE *node = parser_new_node (this_parser, PT_ALTER_USER);
3418 
3419  if (node)
3420  {
3421  node->info.alter_user.user_name = $3;
3422  node->info.alter_user.password = $4;
3423  node->info.alter_user.comment = $5;
3424  if (node->info.alter_user.password == NULL
3425  && node->info.alter_user.comment == NULL)
3426  {
3427  PT_ERRORm (this_parser, node, MSGCAT_SET_PARSER_SYNTAX,
3428  MSGCAT_SYNTAX_INVALID_ALTER);
3429  }
3430  }
3431 
3432  $$ = node;
3433  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
3434 
3435  DBG_PRINT}}
3436  | ALTER
3437  TRIGGER
3438  identifier_list
3439  trigger_status_or_priority_or_change_owner
3440  opt_comment_spec /* 5 */
3441  {{
3442 
3443  PT_NODE *node = parser_new_node (this_parser, PT_ALTER_TRIGGER);
3444 
3445  PT_NODE *list = parser_new_node (this_parser, PT_TRIGGER_SPEC_LIST);
3446  if (list)
3447  {
3448  list->info.trigger_spec_list.trigger_name_list = $3;
3449  }
3450 
3451  if (node)
3452  {
3453  node->info.alter_trigger.trigger_spec_list = list;
3454  node->info.alter_trigger.trigger_status = TO_NUMBER (CONTAINER_AT_0 ($4));
3455  node->info.alter_trigger.trigger_priority = CONTAINER_AT_1 ($4);
3456  node->info.alter_trigger.trigger_owner = CONTAINER_AT_2 ($4);
3457  node->info.alter_trigger.comment = $5;
3458  }
3459 
3460  $$ = node;
3461  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
3462 
3463  DBG_PRINT}}
3464  | ALTER /* 1 */
3465  TRIGGER /* 2 */
3466  identifier /* 3 */
3467  COMMENT comment_value /* 4, 5 */
3468  {{
3469 
3470  PT_NODE *node = parser_new_node (this_parser, PT_ALTER_TRIGGER);
3471 
3472  PT_NODE *list = parser_new_node (this_parser, PT_TRIGGER_SPEC_LIST);
3473  if (list)
3474  {
3475  list->info.trigger_spec_list.trigger_name_list = $3;
3476  }
3477 
3478  if (node)
3479  {
3480  node->info.alter_trigger.trigger_spec_list = list;
3481  node->info.alter_trigger.comment = $5;
3482  }
3483 
3484  $$ = node;
3485  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
3486 
3487  DBG_PRINT}}
3488  | ALTER /* 1 */
3489  SERIAL /* 2 */
3490  identifier /* 3 */
3491  opt_serial_option_list /* 4 */
3492  opt_comment_spec /* 5 */
3493  {{
3494  /* container order
3495  * 0: start_val
3496  * 1: increment_val,
3497  * 2: max_val,
3498  * 3: no_max,
3499  * 4: min_val,
3500  * 5: no_min,
3501  * 6: cyclic,
3502  * 7: no_cyclic,
3503  * 8: cached_num_val,
3504  * 9: no_cache,
3505  */
3506 
3507  PT_NODE *serial_name = $3;
3508  PT_NODE *start_val = CONTAINER_AT_0 ($4);
3509  PT_NODE *increment_val = CONTAINER_AT_1 ($4);
3510  PT_NODE *max_val = CONTAINER_AT_2 ($4);
3511  int no_max = (int) TO_NUMBER (CONTAINER_AT_3 ($4));
3512  PT_NODE *min_val = CONTAINER_AT_4 ($4);
3513  int no_min = (int) TO_NUMBER (CONTAINER_AT_5 ($4));
3514  int cyclic = (int) TO_NUMBER (CONTAINER_AT_6 ($4));
3515  int no_cyclic = (int) TO_NUMBER (CONTAINER_AT_7 ($4));
3516  PT_NODE *cached_num_val = CONTAINER_AT_8 ($4);
3517  int no_cache = (int) TO_NUMBER (CONTAINER_AT_9 ($4));
3518  PT_NODE *comment = $5;
3519 
3520  PT_NODE *node = parser_new_node (this_parser, PT_ALTER_SERIAL);
3521  if (node)
3522  {
3523  node->info.serial.serial_name = serial_name;
3524  node->info.serial.increment_val = increment_val;
3525  node->info.serial.start_val = start_val;
3526  node->info.serial.max_val = max_val;
3527  node->info.serial.no_max = no_max;
3528  node->info.serial.min_val = min_val;
3529  node->info.serial.no_min = no_min;
3530  node->info.serial.cyclic = cyclic;
3531  node->info.serial.no_cyclic = no_cyclic;
3532  node->info.serial.cached_num_val = cached_num_val;
3533  node->info.serial.no_cache = no_cache;
3534  node->info.serial.comment = comment;
3535  }
3536 
3537  $$ = node;
3538  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
3539 
3540  if (!start_val && !increment_val && !max_val && !min_val
3541  && cyclic == 0 && no_max == 0 && no_min == 0
3542  && no_cyclic == 0 && !cached_num_val && no_cache == 0
3543  && comment == NULL)
3544  {
3545  PT_ERRORmf (this_parser, node, MSGCAT_SET_PARSER_SEMANTIC,
3546  MSGCAT_SEMANTIC_SERIAL_ALTER_NO_OPTION, 0);
3547  }
3548 
3549  DBG_PRINT}}
3550  | ALTER /* 1 */
3551  { /* 2 */
3552  PT_NODE* node = parser_new_node(this_parser, PT_ALTER_INDEX);
3553  parser_push_hint_node(node);
3554  }
3555  opt_hint_list /* 3 */
3556  opt_reverse /* 4 */
3557  opt_unique /* 5 */
3558  INDEX /* 6 */
3559  identifier /* 7 */
3560  ON_ /* 8 */
3561  only_class_name /* 9 */
3562  opt_index_column_name_list /* 10 */
3563  opt_where_clause /* 11 */
3564  opt_comment_spec /* 12 */
3565  REBUILD /* 13 */
3566  {{
3567 
3568  PT_NODE *node = parser_pop_hint_node ();
3569  PT_NODE *ocs = parser_new_node(this_parser, PT_SPEC);
3570 
3571  if ($5 && $11)
3572  {
3573  /* Currently, not allowed unique with filter/function index.
3574  However, may be introduced later, if it will be usefull.
3575  Unique filter/function index code is removed from
3576  grammar module only. It is kept yet in the others modules.
3577  This will allow us to easily support this feature later by
3578  adding in grammar only. If no need such feature,
3579  filter/function code must be removed from all modules. */
3580  PT_ERRORm (this_parser, node, MSGCAT_SET_PARSER_SYNTAX,
3581  MSGCAT_SYNTAX_INVALID_CREATE_INDEX);
3582  }
3583  if (node && ocs)
3584  {
3585  PT_NODE *col, *temp;
3586  node->info.index.code = PT_REBUILD_INDEX;
3587  node->info.index.reverse = $4;
3588  node->info.index.unique = $5;
3589  node->info.index.index_name = $7;
3590  if (node->info.index.index_name)
3591  {
3592  node->info.index.index_name->info.name.meta_class = PT_INDEX_NAME;
3593  }
3594 
3595  ocs->info.spec.entity_name = $9;
3596  ocs->info.spec.only_all = PT_ONLY;
3597  ocs->info.spec.meta_class = PT_CLASS;
3598 
3599  node->info.index.indexed_class = ocs;
3600  col = $10;
3601  if (node->info.index.unique)
3602  {
3603  for (temp = col; temp != NULL; temp = temp->next)
3604  {
3605  if (temp->info.sort_spec.expr->node_type == PT_EXPR)
3606  {
3607  /* Currently, not allowed unique with
3608  filter/function index. However, may be
3609  introduced later, if it will be usefull.
3610  Unique filter/function index code is removed
3611  from grammar module only. It is kept yet in
3612  the others modules. This will allow us to
3613  easily support this feature later by adding in
3614  grammar only. If no need such feature,
3615  filter/function code must be removed from all
3616  modules. */
3617  PT_ERRORm (this_parser, node,
3618  MSGCAT_SET_PARSER_SYNTAX,
3619  MSGCAT_SYNTAX_INVALID_CREATE_INDEX);
3620  }
3621  }
3622  }
3623 
3624  node->info.index.column_names = col;
3625  node->info.index.where = $11;
3626  node->info.index.comment = $12;
3627 
3628  $$ = node;
3629  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
3630  }
3631 
3632  DBG_PRINT}}
3633  | ALTER /* 1 */
3634  INDEX /* 2 */
3635  identifier /* 3 */
3636  ON_ /* 4 */
3637  class_name /* 5 */
3638  COMMENT comment_value /* 6, 7 */
3639  {{
3640  PT_NODE* node = parser_new_node(this_parser, PT_ALTER_INDEX);
3641 
3642  if (node)
3643  {
3644  node->info.index.code = PT_CHANGE_INDEX_COMMENT;
3645  node->info.index.index_name = $3;
3646  node->info.index.comment = $7;
3647 
3648  if (node->info.index.index_name)
3649  {
3650  node->info.index.index_name->info.name.meta_class = PT_INDEX_NAME;
3651  }
3652 
3653  if ($5 != NULL)
3654  {
3655  PT_NODE *ocs = parser_new_node(this_parser, PT_SPEC);
3656  ocs->info.spec.entity_name = $5;
3657  ocs->info.spec.only_all = PT_ONLY;
3658  ocs->info.spec.meta_class = PT_CLASS;
3659 
3660  node->info.index.indexed_class = ocs;
3661  }
3662  }
3663 
3664  $$ = node;
3665  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
3666 
3667  DBG_PRINT}}
3668  | ALTER /* 1 */
3669  INDEX /* 2 */
3670  identifier /* 3 */
3671  ON_ /* 4 */
3672  class_name /* 5 */
3673  INVISIBLE /* 6 */
3674  {{
3675  PT_NODE* node = parser_new_node(this_parser, PT_ALTER_INDEX);
3676 
3677  if (node)
3678  {
3679  node->info.index.code = PT_CHANGE_INDEX_STATUS;
3680  node->info.index.index_name = $3;
3681  node->info.index.index_status = SM_INVISIBLE_INDEX;
3682 
3683  if (node->info.index.index_name)
3684  {
3685  node->info.index.index_name->info.name.meta_class = PT_INDEX_NAME;
3686  }
3687 
3688  if ($5 != NULL)
3689  {
3690  PT_NODE *ocs = parser_new_node(this_parser, PT_SPEC);
3691  ocs->info.spec.entity_name = $5;
3692  ocs->info.spec.only_all = PT_ONLY;
3693  ocs->info.spec.meta_class = PT_CLASS;
3694 
3695  node->info.index.indexed_class = ocs;
3696  }
3697  }
3698 
3699  $$ = node;
3700  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
3701 
3702  DBG_PRINT}}
3703  | ALTER /* 1 */
3704  INDEX /* 2 */
3705  identifier /* 3 */
3706  ON_ /* 4 */
3707  class_name /* 5 */
3708  VISIBLE /* 6 */
3709  {{
3710  PT_NODE* node = parser_new_node(this_parser, PT_ALTER_INDEX);
3711 
3712  if (node)
3713  {
3714  node->info.index.code = PT_CHANGE_INDEX_STATUS;
3715  node->info.index.index_name = $3;
3716  node->info.index.index_status = SM_NORMAL_INDEX;
3717 
3718  if (node->info.index.index_name)
3719  {
3720  node->info.index.index_name->info.name.meta_class = PT_INDEX_NAME;
3721  }
3722 
3723  if ($5 != NULL)
3724  {
3725  PT_NODE *ocs = parser_new_node(this_parser, PT_SPEC);
3726  ocs->info.spec.entity_name = $5;
3727  ocs->info.spec.only_all = PT_ONLY;
3728  ocs->info.spec.meta_class = PT_CLASS;
3729 
3730  node->info.index.indexed_class = ocs;
3731  }
3732  }
3733 
3734  $$ = node;
3735  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
3736 
3737  DBG_PRINT}}
3738  | ALTER
3739  view_or_vclass
3740  class_name
3741  AS
3742  csql_query
3743  opt_vclass_comment_spec
3744  {{
3745 
3746  PT_NODE *node = parser_new_node (this_parser, PT_ALTER);
3747  if (node)
3748  {
3749  node->info.alter.entity_type = PT_VCLASS;
3750  node->info.alter.entity_name = $3;
3751  node->info.alter.code = PT_RESET_QUERY;
3752  node->info.alter.alter_clause.query.query = $5;
3753  node->info.alter.alter_clause.query.query_no_list = NULL;
3754  node->info.alter.alter_clause.query.attr_def_list = NULL;
3755  node->info.alter.alter_clause.query.view_comment = $6;
3756 
3757  pt_gather_constraints (this_parser, node);
3758  }
3759  $$ = node;
3760  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
3761 
3762  DBG_PRINT}}
3763  | ALTER
3764  view_or_vclass
3765  class_name
3766  class_comment_spec %dprec 1
3767  {{
3768 
3769  PT_NODE *node = parser_new_node (this_parser, PT_ALTER);
3770  if (node)
3771  {
3772  node->info.alter.entity_type = PT_VCLASS;
3773  node->info.alter.entity_name = $3;
3774  node->info.alter.code = PT_CHANGE_TABLE_COMMENT;
3775  node->info.alter.alter_clause.comment.tbl_comment = $4;
3776 
3777  pt_gather_constraints (this_parser, node);
3778  }
3779  $$ = node;
3780  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
3781 
3782  DBG_PRINT}}
3783  | ALTER /* 1 */
3784  procedure_or_function /* 2 */
3785  identifier /* 3 */
3786  opt_owner_clause /* 4 */
3787  opt_comment_spec /* 5 */
3788  {{
3789 
3790  PT_NODE *node = parser_new_node (this_parser, PT_ALTER_STORED_PROCEDURE);
3791 
3792  if (node != NULL)
3793  {
3794  node->info.sp.name = $3;
3795  node->info.sp.type = ($2 == 1) ? PT_SP_PROCEDURE : PT_SP_FUNCTION;
3796  node->info.sp.ret_type = PT_TYPE_NONE;
3797  node->info.sp.owner = $4;
3798  node->info.sp.comment = $5;
3799  if ($4 == NULL && $5 == NULL)
3800  {
3801  PT_ERRORm (this_parser, node,
3802  MSGCAT_SET_PARSER_SYNTAX,
3803  MSGCAT_SYNTAX_INVALID_ALTER);
3804  }
3805  }
3806 
3807  $$ = node;
3808  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
3809 
3810  DBG_PRINT}}
3811  ;
3812 
3813 view_or_vclass
3814  : VIEW
3815  | VCLASS
3816  ;
3817 
3818 alter_clause_list
3819  : alter_clause_list ',' prepare_alter_node alter_clause_for_alter_list
3820  {{
3821 
3822  $$ = parser_make_link ($1, parser_get_alter_node ());
3823  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
3824 
3825  DBG_PRINT}}
3826  | /* The first node in the list is the one that was pushed for hints. */
3827  {
3828 
3829  PT_NODE *node = parser_pop_hint_node ();
3830  parser_save_alter_node (node);
3831  }
3832  alter_clause_for_alter_list
3833  {{
3834 
3835  $$ = parser_get_alter_node ();
3836  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
3837 
3838  DBG_PRINT}}
3839  ;
3840 
3841 prepare_alter_node
3842  : /* empty */
3843  {{
3844 
3845  PT_NODE *node = parser_new_node (this_parser, PT_ALTER);
3846  parser_save_alter_node (node);
3847 
3848  DBG_PRINT}}
3849  ;
3850 
3851 only_class_name
3852  : ONLY class_name
3853  { $$ = $2; }
3854  | class_name
3855  { $$ = $1; }
3856  ;
3857 
3858 rename_stmt
3859  : RENAME opt_class_type rename_class_list
3860  {{
3861 
3862  PT_NODE *node = NULL;
3863  int entity_type = ($2 == PT_EMPTY ? PT_CLASS : $2);
3864 
3865  for (node = $3; node != NULL; node = node->next)
3866  {
3867  node->info.rename.entity_type = entity_type;
3868  }
3869 
3870  $$ = $3;
3871  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
3872 
3873  DBG_PRINT}}
3874  | RENAME TRIGGER class_name AS class_name
3875  {{
3876 
3877  PT_NODE *node = parser_new_node (this_parser, PT_RENAME_TRIGGER);
3878 
3879  if (node)
3880  {
3881  node->info.rename_trigger.new_name = $5;
3882  node->info.rename_trigger.old_name = $3;
3883  }
3884 
3885  $$ = node;
3886  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
3887 
3888  DBG_PRINT}}
3889  ;
3890 
3891 rename_class_list
3892  : rename_class_list ',' rename_class_pair
3893  {{
3894 
3895  $$ = parser_make_link ($1, $3);
3896  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
3897 
3898  DBG_PRINT}}
3899  | rename_class_pair
3900  {{
3901 
3902  $$ = $1;
3903  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
3904 
3905  DBG_PRINT}}
3906  ;
3907 
3908 rename_class_pair
3909  : only_class_name as_or_to only_class_name
3910  {{
3911 
3912  PT_NODE *node = parser_new_node (this_parser, PT_RENAME);
3913  if (node)
3914  {
3915  node->info.rename.old_name = $1;
3916  node->info.rename.new_name = $3;
3917  node->info.rename.entity_type = PT_CLASS;
3918  }
3919 
3920  $$ = node;
3921  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
3922 
3923  DBG_PRINT}}
3924  ;
3925 
3926 procedure_or_function
3927  : PROCEDURE
3928  {{
3929 
3930  $$ = 1;
3931 
3932  DBG_PRINT}}
3933  | FUNCTION
3934  {{
3935 
3936  $$ = 2;
3937 
3938  DBG_PRINT}}
3939  ;
3940 
3941 opt_owner_clause
3942  : /* empty */
3943  { $$ = NULL; }
3944  | OWNER TO identifier
3945  { $$ = $3; }
3946  ;
3947 
3948 as_or_to
3949  : AS
3950  | TO
3951  ;
3952 
3953 truncate_stmt
3954  : TRUNCATE opt_table_type class_spec
3955  {{
3956 
3957  PT_NODE *node = parser_new_node (this_parser, PT_TRUNCATE);
3958  if (node)
3959  {
3960  node->info.truncate.spec = $3;
3961  }
3962 
3963  $$ = node;
3964  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
3965 
3966  DBG_PRINT}}
3967  ;
3968 
3969 do_stmt
3970  : DO expression_
3971  {{
3972 
3973  PT_NODE *node = parser_new_node (this_parser, PT_DO);
3974  if (node)
3975  {
3976  PT_NODE *expr = $2, *subq = NULL;
3977 
3978  if (expr && PT_IS_QUERY_NODE_TYPE (expr->node_type))
3979  {
3980  expr->info.query.flag.single_tuple = 1;
3981 
3982  if ((subq = pt_get_subquery_list (expr)) && subq->next)
3983  {
3984  /* illegal multi-column subquery */
3985  PT_ERRORm (this_parser, expr, MSGCAT_SET_PARSER_SEMANTIC,
3986  MSGCAT_SEMANTIC_NOT_SINGLE_COL);
3987  }
3988  }
3989 
3990  node->info.do_.expr = expr;
3991  }
3992 
3993  $$ = node;
3994  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
3995 
3996  DBG_PRINT}}
3997  ;
3998 
3999 drop_stmt
4000  : DROP opt_class_type opt_if_exists class_spec_list opt_cascade_constraints
4001  {{
4002 
4003  PT_NODE *node = parser_new_node (this_parser, PT_DROP);
4004  if (node)
4005  {
4006  node->info.drop.if_exists = ($3 == 1);
4007  node->info.drop.spec_list = $4;
4008  node->info.drop.is_cascade_constraints = $5;
4009 
4010  if ($2 == PT_EMPTY)
4011  node->info.drop.entity_type = PT_MISC_DUMMY;
4012  else
4013  node->info.drop.entity_type = $2;
4014  }
4015 
4016  $$ = node;
4017  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4018 
4019  DBG_PRINT}}
4020  | DROP /* 1 */
4021  { /* 2 */
4022  PT_NODE* node = parser_new_node(this_parser, PT_DROP_INDEX);
4023  parser_push_hint_node(node);
4024  }
4025  opt_hint_list /* 3 */
4026  opt_reverse /* 4 */
4027  opt_unique /* 5 */
4028  INDEX /* 6 */
4029  identifier /* 7 */
4030  ON_ /* 8 */
4031  only_class_name /* 9 */
4032  opt_index_column_name_list /* 10 */
4033  {{
4034 
4035  PT_NODE *node = parser_pop_hint_node ();
4036  PT_NODE *ocs = parser_new_node(this_parser, PT_SPEC);
4037 
4038  if (node && ocs)
4039  {
4040  PT_NODE *col, *temp;
4041  node->info.index.reverse = $4;
4042  node->info.index.unique = $5;
4043  node->info.index.index_name = $7;
4044  if (node->info.index.index_name)
4045  {
4046  node->info.index.index_name->info.name.meta_class = PT_INDEX_NAME;
4047  }
4048 
4049  ocs->info.spec.entity_name = $9;
4050  ocs->info.spec.only_all = PT_ONLY;
4051  ocs->info.spec.meta_class = PT_CLASS;
4052  PARSER_SAVE_ERR_CONTEXT (ocs, @9.buffer_pos)
4053  node->info.index.indexed_class = ocs;
4054 
4055  col = $10;
4056  if (node->info.index.unique)
4057  {
4058  for (temp = col; temp != NULL; temp = temp->next)
4059  {
4060  if (temp->info.sort_spec.expr->node_type == PT_EXPR)
4061  {
4062  /* Currently, not allowed unique with
4063  filter/function index. However, may be
4064  introduced later, if it will be usefull.
4065  Unique filter/function index code is removed
4066  from grammar module only. It is kept yet in
4067  the others modules. This will allow us to
4068  easily support this feature later by adding in
4069  grammar only. If no need such feature,
4070  filter/function code must be removed from all
4071  modules. */
4072  PT_ERRORm (this_parser, node,
4073  MSGCAT_SET_PARSER_SYNTAX,
4074  MSGCAT_SYNTAX_INVALID_CREATE_INDEX);
4075  }
4076  }
4077  }
4078  node->info.index.column_names = col;
4079 
4080  $$ = node;
4081  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4082  }
4083 
4084  DBG_PRINT}}
4085  | DROP USER identifier
4086  {{
4087 
4088  PT_NODE *node = parser_new_node (this_parser, PT_DROP_USER);
4089 
4090  if (node)
4091  {
4092  node->info.drop_user.user_name = $3;
4093  }
4094 
4095  $$ = node;
4096  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4097 
4098  DBG_PRINT}}
4099  | DROP TRIGGER identifier_list
4100  {{
4101 
4102  PT_NODE *node = parser_new_node (this_parser, PT_DROP_TRIGGER);
4103 
4104  PT_NODE *list = parser_new_node (this_parser, PT_TRIGGER_SPEC_LIST);
4105  if (list)
4106  {
4107  list->info.trigger_spec_list.trigger_name_list = $3;
4108  }
4109 
4110  if (node)
4111  {
4112  node->info.drop_trigger.trigger_spec_list = list;
4113  }
4114 
4115  $$ = node;
4116  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4117 
4118  DBG_PRINT}}
4119  | DROP DEFERRED TRIGGER trigger_spec_list
4120  {{
4121 
4122  PT_NODE *node = parser_new_node (this_parser, PT_REMOVE_TRIGGER);
4123 
4124  if (node)
4125  {
4126  node->info.remove_trigger.trigger_spec_list = $4;
4127  }
4128 
4129  $$ = node;
4130  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4131 
4132  DBG_PRINT}}
4133  | DROP VARIABLE_ identifier_list
4134  {{
4135 
4136  PT_NODE *node = parser_new_node (this_parser, PT_DROP_VARIABLE);
4137  if (node)
4138  node->info.drop_variable.var_names = $3;
4139  $$ = node;
4140  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4141 
4142  DBG_PRINT}}
4143  | DROP SERIAL opt_if_exists identifier
4144  {{
4145 
4146  PT_NODE *node = parser_new_node (this_parser, PT_DROP_SERIAL);
4147  if (node)
4148  {
4149  node->info.serial.if_exists = $3;
4150  node->info.serial.serial_name = $4;
4151  }
4152  $$ = node;
4153  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4154 
4155  DBG_PRINT}}
4156  | DROP PROCEDURE identifier_list
4157  {{
4158 
4159  PT_NODE *node = parser_new_node (this_parser, PT_DROP_STORED_PROCEDURE);
4160 
4161  if (node)
4162  {
4163  node->info.sp.name = $3;
4164  node->info.sp.type = PT_SP_PROCEDURE;
4165  }
4166 
4167 
4168  $$ = node;
4169  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4170 
4171  DBG_PRINT}}
4172  | DROP FUNCTION identifier_list
4173  {{
4174 
4175  PT_NODE *node = parser_new_node (this_parser, PT_DROP_STORED_PROCEDURE);
4176 
4177  if (node)
4178  {
4179  node->info.sp.name = $3;
4180  node->info.sp.type = PT_SP_FUNCTION;
4181  }
4182 
4183 
4184  $$ = node;
4185  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4186 
4187  DBG_PRINT}}
4188  | deallocate_or_drop PREPARE identifier
4189  {{
4190 
4191  PT_NODE *node = parser_new_node (this_parser, PT_DEALLOCATE_PREPARE);
4192 
4193  if (node)
4194  {
4195  node->info.prepare.name = $3;
4196  }
4197 
4198 
4199  $$ = node;
4200  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4201 
4202  DBG_PRINT}}
4203  | deallocate_or_drop VARIABLE_ session_variable_list
4204  {{
4205 
4206  PT_NODE *node =
4207  parser_new_node (this_parser, PT_DROP_SESSION_VARIABLES);
4208  if (node)
4209  {
4210  node->info.prepare.name = $3;
4211  }
4212  $$ = node;
4213  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4214 
4215  DBG_PRINT}}
4216  ;
4217 
4218 deallocate_or_drop
4219  : DEALLOCATE
4220  | DROP
4221  ;
4222 
4223 opt_reverse
4224  : /* empty */
4225  {{
4226 
4227  parser_save_is_reverse (false);
4228  $$ = false;
4229 
4230  DBG_PRINT}}
4231  | REVERSE
4232  {{
4233 
4234  parser_save_is_reverse (true);
4235  $$ = true;
4236 
4237  DBG_PRINT}}
4238  ;
4239 
4240 opt_unique
4241  : /* empty */
4242  {{
4243 
4244  $$ = false;
4245 
4246  DBG_PRINT}}
4247  | UNIQUE
4248  {{
4249 
4250  $$ = true;
4251 
4252  DBG_PRINT}}
4253  ;
4254 
4255 opt_index_column_name_list
4256  : /* empty */
4257  {{
4258 
4259  $$ = NULL;
4260 
4261  DBG_PRINT}}
4262  | index_column_name_list
4263  {{
4264 
4265  $$ = $1;
4266  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4267 
4268  DBG_PRINT}}
4269  ;
4270 
4271 index_column_name_list
4272  : '(' sort_spec_list ')'
4273  {{
4274  if (parser_get_is_reverse())
4275  {
4276  PT_NODE *node;
4277  for (node = $2; node != NULL; node = node->next)
4278  {
4279  node->info.sort_spec.asc_or_desc = PT_DESC;
4280  }
4281  }
4282 
4283  $$ = $2;
4284  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4285 
4286  DBG_PRINT}}
4287  ;
4288 
4289 update_statistics_stmt
4290  : UPDATE STATISTICS ON_ only_class_name_list opt_with_fullscan
4291  {{
4292 
4293  PT_NODE *ups = parser_new_node (this_parser, PT_UPDATE_STATS);
4294  if (ups)
4295  {
4296  ups->info.update_stats.class_list = $4;
4297  ups->info.update_stats.all_classes = 0;
4298  ups->info.update_stats.with_fullscan = $5;
4299  }
4300  $$ = ups;
4301  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4302 
4303  DBG_PRINT}}
4304  | UPDATE STATISTICS ON_ ALL CLASSES opt_with_fullscan
4305  {{
4306 
4307  PT_NODE *ups = parser_new_node (this_parser, PT_UPDATE_STATS);
4308  if (ups)
4309  {
4310  ups->info.update_stats.class_list = NULL;
4311  ups->info.update_stats.all_classes = 1;
4312  ups->info.update_stats.with_fullscan = $6;
4313  }
4314  $$ = ups;
4315  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4316 
4317  DBG_PRINT}}
4318  | UPDATE STATISTICS ON_ CATALOG CLASSES opt_with_fullscan
4319  {{
4320 
4321  PT_NODE *ups = parser_new_node (this_parser, PT_UPDATE_STATS);
4322  if (ups)
4323  {
4324  ups->info.update_stats.class_list = NULL;
4325  ups->info.update_stats.all_classes = -1;
4326  ups->info.update_stats.with_fullscan = $6;
4327  }
4328  $$ = ups;
4329  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4330 
4331  DBG_PRINT}}
4332  ;
4333 
4334 only_class_name_list
4335  : only_class_name_list ',' only_class_name
4336  {{
4337 
4338  $$ = parser_make_link ($1, $3);
4339  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4340 
4341  DBG_PRINT}}
4342  | only_class_name
4343  {{
4344 
4345  $$ = $1;
4346  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4347 
4348  DBG_PRINT}}
4349  ;
4350 
4351 opt_invisible
4352  : /* empty */
4353  {{
4354  $$ = false;
4355 
4356  DBG_PRINT}}
4357  | INVISIBLE
4358  {{
4359 
4360  $$ = true;
4361 
4362  DBG_PRINT}}
4363  ;
4364 
4365 
4366 opt_with_fullscan
4367  : /* empty */
4368  {{
4369 
4370  $$ = 0;
4371 
4372  DBG_PRINT}}
4373  | WITH FULLSCAN
4374  {{
4375 
4376  $$ = 1;
4377 
4378  DBG_PRINT}}
4379  ;
4380 
4381 opt_with_online
4382  : /* empty */
4383  {{
4384  $$ = 0;
4385 
4386  DBG_PRINT}}
4387  | WITH ONLINE
4388  {{
4389 
4390  $$ = 1; // thread count is 0
4391 
4392  DBG_PRINT}}
4393  | WITH ONLINE PARALLEL unsigned_integer
4394  {{
4395  const int MIN_COUNT = 1;
4396  const int MAX_COUNT = 16;
4397  int thread_count = $4->info.value.data_value.i;
4398  if (thread_count < MIN_COUNT || thread_count > MAX_COUNT)
4399  {
4400  // todo - might be better to have a node here
4401  pt_cat_error (this_parser, NULL, MSGCAT_SET_PARSER_SYNTAX,
4402  MSGCAT_SYNTAX_INVALID_PARALLEL_ARGUMENT, MIN_COUNT, MAX_COUNT);
4403  }
4404  $$ = thread_count + 1;
4405  DBG_PRINT}}
4406  ;
4407 
4408 opt_of_to_eq
4409  : /* empty */
4410  | TO
4411  | '='
4412  ;
4413 
4414 opt_level_spec
4415  : ON_
4416  {{
4417 
4418  PT_NODE *val = parser_new_node (this_parser, PT_VALUE);
4419  if (val)
4420  val->info.value.data_value.i = -1;
4421  $$ = val;
4422  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4423 
4424  DBG_PRINT}}
4425  | OFF_
4426  {{
4427 
4428  PT_NODE *val = parser_new_node (this_parser, PT_VALUE);
4429  if (val)
4430  val->info.value.data_value.i = 0;
4431  $$ = val;
4432  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4433 
4434  DBG_PRINT}}
4435  | unsigned_integer
4436  {{
4437 
4438  $$ = $1;
4439  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4440 
4441  DBG_PRINT}}
4442  | param_
4443  {{
4444 
4445  $$ = $1;
4446  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4447 
4448  DBG_PRINT}}
4449  | host_param_input
4450  {{
4451 
4452  $$ = $1;
4453  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4454 
4455  DBG_PRINT}}
4456  ;
4457 
4458 char_string_literal_list
4459  : char_string_literal_list ',' char_string_literal
4460  {{
4461 
4462  $$ = parser_make_link ($1, $3);
4463  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4464 
4465  DBG_PRINT}}
4466  | char_string_literal
4467  {{
4468 
4469  $$ = $1;
4470  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4471 
4472  DBG_PRINT}}
4473  ;
4474 
4475 table_spec_list
4476  : table_spec_list ',' table_spec
4477  {{
4478 
4479  $$ = parser_make_link ($1, $3);
4480  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4481 
4482  DBG_PRINT}}
4483  | table_spec
4484  {{
4485 
4486  $$ = $1;
4487  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4488 
4489  DBG_PRINT}}
4490  ;
4491 
4492 extended_table_spec_list
4493  : extended_table_spec_list ',' table_spec
4494  {{
4495 
4496  container_2 ctn;
4497  PT_NODE *n1 = CONTAINER_AT_0 ($1);
4498  PT_NODE *n2 = $3;
4499  int number = (int) TO_NUMBER (CONTAINER_AT_1 ($1));
4500  SET_CONTAINER_2 (ctn, parser_make_link (n1, n2), FROM_NUMBER (number));
4501  $$ = ctn;
4502 
4503  DBG_PRINT}}
4504  | extended_table_spec_list join_table_spec
4505  {{
4506 
4507  container_2 ctn;
4508  PT_NODE *n1 = CONTAINER_AT_0 ($1);
4509  PT_NODE *n2 = $2;
4510  SET_CONTAINER_2 (ctn, parser_make_link (n1, n2), FROM_NUMBER (1));
4511  $$ = ctn;
4512 
4513  DBG_PRINT}}
4514  | '(' extended_table_spec_list join_table_spec ')'
4515  {{
4516 
4517  container_2 ctn;
4518  PT_NODE *n1 = CONTAINER_AT_0 ($2);
4519  PT_NODE *n2 = $3;
4520  SET_CONTAINER_2 (ctn, parser_make_link (n1, n2), FROM_NUMBER (1));
4521  $$ = ctn;
4522 
4523  DBG_PRINT}}
4524  | table_spec
4525  {{
4526 
4527  container_2 ctn;
4528  SET_CONTAINER_2 (ctn, $1, FROM_NUMBER (0));
4529  $$ = ctn;
4530 
4531  DBG_PRINT}}
4532  ;
4533 
4534 join_table_spec
4535  : CROSS JOIN table_spec
4536  {{
4537 
4538  PT_NODE *sopt = $3;
4539  if (sopt)
4540  sopt->info.spec.join_type = PT_JOIN_CROSS;
4541  $$ = sopt;
4542  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4543 
4544  DBG_PRINT}}
4545  | opt_of_inner_left_right JOIN table_spec join_condition
4546  {{
4547 
4548  PT_NODE *sopt = $3;
4549  bool natural = false;
4550 
4551  if ($4 == NULL)
4552  {
4553  /* Not exists ON condition, if it is outer join, report error */
4554  if ($1 == PT_JOIN_LEFT_OUTER
4555  || $1 == PT_JOIN_RIGHT_OUTER
4556  || $1 == PT_JOIN_FULL_OUTER)
4557  {
4558  PT_ERRORm(this_parser, sopt,
4559  MSGCAT_SET_PARSER_SYNTAX,
4560  MSGCAT_SYNTAX_OUTER_JOIN_REQUIRES_JOIN_COND);
4561  }
4562  }
4563  if (sopt)
4564  {
4565  sopt->info.spec.natural = natural;
4566  sopt->info.spec.join_type = $1;
4567  sopt->info.spec.on_cond = $4;
4568  }
4569  $$ = sopt;
4570  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4571  parser_restore_pseudoc ();
4572 
4573  DBG_PRINT}}
4574  | NATURAL opt_of_inner_left_right JOIN table_spec
4575  {{
4576 
4577  PT_NODE *sopt = $4;
4578  bool natural = true;
4579 
4580  if (sopt)
4581  {
4582  sopt->info.spec.natural = natural;
4583  sopt->info.spec.join_type = $2;
4584  sopt->info.spec.on_cond = NULL;
4585  }
4586  $$ = sopt;
4587  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4588  DBG_PRINT}}
4589  ;
4590 
4591 join_condition
4592  : /* empty */
4593  {{
4594  parser_save_and_set_pseudoc (0);
4595  $$ = NULL; /* just return NULL */
4596  DBG_PRINT}}
4597  | ON_
4598  {{
4599  parser_save_and_set_pseudoc (0);
4600  parser_save_and_set_wjc (1);
4601  parser_save_and_set_ic (1);
4602  DBG_PRINT}}
4603  search_condition
4604  {{
4605  PT_NODE *condition = $3;
4606  bool instnum_flag = false;
4607 
4608  parser_restore_wjc ();
4609  parser_restore_ic ();
4610 
4611  (void) parser_walk_tree (this_parser, condition,
4612  pt_check_instnum_pre, NULL,
4613  pt_check_instnum_post, &instnum_flag);
4614  if (instnum_flag)
4615  {
4616  PT_ERRORmf(this_parser, condition, MSGCAT_SET_PARSER_SEMANTIC,
4617  MSGCAT_SEMANTIC_EXPR_NOT_ALLOWED_IN_JOIN_COND,
4618  "INST_NUM()/ROWNUM");
4619  }
4620 
4621  $$ = condition;
4622  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4623  DBG_PRINT}}
4624 
4625 
4626  ;
4627 
4628 opt_of_inner_left_right
4629  : /* empty */
4630  {{
4631 
4632  $$ = PT_JOIN_INNER;
4633 
4634  DBG_PRINT}}
4635  | INNER opt_outer
4636  {{
4637 
4638  $$ = PT_JOIN_INNER;
4639 
4640  DBG_PRINT}}
4641  | LEFT opt_outer
4642  {{
4643 
4644  $$ = PT_JOIN_LEFT_OUTER;
4645 
4646  DBG_PRINT}}
4647  | RIGHT opt_outer
4648  {{
4649 
4650  $$ = PT_JOIN_RIGHT_OUTER;
4651 
4652  DBG_PRINT}}
4653  ;
4654 
4655 opt_outer
4656  : /* empty */
4657  | OUTER
4658  ;
4659 
4660 table_spec
4661  : '(' table_spec ')' %dprec 1
4662  {{
4663 
4664  $$ = $2;
4665  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4666 
4667  DBG_PRINT}}
4668  | original_table_spec %dprec 2
4669  {{
4670 
4671  $$ = $1;
4672  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4673 
4674  DBG_PRINT}}
4675 
4676 original_table_spec
4677  : class_spec opt_as_identifier_attr_name opt_table_spec_index_hint_list
4678  {{
4679  PT_NODE *range_var = NULL;
4680  PT_NODE *ent = $1;
4681  if (ent)
4682  {
4683  PT_NODE *stmt = parser_is_hint_node_empty () ? NULL : parser_pop_hint_node ();
4684 
4685  if (stmt)
4686  {
4687  if (stmt->node_type == PT_MERGE
4688  && ent->info.spec.only_all != PT_ONLY)
4689  {
4690  PT_ERRORm (this_parser, ent,
4691  MSGCAT_SET_PARSER_SEMANTIC,
4692  MSGCAT_SEMANTIC_MERGE_HIERARCHY_NOT_ALLOWED);
4693  }
4694  }
4695 
4696  range_var = CONTAINER_AT_0 ($2);
4697  if (range_var != NULL)
4698  {
4699  if (ent->info.spec.range_var != NULL)
4700  {
4701  parser_free_tree (this_parser,
4702  ent->info.spec.range_var);
4703  }
4704  ent->info.spec.range_var = CONTAINER_AT_0 ($2);
4705  }
4706  ent->info.spec.as_attr_list = CONTAINER_AT_1 ($2);
4707 
4708  if ($3)
4709  {
4710  PT_NODE *hint = NULL, *alias = NULL;
4711  const char *qualifier_name = NULL;
4712 
4713  /* Get qualifier */
4714  alias = CONTAINER_AT_0 ($2);
4715  if (alias)
4716  {
4717  qualifier_name = alias->info.name.original;
4718  }
4719  else if (ent->info.spec.entity_name != NULL)
4720  {
4721  qualifier_name = ent->info.spec.entity_name->info.name.original;
4722  }
4723 
4724  /* Resolve table spec index hint names */
4725  hint = $3;
4726  while (hint && qualifier_name)
4727  {
4728  hint->info.name.resolved =
4729  pt_append_string (this_parser, NULL, qualifier_name);
4730 
4731  hint = hint->next;
4732  }
4733 
4734  /* This is an index hint inside a table_spec. Copy index
4735  name list to USING INDEX clause */
4736  if (stmt)
4737  {
4738  /* copy to using_index */
4739  switch (stmt->node_type)
4740  {
4741  case PT_SELECT:
4742  stmt->info.query.q.select.using_index =
4743  parser_make_link ($3, stmt->info.query.q.select.using_index);
4744  break;
4745 
4746  case PT_DELETE:
4747  stmt->info.delete_.using_index =
4748  parser_make_link ($3, stmt->info.delete_.using_index);
4749  break;
4750 
4751  case PT_UPDATE:
4752  stmt->info.update.using_index =
4753  parser_make_link ($3, stmt->info.update.using_index);
4754  break;
4755 
4756  default:
4757  /* if index hint has been specified in
4758  * table_spec clause and statement is not
4759  * SELECT, UPDATE or DELETE raise error
4760  */
4761  PT_ERRORm (this_parser, ent,
4762  MSGCAT_SET_PARSER_SYNTAX,
4763  MSGCAT_SYNTAX_INVALID_INDEX_HINT);
4764  break;
4765  }
4766  }
4767  }
4768 
4769  if (stmt)
4770  {
4771  /* push back node */
4772  parser_push_hint_node (stmt);
4773  }
4774  }
4775 
4776  $$ = ent;
4777  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4778 
4779  DBG_PRINT}}
4780  | meta_class_spec opt_as_identifier_attr_name
4781  {{
4782 
4783  PT_NODE *ent = $1;
4784  if (ent)
4785  {
4786  PT_NODE *stmt = parser_pop_hint_node ();
4787  if (stmt && (stmt->node_type == PT_DELETE || stmt->node_type == PT_UPDATE
4788  || stmt->node_type == PT_MERGE))
4789  {
4790  PT_NODE *sel = $1;
4791  if (sel && sel->node_type == PT_SELECT)
4792  {
4793  PT_SELECT_INFO_CLEAR_FLAG (sel, PT_SELECT_INFO_DUMMY);
4794  }
4795  }
4796  parser_push_hint_node (stmt);
4797 
4798  ent->info.spec.range_var = CONTAINER_AT_0 ($2);
4799  ent->info.spec.as_attr_list = CONTAINER_AT_1 ($2);
4800 
4801  parser_remove_dummy_select (&ent);
4802  }
4803  $$ = ent;
4804  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4805 
4806  DBG_PRINT}}
4807  | subquery opt_as_identifier_attr_name
4808  {{
4809 
4810  PT_NODE *ent = parser_new_node (this_parser, PT_SPEC);
4811  if (ent)
4812  {
4813  PT_NODE *stmt = parser_pop_hint_node ();
4814  if (stmt && (stmt->node_type == PT_DELETE || stmt->node_type == PT_UPDATE
4815  || stmt->node_type == PT_MERGE))
4816  {
4817  PT_NODE *sel = $1;
4818  if (sel && sel->node_type == PT_SELECT)
4819  {
4820  PT_SELECT_INFO_CLEAR_FLAG (sel, PT_SELECT_INFO_DUMMY);
4821  }
4822  }
4823  parser_push_hint_node (stmt);
4824 
4825  ent->info.spec.derived_table = $1;
4826  ent->info.spec.derived_table_type = PT_IS_SUBQUERY;
4827 
4828  ent->info.spec.range_var = CONTAINER_AT_0 ($2);
4829  ent->info.spec.as_attr_list = CONTAINER_AT_1 ($2);
4830 
4831  parser_remove_dummy_select (&ent);
4832  }
4833  $$ = ent;
4834  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4835 
4836  DBG_PRINT}}
4837  | TABLE '(' expression_ ')' opt_as_identifier_attr_name
4838  {{
4839 
4840  PT_NODE *ent = parser_new_node (this_parser, PT_SPEC);
4841  if (ent)
4842  {
4843  ent->info.spec.derived_table = $3;
4844  ent->info.spec.derived_table_type = PT_IS_SET_EXPR;
4845 
4846  ent->info.spec.range_var = CONTAINER_AT_0 ($5);
4847  ent->info.spec.as_attr_list = CONTAINER_AT_1 ($5);
4848 
4849  parser_remove_dummy_select (&ent);
4850  }
4851  $$ = ent;
4852  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4853 
4854  DBG_PRINT}}
4855  | JSON_TABLE json_table_rule opt_as identifier
4856  {{
4857  PT_NODE *ent = parser_new_node (this_parser, PT_SPEC);
4858  if (ent)
4859  {
4860  ent->info.spec.derived_table = $2; // json_table_rule
4861  ent->info.spec.derived_table_type = PT_DERIVED_JSON_TABLE;
4862  ent->info.spec.range_var = $4; // identifier
4863  }
4864  $$ = ent;
4865  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4866 
4867  DBG_PRINT}}
4868  ;
4869 
4870 opt_table_spec_index_hint
4871  : USE index_or_key '(' identifier_list ')'
4872  {{
4873 
4874  PT_NODE *list = $4;
4875  while (list)
4876  {
4877  list->info.name.meta_class = PT_INDEX_NAME;
4878  list = list->next;
4879  }
4880 
4881  $$ = $4;
4882  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4883 
4884  DBG_PRINT}}
4885  | FORCE index_or_key '(' identifier_list ')'
4886  {{
4887 
4888  PT_NODE *list = $4;
4889  while (list)
4890  {
4891  list->info.name.meta_class = PT_INDEX_NAME;
4892  list->etc = (void *) PT_IDX_HINT_FORCE;
4893  list = list->next;
4894  }
4895 
4896  $$ = $4;
4897  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4898 
4899  DBG_PRINT}}
4900  | IGNORE_ index_or_key '(' identifier_list ')'
4901  {{
4902 
4903  PT_NODE *list = $4;
4904  while (list)
4905  {
4906  list->info.name.meta_class = PT_INDEX_NAME;
4907  list->etc = (void *) PT_IDX_HINT_IGNORE;
4908  list = list->next;
4909  }
4910 
4911  $$ = $4;
4912  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4913 
4914  DBG_PRINT}}
4915  ;
4916 
4917 opt_table_spec_index_hint_list
4918  : /* empty */
4919  {{
4920 
4921  $$ = 0;
4922  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4923 
4924  DBG_PRINT}}
4925  | opt_table_spec_index_hint_list ',' opt_table_spec_index_hint
4926  {{
4927 
4928  $$ = parser_make_link($1, $3);
4929  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos);
4930 
4931  DBG_PRINT}}
4932  | opt_table_spec_index_hint
4933  {{
4934 
4935  $$ = $1;
4936  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos);
4937 
4938  DBG_PRINT}}
4939  ;
4940 
4941 opt_as_identifier_attr_name
4942  : /* empty */
4943  {{
4944 
4945  container_2 ctn;
4946  SET_CONTAINER_2 (ctn, NULL, NULL);
4947  $$ = ctn;
4948 
4949  DBG_PRINT}}
4950  | opt_as identifier '(' identifier_list ')'
4951  {{
4952 
4953  container_2 ctn;
4954  SET_CONTAINER_2 (ctn, $2, $4);
4955  $$ = ctn;
4956 
4957  DBG_PRINT}}
4958  | opt_as identifier
4959  {{
4960 
4961  container_2 ctn;
4962  SET_CONTAINER_2 (ctn, $2, NULL);
4963  $$ = ctn;
4964 
4965  DBG_PRINT}}
4966  ;
4967 
4968 opt_as
4969  : /* empty */
4970  | AS
4971  ;
4972 
4973 class_spec_list
4974  : class_spec_list ',' class_spec
4975  {{
4976 
4977  $$ = parser_make_link ($1, $3);
4978  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4979 
4980  DBG_PRINT}}
4981  | class_spec
4982  {{
4983 
4984  $$ = $1;
4985  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4986 
4987  DBG_PRINT}}
4988  ;
4989 
4990 class_spec
4991  : only_all_class_spec
4992  {{
4993 
4994  $$ = $1;
4995  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
4996 
4997  DBG_PRINT}}
4998  | '(' only_all_class_spec_list ')'
4999  {{
5000 
5001  $$ = $2;
5002  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
5003 
5004  DBG_PRINT}}
5005  ;
5006 
5007 only_all_class_spec_list
5008  : only_all_class_spec_list ',' only_all_class_spec
5009  {{
5010 
5011  PT_NODE *result = parser_make_link ($1, $3);
5012  PT_NODE *p = parser_new_node (this_parser, PT_SPEC);
5013  if (p)
5014  p->info.spec.entity_name = result;
5015  $$ = p;
5016  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
5017 
5018  DBG_PRINT}}
5019  | only_all_class_spec
5020  {{
5021 
5022  $$ = $1;
5023  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
5024 
5025  DBG_PRINT}}
5026  ;
5027 
5028 meta_class_spec
5029  : CLASS only_class_name
5030  {{
5031 
5032  PT_NODE *ocs = parser_new_node (this_parser, PT_SPEC);
5033  if (ocs)
5034  {
5035  ocs->info.spec.entity_name = $2;
5036  ocs->info.spec.only_all = PT_ONLY;
5037  ocs->info.spec.meta_class = PT_CLASS;
5038  }
5039 
5040  if (ocs)
5041  ocs->info.spec.meta_class = PT_META_CLASS;
5042  $$ = ocs;
5043  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
5044 
5045  DBG_PRINT}}
5046  ;
5047 
5048 only_all_class_spec
5049  : only_class_name opt_partition_spec
5050  {{
5051 
5052  PT_NODE *ocs = parser_new_node (this_parser, PT_SPEC);
5053  if (ocs)
5054  {
5055  ocs->info.spec.entity_name = $1;
5056  ocs->info.spec.only_all = PT_ONLY;
5057  ocs->info.spec.meta_class = PT_CLASS;
5058  if ($2)
5059  {
5060  ocs->info.spec.partition = $2;
5061  }
5062  }
5063 
5064  $$ = ocs;
5065  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
5066 
5067  DBG_PRINT}}
5068  | ALL class_name '(' EXCEPT class_spec_list ')'
5069  {{
5070 
5071  PT_NODE *acs = parser_new_node (this_parser, PT_SPEC);
5072  if (acs)
5073  {
5074  acs->info.spec.entity_name = $2;
5075  acs->info.spec.only_all = PT_ALL;
5076  acs->info.spec.meta_class = PT_CLASS;
5077 
5078  acs->info.spec.except_list = $5;
5079  }
5080  $$ = acs;
5081  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
5082 
5083  DBG_PRINT}}
5084  | ALL class_name
5085  {{
5086 
5087  PT_NODE *acs = parser_new_node (this_parser, PT_SPEC);
5088  if (acs)
5089  {
5090  acs->info.spec.entity_name = $2;
5091  acs->info.spec.only_all = PT_ALL;
5092  acs->info.spec.meta_class = PT_CLASS;
5093  }
5094 
5095  $$ = acs;
5096  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
5097 
5098  DBG_PRINT}}
5099  ;
5100 
5101 class_name
5102  : identifier DOT identifier
5103  {{
5104 
5105  PT_NODE *user_node = $1;
5106  PT_NODE *name_node = $3;
5107 
5108  if (name_node != NULL && user_node != NULL)
5109  {
5110  name_node->info.name.resolved = pt_append_string (this_parser, NULL,
5111  user_node->info.name.original);
5112  }
5113  if (user_node != NULL)
5114  {
5115  parser_free_tree (this_parser, user_node);
5116  }
5117 
5118  $$ = name_node;
5119  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
5120 
5121  DBG_PRINT}}
5122  | identifier
5123  {{
5124 
5125  $$ = $1;
5126  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
5127 
5128  DBG_PRINT}}
5129  ;
5130 
5131 class_name_list
5132  : class_name_list ',' class_name
5133  {{
5134 
5135  $$ = parser_make_link($1, $3);
5136  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
5137 
5138  DBG_PRINT}}
5139  | class_name
5140  {{
5141 
5142  $$ = $1;
5143  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
5144 
5145  DBG_PRINT}}
5146  ;
5147 
5148 opt_partition_spec
5149  : /* empty */
5150  {{
5151  $$ = NULL;
5152  }}
5153  | PARTITION '(' identifier ')'
5154  {{
5155  $$ = $3;
5156  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
5157  DBG_PRINT}}
5158  ;
5159 
5160 opt_class_type
5161  : /* empty */
5162  {{
5163 
5164  $$ = PT_EMPTY;
5165 
5166  DBG_PRINT}}
5167  | VCLASS
5168  {{
5169 
5170  $$ = PT_VCLASS;
5171 
5172  DBG_PRINT}}
5173  | VIEW
5174  {{
5175 
5176  $$ = PT_VCLASS;
5177 
5178  DBG_PRINT}}
5179  | CLASS
5180  {{
5181 
5182  $$ = PT_CLASS;
5183 
5184  DBG_PRINT}}
5185  | TABLE
5186  {{
5187 
5188  $$ = PT_CLASS;
5189 
5190  DBG_PRINT}}
5191  ;
5192 
5193 opt_table_type
5194  : /* empty */
5195  {{
5196 
5197  $$ = PT_EMPTY;
5198 
5199  DBG_PRINT}}
5200  | CLASS
5201  {{
5202 
5203  $$ = PT_CLASS;
5204 
5205  DBG_PRINT}}
5206  | TABLE
5207  {{
5208 
5209  $$ = PT_CLASS;
5210 
5211  DBG_PRINT}}
5212  ;
5213 
5214 opt_cascade_constraints
5215  : /* empty */
5216  {{
5217 
5218  $$ = false;
5219 
5220  DBG_PRINT}}
5221  | CASCADE CONSTRAINTS
5222  {{
5223 
5224  $$ = true;
5225 
5226  DBG_PRINT}}
5227  ;
5228 
5229 alter_clause_for_alter_list
5230  : ADD alter_add_clause_for_alter_list
5231  | DROP alter_drop_clause_for_alter_list
5232  | DROP alter_drop_clause_mysql_specific
5233  | RENAME alter_rename_clause_mysql_specific
5234  | RENAME alter_rename_clause_allow_multiple opt_resolution_list_for_alter
5235  | ALTER alter_column_clause_mysql_specific
5236  | alter_partition_clause_for_alter_list
5237  | alter_auto_increment_mysql_specific
5238  | MODIFY alter_modify_clause_for_alter_list
5239  | CHANGE alter_change_clause_for_alter_list
5240  | OWNER TO identifier
5241  {{
5242  PT_NODE *alt = parser_get_alter_node();
5243 
5244  if (alt)
5245  {
5246  alt->info.alter.code = PT_CHANGE_OWNER;
5247  alt->info.alter.alter_clause.user.user_name = $3;
5248  }
5249  DBG_PRINT}}
5250  | charset_spec opt_collation
5251  {{
5252  PT_NODE *node = parser_get_alter_node();
5253  PT_NODE *cs_node, *coll_node;
5254  int charset, coll_id;
5255 
5256  cs_node = $1;
5257  coll_node = $2;
5258 
5259  if (node)
5260  {
5261  node->info.alter.alter_clause.collation.charset = -1;
5262  node->info.alter.alter_clause.collation.collation_id = -1;
5263  }
5264 
5265  if (pt_check_grammar_charset_collation (this_parser, cs_node,
5266  coll_node, &charset, &coll_id) == NO_ERROR)
5267  {
5268  if (node)
5269  {
5270  node->info.alter.code = PT_CHANGE_COLLATION;
5271  node->info.alter.alter_clause.collation.charset = charset;
5272 
5273  if (coll_node)
5274  {
5275  node->info.alter.alter_clause.collation.collation_id = coll_id;
5276  }
5277  }
5278  }
5279  DBG_PRINT}}
5280  | collation_spec
5281  {{
5282  PT_NODE *node = parser_get_alter_node();
5283  PT_NODE *coll_node;
5284  int charset, coll_id;
5285 
5286  coll_node = $1;
5287 
5288  if (node)
5289  {
5290  node->info.alter.alter_clause.collation.charset = -1;
5291  node->info.alter.alter_clause.collation.collation_id = -1;
5292  }
5293 
5294  if (pt_check_grammar_charset_collation (this_parser, NULL,
5295  coll_node, &charset, &coll_id) == NO_ERROR)
5296  {
5297  if (node)
5298  {
5299  node->info.alter.code = PT_CHANGE_COLLATION;
5300  node->info.alter.alter_clause.collation.collation_id = coll_id;
5301  }
5302  }
5303  DBG_PRINT}}
5304  | class_comment_spec
5305  {{
5306  PT_NODE *alter_node = parser_get_alter_node();
5307 
5308  if (alter_node != NULL && alter_node->info.alter.code != PT_CHANGE_COLUMN_COMMENT)
5309  {
5310  alter_node->info.alter.code = PT_CHANGE_TABLE_COMMENT;
5311  alter_node->info.alter.alter_clause.comment.tbl_comment = $1;
5312  }
5313  DBG_PRINT}}
5314  ;
5315 
5316 alter_clause_cubrid_specific
5317  : ADD alter_add_clause_cubrid_specific opt_resolution_list_for_alter
5318  | DROP alter_drop_clause_cubrid_specific opt_resolution_list_for_alter
5319  | RENAME alter_rename_clause_cubrid_specific opt_resolution_list_for_alter
5320  | CHANGE alter_change_clause_cubrid_specific
5321  | ADD alter_add_clause_for_alter_list resolution_list_for_alter
5322  | DROP alter_drop_clause_for_alter_list resolution_list_for_alter
5323  | inherit_resolution_list
5324  {{
5325 
5326  PT_NODE *alt = parser_get_alter_node ();
5327 
5328  if (alt)
5329  {
5330  alt->info.alter.code = PT_RENAME_RESOLUTION;
5331  alt->info.alter.super.resolution_list = $1;
5332  }
5333 
5334  DBG_PRINT}}
5335  ;
5336 
5337 opt_resolution_list_for_alter
5338  : /* [empty] */
5339  | resolution_list_for_alter
5340  ;
5341 
5342 resolution_list_for_alter
5343  : inherit_resolution_list
5344  {{
5345 
5346  PT_NODE *alt = parser_get_alter_node ();
5347 
5348  if (alt)
5349  {
5350  alt->info.alter.super.resolution_list = $1;
5351  }
5352 
5353  DBG_PRINT}}
5354  ;
5355 
5356 alter_rename_clause_mysql_specific
5357  : opt_to only_class_name
5358  {{
5359 
5360  PT_NODE *node = parser_get_alter_node ();
5361 
5362  if (node)
5363  {
5364  node->info.alter.code = PT_RENAME_ENTITY;
5365  node->info.alter.alter_clause.rename.new_name = $2;
5366  }
5367 
5368  DBG_PRINT}}
5369  ;
5370 
5371 alter_auto_increment_mysql_specific
5372  : AUTO_INCREMENT '=' UNSIGNED_INTEGER
5373  {{
5374  PT_NODE *node = parser_get_alter_node ();
5375  PT_NODE *val = parser_new_node (this_parser, PT_VALUE);
5376 
5377  if (node)
5378  {
5379  if (val)
5380  {
5381  val->info.value.data_value.str =
5382  pt_append_bytes (this_parser, NULL, $3,
5383  strlen ($3));
5384  val->type_enum = PT_TYPE_NUMERIC;
5385  PT_NODE_PRINT_VALUE_TO_TEXT (this_parser, val);
5386  }
5387 
5388  node->info.alter.code = PT_CHANGE_AUTO_INCREMENT;
5389  node->info.alter.alter_clause.auto_increment.start_value = val;
5390  }
5391 
5392  DBG_PRINT}}
5393  ;
5394 
5395 alter_rename_clause_allow_multiple
5396  : opt_of_attr_column_method opt_class identifier as_or_to identifier
5397  {{
5398 
5399  PT_NODE *node = parser_get_alter_node ();
5400  PT_MISC_TYPE etyp = $1;
5401 
5402  if (node)
5403  {
5404  node->info.alter.code = PT_RENAME_ATTR_MTHD;
5405 
5406  if (etyp == PT_EMPTY)
5407  etyp = PT_ATTRIBUTE;
5408 
5409  node->info.alter.alter_clause.rename.element_type = etyp;
5410  if ($2)
5411  node->info.alter.alter_clause.rename.meta = PT_META_ATTR;
5412  else
5413  node->info.alter.alter_clause.rename.meta = PT_NORMAL;
5414 
5415  node->info.alter.alter_clause.rename.new_name = $5;
5416  node->info.alter.alter_clause.rename.old_name = $3;
5417  }
5418 
5419  DBG_PRINT}}
5420  ;
5421 
5422 alter_rename_clause_cubrid_specific
5423  : FUNCTION opt_identifier OF opt_class identifier AS identifier
5424  {{
5425 
5426  PT_NODE *node = parser_get_alter_node ();
5427 
5428  if (node)
5429  {
5430  node->info.alter.code = PT_RENAME_ATTR_MTHD;
5431  node->info.alter.alter_clause.rename.element_type = PT_FUNCTION_RENAME;
5432  if ($4)
5433  node->info.alter.alter_clause.rename.meta = PT_META_ATTR;
5434  else
5435  node->info.alter.alter_clause.rename.meta = PT_NORMAL;
5436 
5437  node->info.alter.alter_clause.rename.new_name = $7;
5438  node->info.alter.alter_clause.rename.mthd_name = $5;
5439  node->info.alter.alter_clause.rename.old_name = $2;
5440  }
5441 
5442  DBG_PRINT}}
5443  | File file_path_name AS file_path_name
5444  {{
5445 
5446  PT_NODE *node = parser_get_alter_node ();
5447 
5448  if (node)
5449  {
5450  node->info.alter.code = PT_RENAME_ATTR_MTHD;
5451  node->info.alter.alter_clause.rename.element_type = PT_FILE_RENAME;
5452  node->info.alter.alter_clause.rename.new_name = $4;
5453  node->info.alter.alter_clause.rename.old_name = $2;
5454  }
5455 
5456  DBG_PRINT}}
5457  ;
5458 
5459 opt_of_attr_column_method
5460  : /* empty */
5461  {{
5462 
5463  $$ = PT_EMPTY;
5464 
5465  DBG_PRINT}}
5466  | ATTRIBUTE
5467  {{
5468 
5469  $$ = PT_ATTRIBUTE;
5470 
5471  DBG_PRINT}}
5472  | COLUMN
5473  {{
5474 
5475  $$ = PT_ATTRIBUTE;
5476 
5477  DBG_PRINT}}
5478  | METHOD
5479  {{
5480 
5481  $$ = PT_METHOD;
5482  DBG_PRINT}}
5483  ;
5484 
5485 opt_class
5486  : /* empty */
5487  {{
5488 
5489  $$ = 0;
5490 
5491  DBG_PRINT}}
5492  | CLASS
5493  {{
5494 
5495  $$ = 1;
5496 
5497  DBG_PRINT}}
5498  ;
5499 
5500 opt_identifier
5501  : /* empty */
5502  {{
5503 
5504  $$ = NULL;
5505 
5506  DBG_PRINT}}
5507  | identifier
5508  {{
5509 
5510  $$ = $1;
5511  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
5512 
5513  DBG_PRINT}}
5514  ;
5515 
5516 alter_add_clause_for_alter_list
5517  : PARTITION add_partition_clause
5518  | CLASS ATTRIBUTE
5519  { parser_attr_type = PT_META_ATTR; }
5520  '(' attr_def_list ')'
5521  { parser_attr_type = PT_NORMAL; }
5522  {{
5523 
5524  PT_NODE *node = parser_get_alter_node ();
5525  if (node)
5526  {
5527  node->info.alter.code = PT_ADD_ATTR_MTHD;
5528  node->info.alter.alter_clause.attr_mthd.attr_def_list = $5;
5529  }
5530 
5531  DBG_PRINT}}
5532  | CLASS ATTRIBUTE
5533  { parser_attr_type = PT_META_ATTR; }
5534  attr_def
5535  { parser_attr_type = PT_NORMAL; }
5536  {{
5537 
5538  PT_NODE *node = parser_get_alter_node ();
5539  if (node)
5540  {
5541  node->info.alter.code = PT_ADD_ATTR_MTHD;
5542  node->info.alter.alter_clause.attr_mthd.attr_def_list = $4;
5543  }
5544 
5545  DBG_PRINT}}
5546  | opt_of_column_attribute
5547  { allow_attribute_ordering = true; }
5548  '(' attr_def_list ')'
5549  { allow_attribute_ordering = false; }
5550  {{
5551 
5552  PT_NODE *node = parser_get_alter_node ();
5553  if (node)
5554  {
5555  node->info.alter.code = PT_ADD_ATTR_MTHD;
5556  node->info.alter.alter_clause.attr_mthd.attr_def_list = $4;
5557  }
5558 
5559  DBG_PRINT}}
5560  | opt_of_column_attribute
5561  { allow_attribute_ordering = true; }
5562  attr_def
5563  { allow_attribute_ordering = false; }
5564  {{
5565 
5566  PT_NODE *node = parser_get_alter_node ();
5567  if (node)
5568  {
5569  node->info.alter.code = PT_ADD_ATTR_MTHD;
5570  node->info.alter.alter_clause.attr_mthd.attr_def_list = $3;
5571  }
5572 
5573  DBG_PRINT}}
5574  ;
5575 
5576 alter_add_clause_cubrid_specific
5577  : File method_file_list
5578  {{
5579 
5580  PT_NODE *node = parser_get_alter_node ();
5581 
5582  if (node)
5583  {
5584  node->info.alter.code = PT_ADD_ATTR_MTHD;
5585  node->info.alter.alter_clause.attr_mthd.mthd_file_list = $2;
5586  }
5587 
5588  DBG_PRINT}}
5589  | METHOD method_def_list
5590  {{
5591 
5592  PT_NODE *node = parser_get_alter_node ();
5593  if (node)
5594  {
5595  node->info.alter.code = PT_ADD_ATTR_MTHD;
5596  node->info.alter.alter_clause.attr_mthd.mthd_def_list = $2;
5597  }
5598 
5599  DBG_PRINT}}
5600  | METHOD method_def_list File method_file_list
5601  {{
5602 
5603  PT_NODE *node = parser_get_alter_node ();
5604 
5605  if (node)
5606  {
5607  node->info.alter.code = PT_ADD_ATTR_MTHD;
5608  node->info.alter.alter_clause.attr_mthd.mthd_file_list = $4;
5609  node->info.alter.alter_clause.attr_mthd.mthd_def_list = $2;
5610  }
5611 
5612  DBG_PRINT}}
5613  | SUPERCLASS only_class_name_list
5614  {{
5615 
5616  PT_NODE *node = parser_get_alter_node ();
5617 
5618  if (node)
5619  {
5620  node->info.alter.code = PT_ADD_SUPCLASS;
5621  node->info.alter.super.sup_class_list = $2;
5622  }
5623 
5624  DBG_PRINT}}
5625  | QUERY csql_query opt_vclass_comment_spec
5626  {{
5627 
5628  PT_NODE *node = parser_get_alter_node ();
5629 
5630  if (node)
5631  {
5632  node->info.alter.code = PT_ADD_QUERY;
5633  node->info.alter.alter_clause.query.query = $2;
5634  node->info.alter.alter_clause.query.view_comment = $3;
5635  }
5636 
5637  DBG_PRINT}}
5638  | CLASS ATTRIBUTE
5639  { parser_attr_type = PT_META_ATTR; }
5640  attr_def_list_with_commas
5641  { parser_attr_type = PT_NORMAL; }
5642  {{
5643 
5644  PT_NODE *node = parser_get_alter_node ();
5645  if (node)
5646  {
5647  node->info.alter.code = PT_ADD_ATTR_MTHD;
5648  node->info.alter.alter_clause.attr_mthd.attr_def_list = $4;
5649  }
5650 
5651  DBG_PRINT}}
5652  | opt_of_column_attribute attr_def_list_with_commas
5653  {{
5654 
5655  PT_NODE *node = parser_get_alter_node ();
5656  if (node)
5657  {
5658  node->info.alter.code = PT_ADD_ATTR_MTHD;
5659  node->info.alter.alter_clause.attr_mthd.attr_def_list = $2;
5660  }
5661 
5662  DBG_PRINT}}
5663  ;
5664 
5665 opt_of_column_attribute
5666  : /* empty */
5667  | COLUMN
5668  | ATTRIBUTE
5669  ;
5670 
5671 add_partition_clause
5672  : PARTITIONS literal_w_o_param
5673  {{
5674 
5675  PT_NODE *node = parser_get_alter_node ();
5676  node->info.alter.code = PT_ADD_HASHPARTITION;
5677  node->info.alter.alter_clause.partition.size = $2;
5678 
5679  DBG_PRINT}}
5680  | '(' partition_def_list ')'
5681  {{
5682 
5683  PT_NODE *node = parser_get_alter_node ();
5684  node->info.alter.code = PT_ADD_PARTITION;
5685  node->info.alter.alter_clause.partition.parts = $2;
5686 
5687  DBG_PRINT}}
5688  ;
5689 
5690 alter_drop_clause_mysql_specific
5691  : opt_reverse opt_unique index_or_key identifier
5692  {{
5693 
5694  PT_NODE *node = parser_get_alter_node ();
5695 
5696  if (node)
5697  {
5698  node->info.alter.code = PT_DROP_INDEX_CLAUSE;
5699  node->info.alter.alter_clause.index.reverse = $1;
5700  node->info.alter.alter_clause.index.unique = $2;
5701  node->info.alter.constraint_list = $4;
5702  }
5703 
5704  DBG_PRINT}}
5705  | PRIMARY KEY
5706  {{
5707 
5708  PT_NODE *node = parser_get_alter_node ();
5709 
5710  if (node)
5711  {
5712  node->info.alter.code = PT_DROP_PRIMARY_CLAUSE;
5713  }
5714 
5715  DBG_PRINT}}
5716  | FOREIGN KEY identifier
5717  {{
5718 
5719  PT_NODE *node = parser_get_alter_node ();
5720 
5721  if (node)
5722  {
5723  node->info.alter.code = PT_DROP_FK_CLAUSE;
5724  node->info.alter.constraint_list = $3;
5725  }
5726 
5727  DBG_PRINT}}
5728  ;
5729 
5730 alter_drop_clause_for_alter_list
5731  : opt_of_attr_column_method normal_or_class_attr
5732  {{
5733 
5734  PT_NODE *node = parser_get_alter_node ();
5735 
5736  if (node)
5737  {
5738  node->info.alter.code = PT_DROP_ATTR_MTHD;
5739  node->info.alter.alter_clause.attr_mthd.attr_mthd_name_list = $2;
5740  }
5741 
5742  DBG_PRINT}}
5743  | CONSTRAINT identifier
5744  {{
5745 
5746  PT_NODE *node = parser_get_alter_node ();
5747 
5748  if (node)
5749  {
5750  node->info.alter.code = PT_DROP_CONSTRAINT;
5751  node->info.alter.constraint_list = $2;
5752  }
5753 
5754  DBG_PRINT}}
5755  | PARTITION identifier_list
5756  {{
5757 
5758  PT_NODE *node = parser_get_alter_node ();
5759 
5760  if (node)
5761  {
5762  node->info.alter.code = PT_DROP_PARTITION;
5763  node->info.alter.alter_clause.partition.name_list = $2;
5764  }
5765 
5766  DBG_PRINT}}
5767  ;
5768 
5769 alter_drop_clause_cubrid_specific
5770  : opt_of_attr_column_method normal_or_class_attr_list_with_commas
5771  {{
5772 
5773  PT_NODE *node = parser_get_alter_node ();
5774 
5775  if (node)
5776  {
5777  node->info.alter.code = PT_DROP_ATTR_MTHD;
5778  node->info.alter.alter_clause.attr_mthd.attr_mthd_name_list = $2;
5779  }
5780 
5781  DBG_PRINT}}
5782  | File method_file_list
5783  {{
5784 
5785  PT_NODE *node = parser_get_alter_node ();
5786 
5787  if (node)
5788  {
5789  node->info.alter.code = PT_DROP_ATTR_MTHD;
5790  node->info.alter.alter_clause.attr_mthd.mthd_file_list = $2;
5791  }
5792 
5793  DBG_PRINT}}
5794  | SUPERCLASS only_class_name_list
5795  {{
5796 
5797  PT_NODE *node = parser_get_alter_node ();
5798 
5799  if (node)
5800  {
5801  node->info.alter.code = PT_DROP_SUPCLASS;
5802  node->info.alter.super.sup_class_list = $2;
5803  }
5804 
5805  DBG_PRINT}}
5806  | QUERY query_number_list
5807  {{
5808 
5809  PT_NODE *node = parser_get_alter_node ();
5810 
5811  if (node)
5812  {
5813  node->info.alter.code = PT_DROP_QUERY;
5814  node->info.alter.alter_clause.query.query_no_list = $2;
5815  }
5816 
5817  DBG_PRINT}}
5818  | QUERY
5819  {{
5820 
5821  PT_NODE *node = parser_get_alter_node ();
5822 
5823  if (node)
5824  {
5825  node->info.alter.code = PT_DROP_QUERY;
5826  node->info.alter.alter_clause.query.query_no_list = NULL;
5827  }
5828 
5829  DBG_PRINT}}
5830  ;
5831 
5832 normal_or_class_attr_list_with_commas
5833  : normal_or_class_attr_list_with_commas ',' normal_or_class_attr
5834  {{
5835 
5836  $$ = parser_make_link ($1, $3);
5837  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
5838 
5839  DBG_PRINT}}
5840  | normal_or_class_attr ',' normal_or_class_attr
5841  {{
5842 
5843  $$ = parser_make_link ($1, $3);
5844  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
5845 
5846  DBG_PRINT}}
5847  ;
5848 
5849 alter_modify_clause_for_alter_list
5850  : opt_of_column_attribute
5851  { allow_attribute_ordering = true; }
5852  attr_def_one
5853  { allow_attribute_ordering = false; }
5854  {{
5855 
5856  PT_NODE *node = parser_get_alter_node ();
5857 
5858  if (node)
5859  {
5860  node->info.alter.code = PT_CHANGE_ATTR;
5861  node->info.alter.alter_clause.attr_mthd.attr_def_list = $3;
5862  /* no name change for MODIFY */
5863  }
5864 
5865  DBG_PRINT}}
5866  | CLASS ATTRIBUTE
5867  { allow_attribute_ordering = true; }
5868  attr_def_one
5869  { allow_attribute_ordering = false; }
5870  {{
5871 
5872  PT_NODE *node = parser_get_alter_node ();
5873 
5874  if (node)
5875  {
5876  node->info.alter.code = PT_CHANGE_ATTR;
5877  node->info.alter.alter_clause.attr_mthd.attr_def_list = $4;
5878  /* no name change for MODIFY */
5879 
5880  node->info.alter.alter_clause.attr_mthd.attr_def_list->
5881  info.attr_def.attr_type = PT_META_ATTR;
5882  }
5883 
5884  DBG_PRINT}}
5885  ;
5886 
5887 alter_change_clause_for_alter_list
5888  : normal_column_or_class_attribute
5889  { allow_attribute_ordering = true; }
5890  attr_def_one
5891  { allow_attribute_ordering = false; }
5892  {{
5893 
5894  PT_NODE *node = parser_get_alter_node ();
5895 
5896  if (node)
5897  {
5898  PT_NODE *att = NULL;
5899 
5900  node->info.alter.code = PT_CHANGE_ATTR;
5901  node->info.alter.alter_clause.attr_mthd.attr_def_list = $3;
5902  node->info.alter.alter_clause.attr_mthd.attr_old_name = $1;
5903 
5904  att = node->info.alter.alter_clause.attr_mthd.attr_def_list;
5905  att->info.attr_def.attr_type =
5906  node->info.alter.alter_clause.attr_mthd.attr_old_name->info.name.meta_class;
5907  }
5908 
5909  DBG_PRINT}}
5910  ;
5911 
5912 alter_change_clause_cubrid_specific
5913  : METHOD method_def_list
5914  {{
5915 
5916  PT_NODE *node = parser_get_alter_node ();
5917 
5918  if (node)
5919  {
5920  node->info.alter.code = PT_MODIFY_ATTR_MTHD;
5921  node->info.alter.alter_clause.attr_mthd.mthd_def_list = $2;
5922  }
5923 
5924  DBG_PRINT}}
5925  | QUERY unsigned_integer csql_query opt_vclass_comment_spec
5926  {{
5927 
5928  PT_NODE *node = parser_get_alter_node ();
5929 
5930  if (node)
5931  {
5932  node->info.alter.code = PT_MODIFY_QUERY;
5933  node->info.alter.alter_clause.query.query = $3;
5934  node->info.alter.alter_clause.query.query_no_list = $2;
5935  node->info.alter.alter_clause.query.view_comment = $4;
5936  }
5937 
5938  DBG_PRINT}}
5939  | QUERY csql_query opt_vclass_comment_spec
5940  {{
5941 
5942  PT_NODE *node = parser_get_alter_node ();
5943 
5944  if (node)
5945  {
5946  node->info.alter.code = PT_MODIFY_QUERY;
5947  node->info.alter.alter_clause.query.query = $2;
5948  node->info.alter.alter_clause.query.query_no_list = NULL;
5949  node->info.alter.alter_clause.query.view_comment = $3;
5950  }
5951 
5952  DBG_PRINT}}
5953  | File file_path_name AS file_path_name
5954  {{
5955 
5956  PT_NODE *node = parser_get_alter_node ();
5957 
5958  if (node)
5959  {
5960  node->info.alter.code = PT_RENAME_ATTR_MTHD;
5961  node->info.alter.alter_clause.rename.element_type = PT_FILE_RENAME;
5962  node->info.alter.alter_clause.rename.new_name = $4;
5963  node->info.alter.alter_clause.rename.old_name = $2;
5964  }
5965 
5966  DBG_PRINT}}
5967  ;
5968 
5969 normal_or_class_attr
5970  : opt_class identifier
5971  {{
5972 
5973  if ($1)
5974  $2->info.name.meta_class = PT_META_ATTR;
5975  else
5976  $2->info.name.meta_class = PT_NORMAL;
5977 
5978  $$ = $2;
5979  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
5980 
5981  DBG_PRINT}}
5982  ;
5983 
5984 query_number_list
5985  : query_number_list ',' unsigned_integer
5986  {{
5987 
5988  $$ = parser_make_link ($1, $3);
5989  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
5990 
5991  DBG_PRINT}}
5992  | unsigned_integer
5993  {{
5994 
5995  $$ = $1;
5996  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
5997 
5998  DBG_PRINT}}
5999  ;
6000 
6001 alter_column_clause_mysql_specific
6002  : normal_column_or_class_attribute SET DEFAULT expression_
6003  {{
6004 
6005  PT_NODE *alter_node = parser_get_alter_node ();
6006 
6007  if (alter_node)
6008  {
6009  PT_NODE *node = parser_new_node (this_parser, PT_DATA_DEFAULT);
6010 
6011  if (node)
6012  {
6013  PT_NODE *def;
6014  node->info.data_default.default_value = $4;
6015  node->info.data_default.shared = PT_DEFAULT;
6016  PARSER_SAVE_ERR_CONTEXT (node, @4.buffer_pos)
6017 
6018  def = node->info.data_default.default_value;
6019  if (def && def->node_type == PT_EXPR)
6020  {
6021  if (def->info.expr.op == PT_TO_CHAR)
6022  {
6023  if (def->info.expr.arg3)
6024  {
6025  bool dummy;
6026  bool has_user_lang = false;
6027  assert (def->info.expr.arg3->node_type == PT_VALUE);
6028  (void) lang_get_lang_id_from_flag (def->info.expr.arg3->info.value.data_value.i, &dummy, &has_user_lang);
6029  if (has_user_lang)
6030  {
6031  PT_ERROR (this_parser, def->info.expr.arg3, "do not allow lang format in default to_char");
6032  }
6033  }
6034 
6035  if (def->info.expr.arg1 && def->info.expr.arg1->node_type == PT_EXPR)
6036  {
6037  def = def->info.expr.arg1;
6038  }
6039  }
6040 
6041  switch (def->info.expr.op)
6042  {
6043  case PT_SYS_TIME:
6044  node->info.data_default.default_expr_type = DB_DEFAULT_SYSTIME;
6045  break;
6046  case PT_SYS_DATE:
6047  node->info.data_default.default_expr_type = DB_DEFAULT_SYSDATE;
6048  break;
6049  case PT_SYS_DATETIME:
6050  node->info.data_default.default_expr_type = DB_DEFAULT_SYSDATETIME;
6051  break;
6052  case PT_SYS_TIMESTAMP:
6053  node->info.data_default.default_expr_type = DB_DEFAULT_SYSTIMESTAMP;
6054  break;
6055  case PT_CURRENT_TIME:
6056  node->info.data_default.default_expr_type = DB_DEFAULT_CURRENTTIME;
6057  break;
6058  case PT_CURRENT_DATE:
6059  node->info.data_default.default_expr_type = DB_DEFAULT_CURRENTDATE;
6060  break;
6061  case PT_CURRENT_DATETIME:
6062  node->info.data_default.default_expr_type = DB_DEFAULT_CURRENTDATETIME;
6063  break;
6064  case PT_CURRENT_TIMESTAMP:
6065  node->info.data_default.default_expr_type = DB_DEFAULT_CURRENTTIMESTAMP;
6066  break;
6067  case PT_USER:
6068  node->info.data_default.default_expr_type = DB_DEFAULT_USER;
6069  break;
6070  case PT_CURRENT_USER:
6071  node->info.data_default.default_expr_type = DB_DEFAULT_CURR_USER;
6072  break;
6073  case PT_UNIX_TIMESTAMP:
6074  node->info.data_default.default_expr_type = DB_DEFAULT_UNIX_TIMESTAMP;
6075  break;
6076  default:
6077  node->info.data_default.default_expr_type = DB_DEFAULT_NONE;
6078  break;
6079  }
6080  }
6081  else
6082  {
6083  node->info.data_default.default_expr_type = DB_DEFAULT_NONE;
6084  }
6085  }
6086 
6087  alter_node->info.alter.code = PT_ALTER_DEFAULT;
6088  alter_node->info.alter.alter_clause.ch_attr_def.attr_name_list = $1;
6089  alter_node->info.alter.alter_clause.ch_attr_def.data_default_list = node;
6090  }
6091 
6092  DBG_PRINT}}
6093  ;
6094 
6095 normal_column_or_class_attribute
6096  : opt_of_column_attribute identifier
6097  {{
6098 
6099  PT_NODE * node = $2;
6100  if (node)
6101  {
6102  node->info.name.meta_class = PT_NORMAL;
6103  }
6104  $$ = node;
6105  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6106 
6107  DBG_PRINT}}
6108  | CLASS ATTRIBUTE identifier
6109  {{
6110 
6111  PT_NODE * node = $3;
6112  if (node)
6113  {
6114  node->info.name.meta_class = PT_META_ATTR;
6115  }
6116  $$ = node;
6117  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6118 
6119  DBG_PRINT}}
6120  ;
6121 
6122 insert_or_replace_stmt
6123  : insert_name_clause insert_stmt_value_clause on_duplicate_key_update
6124  {{
6125 
6126  PT_NODE *ins = $1;
6127 
6128  if (ins)
6129  {
6130  ins->info.insert.odku_assignments = $3;
6131  ins->info.insert.value_clauses = $2;
6132  }
6133 
6134  $$ = ins;
6135  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6136 
6137  DBG_PRINT}}
6138  | insert_name_clause insert_stmt_value_clause into_clause_opt
6139  {{
6140 
6141  PT_NODE *ins = $1;
6142 
6143  if (ins)
6144  {
6145  ins->info.insert.value_clauses = $2;
6146  ins->info.insert.into_var = $3;
6147  }
6148 
6149  $$ = ins;
6150  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6151 
6152  DBG_PRINT}}
6153  | replace_name_clause insert_stmt_value_clause into_clause_opt
6154  {{
6155 
6156  PT_NODE *ins = $1;
6157 
6158  if (ins)
6159  {
6160  ins->info.insert.value_clauses = $2;
6161  ins->info.insert.into_var = $3;
6162  }
6163 
6164  $$ = ins;
6165  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6166 
6167  DBG_PRINT}}
6168  | insert_set_stmt on_duplicate_key_update
6169  {{
6170 
6171  PT_NODE *ins = $1;
6172  if (ins)
6173  {
6174  ins->info.insert.odku_assignments = $2;
6175  }
6176 
6177  $$ = ins;
6178  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6179 
6180  DBG_PRINT}}
6181  | insert_set_stmt into_clause_opt
6182  {{
6183 
6184  PT_NODE *ins = $1;
6185 
6186  if (ins)
6187  {
6188  ins->info.insert.into_var = $2;
6189  }
6190 
6191  $$ = ins;
6192  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6193 
6194  DBG_PRINT}}
6195  | replace_set_stmt into_clause_opt
6196  {{
6197 
6198  PT_NODE *ins = $1;
6199 
6200  if (ins)
6201  {
6202  ins->info.insert.into_var = $2;
6203  }
6204 
6205  $$ = ins;
6206  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6207 
6208  DBG_PRINT}}
6209  ;
6210 
6211 insert_set_stmt
6212  : insert_stmt_keyword
6213  insert_set_stmt_header
6214  {{
6215  $$ = $2;
6216  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6217  }}
6218  ;
6219 
6220 replace_set_stmt
6221  : replace_stmt_keyword
6222  insert_set_stmt_header
6223  {{
6224  $$ = $2;
6225  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6226  }}
6227  ;
6228 
6229 insert_stmt_keyword
6230  : INSERT
6231  {
6232  PT_NODE* ins = parser_new_node (this_parser, PT_INSERT);
6233  parser_push_hint_node (ins);
6234  }
6235  ;
6236 
6237 replace_stmt_keyword
6238  : REPLACE
6239  {
6240  PT_NODE* ins = parser_new_node (this_parser, PT_INSERT);
6241  if (ins)
6242  {
6243  ins->info.insert.do_replace = true;
6244  }
6245  parser_push_hint_node (ins);
6246  }
6247  ;
6248 
6249 insert_set_stmt_header
6250  : opt_hint_list
6251  opt_into
6252  only_class_name
6253  SET
6254  insert_assignment_list
6255  {{
6256 
6257  PT_NODE *ins = parser_pop_hint_node ();
6258  PT_NODE *ocs = parser_new_node (this_parser, PT_SPEC);
6259  PT_NODE *nls = pt_node_list (this_parser, PT_IS_VALUE, CONTAINER_AT_1 ($5));
6260 
6261  if (ocs)
6262  {
6263  ocs->info.spec.entity_name = $3;
6264  ocs->info.spec.only_all = PT_ONLY;
6265  ocs->info.spec.meta_class = PT_CLASS;
6266  }
6267 
6268  if (ins)
6269  {
6270  ins->info.insert.spec = ocs;
6271  ins->info.insert.attr_list = CONTAINER_AT_0 ($5);
6272  ins->info.insert.value_clauses = nls;
6273  }
6274 
6275  $$ = ins;
6276  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6277 
6278  DBG_PRINT}}
6279  ;
6280 
6281 insert_assignment_list
6282  : insert_assignment_list ',' identifier '=' expression_
6283  {{
6284 
6285  parser_make_link (CONTAINER_AT_0 ($1), $3);
6286  parser_make_link (CONTAINER_AT_1 ($1), $5);
6287 
6288  $$ = $1;
6289 
6290  DBG_PRINT}}
6291  | insert_assignment_list ',' identifier '=' DEFAULT
6292  {{
6293  PT_NODE *arg = parser_copy_tree (this_parser, $3);
6294 
6295  if (arg)
6296  {
6297  pt_set_fill_default_in_path_expression (arg);
6298  }
6299  parser_make_link (CONTAINER_AT_0 ($1), $3);
6300  parser_make_link (CONTAINER_AT_1 ($1),
6301  parser_make_expression (this_parser, PT_DEFAULTF, arg, NULL, NULL));
6302 
6303  $$ = $1;
6304 
6305  DBG_PRINT}}
6306  | identifier '=' expression_
6307  {{
6308 
6309  container_2 ctn;
6310  SET_CONTAINER_2 (ctn, $1, $3);
6311 
6312  $$ = ctn;
6313 
6314  DBG_PRINT}}
6315  | identifier '=' DEFAULT
6316  {{
6317 
6318  container_2 ctn;
6319  PT_NODE *arg = parser_copy_tree (this_parser, $1);
6320 
6321  if (arg)
6322  {
6323  pt_set_fill_default_in_path_expression (arg);
6324  }
6325  SET_CONTAINER_2 (ctn, $1,
6326  parser_make_expression (this_parser, PT_DEFAULTF, arg, NULL, NULL));
6327 
6328  $$ = ctn;
6329 
6330  DBG_PRINT}}
6331  ;
6332 
6333 on_duplicate_key_update
6334  : ON_ DUPLICATE_ KEY UPDATE
6335  update_assignment_list
6336  {{
6337 
6338  $$ = $5;
6339  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6340 
6341  DBG_PRINT}}
6342  ;
6343 
6344 insert_expression
6345  : insert_name_clause insert_expression_value_clause
6346  {{
6347 
6348  PT_NODE *ins = $1;
6349 
6350  if (ins)
6351  {
6352  ins->info.insert.value_clauses = $2;
6353  }
6354 
6355  $$ = ins;
6356  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6357 
6358  DBG_PRINT}}
6359  | '(' insert_name_clause insert_expression_value_clause into_clause_opt ')'
6360  {{
6361 
6362  PT_NODE *ins = $2;
6363 
6364  if (ins)
6365  {
6366  ins->info.insert.value_clauses = $3;
6367  ins->info.insert.into_var = $4;
6368  }
6369 
6370  $$ = ins;
6371  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6372 
6373  DBG_PRINT}}
6374  ;
6375 
6376 insert_name_clause
6377  : insert_stmt_keyword
6378  insert_name_clause_header
6379  {{
6380  $$ = $2;
6381  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6382  }}
6383  ;
6384 
6385 replace_name_clause
6386  : replace_stmt_keyword
6387  insert_name_clause_header
6388  {{
6389  $$ = $2;
6390  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6391  }}
6392  ;
6393 
6394 insert_name_clause_header
6395  : opt_hint_list
6396  opt_into
6397  only_class_name
6398  opt_partition_spec
6399  opt_attr_list
6400  {{
6401 
6402  PT_NODE *ins = parser_pop_hint_node ();
6403  PT_NODE *ocs = parser_new_node (this_parser, PT_SPEC);
6404 
6405  if (ocs)
6406  {
6407  ocs->info.spec.entity_name = $3;
6408  ocs->info.spec.only_all = PT_ONLY;
6409  ocs->info.spec.meta_class = PT_CLASS;
6410  if ($4)
6411  {
6412  ocs->info.spec.partition = $4;
6413  }
6414  }
6415 
6416  if (ins)
6417  {
6418  ins->info.insert.spec = ocs;
6419  ins->info.insert.attr_list = $5;
6420  }
6421 
6422  $$ = ins;
6423  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6424 
6425  DBG_PRINT}}
6426  ;
6427 
6428 opt_attr_list
6429  : /* empty */
6430  {{
6431 
6432  $$ = NULL;
6433 
6434  DBG_PRINT}}
6435  | '(' ')'
6436  {{
6437 
6438  $$ = NULL;
6439 
6440  DBG_PRINT}}
6441  | '(' identifier_list ')'
6442  {{
6443 
6444  $$ = $2;
6445  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6446 
6447  DBG_PRINT}}
6448  ;
6449 
6450 opt_path_attr_list
6451  : /* empty */
6452  {{
6453 
6454  $$ = NULL;
6455 
6456  DBG_PRINT}}
6457  | '(' ')'
6458  {{
6459 
6460  $$ = NULL;
6461 
6462  DBG_PRINT}}
6463  | '(' simple_path_id_list ')'
6464  {{
6465 
6466  $$ = $2;
6467  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6468 
6469  DBG_PRINT}}
6470  ;
6471 
6472 insert_stmt_value_clause
6473  : insert_expression_value_clause
6474  {{
6475 
6476  $$ = $1;
6477  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6478 
6479  DBG_PRINT}}
6480  | opt_with_clause
6481  csql_query_without_values_and_single_subquery
6482  {{
6483 
6484  PT_NODE *with_clause = $1;
6485  PT_NODE *select_node = $2;
6486  select_node->info.query.with = with_clause;
6487  PT_NODE *nls = pt_node_list (this_parser, PT_IS_SUBQUERY, select_node);
6488 
6489  $$ = nls;
6490  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6491 
6492  DBG_PRINT}}
6493  | '(' opt_with_clause
6494  csql_query_without_values_query_no_with_clause ')'
6495  {{
6496  PT_NODE *with_clause = $2;
6497  PT_NODE *select_node = $3;
6498  select_node->info.query.with = with_clause;
6499  PT_NODE *nls = pt_node_list (this_parser, PT_IS_SUBQUERY, select_node);
6500 
6501  $$ = nls;
6502  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6503 
6504  DBG_PRINT}}
6505  ;
6506 
6507 insert_expression_value_clause
6508  : of_value_values insert_value_clause_list
6509  {{
6510 
6511  $$ = $2;
6512  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6513 
6514  DBG_PRINT}}
6515  | DEFAULT opt_values
6516  {{
6517 
6518  PT_NODE *nls = pt_node_list (this_parser, PT_IS_DEFAULT_VALUE, NULL);
6519  $$ = nls;
6520  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6521 
6522  DBG_PRINT}}
6523  ;
6524 
6525 of_value_values
6526  : VALUE
6527  | VALUES
6528  ;
6529 
6530 opt_values
6531  : /* [empty] */
6532  | VALUES
6533  ;
6534 
6535 opt_into
6536  : /* [empty] */
6537  | INTO
6538  ;
6539 
6540 into_clause_opt
6541  : /* empty */
6542  {{
6543 
6544  $$ = NULL;
6545 
6546  DBG_PRINT}}
6547  | INTO to_param
6548  {{
6549 
6550  $$ = $2;
6551  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6552 
6553  DBG_PRINT}}
6554  | TO to_param
6555  {{
6556 
6557  $$ = $2;
6558  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6559 
6560  DBG_PRINT}}
6561  ;
6562 
6563 insert_value_clause_list
6564  : insert_value_clause_list ',' insert_value_clause
6565  {{
6566 
6567  $$ = parser_make_link ($1, $3);
6568  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6569 
6570  DBG_PRINT}}
6571  | insert_value_clause
6572  {{
6573 
6574  $$ = $1;
6575  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6576 
6577  DBG_PRINT}}
6578  ;
6579 
6580 insert_value_clause
6581  : '(' insert_value_list ')'
6582  {{
6583 
6584  PT_NODE *nls = pt_node_list (this_parser, PT_IS_VALUE, $2);
6585  $$ = nls;
6586  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6587 
6588  DBG_PRINT}}
6589  | '('')'
6590  {{
6591 
6592  PT_NODE *nls = NULL;
6593 
6594  if (prm_get_integer_value (PRM_ID_COMPAT_MODE) == COMPAT_MYSQL)
6595  {
6596  nls = pt_node_list (this_parser, PT_IS_DEFAULT_VALUE, NULL);
6597  }
6598  else
6599  {
6600  nls = pt_node_list (this_parser, PT_IS_VALUE, NULL);
6601  }
6602 
6603  $$ = nls;
6604  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6605 
6606  DBG_PRINT}}
6607  | DEFAULT opt_values
6608  {{
6609 
6610  PT_NODE *nls = pt_node_list (this_parser, PT_IS_DEFAULT_VALUE, NULL);
6611  $$ = nls;
6612  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6613 
6614  DBG_PRINT}}
6615  ;
6616 
6617 insert_value_list
6618  : insert_value_list ',' insert_value
6619  {{
6620 
6621  $$ = parser_make_link ($1, $3);
6622  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6623 
6624  DBG_PRINT}}
6625  | insert_value
6626  {{
6627 
6628  $$ = $1;
6629  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6630 
6631  DBG_PRINT}}
6632  ;
6633 
6634 insert_value
6635  : select_stmt
6636  {{
6637 
6638  $$ = $1;
6639  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6640 
6641  DBG_PRINT}}
6642  | normal_expression
6643  {{
6644 
6645  $$ = $1;
6646  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6647 
6648  DBG_PRINT}}
6649  | DEFAULT
6650  {{
6651 
6652  /* The argument will be filled in later, when the
6653  corresponding column name is known.
6654  See fill_in_insert_default_function_arguments(). */
6655  $$ = parser_make_expression (this_parser, PT_DEFAULTF, NULL, NULL, NULL);
6656  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6657 
6658  DBG_PRINT}}
6659  ;
6660 
6661 show_stmt
6662  : SHOW
6663  opt_full
6664  TABLES
6665  {{
6666 
6667  const bool is_full_syntax = ($2 == 1);
6668  const int like_where_syntax = 0; /* neither LIKE nor WHERE */
6669  PT_NODE *node = NULL;
6670 
6671  node = pt_make_query_show_table (this_parser, is_full_syntax, like_where_syntax, NULL);
6672 
6673  $$ = node;
6674  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6675 
6676  DBG_PRINT}}
6677  | SHOW
6678  opt_full
6679  TABLES
6680  LIKE
6681  expression_
6682  {{
6683 
6684  const bool is_full_syntax = ($2 == 1);
6685  const int like_where_syntax = 1; /* is LIKE */
6686  PT_NODE *node = NULL;
6687  PT_NODE *like_rhs = $5;
6688 
6689  node = pt_make_query_show_table (this_parser, is_full_syntax, like_where_syntax, like_rhs);
6690 
6691  $$ = node;
6692  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6693 
6694  DBG_PRINT}}
6695  | SHOW
6696  opt_full
6697  TABLES
6698  WHERE
6699  search_condition
6700  {{
6701 
6702  const bool is_full_syntax = ($2 == 1);
6703  const int like_where_syntax = 2; /* is WHERE */
6704  PT_NODE *node = NULL;
6705  PT_NODE *where_cond = $5;
6706 
6707  node = pt_make_query_show_table (this_parser, is_full_syntax, like_where_syntax, where_cond);
6708 
6709  $$ = node;
6710  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6711 
6712  DBG_PRINT}}
6713  | SHOW
6714  opt_full
6715  COLUMNS
6716  of_from_in
6717  identifier
6718  {{
6719 
6720  const bool is_full_syntax = ($2 == 1);
6721  const int like_where_syntax = 0; /* neither LIKE nor WHERE */
6722  PT_NODE *node = NULL;
6723  PT_NODE *original_cls_id = $5;
6724 
6725  node = pt_make_query_show_columns (this_parser, original_cls_id,
6726  like_where_syntax, NULL, is_full_syntax);
6727 
6728  $$ = node;
6729  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6730 
6731  DBG_PRINT}}
6732  | SHOW
6733  opt_full
6734  COLUMNS
6735  of_from_in
6736  identifier
6737  LIKE
6738  expression_
6739  {{
6740 
6741  const bool is_full_syntax = ($2 == 1);
6742  const int like_where_syntax = 1; /* is LIKE */
6743  PT_NODE *node = NULL;
6744  PT_NODE *original_cls_id = $5;
6745  PT_NODE *like_rhs = $7;
6746 
6747  node = pt_make_query_show_columns (this_parser, original_cls_id,
6748  like_where_syntax, like_rhs, is_full_syntax);
6749 
6750  $$ = node;
6751  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6752 
6753  DBG_PRINT}}
6754  | SHOW
6755  opt_full
6756  COLUMNS
6757  of_from_in
6758  identifier
6759  WHERE
6760  search_condition
6761  {{
6762 
6763  const bool is_full_syntax = ($2 == 1);
6764  const int like_where_syntax = 2; /* is WHERE */
6765  PT_NODE *node = NULL;
6766  PT_NODE *original_cls_id = $5;
6767  PT_NODE *where_cond = $7;
6768 
6769  node = pt_make_query_show_columns (this_parser, original_cls_id,
6770  like_where_syntax, where_cond, is_full_syntax);
6771 
6772  $$ = node;
6773  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6774 
6775  DBG_PRINT}}
6776  | of_describe_desc_explain
6777  identifier
6778  {{
6779 
6780  PT_NODE *node = NULL;
6781  PT_NODE *original_cls_id = $2;
6782 
6783  node = pt_make_query_show_columns (this_parser, original_cls_id,
6784  0, NULL, 0);
6785 
6786  $$ = node;
6787  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6788 
6789  DBG_PRINT}}
6790  | of_describe_desc_explain
6791  identifier
6792  identifier
6793  {{
6794 
6795  PT_NODE *node = NULL;
6796  PT_NODE *original_cls_id = $2;
6797  PT_NODE *attr = $3;
6798 
6799  node = pt_make_query_describe_w_identifier (this_parser, original_cls_id, attr);
6800 
6801  $$ = node;
6802  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6803 
6804  DBG_PRINT}}
6805  | of_describe_desc_explain
6806  identifier
6807  char_string_literal
6808  {{
6809 
6810  int like_where_syntax = 0;
6811  PT_NODE *node = NULL;
6812  PT_NODE *original_cls_id = $2;
6813  PT_NODE *like_rhs = $3;
6814 
6815  if (like_rhs != NULL)
6816  {
6817  like_where_syntax = 1; /* is LIKE */
6818  }
6819  node = pt_make_query_show_columns (this_parser, original_cls_id,
6820  like_where_syntax, like_rhs, 0);
6821 
6822  $$ = node;
6823  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6824 
6825  DBG_PRINT}}
6826  | SHOW
6827  COLLATION
6828  {{
6829 
6830  PT_NODE *node = NULL;
6831 
6832  node = pt_make_query_show_collation (this_parser, 0, NULL);
6833 
6834  $$ = node;
6835  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6836 
6837  DBG_PRINT}}
6838  | SHOW
6839  COLLATION
6840  LIKE
6841  expression_
6842  {{
6843 
6844  const int like_where_syntax = 1; /* is LIKE */
6845  PT_NODE *node = NULL;
6846  PT_NODE *like_rhs = $4;
6847 
6848  node = pt_make_query_show_collation (this_parser,
6849  like_where_syntax,
6850  like_rhs);
6851 
6852  $$ = node;
6853  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6854 
6855  DBG_PRINT}}
6856  | SHOW
6857  COLLATION
6858  WHERE
6859  search_condition
6860  {{
6861  const int like_where_syntax = 2; /* is WHERE */
6862  PT_NODE *node = NULL;
6863  PT_NODE *where_cond = $4;
6864 
6865  node = pt_make_query_show_collation (this_parser,
6866  like_where_syntax,
6867  where_cond);
6868 
6869  $$ = node;
6870  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6871 
6872  DBG_PRINT}}
6873  | SHOW
6874  CREATE
6875  TABLE
6876  identifier
6877  {{
6878 
6879  PT_NODE *node = NULL;
6880  node = pt_make_query_show_create_table (this_parser, $4);
6881 
6882  $$ = node;
6883  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6884 
6885  DBG_PRINT}}
6886  | SHOW
6887  CREATE
6888  VIEW
6889  identifier
6890  {{
6891 
6892  PT_NODE *node = NULL;
6893  PT_NODE *view_id = $4;
6894 
6895  node = pt_make_query_show_create_view (this_parser, view_id);
6896 
6897  $$ = node;
6898  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6899 
6900  DBG_PRINT}}
6901  | SHOW
6902  GRANTS
6903  For
6904  identifier
6905  {{
6906 
6907  PT_NODE *node = NULL;
6908  PT_NODE *user_id = $4;
6909 
6910  assert (user_id != NULL);
6911  assert (user_id->node_type == PT_NAME);
6912 
6913  node = pt_make_query_show_grants (this_parser, user_id->info.name.original);
6914 
6915  $$ = node;
6916  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6917 
6918  DBG_PRINT}}
6919  | SHOW
6920  GRANTS
6921  opt_for_current_user
6922  {{
6923 
6924  PT_NODE *node = NULL;
6925 
6926  node = pt_make_query_show_grants_curr_usr (this_parser);
6927 
6928  $$ = node;
6929  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6930 
6931  DBG_PRINT}}
6932  | SHOW
6933  of_index_indexes_keys
6934  of_from_in
6935  identifier
6936  {{
6937 
6938  PT_NODE *node = NULL;
6939  PT_NODE *table_id = $4;
6940 
6941  node = pt_make_query_show_index (this_parser, table_id);
6942 
6943  $$ = node;
6944  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6945  DBG_PRINT}}
6946  | SHOW EXEC STATISTICS ALL
6947  {{
6948  PT_NODE *node = NULL;
6949 
6950  node = pt_make_query_show_exec_stats_all (this_parser);
6951 
6952  $$ = node;
6953  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6954 
6955  DBG_PRINT}}
6956  | SHOW EXEC STATISTICS
6957  {{
6958  PT_NODE *node = NULL;
6959 
6960  node = pt_make_query_show_exec_stats (this_parser);
6961 
6962  $$ = node;
6963  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6964 
6965  DBG_PRINT}}
6966  | SHOW TRACE
6967  {{
6968  PT_NODE *node = NULL;
6969 
6970  node = pt_make_query_show_trace (this_parser);
6971 
6972  $$ = node;
6973 
6974  DBG_PRINT}}
6975  | SHOW show_type
6976  {{
6977  int type = $2;
6978  PT_NODE *node = pt_make_query_showstmt (this_parser, type, NULL, 0, NULL);
6979 
6980  $$ = node;
6981  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6982 
6983  DBG_PRINT}}
6984  | SHOW show_type_of_like LIKE expression_
6985  {{
6986 
6987  const int like_where_syntax = 1; /* is LIKE */
6988  int type = $2;
6989  PT_NODE *like_rhs = $4;
6990  PT_NODE *node = pt_make_query_showstmt (this_parser, type, NULL,
6991  like_where_syntax, like_rhs);
6992 
6993  $$ = node;
6994  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
6995 
6996  DBG_PRINT}}
6997  | SHOW show_type_of_where WHERE search_condition
6998  {{
6999  const int like_where_syntax = 2; /* is WHERE */
7000  int type = $2;
7001  PT_NODE *where_cond = $4;
7002  PT_NODE *node = pt_make_query_showstmt (this_parser, type, NULL,
7003  like_where_syntax, where_cond);
7004 
7005  $$ = node;
7006  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
7007 
7008  DBG_PRINT}}
7009  | SHOW show_type_arg1 OF arg_value
7010  {{
7011  int type = $2;
7012  PT_NODE *args = $4;
7013  PT_NODE *node = pt_make_query_showstmt (this_parser, type, args, 0, NULL);
7014 
7015  $$ = node;
7016  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
7017 
7018  DBG_PRINT}}
7019  | SHOW show_type_arg1_opt opt_arg_value
7020  {{
7021  PT_NODE *node = NULL;
7022  int type = $2;
7023  PT_NODE *args = $3;
7024 
7025  node = pt_make_query_showstmt (this_parser, type, args, 0, NULL);
7026 
7027  $$ = node;
7028  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
7029 
7030  DBG_PRINT}}
7031  | SHOW show_type_arg_named of_or_where named_args
7032  {{
7033  PT_NODE *node = NULL;
7034  int type = $2;
7035  PT_NODE *args = $4;
7036 
7037  node = pt_make_query_showstmt (this_parser, type, args, 0, NULL);
7038 
7039  $$ = node;
7040  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
7041 
7042  DBG_PRINT}}
7043  | SHOW show_type_id_dot_id OF identifier DOT identifier
7044  {{
7045  int type = $2;
7046  PT_NODE *node, *args = $4;
7047 
7048  args->next = $6;
7049  node = pt_make_query_showstmt (this_parser, type, args, 0, NULL);
7050 
7051  $$ = node;
7052  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
7053 
7054  DBG_PRINT}}
7055  ;
7056 
7057 kill_stmt
7058  : KILL arg_value_list
7059  {{
7060  PT_NODE *node = parser_new_node (this_parser, PT_KILL_STMT);
7061 
7062  if (node)
7063  {
7064  node->info.killstmt.tran_id_list = $2;
7065  }
7066 
7067  $$ = node;
7068  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
7069 
7070  DBG_PRINT}}
7071  | KILL kill_type arg_value_list
7072  {{
7073  int type = $2;
7074  PT_NODE *node = parser_new_node (this_parser, PT_KILL_STMT);
7075 
7076  if (node)
7077  {
7078  node->info.killstmt.tran_id_list = $3;
7079  node->info.killstmt.kill_type = type;
7080  }
7081 
7082  $$ = node;
7083  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
7084 
7085  DBG_PRINT}}
7086  ;
7087 
7088 show_type
7089  : ACCESS STATUS
7090  {{
7091  $$ = SHOWSTMT_ACCESS_STATUS;
7092  }}
7093  | CRITICAL SECTIONS
7094  {{
7095  $$ = SHOWSTMT_GLOBAL_CRITICAL_SECTIONS;
7096  }}
7097  | JOB QUEUES
7098  {{
7099  $$ = SHOWSTMT_JOB_QUEUES;
7100  }}
7101  | PAGE BUFFER STATUS
7102  {{
7103  $$ = SHOWSTMT_PAGE_BUFFER_STATUS;
7104  }}
7105  | TIMEZONES
7106  {{
7107  $$ = SHOWSTMT_TIMEZONES;
7108  }}
7109  | FULL TIMEZONES
7110  {{
7111  $$ = SHOWSTMT_FULL_TIMEZONES;
7112  }}
7113  | TRANSACTION TABLES
7114  {{
7115  $$ = SHOWSTMT_TRAN_TABLES;
7116  }}
7117  | TRAN TABLES
7118  {{
7119  $$ = SHOWSTMT_TRAN_TABLES;
7120  }}
7121  | THREADS
7122  {{
7123  $$ = SHOWSTMT_THREADS;
7124  }}
7125  ;
7126 
7127 show_type_of_like
7128  : ACCESS STATUS
7129  {{
7130  $$ = SHOWSTMT_ACCESS_STATUS;
7131  }}
7132  | TIMEZONES
7133  {{
7134  $$ = SHOWSTMT_TIMEZONES;
7135  }}
7136  | FULL TIMEZONES
7137  {{
7138  $$ = SHOWSTMT_FULL_TIMEZONES;
7139  }}
7140  ;
7141 
7142 show_type_of_where
7143  : ACCESS STATUS
7144  {{
7145  $$ = SHOWSTMT_ACCESS_STATUS;
7146  }}
7147  | TIMEZONES
7148  {{
7149  $$ = SHOWSTMT_TIMEZONES;
7150  }}
7151  | FULL TIMEZONES
7152  {{
7153  $$ = SHOWSTMT_FULL_TIMEZONES;
7154  }}
7155  | TRANSACTION TABLES
7156  {{
7157  $$ = SHOWSTMT_TRAN_TABLES;
7158  }}
7159  | TRAN TABLES
7160  {{
7161  $$ = SHOWSTMT_TRAN_TABLES;
7162  }}
7163  | THREADS
7164  {{
7165  $$ = SHOWSTMT_THREADS;
7166  }}
7167  ;
7168 
7169 show_type_arg1
7170  : VOLUME HEADER
7171  {{
7172  $$ = SHOWSTMT_VOLUME_HEADER;
7173  }}
7174  | ARCHIVE LOG HEADER
7175  {{
7176  $$ = SHOWSTMT_ARCHIVE_LOG_HEADER;
7177  }}
7178  | HEAP HEADER
7179  {{
7180  $$ = SHOWSTMT_HEAP_HEADER;
7181  }}
7182  | ALL HEAP HEADER
7183  {{
7184  $$ = SHOWSTMT_ALL_HEAP_HEADER;
7185  }}
7186  | HEAP CAPACITY
7187  {{
7188  $$ = SHOWSTMT_HEAP_CAPACITY;
7189  }}
7190  | ALL HEAP CAPACITY
7191  {{
7192  $$ = SHOWSTMT_ALL_HEAP_CAPACITY;
7193  }}
7194  | ALL INDEXES HEADER
7195  {{
7196  $$ = SHOWSTMT_ALL_INDEXES_HEADER;
7197  }}
7198  | ALL INDEXES CAPACITY
7199  {{
7200  $$ = SHOWSTMT_ALL_INDEXES_CAPACITY;
7201  }}
7202  ;
7203 
7204 show_type_arg1_opt
7205  : LOG HEADER
7206  {{
7207  $$ = SHOWSTMT_ACTIVE_LOG_HEADER;
7208  }}
7209  ;
7210 
7211 show_type_arg_named
7212  : SLOTTED PAGE HEADER
7213  {{
7214  $$ = SHOWSTMT_SLOTTED_PAGE_HEADER;
7215  }}
7216  | SLOTTED PAGE SLOTS
7217  {{
7218  $$ = SHOWSTMT_SLOTTED_PAGE_SLOTS;
7219  }}
7220  ;
7221 
7222 show_type_id_dot_id
7223  : INDEX HEADER
7224  {{
7225  $$ = SHOWSTMT_INDEX_HEADER;
7226  }}
7227  | INDEX CAPACITY
7228  {{
7229  $$ = SHOWSTMT_INDEX_CAPACITY;
7230  }}
7231  ;
7232 
7233 kill_type
7234  : QUERY
7235  {{
7236  $$ = KILLSTMT_QUERY;
7237  }}
7238  | TRANSACTION
7239  {{
7240  $$ = KILLSTMT_TRAN;
7241  }}
7242  ;
7243 
7244 of_or_where
7245  : OF
7246  {{
7247  $$ = NULL;
7248  }}
7249  | WHERE
7250  {{
7251  $$ = NULL;
7252  }}
7253  ;
7254 
7255 named_args
7256  : named_arg
7257  {{
7258  $$ = $1;
7259  DBG_PRINT}}
7260  | named_args AND named_arg
7261  {{
7262  $$ = parser_make_link ($1, $3);
7263  DBG_PRINT}}
7264  ;
7265 
7266 named_arg
7267  : identifier '=' arg_value
7268  {{
7269  PT_NODE * node = parser_new_node (this_parser, PT_NAMED_ARG);
7270  node->info.named_arg.name = $1;
7271  node->info.named_arg.value = $3;
7272  $$ = node;
7273  DBG_PRINT}}
7274  ;
7275 
7276 opt_arg_value
7277  :
7278  {{
7279  PT_NODE *node = parser_new_node (this_parser, PT_VALUE);
7280  if (node)
7281  node->type_enum = PT_TYPE_NULL;
7282 
7283  $$ = node;
7284  }}
7285  | OF arg_value
7286  {{
7287  $$ = $2;
7288  }}
7289  ;
7290 
7291 arg_value_list
7292  : arg_value_list ',' arg_value
7293  {{
7294 
7295  $$ = parser_make_link ($1, $3);
7296  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
7297 
7298  DBG_PRINT}}
7299  | arg_value
7300  {{
7301 
7302  $$ = $1;
7303  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
7304 
7305  DBG_PRINT}}
7306  ;
7307 
7308 arg_value
7309  : char_string_literal
7310  {{
7311  $$ = $1;
7312  DBG_PRINT}}
7313  | unsigned_integer
7314  {{
7315  $$ = $1;
7316  DBG_PRINT}}
7317  | identifier
7318  {{
7319  $$ = $1;
7320  DBG_PRINT}}
7321  ;
7322 
7323 opt_full
7324  : /* empty */
7325  {{
7326 
7327  $$ = 0;
7328 
7329  DBG_PRINT}}
7330  | FULL
7331  {{
7332 
7333  $$ = 1;
7334 
7335  DBG_PRINT}}
7336  ;
7337 
7338 of_from_in
7339  : FROM
7340  | IN_
7341  ;
7342 
7343 opt_for_current_user
7344  : /* empty */
7345  | For CURRENT_USER
7346  | For CURRENT_USER '(' ')'
7347  ;
7348 
7349 of_describe_desc_explain
7350  : DESCRIBE
7351  | DESC
7352  | EXPLAIN
7353  ;
7354 
7355 of_index_indexes_keys
7356  : INDEX
7357  | INDEXES
7358  | KEYS
7359  ;
7360 
7361 update_head
7362  : UPDATE
7363  {
7364  PT_NODE* node = parser_new_node(this_parser, PT_UPDATE);
7365  parser_push_hint_node(node);
7366  }
7367  opt_hint_list
7368  ;
7369 
7370 update_stmt
7371  : update_head
7372  {
7373  PT_NODE * node = parser_pop_hint_node();
7374  parser_push_orderby_node (node);
7375  parser_push_hint_node (node);
7376  }
7377  extended_table_spec_list
7378  SET
7379  update_assignment_list
7380  opt_of_where_cursor
7381  opt_using_index_clause
7382  opt_update_orderby_clause
7383  opt_upd_del_limit_clause
7384  {{
7385 
7386  PT_NODE *node = parser_pop_hint_node ();
7387 
7388  node->info.update.spec = CONTAINER_AT_0 ($3);
7389  node->info.update.assignment = $5;
7390 
7391  if (CONTAINER_AT_0 ($6))
7392  {
7393  node->info.update.search_cond = CONTAINER_AT_1 ($6);
7394  }
7395  else
7396  {
7397  node->info.update.cursor_name = CONTAINER_AT_1 ($6);
7398  }
7399 
7400  node->info.update.using_index =
7401  (node->info.update.using_index ?
7402  parser_make_link (node->info.update.using_index, $7) : $7);
7403 
7404  /* set LIMIT node */
7405  node->info.update.limit = $9;
7406  node->info.update.rewrite_limit = 1;
7407 
7408  if (node->info.update.spec->next)
7409  {
7410  /* Multi-table update */
7411 
7412  /* Multi-table update cannot have ORDER BY or LIMIT */
7413  if (node->info.update.order_by)
7414  {
7415  PT_ERRORmf(this_parser, node->info.update.order_by,
7416  MSGCAT_SET_PARSER_SEMANTIC,
7417  MSGCAT_SEMANTIC_NOT_ALLOWED_HERE, "ORDER BY");
7418  }
7419  else if (node->info.update.limit)
7420  {
7421  PT_ERRORmf(this_parser, node->info.update.limit,
7422  MSGCAT_SET_PARSER_SEMANTIC,
7423  MSGCAT_SEMANTIC_NOT_ALLOWED_HERE, "LIMIT");
7424  }
7425  }
7426  else
7427  {
7428  /* Single-table update */
7429 
7430  if (node->info.update.limit
7431  && node->info.update.search_cond)
7432  {
7433  /* For UPDATE statements that have LIMIT clause don't allow
7434  * inst_num in search condition
7435  */
7436  bool instnum_flag = false;
7437  (void) parser_walk_tree (this_parser, node->info.update.search_cond,
7438  pt_check_instnum_pre, NULL,
7439  pt_check_instnum_post, &instnum_flag);
7440  if (instnum_flag)
7441  {
7442  PT_ERRORmf(this_parser, node->info.update.search_cond,
7443  MSGCAT_SET_PARSER_SEMANTIC,
7444  MSGCAT_SEMANTIC_NOT_ALLOWED_IN_LIMIT_CLAUSE, "INST_NUM()/ROWNUM");
7445  }
7446  }
7447  else if (node->info.update.limit
7448  && node->info.update.cursor_name)
7449  {
7450  /* It makes no sense to allow LIMIT for UPDATE statements
7451  * that use cursor
7452  */
7453  PT_ERRORmf(this_parser, node->info.update.search_cond,
7454  MSGCAT_SET_PARSER_SEMANTIC,
7455  MSGCAT_SEMANTIC_NOT_ALLOWED_HERE, "LIMIT");
7456  }
7457  else if (node->info.update.limit
7458  && node->info.update.orderby_for)
7459  {
7460  bool ordbynum_flag = false;
7461  /* check for a ORDERBY_NUM it the orderby_for tree */
7462  (void) parser_walk_tree (this_parser, node->info.update.orderby_for,
7463  pt_check_orderbynum_pre, NULL,
7464  pt_check_orderbynum_post, &ordbynum_flag);
7465 
7466  if (ordbynum_flag)
7467  {
7468  PT_ERRORmf(this_parser, node->info.update.orderby_for,
7469  MSGCAT_SET_PARSER_SEMANTIC,
7470  MSGCAT_SEMANTIC_NOT_ALLOWED_IN_LIMIT_CLAUSE, "ORDERBY_NUM()");
7471  }
7472  }
7473  }
7474 
7475  $$ = node;
7476  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
7477 
7478  DBG_PRINT}}
7479  | update_head
7480  OBJECT
7481  from_param
7482  SET
7483  update_assignment_list
7484  {{
7485 
7486  PT_NODE *node = parser_pop_hint_node ();
7487  if (node)
7488  {
7489  node->info.update.object_parameter = $3;
7490  node->info.update.assignment = $5;
7491  }
7492 
7493  $$ = node;
7494  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
7495 
7496  DBG_PRINT}}
7497  ;
7498 
7499 
7500 opt_of_where_cursor
7501  : /* empty */
7502  {{
7503 
7504  container_2 ctn;
7505  SET_CONTAINER_2 (ctn, 0, NULL);
7506  $$ = ctn;
7507 
7508  DBG_PRINT}}
7509  | WHERE
7510  {
7511  parser_save_and_set_ic(1);
7512  DBG_PRINT
7513  }
7514  search_condition
7515  {
7516  parser_restore_ic();
7517  DBG_PRINT
7518  }
7519  {{
7520 
7521  container_2 ctn;
7522  SET_CONTAINER_2 (ctn, FROM_NUMBER (1), $3);
7523  $$ = ctn;
7524 
7525  DBG_PRINT}}
7526  | WHERE CURRENT OF identifier
7527  {{
7528 
7529  container_2 ctn;
7530  SET_CONTAINER_2 (ctn, FROM_NUMBER (0), $4);
7531  $$ = ctn;
7532 
7533  DBG_PRINT}}
7534  ;
7535 
7536 
7537 of_class_spec_meta_class_spec
7538  : class_spec
7539  {{
7540 
7541  $$ = $1;
7542  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
7543 
7544  DBG_PRINT}}
7545  | meta_class_spec
7546  {{
7547 
7548  $$ = $1;
7549  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
7550 
7551  DBG_PRINT}}
7552  ;
7553 
7554 opt_as_identifier
7555  : /* empty */
7556  {{
7557 
7558  $$ = NULL;
7559 
7560  DBG_PRINT}}
7561  | AS identifier
7562  {{
7563 
7564  $$ = $2;
7565  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
7566 
7567  DBG_PRINT}}
7568  | identifier
7569  {{
7570 
7571  $$ = $1;
7572  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
7573 
7574  DBG_PRINT}}
7575  ;
7576 
7577 update_assignment_list
7578  : update_assignment_list ',' update_assignment
7579  {{
7580 
7581  $$ = parser_make_link ($1, $3);
7582  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
7583 
7584  DBG_PRINT}}
7585  | update_assignment
7586  {{
7587 
7588  $$ = $1;
7589 
7590  DBG_PRINT}}
7591  ;
7592 
7593 update_assignment
7594  : path_expression '=' expression_
7595  {{
7596 
7597  $$ = parser_make_expression (this_parser, PT_ASSIGN, $1, $3, NULL);
7598  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
7599 
7600  DBG_PRINT}}
7601  | simple_path_id '=' DEFAULT
7602  {{
7603 
7604  PT_NODE *node, *node_df = NULL;
7605  node = parser_copy_tree (this_parser, $1);
7606  if (node)
7607  {
7608  pt_set_fill_default_in_path_expression (node);
7609  node_df = parser_make_expression (this_parser, PT_DEFAULTF, node, NULL, NULL);
7610  }
7611  $$ = parser_make_expression (this_parser, PT_ASSIGN, $1, node_df, NULL);
7612  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
7613 
7614  DBG_PRINT}}
7615  | paren_path_expression_set '=' primary_w_collate
7616  {{
7617 
7618  PT_NODE *exp = parser_make_expression (this_parser, PT_ASSIGN, $1, NULL, NULL);
7619  PT_NODE *arg1, *arg2, *list, *tmp;
7620  PT_NODE *e1, *e2 = NULL, *e1_next, *e2_next;
7621  bool is_subquery = false;
7622  arg1 = $1;
7623  arg2 = $3;
7624 
7625  /* primary is parentheses expr set value */
7626  if (arg2->node_type == PT_VALUE &&
7627  (arg2->type_enum == PT_TYPE_NULL || arg2->type_enum == PT_TYPE_EXPR_SET))
7628  {
7629 
7630  /* flatten multi-column assignment expr */
7631  if (arg1->node_type == PT_EXPR)
7632  {
7633  /* get elements and free set node */
7634  e1 = arg1->info.expr.arg1;
7635  arg1->info.expr.arg1 = NULL; /* cut-off link */
7636  parser_free_node (this_parser, exp); /* free exp, arg1 */
7637 
7638  if (arg2->type_enum == PT_TYPE_NULL)
7639  {
7640  ; /* nop */
7641  }
7642  else
7643  {
7644  e2 = arg2->info.value.data_value.set;
7645  arg2->info.value.data_value.set = NULL; /* cut-off link */
7646  }
7647  parser_free_node (this_parser, arg2);
7648 
7649  list = NULL; /* init */
7650  for (; e1; e1 = e1_next)
7651  {
7652  e1_next = e1->next;
7653  e1->next = NULL;
7654  if (arg2->type_enum == PT_TYPE_NULL)
7655  {
7656  if ((e2 = parser_new_node (this_parser, PT_VALUE)) == NULL)
7657  break; /* error */
7658  e2->type_enum = PT_TYPE_NULL;
7659  e2->flag.is_added_by_parser = 1;
7660  }
7661  else
7662  {
7663  if (e2 == NULL)
7664  break; /* error */
7665  }
7666  e2_next = e2->next;
7667  e2->next = NULL;
7668 
7669  tmp = parser_new_node (this_parser, PT_EXPR);
7670  if (tmp)
7671  {
7672  tmp->info.expr.op = PT_ASSIGN;
7673  tmp->info.expr.arg1 = e1;
7674  tmp->info.expr.arg2 = e2;
7675  }
7676  list = parser_make_link (tmp, list);
7677 
7678  e2 = e2_next;
7679  }
7680 
7681  PARSER_SAVE_ERR_CONTEXT (list, @$.buffer_pos)
7682  /* expression number check */
7683  if (e1 || e2)
7684  {
7685  PT_ERRORf (this_parser, list,
7686  "check syntax at %s, different number of elements in each expression.",
7687  pt_show_binopcode (PT_ASSIGN));
7688  }
7689 
7690  $$ = list;
7691  }
7692  else
7693  {
7694  /* something wrong */
7695  exp->info.expr.arg2 = arg2;
7696  $$ = exp;
7697  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
7698  }
7699  }
7700  else
7701  {
7702  if (pt_is_query (arg2))
7703  {
7704  /* primary is subquery. go ahead */
7705  is_subquery = true;
7706  }
7707 
7708  exp->info.expr.arg1 = arg1;
7709  exp->info.expr.arg2 = arg2;
7710 
7711  $$ = exp;
7712  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
7713  PICE (exp);
7714 
7715  /* unknown error check */
7716  if (is_subquery == false)
7717  {
7718  PT_ERRORf (this_parser, exp, "check syntax at %s",
7719  pt_show_binopcode (PT_ASSIGN));
7720  }
7721  }
7722 
7723  DBG_PRINT}}
7724  ;
7725 
7726 paren_path_expression_set
7727  : '(' path_expression_list ')'
7728  {{
7729 
7730  PT_NODE *p = parser_new_node (this_parser, PT_EXPR);
7731 
7732  if (p)
7733  {
7734  p->info.expr.op = PT_PATH_EXPR_SET;
7735  p->info.expr.paren_type = 1;
7736  p->info.expr.arg1 = $2;
7737  }
7738 
7739  $$ = p;
7740  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
7741 
7742  DBG_PRINT}}
7743  ;
7744 
7745 path_expression_list
7746  : path_expression_list ',' path_expression
7747  {{
7748 
7749  $$ = parser_make_link ($1, $3);
7750  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
7751 
7752  DBG_PRINT}}
7753  | path_expression
7754  {{
7755 
7756  $$ = $1;
7757  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
7758  DBG_PRINT}}
7759  ;
7760 
7761 delete_name
7762  : identifier
7763  {{
7764 
7765  PT_NODE *node = $1;
7766  node->info.name.meta_class = PT_CLASS;
7767 
7768  $$ = node;
7769 
7770  DBG_PRINT}}
7771  | identifier DOT '*'
7772  {{
7773 
7774  PT_NODE *node = $1;
7775  node->info.name.meta_class = PT_CLASS;
7776 
7777  $$ = node;
7778 
7779  DBG_PRINT}}
7780  ;
7781 
7782 delete_name_list
7783  : delete_name_list ',' delete_name
7784  {{
7785 
7786  $$ = parser_make_link ($1, $3);
7787 
7788  DBG_PRINT}}
7789  | delete_name
7790  {{
7791 
7792  $$ = $1;
7793 
7794  DBG_PRINT}}
7795  ;
7796 
7797 delete_from_using
7798  : delete_name_list FROM extended_table_spec_list
7799  {{
7800 
7801  container_3 ctn;
7802  SET_CONTAINER_3(ctn, $1, CONTAINER_AT_0 ($3), CONTAINER_AT_1 ($3));
7803 
7804  $$ = ctn;
7805 
7806  DBG_PRINT}}
7807  | FROM delete_name_list USING extended_table_spec_list
7808  {{
7809 
7810  container_3 ctn;
7811  SET_CONTAINER_3(ctn, $2, CONTAINER_AT_0 ($4), CONTAINER_AT_1 ($4));
7812 
7813  $$ = ctn;
7814 
7815  DBG_PRINT}}
7816  | FROM table_spec
7817  {{
7818 
7819  container_3 ctn;
7820  SET_CONTAINER_3(ctn, NULL, $2, FROM_NUMBER(0));
7821 
7822  $$ = ctn;
7823 
7824  DBG_PRINT}}
7825  | table_spec
7826  {{
7827 
7828  container_3 ctn;
7829  SET_CONTAINER_3(ctn, NULL, $1, FROM_NUMBER(0));
7830 
7831  $$ = ctn;
7832 
7833  DBG_PRINT}}
7834  ;
7835 
7836 delete_stmt
7837  : DELETE_ /* $1 */
7838  { /* $2 */
7839  PT_NODE* node = parser_new_node(this_parser, PT_DELETE);
7840  parser_push_hint_node(node);
7841  }
7842  opt_hint_list /* $3 */
7843  delete_from_using /* $4 */
7844  opt_of_where_cursor /* $5 */
7845  opt_using_index_clause /* $6 */
7846  opt_upd_del_limit_clause /* $7 */
7847  {{
7848 
7849  PT_NODE *del = parser_pop_hint_node ();
7850 
7851  if (del)
7852  {
7853  PT_NODE *node = NULL;
7854  del->info.delete_.target_classes = CONTAINER_AT_0 ($4);
7855  del->info.delete_.spec = CONTAINER_AT_1 ($4);
7856 
7857  pt_check_unique_names (this_parser,
7858  del->info.delete_.spec);
7859 
7860  if (TO_NUMBER (CONTAINER_AT_0 ($5)))
7861  {
7862  del->info.delete_.search_cond = CONTAINER_AT_1 ($5);
7863  }
7864  else
7865  {
7866  del->info.delete_.cursor_name = CONTAINER_AT_1 ($5);
7867  }
7868 
7869  del->info.delete_.using_index =
7870  (del->info.delete_.using_index ?
7871  parser_make_link (del->info.delete_.using_index, $6) : $6);
7872 
7873  del->info.delete_.limit = $7;
7874  del->info.delete_.rewrite_limit = 1;
7875 
7876  /* In a multi-table case the LIMIT clauses is not allowed. */
7877  if (del->info.delete_.spec->next)
7878  {
7879  if (del->info.delete_.limit)
7880  {
7881  PT_ERRORmf(this_parser, del->info.delete_.limit,
7882  MSGCAT_SET_PARSER_SEMANTIC,
7883  MSGCAT_SEMANTIC_NOT_ALLOWED_HERE, "LIMIT");
7884  }
7885  }
7886  else
7887  {
7888  /* if the delete is single-table no need to specify
7889  * the delete table. In this case add the name of supplied
7890  * spec to the target_classes list. */
7891  if (!del->info.delete_.target_classes)
7892  {
7893  if (del->info.delete_.spec->info.spec.range_var)
7894  {
7895  del->info.delete_.target_classes =
7896  parser_copy_tree(this_parser, del->info.delete_.spec->info.spec.range_var);
7897  }
7898  else
7899  {
7900  del->info.delete_.target_classes =
7901  parser_copy_tree(this_parser, del->info.delete_.spec->info.spec.entity_name);
7902  }
7903  }
7904 
7905  /* set LIMIT node */
7906  if (del->info.delete_.limit && del->info.delete_.search_cond)
7907  {
7908  /* For DELETE statements that have LIMIT clause don't
7909  * allow inst_num in search condition */
7910  bool instnum_flag = false;
7911  (void) parser_walk_tree (this_parser, del->info.delete_.search_cond,
7912  pt_check_instnum_pre, NULL,
7913  pt_check_instnum_post, &instnum_flag);
7914  if (instnum_flag)
7915  {
7916  PT_ERRORmf(this_parser, del->info.delete_.search_cond,
7917  MSGCAT_SET_PARSER_SEMANTIC,
7918  MSGCAT_SEMANTIC_NOT_ALLOWED_IN_LIMIT_CLAUSE, "INST_NUM()/ROWNUM");
7919  }
7920  }
7921  else if (del->info.delete_.limit && del->info.delete_.cursor_name)
7922  {
7923  /* It makes no sense to allow LIMIT for DELETE statements
7924  * that use (Oracle style) cursor */
7925  PT_ERRORmf(this_parser, del->info.delete_.search_cond,
7926  MSGCAT_SET_PARSER_SEMANTIC,
7927  MSGCAT_SEMANTIC_NOT_ALLOWED_HERE, "LIMIT");
7928  }
7929  }
7930 
7931  node = del->info.delete_.target_classes;
7932  while (node)
7933  {
7934  PT_NAME_INFO_SET_FLAG(node, PT_NAME_ALLOW_REUSABLE_OID);
7935  node = node->next;
7936  }
7937  }
7938  $$ = del;
7939  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
7940 
7941  DBG_PRINT}}
7942  ;
7943 
7944 merge_stmt
7945  : MERGE /* $1 */
7946  { /* $2 */
7947  PT_NODE *merge = parser_new_node (this_parser, PT_MERGE);
7948  parser_push_hint_node (merge);
7949  }
7950  opt_hint_list /* $3 */
7951  INTO /* $4 */
7952  table_spec /* $5 */
7953  USING /* $6 */
7954  table_spec /* $7 */
7955  ON_ /* $8 */
7956  search_condition /* $9 */
7957  merge_update_insert_clause /* $10 */
7958  {{
7959 
7960  PT_NODE *merge = parser_pop_hint_node ();
7961  if (merge)
7962  {
7963  merge->info.merge.into = $5;
7964  merge->info.merge.using_clause = $7;
7965  merge->info.merge.search_cond = $9;
7966  }
7967 
7968  $$ = merge;
7969  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
7970 
7971  DBG_PRINT}}
7972  ;
7973 
7974 merge_update_insert_clause
7975  : merge_update_clause
7976  {{
7977  DBG_PRINT}}
7978  | merge_insert_clause
7979  {{
7980  DBG_PRINT}}
7981  | merge_update_clause
7982  merge_insert_clause
7983  {{
7984  DBG_PRINT}}
7985  | merge_insert_clause
7986  merge_update_clause
7987  {{
7988  DBG_PRINT}}
7989  ;
7990 
7991 merge_update_clause
7992  : WHEN MATCHED THEN UPDATE SET
7993  update_assignment_list /* $6 */
7994  opt_where_clause /* $7 */
7995  opt_merge_delete_clause /* $8 */
7996  {{
7997 
7998  PT_NODE *merge = parser_top_hint_node ();
7999  if (merge)
8000  {
8001  merge->info.merge.update.assignment = $6;
8002  merge->info.merge.update.search_cond = $7;
8003  merge->info.merge.update.del_search_cond = $8;
8004  if ($8)
8005  {
8006  merge->info.merge.update.has_delete = true;
8007  }
8008  }
8009 
8010  DBG_PRINT}}
8011  ;
8012 
8013 merge_insert_clause
8014  : WHEN NOT MATCHED THEN INSERT
8015  opt_path_attr_list /* $6 */
8016  insert_expression_value_clause /* $7 */
8017  opt_where_clause /* $8 */
8018  {{
8019 
8020  PT_NODE *merge = parser_top_hint_node ();
8021  if (merge)
8022  {
8023  merge->info.merge.insert.attr_list = $6;
8024  merge->info.merge.insert.value_clauses = $7;
8025  merge->info.merge.insert.search_cond = $8;
8026  }
8027 
8028  DBG_PRINT}}
8029  ;
8030 
8031 opt_merge_delete_clause
8032  : /* empty */
8033  {{
8034 
8035  $$ = NULL;
8036 
8037  DBG_PRINT}}
8038  | DELETE_ WHERE search_condition
8039  {{
8040 
8041  $$ = $3;
8042  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8043 
8044  DBG_PRINT}}
8045  ;
8046 
8047 auth_stmt
8048  : grant_head opt_with_grant_option
8049  {{
8050 
8051  PT_NODE *node = $1;
8052  PT_MISC_TYPE w = PT_NO_GRANT_OPTION;
8053  if ($2)
8054  w = PT_GRANT_OPTION;
8055 
8056  if (node)
8057  {
8058  node->info.grant.grant_option = w;
8059  }
8060 
8061  $$ = node;
8062  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8063 
8064  DBG_PRINT}}
8065  | revoke_cmd on_class_list from_id_list
8066  {{
8067 
8068  PT_NODE *node = parser_new_node (this_parser, PT_REVOKE);
8069 
8070  if (node)
8071  {
8072  node->info.revoke.user_list = $3;
8073  node->info.revoke.spec_list = $2;
8074  node->info.revoke.auth_cmd_list = $1;
8075  }
8076 
8077  $$ = node;
8078  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8079 
8080  DBG_PRINT}}
8081  | revoke_cmd from_id_list on_class_list
8082  {{
8083 
8084  PT_NODE *node = parser_new_node (this_parser, PT_REVOKE);
8085 
8086  if (node)
8087  {
8088  node->info.revoke.user_list = $2;
8089  node->info.revoke.spec_list = $3;
8090  node->info.revoke.auth_cmd_list = $1;
8091  }
8092 
8093  $$ = node;
8094  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8095 
8096  DBG_PRINT}}
8097  ;
8098 
8099 revoke_cmd
8100  : REVOKE
8101  { push_msg(MSGCAT_SYNTAX_MISSING_AUTH_COMMAND_LIST); }
8102  author_cmd_list
8103  { pop_msg(); }
8104  { $$ = $3; }
8105  ;
8106 
8107 grant_cmd
8108  : GRANT
8109  { push_msg(MSGCAT_SYNTAX_MISSING_AUTH_COMMAND_LIST); }
8110  author_cmd_list
8111  { pop_msg(); }
8112  { $$ = $3; }
8113  ;
8114 
8115 grant_head
8116  : grant_cmd on_class_list to_id_list
8117  {{
8118 
8119  PT_NODE *node = parser_new_node (this_parser, PT_GRANT);
8120 
8121  if (node)
8122  {
8123  node->info.grant.user_list = $3;
8124  node->info.grant.spec_list = $2;
8125  node->info.grant.auth_cmd_list = $1;
8126  }
8127 
8128  $$ = node;
8129  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8130 
8131  DBG_PRINT}}
8132  | grant_cmd to_id_list on_class_list
8133  {{
8134 
8135  PT_NODE *node = parser_new_node (this_parser, PT_GRANT);
8136 
8137  if (node)
8138  {
8139  node->info.grant.user_list = $2;
8140  node->info.grant.spec_list = $3;
8141  node->info.grant.auth_cmd_list = $1;
8142  }
8143 
8144  $$ = node;
8145  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8146 
8147  DBG_PRINT}}
8148  ;
8149 
8150 opt_with_grant_option
8151  : /* empty */
8152  {{
8153 
8154  $$ = 0;
8155 
8156  DBG_PRINT}}
8157  | WITH GRANT OPTION
8158  {{
8159 
8160  $$ = 1;
8161 
8162  DBG_PRINT}}
8163  ;
8164 
8165 on_class_list
8166  : ON_
8167  { push_msg(MSGCAT_SYNTAX_MISSING_CLASS_SPEC_LIST); }
8168  class_spec_list
8169  { pop_msg(); }
8170  { $$ = $3; }
8171  ;
8172 
8173 to_id_list
8174  : TO
8175  { push_msg(MSGCAT_SYNTAX_MISSING_IDENTIFIER_LIST); }
8176  identifier_list
8177  { pop_msg(); }
8178  { $$ = $3; }
8179  ;
8180 
8181 from_id_list
8182  : FROM
8183  { push_msg(MSGCAT_SYNTAX_MISSING_IDENTIFIER_LIST); }
8184  identifier_list
8185  { pop_msg(); }
8186  { $$ = $3; }
8187  ;
8188 
8189 author_cmd_list
8190  : author_cmd_list ',' authorized_cmd
8191  {{
8192 
8193  $$ = parser_make_link ($1, $3);
8194  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8195 
8196  DBG_PRINT}}
8197  | authorized_cmd
8198  {{
8199 
8200  $$ = $1;
8201  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8202 
8203  DBG_PRINT}}
8204  ;
8205 
8206 authorized_cmd
8207  : SELECT
8208  {{
8209 
8210  PT_NODE *node = parser_new_node (this_parser, PT_AUTH_CMD);
8211  node->info.auth_cmd.auth_cmd = PT_SELECT_PRIV;
8212  node->info.auth_cmd.attr_mthd_list = NULL;
8213  $$ = node;
8214  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8215 
8216  DBG_PRINT}}
8217  | INSERT
8218  {{
8219 
8220  PT_NODE *node = parser_new_node (this_parser, PT_AUTH_CMD);
8221 
8222  if (node)
8223  {
8224  node->info.auth_cmd.auth_cmd = PT_INSERT_PRIV;
8225  node->info.auth_cmd.attr_mthd_list = NULL;
8226  }
8227 
8228  $$ = node;
8229  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8230 
8231  DBG_PRINT}}
8232  | INDEX
8233  {{
8234 
8235  PT_NODE *node = parser_new_node (this_parser, PT_AUTH_CMD);
8236 
8237  if (node)
8238  {
8239  node->info.auth_cmd.auth_cmd = PT_INDEX_PRIV;
8240  node->info.auth_cmd.attr_mthd_list = NULL;
8241  }
8242 
8243  $$ = node;
8244  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8245 
8246  DBG_PRINT}}
8247  | DELETE_
8248  {{
8249 
8250  PT_NODE *node = parser_new_node (this_parser, PT_AUTH_CMD);
8251 
8252  if (node)
8253  {
8254  node->info.auth_cmd.auth_cmd = PT_DELETE_PRIV;
8255  node->info.auth_cmd.attr_mthd_list = NULL;
8256  }
8257 
8258  $$ = node;
8259  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8260 
8261  DBG_PRINT}}
8262 
8263  | UPDATE '(' identifier_list ')'
8264  {{
8265 
8266  PT_NODE *node = parser_new_node (this_parser, PT_AUTH_CMD);
8267  PARSER_SAVE_ERR_CONTEXT (node, @$.buffer_pos)
8268  if (node)
8269  {
8270  node->info.auth_cmd.auth_cmd = PT_UPDATE_PRIV;
8271  PT_ERRORmf (this_parser, node, MSGCAT_SET_PARSER_SYNTAX,
8272  MSGCAT_SYNTAX_ATTR_IN_PRIVILEGE,
8273  parser_print_tree_list (this_parser, $3));
8274 
8275  node->info.auth_cmd.attr_mthd_list = $3;
8276  }
8277 
8278  $$ = node;
8279 
8280  DBG_PRINT}}
8281  | UPDATE
8282  {{
8283 
8284  PT_NODE *node = parser_new_node (this_parser, PT_AUTH_CMD);
8285 
8286  if (node)
8287  {
8288  node->info.auth_cmd.auth_cmd = PT_UPDATE_PRIV;
8289  node->info.auth_cmd.attr_mthd_list = NULL;
8290  }
8291 
8292  $$ = node;
8293  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8294 
8295  DBG_PRINT}}
8296  | ALTER
8297  {{
8298 
8299  PT_NODE *node = parser_new_node (this_parser, PT_AUTH_CMD);
8300 
8301  if (node)
8302  {
8303  node->info.auth_cmd.auth_cmd = PT_ALTER_PRIV;
8304  node->info.auth_cmd.attr_mthd_list = NULL;
8305  }
8306 
8307  $$ = node;
8308  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8309 
8310  DBG_PRINT}}
8311  | ADD
8312  {{
8313 
8314  PT_NODE *node = parser_new_node (this_parser, PT_AUTH_CMD);
8315 
8316  if (node)
8317  {
8318  node->info.auth_cmd.auth_cmd = PT_ADD_PRIV;
8319  node->info.auth_cmd.attr_mthd_list = NULL;
8320  }
8321 
8322  $$ = node;
8323  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8324 
8325  DBG_PRINT}}
8326  | DROP
8327  {{
8328 
8329  PT_NODE *node = parser_new_node (this_parser, PT_AUTH_CMD);
8330 
8331  if (node)
8332  {
8333  node->info.auth_cmd.auth_cmd = PT_DROP_PRIV;
8334  node->info.auth_cmd.attr_mthd_list = NULL;
8335  }
8336 
8337  $$ = node;
8338  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8339 
8340  DBG_PRINT}}
8341  | EXECUTE
8342  {{
8343 
8344  PT_NODE *node = parser_new_node (this_parser, PT_AUTH_CMD);
8345 
8346  if (node)
8347  {
8348  node->info.auth_cmd.auth_cmd = PT_EXECUTE_PRIV;
8349  node->info.auth_cmd.attr_mthd_list = NULL;
8350  }
8351 
8352  $$ = node;
8353  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8354 
8355  DBG_PRINT}}
8356  | REFERENCES
8357  {{
8358 
8359  PT_NODE *node = parser_new_node (this_parser, PT_AUTH_CMD);
8360 
8361  if (node)
8362  {
8363  node->info.auth_cmd.auth_cmd = PT_REFERENCES_PRIV;
8364  node->info.auth_cmd.attr_mthd_list = NULL;
8365  }
8366 
8367  $$ = node;
8368  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8369 
8370  DBG_PRINT}}
8371  | ALL PRIVILEGES
8372  {{
8373 
8374  PT_NODE *node = parser_new_node (this_parser, PT_AUTH_CMD);
8375 
8376  if (node)
8377  {
8378  node->info.auth_cmd.auth_cmd = PT_ALL_PRIV;
8379  node->info.auth_cmd.attr_mthd_list = NULL;
8380  }
8381 
8382  $$ = node;
8383  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8384 
8385  DBG_PRINT}}
8386  | ALL
8387  {{
8388 
8389  PT_NODE *node = parser_new_node (this_parser, PT_AUTH_CMD);
8390 
8391  if (node)
8392  {
8393  node->info.auth_cmd.auth_cmd = PT_ALL_PRIV;
8394  node->info.auth_cmd.attr_mthd_list = NULL;
8395  }
8396 
8397  $$ = node;
8398  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8399 
8400  DBG_PRINT}}
8401  ;
8402 
8403 opt_password
8404  : /* empty */
8405  {{
8406 
8407  $$ = NULL;
8408 
8409  DBG_PRINT}}
8410  | PASSWORD
8411  { push_msg(MSGCAT_SYNTAX_INVALID_PASSWORD); }
8412  char_string_literal
8413  { pop_msg(); }
8414  {{
8415 
8416  $$ = $3;
8417  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8418 
8419  DBG_PRINT}}
8420  ;
8421 
8422 opt_groups
8423  : /* empty */
8424  {{
8425 
8426  $$ = NULL;
8427 
8428  DBG_PRINT}}
8429  | GROUPS
8430  { push_msg(MSGCAT_SYNTAX_INVALID_GROUPS); }
8431  identifier_list
8432  { pop_msg(); }
8433  {{
8434 
8435  $$ = $3;
8436  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8437 
8438  DBG_PRINT}}
8439  ;
8440 
8441 opt_members
8442  : /* empty */
8443  {{
8444 
8445  $$ = NULL;
8446 
8447  DBG_PRINT}}
8448  | MEMBERS
8449  { push_msg(MSGCAT_SYNTAX_INVALID_MEMBERS); }
8450  identifier_list
8451  { pop_msg(); }
8452  {{
8453 
8454  $$ = $3;
8455  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8456 
8457  DBG_PRINT}}
8458  ;
8459 
8460 call_stmt
8461  : CALL generic_function into_clause_opt
8462  {{
8463 
8464  PT_NODE *node = $2;
8465  if (node)
8466  {
8467  node->info.method_call.call_or_expr = PT_IS_CALL_STMT;
8468  node->info.method_call.to_return_var = $3;
8469  }
8470 
8471  parser_cannot_prepare = true;
8472  parser_cannot_cache = true;
8473 
8474  $$ = node;
8475  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8476 
8477  DBG_PRINT}}
8478  ;
8479 
8480 opt_class_or_normal_attr_def_list
8481  : /* empty */
8482  {{
8483 
8484  $$ = NULL;
8485 
8486  DBG_PRINT}}
8487  | '(' class_or_normal_attr_def_list ')'
8488  {{
8489 
8490  $$ = $2;
8491  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8492 
8493  DBG_PRINT}}
8494  ;
8495 
8496 opt_method_def_list
8497  : /* empty */
8498  {{
8499 
8500  $$ = NULL;
8501 
8502  DBG_PRINT}}
8503  | METHOD method_def_list
8504  {{
8505 
8506  $$ = $2;
8507  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8508 
8509  DBG_PRINT}}
8510  ;
8511 
8512 opt_method_files
8513  : /* empty */
8514  {{
8515 
8516  $$ = NULL;
8517 
8518  DBG_PRINT}}
8519  | File method_file_list
8520  {{
8521 
8522  $$ = $2;
8523  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8524 
8525  DBG_PRINT}}
8526  ;
8527 
8528 opt_inherit_resolution_list
8529  : /* empty */
8530  {{
8531 
8532  $$ = NULL;
8533 
8534  DBG_PRINT}}
8535  | inherit_resolution_list
8536  {{
8537 
8538  $$ = $1;
8539  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8540 
8541  DBG_PRINT}}
8542  ;
8543 
8544 opt_table_option_list
8545  : /* empty */
8546  {{
8547 
8548  $$ = NULL;
8549 
8550  DBG_PRINT}}
8551  | table_option_list
8552  {{
8553 
8554  $$ = $1;
8555  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8556 
8557  DBG_PRINT}}
8558  ;
8559 
8560 opt_partition_clause
8561  : /* empty */
8562  {{
8563 
8564  $$ = NULL;
8565 
8566  DBG_PRINT}}
8567  | partition_clause
8568  {{
8569 
8570  $$ = $1;
8571  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8572 
8573  DBG_PRINT}}
8574  ;
8575 
8576 opt_create_as_clause
8577  : /* empty */
8578  {{
8579 
8580  container_2 ctn;
8581  SET_CONTAINER_2(ctn, NULL, NULL);
8582  $$ = ctn;
8583 
8584  DBG_PRINT}}
8585  | create_as_clause
8586  {{
8587 
8588  $$ = $1;
8589 
8590  DBG_PRINT}}
8591  ;
8592 
8593 of_class_table_type
8594  : CLASS
8595  {{
8596 
8597  $$ = PT_CLASS;
8598 
8599  DBG_PRINT}}
8600  | TABLE
8601  {{
8602 
8603  $$ = PT_CLASS;
8604 
8605  DBG_PRINT}}
8606  ;
8607 
8608 of_view_vclass
8609  : VIEW
8610  | VCLASS
8611  ;
8612 
8613 opt_or_replace
8614  : /*empty*/
8615  {{
8616 
8617  $$ = 0;
8618 
8619  DBG_PRINT}}
8620  | OR REPLACE
8621  {{
8622 
8623  $$ = 1;
8624 
8625  DBG_PRINT}}
8626  ;
8627 
8628 opt_if_not_exists
8629  : /*empty*/
8630  {{
8631 
8632  $$ = 0;
8633 
8634  DBG_PRINT}}
8635  | IF NOT EXISTS
8636  {{
8637 
8638  $$ = 1;
8639 
8640  DBG_PRINT}}
8641  ;
8642 
8643 opt_if_exists
8644  : /*empty*/
8645  {{
8646 
8647  $$ = 0;
8648 
8649  DBG_PRINT}}
8650  | IF EXISTS
8651  {{
8652 
8653  $$ = 1;
8654 
8655  DBG_PRINT}}
8656  ;
8657 
8658 opt_paren_view_attr_def_list
8659  : /* empty */
8660  {{
8661 
8662  $$ = NULL;
8663 
8664  DBG_PRINT}}
8665  | '(' view_attr_def_list ')'
8666  {{
8667 
8668  $$ = $2;
8669  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8670 
8671  DBG_PRINT}}
8672  ;
8673 
8674 opt_as_query_list
8675  : /* empty */
8676  {{
8677 
8678  $$ = NULL;
8679 
8680  DBG_PRINT}}
8681  | AS query_list
8682  {{
8683 
8684  $$ = $2;
8685  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8686 
8687  DBG_PRINT}}
8688  ;
8689 
8690 opt_with_levels_clause
8691  : /* empty */
8692  {{
8693 
8694  $$ = PT_EMPTY;
8695 
8696  DBG_PRINT}}
8697  | WITH LOCAL CHECK OPTION
8698  {{
8699 
8700  $$ = PT_LOCAL;
8701 
8702  DBG_PRINT}}
8703  | WITH CASCADED CHECK OPTION
8704  {{
8705 
8706  $$ = PT_CASCADED;
8707 
8708  DBG_PRINT}}
8709  | WITH CHECK OPTION
8710  {{
8711 
8712  $$ = PT_CASCADED;
8713 
8714  DBG_PRINT}}
8715  ;
8716 
8717 query_list
8718  : query_list ',' csql_query
8719  {{
8720 
8721  $$ = parser_make_link ($1, $3);
8722  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8723 
8724  DBG_PRINT}}
8725  | csql_query
8726  {{
8727 
8728  $$ = $1;
8729  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8730 
8731  DBG_PRINT}}
8732  ;
8733 
8734 inherit_resolution_list
8735  : inherit_resolution_list ',' inherit_resolution
8736  {{
8737 
8738  $$ = parser_make_link ($1, $3);
8739  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8740 
8741  DBG_PRINT}}
8742  | INHERIT inherit_resolution
8743  {{
8744 
8745  $$ = $2;
8746  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8747 
8748  DBG_PRINT}}
8749  ;
8750 
8751 inherit_resolution
8752  : opt_class identifier OF identifier AS identifier
8753  {{
8754 
8755  PT_NODE *node = parser_new_node (this_parser, PT_RESOLUTION);
8756 
8757  if (node)
8758  {
8759  PT_MISC_TYPE t = PT_NORMAL;
8760 
8761  if ($1)
8762  t = PT_META_ATTR;
8763  node->info.resolution.of_sup_class_name = $4;
8764  node->info.resolution.attr_mthd_name = $2;
8765  node->info.resolution.attr_type = t;
8766  node->info.resolution.as_attr_mthd_name = $6;
8767  }
8768 
8769  $$ = node;
8770  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8771 
8772  DBG_PRINT}}
8773  | opt_class identifier OF identifier
8774  {{
8775 
8776  PT_NODE *node = parser_new_node (this_parser, PT_RESOLUTION);
8777 
8778  if (node)
8779  {
8780  PT_MISC_TYPE t = PT_NORMAL;
8781 
8782  if ($1)
8783  t = PT_META_ATTR;
8784  node->info.resolution.of_sup_class_name = $4;
8785  node->info.resolution.attr_mthd_name = $2;
8786  node->info.resolution.attr_type = t;
8787  }
8788 
8789  $$ = node;
8790  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8791 
8792  DBG_PRINT}}
8793  ;
8794 
8795 table_option_list
8796  : table_option_list ',' table_option
8797  {{
8798 
8799  $$ = parser_make_link ($1, $3);
8800  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8801 
8802  DBG_PRINT}}
8803  | table_option_list table_option
8804  {{
8805 
8806  $$ = parser_make_link ($1, $2);
8807  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8808 
8809  DBG_PRINT}}
8810  | table_option
8811  {{
8812 
8813  $$ = $1;
8814  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8815 
8816  DBG_PRINT}}
8817  ;
8818 
8819 table_option
8820  : REUSE_OID
8821  {{
8822 
8823  $$ = pt_table_option (this_parser, PT_TABLE_OPTION_REUSE_OID, NULL);
8824  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8825 
8826  DBG_PRINT}}
8827  | DONT_REUSE_OID
8828  {{
8829 
8830  $$ = pt_table_option (this_parser, PT_TABLE_OPTION_DONT_REUSE_OID, NULL);
8831  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8832 
8833  DBG_PRINT}}
8834  | AUTO_INCREMENT '=' UNSIGNED_INTEGER
8835  {{
8836 
8837  PT_NODE *val = parser_new_node (this_parser, PT_VALUE);
8838  if (val)
8839  {
8840  val->info.value.data_value.str =
8841  pt_append_bytes (this_parser, NULL, $3,
8842  strlen ($3));
8843  val->type_enum = PT_TYPE_NUMERIC;
8844  PT_NODE_PRINT_VALUE_TO_TEXT (this_parser, val);
8845  }
8846 
8847  $$ = pt_table_option (this_parser, PT_TABLE_OPTION_AUTO_INCREMENT, val);
8848  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8849 
8850  DBG_PRINT}}
8851  | class_encrypt_spec
8852  {{
8853 
8854  $$ = pt_table_option (this_parser, PT_TABLE_OPTION_ENCRYPT, $1);
8855  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8856 
8857  DBG_PRINT}}
8858  | charset_spec
8859  {{
8860 
8861  $$ = pt_table_option (this_parser, PT_TABLE_OPTION_CHARSET, $1);
8862  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8863 
8864  DBG_PRINT}}
8865  | collation_spec
8866  {{
8867 
8868  $$ = pt_table_option (this_parser, PT_TABLE_OPTION_COLLATION, $1);
8869  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8870 
8871  DBG_PRINT}}
8872  | class_comment_spec
8873  {{
8874 
8875  $$ = pt_table_option (this_parser, PT_TABLE_OPTION_COMMENT, $1);
8876  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8877 
8878  DBG_PRINT}}
8879  ;
8880 
8881 opt_subtable_clause
8882  : /* empty */
8883  {{
8884 
8885  $$ = NULL;
8886 
8887  DBG_PRINT}}
8888  | UNDER only_class_name_list
8889  {{
8890 
8891  $$ = $2;
8892  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8893 
8894  DBG_PRINT}}
8895  | AS SUBCLASS OF only_class_name_list
8896  {{
8897 
8898  $$ = $4;
8899  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8900 
8901  DBG_PRINT}}
8902  ;
8903 
8904 opt_constraint_id
8905  : /* empty */
8906  {{
8907 
8908  $$ = NULL;
8909 
8910  DBG_PRINT}}
8911  | CONSTRAINT identifier
8912  {{
8913 
8914  $$ = $2;
8915  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8916 
8917  DBG_PRINT}}
8918  ;
8919 
8920 opt_constraint_opt_id
8921  : /* empty */
8922  {{
8923 
8924  $$ = NULL;
8925 
8926  DBG_PRINT}}
8927  | CONSTRAINT opt_identifier
8928  {{
8929 
8930  $$ = $2;
8931  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8932 
8933  DBG_PRINT}}
8934  ;
8935 
8936 of_unique_foreign_check
8937  : unique_constraint
8938  {{
8939 
8940  $$ = $1;
8941  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8942 
8943  DBG_PRINT}}
8944  | foreign_key_constraint
8945  {{
8946 
8947  $$ = $1;
8948  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8949 
8950  DBG_PRINT}}
8951  | check_constraint
8952  {{
8953 
8954  $$ = $1;
8955  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
8956 
8957  DBG_PRINT}}
8958  ;
8959 
8960 opt_constraint_attr_list
8961  : /* empty */
8962  {{
8963 
8964  container_4 ctn;
8965  SET_CONTAINER_4 (ctn, FROM_NUMBER (0), FROM_NUMBER (0), FROM_NUMBER (0),
8966  FROM_NUMBER (0));
8967  $$ = ctn;
8968 
8969  DBG_PRINT}}
8970  | constraint_attr_list
8971  {{
8972 
8973  $$ = $1;
8974 
8975  DBG_PRINT}}
8976  ;
8977 
8978 constraint_attr_list
8979  : constraint_attr_list ',' constraint_attr
8980  {{
8981 
8982  container_4 ctn = $1;
8983  container_4 ctn_new = $3;
8984 
8985  if (TO_NUMBER (ctn_new.c1))
8986  {
8987  ctn.c1 = ctn_new.c1;
8988  ctn.c2 = ctn_new.c2;
8989  }
8990 
8991  if (TO_NUMBER (ctn_new.c3))
8992  {
8993  ctn.c3 = ctn_new.c3;
8994  ctn.c4 = ctn_new.c4;
8995  }
8996 
8997  $$ = ctn;
8998 
8999  DBG_PRINT}}
9000  | constraint_attr
9001  {{
9002 
9003  $$ = $1;
9004 
9005  DBG_PRINT}}
9006  ;
9007 
9008 unique_constraint
9009  : PRIMARY KEY opt_identifier '(' index_column_identifier_list ')'
9010  {{
9011 
9012  PT_NODE *node = parser_new_node (this_parser, PT_CONSTRAINT);
9013 
9014  if (node)
9015  {
9016  node->info.constraint.type = PT_CONSTRAIN_PRIMARY_KEY;
9017  node->info.constraint.name = $3;
9018  node->info.constraint.un.unique.attrs = $5;
9019  }
9020 
9021  $$ = node;
9022  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
9023 
9024  DBG_PRINT}}
9025  | UNIQUE opt_of_index_key opt_identifier index_column_name_list
9026  {{
9027 
9028  PT_NODE *node = NULL;
9029  PT_NODE *sort_spec_cols = $4, *name_cols = NULL, *temp;
9030 
9031  for (temp = sort_spec_cols; temp != NULL; temp = temp->next)
9032  {
9033  if (temp->info.sort_spec.expr->node_type == PT_EXPR)
9034  {
9035  /* Currently, not allowed unique with filter/function
9036  index. However, may be introduced later, if it will be
9037  usefull. Unique filter/function index code is removed
9038  from grammar module only. It is kept yet in the others
9039  modules. This will allow us to easily support this
9040  feature later by adding in grammar only. If no need
9041  such feature, filter/function code must be removed
9042  from all modules. */
9043  PT_ERRORm (this_parser, node, MSGCAT_SET_PARSER_SYNTAX,
9044  MSGCAT_SYNTAX_INVALID_CREATE_INDEX);
9045  }
9046  }
9047  name_cols = pt_sort_spec_list_to_name_node_list (this_parser, sort_spec_cols);
9048  if (name_cols)
9049  {
9050  /* create constraint node */
9051  node = parser_new_node (this_parser, PT_CONSTRAINT);
9052  PARSER_SAVE_ERR_CONTEXT (node, @$.buffer_pos)
9053  if (node)
9054  {
9055  node->info.constraint.type = PT_CONSTRAIN_UNIQUE;
9056  node->info.constraint.name = $3;
9057  node->info.constraint.un.unique.attrs = name_cols;
9058  }
9059  parser_free_tree (this_parser, sort_spec_cols);
9060  }
9061  else
9062  {
9063  /* create index node */
9064 
9065  if (parser_count_list (sort_spec_cols) == 1
9066  && (sort_spec_cols->info.sort_spec.expr->node_type != PT_EXPR))
9067  {
9068  /* unique index with prefix length not allowed */
9069  PT_ERRORm (this_parser, node, MSGCAT_SET_PARSER_SYNTAX,
9070  MSGCAT_SYNTAX_INVALID_CREATE_INDEX);
9071  }
9072  else
9073  {
9074  node = parser_new_node (this_parser, PT_CREATE_INDEX);
9075  PARSER_SAVE_ERR_CONTEXT (node, @$.buffer_pos)
9076  if (node)
9077  {
9078  node->info.index.index_name = $3;
9079  if (node->info.index.index_name)
9080  {
9081  node->info.index.index_name->info.name.meta_class = PT_INDEX_NAME;
9082  }
9083 
9084  node->info.index.indexed_class = NULL;
9085  node->info.index.column_names = sort_spec_cols;
9086  node->info.index.unique = 1;
9087  node->info.index.index_status = SM_NORMAL_INDEX;
9088  }
9089  }
9090  }
9091 
9092  $$ = node;
9093 
9094  DBG_PRINT}}
9095  ;
9096 
9097 foreign_key_constraint
9098  : FOREIGN /* 1 */
9099  KEY /* 2 */
9100  opt_identifier /* 3 */
9101  '(' index_column_identifier_list ')' /* 4, 5, 6 */
9102  REFERENCES /* 7 */
9103  class_name /* 8 */
9104  opt_paren_attr_list /* 9 */
9105  opt_ref_rule_list /* 10 */
9106  {{
9107 
9108  PT_NODE *node = parser_new_node (this_parser, PT_CONSTRAINT);
9109 
9110  if (node)
9111  {
9112  node->info.constraint.name = $3;
9113  node->info.constraint.type = PT_CONSTRAIN_FOREIGN_KEY;
9114  node->info.constraint.un.foreign_key.attrs = $5;
9115 
9116  node->info.constraint.un.foreign_key.referenced_attrs = $9;
9117  node->info.constraint.un.foreign_key.match_type = PT_MATCH_REGULAR;
9118  node->info.constraint.un.foreign_key.delete_action = TO_NUMBER (CONTAINER_AT_0 ($10)); /* delete_action */
9119  node->info.constraint.un.foreign_key.update_action = TO_NUMBER (CONTAINER_AT_1 ($10)); /* update_action */
9120  node->info.constraint.un.foreign_key.referenced_class = $8;
9121  }
9122 
9123  $$ = node;
9124  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
9125 
9126  DBG_PRINT}}
9127  ;
9128 
9129 index_column_identifier_list
9130  : index_column_identifier_list ',' index_column_identifier
9131  {{
9132 
9133  $$ = parser_make_link ($1, $3);
9134  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
9135 
9136  DBG_PRINT}}
9137  | index_column_identifier
9138  {{
9139 
9140  $$ = $1;
9141  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
9142 
9143  DBG_PRINT}}
9144  ;
9145 
9146 index_column_identifier
9147  : identifier opt_asc_or_desc
9148  {{
9149 
9150  if ($2)
9151  {
9152  PT_NAME_INFO_SET_FLAG ($1, PT_NAME_INFO_DESC);
9153  }
9154  $$ = $1;
9155  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
9156 
9157  DBG_PRINT}}
9158  ;
9159 
9160 opt_asc_or_desc
9161  : /* empty */
9162  {{
9163 
9164  $$ = 0;
9165 
9166  DBG_PRINT}}
9167  | ASC
9168  {{
9169 
9170  $$ = 0;
9171 
9172  DBG_PRINT}}
9173  | DESC
9174  {{
9175 
9176  $$ = 1;
9177 
9178  DBG_PRINT}}
9179  ;
9180 
9181 opt_paren_attr_list
9182  : /* empty */
9183  {{
9184 
9185  $$ = NULL;
9186 
9187  DBG_PRINT}}
9188  | '(' identifier_list ')'
9189  {{
9190 
9191  $$ = $2;
9192  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
9193 
9194  DBG_PRINT}}
9195  ;
9196 
9197 opt_ref_rule_list
9198  : /* empty */
9199  {{
9200 
9201  container_3 ctn;
9202  SET_CONTAINER_3 (ctn, FROM_NUMBER (PT_RULE_RESTRICT),
9203  FROM_NUMBER (PT_RULE_RESTRICT), NULL);
9204  $$ = ctn;
9205 
9206  DBG_PRINT}}
9207  | ref_rule_list
9208  {{
9209 
9210  container_3 ctn = $1;
9211  if (ctn.c1 == NULL)
9212  ctn.c1 = FROM_NUMBER (PT_RULE_RESTRICT);
9213  if (ctn.c2 == NULL)
9214  ctn.c2 = FROM_NUMBER (PT_RULE_RESTRICT);
9215  $$ = ctn;
9216 
9217  DBG_PRINT}}
9218  ;
9219 
9220 ref_rule_list
9221  : ref_rule_list ON_ DELETE_ CASCADE
9222  {{
9223 
9224  container_3 ctn = $1;
9225  if (ctn.c1 != NULL)
9226  {
9227  push_msg (MSGCAT_SYNTAX_DUPLICATED_REF_RULE);
9228  csql_yyerror_explicit (@2.first_line, @2.first_column);
9229  }
9230 
9231  ctn.c1 = FROM_NUMBER (PT_RULE_CASCADE);
9232  $$ = ctn;
9233 
9234  DBG_PRINT}}
9235  | ref_rule_list ON_ DELETE_ NO ACTION
9236  {{
9237 
9238  container_3 ctn = $1;
9239  if (ctn.c1 != NULL)
9240  {
9241  push_msg (MSGCAT_SYNTAX_DUPLICATED_REF_RULE);
9242  csql_yyerror_explicit (@2.first_line, @2.first_column);
9243  }
9244 
9245  ctn.c1 = FROM_NUMBER (PT_RULE_NO_ACTION);
9246  $$ = ctn;
9247 
9248  DBG_PRINT}}
9249  | ref_rule_list ON_ DELETE_ RESTRICT
9250  {{
9251 
9252  container_3 ctn = $1;
9253  if (ctn.c1 != NULL)
9254  {
9255  push_msg (MSGCAT_SYNTAX_DUPLICATED_REF_RULE);
9256  csql_yyerror_explicit (@2.first_line, @2.first_column);
9257  }
9258 
9259  ctn.c1 = FROM_NUMBER (PT_RULE_RESTRICT);
9260  $$ = ctn;
9261 
9262  DBG_PRINT}}
9263  | ref_rule_list ON_ DELETE_ SET Null
9264  {{
9265 
9266  container_3 ctn = $1;
9267  if (ctn.c1 != NULL)
9268  {
9269  push_msg (MSGCAT_SYNTAX_DUPLICATED_REF_RULE);
9270  csql_yyerror_explicit (@2.first_line, @2.first_column);
9271  }
9272 
9273  ctn.c1 = FROM_NUMBER (PT_RULE_SET_NULL);
9274  $$ = ctn;
9275 
9276  DBG_PRINT}}
9277  | ref_rule_list ON_ UPDATE NO ACTION
9278  {{
9279 
9280  container_3 ctn = $1;
9281  if (ctn.c2 != NULL)
9282  {
9283  push_msg (MSGCAT_SYNTAX_DUPLICATED_REF_RULE);
9284  csql_yyerror_explicit (@2.first_line, @2.first_column);
9285  }
9286 
9287  ctn.c2 = FROM_NUMBER (PT_RULE_NO_ACTION);
9288  $$ = ctn;
9289 
9290  DBG_PRINT}}
9291  | ref_rule_list ON_ UPDATE RESTRICT
9292  {{
9293 
9294  container_3 ctn = $1;
9295  if (ctn.c2 != NULL)
9296  {
9297  push_msg (MSGCAT_SYNTAX_DUPLICATED_REF_RULE);
9298  csql_yyerror_explicit (@2.first_line, @2.first_column);
9299  }
9300 
9301  ctn.c2 = FROM_NUMBER (PT_RULE_RESTRICT);
9302  $$ = ctn;
9303 
9304  DBG_PRINT}}
9305  | ref_rule_list ON_ UPDATE SET Null
9306  {{
9307 
9308  container_3 ctn = $1;
9309  if (ctn.c2 != NULL)
9310  {
9311  push_msg (MSGCAT_SYNTAX_DUPLICATED_REF_RULE);
9312  csql_yyerror_explicit (@2.first_line, @2.first_column);
9313  }
9314 
9315  ctn.c2 = FROM_NUMBER (PT_RULE_SET_NULL);
9316  $$ = ctn;
9317 
9318  DBG_PRINT}}
9319  | ON_ DELETE_ CASCADE
9320  {{
9321 
9322  container_3 ctn;
9323  SET_CONTAINER_3 (ctn, FROM_NUMBER (PT_RULE_CASCADE), NULL, NULL);
9324  $$ = ctn;
9325 
9326  DBG_PRINT}}
9327  | ON_ DELETE_ NO ACTION
9328  {{
9329 
9330  container_3 ctn;
9331  SET_CONTAINER_3 (ctn, FROM_NUMBER (PT_RULE_NO_ACTION), NULL, NULL);
9332  $$ = ctn;
9333 
9334  DBG_PRINT}}
9335  | ON_ DELETE_ RESTRICT
9336  {{
9337 
9338  container_3 ctn;
9339  SET_CONTAINER_3 (ctn, FROM_NUMBER (PT_RULE_RESTRICT), NULL, NULL);
9340  $$ = ctn;
9341 
9342  DBG_PRINT}}
9343  | ON_ DELETE_ SET Null
9344  {{
9345 
9346  container_3 ctn;
9347  SET_CONTAINER_3 (ctn, FROM_NUMBER (PT_RULE_SET_NULL), NULL, NULL);
9348  $$ = ctn;
9349 
9350  DBG_PRINT}}
9351  | ON_ UPDATE NO ACTION
9352  {{
9353 
9354  container_3 ctn;
9355  SET_CONTAINER_3 (ctn, NULL, FROM_NUMBER (PT_RULE_NO_ACTION), NULL);
9356  $$ = ctn;
9357 
9358  DBG_PRINT}}
9359  | ON_ UPDATE RESTRICT
9360  {{
9361 
9362  container_3 ctn;
9363  SET_CONTAINER_3 (ctn, NULL, FROM_NUMBER (PT_RULE_RESTRICT), NULL);
9364  $$ = ctn;
9365 
9366  DBG_PRINT}}
9367  | ON_ UPDATE SET Null
9368  {{
9369 
9370  container_3 ctn;
9371  SET_CONTAINER_3 (ctn, NULL, FROM_NUMBER (PT_RULE_SET_NULL), NULL);
9372  $$ = ctn;
9373 
9374  DBG_PRINT}}
9375  ;
9376 
9377 
9378 check_constraint
9379  : CHECK '(' search_condition ')'
9380  {{
9381 
9382  PT_NODE *node = parser_new_node (this_parser, PT_CONSTRAINT);
9383 
9384  if (node)
9385  {
9386  node->info.constraint.type = PT_CONSTRAIN_CHECK;
9387  node->info.constraint.un.check.expr = $3;
9388  }
9389 
9390  $$ = node;
9391  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
9392 
9393  DBG_PRINT}}
9394  ;
9395 
9396 
9397 /* bool_deferrable, deferrable value, bool_initially_deferred, initially_deferred value */
9398 constraint_attr
9399  : NOT DEFERRABLE
9400  {{
9401 
9402  container_4 ctn;
9403  ctn.c1 = FROM_NUMBER (1);
9404  ctn.c2 = FROM_NUMBER (0);
9405  ctn.c3 = FROM_NUMBER (0);
9406  ctn.c4 = FROM_NUMBER (0);
9407  $$ = ctn;
9408 
9409  DBG_PRINT}}
9410  | DEFERRABLE
9411  {{
9412 
9413  container_4 ctn;
9414  ctn.c1 = FROM_NUMBER (1);
9415  ctn.c2 = FROM_NUMBER (1);
9416  ctn.c3 = FROM_NUMBER (0);
9417  ctn.c4 = FROM_NUMBER (0);
9418  $$ = ctn;
9419 
9420  DBG_PRINT}}
9421  | INITIALLY DEFERRED
9422  {{
9423 
9424  container_4 ctn;
9425  ctn.c1 = FROM_NUMBER (0);
9426  ctn.c2 = FROM_NUMBER (0);
9427  ctn.c3 = FROM_NUMBER (1);
9428  ctn.c4 = FROM_NUMBER (1);
9429  $$ = ctn;
9430 
9431  DBG_PRINT}}
9432  | INITIALLY IMMEDIATE
9433  {{
9434 
9435  container_4 ctn;
9436  ctn.c1 = FROM_NUMBER (0);
9437  ctn.c2 = FROM_NUMBER (0);
9438  ctn.c3 = FROM_NUMBER (1);
9439  ctn.c4 = FROM_NUMBER (0);
9440  $$ = ctn;
9441 
9442  DBG_PRINT}}
9443  ;
9444 
9445 method_def_list
9446  : method_def_list ',' method_def
9447  {{
9448 
9449  $$ = parser_make_link ($1, $3);
9450  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
9451 
9452  DBG_PRINT}}
9453  | method_def
9454  {{
9455 
9456  $$ = $1;
9457  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
9458 
9459  DBG_PRINT}}
9460  ;
9461 
9462 method_def
9463  : opt_class
9464  identifier
9465  opt_method_def_arg_list
9466  opt_data_type
9467  opt_function_identifier
9468  {{
9469 
9470  PT_NODE *node = parser_new_node (this_parser, PT_METHOD_DEF);
9471  PT_MISC_TYPE t = PT_NORMAL;
9472  if ($1)
9473  t = PT_META_ATTR;
9474 
9475  if (node)
9476  {
9477  node->info.method_def.method_name = $2;
9478  node->info.method_def.mthd_type = t;
9479  node->info.method_def.method_args_list = $3;
9480  node->type_enum = TO_NUMBER (CONTAINER_AT_0 ($4));
9481  node->data_type = CONTAINER_AT_1 ($4);
9482  node->info.method_def.function_name = $5;
9483  }
9484  $$ = node;
9485  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
9486 
9487  DBG_PRINT}}
9488  ;
9489 
9490 opt_method_def_arg_list
9491  : /* empty */
9492  {{
9493 
9494  $$ = NULL;
9495 
9496  DBG_PRINT}}
9497  | '(' arg_type_list ')'
9498  {{
9499 
9500  $$ = $2;
9501  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
9502 
9503  DBG_PRINT}}
9504  | '(' ')'
9505  {{
9506 
9507  $$ = NULL;
9508 
9509  DBG_PRINT}}
9510  ;
9511 
9512 arg_type_list
9513  : arg_type_list ',' inout_data_type
9514  {{
9515 
9516  $$ = parser_make_link ($1, $3);
9517  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
9518 
9519  DBG_PRINT}}
9520  | inout_data_type
9521  {{
9522 
9523  $$ = $1;
9524  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
9525 
9526  DBG_PRINT}}
9527  ;
9528 
9529 inout_data_type
9530  : opt_in_out data_type
9531  {{
9532 
9533  PT_NODE *at = parser_new_node (this_parser, PT_DATA_TYPE);
9534 
9535  if (at)
9536  {
9537  at->type_enum = TO_NUMBER (CONTAINER_AT_0 ($2));
9538  at->data_type = CONTAINER_AT_1 ($2);
9539  at->info.data_type.inout = $1;
9540  }
9541 
9542  $$ = at;
9543  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
9544 
9545  DBG_PRINT}}
9546  ;
9547 
9548 opt_data_type
9549  : /* empty */
9550  {{
9551 
9552  container_2 ctn;
9553  SET_CONTAINER_2 (ctn, FROM_NUMBER (PT_TYPE_NONE), NULL);
9554  $$ = ctn;
9555 
9556  DBG_PRINT}}
9557  | data_type
9558  {{
9559 
9560  $$ = $1;
9561 
9562  DBG_PRINT}}
9563  ;
9564 
9565 opt_function_identifier
9566  : /* empty */
9567  {{
9568 
9569  $$ = NULL;
9570 
9571  DBG_PRINT}}
9572  | FUNCTION identifier
9573  {{
9574 
9575  $$ = $2;
9576  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
9577 
9578  DBG_PRINT}}
9579  ;
9580 
9581 method_file_list
9582  : method_file_list ',' file_path_name
9583  {{
9584 
9585  $$ = parser_make_link ($1, $3);
9586  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
9587 
9588  DBG_PRINT}}
9589  | file_path_name
9590  {{
9591 
9592  $$ = $1;
9593  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
9594 
9595  DBG_PRINT}}
9596  ;
9597 
9598 file_path_name
9599  : char_string_literal
9600  {{
9601 
9602  PT_NODE *node = parser_new_node (this_parser, PT_FILE_PATH);
9603  if (node)
9604  node->info.file_path.string = $1;
9605  $$ = node;
9606  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
9607 
9608  DBG_PRINT}}
9609  ;
9610 
9611 opt_class_attr_def_list
9612  : /* empty */
9613  {{
9614 
9615  $$ = NULL;
9616 
9617  DBG_PRINT}}
9618  | CLASS
9619  ATTRIBUTE
9620  { parser_attr_type = PT_META_ATTR; }
9621  '(' attr_def_list ')'
9622  { parser_attr_type = PT_NORMAL; }
9623  {{
9624 
9625  $$ = $5;
9626  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
9627 
9628  DBG_PRINT}}
9629  ;
9630 
9631 class_or_normal_attr_def_list
9632  : class_or_normal_attr_def_list ',' class_or_normal_attr_def
9633  {{
9634 
9635  $$ = parser_make_link ($1, $3);
9636  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
9637 
9638  DBG_PRINT}}
9639  | class_or_normal_attr_def
9640  {{
9641 
9642  $$ = $1;
9643  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
9644 
9645  DBG_PRINT}}
9646  ;
9647 
9648 class_or_normal_attr_def
9649  : CLASS { parser_attr_type = PT_META_ATTR; } attr_def { parser_attr_type = PT_NORMAL; }
9650  {{
9651 
9652  $$ = $3;
9653  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
9654 
9655  DBG_PRINT}}
9656  | attr_def
9657  {{
9658 
9659  $$ = $1;
9660  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
9661 
9662  DBG_PRINT}}
9663  ;
9664 
9665 view_attr_def_list
9666  : view_attr_def_list ',' view_attr_def
9667  {{
9668 
9669  $$ = parser_make_link ($1, $3);
9670  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
9671 
9672  DBG_PRINT}}
9673  | view_attr_def
9674  {{
9675 
9676  $$ = $1;
9677  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
9678 
9679  DBG_PRINT}}
9680  ;
9681 
9682 view_attr_def
9683  : attr_def
9684  {{
9685 
9686  $$ = $1;
9687  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
9688 
9689  DBG_PRINT}}
9690  | identifier opt_comment_spec
9691  {{
9692 
9693  PT_NODE *node = parser_new_node (this_parser, PT_ATTR_DEF);
9694 
9695  if (node)
9696  {
9697  node->data_type = NULL;
9698  node->info.attr_def.attr_name = $1;
9699  node->info.attr_def.comment = $2;
9700  node->info.attr_def.attr_type = PT_NORMAL;
9701  }
9702 
9703  $$ = node;
9704  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
9705 
9706  DBG_PRINT}}
9707  ;
9708 
9709 attr_def_list_with_commas
9710  : attr_def_list_with_commas ',' attr_def
9711  {{
9712 
9713  $$ = parser_make_link ($1, $3);
9714  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
9715 
9716  DBG_PRINT}}
9717  | attr_def ',' attr_def
9718  {{
9719 
9720  $$ = parser_make_link ($1, $3);
9721  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
9722 
9723  DBG_PRINT}}
9724  ;
9725 
9726 attr_def_list
9727  : attr_def_list ',' attr_def
9728  {{
9729 
9730  $$ = parser_make_link ($1, $3);
9731  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
9732 
9733  DBG_PRINT}}
9734  | attr_def
9735  {{
9736 
9737  $$ = $1;
9738  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
9739 
9740  DBG_PRINT}}
9741  ;
9742 
9743 attr_def
9744  : attr_constraint_def
9745  {{
9746 
9747  $$ = $1;
9748  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
9749 
9750  DBG_PRINT}}
9751  | attr_index_def
9752  {{
9753 
9754  $$ = $1;
9755  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
9756 
9757  DBG_PRINT}}
9758  | attr_def_one
9759  {{
9760 
9761  $$ = $1;
9762  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
9763 
9764  DBG_PRINT}}
9765  ;
9766 
9767 attr_constraint_def
9768  : opt_constraint_opt_id
9769  of_unique_foreign_check
9770  opt_constraint_attr_list
9771  opt_comment_spec
9772  {{
9773 
9774  PT_NODE *name = $1;
9775  PT_NODE *constraint = $2;
9776 
9777  if (constraint)
9778  {
9779  if (constraint->node_type == PT_CONSTRAINT)
9780  {
9781  /* If both the constraint name and the index name are
9782  given we ignore the constraint name because that is
9783  what MySQL does for UNIQUE constraints. */
9784  if (constraint->info.constraint.name == NULL)
9785  {
9786  constraint->info.constraint.name = name;
9787  }
9788  constraint->info.constraint.comment = $4;
9789  if (TO_NUMBER (CONTAINER_AT_0 ($3)))
9790  {
9791  constraint->info.constraint.deferrable = (short)TO_NUMBER (CONTAINER_AT_1 ($3));
9792  }
9793  if (TO_NUMBER (CONTAINER_AT_2 ($3)))
9794  {
9795  constraint->info.constraint.initially_deferred =
9796  (short)TO_NUMBER (CONTAINER_AT_3 ($3));
9797  }
9798  }
9799  else
9800  {
9801  /* UNIQUE - constraint->node_type = PT_CREATE_INDEX */
9802  if (TO_NUMBER (CONTAINER_AT_0 ($3)) || TO_NUMBER (CONTAINER_AT_2 ($3)))
9803  {
9804  PT_ERRORm (this_parser, constraint, MSGCAT_SET_PARSER_SYNTAX,
9805  MSGCAT_SYNTAX_INVALID_CREATE_INDEX);
9806  }
9807  else
9808  {
9809  constraint->info.index.comment = $4;
9810  if (constraint->info.index.index_name == NULL)
9811  {
9812  constraint->info.index.index_name = name;
9813  if (name == NULL)
9814  {
9815  PT_ERRORm (this_parser, constraint,
9816  MSGCAT_SET_PARSER_SYNTAX,
9817  MSGCAT_SYNTAX_INVALID_CREATE_INDEX);
9818  }
9819  }
9820  }
9821  }
9822  }
9823 
9824  $$ = constraint;
9825  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
9826 
9827  DBG_PRINT}}
9828  ;
9829 
9830 attr_index_def
9831  : index_or_key /* 1 */
9832  identifier /* 2 */
9833  index_column_name_list /* 3 */
9834  opt_where_clause /* 4 */
9835  opt_comment_spec /* 5 */
9836  opt_invisible /* 6 */
9837  {{
9838  int arg_count = 0, prefix_col_count = 0;
9839  PT_NODE* node = parser_new_node(this_parser,
9840  PT_CREATE_INDEX);
9841  PT_NODE* col = $3;
9842 
9843  PARSER_SAVE_ERR_CONTEXT (node, @$.buffer_pos)
9844  node->info.index.index_name = $2;
9845  if (node->info.index.index_name)
9846  {
9847  node->info.index.index_name->info.name.meta_class = PT_INDEX_NAME;
9848  }
9849  node->info.index.indexed_class = NULL;
9850  node->info.index.where = $4;
9851  node->info.index.comment = $5;
9852  node->info.index.index_status = SM_NORMAL_INDEX;
9853 
9854  prefix_col_count =
9855  parser_count_prefix_columns (col, &arg_count);
9856 
9857  if (prefix_col_count > 1 ||
9858  (prefix_col_count == 1 && arg_count > 1))
9859  {
9860  PT_ERRORm (this_parser, node,
9861  MSGCAT_SET_PARSER_SEMANTIC,
9862  MSGCAT_SEMANTIC_MULTICOL_PREFIX_INDX_NOT_ALLOWED);
9863  }
9864  else
9865  {
9866  if (arg_count == 1 && (prefix_col_count == 1
9867  || col->info.sort_spec.expr->node_type == PT_FUNCTION))
9868  {
9869  PT_NODE *expr = col->info.sort_spec.expr;
9870  PT_NODE *arg_list = expr->info.function.arg_list;
9871  if ((arg_list != NULL)
9872  && (arg_list->next == NULL)
9873  && (arg_list->node_type == PT_VALUE))
9874  {
9875  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
9876  if (p)
9877  {
9878  p->info.name.original = expr->info.function.generic_name;
9879  }
9880  node->info.index.prefix_length =
9881  expr->info.function.arg_list;
9882  col->info.sort_spec.expr = p;
9883  }
9884  else
9885  {
9886  PT_ERRORm (this_parser, node,
9887  MSGCAT_SET_PARSER_SYNTAX,
9888  MSGCAT_SYNTAX_INVALID_CREATE_INDEX);
9889  }
9890  }
9891  }
9892  node->info.index.column_names = col;
9893  node->info.index.index_status = SM_NORMAL_INDEX;
9894  if ($6)
9895  {
9896  node->info.index.index_status = SM_INVISIBLE_INDEX;
9897  }
9898  $$ = node;
9899 
9900  DBG_PRINT}}
9901  ;
9902 
9903 attr_def_one
9904  : identifier
9905  data_type
9906  {{//attr_def_one : identifier
9907 
9908  PT_NODE *dt;
9909  PT_TYPE_ENUM typ;
9910  PT_NODE *node = parser_new_node (this_parser, PT_ATTR_DEF);
9911 
9912  if (node)
9913  {
9914  node->type_enum = typ = TO_NUMBER (CONTAINER_AT_0 ($2));
9915  node->data_type = dt = CONTAINER_AT_1 ($2);
9916  node->info.attr_def.attr_name = $1;
9917  if (typ == PT_TYPE_CHAR && dt)
9918  node->info.attr_def.size_constraint = dt->info.data_type.precision;
9919  if (typ == PT_TYPE_OBJECT && dt && dt->type_enum == PT_TYPE_VARCHAR)
9920  {
9921  node->type_enum = dt->type_enum;
9922  PT_NAME_INFO_SET_FLAG (node->info.attr_def.attr_name,
9923  PT_NAME_INFO_EXTERNAL);
9924  }
9925  }
9926 
9927  parser_save_attr_def_one (node);
9928 
9929  DBG_PRINT}}
9930  opt_constraint_list_and_opt_column_comment
9931  opt_attr_ordering_info
9932  {{
9933 
9934  PT_NODE *node = parser_get_attr_def_one ();
9935  if (node != NULL && node->info.attr_def.attr_type != PT_SHARED)
9936  {
9937  node->info.attr_def.attr_type = parser_attr_type;
9938  }
9939  if (node != NULL)
9940  {
9941  node->info.attr_def.ordering_info = $5;
9942  }
9943 
9944  $$ = node;
9945  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
9946 
9947  DBG_PRINT}}
9948  ;
9949 
9950 opt_attr_ordering_info
9951  : /* empty */
9952  {{
9953 
9954  $$ = NULL;
9955 
9956  DBG_PRINT}}
9957  | FIRST
9958  {{
9959 
9960  PT_NODE *ord = parser_new_node (this_parser, PT_ATTR_ORDERING);
9961  PARSER_SAVE_ERR_CONTEXT (ord, @$.buffer_pos)
9962  if (ord)
9963  {
9964  ord->info.attr_ordering.first = true;
9965  if (!allow_attribute_ordering)
9966  {
9967  PT_ERRORmf(this_parser, ord,
9968  MSGCAT_SET_PARSER_SEMANTIC,
9969  MSGCAT_SEMANTIC_NOT_ALLOWED_HERE, "FIRST");
9970  }
9971  }
9972 
9973  $$ = ord;
9974 
9975  DBG_PRINT}}
9976  | AFTER identifier
9977  {{
9978 
9979  PT_NODE *ord = parser_new_node (this_parser, PT_ATTR_ORDERING);
9980  PARSER_SAVE_ERR_CONTEXT (ord, @$.buffer_pos)
9981  if (ord)
9982  {
9983  ord->info.attr_ordering.after = $2;
9984  if (!allow_attribute_ordering)
9985  {
9986  PT_ERRORmf(this_parser, ord,
9987  MSGCAT_SET_PARSER_SEMANTIC,
9988  MSGCAT_SEMANTIC_NOT_ALLOWED_HERE, "AFTER column");
9989  }
9990  }
9991 
9992  $$ = ord;
9993 
9994  DBG_PRINT}}
9995  ;
9996 
9997 opt_constraint_list_and_opt_column_comment
9998  : /* empty */
9999  { $$ = 0; }
10000  | constraint_list_and_column_comment
10001  { $$ = $1; }
10002  ;
10003 
10004 constraint_list_and_column_comment
10005  : constraint_list_and_column_comment column_constraint_and_comment_def
10006  {{
10007  unsigned int mask = $1;
10008  unsigned int new_bit = $2;
10009  unsigned int merged = mask | new_bit;
10010 
10011  /* Check the constraints according to the following rules:
10012  * 1. A constraint should be specified once.
10013  * 2. Only one of SHARED, DEFAULT or AI can be specified.
10014  * 3. SHARED constraint cannot be defined with UNIQUE or PK constraint.
10015  */
10016  if (((mask & new_bit) ^ new_bit) == 0)
10017  {
10018  PT_ERROR (this_parser, pt_top(this_parser),
10019  "Multiple definitions exist for a constraint or comment");
10020  }
10021  else if ((new_bit & COLUMN_CONSTRAINT_SHARED_DEFAULT_AI)
10022  && ((merged & COLUMN_CONSTRAINT_SHARED_DEFAULT_AI)
10023  ^ (new_bit & COLUMN_CONSTRAINT_SHARED_DEFAULT_AI)) != 0)
10024  {
10025  PT_ERRORm (this_parser, pt_top(this_parser),
10026  MSGCAT_SET_PARSER_SEMANTIC,
10027  MSGCAT_SEMANTIC_INVALID_AUTO_INCREMENT_ON_DEFAULT_SHARED);
10028  }
10029  else if ((merged & COLUMN_CONSTRAINT_SHARED)
10030  && ((merged & COLUMN_CONSTRAINT_UNIQUE)
10031  || (merged & COLUMN_CONSTRAINT_PRIMARY_KEY)))
10032  {
10033  PT_ERROR (this_parser, pt_top(this_parser),
10034  "SHARED cannot be defined with PRIMARY KEY or UNIQUE constraint");
10035  }
10036 
10037  $$ = merged;
10038  }}
10039  | column_constraint_and_comment_def
10040  {{
10041  $$ = $1;
10042  }}
10043  ;
10044 
10045 column_constraint_and_comment_def
10046  : column_unique_constraint_def
10047  {{
10048  $$ = COLUMN_CONSTRAINT_UNIQUE;
10049  }}
10050  | column_primary_constraint_def
10051  {{
10052  $$ = COLUMN_CONSTRAINT_PRIMARY_KEY;
10053  }}
10054  | column_null_constraint_def
10055  {{
10056  $$ = COLUMN_CONSTRAINT_NULL;
10057  }}
10058  | column_other_constraint_def
10059  {{
10060  $$ = COLUMN_CONSTRAINT_OTHERS;
10061  }}
10062  | column_shared_constraint_def
10063  {{
10064  $$ = COLUMN_CONSTRAINT_SHARED;
10065  }}
10066  | column_default_constraint_def
10067  {{
10068  $$ = COLUMN_CONSTRAINT_DEFAULT;
10069  }}
10070  | column_ai_constraint_def
10071  {{
10072  $$ = COLUMN_CONSTRAINT_AUTO_INCREMENT;
10073  }}
10074  | column_comment_def
10075  {{
10076  $$ = COLUMN_CONSTRAINT_COMMENT;
10077  }}
10078  | column_on_update_def
10079  {{
10080  $$ = COLUMN_CONSTRAINT_ON_UPDATE;
10081  }}
10082  ;
10083 
10084 column_unique_constraint_def
10085  : opt_constraint_id UNIQUE opt_key opt_constraint_attr_list
10086  {{
10087 
10088  PT_NODE *node = parser_get_attr_def_one ();
10089  PT_NODE *constrant_name = $1;
10090  PT_NODE *constraint = parser_new_node (this_parser, PT_CONSTRAINT);
10091 
10092  if (constraint)
10093  {
10094  constraint->info.constraint.type = PT_CONSTRAIN_UNIQUE;
10095  constraint->info.constraint.un.unique.attrs
10096  = parser_copy_tree (this_parser, node->info.attr_def.attr_name);
10097 
10098  if (node->info.attr_def.attr_type == PT_SHARED)
10099  constraint->info.constraint.un.unique.attrs->info.name.meta_class
10100  = PT_SHARED;
10101 
10102  else
10103  constraint->info.constraint.un.unique.attrs->info.name.meta_class
10104  = parser_attr_type;
10105 
10106  constraint->info.constraint.name = $1;
10107 
10108  if (TO_NUMBER (CONTAINER_AT_0 ($4)))
10109  {
10110  constraint->info.constraint.deferrable =
10111  (short)TO_NUMBER (CONTAINER_AT_1 ($4));
10112  }
10113 
10114  if (TO_NUMBER (CONTAINER_AT_2 ($4)))
10115  {
10116  constraint->info.constraint.initially_deferred =
10117  (short)TO_NUMBER (CONTAINER_AT_3 ($4));
10118  }
10119  }
10120 
10121  parser_make_link (node, constraint);
10122 
10123  DBG_PRINT}}
10124  ;
10125 
10126 column_primary_constraint_def
10127  : opt_constraint_id PRIMARY KEY opt_constraint_attr_list
10128  {{
10129 
10130  PT_NODE *node = parser_get_attr_def_one ();
10131  PT_NODE *constrant_name = $1;
10132  PT_NODE *constraint = parser_new_node (this_parser, PT_CONSTRAINT);
10133 
10134  if (constraint)
10135  {
10136  constraint->info.constraint.type = PT_CONSTRAIN_PRIMARY_KEY;
10137  constraint->info.constraint.un.unique.attrs
10138  = parser_copy_tree (this_parser, node->info.attr_def.attr_name);
10139 
10140  constraint->info.constraint.name = $1;
10141 
10142  if (TO_NUMBER (CONTAINER_AT_0 ($4)))
10143  {
10144  constraint->info.constraint.deferrable =
10145  (short)TO_NUMBER (CONTAINER_AT_1 ($4));
10146  }
10147 
10148  if (TO_NUMBER (CONTAINER_AT_2 ($4)))
10149  {
10150  constraint->info.constraint.initially_deferred =
10151  (short)TO_NUMBER (CONTAINER_AT_3 ($4));
10152  }
10153  }
10154 
10155  parser_make_link (node, constraint);
10156 
10157  DBG_PRINT}}
10158  ;
10159 
10160 column_null_constraint_def
10161  : opt_constraint_id Null opt_constraint_attr_list
10162  {{
10163 
10164  PT_NODE *node = parser_get_attr_def_one ();
10165  PT_NODE *constrant_name = $1;
10166  PT_NODE *constraint = parser_new_node (this_parser, PT_CONSTRAINT);
10167 
10168  /* to support null in ODBC-DDL, ignore it */
10169  if (constraint)
10170  {
10171  constraint->info.constraint.type = PT_CONSTRAIN_NULL;
10172  constraint->info.constraint.name = $1;
10173 
10174  if (TO_NUMBER (CONTAINER_AT_0 ($3)))
10175  {
10176  constraint->info.constraint.deferrable =
10177  (short)TO_NUMBER (CONTAINER_AT_1 ($3));
10178  }
10179 
10180  if (TO_NUMBER (CONTAINER_AT_2 ($3)))
10181  {
10182  constraint->info.constraint.initially_deferred =
10183  (short)TO_NUMBER (CONTAINER_AT_3 ($3));
10184  }
10185  }
10186 
10187  parser_make_link (node, constraint);
10188 
10189  DBG_PRINT}}
10190  | opt_constraint_id NOT Null opt_constraint_attr_list
10191  {{
10192 
10193  PT_NODE *node = parser_get_attr_def_one ();
10194  PT_NODE *constrant_name = $1;
10195  PT_NODE *constraint = parser_new_node (this_parser, PT_CONSTRAINT);
10196 
10197 
10198  if (constraint)
10199  {
10200  constraint->info.constraint.type = PT_CONSTRAIN_NOT_NULL;
10201  constraint->info.constraint.un.not_null.attr
10202  = parser_copy_tree (this_parser, node->info.attr_def.attr_name);
10203  /*
10204  * This should probably be deferred until semantic
10205  * analysis time; leave it this way for now.
10206  */
10207  node->info.attr_def.constrain_not_null = 1;
10208 
10209  constraint->info.constraint.name = $1;
10210 
10211  if (TO_NUMBER (CONTAINER_AT_0 ($4)))
10212  {
10213  constraint->info.constraint.deferrable =
10214  (short)TO_NUMBER (CONTAINER_AT_1 ($4));
10215  }
10216 
10217  if (TO_NUMBER (CONTAINER_AT_2 ($4)))
10218  {
10219  constraint->info.constraint.initially_deferred =
10220  (short)TO_NUMBER (CONTAINER_AT_3 ($4));
10221  }
10222  }
10223 
10224  parser_make_link (node, constraint);
10225 
10226  DBG_PRINT}}
10227  ;
10228 
10229 column_other_constraint_def
10230  : opt_constraint_id CHECK '(' search_condition ')' opt_constraint_attr_list
10231  {{
10232 
10233  PT_NODE *node = parser_get_attr_def_one ();
10234  PT_NODE *constrant_name = $1;
10235  PT_NODE *constraint = parser_new_node (this_parser, PT_CONSTRAINT);
10236 
10237  if (constraint)
10238  {
10239  constraint->info.constraint.type = PT_CONSTRAIN_CHECK;
10240  constraint->info.constraint.un.check.expr = $4;
10241 
10242  constraint->info.constraint.name = $1;
10243 
10244  if (TO_NUMBER (CONTAINER_AT_0 ($6)))
10245  {
10246  constraint->info.constraint.deferrable =
10247  (short)TO_NUMBER (CONTAINER_AT_1 ($6));
10248  }
10249 
10250  if (TO_NUMBER (CONTAINER_AT_2 ($6)))
10251  {
10252  constraint->info.constraint.initially_deferred =
10253  (short)TO_NUMBER (CONTAINER_AT_3 ($6));
10254  }
10255  }
10256 
10257  parser_make_link (node, constraint);
10258 
10259  DBG_PRINT}}
10260  | opt_constraint_id /* 1 */
10261  opt_foreign_key /* 2 */
10262  REFERENCES /* 3 */
10263  class_name /* 4 */
10264  opt_paren_attr_list /* 5 */
10265  opt_ref_rule_list /* 6 */
10266  opt_constraint_attr_list /* 7 */
10267  {{
10268 
10269  PT_NODE *node = parser_get_attr_def_one ();
10270  PT_NODE *constrant_name = $1;
10271  PT_NODE *constraint = parser_new_node (this_parser, PT_CONSTRAINT);
10272 
10273  if (constraint)
10274  {
10275  constraint->info.constraint.un.foreign_key.referenced_attrs = $5;
10276  constraint->info.constraint.un.foreign_key.match_type = PT_MATCH_REGULAR;
10277  constraint->info.constraint.un.foreign_key.delete_action = TO_NUMBER (CONTAINER_AT_0 ($6)); /* delete_action */
10278  constraint->info.constraint.un.foreign_key.update_action = TO_NUMBER (CONTAINER_AT_1 ($6)); /* update_action */
10279  constraint->info.constraint.un.foreign_key.referenced_class = $4;
10280  }
10281 
10282  if (constraint)
10283  {
10284  constraint->info.constraint.type = PT_CONSTRAIN_FOREIGN_KEY;
10285  constraint->info.constraint.un.foreign_key.attrs
10286  = parser_copy_tree (this_parser, node->info.attr_def.attr_name);
10287 
10288  constraint->info.constraint.name = $1;
10289 
10290  if (TO_NUMBER (CONTAINER_AT_0 ($7)))
10291  {
10292  constraint->info.constraint.deferrable =
10293  (short)TO_NUMBER (CONTAINER_AT_1 ($7));
10294  }
10295 
10296  if (TO_NUMBER (CONTAINER_AT_2 ($7)))
10297  {
10298  constraint->info.constraint.initially_deferred =
10299  (short)TO_NUMBER (CONTAINER_AT_3 ($7));
10300  }
10301  }
10302 
10303  parser_make_link (node, constraint);
10304 
10305  DBG_PRINT}}
10306  ;
10307 
10308 index_or_key
10309  : INDEX
10310  | KEY
10311  ;
10312 
10313 opt_of_index_key
10314  : /* empty */
10315  | INDEX
10316  | KEY
10317  ;
10318 
10319 opt_key
10320  : /* empty */
10321  | KEY
10322  ;
10323 
10324 opt_foreign_key
10325  : /* empty */
10326  | FOREIGN KEY
10327  ;
10328 
10329 column_ai_constraint_def
10330  : AUTO_INCREMENT '(' integer_text ',' integer_text ')'
10331  {{
10332 
10333  PT_NODE *node = parser_get_attr_def_one ();
10334  PT_NODE *start_val = parser_new_node (this_parser, PT_VALUE);
10335  PT_NODE *increment_val = parser_new_node (this_parser, PT_VALUE);
10336  PT_NODE *ai_node;
10337 
10338  if (start_val)
10339  {
10340  start_val->info.value.data_value.str =
10341  pt_append_bytes (this_parser, NULL, $3,
10342  strlen ($3));
10343  start_val->type_enum = PT_TYPE_NUMERIC;
10344  PT_NODE_PRINT_VALUE_TO_TEXT (this_parser,
10345  start_val);
10346  }
10347 
10348  if (increment_val)
10349  {
10350  increment_val->info.value.data_value.str =
10351  pt_append_bytes (this_parser, NULL, $5,
10352  strlen ($5));
10353  increment_val->type_enum = PT_TYPE_NUMERIC;
10354  PT_NODE_PRINT_VALUE_TO_TEXT (this_parser,
10355  increment_val);
10356  }
10357 
10358  ai_node = parser_new_node (this_parser, PT_AUTO_INCREMENT);
10359  ai_node->info.auto_increment.start_val = start_val;
10360  ai_node->info.auto_increment.increment_val = increment_val;
10361  node->info.attr_def.auto_increment = ai_node;
10362 
10363  if (parser_attr_type == PT_META_ATTR)
10364  {
10365  PT_ERRORm (this_parser, node, MSGCAT_SET_PARSER_SEMANTIC,
10366  MSGCAT_SEMANTIC_CLASS_ATT_CANT_BE_AUTOINC);
10367  }
10368 
10369  DBG_PRINT}}
10370  | AUTO_INCREMENT
10371  {{
10372 
10373  PT_NODE *node = parser_get_attr_def_one ();
10374 
10375  PT_NODE *ai_node = parser_new_node (this_parser, PT_AUTO_INCREMENT);
10376  ai_node->info.auto_increment.start_val = NULL;
10377  ai_node->info.auto_increment.increment_val = NULL;
10378  node->info.attr_def.auto_increment = ai_node;
10379 
10380  if (parser_attr_type == PT_META_ATTR)
10381  {
10382  PT_ERRORm (this_parser, node, MSGCAT_SET_PARSER_SEMANTIC,
10383  MSGCAT_SEMANTIC_CLASS_ATT_CANT_BE_AUTOINC);
10384  }
10385 
10386  DBG_PRINT}}
10387  ;
10388 
10389 column_shared_constraint_def
10390  : SHARED expression_
10391  {{
10392  PT_NODE *attr_node;
10393  PT_NODE *node = parser_new_node (this_parser, PT_DATA_DEFAULT);
10394 
10395  if (node)
10396  {
10397  node->info.data_default.default_value = $2;
10398  node->info.data_default.shared = PT_SHARED;
10399  PARSER_SAVE_ERR_CONTEXT (node, @2.buffer_pos)
10400  }
10401 
10402  attr_node = parser_get_attr_def_one ();
10403  attr_node->info.attr_def.data_default = node;
10404  attr_node->info.attr_def.attr_type = PT_SHARED;
10405 
10406  DBG_PRINT}}
10407  ;
10408 
10409 column_on_update_def
10410  : ON_ UPDATE expression_
10411  {{
10412  DB_DEFAULT_EXPR_TYPE default_expr_type = DB_DEFAULT_NONE;
10413  PT_NODE *attr_node = parser_get_attr_def_one ();
10414  PT_NODE *on_update_default_value = $3;
10415  PARSER_SAVE_ERR_CONTEXT (attr_node, @3.buffer_pos)
10416 
10417  if (on_update_default_value && on_update_default_value->node_type == PT_EXPR)
10418  {
10419  switch (on_update_default_value->info.expr.op)
10420  {
10421  case PT_CURRENT_TIMESTAMP:
10422  default_expr_type = DB_DEFAULT_CURRENTTIMESTAMP;
10423  break;
10424  case PT_CURRENT_DATE:
10425  default_expr_type = DB_DEFAULT_CURRENTDATE;
10426  break;
10427  case PT_CURRENT_DATETIME:
10428  default_expr_type = DB_DEFAULT_CURRENTDATETIME;
10429  break;
10430  case PT_SYS_TIMESTAMP:
10431  default_expr_type = DB_DEFAULT_SYSTIMESTAMP;
10432  break;
10433  case PT_UNIX_TIMESTAMP:
10434  default_expr_type = DB_DEFAULT_UNIX_TIMESTAMP;
10435  break;
10436  case PT_SYS_DATE:
10437  default_expr_type = DB_DEFAULT_SYSDATE;
10438  break;
10439  case PT_SYS_DATETIME:
10440  default_expr_type = DB_DEFAULT_SYSDATETIME;
10441  break;
10442  case PT_SYS_TIME:
10443  default_expr_type = DB_DEFAULT_SYSTIME;
10444  break;
10445  default:
10446  PT_ERROR (this_parser, attr_node, "invalid expression type");
10447  break;
10448  }
10449  }
10450  else
10451  {
10452  PT_ERROR (this_parser, attr_node, "on update must be an expression");
10453  }
10454 
10455  attr_node->info.attr_def.on_update = default_expr_type;
10456 
10457  DBG_PRINT}}
10458  ;
10459 
10460 column_default_constraint_def
10461  : DEFAULT expression_
10462  {{
10463 
10464  PT_NODE *attr_node;
10465  PT_NODE *node = parser_new_node (this_parser, PT_DATA_DEFAULT);
10466 
10467  if (node)
10468  {
10469  PT_NODE *def;
10470  node->info.data_default.default_value = $2;
10471  node->info.data_default.shared = PT_DEFAULT;
10472  PARSER_SAVE_ERR_CONTEXT (node, @2.buffer_pos)
10473 
10474  def = node->info.data_default.default_value;
10475  if (def && def->node_type == PT_EXPR)
10476  {
10477  if (def->info.expr.op == PT_TO_CHAR)
10478  {
10479  if (def->info.expr.arg3)
10480  {
10481  bool has_user_lang = false;
10482  bool dummy;
10483 
10484  assert (def->info.expr.arg3->node_type == PT_VALUE);
10485  (void) lang_get_lang_id_from_flag (def->info.expr.arg3->info.value.data_value.i, &dummy, &has_user_lang);
10486  if (has_user_lang)
10487  {
10488  PT_ERROR (this_parser, def->info.expr.arg3, "do not allow lang format in default to_char");
10489  }
10490  }
10491 
10492  if (def->info.expr.arg1 && def->info.expr.arg1->node_type == PT_EXPR)
10493  {
10494  def = def->info.expr.arg1;
10495  }
10496  }
10497 
10498  switch (def->info.expr.op)
10499  {
10500  case PT_SYS_TIME:
10501  node->info.data_default.default_expr_type = DB_DEFAULT_SYSTIME;
10502  break;
10503  case PT_SYS_DATE:
10504  node->info.data_default.default_expr_type = DB_DEFAULT_SYSDATE;
10505  break;
10506  case PT_SYS_DATETIME:
10507  node->info.data_default.default_expr_type = DB_DEFAULT_SYSDATETIME;
10508  break;
10509  case PT_SYS_TIMESTAMP:
10510  node->info.data_default.default_expr_type = DB_DEFAULT_SYSTIMESTAMP;
10511  break;
10512  case PT_CURRENT_TIME:
10513  node->info.data_default.default_expr_type = DB_DEFAULT_CURRENTTIME;
10514  break;
10515  case PT_CURRENT_DATE:
10516  node->info.data_default.default_expr_type = DB_DEFAULT_CURRENTDATE;
10517  break;
10518  case PT_CURRENT_DATETIME:
10519  node->info.data_default.default_expr_type = DB_DEFAULT_CURRENTDATETIME;
10520  break;
10521  case PT_CURRENT_TIMESTAMP:
10522  node->info.data_default.default_expr_type = DB_DEFAULT_CURRENTTIMESTAMP;
10523  break;
10524  case PT_USER:
10525  node->info.data_default.default_expr_type = DB_DEFAULT_USER;
10526  break;
10527  case PT_CURRENT_USER:
10528  node->info.data_default.default_expr_type = DB_DEFAULT_CURR_USER;
10529  break;
10530  case PT_UNIX_TIMESTAMP:
10531  node->info.data_default.default_expr_type = DB_DEFAULT_UNIX_TIMESTAMP;
10532  break;
10533  default:
10534  node->info.data_default.default_expr_type = DB_DEFAULT_NONE;
10535  break;
10536  }
10537  }
10538  else
10539  {
10540  node->info.data_default.default_expr_type = DB_DEFAULT_NONE;
10541  }
10542  }
10543 
10544  attr_node = parser_get_attr_def_one ();
10545  attr_node->info.attr_def.data_default = node;
10546 
10547  DBG_PRINT}}
10548  ;
10549 
10550 attr_def_comment_list
10551  : attr_def_comment_list ',' attr_def_comment
10552  {{
10553 
10554  $$ = parser_make_link ($1, $3);
10555  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos);
10556 
10557  DBG_PRINT}}
10558  | attr_def_comment
10559  {{
10560 
10561  $$ = $1;
10562  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos);
10563 
10564  DBG_PRINT}}
10565  ;
10566 
10567 attr_def_comment
10568  : identifier opt_equalsign comment_value
10569  {{
10570 
10571  PT_NODE *attr_node = parser_new_node (this_parser, PT_ATTR_DEF);
10572 
10573  if (attr_node)
10574  {
10575  attr_node->info.attr_def.attr_name = $1;
10576  attr_node->info.attr_def.comment = $3;
10577  attr_node->info.attr_def.attr_type = parser_attr_type;
10578  }
10579 
10580  $$ = attr_node;
10581  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos);
10582 
10583  DBG_PRINT}}
10584  ;
10585 
10586 column_comment_def
10587  : COMMENT comment_value
10588  {{
10589 
10590  PT_NODE *attr_node;
10591  attr_node = parser_get_attr_def_one ();
10592  attr_node->info.attr_def.comment = $2;
10593 
10594  DBG_PRINT}}
10595  ;
10596 
10597 transaction_mode_list
10598  : transaction_mode_list ',' transaction_mode %dprec 1
10599  {{
10600 
10601  $$ = parser_make_link ($1, $3);
10602  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
10603 
10604  DBG_PRINT}}
10605  | transaction_mode %dprec 2
10606  {{
10607 
10608  $$ = $1;
10609  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
10610 
10611  DBG_PRINT}}
10612  ;
10613 
10614 transaction_mode
10615  : ISOLATION LEVEL isolation_level_spec ',' isolation_level_spec %dprec 1
10616  {{
10617 
10618  PT_NODE *tm = parser_new_node (this_parser, PT_ISOLATION_LVL);
10619  PT_NODE *is = parser_new_node (this_parser, PT_ISOLATION_LVL);
10620  int async_ws_or_error;
10621 
10622  if (tm && is)
10623  {
10624  PARSER_SAVE_ERR_CONTEXT (tm, @$.buffer_pos)
10625  async_ws_or_error = (int) TO_NUMBER (CONTAINER_AT_3 ($3));
10626  if (async_ws_or_error < 0)
10627  {
10628  PT_ERRORm(this_parser, tm, MSGCAT_SET_PARSER_SYNTAX,
10629  MSGCAT_SYNTAX_READ_UNCOMMIT);
10630  async_ws_or_error = 0;
10631  }
10632  tm->info.isolation_lvl.level = CONTAINER_AT_0 ($3);
10633  tm->info.isolation_lvl.schema = TO_NUMBER (CONTAINER_AT_1 ($3));
10634  tm->info.isolation_lvl.instances = TO_NUMBER (CONTAINER_AT_2 ($3));
10635  tm->info.isolation_lvl.async_ws = async_ws_or_error;
10636 
10637 
10638  async_ws_or_error = (int) TO_NUMBER (CONTAINER_AT_3 ($5));
10639  if (async_ws_or_error < 0)
10640  {
10641  PT_ERRORm(this_parser, is, MSGCAT_SET_PARSER_SYNTAX,
10642  MSGCAT_SYNTAX_READ_UNCOMMIT);
10643  async_ws_or_error = 0;
10644  }
10645  is->info.isolation_lvl.level = CONTAINER_AT_0 ($5);
10646  is->info.isolation_lvl.schema = TO_NUMBER (CONTAINER_AT_1 ($5));
10647  is->info.isolation_lvl.instances = TO_NUMBER (CONTAINER_AT_2 ($5));
10648  is->info.isolation_lvl.async_ws = async_ws_or_error;
10649 
10650  if (tm->info.isolation_lvl.async_ws)
10651  {
10652  if (is->info.isolation_lvl.async_ws)
10653  {
10654  /* async_ws, async_ws */
10655  }
10656  else
10657  {
10658  /* async_ws, iso_lvl */
10659  tm->info.isolation_lvl.schema = is->info.isolation_lvl.schema;
10660  tm->info.isolation_lvl.instances =
10661  is->info.isolation_lvl.instances;
10662  tm->info.isolation_lvl.level = is->info.isolation_lvl.level;
10663  }
10664  }
10665  else
10666  {
10667  if (is->info.isolation_lvl.async_ws)
10668  {
10669  /* iso_lvl, async_ws */
10670  tm->info.isolation_lvl.async_ws = 1;
10671  }
10672  else
10673  {
10674  /* iso_lvl, iso_lvl */
10675  if (tm->info.isolation_lvl.level != NULL
10676  || is->info.isolation_lvl.level != NULL)
10677  PT_ERRORm (this_parser, tm, MSGCAT_SET_PARSER_SEMANTIC,
10678  MSGCAT_SEMANTIC_GT_1_ISOLATION_LVL);
10679  else if (tm->info.isolation_lvl.schema !=
10680  is->info.isolation_lvl.schema
10681  || tm->info.isolation_lvl.instances !=
10682  is->info.isolation_lvl.instances)
10683  PT_ERRORm (this_parser, tm, MSGCAT_SET_PARSER_SEMANTIC,
10684  MSGCAT_SEMANTIC_GT_1_ISOLATION_LVL);
10685  }
10686  }
10687 
10688  is->info.isolation_lvl.level = NULL;
10689  parser_free_node (this_parser, is);
10690  }
10691 
10692  $$ = tm;
10693 
10694  DBG_PRINT}}
10695  | ISOLATION LEVEL isolation_level_spec %dprec 2
10696  {{
10697 
10698  PT_NODE *tm = parser_new_node (this_parser, PT_ISOLATION_LVL);
10699  int async_ws_or_error = (int) TO_NUMBER (CONTAINER_AT_3 ($3));
10700 
10701  PARSER_SAVE_ERR_CONTEXT (tm, @$.buffer_pos)
10702 
10703  if (async_ws_or_error < 0)
10704  {
10705  PT_ERRORm(this_parser, tm, MSGCAT_SET_PARSER_SYNTAX,
10706  MSGCAT_SYNTAX_READ_UNCOMMIT);
10707  async_ws_or_error = 0;
10708  }
10709 
10710  if (tm)
10711  {
10712  tm->info.isolation_lvl.level = CONTAINER_AT_0 ($3);
10713  tm->info.isolation_lvl.schema = TO_NUMBER (CONTAINER_AT_1 ($3));
10714  tm->info.isolation_lvl.instances = TO_NUMBER (CONTAINER_AT_2 ($3));
10715  tm->info.isolation_lvl.async_ws = async_ws_or_error;
10716  }
10717 
10718  $$ = tm;
10719 
10720  DBG_PRINT}}
10721  | LOCK_ TIMEOUT timeout_spec
10722  {{
10723 
10724  PT_NODE *tm = parser_new_node (this_parser, PT_TIMEOUT);
10725 
10726  if (tm)
10727  {
10728  tm->info.timeout.val = $3;
10729  }
10730 
10731  $$ = tm;
10732  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
10733 
10734  DBG_PRINT}}
10735  ;
10736 
10737 
10738 /* container order : level, schema, instances, async_ws */
10739 isolation_level_spec
10740  : expression_
10741  {{
10742 
10743  container_4 ctn;
10744  SET_CONTAINER_4 (ctn, $1, FROM_NUMBER (PT_NO_ISOLATION_LEVEL),
10745  FROM_NUMBER (PT_NO_ISOLATION_LEVEL), FROM_NUMBER (0));
10746  $$ = ctn;
10747 
10748  DBG_PRINT}}
10749  | ASYNC WORKSPACE
10750  {{
10751 
10752  container_4 ctn;
10753  SET_CONTAINER_4 (ctn, NULL, FROM_NUMBER (PT_NO_ISOLATION_LEVEL),
10754  FROM_NUMBER (PT_NO_ISOLATION_LEVEL), FROM_NUMBER (1));
10755  $$ = ctn;
10756 
10757  DBG_PRINT}}
10758  | SERIALIZABLE
10759  {{
10760 
10761  container_4 ctn;
10762  SET_CONTAINER_4 (ctn, NULL, FROM_NUMBER (PT_SERIALIZABLE),
10763  FROM_NUMBER (PT_SERIALIZABLE), FROM_NUMBER (0));
10764  $$ = ctn;
10765 
10766  DBG_PRINT}}
10767  | CURSOR STABILITY
10768  {{
10769 
10770  container_4 ctn;
10771  SET_CONTAINER_4 (ctn, NULL, FROM_NUMBER (PT_NO_ISOLATION_LEVEL),
10772  FROM_NUMBER (PT_READ_COMMITTED), FROM_NUMBER (0));
10773  $$ = ctn;
10774 
10775  DBG_PRINT}}
10776  | isolation_level_name %dprec 1
10777  {{
10778 
10779  container_4 ctn;
10780  PT_MISC_TYPE schema = PT_REPEATABLE_READ;
10781  PT_MISC_TYPE level = 0;
10782  level = $1;
10783 
10784  SET_CONTAINER_4 (ctn, NULL, FROM_NUMBER (schema),
10785  FROM_NUMBER (level), FROM_NUMBER (0));
10786  $$ = ctn;
10787 
10788  DBG_PRINT}}
10789  | isolation_level_name of_schema_class %dprec 1
10790  {{
10791 
10792  container_4 ctn;
10793  PT_MISC_TYPE schema = 0;
10794  PT_MISC_TYPE level = 0;
10795  int error = 0;
10796 
10797  schema = $1;
10798 
10799  level = PT_NO_ISOLATION_LEVEL;
10800 
10801  SET_CONTAINER_4 (ctn, NULL, FROM_NUMBER (schema), FROM_NUMBER (level),
10802  FROM_NUMBER (error));
10803  $$ = ctn;
10804 
10805  DBG_PRINT}}
10806  | isolation_level_name INSTANCES %dprec 1
10807  {{
10808 
10809  container_4 ctn;
10810  PT_MISC_TYPE schema = 0;
10811  PT_MISC_TYPE level = 0;
10812 
10813  schema = PT_NO_ISOLATION_LEVEL;
10814  level = $1;
10815 
10816  SET_CONTAINER_4 (ctn, NULL, FROM_NUMBER (schema), FROM_NUMBER (level),
10817  FROM_NUMBER (0));
10818  $$ = ctn;
10819 
10820  DBG_PRINT}}
10821  | isolation_level_name of_schema_class ',' isolation_level_name INSTANCES %dprec 10
10822  {{
10823 
10824  container_4 ctn;
10825  PT_MISC_TYPE schema = 0;
10826  PT_MISC_TYPE level = 0;
10827  int error = 0;
10828 
10829  level = $4;
10830  schema = $1;
10831 
10832  SET_CONTAINER_4 (ctn, NULL, FROM_NUMBER (schema), FROM_NUMBER (level),
10833  FROM_NUMBER (error));
10834  $$ = ctn;
10835 
10836  DBG_PRINT}}
10837  | isolation_level_name INSTANCES ',' isolation_level_name of_schema_class %dprec 10
10838  {{
10839  container_4 ctn;
10840  PT_MISC_TYPE schema = 0;
10841  PT_MISC_TYPE level = 0;
10842  int error = 0;
10843 
10844  level = $1;
10845  schema = $4;
10846 
10847  SET_CONTAINER_4 (ctn, NULL, FROM_NUMBER (schema), FROM_NUMBER (level),
10848  FROM_NUMBER (error));
10849  $$ = ctn;
10850 
10851  DBG_PRINT}}
10852  ;
10853 
10854 of_schema_class
10855  : SCHEMA
10856  | CLASS
10857  ;
10858 
10859 isolation_level_name
10860  : REPEATABLE READ
10861  {{
10862 
10863  $$ = PT_REPEATABLE_READ;
10864 
10865  DBG_PRINT}}
10866  | READ COMMITTED
10867  {{
10868 
10869  $$ = PT_READ_COMMITTED;
10870 
10871  DBG_PRINT}}
10872  ;
10873 
10874 timeout_spec
10875  : INFINITE_
10876  {{
10877 
10878  PT_NODE *val = parser_new_node (this_parser, PT_VALUE);
10879 
10880  if (val)
10881  {
10882  val->type_enum = PT_TYPE_INTEGER;
10883  val->info.value.data_value.i = -1;
10884  }
10885 
10886  $$ = val;
10887  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
10888 
10889  DBG_PRINT}}
10890  | OFF_
10891  {{
10892 
10893  PT_NODE *val = parser_new_node (this_parser, PT_VALUE);
10894 
10895  if (val)
10896  {
10897  val->type_enum = PT_TYPE_INTEGER;
10898  val->info.value.data_value.i = 0;
10899  }
10900 
10901  $$ = val;
10902  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
10903 
10904  DBG_PRINT}}
10905  | unsigned_integer
10906  {{
10907 
10908  $$ = $1;
10909  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
10910 
10911  DBG_PRINT}}
10912  | unsigned_real
10913  {{
10914 
10915  $$ = $1;
10916  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
10917 
10918  DBG_PRINT}}
10919  | param_
10920  {{
10921 
10922  $$ = $1;
10923  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
10924 
10925  DBG_PRINT}}
10926  | host_param_input
10927  {{
10928 
10929  $$ = $1;
10930  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
10931 
10932  DBG_PRINT}}
10933  ;
10934 
10935 
10936 transaction_stmt
10937  : COMMIT opt_work RETAIN LOCK_
10938  {{
10939 
10940  PT_NODE *comm = parser_new_node (this_parser, PT_COMMIT_WORK);
10941 
10942  if (comm)
10943  {
10944  comm->info.commit_work.retain_lock = 1;
10945  }
10946 
10947  $$ = comm;
10948  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
10949 
10950  DBG_PRINT}}
10951  | COMMIT opt_work
10952  {{
10953 
10954  PT_NODE *comm = parser_new_node (this_parser, PT_COMMIT_WORK);
10955  $$ = comm;
10956  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
10957 
10958  DBG_PRINT}}
10959  | ROLLBACK opt_work TO opt_savepoint expression_
10960  {{
10961 
10962  PT_NODE *roll = parser_new_node (this_parser, PT_ROLLBACK_WORK);
10963 
10964  if (roll)
10965  {
10966  roll->info.rollback_work.save_name = $5;
10967  }
10968 
10969  $$ = roll;
10970  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
10971 
10972  DBG_PRINT}}
10973  | ROLLBACK opt_work
10974  {{
10975 
10976  PT_NODE *roll = parser_new_node (this_parser, PT_ROLLBACK_WORK);
10977  $$ = roll;
10978  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
10979 
10980  DBG_PRINT}}
10981  | SAVEPOINT expression_
10982  {{
10983 
10984  PT_NODE *svpt = parser_new_node (this_parser, PT_SAVEPOINT);
10985 
10986  if (svpt)
10987  {
10988  svpt->info.savepoint.save_name = $2;
10989  }
10990 
10991  $$ = svpt;
10992  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
10993 
10994  DBG_PRINT}}
10995  ;
10996 
10997 
10998 opt_savepoint
10999  : /* empty */
11000  | SAVEPOINT
11001  ;
11002 
11003 opt_work
11004  : /* empty */
11005  | WORK
11006  ;
11007 
11008 opt_to
11009  : /* empty */
11010  | TO
11011  ;
11012 
11013 evaluate_stmt
11014  : EVALUATE expression_ into_clause_opt
11015  {{
11016 
11017  PT_NODE *node = parser_new_node (this_parser, PT_EVALUATE);
11018 
11019  if (node)
11020  {
11021  node->info.evaluate.expression = $2;
11022  node->info.evaluate.into_var = $3;
11023  }
11024 
11025  $$ = node;
11026  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
11027 
11028  DBG_PRINT}}
11029  ;
11030 
11031 prepare_stmt
11032  : PREPARE identifier FROM char_string
11033  {{
11034 
11035  PT_NODE *node = parser_new_node (this_parser, PT_PREPARE_STATEMENT);
11036 
11037  if (node)
11038  {
11039  node->info.prepare.name = $2;
11040  node->info.prepare.statement = $4;
11041  }
11042 
11043  $$ = node;
11044  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
11045 
11046  DBG_PRINT}}
11047  ;
11048 
11049 execute_stmt
11050  : EXECUTE identifier opt_using
11051  {{
11052 
11053  PT_NODE *node = parser_new_node (this_parser, PT_EXECUTE_PREPARE);
11054 
11055  if (node)
11056  {
11057  node->info.execute.name = $2;
11058  node->info.execute.using_list = $3;
11059  node->info.execute.into_list = NULL;
11060  node->info.execute.query = NULL;
11061  }
11062 
11063  $$ = node;
11064  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
11065 
11066  DBG_PRINT}}
11067  ;
11068 
11069 opt_using
11070  : /* empty */
11071  {{
11072 
11073  $$ = NULL;
11074 
11075  DBG_PRINT}}
11076  | USING
11077  { parser_save_and_set_hvar (0); }
11078  execute_using_list
11079  { parser_restore_hvar (); }
11080  {{
11081 
11082  $$ = $3;
11083  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
11084 
11085  DBG_PRINT}}
11086  ;
11087 
11088 opt_status
11089  : /* empty */
11090  {{
11091 
11092  $$ = PT_MISC_DUMMY;
11093 
11094  DBG_PRINT}}
11095  | trigger_status
11096  {{
11097 
11098  $$ = $1;
11099 
11100  DBG_PRINT}}
11101  ;
11102 
11103 trigger_status
11104  : STATUS ACTIVE
11105  {{
11106 
11107  $$ = PT_ACTIVE;
11108 
11109  DBG_PRINT}}
11110  | STATUS INACTIVE
11111  {{
11112 
11113  $$ = PT_INACTIVE;
11114 
11115  DBG_PRINT}}
11116  ;
11117 
11118 opt_priority
11119  : /* empty */
11120  {{
11121 
11122  $$ = NULL;
11123 
11124  DBG_PRINT}}
11125  | trigger_priority
11126  {{
11127 
11128  $$ = $1;
11129  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
11130 
11131  DBG_PRINT}}
11132  ;
11133 
11134 trigger_priority
11135  : PRIORITY unsigned_real
11136  {{
11137 
11138  $$ = $2;
11139  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
11140 
11141  DBG_PRINT}}
11142  ;
11143 
11144 opt_if_trigger_condition
11145  : /* empty */
11146  {{
11147 
11148  $$ = NULL;
11149 
11150  DBG_PRINT}}
11151  | IF trigger_condition
11152  {{
11153 
11154  $$ = $2;
11155  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
11156 
11157  DBG_PRINT}}
11158  ;
11159 
11160 trigger_time
11161  : BEFORE
11162  {{
11163 
11164  $$ = PT_BEFORE;
11165 
11166  DBG_PRINT}}
11167  | AFTER
11168  {{
11169 
11170  $$ = PT_AFTER;
11171 
11172  DBG_PRINT}}
11173  | DEFERRED
11174  {{
11175 
11176  $$ = PT_DEFERRED;
11177 
11178  DBG_PRINT}}
11179  ;
11180 
11181 opt_trigger_action_time
11182  : /* empty */
11183  {{
11184 
11185  $$ = PT_MISC_DUMMY;
11186 
11187  DBG_PRINT}}
11188  | AFTER
11189  {{
11190 
11191  $$ = PT_AFTER;
11192 
11193  DBG_PRINT}}
11194  | DEFERRED
11195  {{
11196 
11197  $$ = PT_DEFERRED;
11198 
11199  DBG_PRINT}}
11200  ;
11201 
11202 event_spec
11203  : event_type
11204  {{
11205 
11206  PT_NODE *node = parser_new_node (this_parser, PT_EVENT_SPEC);
11207 
11208  if (node)
11209  {
11210  node->info.event_spec.event_type = $1;
11211  }
11212 
11213  $$ = node;
11214  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
11215 
11216  DBG_PRINT}}
11217  | event_type event_target
11218  {{
11219 
11220  PT_NODE *node = parser_new_node (this_parser, PT_EVENT_SPEC);
11221 
11222  if (node)
11223  {
11224  node->info.event_spec.event_type = $1;
11225  node->info.event_spec.event_target = $2;
11226  }
11227 
11228  $$ = node;
11229  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
11230 
11231  DBG_PRINT}}
11232  ;
11233 
11234 event_type
11235  : INSERT
11236  {{
11237 
11238  $$ = PT_EV_INSERT;
11239 
11240  DBG_PRINT}}
11241  | STATEMENT INSERT
11242  {{
11243 
11244  $$ = PT_EV_STMT_INSERT;
11245 
11246  DBG_PRINT}}
11247  | DELETE_
11248  {{
11249 
11250  $$ = PT_EV_DELETE;
11251 
11252  DBG_PRINT}}
11253  | STATEMENT DELETE_
11254  {{
11255 
11256  $$ = PT_EV_STMT_DELETE;
11257 
11258  DBG_PRINT}}
11259  | UPDATE
11260  {{
11261 
11262  $$ = PT_EV_UPDATE;
11263 
11264  DBG_PRINT}}
11265  | STATEMENT UPDATE
11266  {{
11267 
11268  $$ = PT_EV_STMT_UPDATE;
11269 
11270  DBG_PRINT}}
11271  | COMMIT
11272  {{
11273 
11274  $$ = PT_EV_COMMIT;
11275 
11276  DBG_PRINT}}
11277  | ROLLBACK
11278  {{
11279 
11280  $$ = PT_EV_ROLLBACK;
11281 
11282  DBG_PRINT}}
11283  ;
11284 
11285 event_target
11286  : ON_ identifier '(' identifier ')'
11287  {{
11288 
11289  PT_NODE *node = parser_new_node (this_parser, PT_EVENT_TARGET);
11290 
11291  if (node)
11292  {
11293  node->info.event_target.class_name = $2;
11294  node->info.event_target.attribute = $4;
11295  }
11296 
11297  $$ = node;
11298  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
11299 
11300  DBG_PRINT}}
11301  | ON_ identifier
11302  {{
11303 
11304  PT_NODE *node = parser_new_node (this_parser, PT_EVENT_TARGET);
11305 
11306  if (node)
11307  {
11308  node->info.event_target.class_name = $2;
11309  }
11310 
11311  $$ = node;
11312  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
11313 
11314  DBG_PRINT}}
11315  ;
11316 
11317 trigger_condition
11318  : search_condition
11319  {{
11320 
11321  $$ = $1;
11322  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
11323 
11324  DBG_PRINT}}
11325  | call_stmt
11326  {{
11327 
11328  $$ = $1;
11329  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
11330 
11331  DBG_PRINT}}
11332  ;
11333 
11334 trigger_action
11335  : REJECT_
11336  {{
11337 
11338  PT_NODE *node = parser_new_node (this_parser, PT_TRIGGER_ACTION);
11339 
11340  if (node)
11341  {
11342  node->info.trigger_action.action_type = PT_REJECT;
11343  }
11344 
11345  $$ = node;
11346  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
11347 
11348  DBG_PRINT}}
11349  | INVALIDATE TRANSACTION
11350  {{
11351 
11352  PT_NODE *node = parser_new_node (this_parser, PT_TRIGGER_ACTION);
11353 
11354  if (node)
11355  {
11356  node->info.trigger_action.action_type = PT_INVALIDATE_XACTION;
11357  }
11358 
11359  $$ = node;
11360  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
11361 
11362  DBG_PRINT}}
11363  | PRINT char_string_literal
11364  {{
11365 
11366  PT_NODE *node = parser_new_node (this_parser, PT_TRIGGER_ACTION);
11367 
11368  if (node)
11369  {
11370  node->info.trigger_action.action_type = PT_PRINT;
11371  node->info.trigger_action.string = $2;
11372  }
11373 
11374  $$ = node;
11375  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
11376 
11377  DBG_PRINT}}
11378  | evaluate_stmt
11379  {{
11380 
11381  PT_NODE *node = parser_new_node (this_parser, PT_TRIGGER_ACTION);
11382 
11383  if (node)
11384  {
11385  node->info.trigger_action.action_type = PT_EXPRESSION;
11386  node->info.trigger_action.expression = $1;
11387  }
11388 
11389  $$ = node;
11390  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
11391 
11392  DBG_PRINT}}
11393  | insert_or_replace_stmt
11394  {{
11395 
11396  PT_NODE *node = parser_new_node (this_parser, PT_TRIGGER_ACTION);
11397 
11398  if (node)
11399  {
11400  node->info.trigger_action.action_type = PT_EXPRESSION;
11401  node->info.trigger_action.expression = $1;
11402  }
11403 
11404  $$ = node;
11405  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
11406 
11407  DBG_PRINT}}
11408  | update_stmt
11409  {{
11410 
11411  PT_NODE *node = parser_new_node (this_parser, PT_TRIGGER_ACTION);
11412 
11413  if (node)
11414  {
11415  node->info.trigger_action.action_type = PT_EXPRESSION;
11416  node->info.trigger_action.expression = $1;
11417  }
11418 
11419  $$ = node;
11420  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
11421 
11422  DBG_PRINT}}
11423  | delete_stmt
11424  {{
11425 
11426  PT_NODE *node = parser_new_node (this_parser, PT_TRIGGER_ACTION);
11427 
11428  if (node)
11429  {
11430  node->info.trigger_action.action_type = PT_EXPRESSION;
11431  node->info.trigger_action.expression = $1;
11432  }
11433 
11434  $$ = node;
11435  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
11436 
11437  DBG_PRINT}}
11438  | call_stmt
11439  {{
11440 
11441  PT_NODE *node = parser_new_node (this_parser, PT_TRIGGER_ACTION);
11442 
11443  if (node)
11444  {
11445  node->info.trigger_action.action_type = PT_EXPRESSION;
11446  node->info.trigger_action.expression = $1;
11447  }
11448 
11449  $$ = node;
11450  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
11451 
11452  DBG_PRINT}}
11453  | merge_stmt
11454  {{
11455 
11456  PT_NODE *node = parser_new_node (this_parser, PT_TRIGGER_ACTION);
11457 
11458  if (node)
11459  {
11460  node->info.trigger_action.action_type = PT_EXPRESSION;
11461  node->info.trigger_action.expression = $1;
11462  }
11463 
11464  $$ = node;
11465  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
11466 
11467  DBG_PRINT}}
11468  ;
11469 
11470 trigger_spec_list
11471  : identifier_list
11472  {{
11473 
11474  PT_NODE *node = parser_new_node (this_parser, PT_TRIGGER_SPEC_LIST);
11475 
11476  if (node)
11477  {
11478  node->info.trigger_spec_list.trigger_name_list = $1;
11479  }
11480 
11481  $$ = node;
11482  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
11483 
11484  DBG_PRINT}}
11485  | ALL TRIGGERS
11486  {{
11487 
11488  PT_NODE *node = parser_new_node (this_parser, PT_TRIGGER_SPEC_LIST);
11489 
11490  if (node)
11491  {
11492  node->info.trigger_spec_list.all_triggers = 1;
11493  }
11494 
11495  $$ = node;
11496  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
11497 
11498  DBG_PRINT}}
11499  ;
11500 
11501 trigger_status_or_priority_or_change_owner
11502  : trigger_status
11503  {{
11504 
11505  container_3 ctn;
11506  SET_CONTAINER_3 (ctn, FROM_NUMBER ($1), NULL, NULL);
11507  $$ = ctn;
11508 
11509  DBG_PRINT}}
11510  | trigger_priority
11511  {{
11512 
11513  container_3 ctn;
11514  SET_CONTAINER_3 (ctn, FROM_NUMBER (PT_MISC_DUMMY), $1, NULL);
11515  $$ = ctn;
11516 
11517  DBG_PRINT}}
11518  | OWNER TO identifier
11519  {{
11520 
11521  container_3 ctn;
11522  SET_CONTAINER_3 (ctn, FROM_NUMBER (PT_MISC_DUMMY), NULL, $3);
11523  $$ = ctn;
11524 
11525  DBG_PRINT}}
11526  ;
11527 
11528 opt_maximum
11529  : /* empty */
11530  | MAXIMUM
11531  ;
11532 
11533 trace_spec
11534  : ON_
11535  {{
11536 
11537  PT_NODE *node = parser_new_node (this_parser, PT_VALUE);
11538 
11539  if (node)
11540  {
11541  node->info.value.data_value.i = -1;
11542  node->type_enum = PT_TYPE_INTEGER;
11543  }
11544 
11545  $$ = node;
11546  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
11547 
11548  DBG_PRINT}}
11549  | OFF_
11550  {{
11551 
11552  PT_NODE *node = parser_new_node (this_parser, PT_VALUE);
11553 
11554  if (node)
11555  {
11556  node->info.value.data_value.i = 0;
11557  node->type_enum = PT_TYPE_INTEGER;
11558  }
11559 
11560  $$ = node;
11561  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
11562 
11563  DBG_PRINT}}
11564  | unsigned_integer
11565  {{
11566 
11567  $$ = $1;
11568  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
11569 
11570  DBG_PRINT}}
11571  | param_
11572  {{
11573 
11574  $$ = $1;
11575  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
11576 
11577  DBG_PRINT}}
11578  | host_param_input
11579  {{
11580 
11581  $$ = $1;
11582  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
11583 
11584  DBG_PRINT}}
11585  ;
11586 
11587 depth_spec
11588  : unsigned_integer
11589  {{
11590 
11591  $$ = $1;
11592  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
11593 
11594  DBG_PRINT}}
11595  | param_
11596  {{
11597 
11598  $$ = $1;
11599  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
11600 
11601  DBG_PRINT}}
11602  | host_param_input
11603  {{
11604 
11605  $$ = $1;
11606  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
11607 
11608  DBG_PRINT}}
11609  ;
11610 
11611 serial_start
11612  : START_ WITH integer_text
11613  {{
11614 
11615  PT_NODE *node = parser_new_node (this_parser, PT_VALUE);
11616  if (node)
11617  {
11618  node->info.value.data_value.str =
11619  pt_append_bytes (this_parser, NULL, $3,
11620  strlen ($3));
11621  node->type_enum = PT_TYPE_NUMERIC;
11622  PT_NODE_PRINT_VALUE_TO_TEXT (this_parser, node);
11623  }
11624 
11625  $$ = node;
11626  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
11627 
11628  DBG_PRINT}}
11629  ;
11630 
11631 serial_increment
11632  : INCREMENT BY integer_text
11633  {{
11634 
11635  PT_NODE *node = parser_new_node (this_parser, PT_VALUE);
11636  if (node)
11637  {
11638  node->info.value.data_value.str =
11639  pt_append_bytes (this_parser, NULL, $3,
11640  strlen ($3));
11641  node->type_enum = PT_TYPE_NUMERIC;
11642  PT_NODE_PRINT_VALUE_TO_TEXT (this_parser, node);
11643  }
11644 
11645  $$ = node;
11646  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
11647 
11648  DBG_PRINT}}
11649  ;
11650 
11651 
11652 serial_min
11653  : MINVALUE integer_text
11654  {{
11655 
11656  container_2 ctn;
11657  PT_NODE *node = parser_new_node (this_parser, PT_VALUE);
11658  if (node)
11659  {
11660  node->info.value.data_value.str =
11661  pt_append_bytes (this_parser, NULL, $2,
11662  strlen ($2));
11663  node->type_enum = PT_TYPE_NUMERIC;
11664  PT_NODE_PRINT_VALUE_TO_TEXT (this_parser, node);
11665  }
11666 
11667  SET_CONTAINER_2 (ctn, node, FROM_NUMBER (0));
11668  $$ = ctn;
11669 
11670  DBG_PRINT}}
11671  | NOMINVALUE
11672  {{
11673 
11674  container_2 ctn;
11675  SET_CONTAINER_2 (ctn, NULL, FROM_NUMBER (1));
11676  $$ = ctn;
11677 
11678  DBG_PRINT}}
11679  ;
11680 
11681 serial_max
11682  : MAXVALUE integer_text
11683  {{
11684 
11685  container_2 ctn;
11686  PT_NODE *node = parser_new_node (this_parser, PT_VALUE);
11687  if (node)
11688  {
11689  node->info.value.data_value.str =
11690  pt_append_bytes (this_parser, NULL, $2,
11691  strlen ($2));
11692  node->type_enum = PT_TYPE_NUMERIC;
11693  PT_NODE_PRINT_VALUE_TO_TEXT (this_parser, node);
11694  }
11695 
11696  SET_CONTAINER_2 (ctn, node, FROM_NUMBER (0));
11697  $$ = ctn;
11698 
11699  DBG_PRINT}}
11700  | NOMAXVALUE
11701  {{
11702 
11703  container_2 ctn;
11704  SET_CONTAINER_2 (ctn, NULL, FROM_NUMBER (1));
11705  $$ = ctn;
11706 
11707  DBG_PRINT}}
11708  ;
11709 
11710 of_cycle_nocycle
11711  : CYCLE
11712  {{
11713 
11714  container_2 ctn;
11715  SET_CONTAINER_2 (ctn, FROM_NUMBER (1), FROM_NUMBER (0));
11716  $$ = ctn;
11717 
11718  DBG_PRINT}}
11719  | NOCYCLE
11720  {{
11721 
11722  container_2 ctn;
11723  SET_CONTAINER_2 (ctn, FROM_NUMBER (0), FROM_NUMBER (1));
11724  $$ = ctn;
11725 
11726  DBG_PRINT}}
11727  ;
11728 
11729 of_cached_num
11730  : CACHE unsigned_int32
11731  {{
11732 
11733  container_2 ctn;
11734  SET_CONTAINER_2 (ctn, $2, FROM_NUMBER (0));
11735  $$ = ctn;
11736 
11737  DBG_PRINT}}
11738  | NOCACHE
11739  {{
11740  container_2 ctn;
11741  SET_CONTAINER_2 (ctn, NULL, FROM_NUMBER (1));
11742  $$ = ctn;
11743 
11744  DBG_PRINT}}
11745  ;
11746 
11747 integer_text
11748  : opt_plus UNSIGNED_INTEGER
11749  {{
11750 
11751  $$ = $2;
11752 
11753  DBG_PRINT}}
11754  | '-' UNSIGNED_INTEGER
11755  {{
11756 
11757  $$ = pt_append_string (this_parser, (char *) "-", $2);
11758 
11759  DBG_PRINT}}
11760  ;
11761 
11762 uint_text
11763  : UNSIGNED_INTEGER
11764  {{
11765 
11766  $$ = $1;
11767 
11768  DBG_PRINT}}
11769  ;
11770 
11771 opt_plus
11772  : /* empty */
11773  | '+'
11774  ;
11775 
11776 opt_of_data_type_cursor
11777  : /* empty */
11778  {{
11779 
11780  $$ = PT_TYPE_NONE;
11781 
11782  DBG_PRINT}}
11783  | data_type
11784  {{
11785 
11786  $$ = (int) TO_NUMBER (CONTAINER_AT_0 ($1));
11787 
11788  DBG_PRINT}}
11789  | CURSOR
11790  {{
11791 
11792  $$ = PT_TYPE_RESULTSET;
11793 
11794  DBG_PRINT}}
11795  ;
11796 
11797 opt_of_is_as
11798  : /* empty */
11799  | IS
11800  | AS
11801  ;
11802 
11803 opt_sp_param_list
11804  : /* empty */
11805  {{
11806 
11807  $$ = NULL;
11808 
11809  DBG_PRINT}}
11810  | sp_param_list
11811  {{
11812 
11813  $$ = $1;
11814  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
11815 
11816  DBG_PRINT}}
11817  ;
11818 
11819 sp_param_list
11820  : sp_param_list ',' sp_param_def
11821  {{
11822 
11823  $$ = parser_make_link ($1, $3);
11824  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
11825 
11826  DBG_PRINT}}
11827  | sp_param_def
11828  {{
11829 
11830  $$ = $1;
11831  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
11832 
11833  DBG_PRINT}}
11834  ;
11835 
11836 sp_param_def
11837  : identifier
11838  opt_sp_in_out
11839  data_type
11840  opt_comment_spec
11841  {{
11842 
11843  PT_NODE *node = parser_new_node (this_parser, PT_SP_PARAMETERS);
11844 
11845  if (node)
11846  {
11847  node->type_enum = TO_NUMBER (CONTAINER_AT_0 ($3));
11848  node->data_type = CONTAINER_AT_1 ($3);
11849  node->info.sp_param.name = $1;
11850  node->info.sp_param.mode = $2;
11851  node->info.sp_param.comment = $4;
11852  }
11853 
11854  $$ = node;
11855  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
11856 
11857  DBG_PRINT}}
11858  | identifier
11859  opt_sp_in_out
11860  CURSOR
11861  opt_comment_spec
11862  {{
11863 
11864  PT_NODE *node = parser_new_node (this_parser, PT_SP_PARAMETERS);
11865 
11866  if (node)
11867  {
11868  node->type_enum = PT_TYPE_RESULTSET;
11869  node->data_type = NULL;
11870  node->info.sp_param.name = $1;
11871  node->info.sp_param.mode = $2;
11872  node->info.sp_param.comment = $4;
11873  }
11874 
11875  $$ = node;
11876  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
11877 
11878  DBG_PRINT}}
11879  ;
11880 
11881 opt_sp_in_out
11882  : opt_in_out
11883  {{
11884 
11885  $$ = $1;
11886 
11887  DBG_PRINT}}
11888  | IN_ OUT_
11889  {{
11890 
11891  $$ = PT_INPUTOUTPUT;
11892 
11893  DBG_PRINT}}
11894  ;
11895 
11896 esql_query_stmt
11897  : { parser_select_level++; }
11898  csql_query_select_has_no_with_clause
11899  {{
11900  $$ = $2;
11901  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
11902  parser_select_level--;
11903 
11904  DBG_PRINT}}
11905  ;
11906 
11907 csql_query
11908  :
11909  {{
11910 
11911  parser_save_and_set_cannot_cache (false);
11912  parser_save_and_set_ic (0);
11913  parser_save_and_set_gc (0);
11914  parser_save_and_set_oc (0);
11915  parser_save_and_set_wjc (0);
11916  parser_save_and_set_sysc (0);
11917  parser_save_and_set_prc (0);
11918  parser_save_and_set_cbrc (0);
11919  parser_save_and_set_serc (1);
11920  parser_save_and_set_sqc (1);
11921  parser_save_and_set_pseudoc (1);
11922 
11923  DBG_PRINT}}
11924  select_expression_opt_with
11925  {{
11926 
11927  PT_NODE *node = $2;
11928  parser_push_orderby_node (node);
11929 
11930  DBG_PRINT}}
11931  opt_orderby_clause
11932  {{
11933 
11934  PT_NODE *node = parser_pop_orderby_node ();
11935 
11936  if (node && parser_cannot_cache)
11937  {
11938  node->info.query.flag.reexecute = 1;
11939  node->info.query.flag.do_cache = 0;
11940  node->info.query.flag.do_not_cache = 1;
11941  }
11942 
11943  parser_restore_cannot_cache ();
11944  parser_restore_ic ();
11945  parser_restore_gc ();
11946  parser_restore_oc ();
11947  parser_restore_wjc ();
11948  parser_restore_sysc ();
11949  parser_restore_prc ();
11950  parser_restore_cbrc ();
11951  parser_restore_serc ();
11952  parser_restore_sqc ();
11953  parser_restore_pseudoc ();
11954 
11955  if (parser_subquery_check == 0)
11956  PT_ERRORmf(this_parser, pt_top(this_parser),
11957  MSGCAT_SET_PARSER_SEMANTIC,
11958  MSGCAT_SEMANTIC_NOT_ALLOWED_HERE, "Subquery");
11959 
11960  if (node)
11961  {
11962  /* handle ORDER BY NULL */
11963  PT_NODE *order = node->info.query.order_by;
11964  if (order && order->info.sort_spec.expr
11965  && order->info.sort_spec.expr->node_type == PT_VALUE
11966  && order->info.sort_spec.expr->type_enum == PT_TYPE_NULL)
11967  {
11968  if (!node->info.query.q.select.group_by)
11969  {
11970  PT_ERRORm (this_parser, node, MSGCAT_SET_PARSER_SEMANTIC,
11971  MSGCAT_SEMANTIC_ORDERBYNULL_REQUIRES_GROUPBY);
11972  }
11973  else
11974  {
11975  parser_free_tree (this_parser, node->info.query.order_by);
11976  node->info.query.order_by = NULL;
11977  }
11978  }
11979  }
11980 
11981  parser_push_orderby_node (node);
11982 
11983  DBG_PRINT}}
11984  opt_select_limit_clause
11985  opt_for_update_clause
11986  {{
11987 
11988  PT_NODE *node = parser_pop_orderby_node ();
11989  $$ = node;
11990  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
11991 
11992  DBG_PRINT}}
11993  ;
11994 
11995 csql_query_select_has_no_with_clause
11996  :
11997  {{
11998 
11999  parser_save_and_set_cannot_cache (false);
12000  parser_save_and_set_ic (0);
12001  parser_save_and_set_gc (0);
12002  parser_save_and_set_oc (0);
12003  parser_save_and_set_wjc (0);
12004  parser_save_and_set_sysc (0);
12005  parser_save_and_set_prc (0);
12006  parser_save_and_set_cbrc (0);
12007  parser_save_and_set_serc (1);
12008  parser_save_and_set_sqc (1);
12009  parser_save_and_set_pseudoc (1);
12010 
12011  DBG_PRINT}}
12012  select_expression
12013  {{
12014 
12015  PT_NODE *node = $2;
12016  parser_push_orderby_node (node);
12017 
12018  DBG_PRINT}}
12019  opt_orderby_clause
12020  {{
12021 
12022  PT_NODE *node = parser_pop_orderby_node ();
12023 
12024  if (node && parser_cannot_cache)
12025  {
12026  node->info.query.flag.reexecute = 1;
12027  node->info.query.flag.do_cache = 0;
12028  node->info.query.flag.do_not_cache = 1;
12029  }
12030 
12031  parser_restore_cannot_cache ();
12032  parser_restore_ic ();
12033  parser_restore_gc ();
12034  parser_restore_oc ();
12035  parser_restore_wjc ();
12036  parser_restore_sysc ();
12037  parser_restore_prc ();
12038  parser_restore_cbrc ();
12039  parser_restore_serc ();
12040  parser_restore_sqc ();
12041  parser_restore_pseudoc ();
12042 
12043  if (parser_subquery_check == 0)
12044  PT_ERRORmf(this_parser, pt_top(this_parser),
12045  MSGCAT_SET_PARSER_SEMANTIC,
12046  MSGCAT_SEMANTIC_NOT_ALLOWED_HERE, "Subquery");
12047 
12048  if (node)
12049  {
12050  /* handle ORDER BY NULL */
12051  PT_NODE *order = node->info.query.order_by;
12052  if (order && order->info.sort_spec.expr
12053  && order->info.sort_spec.expr->node_type == PT_VALUE
12054  && order->info.sort_spec.expr->type_enum == PT_TYPE_NULL)
12055  {
12056  if (!node->info.query.q.select.group_by)
12057  {
12058  PT_ERRORm (this_parser, node, MSGCAT_SET_PARSER_SEMANTIC,
12059  MSGCAT_SEMANTIC_ORDERBYNULL_REQUIRES_GROUPBY);
12060  }
12061  else
12062  {
12063  parser_free_tree (this_parser, node->info.query.order_by);
12064  node->info.query.order_by = NULL;
12065  }
12066  }
12067  }
12068 
12069  parser_push_orderby_node (node);
12070 
12071  DBG_PRINT}}
12072  opt_select_limit_clause
12073  opt_for_update_clause
12074  {{
12075 
12076  PT_NODE *node = parser_pop_orderby_node ();
12077  $$ = node;
12078  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
12079 
12080  DBG_PRINT}}
12081  ;
12082 
12083 csql_query_without_subquery_and_with_clause
12084  :
12085  {{
12086 
12087  parser_save_and_set_cannot_cache (false);
12088  parser_save_and_set_ic (0);
12089  parser_save_and_set_gc (0);
12090  parser_save_and_set_oc (0);
12091  parser_save_and_set_wjc (0);
12092  parser_save_and_set_sysc (0);
12093  parser_save_and_set_prc (0);
12094  parser_save_and_set_cbrc (0);
12095  parser_save_and_set_serc (1);
12096  parser_save_and_set_sqc (1);
12097  parser_save_and_set_pseudoc (1);
12098 
12099  DBG_PRINT}}
12100  select_expression_without_subquery
12101  {{
12102 
12103  PT_NODE *node = $2;
12104  parser_push_orderby_node (node);
12105 
12106  DBG_PRINT}}
12107  opt_orderby_clause
12108  {{
12109 
12110  PT_NODE *node = parser_pop_orderby_node ();
12111 
12112  if (node && parser_cannot_cache)
12113  {
12114  node->info.query.flag.reexecute = 1;
12115  node->info.query.flag.do_cache = 0;
12116  node->info.query.flag.do_not_cache = 1;
12117  }
12118 
12119  parser_restore_cannot_cache ();
12120  parser_restore_ic ();
12121  parser_restore_gc ();
12122  parser_restore_oc ();
12123  parser_restore_wjc ();
12124  parser_restore_sysc ();
12125  parser_restore_prc ();
12126  parser_restore_cbrc ();
12127  parser_restore_serc ();
12128  parser_restore_sqc ();
12129  parser_restore_pseudoc ();
12130 
12131  if (parser_subquery_check == 0)
12132  PT_ERRORmf(this_parser, pt_top(this_parser),
12133  MSGCAT_SET_PARSER_SEMANTIC,
12134  MSGCAT_SEMANTIC_NOT_ALLOWED_HERE, "Subquery");
12135 
12136  if (node)
12137  {
12138  /* handle ORDER BY NULL */
12139  PT_NODE *order = node->info.query.order_by;
12140  if (order && order->info.sort_spec.expr
12141  && order->info.sort_spec.expr->node_type == PT_VALUE
12142  && order->info.sort_spec.expr->type_enum == PT_TYPE_NULL)
12143  {
12144  if (!node->info.query.q.select.group_by)
12145  {
12146  PT_ERRORm (this_parser, node, MSGCAT_SET_PARSER_SEMANTIC,
12147  MSGCAT_SEMANTIC_ORDERBYNULL_REQUIRES_GROUPBY);
12148  }
12149  else
12150  {
12151  parser_free_tree (this_parser, node->info.query.order_by);
12152  node->info.query.order_by = NULL;
12153  }
12154  }
12155  }
12156 
12157  parser_push_orderby_node (node);
12158 
12159  DBG_PRINT}}
12160  opt_select_limit_clause
12161  opt_for_update_clause
12162  {{
12163 
12164  PT_NODE *node = parser_pop_orderby_node ();
12165  $$ = node;
12166  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
12167 
12168  DBG_PRINT}}
12169  ;
12170 
12171 csql_query_without_values_query
12172  :
12173  {{
12174 
12175  parser_save_and_set_cannot_cache (false);
12176  parser_save_and_set_ic (0);
12177  parser_save_and_set_gc (0);
12178  parser_save_and_set_oc (0);
12179  parser_save_and_set_wjc (0);
12180  parser_save_and_set_sysc (0);
12181  parser_save_and_set_prc (0);
12182  parser_save_and_set_cbrc (0);
12183  parser_save_and_set_serc (1);
12184  parser_save_and_set_sqc (1);
12185  parser_save_and_set_pseudoc (1);
12186 
12187  DBG_PRINT}}
12188  select_expression_without_values_query
12189  {{
12190 
12191  PT_NODE *node = $2;
12192  parser_push_orderby_node (node);
12193 
12194  DBG_PRINT}}
12195  opt_orderby_clause
12196  {{
12197 
12198  PT_NODE *node = parser_pop_orderby_node ();
12199 
12200  if (node && parser_cannot_cache)
12201  {
12202  node->info.query.flag.reexecute = 1;
12203  node->info.query.flag.do_cache = 0;
12204  node->info.query.flag.do_not_cache = 1;
12205  }
12206 
12207  parser_restore_cannot_cache ();
12208  parser_restore_ic ();
12209  parser_restore_gc ();
12210  parser_restore_oc ();
12211  parser_restore_wjc ();
12212  parser_restore_sysc ();
12213  parser_restore_prc ();
12214  parser_restore_cbrc ();
12215  parser_restore_serc ();
12216  parser_restore_sqc ();
12217  parser_restore_pseudoc ();
12218 
12219  if (parser_subquery_check == 0)
12220  PT_ERRORmf(this_parser, pt_top(this_parser),
12221  MSGCAT_SET_PARSER_SEMANTIC,
12222  MSGCAT_SEMANTIC_NOT_ALLOWED_HERE, "Subquery");
12223 
12224  if (node)
12225  {
12226  /* handle ORDER BY NULL */
12227  PT_NODE *order = node->info.query.order_by;
12228  if (order && order->info.sort_spec.expr
12229  && order->info.sort_spec.expr->node_type == PT_VALUE
12230  && order->info.sort_spec.expr->type_enum == PT_TYPE_NULL)
12231  {
12232  if (!node->info.query.q.select.group_by)
12233  {
12234  PT_ERRORm (this_parser, node, MSGCAT_SET_PARSER_SEMANTIC,
12235  MSGCAT_SEMANTIC_ORDERBYNULL_REQUIRES_GROUPBY);
12236  }
12237  else
12238  {
12239  parser_free_tree (this_parser, node->info.query.order_by);
12240  node->info.query.order_by = NULL;
12241  }
12242  }
12243  }
12244 
12245  parser_push_orderby_node (node);
12246 
12247  DBG_PRINT}}
12248  opt_select_limit_clause
12249  opt_for_update_clause
12250  {{
12251 
12252  PT_NODE *node = parser_pop_orderby_node ();
12253  $$ = node;
12254  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
12255 
12256  DBG_PRINT}}
12257  ;
12258 
12259 csql_query_without_values_query_no_with_clause
12260  :
12261  {{
12262 
12263  parser_save_and_set_cannot_cache (false);
12264  parser_save_and_set_ic (0);
12265  parser_save_and_set_gc (0);
12266  parser_save_and_set_oc (0);
12267  parser_save_and_set_wjc (0);
12268  parser_save_and_set_sysc (0);
12269  parser_save_and_set_prc (0);
12270  parser_save_and_set_cbrc (0);
12271  parser_save_and_set_serc (1);
12272  parser_save_and_set_sqc (1);
12273  parser_save_and_set_pseudoc (1);
12274 
12275  DBG_PRINT}}
12276  select_expression_without_values_query_no_with_clause
12277  {{
12278 
12279  PT_NODE *node = $2;
12280  parser_push_orderby_node (node);
12281 
12282  DBG_PRINT}}
12283  opt_orderby_clause
12284  {{
12285 
12286  PT_NODE *node = parser_pop_orderby_node ();
12287 
12288  if (node && parser_cannot_cache)
12289  {
12290  node->info.query.flag.reexecute = 1;
12291  node->info.query.flag.do_cache = 0;
12292  node->info.query.flag.do_not_cache = 1;
12293  }
12294 
12295  parser_restore_cannot_cache ();
12296  parser_restore_ic ();
12297  parser_restore_gc ();
12298  parser_restore_oc ();
12299  parser_restore_wjc ();
12300  parser_restore_sysc ();
12301  parser_restore_prc ();
12302  parser_restore_cbrc ();
12303  parser_restore_serc ();
12304  parser_restore_sqc ();
12305  parser_restore_pseudoc ();
12306 
12307  if (parser_subquery_check == 0)
12308  PT_ERRORmf(this_parser, pt_top(this_parser),
12309  MSGCAT_SET_PARSER_SEMANTIC,
12310  MSGCAT_SEMANTIC_NOT_ALLOWED_HERE, "Subquery");
12311 
12312  if (node)
12313  {
12314  /* handle ORDER BY NULL */
12315  PT_NODE *order = node->info.query.order_by;
12316  if (order && order->info.sort_spec.expr
12317  && order->info.sort_spec.expr->node_type == PT_VALUE
12318  && order->info.sort_spec.expr->type_enum == PT_TYPE_NULL)
12319  {
12320  if (!node->info.query.q.select.group_by)
12321  {
12322  PT_ERRORm (this_parser, node, MSGCAT_SET_PARSER_SEMANTIC,
12323  MSGCAT_SEMANTIC_ORDERBYNULL_REQUIRES_GROUPBY);
12324  }
12325  else
12326  {
12327  parser_free_tree (this_parser, node->info.query.order_by);
12328  node->info.query.order_by = NULL;
12329  }
12330  }
12331  }
12332 
12333  parser_push_orderby_node (node);
12334 
12335  DBG_PRINT}}
12336  opt_select_limit_clause
12337  opt_for_update_clause
12338  {{
12339 
12340  PT_NODE *node = parser_pop_orderby_node ();
12341  $$ = node;
12342  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
12343 
12344  DBG_PRINT}}
12345  ;
12346 
12347 csql_query_without_values_and_single_subquery
12348  :
12349  {{
12350 
12351  parser_save_and_set_cannot_cache (false);
12352  parser_save_and_set_ic (0);
12353  parser_save_and_set_gc (0);
12354  parser_save_and_set_oc (0);
12355  parser_save_and_set_wjc (0);
12356  parser_save_and_set_sysc (0);
12357  parser_save_and_set_prc (0);
12358  parser_save_and_set_cbrc (0);
12359  parser_save_and_set_serc (1);
12360  parser_save_and_set_sqc (1);
12361  parser_save_and_set_pseudoc (1);
12362 
12363  DBG_PRINT}}
12364  select_expression_without_values_and_single_subquery
12365  {{
12366 
12367  PT_NODE *node = $2;
12368  parser_push_orderby_node (node);
12369 
12370  DBG_PRINT}}
12371  opt_orderby_clause
12372  {{
12373 
12374  PT_NODE *node = parser_pop_orderby_node ();
12375 
12376  if (node && parser_cannot_cache)
12377  {
12378  node->info.query.flag.reexecute = 1;
12379  node->info.query.flag.do_cache = 0;
12380  node->info.query.flag.do_not_cache = 1;
12381  }
12382 
12383  parser_restore_cannot_cache ();
12384  parser_restore_ic ();
12385  parser_restore_gc ();
12386  parser_restore_oc ();
12387  parser_restore_wjc ();
12388  parser_restore_sysc ();
12389  parser_restore_prc ();
12390  parser_restore_cbrc ();
12391  parser_restore_serc ();
12392  parser_restore_sqc ();
12393  parser_restore_pseudoc ();
12394 
12395  if (parser_subquery_check == 0)
12396  PT_ERRORmf (this_parser, pt_top(this_parser), MSGCAT_SET_PARSER_SEMANTIC,
12397  MSGCAT_SEMANTIC_NOT_ALLOWED_HERE, "Subquery");
12398 
12399  if (node)
12400  {
12401  /* handle ORDER BY NULL */
12402  PT_NODE *order = node->info.query.order_by;
12403  if (order && order->info.sort_spec.expr
12404  && order->info.sort_spec.expr->node_type == PT_VALUE
12405  && order->info.sort_spec.expr->type_enum == PT_TYPE_NULL)
12406  {
12407  if (!node->info.query.q.select.group_by)
12408  {
12409  PT_ERRORm (this_parser, node, MSGCAT_SET_PARSER_SEMANTIC,
12410  MSGCAT_SEMANTIC_ORDERBYNULL_REQUIRES_GROUPBY);
12411  }
12412  else
12413  {
12414  parser_free_tree (this_parser, node->info.query.order_by);
12415  node->info.query.order_by = NULL;
12416  }
12417  }
12418  }
12419 
12420  parser_push_orderby_node (node);
12421 
12422  DBG_PRINT}}
12423  opt_select_limit_clause
12424  opt_for_update_clause
12425  {{
12426 
12427  PT_NODE *node = parser_pop_orderby_node ();
12428  $$ = node;
12429  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
12430 
12431  DBG_PRINT}}
12432  ;
12433 
12434 
12435 select_expression_opt_with
12436  : opt_with_clause
12437  select_expression
12438  {{
12439 
12440  PT_NODE *with_clause = $1;
12441  PT_NODE *stmt = $2;
12442  if (stmt && with_clause)
12443  {
12444  stmt->info.query.with = with_clause;
12445  }
12446 
12447  $$ = stmt;
12448 
12449  DBG_PRINT}}
12450  ;
12451 
12452 select_expression_without_subquery
12453  : select_expression_without_subquery
12454  {{
12455  PT_NODE *node = $1;
12456  parser_push_orderby_node (node);
12457  }}
12458 
12459  opt_orderby_clause
12460  {{
12461 
12462  PT_NODE *node = parser_pop_orderby_node ();
12463 
12464  if (node && parser_cannot_cache)
12465  {
12466  node->info.query.flag.reexecute = 1;
12467  node->info.query.flag.do_cache = 0;
12468  node->info.query.flag.do_not_cache = 1;
12469  }
12470 
12471 
12472  if (parser_subquery_check == 0)
12473  PT_ERRORmf (this_parser, pt_top(this_parser), MSGCAT_SET_PARSER_SEMANTIC,
12474  MSGCAT_SEMANTIC_NOT_ALLOWED_HERE, "Subquery");
12475 
12476  if (node)
12477  {
12478  PT_NODE *order = node->info.query.order_by;
12479  if (order && order->info.sort_spec.expr
12480  && order->info.sort_spec.expr->node_type == PT_VALUE
12481  && order->info.sort_spec.expr->type_enum == PT_TYPE_NULL)
12482  {
12483  if (!node->info.query.q.select.group_by)
12484  {
12485  PT_ERRORm (this_parser, node, MSGCAT_SET_PARSER_SEMANTIC,
12486  MSGCAT_SEMANTIC_ORDERBYNULL_REQUIRES_GROUPBY);
12487  }
12488  else
12489  {
12490  parser_free_tree (this_parser, node->info.query.order_by);
12491  node->info.query.order_by = NULL;
12492  }
12493  }
12494  }
12495 
12496  parser_push_orderby_node (node);
12497 
12498  DBG_PRINT}}
12499 
12500  opt_select_limit_clause
12501  opt_for_update_clause
12502  {{
12503 
12504  PT_NODE *node = parser_pop_orderby_node ();
12505  $<node>$ = node;
12506  PARSER_SAVE_ERR_CONTEXT ($<node>$, @$.buffer_pos)
12507 
12508  DBG_PRINT}}
12509 
12510  table_op select_or_values_query
12511  {{
12512 
12513  PT_NODE *stmt = $8;
12514  PT_NODE *arg1 = $1;
12515 
12516  if (stmt)
12517  {
12518  stmt->info.query.id = (UINTPTR) stmt;
12519  stmt->info.query.q.union_.arg1 = $1;
12520  stmt->info.query.q.union_.arg2 = $9;
12521  stmt->flag.recompile = $1->flag.recompile | $9->flag.recompile;
12522 
12523  if (arg1 != NULL
12524  && arg1->info.query.is_subquery != PT_IS_SUBQUERY
12525  && arg1->info.query.order_by != NULL)
12526  {
12527  PT_ERRORm (this_parser, stmt,
12528  MSGCAT_SET_PARSER_SYNTAX,
12529  MSGCAT_SYNTAX_INVALID_UNION_ORDERBY);
12530  }
12531  }
12532 
12533 
12534  $$ = stmt;
12535  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
12536 
12537  DBG_PRINT}}
12538  | select_or_values_query
12539  {{
12540  $$ = $1;
12541  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
12542 
12543  DBG_PRINT}}
12544  ;
12545 
12546 select_expression
12547  : select_expression
12548  {{
12549  PT_NODE *node = $1;
12550  parser_push_orderby_node (node);
12551  }}
12552  opt_orderby_clause
12553  {{
12554 
12555  PT_NODE *node = parser_pop_orderby_node ();
12556 
12557  if (node && parser_cannot_cache)
12558  {
12559  node->info.query.flag.reexecute = 1;
12560  node->info.query.flag.do_cache = 0;
12561  node->info.query.flag.do_not_cache = 1;
12562  }
12563 
12564 
12565  if (parser_subquery_check == 0)
12566  PT_ERRORmf (this_parser, pt_top(this_parser), MSGCAT_SET_PARSER_SEMANTIC,
12567  MSGCAT_SEMANTIC_NOT_ALLOWED_HERE, "Subquery");
12568 
12569  if (node)
12570  {
12571 
12572  PT_NODE *order = node->info.query.order_by;
12573  if (order && order->info.sort_spec.expr
12574  && order->info.sort_spec.expr->node_type == PT_VALUE
12575  && order->info.sort_spec.expr->type_enum == PT_TYPE_NULL)
12576  {
12577  if (!node->info.query.q.select.group_by)
12578  {
12579  PT_ERRORm (this_parser, node, MSGCAT_SET_PARSER_SEMANTIC,
12580  MSGCAT_SEMANTIC_ORDERBYNULL_REQUIRES_GROUPBY);
12581  }
12582  else
12583  {
12584  parser_free_tree (this_parser, node->info.query.order_by);
12585  node->info.query.order_by = NULL;
12586  }
12587  }
12588  }
12589 
12590  parser_push_orderby_node (node);
12591 
12592  DBG_PRINT}}
12593  opt_select_limit_clause
12594  opt_for_update_clause
12595  {{
12596 
12597  PT_NODE *node = parser_pop_orderby_node ();
12598  $<node>$ = node;
12599  PARSER_SAVE_ERR_CONTEXT ($<node>$, @$.buffer_pos)
12600 
12601  DBG_PRINT}}
12602  table_op select_or_subquery
12603  {{
12604 
12605  PT_NODE *stmt = $8;
12606  PT_NODE *arg1 = $1;
12607 
12608  if (stmt)
12609  {
12610  stmt->info.query.id = (UINTPTR) stmt;
12611  stmt->info.query.q.union_.arg1 = $1;
12612  stmt->info.query.q.union_.arg2 = $9;
12613  stmt->flag.recompile = $1->flag.recompile | $9->flag.recompile;
12614 
12615  if (arg1 != NULL
12616  && arg1->info.query.is_subquery != PT_IS_SUBQUERY
12617  && arg1->info.query.order_by != NULL)
12618  {
12619  PT_ERRORm (this_parser, stmt, MSGCAT_SET_PARSER_SYNTAX,
12620  MSGCAT_SYNTAX_INVALID_UNION_ORDERBY);
12621  }
12622  }
12623 
12624 
12625  $$ = stmt;
12626  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
12627 
12628  DBG_PRINT}}
12629  | select_or_subquery
12630  {{
12631 
12632  $$ = $1;
12633  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
12634 
12635  DBG_PRINT}}
12636  ;
12637 
12638 select_expression_without_values_query
12639  : select_expression_without_values_query
12640  {{
12641  PT_NODE *node = $1;
12642  parser_push_orderby_node (node);
12643  }}
12644  opt_orderby_clause
12645  {{
12646 
12647  PT_NODE *node = parser_pop_orderby_node ();
12648 
12649  if (node && parser_cannot_cache)
12650  {
12651  node->info.query.flag.reexecute = 1;
12652  node->info.query.flag.do_cache = 0;
12653  node->info.query.flag.do_not_cache = 1;
12654  }
12655 
12656  if (parser_subquery_check == 0)
12657  PT_ERRORmf (this_parser, pt_top(this_parser), MSGCAT_SET_PARSER_SEMANTIC,
12658  MSGCAT_SEMANTIC_NOT_ALLOWED_HERE, "Subquery");
12659 
12660  if (node)
12661  {
12662 
12663  PT_NODE *order = node->info.query.order_by;
12664  if (order && order->info.sort_spec.expr
12665  && order->info.sort_spec.expr->node_type == PT_VALUE
12666  && order->info.sort_spec.expr->type_enum == PT_TYPE_NULL)
12667  {
12668  if (!node->info.query.q.select.group_by)
12669  {
12670  PT_ERRORm (this_parser, node, MSGCAT_SET_PARSER_SEMANTIC,
12671  MSGCAT_SEMANTIC_ORDERBYNULL_REQUIRES_GROUPBY);
12672  }
12673  else
12674  {
12675  parser_free_tree (this_parser, node->info.query.order_by);
12676  node->info.query.order_by = NULL;
12677  }
12678  }
12679  }
12680 
12681  parser_push_orderby_node (node);
12682 
12683  DBG_PRINT}}
12684  opt_select_limit_clause
12685  opt_for_update_clause
12686  {{
12687 
12688  PT_NODE *node = parser_pop_orderby_node ();
12689  $<node>$ = node;
12690  PARSER_SAVE_ERR_CONTEXT ($<node>$, @$.buffer_pos)
12691 
12692  DBG_PRINT}}
12693  table_op select_or_subquery_without_values_query
12694  {{
12695 
12696  PT_NODE *stmt = $8;
12697  PT_NODE *arg1 = $1;
12698 
12699  if (stmt)
12700  {
12701  stmt->info.query.id = (UINTPTR) stmt;
12702  stmt->info.query.q.union_.arg1 = $1;
12703  stmt->info.query.q.union_.arg2 = $9;
12704  stmt->flag.recompile = $1->flag.recompile | $9->flag.recompile;
12705 
12706  if (arg1 != NULL
12707  && arg1->info.query.is_subquery != PT_IS_SUBQUERY
12708  && arg1->info.query.order_by != NULL)
12709  {
12710  PT_ERRORm (this_parser, stmt, MSGCAT_SET_PARSER_SYNTAX,
12711  MSGCAT_SYNTAX_INVALID_UNION_ORDERBY);
12712  }
12713  }
12714 
12715 
12716  $$ = stmt;
12717  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
12718 
12719  DBG_PRINT}}
12720  | select_or_subquery_without_values_query
12721  {{
12722 
12723  $$ = $1;
12724  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
12725 
12726  DBG_PRINT}}
12727  ;
12728 
12729 select_expression_without_values_query_no_with_clause
12730  : select_expression_without_values_query_no_with_clause
12731  {{
12732  PT_NODE *node = $1;
12733  parser_push_orderby_node (node);
12734  }}
12735  opt_orderby_clause
12736  {{
12737 
12738  PT_NODE *node = parser_pop_orderby_node ();
12739 
12740  if (node && parser_cannot_cache)
12741  {
12742  node->info.query.flag.reexecute = 1;
12743  node->info.query.flag.do_cache = 0;
12744  node->info.query.flag.do_not_cache = 1;
12745  }
12746 
12747  if (parser_subquery_check == 0)
12748  PT_ERRORmf (this_parser, pt_top(this_parser), MSGCAT_SET_PARSER_SEMANTIC,
12749  MSGCAT_SEMANTIC_NOT_ALLOWED_HERE, "Subquery");
12750 
12751  if (node)
12752  {
12753 
12754  PT_NODE *order = node->info.query.order_by;
12755  if (order && order->info.sort_spec.expr
12756  && order->info.sort_spec.expr->node_type == PT_VALUE
12757  && order->info.sort_spec.expr->type_enum == PT_TYPE_NULL)
12758  {
12759  if (!node->info.query.q.select.group_by)
12760  {
12761  PT_ERRORm (this_parser, node, MSGCAT_SET_PARSER_SEMANTIC,
12762  MSGCAT_SEMANTIC_ORDERBYNULL_REQUIRES_GROUPBY);
12763  }
12764  else
12765  {
12766  parser_free_tree (this_parser, node->info.query.order_by);
12767  node->info.query.order_by = NULL;
12768  }
12769  }
12770  }
12771 
12772  parser_push_orderby_node (node);
12773 
12774  DBG_PRINT}}
12775  opt_select_limit_clause
12776  opt_for_update_clause
12777  {{
12778 
12779  PT_NODE *node = parser_pop_orderby_node ();
12780  $<node>$ = node;
12781  PARSER_SAVE_ERR_CONTEXT ($<node>$, @$.buffer_pos)
12782 
12783  DBG_PRINT}}
12784  table_op select_or_subquery_without_values_query_no_with_clause
12785  {{
12786 
12787  PT_NODE *stmt = $8;
12788  PT_NODE *arg1 = $1;
12789 
12790  if (stmt)
12791  {
12792  stmt->info.query.id = (UINTPTR) stmt;
12793  stmt->info.query.q.union_.arg1 = $1;
12794  stmt->info.query.q.union_.arg2 = $9;
12795  stmt->flag.recompile = $1->flag.recompile | $9->flag.recompile;
12796 
12797  if (arg1 != NULL
12798  && arg1->info.query.is_subquery != PT_IS_SUBQUERY
12799  && arg1->info.query.order_by != NULL)
12800  {
12801  PT_ERRORm (this_parser, stmt, MSGCAT_SET_PARSER_SYNTAX,
12802  MSGCAT_SYNTAX_INVALID_UNION_ORDERBY);
12803  }
12804  }
12805 
12806 
12807  $$ = stmt;
12808  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
12809 
12810  DBG_PRINT}}
12811  | select_or_subquery_without_values_query_no_with_clause
12812  {{
12813 
12814  $$ = $1;
12815  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
12816 
12817  DBG_PRINT}}
12818  ;
12819 
12820 select_expression_without_values_and_single_subquery
12821  : select_expression_without_values_query_no_with_clause
12822  {{
12823  PT_NODE *node = $1;
12824  parser_push_orderby_node (node);
12825  }}
12826  opt_orderby_clause
12827  {{
12828 
12829  PT_NODE *node = parser_pop_orderby_node ();
12830 
12831  if (node && parser_cannot_cache)
12832  {
12833  node->info.query.flag.reexecute = 1;
12834  node->info.query.flag.do_cache = 0;
12835  node->info.query.flag.do_not_cache = 1;
12836  }
12837 
12838 
12839  if (parser_subquery_check == 0)
12840  PT_ERRORmf (this_parser, pt_top(this_parser), MSGCAT_SET_PARSER_SEMANTIC,
12841  MSGCAT_SEMANTIC_NOT_ALLOWED_HERE, "Subquery");
12842 
12843  if (node)
12844  {
12845 
12846  PT_NODE *order = node->info.query.order_by;
12847  if (order && order->info.sort_spec.expr
12848  && order->info.sort_spec.expr->node_type == PT_VALUE
12849  && order->info.sort_spec.expr->type_enum == PT_TYPE_NULL)
12850  {
12851  if (!node->info.query.q.select.group_by)
12852  {
12853  PT_ERRORm (this_parser, node, MSGCAT_SET_PARSER_SEMANTIC,
12854  MSGCAT_SEMANTIC_ORDERBYNULL_REQUIRES_GROUPBY);
12855  }
12856  else
12857  {
12858  parser_free_tree (this_parser, node->info.query.order_by);
12859  node->info.query.order_by = NULL;
12860  }
12861  }
12862  }
12863 
12864  parser_push_orderby_node (node);
12865 
12866  DBG_PRINT}}
12867  opt_select_limit_clause
12868  opt_for_update_clause
12869  {{
12870 
12871  PT_NODE *node = parser_pop_orderby_node ();
12872  $<node>$ = node;
12873  PARSER_SAVE_ERR_CONTEXT ($<node>$, @$.buffer_pos)
12874 
12875  DBG_PRINT}}
12876  table_op select_or_subquery_without_values_query_no_with_clause
12877  {{
12878 
12879  PT_NODE *stmt = $8;
12880  PT_NODE *arg1 = $1;
12881 
12882  if (stmt)
12883  {
12884  stmt->info.query.id = (UINTPTR) stmt;
12885  stmt->info.query.q.union_.arg1 = $1;
12886  stmt->info.query.q.union_.arg2 = $9;
12887  stmt->flag.recompile = $1->flag.recompile | $9->flag.recompile;
12888 
12889  if (arg1 != NULL
12890  && arg1->info.query.is_subquery != PT_IS_SUBQUERY
12891  && arg1->info.query.order_by != NULL)
12892  {
12893  PT_ERRORm (this_parser, stmt, MSGCAT_SET_PARSER_SYNTAX,
12894  MSGCAT_SYNTAX_INVALID_UNION_ORDERBY);
12895  }
12896  }
12897 
12898 
12899  $$ = stmt;
12900  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
12901 
12902  DBG_PRINT}}
12903  | select_or_nested_values_query
12904  {{
12905 
12906  $$ = $1;
12907  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
12908 
12909  DBG_PRINT}}
12910  ;
12911 
12912 table_op
12913  : Union all_distinct
12914  {{
12915  PT_MISC_TYPE isAll = $2;
12916  PT_NODE *node = parser_new_node (this_parser, PT_UNION);
12917  if (node)
12918  {
12919  if (isAll == PT_EMPTY)
12920  isAll = PT_DISTINCT;
12921  node->info.query.all_distinct = isAll;
12922  }
12923 
12924  $$ = node;
12925  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
12926 
12927  DBG_PRINT}}
12928  | DIFFERENCE_ all_distinct
12929  {{
12930 
12931  PT_MISC_TYPE isAll = $2;
12932  PT_NODE *node = parser_new_node (this_parser, PT_DIFFERENCE);
12933  if (node)
12934  {
12935  if (isAll == PT_EMPTY)
12936  isAll = PT_DISTINCT;
12937  node->info.query.all_distinct = isAll;
12938  }
12939 
12940  $$ = node;
12941  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
12942 
12943  DBG_PRINT}}
12944  | EXCEPT all_distinct
12945  {{
12946 
12947  PT_MISC_TYPE isAll = $2;
12948  PT_NODE *node = parser_new_node (this_parser, PT_DIFFERENCE);
12949  if (node)
12950  {
12951  if (isAll == PT_EMPTY)
12952  isAll = PT_DISTINCT;
12953  node->info.query.all_distinct = isAll;
12954  }
12955 
12956  $$ = node;
12957  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
12958 
12959  DBG_PRINT}}
12960  | INTERSECTION all_distinct
12961  {{
12962 
12963  PT_MISC_TYPE isAll = $2;
12964  PT_NODE *node = parser_new_node (this_parser, PT_INTERSECTION);
12965  if (node)
12966  {
12967  if (isAll == PT_EMPTY)
12968  isAll = PT_DISTINCT;
12969  node->info.query.all_distinct = isAll;
12970  }
12971 
12972  $$ = node;
12973  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
12974 
12975  DBG_PRINT}}
12976  | INTERSECT all_distinct
12977  {{
12978 
12979  PT_MISC_TYPE isAll = $2;
12980  PT_NODE *node = parser_new_node (this_parser, PT_INTERSECTION);
12981  if (node)
12982  {
12983  if (isAll == PT_EMPTY)
12984  isAll = PT_DISTINCT;
12985  node->info.query.all_distinct = isAll;
12986  }
12987 
12988  $$ = node;
12989  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
12990 
12991  DBG_PRINT}}
12992  ;
12993 
12994 select_or_subquery
12995  : select_stmt
12996  {{
12997 
12998  $$ = $1;
12999  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
13000 
13001  DBG_PRINT}}
13002  | subquery
13003  {{
13004 
13005  $$ = $1;
13006  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
13007 
13008  DBG_PRINT}}
13009  | values_query
13010  {{
13011  $$ = $1;
13012  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
13013  DBG_PRINT}}
13014  ;
13015 
13016 select_or_values_query
13017  : values_query
13018  {{
13019  $$ = $1;
13020  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
13021  DBG_PRINT}}
13022  | select_stmt
13023  {{
13024 
13025  $$ = $1;
13026  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
13027 
13028  DBG_PRINT}}
13029  ;
13030 
13031 select_or_subquery_without_values_query
13032  : select_stmt
13033  {{
13034 
13035  $$ = $1;
13036  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
13037 
13038  DBG_PRINT}}
13039  | subquery
13040  {{
13041 
13042  $$ = $1;
13043  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
13044 
13045  DBG_PRINT}}
13046  ;
13047 
13048 select_or_subquery_without_values_query_no_with_clause
13049  : select_stmt
13050  {{
13051 
13052  $$ = $1;
13053  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
13054 
13055  DBG_PRINT}}
13056  | subquery_without_subquery_and_with_clause
13057  {{
13058 
13059  $$ = $1;
13060  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
13061 
13062  DBG_PRINT}}
13063  ;
13064 
13065 select_or_nested_values_query
13066  : select_stmt
13067  {{
13068 
13069  $$ = $1;
13070  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
13071 
13072  DBG_PRINT}}
13073  | '(' values_query ')'
13074  {{
13075  $$ = $2;
13076  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
13077  DBG_PRINT}}
13078  ;
13079 
13080 values_query
13081  : of_value_values
13082  {{
13083  PT_NODE *node;
13084  parser_save_found_Oracle_outer ();
13085  if (parser_select_level >= 0)
13086  parser_select_level++;
13087  parser_hidden_incr_list = NULL;
13088 
13089  node = parser_new_node (this_parser, PT_SELECT);
13090 
13091  if (node)
13092  {
13093  PT_SET_VALUE_QUERY(node); /* generated by "values" */
13094  node->info.query.q.select.flavor = PT_USER_SELECT;
13095  node->info.query.q.select.hint = PT_HINT_NONE;
13096  }
13097 
13098  parser_push_select_stmt_node (node);
13099  parser_push_hint_node (node);
13100  DBG_PRINT}}
13101  values_expression
13102  {{
13103  /* $3 node of type PT_NODE_LIST */
13104  PT_NODE *n;
13105  PT_NODE *node = parser_pop_select_stmt_node ();
13106  parser_found_Oracle_outer = false;
13107  parser_pop_hint_node ();
13108 
13109  if (node)
13110  {
13111  n = $3;
13112  node->info.query.q.select.list = n;
13113  node->info.query.into_list = NULL;
13114  node->info.query.id = (UINTPTR)node;
13115  node->info.query.all_distinct = PT_ALL;
13116  }
13117 
13118  /* We don't want to allow subqueries for VALUES query */
13119  if (PT_IS_VALUE_QUERY (node))
13120  {
13121  PT_NODE *node_list, *attrs;
13122 
13123  for (node_list = node->info.query.q.select.list; node_list;
13124  node_list = node_list->next)
13125  {
13126  /* node_list->node_type should be PT_NODE_LIST */
13127  for (attrs = node_list->info.node_list.list; attrs; attrs = attrs->next)
13128  {
13129  if (PT_IS_QUERY (attrs))
13130  {
13131  PT_ERRORmf (this_parser, node, MSGCAT_SET_PARSER_SEMANTIC,
13132  MSGCAT_SEMANTIC_NOT_ALLOWED_HERE, "Subquery");
13133  break;
13134  }
13135  }
13136  }
13137  }
13138 
13139  parser_restore_found_Oracle_outer ();
13140  if (parser_select_level >= 0)
13141  parser_select_level--;
13142 
13143  $$ = node;
13144  DBG_PRINT}}
13145  ;
13146 
13147 values_expression
13148  : values_expression ',' values_expr_item
13149  {{
13150  PT_NODE *node1 = $1;
13151  PT_NODE *node2 = $3;
13152  parser_make_link (node1, node2);
13153 
13154  $$ = node1;
13155  DBG_PRINT}}
13156  | values_expr_item
13157  {{
13158  $$ = $1;
13159  DBG_PRINT}}
13160  ;
13161 
13162 values_expr_item
13163  : '(' alias_enabled_expression_list_top ')'
13164  {{
13165  PT_NODE *node_value = $2;
13166  PT_NODE *node_tmp = $2;
13167  PT_NODE *node = NULL;
13168 
13169  while (node_tmp)
13170  {
13171  PT_SET_VALUE_QUERY(node_tmp);
13172  node_tmp = node_tmp->next;
13173  }
13174 
13175  node = pt_node_list(this_parser, PT_IS_VALUE, node_value);
13176  PT_SET_VALUE_QUERY(node);
13177 
13178  $$ = node;
13179  DBG_PRINT}}
13180  ;
13181 
13182 select_stmt
13183  :
13184  SELECT /* $1 */
13185  {{
13186  /* $2 */
13187  PT_NODE *node;
13188  parser_save_found_Oracle_outer ();
13189  if (parser_select_level >= 0)
13190  parser_select_level++;
13191  parser_hidden_incr_list = NULL;
13192 
13193  node = parser_new_node (this_parser, PT_SELECT);
13194 
13195  if (node)
13196  {
13197  node->info.query.q.select.flavor = PT_USER_SELECT;
13198  node->info.query.q.select.hint = PT_HINT_NONE;
13199  }
13200 
13201  parser_push_select_stmt_node (node);
13202  parser_push_hint_node (node);
13203 
13204  DBG_PRINT}}
13205  opt_hint_list /* $3 */
13206  all_distinct /* $4 */
13207  select_list /* $5 */
13208  opt_select_param_list /* $6 */
13209  {{
13210  /* $7 */
13211  PT_MISC_TYPE isAll = $4;
13212  PT_NODE *node = parser_top_select_stmt_node ();
13213  if (node)
13214  {
13215  if (isAll == PT_EMPTY)
13216  isAll = PT_ALL;
13217  node->info.query.all_distinct = isAll;
13218  node->info.query.q.select.list = $5;
13219  node->info.query.into_list = $6;
13220  if (parser_hidden_incr_list)
13221  {
13222  (void) parser_append_node (parser_hidden_incr_list,
13223  node->info.query.q.select.list);
13224  parser_hidden_incr_list = NULL;
13225  }
13226  }
13227 
13228  }}
13229  opt_from_clause /* $8 */
13230  {{
13231  $$ = $8;
13232  }}
13233  ;
13234 
13235 opt_with_clause
13236  : /* empty */
13237  {{
13238 
13239  $$ = NULL;
13240 
13241  DBG_PRINT}}
13242  | WITH /* $1 */
13243  opt_recursive /* $2 */
13244  cte_definition_list /* $3 */
13245  {{
13246 
13247  PT_NODE *node = parser_new_node (this_parser, PT_WITH_CLAUSE);
13248  if (node)
13249  {
13250  PARSER_SAVE_ERR_CONTEXT (node, @$.buffer_pos)
13251  node->info.with_clause.recursive = $2;
13252  if ($3)
13253  {
13254  node->info.with_clause.cte_definition_list = $3;
13255  }
13256  }
13257 
13258  $$ = node;
13259 
13260  DBG_PRINT}}
13261  ;
13262 
13263 opt_recursive
13264  : /* empty */
13265  {{
13266  $$ = 0;
13267 
13268  DBG_PRINT}}
13269  | RECURSIVE
13270  {{
13271  $$ = 1;
13272 
13273  DBG_PRINT}}
13274  ;
13275 
13276 cte_definition_list
13277  : cte_definition_list ',' cte_definition
13278  {{
13279 
13280  $$ = parser_make_link($1, $3);
13281  PARSER_SAVE_ERR_CONTEXT($$, @$.buffer_pos)
13282 
13283  DBG_PRINT}}
13284  | cte_definition
13285  {{
13286 
13287  $$ = $1;
13288  PARSER_SAVE_ERR_CONTEXT($$, @$.buffer_pos)
13289 
13290  DBG_PRINT}}
13291  ;
13292 
13293 cte_definition
13294  : identifier /* $1 */
13295  opt_bracketed_identifier_list /* $2 */
13296  AS /* $3 */
13297  cte_query_list /* $4 */
13298  {{
13299  PT_NODE *node = parser_new_node (this_parser, PT_CTE);
13300  if (node)
13301  {
13302  PARSER_SAVE_ERR_CONTEXT (node, @$.buffer_pos)
13303  node->info.cte.name = $1;
13304  if ($2)
13305  {
13306  node->info.cte.as_attr_list = $2;
13307  }
13308  node->info.cte.non_recursive_part = $4;
13309  node->info.cte.recursive_part = NULL;
13310  }
13311 
13312  $$ = node;
13313 
13314  DBG_PRINT}}
13315  ;
13316 
13317 cte_query_list
13318  : cte_query_list
13319  table_op
13320  select_or_subquery
13321  {{
13322 
13323  PT_NODE *stmt = $2;
13324  PT_NODE *arg1 = $1, *arg2 = $3;
13325  if (stmt)
13326  {
13327  stmt->info.query.id = (UINTPTR) stmt;
13328  stmt->info.query.q.union_.arg1 = arg1;
13329  stmt->info.query.q.union_.arg2 = arg2;
13330  stmt->flag.recompile = arg1->flag.recompile | arg2->flag.recompile;
13331  }
13332 
13333  $$ = stmt;
13334  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
13335 
13336  DBG_PRINT}}
13337  | select_or_subquery
13338  {{
13339 
13340  $$ = $1;
13341  PARSER_SAVE_ERR_CONTEXT($$, @$.buffer_pos);
13342 
13343  DBG_PRINT}}
13344  ;
13345 
13346 opt_from_clause
13347  : /* empty */
13348  {{
13349 
13350  PT_NODE *n;
13351  PT_NODE *node = parser_pop_select_stmt_node ();
13352  parser_found_Oracle_outer = false;
13353  parser_pop_hint_node ();
13354 
13355  if (node)
13356  {
13357  PARSER_SAVE_ERR_CONTEXT (node, @$.buffer_pos)
13358  n = node->info.query.q.select.list;
13359  if (n && n->type_enum == PT_TYPE_STAR)
13360  {
13361  /* "select *" is not valid, raise an error */
13362  PT_ERRORm (this_parser, node, MSGCAT_SET_PARSER_SEMANTIC,
13363  MSGCAT_SEMANTIC_NO_TABLES_USED);
13364  }
13365 
13366  node->info.query.id = (UINTPTR) node;
13367  node->info.query.all_distinct = PT_ALL;
13368  }
13369 
13370  if (parser_hidden_incr_list)
13371  {
13372  /* if not handle hidden expressions, raise an error */
13373  PT_ERRORf (this_parser, node,
13374  "%s can be used at select or with increment clause only.",
13375  pt_short_print (this_parser, parser_hidden_incr_list));
13376  }
13377 
13378  parser_restore_found_Oracle_outer (); /* restore */
13379  if (parser_select_level >= 0)
13380  parser_select_level--;
13381 
13382  $$ = node;
13383 
13384  DBG_PRINT}}
13385  | FROM /* $1 */
13386  extended_table_spec_list /* $2 */
13387  {{ /* $3 */
13388 
13389  parser_found_Oracle_outer = false;
13390 
13391  DBG_PRINT}}
13392  opt_where_clause /* $4 */
13393  opt_startwith_connectby_clause/* $5 */
13394  opt_groupby_clause /* $6 */
13395  opt_with_rollup /* $7 */
13396  opt_having_clause /* $8 */
13397  opt_using_index_clause /* $9 */
13398  opt_with_increment_clause /* $10 */
13399  {{
13400 
13401  PT_NODE *n;
13402  bool is_dummy_select;
13403  PT_NODE *node = parser_pop_select_stmt_node ();
13404  int with_rollup = $7;
13405  parser_pop_hint_node ();
13406 
13407  is_dummy_select = false;
13408 
13409  if (node)
13410  {
13411  PARSER_SAVE_ERR_CONTEXT (node, @$.buffer_pos)
13412  n = node->info.query.q.select.list;
13413  if (n && n->next == NULL && n->node_type == PT_VALUE
13414  && n->type_enum == PT_TYPE_STAR)
13415  {
13416  /* select * from ... */
13417  is_dummy_select = true; /* Here, guess as TRUE */
13418  }
13419  else if (n && n->next == NULL && n->node_type == PT_NAME
13420  && n->type_enum == PT_TYPE_STAR)
13421  {
13422  /* select A.* from */
13423  is_dummy_select = true; /* Here, guess as TRUE */
13424  }
13425  else
13426  {
13427  is_dummy_select = false; /* not dummy */
13428  }
13429 
13430  if (node->info.query.into_list)
13431  {
13432  is_dummy_select = false; /* not dummy */
13433  }
13434 
13435  node->info.query.q.select.from = n = CONTAINER_AT_0 ($2);
13436  if (n && n->next)
13437  is_dummy_select = false; /* not dummy */
13438  if (TO_NUMBER (CONTAINER_AT_1 ($2)) == 1)
13439  {
13440  PT_SELECT_INFO_SET_FLAG (node, PT_SELECT_INFO_ANSI_JOIN);
13441  }
13442 
13443  node->info.query.q.select.where = n = $4;
13444  if (n)
13445  is_dummy_select = false; /* not dummy */
13446  if (parser_found_Oracle_outer == true)
13447  PT_SELECT_INFO_SET_FLAG (node, PT_SELECT_INFO_ORACLE_OUTER);
13448 
13449  node->info.query.q.select.start_with = n = CONTAINER_AT_0 ($5);
13450  if (n)
13451  is_dummy_select = false; /* not dummy */
13452 
13453  node->info.query.q.select.connect_by = n = CONTAINER_AT_1 ($5);
13454  if (n)
13455  is_dummy_select = false; /* not dummy */
13456 
13457  node->info.query.q.select.group_by = n = $6;
13458  if (n)
13459  is_dummy_select = false; /* not dummy */
13460 
13461  if (with_rollup)
13462  {
13463  if (!node->info.query.q.select.group_by)
13464  {
13465  PT_ERRORm (this_parser, node, MSGCAT_SET_PARSER_SEMANTIC,
13466  MSGCAT_SEMANTIC_WITHROLLUP_REQUIRES_GROUPBY);
13467  }
13468  else
13469  {
13470  node->info.query.q.select.group_by->flag.with_rollup = 1;
13471  }
13472  }
13473 
13474  node->info.query.q.select.having = n = $8;
13475  if (n)
13476  is_dummy_select = false; /* not dummy */
13477 
13478  node->info.query.q.select.using_index =
13479  (node->info.query.q.select.using_index ?
13480  parser_make_link (node->info.query.q.select.using_index, $9) : $9);
13481 
13482  node->info.query.q.select.with_increment = $10;
13483  node->info.query.id = (UINTPTR) node;
13484  }
13485 
13486  if (node->info.query.all_distinct != PT_ALL)
13487  is_dummy_select = false; /* not dummy */
13488  if (is_dummy_select == true)
13489  {
13490  /* mark as dummy */
13491  PT_SELECT_INFO_SET_FLAG (node, PT_SELECT_INFO_DUMMY);
13492  }
13493 
13494  if (parser_hidden_incr_list)
13495  {
13496  /* if not handle hidden expressions, raise an error */
13497  PT_ERRORf (this_parser, node,
13498  "%s can be used at select or with increment clause only.",
13499  pt_short_print (this_parser, parser_hidden_incr_list));
13500  }
13501 
13502  parser_restore_found_Oracle_outer (); /* restore */
13503  if (parser_select_level >= 0)
13504  parser_select_level--;
13505 
13506  $$ = node;
13507 
13508  DBG_PRINT}}
13509  ;
13510 
13511 opt_select_param_list
13512  : /* empty */
13513  {{
13514 
13515  $$ = NULL;
13516 
13517  DBG_PRINT}}
13518  | INTO to_param_list
13519  {{
13520 
13521  $$ = $2;
13522  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
13523 
13524  DBG_PRINT}}
13525  | TO to_param_list
13526  {{
13527 
13528  $$ = $2;
13529  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
13530 
13531  DBG_PRINT}}
13532  ;
13533 
13534 opt_hint_list
13535  : /* empty */
13536  | hint_list
13537  ;
13538 
13539 hint_list
13540  : hint_list CPP_STYLE_HINT
13541  {{
13542 
13543  PT_NODE *node = parser_top_hint_node ();
13544  char *hint_comment = $2;
13545  (void) pt_get_hint (hint_comment, parser_hint_table, node);
13546 
13547  DBG_PRINT}}
13548  | hint_list SQL_STYLE_HINT
13549  {{
13550 
13551  PT_NODE *node = parser_top_hint_node ();
13552  char *hint_comment = $2;
13553  (void) pt_get_hint (hint_comment, parser_hint_table, node);
13554 
13555  DBG_PRINT}}
13556  | hint_list C_STYLE_HINT
13557  {{
13558 
13559  PT_NODE *node = parser_top_hint_node ();
13560  char *hint_comment = $2;
13561  (void) pt_get_hint (hint_comment, parser_hint_table, node);
13562 
13563  DBG_PRINT}}
13564  | CPP_STYLE_HINT
13565  {{
13566 
13567  PT_NODE *node = parser_top_hint_node ();
13568  char *hint_comment = $1;
13569  (void) pt_get_hint (hint_comment, parser_hint_table, node);
13570 
13571  DBG_PRINT}}
13572  | SQL_STYLE_HINT
13573  {{
13574 
13575  PT_NODE *node = parser_top_hint_node ();
13576  char *hint_comment = $1;
13577  (void) pt_get_hint (hint_comment, parser_hint_table, node);
13578 
13579  DBG_PRINT}}
13580  | C_STYLE_HINT
13581  {{
13582 
13583  PT_NODE *node = parser_top_hint_node ();
13584  char *hint_comment = $1;
13585  (void) pt_get_hint (hint_comment, parser_hint_table, node);
13586 
13587  DBG_PRINT}}
13588  ;
13589 
13590 all_distinct
13591  : /* empty */
13592  {{
13593 
13594  $$ = PT_EMPTY;
13595 
13596  DBG_PRINT}}
13597  | ALL
13598  {{
13599 
13600  $$ = PT_ALL;
13601 
13602  DBG_PRINT}}
13603  | DISTINCT
13604  {{
13605 
13606  $$ = PT_DISTINCT;
13607 
13608  DBG_PRINT}}
13609  | UNIQUE
13610  {{
13611 
13612  $$ = PT_DISTINCT;
13613 
13614  DBG_PRINT}}
13615  ;
13616 
13617 select_list
13618  : '*'
13619  {{
13620 
13621  PT_NODE *node = parser_new_node (this_parser, PT_VALUE);
13622  if (node)
13623  node->type_enum = PT_TYPE_STAR;
13624  $$ = node;
13625  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
13626 
13627  DBG_PRINT}}
13628 
13629  | '*' ',' alias_enabled_expression_list_top
13630  {{
13631 
13632  PT_NODE *node = parser_new_node (this_parser, PT_VALUE);
13633  if (node)
13634  node->type_enum = PT_TYPE_STAR;
13635 
13636  $$ = parser_make_link (node, $3);
13637  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
13638 
13639  DBG_PRINT}}
13640 
13641  | alias_enabled_expression_list_top
13642  {{
13643  $$ = $1;
13644  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
13645  DBG_PRINT}}
13646  ;
13647 
13648 alias_enabled_expression_list_top
13649  :
13650  {{
13651 
13652  parser_save_and_set_ic (2);
13653  parser_save_and_set_gc (2);
13654  parser_save_and_set_oc (2);
13655  parser_save_and_set_sysc (1);
13656  parser_save_and_set_prc (1);
13657  parser_save_and_set_cbrc (1);
13658 
13659  DBG_PRINT}}
13660  alias_enabled_expression_list
13661  {{
13662 
13663  $$ = $2;
13664  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
13665  parser_restore_ic ();
13666  parser_restore_gc ();
13667  parser_restore_oc ();
13668  parser_restore_sysc ();
13669  parser_restore_prc ();
13670  parser_restore_cbrc ();
13671 
13672  DBG_PRINT}}
13673  ;
13674 
13675 alias_enabled_expression_list
13676  : alias_enabled_expression_list ',' alias_enabled_expression_
13677  {{
13678 
13679  $$ = parser_make_link ($1, $3);
13680  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
13681 
13682  DBG_PRINT}}
13683  | alias_enabled_expression_
13684  {{
13685 
13686  PT_NODE *node = $1;
13687  if (node != NULL)
13688  {
13689  node->flag.is_alias_enabled_expr = 1;
13690  }
13691  $$ = node;
13692  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
13693 
13694  DBG_PRINT}}
13695  ;
13696 
13697 alias_enabled_expression_
13698  : normal_expression opt_as_identifier %dprec 2
13699  {{
13700 
13701  PT_NODE *subq, *id;
13702  PT_NODE *node = $1;
13703  if (node->node_type == PT_VALUE && node->type_enum == PT_TYPE_EXPR_SET)
13704  {
13705  node->type_enum = PT_TYPE_SEQUENCE; /* for print out */
13706  PT_ERRORf (this_parser, node,
13707  "check syntax at %s, illegal parentheses set expression.",
13708  pt_short_print (this_parser, node));
13709  }
13710  else if (PT_IS_QUERY_NODE_TYPE (node->node_type))
13711  {
13712  /* mark as single tuple query */
13713  node->info.query.flag.single_tuple = 1;
13714 
13715  if ((subq = pt_get_subquery_list (node)) && subq->next)
13716  {
13717  /* illegal multi-column subquery */
13718  PT_ERRORm (this_parser, node, MSGCAT_SET_PARSER_SEMANTIC,
13719  MSGCAT_SEMANTIC_NOT_SINGLE_COL);
13720  }
13721  }
13722 
13723 
13724  id = $2;
13725  if (id && id->node_type == PT_NAME)
13726  {
13727  if (node->type_enum == PT_TYPE_STAR)
13728  {
13729  PT_ERROR (this_parser, id,
13730  "please check syntax after '*', expecting ',' or FROM in select statement.");
13731  }
13732  else
13733  {
13734  node->alias_print = pt_makename (id->info.name.original);
13735  parser_free_node (this_parser, id);
13736  }
13737  }
13738 
13739  $$ = node;
13740  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
13741 
13742  DBG_PRINT}}
13743  | predicate_expression opt_as_identifier %dprec 1
13744  {{
13745 
13746  PT_NODE *id;
13747  PT_NODE *node = $1;
13748 
13749  id = $2;
13750  if (id && id->node_type == PT_NAME)
13751  {
13752  node->alias_print = pt_makename (id->info.name.original);
13753  parser_free_node (this_parser, id);
13754  }
13755 
13756  $$ = node;
13757  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
13758 
13759  DBG_PRINT}}
13760  ;
13761 
13762 expression_list
13763  : expression_queue
13764  {{
13765 
13766  $$ = CONTAINER_AT_0($1);
13767 
13768  DBG_PRINT}}
13769  ;
13770 
13771 expression_queue
13772  : expression_queue ',' expression_
13773  {{
13774  container_2 new_q;
13775 
13776  PT_NODE* q_head = CONTAINER_AT_0($1);
13777  PT_NODE* q_tail = CONTAINER_AT_1($1);
13778  q_tail->next = $3;
13779 
13780  SET_CONTAINER_2(new_q, q_head, $3);
13781  $$ = new_q;
13782  PARSER_SAVE_ERR_CONTEXT (q_head, @$.buffer_pos)
13783 
13784  DBG_PRINT}}
13785  | expression_
13786  {{
13787  container_2 new_q;
13788 
13789  SET_CONTAINER_2(new_q, $1, $1);
13790  $$ = new_q;
13791  PARSER_SAVE_ERR_CONTEXT ($1, @$.buffer_pos)
13792 
13793  DBG_PRINT}}
13794  ;
13795 
13796 to_param_list
13797  : to_param_list ',' to_param
13798  {{
13799 
13800  $$ = parser_make_link ($1, $3);
13801  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
13802 
13803  DBG_PRINT}}
13804  | to_param
13805  {{
13806 
13807  $$ = $1;
13808  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
13809 
13810  DBG_PRINT}}
13811  ;
13812 
13813 to_param
13814  : host_param_output
13815  {{
13816 
13817  $1->info.host_var.var_type = PT_HOST_OUT;
13818  $$ = $1;
13819  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
13820 
13821  DBG_PRINT}}
13822  | param_
13823  {{
13824 
13825  PT_NODE *val = $1;
13826 
13827  if (val)
13828  {
13829  val->info.name.meta_class = PT_PARAMETER;
13830  val->info.name.spec_id = (UINTPTR) val;
13831  val->info.name.resolved = pt_makename ("out parameter");
13832  }
13833 
13834  $$ = val;
13835  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
13836 
13837  DBG_PRINT}}
13838  | identifier
13839  {{
13840 
13841  PT_NODE *val = $1;
13842 
13843  if (val)
13844  {
13845  val->info.name.meta_class = PT_PARAMETER;
13846  val->info.name.spec_id = (UINTPTR) val;
13847  val->info.name.resolved = pt_makename ("out parameter");
13848  }
13849 
13850  $$ = val;
13851  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
13852 
13853  DBG_PRINT}}
13854  ;
13855 
13856 from_param
13857  : host_param_input
13858  {{
13859 
13860  PT_NODE *val = $1;
13861 
13862  if (val)
13863  {
13864  val->info.name.meta_class = PT_PARAMETER;
13865  val->data_type = parser_new_node (this_parser, PT_DATA_TYPE);
13866  }
13867 
13868  $$ = val;
13869  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
13870 
13871  DBG_PRINT}}
13872  | param_
13873  {{
13874 
13875  PT_NODE *val = $1;
13876 
13877  if (val)
13878  {
13879  val->info.name.meta_class = PT_PARAMETER;
13880  val->data_type = parser_new_node (this_parser, PT_DATA_TYPE);
13881  }
13882 
13883  $$ = val;
13884  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
13885 
13886  DBG_PRINT}}
13887  | CLASS identifier
13888  {{
13889 
13890  PT_NODE *val = $2;
13891 
13892  if (val)
13893  {
13894  val->info.name.meta_class = PT_META_CLASS;
13895  val->data_type = parser_new_node (this_parser, PT_DATA_TYPE);
13896  }
13897 
13898  $$ = val;
13899  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
13900 
13901  DBG_PRINT}}
13902  | identifier
13903  {{
13904 
13905  PT_NODE *val = $1;
13906 
13907  if (val)
13908  {
13909  val->info.name.meta_class = PT_PARAMETER;
13910  val->data_type = parser_new_node (this_parser, PT_DATA_TYPE);
13911  }
13912 
13913  $$ = val;
13914  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
13915 
13916  DBG_PRINT}}
13917  ;
13918 
13919 
13920 host_param_input
13921  : '?'
13922  {{
13923 
13924  PT_NODE *node = parser_new_node (this_parser, PT_HOST_VAR);
13925 
13926  if (node)
13927  {
13928  PARSER_SAVE_ERR_CONTEXT (node, @$.buffer_pos)
13929  node->info.host_var.var_type = PT_HOST_IN;
13930  node->info.host_var.str = pt_makename ("?");
13931  node->info.host_var.index = parser_input_host_index++;
13932  }
13933  if (parser_hostvar_check == 0)
13934  {
13935  PT_ERRORmf(this_parser, node, MSGCAT_SET_PARSER_SEMANTIC,
13936  MSGCAT_SEMANTIC_NOT_ALLOWED_HERE, "host variable");
13937  }
13938 
13939  $$ = node;
13940 
13941  DBG_PRINT}}
13942  | PARAM_HEADER uint_text
13943  {{
13944 
13945  PT_NODE *node = parser_new_node (this_parser, PT_HOST_VAR);
13946 
13947  if (node)
13948  {
13949  PARSER_SAVE_ERR_CONTEXT (node, @$.buffer_pos)
13950  node->info.host_var.var_type = PT_HOST_IN;
13951  node->info.host_var.str = pt_makename ("?");
13952  node->info.host_var.index = atol ($2);
13953  if (node->info.host_var.index >= parser_input_host_index)
13954  {
13955  parser_input_host_index = node->info.host_var.index + 1;
13956  }
13957  }
13958  if (parser_hostvar_check == 0)
13959  {
13960  PT_ERRORmf(this_parser, node, MSGCAT_SET_PARSER_SEMANTIC,
13961  MSGCAT_SEMANTIC_NOT_ALLOWED_HERE, "host variable");
13962  }
13963 
13964  $$ = node;
13965 
13966  DBG_PRINT}}
13967  ;
13968 
13969 host_param_output
13970  : '?'
13971  {{
13972 
13973  PT_NODE *node = parser_new_node (this_parser, PT_HOST_VAR);
13974 
13975  if (node)
13976  {
13977  node->info.host_var.var_type = PT_HOST_IN;
13978  node->info.host_var.str = pt_makename ("?");
13979  node->info.host_var.index = parser_output_host_index++;
13980  }
13981 
13982  $$ = node;
13983  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
13984 
13985  DBG_PRINT}}
13986  | PARAM_HEADER uint_text
13987  {{
13988 
13989  PT_NODE *node = parser_new_node (this_parser, PT_HOST_VAR);
13990 
13991  if (parent_parser == NULL)
13992  {
13993  /* This syntax is only permitted at internal statement parsing */
13994  PT_ERRORf (this_parser, node, "check syntax at %s",
13995  parser_print_tree (this_parser, node));
13996  }
13997  else if (node)
13998  {
13999  PARSER_SAVE_ERR_CONTEXT (node, @$.buffer_pos)
14000  node->info.host_var.var_type = PT_HOST_IN;
14001  node->info.host_var.str = pt_makename ("?");
14002  node->info.host_var.index = atol ($2);
14003  if (node->info.host_var.index >= parser_output_host_index)
14004  {
14005  parser_output_host_index = node->info.host_var.index + 1;
14006  }
14007  }
14008 
14009  $$ = node;
14010 
14011  DBG_PRINT}}
14012  ;
14013 
14014 param_
14015  : ':' identifier
14016  {{
14017 
14018  $2->info.name.meta_class = PT_PARAMETER;
14019  $$ = $2;
14020  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
14021 
14022  DBG_PRINT}}
14023  ;
14024 
14025 opt_where_clause
14026  : /* empty */
14027  {{
14028 
14029  $$ = NULL;
14030 
14031  DBG_PRINT}}
14032  | {
14033  parser_save_and_set_ic (1);
14034  assert (parser_prior_check == 0);
14035  assert (parser_connectbyroot_check == 0);
14036  parser_save_and_set_sysc (1);
14037  parser_save_and_set_prc (1);
14038  parser_save_and_set_cbrc (1);
14039  }
14040  WHERE search_condition
14041  {{
14042 
14043  parser_restore_ic ();
14044  parser_restore_sysc ();
14045  parser_restore_prc ();
14046  parser_restore_cbrc ();
14047  $$ = $3;
14048  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
14049 
14050  DBG_PRINT}}
14051  ;
14052 
14053 opt_startwith_connectby_clause
14054  : /* empty */
14055  {{
14056 
14057  container_2 ctn;
14058  SET_CONTAINER_2 (ctn, NULL, NULL);
14059  $$ = ctn;
14060 
14061  DBG_PRINT}}
14062  | startwith_clause connectby_clause
14063  {{
14064 
14065  container_2 ctn;
14066  SET_CONTAINER_2 (ctn, $1, $2);
14067  $$ = ctn;
14068 
14069  DBG_PRINT}}
14070  | connectby_clause startwith_clause
14071  {{
14072 
14073  container_2 ctn;
14074  SET_CONTAINER_2 (ctn, $2, $1);
14075  $$ = ctn;
14076 
14077  DBG_PRINT}}
14078  | connectby_clause
14079  {{
14080 
14081  container_2 ctn;
14082  SET_CONTAINER_2 (ctn, NULL, $1);
14083  $$ = ctn;
14084 
14085  DBG_PRINT}}
14086 
14087 startwith_clause
14088  : {
14089  parser_save_and_set_pseudoc (0);
14090  }
14091  START_ WITH search_condition
14092  {{
14093 
14094  parser_restore_pseudoc ();
14095  $$ = $4;
14096  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
14097 
14098  DBG_PRINT}}
14099  ;
14100 
14101 connectby_clause
14102  : {
14103  parser_save_and_set_prc (1);
14104  parser_save_and_set_serc (0);
14105  parser_save_and_set_pseudoc (1);
14106  parser_save_and_set_sqc (0);
14107  }
14108  CONNECT BY opt_nocycle search_condition
14109  {{
14110 
14111  parser_restore_prc ();
14112  parser_restore_serc ();
14113  parser_restore_pseudoc ();
14114  parser_restore_sqc ();
14115  $$ = $5;
14116  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
14117 
14118  DBG_PRINT}}
14119  ;
14120 
14121 opt_nocycle
14122  : /* empty */
14123  | NOCYCLE
14124  {{
14125 
14126  PT_NODE *node = parser_top_select_stmt_node ();
14127  if (node)
14128  {
14129  node->info.query.q.select.check_cycles =
14130  CONNECT_BY_CYCLES_NONE;
14131  }
14132 
14133  DBG_PRINT}}
14134  ;
14135 
14136 opt_groupby_clause
14137  : /* empty */
14138  {{
14139 
14140  $$ = NULL;
14141 
14142  DBG_PRINT}}
14143  | GROUP_ BY group_spec_list
14144  {{
14145 
14146  $$ = $3;
14147  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
14148 
14149  DBG_PRINT}}
14150  ;
14151 
14152 opt_with_rollup
14153  : /*empty*/
14154  {{
14155 
14156  $$ = 0;
14157 
14158  DBG_PRINT}}
14159  | WITH ROLLUP
14160  {{
14161 
14162  $$ = 1;
14163 
14164  DBG_PRINT}}
14165  ;
14166 
14167 group_spec_list
14168  : group_spec_list ',' group_spec
14169  {{
14170 
14171  $$ = parser_make_link ($1, $3);
14172  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
14173 
14174  DBG_PRINT}}
14175  | group_spec
14176  {{
14177 
14178  $$ = $1;
14179  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
14180 
14181  DBG_PRINT}}
14182  ;
14183 
14184 
14185 // SR +3
14186 group_spec
14187  :
14188  {
14189  parser_groupby_exception = 0;
14190  }
14191  expression_
14192  opt_asc_or_desc /* $3 */
14193  {{
14194 
14195  PT_NODE *node = parser_new_node (this_parser, PT_SORT_SPEC);
14196 
14197  PARSER_SAVE_ERR_CONTEXT (node, @$.buffer_pos)
14198 
14199  switch (parser_groupby_exception)
14200  {
14201  case PT_COUNT:
14202  case PT_OID_ATTR:
14203  case PT_INST_NUM:
14204  case PT_ORDERBY_NUM:
14205  case PT_ROWNUM:
14206  PT_ERROR (this_parser, node,
14207  "expression is not allowed as group by spec");
14208  break;
14209 
14210  case PT_IS_SUBINSERT:
14211  PT_ERROR (this_parser, node,
14212  "insert expression is not allowed as group by spec");
14213  break;
14214 
14215  case PT_IS_SUBQUERY:
14216  PT_ERROR (this_parser, node,
14217  "subquery is not allowed to group as spec");
14218  break;
14219 
14220  case PT_EXPR:
14221  PT_ERROR (this_parser, node,
14222  "search condition is not allowed as group by spec");
14223  break;
14224  }
14225 
14226  if (node)
14227  {
14228  node->info.sort_spec.asc_or_desc = PT_ASC;
14229  node->info.sort_spec.expr = $2;
14230  if ($3)
14231  {
14232  node->info.sort_spec.asc_or_desc = PT_DESC;
14233  }
14234  }
14235 
14236  $$ = node;
14237 
14238  DBG_PRINT}}
14239  ;
14240 
14241 
14242 opt_having_clause
14243  : /* empty */
14244  {{
14245 
14246  $$ = NULL;
14247 
14248  DBG_PRINT}}
14249  | { parser_save_and_set_gc(1); }
14250  HAVING search_condition
14251  {{
14252 
14253  parser_restore_gc ();
14254  $$ = $3;
14255  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
14256 
14257  DBG_PRINT}}
14258  ;
14259 
14260 opt_using_index_clause
14261  : /* empty */
14262  {{
14263 
14264  $$ = NULL;
14265 
14266  DBG_PRINT}}
14267  | USING INDEX index_name_keylimit_list
14268  {{
14269 
14270  $$ = $3;
14271  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
14272 
14273  DBG_PRINT}}
14274  | USING INDEX NONE
14275  {{
14276 
14277  PT_NODE *node = parser_new_node (this_parser, PT_NAME);
14278 
14279  if (node)
14280  {
14281  node->info.name.original = NULL;
14282  node->info.name.resolved = NULL;
14283  node->info.name.meta_class = PT_INDEX_NAME;
14284  node->etc = (void *) PT_IDX_HINT_NONE;
14285  }
14286 
14287  $$ = node;
14288  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
14289 
14290  DBG_PRINT}}
14291  | USING INDEX ALL EXCEPT index_name_list
14292  {{
14293  PT_NODE *curr;
14294  PT_NODE *node = parser_new_node (this_parser, PT_NAME);
14295 
14296  if (node)
14297  {
14298  node->info.name.original = NULL;
14299  node->info.name.resolved = "*";
14300  node->info.name.meta_class = PT_INDEX_NAME;
14301  node->etc = (void *) PT_IDX_HINT_ALL_EXCEPT;
14302  }
14303 
14304  node->next = $5;
14305  curr = node;
14306  for (curr = node; curr; curr = curr->next)
14307  {
14308  if (curr->etc == (void *) PT_IDX_HINT_FORCE)
14309  {
14310  PT_ERRORmf(this_parser, curr, MSGCAT_SET_PARSER_SEMANTIC,
14311  MSGCAT_SEMANTIC_NOT_ALLOWED_HERE, "(+)");
14312  break;
14313  }
14314  else if (curr->etc == (void *) PT_IDX_HINT_IGNORE)
14315  {
14316  PT_ERRORmf(this_parser, curr, MSGCAT_SET_PARSER_SEMANTIC,
14317  MSGCAT_SEMANTIC_NOT_ALLOWED_HERE, "(-)");
14318  break;
14319  }
14320  curr->etc = (void *) PT_IDX_HINT_ALL_EXCEPT;
14321  }
14322 
14323  $$ = node;
14324  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
14325 
14326  DBG_PRINT}}
14327  ;
14328 
14329 index_name_keylimit_list
14330  : index_name_keylimit_list ',' index_name_keylimit
14331  {{
14332 
14333  $$ = parser_make_link ($1, $3);
14334  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
14335 
14336  DBG_PRINT}}
14337  | index_name_keylimit
14338  {{
14339 
14340  $$ = $1;
14341  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
14342 
14343  DBG_PRINT}}
14344  ;
14345 
14346 index_name_list
14347  : index_name_list ',' index_name
14348  {{
14349 
14350  $$ = parser_make_link ($1, $3);
14351  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
14352 
14353  DBG_PRINT}}
14354  | index_name
14355  {{
14356 
14357  $$ = $1;
14358  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
14359 
14360  DBG_PRINT}}
14361  ;
14362 
14363 index_name_keylimit
14364  : index_name KEYLIMIT limit_expr
14365  {{
14366 
14367  PT_NODE *node = $1;
14368  PARSER_SAVE_ERR_CONTEXT (node, @$.buffer_pos)
14369 
14370  if (node)
14371  {
14372  if (node->etc == (void *) PT_IDX_HINT_NONE
14373  || node->etc == (void *) PT_IDX_HINT_CLASS_NONE)
14374  {
14375  PT_ERRORm(this_parser, node, MSGCAT_SET_PARSER_SEMANTIC, MSGCAT_SEMANTIC_KEYLIMIT_INDEX_NONE);
14376  }
14377  else if (node->etc == (void *) PT_IDX_HINT_IGNORE)
14378  {
14379  PT_ERRORmf(this_parser, node, MSGCAT_SET_PARSER_SEMANTIC, MSGCAT_SEMANTIC_NOT_ALLOWED_HERE, "KEYLIMIT");
14380  }
14381  else
14382  {
14383  /* set key limit */
14384  node->info.name.indx_key_limit = $3;
14385  }
14386  }
14387  $$ = node;
14388 
14389  DBG_PRINT}}
14390  | index_name KEYLIMIT limit_expr ',' limit_expr
14391  {{
14392 
14393  PT_NODE *node = $1;
14394  if (node)
14395  {
14396  if (node->etc == (void *) PT_IDX_HINT_NONE
14397  || node->etc == (void *) PT_IDX_HINT_CLASS_NONE)
14398  {
14399  PT_ERRORm(this_parser, node, MSGCAT_SET_PARSER_SEMANTIC, MSGCAT_SEMANTIC_KEYLIMIT_INDEX_NONE);
14400  }
14401  else
14402  {
14403  /* set key limits */
14404  node->info.name.indx_key_limit = $5;
14405  if ($5)
14406  {
14407  ($5)->next = $3;
14408  }
14409  }
14410  }
14411  $$ = node;
14412  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
14413 
14414  DBG_PRINT}}
14415  | index_name
14416  {{
14417 
14418  $$ = $1;
14419  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
14420 
14421  DBG_PRINT}}
14422  ;
14423 
14424 index_name
14425  : class_name paren_plus
14426  {{
14427 
14428  PT_NODE *node = $1;
14429  node->info.name.meta_class = PT_INDEX_NAME;
14430  node->etc = (void *) PT_IDX_HINT_FORCE;
14431  $$ = node;
14432  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
14433 
14434  DBG_PRINT}}
14435  | class_name paren_minus
14436  {{
14437 
14438  PT_NODE *node = $1;
14439  node->info.name.meta_class = PT_INDEX_NAME;
14440  node->etc = (void *) PT_IDX_HINT_IGNORE;
14441  $$ = node;
14442  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
14443 
14444  DBG_PRINT}}
14445  | class_name
14446  {{
14447 
14448  PT_NODE *node = $1;
14449  node->info.name.meta_class = PT_INDEX_NAME;
14450  node->etc = (void *) PT_IDX_HINT_USE;
14451  $$ = node;
14452  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
14453 
14454  DBG_PRINT}}
14455  | identifier DOT NONE
14456  {{
14457 
14458  PT_NODE *node = $1;
14459  node->info.name.meta_class = PT_INDEX_NAME;
14460  node->info.name.resolved = node->info.name.original;
14461  node->info.name.original = NULL;
14462  node->etc = (void *) PT_IDX_HINT_CLASS_NONE;
14463  $$ = node;
14464  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
14465 
14466  DBG_PRINT}}
14467  ;
14468 
14469 opt_with_increment_clause
14470  : /* empty */
14471  {{
14472 
14473  $$ = NULL;
14474 
14475  DBG_PRINT}}
14476  | WITH INCREMENT For incr_arg_name_list__inc
14477  {{
14478 
14479  $$ = $4;
14480  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
14481 
14482  DBG_PRINT}}
14483  | WITH DECREMENT For incr_arg_name_list__dec
14484  {{
14485 
14486  $$ = $4;
14487  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
14488 
14489  DBG_PRINT}}
14490  ;
14491 
14492 opt_for_update_clause
14493  : /* empty */
14494  | For UPDATE
14495  {{
14496 
14497  PT_NODE *node = parser_top_orderby_node ();
14498 
14499  if (node != NULL && node->node_type == PT_SELECT)
14500  {
14501  PT_SELECT_INFO_SET_FLAG(node, PT_SELECT_INFO_FOR_UPDATE);
14502  }
14503  else
14504  {
14505  PT_ERRORm (this_parser, node,
14506  MSGCAT_SET_PARSER_SEMANTIC,
14507  MSGCAT_SEMANTIC_INVALID_USE_FOR_UPDATE_CLAUSE);
14508  }
14509 
14510  $$ = node;
14511  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
14512 
14513  DBG_PRINT}}
14514  | For UPDATE OF class_name_list
14515  {{
14516 
14517  PT_NODE *node = parser_top_orderby_node ();
14518  PT_NODE *names_list = $4;
14519  PT_NODE *node1 = names_list, *node2 = NULL;
14520 
14521  if (node != NULL && node->node_type == PT_SELECT)
14522  {
14523  PT_SELECT_INFO_SET_FLAG(node, PT_SELECT_INFO_FOR_UPDATE);
14524  node->info.query.q.select.for_update = names_list;
14525  for (; node1 != NULL && node2 == NULL; node1 = node1->next)
14526  {
14527  for (node2 = node1->next; node2 != NULL; node2 = node2->next)
14528  {
14529  /* check if search is duplicate of table */
14530  if (!pt_str_compare (node1->info.name.original,
14531  node2->info.name.original, CASE_INSENSITIVE))
14532  {
14533  /* same class found twice in table list */
14534  PT_ERRORmf (this_parser, node2,
14535  MSGCAT_SET_PARSER_SEMANTIC,
14536  MSGCAT_SEMANTIC_DUPLICATE_CLASS_OR_ALIAS,
14537  node2->info.name.original);
14538  break;
14539  }
14540  }
14541  PT_NAME_INFO_SET_FLAG(node1, PT_NAME_FOR_UPDATE);
14542  }
14543  }
14544  else
14545  {
14546  PT_ERRORm (this_parser, node,
14547  MSGCAT_SET_PARSER_SEMANTIC,
14548  MSGCAT_SEMANTIC_INVALID_USE_FOR_UPDATE_CLAUSE);
14549  }
14550 
14551  $$ = node;
14552  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
14553 
14554  DBG_PRINT}}
14555  ;
14556 
14557 incr_arg_name_list__inc
14558  : incr_arg_name_list__inc ',' incr_arg_name__inc
14559  {{
14560 
14561  $$ = parser_make_link ($1, $3);
14562  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
14563 
14564  DBG_PRINT}}
14565  | incr_arg_name__inc
14566  {{
14567 
14568  $$ = $1;
14569  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
14570 
14571  DBG_PRINT}}
14572  ;
14573 
14574 incr_arg_name__inc
14575  : path_expression
14576  {{
14577  PT_NODE *node = $1;
14578 
14579  if (node->node_type == PT_EXPR && node->info.expr.op == PT_INCR)
14580  {
14581  /* do nothing */
14582  }
14583  else if (node->node_type == PT_EXPR && node->info.expr.op == PT_DECR)
14584  {
14585  PT_ERRORf2 (this_parser, node, "%s can be used at 'with %s for'.",
14586  pt_short_print (this_parser, node), "increment");
14587  }
14588  else
14589  {
14590  node = parser_make_expression (this_parser, PT_INCR, $1, NULL, NULL);
14591  node->flag.is_hidden_column = 1;
14592  }
14593 
14594  $$ = node;
14595  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
14596  DBG_PRINT}}
14597  ;
14598 
14599 incr_arg_name_list__dec
14600  : incr_arg_name_list__dec ',' incr_arg_name__dec
14601  {{
14602 
14603  $$ = parser_make_link ($1, $3);
14604  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
14605 
14606  DBG_PRINT}}
14607  | incr_arg_name__dec
14608  {{
14609 
14610  $$ = $1;
14611  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
14612 
14613  DBG_PRINT}}
14614  ;
14615 
14616 incr_arg_name__dec
14617  : path_expression
14618  {{
14619  PT_NODE *node = $1;
14620 
14621  if (node->node_type == PT_EXPR && node->info.expr.op == PT_INCR)
14622  {
14623  PT_ERRORf2 (this_parser, node, "%s can be used at 'with %s for'.",
14624  pt_short_print (this_parser, node), "increment");
14625  }
14626  else if (node->node_type == PT_EXPR && node->info.expr.op == PT_DECR)
14627  {
14628  /* do nothing */
14629  }
14630  else
14631  {
14632  node = parser_make_expression (this_parser, PT_DECR, $1, NULL, NULL);
14633  node->flag.is_hidden_column = 1;
14634  }
14635 
14636  $$ = node;
14637  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
14638  DBG_PRINT}}
14639  ;
14640 
14641 opt_update_orderby_clause
14642  : /* empty */
14643  { $$ = NULL; }
14644  | ORDER BY
14645  sort_spec_list
14646  { parser_save_and_set_oc (1); }
14647  opt_for_search_condition
14648  {{
14649  PT_NODE *stmt = parser_pop_orderby_node ();
14650 
14651  parser_restore_oc ();
14652 
14653  stmt->info.update.order_by = $3;
14654  stmt->info.update.orderby_for = $5;
14655 
14656  $$ = stmt;
14657  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
14658  DBG_PRINT}}
14659  ;
14660 
14661 opt_orderby_clause
14662  : /* empty */
14663  { $$ = NULL; }
14664  | ORDER
14665  opt_siblings
14666  BY
14667  {{
14668  PT_NODE *stmt = parser_top_orderby_node ();
14669 
14670  if (!stmt->info.query.flag.order_siblings)
14671  {
14672  parser_save_and_set_sysc (1);
14673  parser_save_and_set_prc (1);
14674  parser_save_and_set_cbrc (1);
14675  parser_save_and_set_pseudoc (1);
14676  }
14677  else
14678  {
14679  parser_save_and_set_sysc (0);
14680  parser_save_and_set_prc (0);
14681  parser_save_and_set_cbrc (0);
14682  parser_save_and_set_pseudoc (0);
14683  }
14684 
14685  if (stmt && !stmt->info.query.q.select.from)
14686  PT_ERRORmf(this_parser, pt_top(this_parser),
14687  MSGCAT_SET_PARSER_SEMANTIC,
14688  MSGCAT_SEMANTIC_NOT_ALLOWED_HERE, "ORDER BY");
14689 
14690  DBG_PRINT}}
14691  sort_spec_list
14692  {{
14693 
14694  PT_NODE *stmt = parser_top_orderby_node ();
14695 
14696  parser_restore_sysc ();
14697  parser_restore_prc ();
14698  parser_restore_cbrc ();
14699  parser_restore_pseudoc ();
14700  parser_save_and_set_oc (1);
14701 
14702  DBG_PRINT}}
14703  opt_for_search_condition
14704  {{
14705 
14706  PT_NODE *col, *order, *n, *temp, *list = NULL;
14707  PT_NODE *stmt = parser_top_orderby_node ();
14708  bool found_star;
14709  int index_of_col;
14710  char *n_str, *c_str;
14711  bool is_col, is_alias;
14712 
14713  parser_restore_oc ();
14714  if (stmt)
14715  {
14716  stmt->info.query.orderby_for = $7;
14717  /* support for alias in FOR */
14718  n = stmt->info.query.orderby_for;
14719  while (n)
14720  {
14721  resolve_alias_in_expr_node (n, stmt->info.query.q.select.list);
14722  n = n->next;
14723  }
14724  }
14725 
14726  if (stmt)
14727  {
14728  stmt->info.query.order_by = order = $5;
14729  if (order)
14730  { /* not dummy */
14731  PT_SELECT_INFO_CLEAR_FLAG (stmt, PT_SELECT_INFO_DUMMY);
14732  if (pt_is_query (stmt))
14733  {
14734  /* UNION, INTERSECT, DIFFERENCE, SELECT */
14735  temp = stmt;
14736  while (temp)
14737  {
14738  switch (temp->node_type)
14739  {
14740  case PT_SELECT:
14741  goto start_check;
14742  break;
14743  case PT_UNION:
14744  case PT_INTERSECTION:
14745  case PT_DIFFERENCE:
14746  temp = temp->info.query.q.union_.arg1;
14747  break;
14748  default:
14749  temp = NULL;
14750  break;
14751  }
14752  }
14753 
14754  start_check:
14755  if (temp)
14756  {
14757  list = temp->info.query.q.select.list;
14758  }
14759  found_star = false;
14760 
14761  if (list && list->node_type == PT_VALUE
14762  && list->type_enum == PT_TYPE_STAR)
14763  {
14764  /* found "*" */
14765  found_star = true;
14766  }
14767  else
14768  {
14769  for (col = list; col; col = col->next)
14770  {
14771  if (col->node_type == PT_NAME
14772  && col->type_enum == PT_TYPE_STAR)
14773  {
14774  /* found "classname.*" */
14775  found_star = true;
14776  break;
14777  }
14778  }
14779  }
14780 
14781  for (; order; order = order->next)
14782  {
14783  is_alias = false;
14784  is_col = false;
14785 
14786  n = order->info.sort_spec.expr;
14787  if (n == NULL)
14788  {
14789  break;
14790  }
14791 
14792  if (n->node_type == PT_VALUE)
14793  {
14794  continue;
14795  }
14796 
14797  n_str = parser_print_tree (this_parser, n);
14798  if (n_str == NULL)
14799  {
14800  continue;
14801  }
14802 
14803  for (col = list, index_of_col = 1; col;
14804  col = col->next, index_of_col++)
14805  {
14806  c_str = parser_print_tree (this_parser, col);
14807  if (c_str == NULL)
14808  {
14809  continue;
14810  }
14811 
14812  if ((col->alias_print
14813  && intl_identifier_namecmp (n_str, col->alias_print) == 0
14814  && (is_alias = true))
14815  || (intl_identifier_namecmp (n_str, c_str) == 0
14816  && (is_col = true)))
14817  {
14818  if (found_star)
14819  {
14820  temp = parser_copy_tree (this_parser, col);
14821  temp->next = NULL;
14822  }
14823  else
14824  {
14825  temp = parser_new_node (this_parser, PT_VALUE);
14826  if (temp == NULL)
14827  {
14828  break;
14829  }
14830 
14831  temp->type_enum = PT_TYPE_INTEGER;
14832  temp->info.value.data_value.i = index_of_col;
14833  }
14834 
14835  parser_free_node (this_parser, order->info.sort_spec.expr);
14836  order->info.sort_spec.expr = temp;
14837 
14838  if (is_col == true && is_alias == true)
14839  {
14840  /* alias/col name ambiguity, raise error */
14841  PT_ERRORmf (this_parser, order, MSGCAT_SET_PARSER_SEMANTIC,
14842  MSGCAT_SEMANTIC_AMBIGUOUS_COLUMN_IN_ORDERING,
14843  n_str);
14844  break;
14845  }
14846  }
14847  }
14848  }
14849  }
14850  }
14851  }
14852 
14853  $$ = stmt;
14854  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
14855 
14856  DBG_PRINT}}
14857  ;
14858 
14859 opt_siblings
14860  : /* empty */
14861  | SIBLINGS
14862  {{
14863 
14864  PT_NODE *stmt = parser_top_orderby_node ();
14865  stmt->info.query.flag.order_siblings = true;
14866  if (stmt->info.query.q.select.connect_by == NULL)
14867  {
14868  PT_ERRORmf(this_parser, stmt,
14869  MSGCAT_SET_PARSER_SEMANTIC,
14870  MSGCAT_SEMANTIC_NOT_HIERACHICAL_QUERY,
14871  "SIBLINGS");
14872  }
14873 
14874  DBG_PRINT}}
14875  ;
14876 
14877 limit_expr
14878  : limit_expr '+' limit_term
14879  {{
14880  $$ = parser_make_expression (this_parser, PT_PLUS, $1, $3, NULL);
14881  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
14882 
14883  DBG_PRINT}}
14884  | limit_expr '-' limit_term
14885  {{
14886  $$ = parser_make_expression (this_parser, PT_MINUS, $1, $3, NULL);
14887  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
14888 
14889  DBG_PRINT}}
14890  | limit_term
14891  {{
14892  $$ = $1;
14893  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
14894 
14895  DBG_PRINT}}
14896  ;
14897 
14898 limit_term
14899  : limit_term '*' limit_factor
14900  {{
14901  $$ = parser_make_expression (this_parser, PT_TIMES, $1, $3, NULL);
14902  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
14903 
14904  DBG_PRINT}}
14905  | limit_term '/' limit_factor
14906  {{
14907  $$ = parser_make_expression (this_parser, PT_DIVIDE, $1, $3, NULL);
14908  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
14909 
14910  DBG_PRINT}}
14911  | limit_factor
14912  {{
14913  $$ = $1;
14914  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
14915 
14916  DBG_PRINT}}
14917  ;
14918 
14919 limit_factor
14920  : host_param_input
14921  {{
14922 
14923  $$ = $1;
14924  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
14925 
14926  DBG_PRINT}}
14927  | unsigned_integer
14928  {{
14929 
14930  $$ = $1;
14931  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
14932 
14933  DBG_PRINT}}
14934 
14935  | '(' limit_expr ')'
14936  {{
14937  PT_NODE *exp = $2;
14938 
14939  if (exp && exp->node_type == PT_EXPR)
14940  {
14941  exp->info.expr.paren_type = 1;
14942  }
14943 
14944  $$ = exp;
14945  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
14946 
14947  DBG_PRINT}}
14948  ;
14949 
14950 opt_select_limit_clause
14951  : /* empty */
14952  | LIMIT limit_options
14953  {{
14954 
14955  PT_NODE *node = $2;
14956  if (node)
14957  {
14958  if (node->node_type == PT_SELECT)
14959  {
14960  if (!node->info.query.q.select.from)
14961  {
14962  PT_ERRORm (this_parser, node, MSGCAT_SET_PARSER_SEMANTIC,
14963  MSGCAT_SEMANTIC_NO_TABLES_USED);
14964  }
14965 
14966  /* not dummy */
14967  PT_SELECT_INFO_CLEAR_FLAG (node, PT_SELECT_INFO_DUMMY);
14968 
14969  /* For queries that have LIMIT clause don't allow
14970  * inst_num, groupby_num, orderby_num in where, having, for
14971  * respectively.
14972  */
14973  if (node->info.query.q.select.having)
14974  {
14975  bool grbynum_flag = false;
14976  (void) parser_walk_tree (this_parser, node->info.query.q.select.having,
14977  pt_check_groupbynum_pre, NULL,
14978  pt_check_groupbynum_post, &grbynum_flag);
14979  if (grbynum_flag)
14980  {
14981  PT_ERRORmf(this_parser, node->info.query.q.select.having,
14982  MSGCAT_SET_PARSER_SEMANTIC,
14983  MSGCAT_SEMANTIC_NOT_ALLOWED_IN_LIMIT_CLAUSE, "GROUPBY_NUM()");
14984  }
14985  }
14986  if (node->info.query.q.select.where)
14987  {
14988  bool instnum_flag = false;
14989  (void) parser_walk_tree (this_parser, node->info.query.q.select.where,
14990  pt_check_instnum_pre, NULL,
14991  pt_check_instnum_post, &instnum_flag);
14992  if (instnum_flag)
14993  {
14994  PT_ERRORmf(this_parser, node->info.query.q.select.where,
14995  MSGCAT_SET_PARSER_SEMANTIC,
14996  MSGCAT_SEMANTIC_NOT_ALLOWED_IN_LIMIT_CLAUSE, "INST_NUM()/ROWNUM");
14997  }
14998  }
14999  }
15000 
15001  if (node->info.query.orderby_for)
15002  {
15003  bool ordbynum_flag = false;
15004  (void) parser_walk_tree (this_parser, node->info.query.orderby_for,
15005  pt_check_orderbynum_pre, NULL,
15006  pt_check_orderbynum_post, &ordbynum_flag);
15007  if (ordbynum_flag)
15008  {
15009  PT_ERRORmf(this_parser, node->info.query.orderby_for,
15010  MSGCAT_SET_PARSER_SEMANTIC,
15011  MSGCAT_SEMANTIC_NOT_ALLOWED_IN_LIMIT_CLAUSE, "ORDERBY_NUM()");
15012  }
15013  }
15014  }
15015  $$ = node;
15016  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15017 
15018  DBG_PRINT}}
15019  ;
15020 
15021 limit_options
15022  : limit_expr
15023  {{
15024 
15025  PT_NODE *node = parser_top_orderby_node ();
15026  if (node)
15027  {
15028  node->info.query.limit = $1;
15029  node->info.query.flag.rewrite_limit = 1;
15030  }
15031  $$ = node;
15032  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15033 
15034  DBG_PRINT}}
15035  | limit_expr ',' limit_expr
15036  {{
15037 
15038  PT_NODE *node = parser_top_orderby_node ();
15039  if (node)
15040  {
15041  PT_NODE *limit1 = $1;
15042  PT_NODE *limit2 = $3;
15043  if (limit1)
15044  {
15045  limit1->next = limit2;
15046  }
15047  node->info.query.limit = limit1;
15048  node->info.query.flag.rewrite_limit = 1;
15049  }
15050  $$ = node;
15051  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15052 
15053  DBG_PRINT}}
15054  | limit_expr OFFSET limit_expr
15055  {{
15056 
15057  PT_NODE *node = parser_top_orderby_node ();
15058  if (node)
15059  {
15060  PT_NODE *limit1 = $3;
15061  PT_NODE *limit2 = $1;
15062  if (limit1)
15063  {
15064  limit1->next = limit2;
15065  }
15066  node->info.query.limit = limit1;
15067  node->info.query.flag.rewrite_limit = 1;
15068  }
15069  $$ = node;
15070  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15071 
15072  DBG_PRINT}}
15073  ;
15074 
15075 opt_upd_del_limit_clause
15076  : /* empty */
15077  { $$ = NULL; }
15078  | LIMIT limit_expr
15079  {{
15080 
15081  $$ = $2;
15082  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15083 
15084  DBG_PRINT}}
15085  ;
15086 
15087 opt_for_search_condition
15088  : /* empty */
15089  { $$ = NULL; }
15090  | For search_condition
15091  {{
15092  PT_NODE *node = $2;
15093  bool subquery_flag = false;
15094  if (node)
15095  {
15096  (void) parser_walk_tree (this_parser, node,
15097  pt_check_subquery_pre, NULL,
15098  pt_check_subquery_post,
15099  &subquery_flag);
15100  if (subquery_flag)
15101  {
15102  PT_ERRORm(this_parser, node,
15103  MSGCAT_SET_PARSER_SEMANTIC,
15104  MSGCAT_SEMANTIC_SUBQUERY_NOT_ALLOWED_IN_ORDERBY_FOR_CLAUSE);
15105  }
15106  }
15107  $$ = $2;
15108  DBG_PRINT}}
15109  ;
15110 
15111 sort_spec_list
15112  : sort_spec_list ',' sort_spec
15113  {{
15114 
15115  $$ = parser_make_link ($1, $3);
15116  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15117 
15118  DBG_PRINT}}
15119  | sort_spec
15120  {{
15121 
15122  $$ = $1;
15123  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15124 
15125  DBG_PRINT}}
15126  ;
15127 
15128 sort_spec
15129  : expression_ ASC opt_nulls_first_or_last
15130  {{
15131  PT_NODE *node = parser_new_node (this_parser, PT_SORT_SPEC);
15132 
15133  if (node)
15134  {
15135  node->info.sort_spec.asc_or_desc = PT_ASC;
15136  node->info.sort_spec.expr = $1;
15137  node->info.sort_spec.nulls_first_or_last = $3;
15138  }
15139 
15140  $$ = node;
15141  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15142 
15143  DBG_PRINT}}
15144  | expression_ DESC opt_nulls_first_or_last
15145  {{
15146 
15147  PT_NODE *node = parser_new_node (this_parser, PT_SORT_SPEC);
15148 
15149  if (node)
15150  {
15151  node->info.sort_spec.asc_or_desc = PT_DESC;
15152  node->info.sort_spec.expr = $1;
15153  node->info.sort_spec.nulls_first_or_last = $3;
15154  }
15155 
15156  $$ = node;
15157  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15158 
15159  DBG_PRINT}}
15160  | expression_ opt_nulls_first_or_last
15161  {{
15162 
15163  PT_NODE *node = parser_new_node (this_parser, PT_SORT_SPEC);
15164 
15165  if (node)
15166  {
15167  node->info.sort_spec.asc_or_desc = PT_ASC;
15168  node->info.sort_spec.expr = $1;
15169  node->info.sort_spec.nulls_first_or_last = $2;
15170  }
15171 
15172  $$ = node;
15173  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15174 
15175  DBG_PRINT}}
15176  ;
15177 
15178 opt_nulls_first_or_last
15179  : /* empty */
15180  {{
15181 
15182  $$ = PT_NULLS_DEFAULT;
15183 
15184  DBG_PRINT}}
15185  | NULLS FIRST
15186  {{
15187 
15188  $$ = PT_NULLS_FIRST;
15189 
15190  DBG_PRINT}}
15191  | NULLS LAST
15192  {{
15193 
15194  $$ = PT_NULLS_LAST;
15195 
15196  DBG_PRINT}}
15197  ;
15198 
15199 expression_
15200  : normal_expression
15201  {{
15202 
15203  $$ = $1;
15204  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15205 
15206  DBG_PRINT}}
15207  | predicate_expression
15208  {{
15209 
15210  $$ = $1;
15211  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15212 
15213  DBG_PRINT}}
15214  ;
15215 
15216 
15217 normal_expression
15218  : session_variable_definition
15219  {{
15220 
15221  $$ = $1;
15222  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15223 
15224  DBG_PRINT}}
15225  | expression_strcat
15226  {{
15227 
15228  $$ = $1;
15229  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15230 
15231  DBG_PRINT}}
15232  ;
15233 
15234 expression_strcat
15235  : expression_strcat STRCAT expression_bitor
15236  {{
15237 
15238  $$ = parser_make_expression (this_parser, PT_STRCAT, $1, $3, NULL);
15239  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15240 
15241  DBG_PRINT}}
15242  | expression_bitor
15243  {{
15244 
15245  $$ = $1;
15246  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15247 
15248  DBG_PRINT}}
15249  ;
15250 
15251 expression_bitor
15252  : expression_bitor '|' expression_bitand
15253  {{
15254 
15255  $$ = parser_make_expression (this_parser, PT_BIT_OR, $1, $3, NULL);
15256  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15257 
15258  DBG_PRINT}}
15259  | expression_bitand
15260  {{
15261 
15262  $$ = $1;
15263  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15264 
15265  DBG_PRINT}}
15266  ;
15267 
15268 expression_bitand
15269  : expression_bitand '&' expression_bitshift
15270  {{
15271 
15272  $$ = parser_make_expression (this_parser, PT_BIT_AND, $1, $3, NULL);
15273  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15274 
15275  DBG_PRINT}}
15276  | expression_bitshift
15277  {{
15278 
15279  $$ = $1;
15280  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15281 
15282  DBG_PRINT}}
15283  ;
15284 
15285 expression_bitshift
15286  : expression_bitshift BITSHIFT_LEFT expression_add_sub
15287  {{
15288 
15289  $$ = parser_make_expression (this_parser, PT_BITSHIFT_LEFT, $1, $3, NULL);
15290  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15291 
15292  DBG_PRINT}}
15293  | expression_bitshift BITSHIFT_RIGHT expression_add_sub
15294  {{
15295 
15296  $$ = parser_make_expression (this_parser, PT_BITSHIFT_RIGHT, $1, $3, NULL);
15297  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15298 
15299  DBG_PRINT}}
15300  | expression_add_sub
15301  {{
15302 
15303  $$ = $1;
15304  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15305 
15306  DBG_PRINT}}
15307  ;
15308 
15309 expression_add_sub
15310  : expression_add_sub '+' term
15311  {{
15312 
15313  $$ = parser_make_expression (this_parser, PT_PLUS, $1, $3, NULL);
15314  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15315 
15316  DBG_PRINT}}
15317  | expression_add_sub '-' term
15318  {{
15319 
15320  $$ = parser_make_expression (this_parser, PT_MINUS, $1, $3, NULL);
15321  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15322 
15323  DBG_PRINT}}
15324  | term
15325  {{
15326 
15327  $$ = $1;
15328  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15329 
15330  DBG_PRINT}}
15331  ;
15332 
15333 term
15334  : term '*' factor
15335  {{
15336 
15337  $$ = parser_make_expression (this_parser, PT_TIMES, $1, $3, NULL);
15338  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15339 
15340  DBG_PRINT}}
15341  | term '/' factor
15342  {{
15343 
15344  $$ = parser_make_expression (this_parser, PT_DIVIDE, $1, $3, NULL);
15345  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15346 
15347  DBG_PRINT}}
15348  | term DIV factor
15349  {{
15350 
15351  $$ = parser_make_expression (this_parser, PT_DIV, $1, $3, NULL);
15352  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15353 
15354  DBG_PRINT}}
15355  | term MOD factor
15356  {{
15357 
15358  $$ = parser_make_expression (this_parser, PT_MOD, $1, $3, NULL);
15359  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15360 
15361  DBG_PRINT}}
15362  | factor
15363  {{
15364 
15365  $$ = $1;
15366  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15367 
15368  DBG_PRINT}}
15369  ;
15370 
15371 factor
15372  : factor '^' factor_
15373  {{
15374 
15375  $$ = parser_make_expression (this_parser, PT_BIT_XOR, $1, $3, NULL);
15376  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15377 
15378  DBG_PRINT}}
15379  | factor_
15380  {{
15381 
15382  $$ = $1;
15383  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15384 
15385  DBG_PRINT}}
15386  ;
15387 
15388 factor_
15389  : primary_w_collate
15390  {{
15391 
15392  $$ = $1;
15393  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15394 
15395  DBG_PRINT}}
15396  | '-' factor_
15397  {{
15398 
15399  $$ = parser_make_expression (this_parser, PT_UNARY_MINUS, $2, NULL, NULL);
15400  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15401 
15402  DBG_PRINT}}
15403  | '+' factor_
15404  {{
15405 
15406  $$ = $2;
15407  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15408 
15409  DBG_PRINT}}
15410  | '~' primary
15411  {{
15412 
15413  $$ = parser_make_expression (this_parser, PT_BIT_NOT, $2, NULL, NULL);
15414  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15415 
15416  DBG_PRINT}}
15417  | PRIOR
15418  {{
15419 
15420  parser_save_and_set_sysc (0);
15421  parser_save_and_set_prc (0);
15422  parser_save_and_set_cbrc (0);
15423  parser_save_and_set_pseudoc (0);
15424 
15425  DBG_PRINT}}
15426  primary_w_collate
15427  {{
15428 
15429  PT_NODE *node = parser_make_expression (this_parser, PT_PRIOR, $3, NULL, NULL);
15430  PARSER_SAVE_ERR_CONTEXT (node, @$.buffer_pos)
15431 
15432  parser_restore_sysc ();
15433  parser_restore_prc ();
15434  parser_restore_cbrc ();
15435  parser_restore_pseudoc ();
15436 
15437  if (parser_prior_check == 0)
15438  {
15439  PT_ERRORmf(this_parser, node, MSGCAT_SET_PARSER_SEMANTIC,
15440  MSGCAT_SEMANTIC_NOT_ALLOWED_HERE, "PRIOR");
15441  }
15442 
15443  $$ = node;
15444 
15445  DBG_PRINT}}
15446  | CONNECT_BY_ROOT
15447  {{
15448 
15449  parser_save_and_set_sysc (0);
15450  parser_save_and_set_prc (0);
15451  parser_save_and_set_cbrc (0);
15452  parser_save_and_set_pseudoc (0);
15453 
15454  DBG_PRINT}}
15455  primary_w_collate
15456  {{
15457 
15458  PT_NODE *node = parser_make_expression (this_parser, PT_CONNECT_BY_ROOT, $3, NULL, NULL);
15459  PARSER_SAVE_ERR_CONTEXT (node, @$.buffer_pos)
15460 
15461  parser_restore_sysc ();
15462  parser_restore_prc ();
15463  parser_restore_cbrc ();
15464  parser_restore_pseudoc ();
15465 
15466  if (parser_connectbyroot_check == 0)
15467  {
15468  PT_ERRORmf(this_parser, node, MSGCAT_SET_PARSER_SEMANTIC,
15469  MSGCAT_SEMANTIC_NOT_ALLOWED_HERE, "CONNECT_BY_ROOT");
15470  }
15471 
15472  $$ = node;
15473 
15474  DBG_PRINT}}
15475  ;
15476 
15477 primary_w_collate
15478  : primary opt_collation
15479  {{
15480  PT_NODE *node = $1;
15481  PT_NODE *coll_node = $2;
15482 
15483  if (node != NULL && coll_node != NULL)
15484  {
15485  node = pt_set_collation_modifier (this_parser, node, coll_node);
15486  }
15487 
15488  if (node->node_type == PT_VALUE)
15489  {
15490  node->info.value.is_collate_allowed = true;
15491  }
15492 
15493  $$ = node;
15494  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15495 
15496  DBG_PRINT}}
15497 
15498 primary
15499  : pseudo_column %dprec 11
15500  {{
15501 
15502  if (parser_pseudocolumn_check == 0)
15503  PT_ERRORmf (this_parser, $1, MSGCAT_SET_PARSER_SEMANTIC,
15504  MSGCAT_SEMANTIC_NOT_ALLOWED_HERE, "Pseudo-column");
15505 
15506  $$ = $1;
15507  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15508 
15509  DBG_PRINT}}
15510  | reserved_func %dprec 10
15511  {{
15512 
15513  $$ = $1;
15514  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15515 
15516  DBG_PRINT}}
15517  | case_expr %dprec 9
15518  {{
15519 
15520  $$ = $1;
15521  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15522 
15523  DBG_PRINT}}
15524  | extract_expr %dprec 8
15525  {{
15526 
15527  $$ = $1;
15528  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15529 
15530  DBG_PRINT}}
15531  | literal_w_o_param %dprec 7
15532  {{
15533 
15534  $$ = $1;
15535  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15536 
15537  DBG_PRINT}}
15538  | insert_expression %dprec 6
15539  {{
15540 
15541  $1->info.insert.is_subinsert = PT_IS_SUBINSERT;
15542  $$ = $1;
15543  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15544  parser_groupby_exception = PT_IS_SUBINSERT;
15545 
15546  DBG_PRINT}}
15547  | path_expression %dprec 5
15548  {{
15549 
15550  $$ = $1;
15551  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15552 
15553  DBG_PRINT}}
15554  | '(' expression_list ')' %dprec 4
15555  {{
15556  PT_NODE *exp = $2;
15557  exp = pt_create_paren_expr_list (exp);
15558  $$ = exp;
15559  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15560 
15561  DBG_PRINT}}
15562  | ROW '(' expression_list ')' %dprec 4
15563  {{
15564  PT_NODE *exp = $3;
15565  exp = pt_create_paren_expr_list (exp);
15566  $$ = exp;
15567  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15568 
15569  DBG_PRINT}}
15570  | '(' search_condition_query ')' %dprec 2
15571  {{
15572 
15573  PT_NODE *exp = $2;
15574 
15575  if (exp && exp->node_type == PT_EXPR)
15576  {
15577  exp->info.expr.paren_type = 1;
15578  }
15579 
15580  $$ = exp;
15581  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15582  parser_groupby_exception = PT_EXPR;
15583 
15584  DBG_PRINT}}
15585  | subquery %dprec 1
15586  {{
15587  parser_groupby_exception = PT_IS_SUBQUERY;
15588  $$ = $1;
15589  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15590  DBG_PRINT}}
15591  | session_variable_expression
15592  {{
15593 
15594  $$ = $1;
15595  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15596 
15597  }}
15598  ;
15599 
15600 search_condition_query
15601  : search_condition_expression
15602  {{
15603 
15604  PT_NODE *node = $1;
15605  parser_push_orderby_node (node);
15606 
15607  DBG_PRINT}}
15608  opt_orderby_clause
15609  {{
15610 
15611  PT_NODE *node = parser_pop_orderby_node ();
15612  $$ = node;
15613  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15614 
15615  DBG_PRINT}}
15616  ;
15617 
15618 search_condition_expression
15619  : search_condition
15620  {{
15621 
15622  $$ = $1;
15623  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15624 
15625  DBG_PRINT}}
15626  ;
15627 
15628 pseudo_column
15629  : CONNECT_BY_ISCYCLE
15630  {{
15631 
15632  $$ = parser_make_expression (this_parser, PT_CONNECT_BY_ISCYCLE, NULL, NULL, NULL);
15633  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15634 
15635  DBG_PRINT}}
15636  | CONNECT_BY_ISLEAF
15637  {{
15638 
15639  $$ = parser_make_expression (this_parser, PT_CONNECT_BY_ISLEAF, NULL, NULL, NULL);
15640  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15641 
15642  DBG_PRINT}}
15643  | LEVEL
15644  {{
15645 
15646  $$ = parser_make_expression (this_parser, PT_LEVEL, NULL, NULL, NULL);
15647  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15648 
15649  DBG_PRINT}}
15650  ;
15651 
15652 
15653 reserved_func
15654  : COUNT '(' '*' ')'
15655  {{
15656 
15657  PT_NODE *node = parser_new_node (this_parser, PT_FUNCTION);
15658 
15659  if (node)
15660  {
15661  node->info.function.arg_list = NULL;
15662  node->info.function.function_type = PT_COUNT_STAR;
15663  }
15664 
15665 
15666  $$ = node;
15667  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15668  parser_groupby_exception = PT_COUNT;
15669 
15670  DBG_PRINT}}
15671  | COUNT '(' '*' ')' OVER '(' opt_analytic_partition_by opt_analytic_order_by ')'
15672  {{
15673 
15674  PT_NODE *node = parser_new_node (this_parser, PT_FUNCTION);
15675 
15676  if (node)
15677  {
15678  node->info.function.function_type = PT_COUNT_STAR;
15679  node->info.function.all_or_distinct = PT_ALL;
15680  node->info.function.arg_list = NULL;
15681  node->info.function.analytic.is_analytic = true;
15682  node->info.function.analytic.partition_by = $7;
15683  node->info.function.analytic.order_by = $8;
15684  }
15685 
15686  $$ = node;
15687  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15688 
15689  DBG_PRINT}}
15690  | COUNT '(' of_distinct_unique expression_ ')'
15691  {{
15692 
15693  PT_NODE *node = parser_new_node (this_parser, PT_FUNCTION);
15694 
15695  if (node)
15696  {
15697  node->info.function.all_or_distinct = PT_DISTINCT;
15698  node->info.function.function_type = PT_COUNT;
15699  node->info.function.arg_list = $4;
15700  }
15701 
15702  $$ = node;
15703  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15704  parser_groupby_exception = PT_COUNT;
15705 
15706  DBG_PRINT}}
15707  | COUNT '(' of_distinct_unique expression_ ')' OVER '(' opt_analytic_partition_by opt_analytic_order_by ')'
15708  {{
15709 
15710  PT_NODE *node = parser_new_node (this_parser, PT_FUNCTION);
15711 
15712  if (node)
15713  {
15714  node->info.function.all_or_distinct = PT_DISTINCT;
15715  node->info.function.function_type = PT_COUNT;
15716  node->info.function.arg_list = $4;
15717  node->info.function.analytic.is_analytic = true;
15718  node->info.function.analytic.partition_by = $8;
15719  node->info.function.analytic.order_by = $9;
15720  }
15721 
15722  $$ = node;
15723  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15724 
15725  DBG_PRINT}}
15726  | COUNT '(' opt_all expression_ ')'
15727  {{
15728 
15729  PT_NODE *node = parser_new_node (this_parser, PT_FUNCTION);
15730 
15731  if (node)
15732  {
15733  node->info.function.all_or_distinct = PT_ALL;
15734  node->info.function.function_type = PT_COUNT;
15735  node->info.function.arg_list = $4;
15736  }
15737 
15738  $$ = node;
15739  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15740  parser_groupby_exception = PT_COUNT;
15741 
15742  DBG_PRINT}}
15743  | COUNT '(' opt_all expression_ ')' OVER '(' opt_analytic_partition_by opt_analytic_order_by ')'
15744  {{
15745 
15746  PT_NODE *node = parser_new_node (this_parser, PT_FUNCTION);
15747 
15748  if (node)
15749  {
15750  node->info.function.all_or_distinct = PT_ALL;
15751  node->info.function.function_type = PT_COUNT;
15752  node->info.function.arg_list = $4;
15753  node->info.function.analytic.is_analytic = true;
15754  node->info.function.analytic.partition_by = $8;
15755  node->info.function.analytic.order_by = $9;
15756  }
15757 
15758  $$ = node;
15759  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15760 
15761  DBG_PRINT}}
15762  | of_avg_max_etc '(' of_distinct_unique expression_ ')'
15763  {{//reserved_func | of_avg_max_etc '(' of_distinct_unique expression_ ')'
15764 
15765  PT_NODE *node = parser_new_node (this_parser, PT_FUNCTION);
15766 
15767  if (node != NULL)
15768  {
15769  node->info.function.function_type = $1;
15770 
15771  if ($1 == PT_MAX || $1 == PT_MIN)
15772  node->info.function.all_or_distinct = PT_ALL;
15773  else
15774  node->info.function.all_or_distinct = PT_DISTINCT;
15775 
15776  node->info.function.arg_list = $4;
15777  }
15778 
15779  $$ = node;
15780  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15781  parser_groupby_exception = PT_COUNT;
15782 
15783  DBG_PRINT}}
15784  | of_avg_max_etc '(' opt_all expression_ ')'
15785  {{//reserved_func | of_avg_max_etc '(' opt_all expression_ ')'
15786 
15787  PT_NODE *node = parser_new_node (this_parser, PT_FUNCTION);
15788 
15789  if (node != NULL)
15790  {
15791  node->info.function.function_type = $1;
15792  node->info.function.all_or_distinct = PT_ALL;
15793  node->info.function.arg_list = $4;
15794  }
15795 
15796  $$ = node;
15797  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15798  parser_groupby_exception = PT_COUNT;
15799 
15800  DBG_PRINT}}
15801  | of_analytic '(' of_distinct_unique expression_ ')' OVER '(' opt_analytic_partition_by opt_analytic_order_by ')'
15802  {{
15803 
15804  PT_NODE *node = parser_new_node (this_parser, PT_FUNCTION);
15805 
15806  if (node)
15807  {
15808  node->info.function.function_type = $1;
15809  if ($1 == PT_MAX || $1 == PT_MIN)
15810  node->info.function.all_or_distinct = PT_ALL;
15811  else
15812  node->info.function.all_or_distinct = PT_DISTINCT;
15813  node->info.function.arg_list = $4;
15814  node->info.function.analytic.is_analytic = true;
15815  node->info.function.analytic.partition_by = $8;
15816  node->info.function.analytic.order_by = $9;
15817  }
15818 
15819  $$ = node;
15820  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15821 
15822  DBG_PRINT}}
15823  | of_analytic '(' opt_all expression_ ')' OVER '(' opt_analytic_partition_by opt_analytic_order_by ')'
15824  {{
15825 
15826  PT_NODE *node = parser_new_node (this_parser, PT_FUNCTION);
15827 
15828  if (node)
15829  {
15830  node->info.function.function_type = $1;
15831  node->info.function.all_or_distinct = PT_ALL;
15832  node->info.function.arg_list = $4;
15833  node->info.function.analytic.is_analytic = true;
15834  node->info.function.analytic.partition_by = $8;
15835  node->info.function.analytic.order_by = $9;
15836  }
15837 
15838  $$ = node;
15839  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15840 
15841  DBG_PRINT}}
15842  | of_analytic_first_last '(' expression_ ')' opt_analytic_ignore_nulls OVER '(' opt_analytic_partition_by opt_analytic_order_by ')'
15843  {{
15844 
15845  PT_NODE *node = parser_new_node (this_parser, PT_FUNCTION);
15846 
15847  if (node)
15848  {
15849  node->info.function.function_type = $1;
15850  node->info.function.all_or_distinct = PT_ALL;
15851  node->info.function.arg_list = $3;
15852 
15853  node->info.function.analytic.ignore_nulls = $5;
15854 
15855  node->info.function.analytic.is_analytic = true;
15856  node->info.function.analytic.partition_by = $8;
15857  node->info.function.analytic.order_by = $9;
15858  }
15859 
15860  $$ = node;
15861  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15862 
15863  DBG_PRINT}}
15864  | of_analytic_nth_value '(' expression_ ',' expression_ ')' opt_analytic_from_last opt_analytic_ignore_nulls OVER '(' opt_analytic_partition_by opt_analytic_order_by ')'
15865  {{
15866 
15867  PT_NODE *node = parser_new_node (this_parser, PT_FUNCTION);
15868 
15869  if (node)
15870  {
15871  node->info.function.function_type = $1;
15872  node->info.function.all_or_distinct = PT_ALL;
15873  node->info.function.arg_list = $3;
15874 
15875  node->info.function.analytic.offset = $5;
15876 
15877  node->info.function.analytic.default_value = parser_new_node (this_parser, PT_VALUE);
15878  if (node->info.function.analytic.default_value != NULL)
15879  {
15880  node->info.function.analytic.default_value->type_enum = PT_TYPE_NULL;
15881  }
15882 
15883  node->info.function.analytic.from_last = $7;
15884  node->info.function.analytic.ignore_nulls = $8;
15885 
15886  node->info.function.analytic.is_analytic = true;
15887  node->info.function.analytic.partition_by = $11;
15888  node->info.function.analytic.order_by = $12;
15889  }
15890 
15891  $$ = node;
15892  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15893 
15894  DBG_PRINT}}
15895  | of_analytic_lead_lag '(' expression_ ')' OVER '(' opt_analytic_partition_by opt_analytic_order_by ')'
15896  {{
15897 
15898  PT_NODE *node = parser_new_node (this_parser, PT_FUNCTION);
15899 
15900  if (node)
15901  {
15902  node->info.function.function_type = $1;
15903  node->info.function.all_or_distinct = PT_ALL;
15904  node->info.function.arg_list = $3;
15905 
15906  node->info.function.analytic.offset = parser_new_node (this_parser, PT_VALUE);
15907  if (node->info.function.analytic.offset != NULL)
15908  {
15909  node->info.function.analytic.offset->type_enum = PT_TYPE_INTEGER;
15910  node->info.function.analytic.offset->info.value.data_value.i = 1;
15911  }
15912 
15913  node->info.function.analytic.default_value = parser_new_node (this_parser, PT_VALUE);
15914  if (node->info.function.analytic.default_value != NULL)
15915  {
15916  node->info.function.analytic.default_value->type_enum = PT_TYPE_NULL;
15917  }
15918 
15919  node->info.function.analytic.partition_by = $7;
15920  node->info.function.analytic.order_by = $8;
15921  node->info.function.analytic.is_analytic = true;
15922  }
15923 
15924  $$ = node;
15925  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15926 
15927  DBG_PRINT}}
15928  | of_analytic_lead_lag '(' expression_ ',' expression_ ')' OVER '(' opt_analytic_partition_by opt_analytic_order_by ')'
15929  {{
15930 
15931  PT_NODE *node = parser_new_node (this_parser, PT_FUNCTION);
15932 
15933  if (node)
15934  {
15935  node->info.function.function_type = $1;
15936  node->info.function.all_or_distinct = PT_ALL;
15937  node->info.function.arg_list = $3;
15938  node->info.function.analytic.offset = $5;
15939 
15940  node->info.function.analytic.default_value = parser_new_node (this_parser, PT_VALUE);
15941  if (node->info.function.analytic.default_value != NULL)
15942  {
15943  node->info.function.analytic.default_value->type_enum = PT_TYPE_NULL;
15944  }
15945 
15946  node->info.function.analytic.partition_by = $9;
15947  node->info.function.analytic.order_by = $10;
15948  node->info.function.analytic.is_analytic = true;
15949  }
15950 
15951  $$ = node;
15952  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15953 
15954  DBG_PRINT}}
15955  | of_analytic_lead_lag '(' expression_ ',' expression_ ',' expression_ ')' OVER '(' opt_analytic_partition_by opt_analytic_order_by ')'
15956  {{
15957 
15958  PT_NODE *node = parser_new_node (this_parser, PT_FUNCTION);
15959 
15960  if (node)
15961  {
15962  node->info.function.function_type = $1;
15963  node->info.function.all_or_distinct = PT_ALL;
15964  node->info.function.arg_list = $3;
15965  node->info.function.analytic.offset = $5;
15966  node->info.function.analytic.default_value = $7;
15967  node->info.function.analytic.partition_by = $11;
15968  node->info.function.analytic.order_by = $12;
15969  node->info.function.analytic.is_analytic = true;
15970  }
15971 
15972  $$ = node;
15973  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
15974 
15975  DBG_PRINT}}
15976  | of_analytic_no_args '(' ')' OVER '(' opt_analytic_partition_by opt_analytic_order_by ')'
15977  {{
15978 
15979  PT_NODE *node = parser_new_node (this_parser, PT_FUNCTION);
15980 
15981  if (node)
15982  {
15983  node->info.function.function_type = $1;
15984  node->info.function.all_or_distinct = PT_ALL;
15985  node->info.function.arg_list = NULL;
15986  node->info.function.analytic.is_analytic = true;
15987  node->info.function.analytic.partition_by = $6;
15988  node->info.function.analytic.order_by = $7;
15989  if ($7 == NULL)
15990  {
15991  if ($1 == PT_CUME_DIST || $1 == PT_PERCENT_RANK)
15992  {
15993  PT_ERRORmf (this_parser, node,
15994  MSGCAT_SET_PARSER_SEMANTIC,
15995  MSGCAT_SEMANTIC_NULL_ORDER_BY,
15996  fcode_get_lowercase_name ($1));
15997  }
15998  }
15999  }
16000 
16001  $$ = node;
16002  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16003 
16004  DBG_PRINT}}
16005  | GROUP_CONCAT
16006  { push_msg(MSGCAT_SYNTAX_INVALID_GROUP_CONCAT); }
16007  '(' of_distinct_unique expression_ opt_agg_order_by opt_group_concat_separator ')'
16008  { pop_msg(); }
16009  {{
16010 
16011  PT_NODE *node = parser_new_node (this_parser, PT_FUNCTION);
16012 
16013  if (node)
16014  {
16015  node->info.function.function_type = PT_GROUP_CONCAT;
16016  node->info.function.all_or_distinct = PT_DISTINCT;
16017  node->info.function.arg_list = parser_make_link ($5, $7);
16018  node->info.function.order_by = $6;
16019  }
16020 
16021  $$ = node;
16022  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16023 
16024  DBG_PRINT}}
16025  | GROUP_CONCAT '(' opt_all opt_expression_list opt_agg_order_by opt_group_concat_separator ')'
16026  {{
16027 
16028  PT_NODE *node = parser_new_node (this_parser, PT_FUNCTION);
16029 
16030  PT_NODE *args_list = $4;
16031 
16032  if (parser_count_list(args_list) != 1)
16033  {
16034  PT_ERRORm (this_parser, node, MSGCAT_SET_PARSER_SYNTAX,
16035  MSGCAT_SYNTAX_INVALID_GROUP_CONCAT);
16036  }
16037 
16038  if (node)
16039  {
16040  node->info.function.function_type = PT_GROUP_CONCAT;
16041  node->info.function.all_or_distinct = PT_ALL;
16042  node->info.function.arg_list = parser_make_link ($4, $6);
16043  node->info.function.order_by = $5;
16044  }
16045 
16046  $$ = node;
16047  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16048 
16049  DBG_PRINT}}
16050  | JSON_ARRAYAGG '(' expression_ ')'
16051  {{
16052 
16053  PT_NODE *node = parser_new_node (this_parser, PT_FUNCTION);
16054 
16055  if (node)
16056  {
16057  node->info.function.function_type = PT_JSON_ARRAYAGG;
16058  node->info.function.all_or_distinct = PT_ALL;
16059  node->info.function.arg_list = parser_make_link ($3, NULL);
16060  }
16061 
16062  $$ = node;
16063  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16064 
16065  DBG_PRINT}}
16066  | JSON_OBJECTAGG '(' expression_list ')'
16067  {{
16068  PT_NODE *node = parser_new_node (this_parser, PT_FUNCTION);
16069  PT_NODE *args_list = $3;
16070 
16071  if (parser_count_list(args_list) != 2)
16072  {
16073  PT_ERRORm (this_parser, node, MSGCAT_SET_PARSER_SYNTAX,
16074  MSGCAT_SYNTAX_INVALID_JSON_OBJECTAGG);
16075  }
16076 
16077  if (node)
16078  {
16079  node->info.function.function_type = PT_JSON_OBJECTAGG;
16080  node->info.function.all_or_distinct = PT_ALL;
16081  node->info.function.arg_list = args_list;
16082  }
16083 
16084  $$ = node;
16085  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16086  DBG_PRINT}}
16087  | of_percentile '(' expression_ ')' WITHIN GROUP_ '(' ORDER BY sort_spec ')' opt_over_analytic_partition_by
16088  {{
16089 
16090  PT_NODE *node = parser_new_node (this_parser, PT_FUNCTION);
16091 
16092  if (node != NULL)
16093  {
16094  node->info.function.function_type = $1;
16095  node->info.function.all_or_distinct = PT_ALL;
16096 
16097  if ($3 != NULL)
16098  {
16099  node->info.function.percentile =
16100  pt_wrap_with_cast_op (this_parser, $3,
16101  PT_TYPE_DOUBLE, 0, 0, NULL);
16102  }
16103 
16104  if ($10 != NULL)
16105  {
16106  if (pt_is_const ($10->info.sort_spec.expr))
16107  {
16108  node->info.function.arg_list =
16109  $10->info.sort_spec.expr;
16110  }
16111  else
16112  {
16113  if (is_analytic_function)
16114  {
16115  node->info.function.analytic.order_by = $10;
16116  }
16117  else
16118  {
16119  node->info.function.order_by = $10;
16120  }
16121 
16122  node->info.function.arg_list =
16123  parser_copy_tree (this_parser,
16124  $10->info.sort_spec.expr);
16125  }
16126  }
16127 
16128  if (is_analytic_function)
16129  {
16130  node->info.function.analytic.is_analytic = is_analytic_function;
16131  node->info.function.analytic.partition_by = $12;
16132  }
16133  }
16134 
16135  $$ = node;
16136  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos);
16137 
16138  DBG_PRINT}}
16139  | INSERT
16140  { push_msg(MSGCAT_SYNTAX_INVALID_INSERT_SUBSTRING); }
16141  '(' expression_list ')'
16142  { pop_msg(); }
16143  {{
16144  $$ = parser_make_func_with_arg_count (this_parser, F_INSERT_SUBSTRING, $4, 4, 4);
16145  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16146  DBG_PRINT}}
16147  | ELT '(' opt_expression_list ')'
16148  {{
16149  $$ = parser_make_func_with_arg_count (this_parser, F_ELT, $3, 1, 0);
16150  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16151  DBG_PRINT}}
16152  | POSITION '(' expression_ IN_ expression_ ')'
16153  {{
16154 
16155  $$ = parser_make_expression (this_parser, PT_POSITION, $3, $5, NULL);
16156  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16157 
16158  DBG_PRINT}}
16159  | SUBSTRING_
16160  { push_msg(MSGCAT_SYNTAX_INVALID_SUBSTRING); }
16161  '(' expression_ FROM expression_ For expression_ ')'
16162  { pop_msg(); }
16163  {{
16164 
16165  PT_NODE *node = parser_make_expression (this_parser, PT_SUBSTRING, $4, $6, $8);
16166  node->info.expr.qualifier = PT_SUBSTR_ORG;
16167  PICE (node);
16168  $$ = node;
16169  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16170 
16171  DBG_PRINT}}
16172  | SUBSTRING_
16173  { push_msg(MSGCAT_SYNTAX_INVALID_SUBSTRING); }
16174  '(' expression_ FROM expression_ ')'
16175  { pop_msg(); }
16176  {{
16177 
16178  PT_NODE *node = parser_make_expression (this_parser, PT_SUBSTRING, $4, $6, NULL);
16179  node->info.expr.qualifier = PT_SUBSTR_ORG;
16180  PICE (node);
16181  $$ = node;
16182  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16183 
16184  DBG_PRINT}}
16185  | SUBSTRING_
16186  { push_msg(MSGCAT_SYNTAX_INVALID_SUBSTRING); }
16187  '(' expression_ ',' expression_ ',' expression_ ')'
16188  { pop_msg(); }
16189  {{
16190 
16191  PT_NODE *node = parser_make_expression (this_parser, PT_SUBSTRING, $4, $6, $8);
16192  node->info.expr.qualifier = PT_SUBSTR_ORG;
16193  PICE (node);
16194  $$ = node;
16195  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16196 
16197  DBG_PRINT}}
16198  | SUBSTRING_
16199  { push_msg(MSGCAT_SYNTAX_INVALID_SUBSTRING); }
16200  '(' expression_ ',' expression_ ')'
16201  { pop_msg(); }
16202  {{
16203 
16204  PT_NODE *node = parser_make_expression (this_parser, PT_SUBSTRING, $4, $6, NULL);
16205  node->info.expr.qualifier = PT_SUBSTR_ORG;
16206  PICE (node);
16207  $$ = node;
16208  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16209 
16210  DBG_PRINT}}
16211  | Date
16212  { push_msg(MSGCAT_SYNTAX_INVALID_DATE); }
16213  '(' expression_ ')'
16214  { pop_msg(); }
16215  {{
16216 
16217  PT_NODE *node = parser_make_expression (this_parser, PT_DATEF, $4, NULL, NULL);
16218  PICE (node);
16219  $$ = node;
16220  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16221 
16222  DBG_PRINT}}
16223  | Time
16224  { push_msg(MSGCAT_SYNTAX_INVALID_TIME); }
16225  '(' expression_ ')'
16226  { pop_msg(); }
16227  {{
16228 
16229  PT_NODE *node = parser_make_expression (this_parser, PT_TIMEF, $4, NULL, NULL);
16230  PICE (node);
16231  $$ = node;
16232  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16233 
16234  DBG_PRINT}}
16235  | ADDDATE
16236  { push_msg(MSGCAT_SYNTAX_INVALID_ADDDATE); }
16237  '(' expression_ ',' expression_ ')'
16238  { pop_msg(); }
16239  {{
16240 
16241  PT_NODE *node = parser_make_expression (this_parser, PT_ADDDATE, $4, $6, NULL);
16242  PICE (node);
16243  $$ = node;
16244  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16245 
16246  DBG_PRINT}}
16247  | adddate_name
16248  { push_msg(MSGCAT_SYNTAX_INVALID_DATE_ADD); }
16249  '(' expression_ ',' INTERVAL expression_ datetime_field ')'
16250  { pop_msg(); }
16251  {{
16252 
16253  PT_NODE *node;
16254  PT_NODE *node_unit = parser_new_node (this_parser, PT_VALUE);
16255 
16256  if (node_unit)
16257  {
16258  node_unit->info.expr.qualifier = $8;
16259  node_unit->type_enum = PT_TYPE_INTEGER;
16260  }
16261 
16262  node = parser_make_expression (this_parser, PT_DATE_ADD, $4, $7, node_unit);
16263  PICE (node);
16264  $$ = node;
16265  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16266 
16267  DBG_PRINT}}
16268  | SUBDATE
16269  { push_msg(MSGCAT_SYNTAX_INVALID_SUBDATE); }
16270  '(' expression_ ',' expression_ ')'
16271  { pop_msg(); }
16272  {{
16273 
16274  PT_NODE *node = parser_make_expression (this_parser, PT_SUBDATE, $4, $6, NULL);
16275  PICE (node);
16276  $$ = node;
16277  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16278 
16279  DBG_PRINT}}
16280  | subdate_name
16281  { push_msg(MSGCAT_SYNTAX_INVALID_DATE_SUB); }
16282  '(' expression_ ',' INTERVAL expression_ datetime_field ')'
16283  { pop_msg(); }
16284  {{
16285 
16286  PT_NODE *node;
16287  PT_NODE *node_unit = parser_new_node (this_parser, PT_VALUE);
16288 
16289  if (node_unit)
16290  {
16291  node_unit->info.expr.qualifier = $8;
16292  node_unit->type_enum = PT_TYPE_INTEGER;
16293  }
16294 
16295  node = parser_make_expression (this_parser, PT_DATE_SUB, $4, $7, node_unit);
16296  PICE (node);
16297  $$ = node;
16298  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16299 
16300  DBG_PRINT}}
16301  | TIMESTAMP
16302  { push_msg(MSGCAT_SYNTAX_INVALID_TIMESTAMP); }
16303  '(' expression_ ')'
16304  { pop_msg(); }
16305  {{
16306  PT_NODE *arg2 = NULL;
16307  PT_NODE *node = NULL;
16308  arg2 = parser_new_node(this_parser, PT_VALUE);
16309  if (arg2)
16310  {
16311  db_make_int(&arg2->info.value.db_value, 0);
16312  arg2->type_enum = PT_TYPE_INTEGER;
16313  }
16314  node = parser_make_expression (this_parser, PT_TIMESTAMP, $4, arg2, NULL); /* will call timestamp(arg1, 0) */
16315  PICE (node);
16316  $$ = node;
16317  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16318 
16319  DBG_PRINT}}
16320  | TIMESTAMP
16321  { push_msg(MSGCAT_SYNTAX_INVALID_TIMESTAMP); }
16322  '(' expression_ ',' expression_ ')'
16323  { pop_msg(); }
16324  {{
16325 
16326  PT_NODE *node = parser_make_expression (this_parser, PT_TIMESTAMP, $4, $6, NULL); /* 2 parameters */
16327  PICE (node);
16328  $$ = node;
16329  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16330 
16331  DBG_PRINT}}
16332  | YEAR_
16333  { push_msg(MSGCAT_SYNTAX_INVALID_YEAR); }
16334  '(' expression_ ')'
16335  { pop_msg(); }
16336  {{
16337 
16338  PT_NODE *node = parser_make_expression (this_parser, PT_YEARF, $4, NULL, NULL); /* 1 parameter */
16339  PICE (node);
16340  $$ = node;
16341  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16342 
16343  DBG_PRINT}}
16344  | MONTH_
16345  { push_msg(MSGCAT_SYNTAX_INVALID_MONTH); }
16346  '(' expression_ ')'
16347  { pop_msg(); }
16348  {{
16349 
16350  PT_NODE *node = parser_make_expression (this_parser, PT_MONTHF, $4, NULL, NULL); /* 1 parameter */
16351  PICE (node);
16352  $$ = node;
16353  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16354 
16355  DBG_PRINT}}
16356  | DAY_
16357  { push_msg(MSGCAT_SYNTAX_INVALID_DAY); }
16358  '(' expression_ ')'
16359  { pop_msg(); }
16360  {{
16361 
16362  PT_NODE *node = parser_make_expression (this_parser, PT_DAYF, $4, NULL, NULL); /* 1 parameter */
16363  PICE (node);
16364  $$ = node;
16365  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16366 
16367  DBG_PRINT}}
16368  | HOUR_
16369  { push_msg(MSGCAT_SYNTAX_INVALID_HOUR); }
16370  '(' expression_ ')'
16371  { pop_msg(); }
16372  {{
16373 
16374  PT_NODE *node = parser_make_expression (this_parser, PT_HOURF, $4, NULL, NULL); /* 1 parameter */
16375  PICE (node);
16376  $$ = node;
16377  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16378 
16379  DBG_PRINT}}
16380  | MINUTE_
16381  { push_msg(MSGCAT_SYNTAX_INVALID_MINUTE); }
16382  '(' expression_ ')'
16383  { pop_msg(); }
16384  {{
16385 
16386  PT_NODE *node = parser_make_expression (this_parser, PT_MINUTEF, $4, NULL, NULL); /* 1 parameter */
16387  PICE (node);
16388  $$ = node;
16389  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16390 
16391  DBG_PRINT}}
16392  | SECOND_
16393  { push_msg(MSGCAT_SYNTAX_INVALID_SECOND); }
16394  '(' expression_ ')'
16395  { pop_msg(); }
16396  {{
16397 
16398  PT_NODE *node = parser_make_expression (this_parser, PT_SECONDF, $4, NULL, NULL); /* 1 parameter */
16399  PICE (node);
16400  $$ = node;
16401  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16402 
16403  DBG_PRINT}}
16404  | DATABASE
16405  { push_msg(MSGCAT_SYNTAX_INVALID_DATABASE); }
16406  '(' ')'
16407  { pop_msg(); }
16408  {{
16409 
16410  PT_NODE *node = parser_make_expression (this_parser, PT_DATABASE, NULL, NULL, NULL);
16411  PICE (node);
16412  $$ = node;
16413  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16414 
16415  DBG_PRINT}}
16416  | SCHEMA
16417  { push_msg(MSGCAT_SYNTAX_INVALID_SCHEMA); }
16418  '(' ')'
16419  { pop_msg(); }
16420  {{
16421 
16422  PT_NODE *node = parser_make_expression (this_parser, PT_SCHEMA, NULL, NULL, NULL);
16423  PICE (node);
16424  $$ = node;
16425  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16426 
16427  DBG_PRINT}}
16428  | TRIM
16429  { push_msg(MSGCAT_SYNTAX_INVALID_TRIM); }
16430  '(' of_leading_trailing_both expression_ FROM expression_ ')'
16431  { pop_msg(); }
16432  {{
16433 
16434  PT_NODE *node = parser_make_expression (this_parser, PT_TRIM, $7, $5, NULL);
16435  node->info.expr.qualifier = $4;
16436  PICE (node);
16437  $$ = node;
16438  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16439 
16440  DBG_PRINT}}
16441  | TRIM
16442  { push_msg(MSGCAT_SYNTAX_INVALID_TRIM); }
16443  '(' of_leading_trailing_both FROM expression_ ')'
16444  { pop_msg(); }
16445  {{
16446 
16447  PT_NODE *node = parser_make_expression (this_parser, PT_TRIM, $6, NULL, NULL);
16448  node->info.expr.qualifier = $4;
16449  PICE (node);
16450  $$ = node;
16451  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16452 
16453  DBG_PRINT}}
16454  | TRIM
16455  { push_msg(MSGCAT_SYNTAX_INVALID_TRIM); }
16456  '(' expression_ FROM expression_ ')'
16457  { pop_msg(); }
16458  {{
16459 
16460  PT_NODE *node = parser_make_expression (this_parser, PT_TRIM, $6, $4, NULL);
16461  node->info.expr.qualifier = PT_BOTH;
16462  PICE (node);
16463  $$ = node;
16464  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16465 
16466  DBG_PRINT}}
16467  | TRIM
16468  { push_msg(MSGCAT_SYNTAX_INVALID_TRIM); }
16469  '(' expression_ ')'
16470  { pop_msg(); }
16471  {{
16472 
16473  PT_NODE *node = parser_make_expression (this_parser, PT_TRIM, $4, NULL, NULL);
16474  node->info.expr.qualifier = PT_BOTH;
16475  PICE (node);
16476  $$ = node;
16477  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16478 
16479  DBG_PRINT}}
16480  | CHR
16481  { push_msg(MSGCAT_SYNTAX_INVALID_CHR); }
16482  '(' expression_ opt_using_charset ')'
16483  { pop_msg(); }
16484  {{
16485 
16486  PT_NODE *node = parser_make_expression (this_parser, PT_CHR, $4, $5, NULL);
16487  PICE (node);
16488  $$ = node;
16489  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16490 
16491  DBG_PRINT}}
16492  | CLOB_TO_CHAR
16493  { push_msg(MSGCAT_SYNTAX_INVALID_CLOB_TO_CHAR); }
16494  '(' expression_ opt_using_charset ')'
16495  { pop_msg(); }
16496  {{
16497 
16498  PT_NODE *node = parser_make_expression (this_parser, PT_CLOB_TO_CHAR, $4, $5, NULL);
16499  PICE (node);
16500  $$ = node;
16501  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16502 
16503  DBG_PRINT}}
16504  | CAST
16505  { push_msg(MSGCAT_SYNTAX_INVALID_CAST); }
16506  '(' expression_ AS of_cast_data_type ')'
16507  { pop_msg(); }
16508  {{
16509 
16510  PT_NODE *expr = parser_make_expression (this_parser, PT_CAST, $4, NULL, NULL);
16511  PT_TYPE_ENUM typ = TO_NUMBER (CONTAINER_AT_0 ($6));
16512  PT_NODE *dt = CONTAINER_AT_1 ($6);
16513  PT_NODE *set_dt;
16514 
16515  if (!dt)
16516  {
16517  dt = parser_new_node (this_parser, PT_DATA_TYPE);
16518  dt->type_enum = TO_NUMBER (CONTAINER_AT_0 ($6));
16519  dt->data_type = NULL;
16520  }
16521  else if (typ == PT_TYPE_SET || typ == PT_TYPE_MULTISET
16522  || typ == PT_TYPE_SEQUENCE)
16523  {
16524  set_dt = parser_new_node (this_parser, PT_DATA_TYPE);
16525  set_dt->type_enum = typ;
16526  set_dt->data_type = dt;
16527  dt = set_dt;
16528  }
16529  if (dt->type_enum == PT_TYPE_ENUMERATION)
16530  {
16531  (void) pt_check_enum_data_type(this_parser, dt);
16532  }
16533 
16534  expr->info.expr.cast_type = dt;
16535  $$ = expr;
16536  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16537 
16538  DBG_PRINT}}
16539  | CLASS '(' identifier ')'
16540  {{
16541 
16542  $3->info.name.meta_class = PT_OID_ATTR;
16543  $$ = $3;
16544  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16545  parser_groupby_exception = PT_OID_ATTR;
16546 
16547  DBG_PRINT}}
16548  | SYS_DATE
16549  {{
16550 
16551  PT_NODE *expr = parser_make_expression (this_parser, PT_SYS_DATE, NULL, NULL, NULL);
16552  $$ = expr;
16553  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16554 
16555  DBG_PRINT}}
16556  | of_current_date
16557  {{
16558 
16559  PT_NODE *expr = parser_make_expression (this_parser, PT_CURRENT_DATE, NULL, NULL, NULL);
16560  $$ = expr;
16561  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16562 
16563  DBG_PRINT}}
16564  | SYS_TIME_
16565  {{
16566 
16567  PT_NODE *expr = parser_make_expression (this_parser, PT_SYS_TIME, NULL, NULL, NULL);
16568  $$ = expr;
16569  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16570 
16571  DBG_PRINT}}
16572  | of_current_time
16573  {{
16574 
16575  PT_NODE *expr = parser_make_expression (this_parser, PT_CURRENT_TIME, NULL, NULL, NULL);
16576  $$ = expr;
16577  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16578 
16579  DBG_PRINT}}
16580  | of_db_timezone_
16581  {{
16582 
16583  PT_NODE *expr = parser_make_expression (this_parser, PT_DBTIMEZONE, NULL, NULL, NULL);
16584  $$ = expr;
16585  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16586 
16587  DBG_PRINT}}
16588  | of_session_timezone_
16589  {{
16590 
16591  PT_NODE *expr = parser_make_expression (this_parser, PT_SESSIONTIMEZONE, NULL, NULL, NULL);
16592  $$ = expr;
16593  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16594 
16595  DBG_PRINT}}
16596  | SYS_TIMESTAMP
16597  {{
16598 
16599  PT_NODE *expr = parser_make_expression (this_parser, PT_SYS_TIMESTAMP, NULL, NULL, NULL);
16600  $$ = expr;
16601  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16602 
16603  DBG_PRINT}}
16604  | of_current_timestamps
16605  {{
16606 
16607  PT_NODE *expr = parser_make_expression (this_parser, PT_CURRENT_TIMESTAMP, NULL, NULL, NULL);
16608  $$ = expr;
16609  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16610 
16611  DBG_PRINT}}
16612  | SYS_DATETIME
16613  {{
16614 
16615  PT_NODE *expr = parser_make_expression (this_parser, PT_SYS_DATETIME, NULL, NULL, NULL);
16616  $$ = expr;
16617  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16618 
16619  DBG_PRINT}}
16620  | of_current_datetime
16621  {{
16622 
16623  PT_NODE *expr = parser_make_expression (this_parser, PT_CURRENT_DATETIME, NULL, NULL, NULL);
16624  $$ = expr;
16625  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16626 
16627  DBG_PRINT}}
16628  | of_users
16629  {{
16630 
16631  PT_NODE *node = parser_new_node (this_parser, PT_EXPR);
16632  if (node)
16633  node->info.expr.op = PT_CURRENT_USER;
16634 
16635  parser_cannot_cache = true;
16636  $$ = node;
16637  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16638 
16639  DBG_PRINT}}
16640  | of_users
16641  { push_msg(MSGCAT_SYNTAX_INVALID_SYSTEM_USER); }
16642  '(' ')'
16643  { pop_msg(); }
16644  {{
16645 
16646  PT_NODE *node = parser_make_expression (this_parser, PT_USER, NULL, NULL, NULL);
16647  PICE (node);
16648  $$ = node;
16649  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16650 
16651  DBG_PRINT}}
16652  | DEFAULT '('
16653  { push_msg(MSGCAT_SYNTAX_INVALID_DEFAULT); }
16654  simple_path_id ')'
16655  { pop_msg(); }
16656  {{
16657 
16658  PT_NODE *node = NULL;
16659  PT_NODE *path = $4;
16660 
16661  if (path != NULL)
16662  {
16663  pt_set_fill_default_in_path_expression (path);
16664  node = parser_make_expression (this_parser, PT_DEFAULTF, path, NULL, NULL);
16665  PICE (node);
16666  }
16667  $$ = node;
16668  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16669 
16670  DBG_PRINT}}
16671  | LOCAL_TRANSACTION_ID
16672  {{
16673 
16674  PT_NODE *node = parser_new_node (this_parser, PT_EXPR);
16675  if (node)
16676  node->info.expr.op = PT_LOCAL_TRANSACTION_ID;
16677 
16678  parser_si_tran_id = true;
16679  parser_cannot_cache = true;
16680  $$ = node;
16681  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16682 
16683  DBG_PRINT}}
16684  | ROWNUM
16685  {{
16686 
16687  PT_NODE *node = parser_new_node (this_parser, PT_EXPR);
16688 
16689  if (node)
16690  {
16691  node->info.expr.op = PT_ROWNUM;
16692  PT_EXPR_INFO_SET_FLAG (node, PT_EXPR_INFO_INSTNUM_C);
16693  }
16694 
16695  $$ = node;
16696  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16697  parser_groupby_exception = PT_ROWNUM;
16698 
16699  if (parser_instnum_check == 0)
16700  PT_ERRORmf2 (this_parser, node, MSGCAT_SET_PARSER_SEMANTIC,
16701  MSGCAT_SEMANTIC_INSTNUM_COMPATIBILITY_ERR,
16702  "INST_NUM() or ROWNUM", "INST_NUM() or ROWNUM");
16703 
16704  DBG_PRINT}}
16705  | ADD_MONTHS
16706  { push_msg(MSGCAT_SYNTAX_INVALID_ADD_MONTHS); }
16707  '(' expression_ ',' expression_ ')'
16708  { pop_msg(); }
16709  {{
16710 
16711  $$ = parser_make_expression (this_parser, PT_ADD_MONTHS, $4, $6, NULL);
16712  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16713 
16714  DBG_PRINT}}
16715  | OCTET_LENGTH
16716  { push_msg(MSGCAT_SYNTAX_INVALID_OCTET_LENGTH); }
16717  '(' expression_ ')'
16718  { pop_msg(); }
16719  {{
16720 
16721  $$ = parser_make_expression (this_parser, PT_OCTET_LENGTH, $4, NULL, NULL);
16722  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16723 
16724  DBG_PRINT}}
16725  | BIT_LENGTH
16726  { push_msg(MSGCAT_SYNTAX_INVALID_BIT_LENGTH); }
16727  '(' expression_ ')'
16728  { pop_msg(); }
16729  {{
16730 
16731  $$ = parser_make_expression (this_parser, PT_BIT_LENGTH, $4, NULL, NULL);
16732  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16733 
16734  DBG_PRINT}}
16735  | LOWER
16736  { push_msg(MSGCAT_SYNTAX_INVALID_LOWER); }
16737  '(' expression_ ')'
16738  { pop_msg(); }
16739  {{
16740 
16741  $$ = parser_make_expression (this_parser, PT_LOWER, $4, NULL, NULL);
16742  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16743 
16744  DBG_PRINT}}
16745  | LCASE
16746  { push_msg(MSGCAT_SYNTAX_INVALID_LOWER); }
16747  '(' expression_ ')'
16748  { pop_msg(); }
16749  {{
16750 
16751  $$ = parser_make_expression (this_parser, PT_LOWER, $4, NULL, NULL);
16752  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16753 
16754  DBG_PRINT}}
16755  | UPPER
16756  { push_msg(MSGCAT_SYNTAX_INVALID_UPPER); }
16757  '(' expression_ ')'
16758  { pop_msg(); }
16759  {{
16760 
16761  $$ = parser_make_expression (this_parser, PT_UPPER, $4, NULL, NULL);
16762  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16763 
16764  DBG_PRINT}}
16765  | UCASE
16766  { push_msg(MSGCAT_SYNTAX_INVALID_UPPER); }
16767  '(' expression_ ')'
16768  { pop_msg(); }
16769  {{
16770 
16771  $$ = parser_make_expression (this_parser, PT_UPPER, $4, NULL, NULL);
16772  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16773 
16774  DBG_PRINT}}
16775  | SYS_CONNECT_BY_PATH
16776  {{
16777 
16778  push_msg(MSGCAT_SYNTAX_INVALID_SYS_CONNECT_BY_PATH);
16779 
16780  parser_save_and_set_sysc (0);
16781  parser_save_and_set_prc (0);
16782  parser_save_and_set_cbrc (0);
16783  parser_save_and_set_pseudoc (0);
16784 
16785  }}
16786  '(' expression_ ',' char_string_literal ')'
16787  { pop_msg(); }
16788  {{
16789 
16790  PT_NODE *node = parser_make_expression (this_parser, PT_SYS_CONNECT_BY_PATH, $4, $6, NULL);
16791  PT_NODE *char_string_node = $6;
16792 
16793  pt_value_set_collation_info (this_parser, char_string_node, NULL);
16794 
16795  PARSER_SAVE_ERR_CONTEXT (node, @$.buffer_pos)
16796 
16797  parser_restore_sysc ();
16798  parser_restore_prc ();
16799  parser_restore_cbrc ();
16800  parser_restore_pseudoc ();
16801  if (parser_sysconnectbypath_check == 0)
16802  {
16803  PT_ERRORmf(this_parser, node, MSGCAT_SET_PARSER_SEMANTIC,
16804  MSGCAT_SEMANTIC_NOT_ALLOWED_HERE, "SYS_CONNECT_BY_PATH");
16805  }
16806  $$ = node;
16807 
16808  DBG_PRINT}}
16809  | IF
16810  { push_msg (MSGCAT_SYNTAX_INVALID_IF); }
16811  '(' search_condition ',' expression_ ',' expression_ ')'
16812  { pop_msg(); }
16813  {{
16814 
16815  $$ = parser_make_expression (this_parser, PT_IF, $4, $6, $8);
16816  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16817 
16818  DBG_PRINT}}
16819  | IFNULL
16820  { push_msg (MSGCAT_SYNTAX_INVALID_IFNULL); }
16821  '(' expression_ ',' expression_ ')'
16822  { pop_msg(); }
16823  {{
16824 
16825  $$ = parser_make_expression (this_parser, PT_IFNULL, $4, $6, NULL);
16826  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16827 
16828  DBG_PRINT}}
16829  | ISNULL
16830  { push_msg (MSGCAT_SYNTAX_INVALID_ISNULL); }
16831  '(' expression_ ')'
16832  { pop_msg(); }
16833  {{
16834 
16835  $$ = parser_make_expression (this_parser, PT_ISNULL, $4, NULL, NULL);
16836  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16837 
16838  DBG_PRINT}}
16839  | LEFT
16840  { push_msg(MSGCAT_SYNTAX_INVALID_LEFT); }
16841  '(' expression_ ',' expression_ ')'
16842  { pop_msg(); }
16843  {{
16844  PT_NODE *node =
16845  parser_make_expression (this_parser, PT_LEFT, $4, $6, NULL);
16846  PICE (node);
16847  $$ = node;
16848  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16849 
16850  DBG_PRINT}}
16851  | RIGHT
16852  { push_msg(MSGCAT_SYNTAX_INVALID_RIGHT); }
16853  '(' expression_ ',' expression_ ')'
16854  { pop_msg(); }
16855  {{
16856  PT_NODE *node =
16857  parser_make_expression (this_parser, PT_RIGHT, $4, $6, NULL);
16858  PICE (node);
16859  $$ = node;
16860  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16861 
16862  DBG_PRINT}}
16863  | MOD
16864  { push_msg(MSGCAT_SYNTAX_INVALID_MODULUS); }
16865  '(' expression_ ',' expression_ ')'
16866  { pop_msg(); }
16867  {{
16868  PT_NODE *node =
16869  parser_make_expression (this_parser, PT_MODULUS, $4, $6, NULL);
16870  PICE (node);
16871  $$ = node;
16872  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16873 
16874  DBG_PRINT}}
16875  | TRUNCATE
16876  { push_msg(MSGCAT_SYNTAX_INVALID_TRUNCATE); }
16877  '(' expression_ ',' expression_ ')'
16878  { pop_msg(); }
16879  {{
16880 
16881  $$ = parser_make_expression (this_parser, PT_TRUNC, $4, $6, NULL);
16882  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16883 
16884  DBG_PRINT}}
16885  | TRANSLATE
16886  { push_msg(MSGCAT_SYNTAX_INVALID_TRANSLATE); }
16887  '(' expression_ ',' expression_ ',' expression_ ')'
16888  { pop_msg(); }
16889  {{
16890 
16891  $$ = parser_make_expression (this_parser, PT_TRANSLATE, $4, $6, $8);
16892  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16893 
16894  DBG_PRINT}}
16895  | REPLACE
16896  { push_msg(MSGCAT_SYNTAX_INVALID_TRANSLATE); }
16897  '(' expression_ ',' expression_ ',' expression_ ')'
16898  { pop_msg(); }
16899  {{
16900 
16901  $$ = parser_make_expression (this_parser, PT_REPLACE, $4, $6, $8);
16902  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16903 
16904  DBG_PRINT}}
16905  | REPLACE
16906  { push_msg(MSGCAT_SYNTAX_INVALID_REPLACE); }
16907  '(' expression_ ',' expression_ ')'
16908  { pop_msg(); }
16909  {{
16910 
16911  $$ = parser_make_expression (this_parser, PT_REPLACE, $4, $6, NULL);
16912  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16913 
16914  DBG_PRINT}}
16915  | STR_TO_DATE
16916  { push_msg(MSGCAT_SYNTAX_INVALID_STRTODATE); }
16917  '(' expression_ ',' string_literal_or_input_hv ')'
16918  { pop_msg(); }
16919  {{
16920 
16921  $$ = parser_make_expression (this_parser, PT_STR_TO_DATE, $4, $6, parser_make_date_lang (2, NULL));
16922  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16923 
16924  DBG_PRINT}}
16925  | STR_TO_DATE
16926  { push_msg(MSGCAT_SYNTAX_INVALID_STRTODATE); }
16927  '(' expression_ ',' Null ')'
16928  { pop_msg(); }
16929  {{
16930  PT_NODE *node = parser_new_node (this_parser, PT_VALUE);
16931  if (node)
16932  {
16933  node->type_enum = PT_TYPE_NULL;
16934  node->flag.is_added_by_parser = 1;
16935  }
16936 
16937  $$ = parser_make_expression (this_parser, PT_STR_TO_DATE, $4, node, parser_make_date_lang (2, NULL));
16938  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16939 
16940  DBG_PRINT}}
16941  | CHARSET
16942  { push_msg(MSGCAT_SYNTAX_INVALID_CHARSET); }
16943  '(' expression_ ')'
16944  { pop_msg(); }
16945  {{
16946  PT_NODE *node =
16947  parser_make_expression (this_parser, PT_CHARSET, $4, NULL, NULL);
16948  PICE (node);
16949  $$ = node;
16950  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16951 
16952  DBG_PRINT}}
16953  | COLLATION
16954  { push_msg(MSGCAT_SYNTAX_INVALID_COLLATION); }
16955  '(' expression_ ')'
16956  { pop_msg(); }
16957  {{
16958  PT_NODE *node =
16959  parser_make_expression (this_parser, PT_COLLATION, $4, NULL, NULL);
16960  PICE (node);
16961  $$ = node;
16962  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16963 
16964  DBG_PRINT}}
16965  | of_cume_dist_percent_rank_function '(' expression_list ')' WITHIN GROUP_ '('ORDER BY sort_spec_list')'
16966  {{
16967 
16968  PT_NODE *node = parser_new_node (this_parser, PT_FUNCTION);
16969  if (node)
16970  {
16971  node->info.function.function_type = $1;
16972  node->info.function.all_or_distinct = PT_ALL;
16973  node->info.function.arg_list = $3;
16974  node->info.function.analytic.is_analytic = false;
16975  node->info.function.order_by = $10;
16976  }
16977 
16978  $$ = node;
16979  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16980  DBG_PRINT}}
16981  | INDEX_PREFIX
16982  { push_msg(MSGCAT_SYNTAX_INVALID_INDEX_PREFIX); }
16983  '(' expression_ ',' expression_ ',' expression_ ')'
16984  { pop_msg(); }
16985  {{
16986 
16987  $$ = parser_make_expression (this_parser, PT_INDEX_PREFIX, $4, $6, $8);
16988  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16989 
16990  DBG_PRINT}}
16991  | JSON_ARRAY_APPEND '(' expression_list ')'
16992  {{
16993  $$ = parser_make_func_with_arg_count_mod2 (this_parser, F_JSON_ARRAY_APPEND, $3, 3, 0, 1);
16994  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
16995  DBG_PRINT}}
16996  | JSON_ARRAY_INSERT '(' expression_list ')'
16997  {{
16998  $$ = parser_make_func_with_arg_count_mod2 (this_parser, F_JSON_ARRAY_INSERT, $3, 3, 0, 1);
16999  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17000  DBG_PRINT}}
17001  | JSON_ARRAY_LEX '(' opt_expression_list ')'
17002  {{
17003  $$ = parser_make_func_with_arg_count (this_parser, F_JSON_ARRAY, $3, 0, 0);
17004  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17005  DBG_PRINT}}
17006  | JSON_CONTAINS '(' expression_list ')'
17007  {{
17008  $$ = parser_make_func_with_arg_count (this_parser, F_JSON_CONTAINS, $3, 2, 3);
17009  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17010  DBG_PRINT}}
17011  | JSON_CONTAINS_PATH '(' expression_list ')'
17012  {{
17013  $$ = parser_make_func_with_arg_count (this_parser, F_JSON_CONTAINS_PATH, $3, 3, 0);
17014  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17015  DBG_PRINT}}
17016  | JSON_DEPTH '(' expression_list ')'
17017  {{
17018  $$ = parser_make_func_with_arg_count (this_parser, F_JSON_DEPTH, $3, 1, 1);
17019  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17020  DBG_PRINT}}
17021  | JSON_EXTRACT '(' expression_list ')'
17022  {{
17023  $$ = parser_make_func_with_arg_count (this_parser, F_JSON_EXTRACT, $3, 2, 0);
17024  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17025  DBG_PRINT}}
17026  | JSON_GET_ALL_PATHS '(' expression_list ')'
17027  {{
17028  $$ = parser_make_func_with_arg_count (this_parser, F_JSON_GET_ALL_PATHS, $3, 1, 1);
17029  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17030  DBG_PRINT}}
17031  | JSON_INSERT '(' expression_list ')'
17032  {{
17033  $$ = parser_make_func_with_arg_count_mod2 (this_parser, F_JSON_INSERT, $3, 3, 0, 1);
17034  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17035  DBG_PRINT}}
17036  | JSON_KEYS '(' expression_list ')'
17037  {{
17038  $$ = parser_make_func_with_arg_count (this_parser, F_JSON_KEYS, $3, 0, 2);
17039  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17040  DBG_PRINT}}
17041  | JSON_LENGTH '(' expression_list ')'
17042  {{
17043  $$ = parser_make_func_with_arg_count (this_parser, F_JSON_LENGTH, $3, 1, 2);
17044  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17045  DBG_PRINT}}
17046  | JSON_MERGE '(' expression_list ')'
17047  {{
17048  $$ = parser_make_func_with_arg_count (this_parser, F_JSON_MERGE, $3, 2, 0);
17049  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17050  DBG_PRINT}}
17051  | JSON_MERGE_PATCH '(' expression_list ')'
17052  {{
17053  $$ = parser_make_func_with_arg_count (this_parser, F_JSON_MERGE_PATCH, $3, 2, 0);
17054  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17055  DBG_PRINT}}
17056  | JSON_MERGE_PRESERVE '(' expression_list ')'
17057  {{
17058  $$ = parser_make_func_with_arg_count (this_parser, F_JSON_MERGE, $3, 2, 0);
17059  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17060  DBG_PRINT}}
17061  | JSON_OBJECT_LEX '(' opt_expression_list ')'
17062  {{
17063  $$ = parser_make_func_with_arg_count_mod2 (this_parser, F_JSON_OBJECT, $3, 0, 0, 0);
17064  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17065  DBG_PRINT}}
17066  | JSON_PRETTY '(' expression_list ')'
17067  {{
17068  $$ = parser_make_func_with_arg_count (this_parser, F_JSON_PRETTY, $3, 1, 1);
17069  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17070  DBG_PRINT}}
17071  | JSON_QUOTE '(' expression_list ')'
17072  {{
17073  $$ = parser_make_func_with_arg_count (this_parser, F_JSON_QUOTE, $3, 1, 1);
17074  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17075  DBG_PRINT}}
17076  | JSON_REMOVE '(' expression_list ')'
17077  {{
17078  $$ = parser_make_func_with_arg_count (this_parser, F_JSON_REMOVE, $3, 2, 0);
17079  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17080  DBG_PRINT}}
17081  | JSON_REPLACE '(' expression_list ')'
17082  {{
17083  $$ = parser_make_func_with_arg_count_mod2 (this_parser, F_JSON_REPLACE, $3, 3, 0, 1);
17084  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17085  DBG_PRINT}}
17086  | JSON_SET '(' expression_list ')'
17087  {{
17088  $$ = parser_make_func_with_arg_count_mod2 (this_parser, F_JSON_SET, $3, 3, 0, 1);
17089  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17090  DBG_PRINT}}
17091  | JSON_SEARCH '(' expression_list ')'
17092  {{
17093  $$ = parser_make_func_with_arg_count (this_parser, F_JSON_SEARCH, $3, 3, 0);
17094  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17095  DBG_PRINT}}
17096  | JSON_TYPE '(' expression_list ')'
17097  {{
17098  $$ = parser_make_func_with_arg_count (this_parser, F_JSON_TYPE, $3, 1, 1);
17099  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17100  DBG_PRINT}}
17101  | JSON_UNQUOTE '(' expression_list ')'
17102  {{
17103  $$ = parser_make_func_with_arg_count (this_parser, F_JSON_UNQUOTE, $3, 1, 1);
17104  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17105  DBG_PRINT}}
17106  | JSON_VALID '(' expression_list ')'
17107  {{
17108  $$ = parser_make_func_with_arg_count (this_parser, F_JSON_VALID, $3, 1, 1);
17109  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17110  DBG_PRINT}}
17111  | simple_path_id RIGHT_ARROW CHAR_STRING
17112  {{
17113  PT_NODE *matcher = parser_new_node (this_parser, PT_VALUE);
17114  if (matcher != NULL)
17115  {
17116  matcher->type_enum = PT_TYPE_CHAR;
17117  matcher->info.value.string_type = ' ';
17118  matcher->info.value.data_value.str = pt_append_bytes (this_parser, NULL, $3, strlen ($3));
17119  PT_NODE_PRINT_VALUE_TO_TEXT (this_parser, matcher);
17120  }
17121  PT_NODE *first_arg = $1;
17122  first_arg->next = matcher;
17123  $$ = parser_make_expr_with_func (this_parser, F_JSON_EXTRACT, first_arg);
17124  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17125  DBG_PRINT}}
17126  | simple_path_id DOUBLE_RIGHT_ARROW CHAR_STRING
17127  {{
17128  PT_NODE *matcher = parser_new_node (this_parser, PT_VALUE);
17129  if (matcher != NULL)
17130  {
17131  matcher->type_enum = PT_TYPE_CHAR;
17132  matcher->info.value.string_type = ' ';
17133  matcher->info.value.data_value.str = pt_append_bytes (this_parser, NULL, $3, strlen ($3));
17134  PT_NODE_PRINT_VALUE_TO_TEXT (this_parser, matcher);
17135  }
17136  PT_NODE *first_arg = $1;
17137  first_arg->next = matcher;
17138  PT_NODE *extract_expr = parser_make_expr_with_func (this_parser, F_JSON_EXTRACT, first_arg);
17139  $$ = parser_make_expr_with_func (this_parser, F_JSON_UNQUOTE, extract_expr);
17140  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17141  DBG_PRINT}}
17142  | BENCHMARK '(' expression_list ')'
17143  {{
17144  $$ = parser_make_func_with_arg_count (this_parser, F_BENCHMARK, $3, 2, 2);
17145  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17146  DBG_PRINT}}
17147  | REGEXP_COUNT '(' expression_list ')'
17148  {{
17149  $$ = parser_make_func_with_arg_count (this_parser, F_REGEXP_COUNT, $3, 2, 4);
17150  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17151  DBG_PRINT}}
17152  | REGEXP_INSTR '(' expression_list ')'
17153  {{
17154  $$ = parser_make_func_with_arg_count (this_parser, F_REGEXP_INSTR, $3, 2, 6);
17155  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17156  DBG_PRINT}}
17157  | REGEXP_LIKE '(' expression_list ')'
17158  {{
17159  $$ = parser_make_func_with_arg_count (this_parser, F_REGEXP_LIKE, $3, 2, 3);
17160  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17161  DBG_PRINT}}
17162  | REGEXP_REPLACE '(' expression_list ')'
17163  {{
17164  $$ = parser_make_func_with_arg_count (this_parser, F_REGEXP_REPLACE, $3, 3, 6);
17165  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17166  DBG_PRINT}}
17167  | REGEXP_SUBSTR '(' expression_list ')'
17168  {{
17169  $$ = parser_make_func_with_arg_count (this_parser, F_REGEXP_SUBSTR, $3, 2, 5);
17170  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17171  DBG_PRINT}}
17172  ;
17173 
17174 of_cume_dist_percent_rank_function
17175  : CUME_DIST
17176  {{
17177  $$ = PT_CUME_DIST;
17178  DBG_PRINT}}
17179 
17180  |PERCENT_RANK
17181  {{
17182  $$ = PT_PERCENT_RANK;
17183  DBG_PRINT}}
17184  ;
17185 
17186 of_current_date
17187  : CURRENT_DATE
17188  | CURRENT_DATE
17189  { push_msg(MSGCAT_SYNTAX_INVALID_CURRENT_DATE); }
17190  '(' ')'
17191  { pop_msg(); }
17192  ;
17193 
17194 of_current_time
17195  : CURRENT_TIME
17196  | CURRENT_TIME
17197  { push_msg(MSGCAT_SYNTAX_INVALID_CURRENT_TIME); }
17198  '(' ')'
17199  { pop_msg(); }
17200  ;
17201 
17202 of_db_timezone_
17203  : DB_TIMEZONE
17204  | DB_TIMEZONE
17205  { push_msg(MSGCAT_SYNTAX_INVALID_DB_TIMEZONE); }
17206  '(' ')'
17207  { pop_msg(); }
17208  ;
17209 
17210 of_session_timezone_
17211  : SESSION_TIMEZONE
17212  | SESSION_TIMEZONE
17213  { push_msg(MSGCAT_SYNTAX_INVALID_SESSION_TIMEZONE); }
17214  '('')'
17215  { pop_msg(); }
17216  ;
17217 
17218 of_current_timestamps
17219  : CURRENT_TIMESTAMP
17220  | CURRENT_TIMESTAMP
17221  { push_msg(MSGCAT_SYNTAX_INVALID_CURRENT_TIMESTAMP); }
17222  '(' ')'
17223  { pop_msg(); }
17224  | LOCALTIMESTAMP
17225  | LOCALTIMESTAMP
17226  { push_msg(MSGCAT_SYNTAX_INVALID_LOCALTIMESTAMP); }
17227  '(' ')'
17228  { pop_msg(); }
17229  | LOCALTIME
17230  | LOCALTIME
17231  { push_msg(MSGCAT_SYNTAX_INVALID_LOCALTIME); }
17232  '(' ')'
17233  { pop_msg(); }
17234  ;
17235 
17236 of_current_datetime
17237  : CURRENT_DATETIME
17238  | CURRENT_DATETIME
17239  { push_msg(MSGCAT_SYNTAX_INVALID_CURRENT_DATETIME); }
17240  '(' ')'
17241  { pop_msg(); }
17242  ;
17243 of_users
17244  : CURRENT_USER
17245  | SYSTEM_USER
17246  | USER
17247  ;
17248 
17249 of_avg_max_etc
17250  : AVG
17251  {{
17252 
17253  $$ = PT_AVG;
17254 
17255  DBG_PRINT}}
17256  | Max
17257  {{
17258 
17259  $$ = PT_MAX;
17260 
17261  DBG_PRINT}}
17262  | Min
17263  {{
17264 
17265  $$ = PT_MIN;
17266 
17267  DBG_PRINT}}
17268  | SUM
17269  {{
17270 
17271  $$ = PT_SUM;
17272 
17273  DBG_PRINT}}
17274  | STDDEV
17275  {{
17276 
17277  $$ = PT_STDDEV;
17278 
17279  DBG_PRINT}}
17280  | STDDEV_POP
17281  {{
17282 
17283  $$ = PT_STDDEV_POP;
17284 
17285  DBG_PRINT}}
17286  | STDDEV_SAMP
17287  {{
17288 
17289  $$ = PT_STDDEV_SAMP;
17290 
17291  DBG_PRINT}}
17292  | VAR_POP
17293  {{
17294 
17295  $$ = PT_VAR_POP;
17296 
17297  DBG_PRINT}}
17298  | VAR_SAMP
17299  {{
17300 
17301  $$ = PT_VAR_SAMP;
17302 
17303  DBG_PRINT}}
17304  | VARIANCE
17305  {{
17306 
17307  $$ = PT_VARIANCE;
17308 
17309  DBG_PRINT}}
17310  | BIT_AND
17311  {{
17312 
17313  $$ = PT_AGG_BIT_AND;
17314 
17315  DBG_PRINT}}
17316  | BIT_OR
17317  {{
17318 
17319  $$ = PT_AGG_BIT_OR;
17320 
17321  DBG_PRINT}}
17322  | BIT_XOR
17323  {{
17324 
17325  $$ = PT_AGG_BIT_XOR;
17326 
17327  DBG_PRINT}}
17328  | MEDIAN
17329  {{
17330 
17331  $$ = PT_MEDIAN;
17332 
17333  DBG_PRINT}}
17334  ;
17335 
17336 of_analytic
17337  : AVG
17338  {{
17339 
17340  $$ = PT_AVG;
17341 
17342  DBG_PRINT}}
17343  | Max
17344  {{
17345 
17346  $$ = PT_MAX;
17347 
17348  DBG_PRINT}}
17349  | Min
17350  {{
17351 
17352  $$ = PT_MIN;
17353 
17354  DBG_PRINT}}
17355  | SUM
17356  {{
17357 
17358  $$ = PT_SUM;
17359 
17360  DBG_PRINT}}
17361  | STDDEV
17362  {{
17363 
17364  $$ = PT_STDDEV;
17365 
17366  DBG_PRINT}}
17367  | STDDEV_POP
17368  {{
17369 
17370  $$ = PT_STDDEV_POP;
17371 
17372  DBG_PRINT}}
17373  | STDDEV_SAMP
17374  {{
17375 
17376  $$ = PT_STDDEV_SAMP;
17377 
17378  DBG_PRINT}}
17379  | VAR_POP
17380  {{
17381 
17382  $$ = PT_VAR_POP;
17383 
17384  DBG_PRINT}}
17385  | VAR_SAMP
17386  {{
17387 
17388  $$ = PT_VAR_SAMP;
17389 
17390  DBG_PRINT}}
17391  | VARIANCE
17392  {{
17393 
17394  $$ = PT_VARIANCE;
17395 
17396  DBG_PRINT}}
17397  | NTILE
17398  {{
17399 
17400  $$ = PT_NTILE;
17401 
17402  DBG_PRINT}}
17403  | MEDIAN
17404  {{
17405 
17406  $$ = PT_MEDIAN;
17407 
17408  DBG_PRINT}}
17409  /* add other analytic functions here */
17410  ;
17411 
17412 of_analytic_first_last
17413  : FIRST_VALUE
17414  {{
17415 
17416  $$ = PT_FIRST_VALUE;
17417 
17418  DBG_PRINT}}
17419  | LAST_VALUE
17420  {{
17421 
17422  $$ = PT_LAST_VALUE;
17423 
17424  DBG_PRINT}}
17425  ;
17426 
17427 of_analytic_nth_value
17428  : NTH_VALUE
17429  {{
17430 
17431  $$ = PT_NTH_VALUE;
17432 
17433  DBG_PRINT}}
17434  ;
17435 
17436 of_analytic_lead_lag
17437  : LEAD
17438  {{
17439 
17440  $$ = PT_LEAD;
17441 
17442  DBG_PRINT}}
17443  | LAG
17444  {{
17445 
17446  $$ = PT_LAG;
17447 
17448  DBG_PRINT}}
17449  /* functions that use other row values */
17450  ;
17451 
17452 of_percentile
17453  : PERCENTILE_CONT
17454  {{
17455 
17456  $$ = PT_PERCENTILE_CONT;
17457 
17458  DBG_PRINT}}
17459  | PERCENTILE_DISC
17460  {{
17461 
17462  $$ = PT_PERCENTILE_DISC;
17463 
17464  DBG_PRINT}}
17465  ;
17466 
17467 of_analytic_no_args
17468  : ROW_NUMBER
17469  {{
17470 
17471  $$ = PT_ROW_NUMBER;
17472 
17473  DBG_PRINT}}
17474  | RANK
17475  {{
17476 
17477  $$ = PT_RANK;
17478 
17479  DBG_PRINT}}
17480  | DENSE_RANK
17481  {{
17482 
17483  $$ = PT_DENSE_RANK;
17484 
17485  DBG_PRINT}}
17486  | CUME_DIST
17487  {{
17488  $$ = PT_CUME_DIST;
17489 
17490  DBG_PRINT}}
17491  | PERCENT_RANK
17492  {{
17493  $$ = PT_PERCENT_RANK;
17494 
17495  DBG_PRINT}}
17496  /* add other analytic functions here */
17497  ;
17498 
17499 of_distinct_unique
17500  : DISTINCT
17501  | UNIQUE
17502  ;
17503 
17504 opt_group_concat_separator
17505  : /* empty */
17506  {{
17507 
17508  $$ = NULL;
17509 
17510  DBG_PRINT}}
17511  | SEPARATOR char_string
17512  {{
17513 
17514  $$ = $2;
17515  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17516 
17517  DBG_PRINT}}
17518  | SEPARATOR bit_string_literal
17519  {{
17520 
17521  $$ = $2;
17522  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17523 
17524  DBG_PRINT}}
17525  ;
17526 
17527 opt_agg_order_by
17528  : /* empty */
17529  {{
17530 
17531  $$ = NULL;
17532 
17533  DBG_PRINT}}
17534  | ORDER BY sort_spec
17535  {{
17536 
17537  $$ = $3;
17538  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17539 
17540  DBG_PRINT}}
17541  ;
17542 
17543 opt_analytic_from_last
17544  : /* empty */
17545  {{
17546 
17547  $$ = false;
17548 
17549  DBG_PRINT}}
17550  | FROM FIRST
17551  {{
17552 
17553  $$ = false;
17554 
17555  DBG_PRINT}}
17556  | FROM LAST
17557  {{
17558 
17559  $$ = true;
17560 
17561  DBG_PRINT}}
17562  ;
17563 
17564 opt_analytic_ignore_nulls
17565  : /* empty */
17566  {{
17567 
17568  $$ = false;
17569 
17570  DBG_PRINT}}
17571  | RESPECT NULLS
17572  {{
17573 
17574  $$ = false;
17575 
17576  DBG_PRINT}}
17577  | IGNORE_ NULLS
17578  {{
17579 
17580  $$ = true;
17581 
17582  DBG_PRINT}}
17583  ;
17584 
17585 opt_analytic_partition_by
17586  : /* empty */
17587  {{
17588 
17589  $$ = NULL;
17590 
17591  DBG_PRINT}}
17592  | PARTITION BY sort_spec_list
17593  {{
17594 
17595  PT_NODE *list;
17596  $$ = $3;
17597 
17598  for (list = $3; list != NULL; list = list->next)
17599  {
17600  if (list->info.sort_spec.expr != NULL)
17601  {
17602  list->info.sort_spec.expr->flag.do_not_fold = true;
17603  }
17604  }
17605 
17606  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17607 
17608  DBG_PRINT}}
17609  ;
17610 
17611 opt_over_analytic_partition_by
17612  : /* empty */
17613  {{
17614 
17615  is_analytic_function = false;
17616  $$ = NULL;
17617 
17618  DBG_PRINT}}
17619  | OVER '(' opt_analytic_partition_by ')'
17620  {{
17621 
17622  is_analytic_function = true;
17623  $$= $3;
17624 
17625  DBG_PRINT}}
17626  ;
17627 
17628 opt_analytic_order_by
17629  : /* empty */
17630  {{
17631 
17632  $$ = NULL;
17633 
17634  DBG_PRINT}}
17635  | ORDER BY sort_spec_list
17636  {{
17637 
17638  PT_NODE *list;
17639  $$ = $3;
17640 
17641  for (list = $3; list != NULL; list = list->next)
17642  {
17643  if (list->info.sort_spec.expr != NULL)
17644  {
17645  list->info.sort_spec.expr->flag.do_not_fold = true;
17646  }
17647  }
17648  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17649 
17650  DBG_PRINT}}
17651  ;
17652 
17653 of_leading_trailing_both
17654  : LEADING_
17655  {{
17656 
17657  $$ = PT_LEADING;
17658 
17659  DBG_PRINT}}
17660  | TRAILING_
17661  {{
17662 
17663  $$ = PT_TRAILING;
17664 
17665  DBG_PRINT}}
17666  | BOTH_
17667  {{
17668 
17669  $$ = PT_BOTH;
17670 
17671  DBG_PRINT}}
17672  ;
17673 
17674 case_expr
17675  : NULLIF '(' expression_ ',' expression_ ')'
17676  {{
17677  $$ = parser_make_expression (this_parser, PT_NULLIF, $3, $5, NULL);
17678  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17679  DBG_PRINT}}
17680  | COALESCE '(' expression_list ')'
17681  {{
17682  PT_NODE *prev, *expr, *arg, *tmp;
17683  int count = parser_count_list ($3);
17684  int i;
17685  arg = $3;
17686 
17687  expr = parser_new_node (this_parser, PT_EXPR);
17688  if (expr)
17689  {
17690  expr->info.expr.op = PT_COALESCE;
17691  expr->info.expr.arg1 = arg;
17692  expr->info.expr.arg2 = NULL;
17693  expr->info.expr.arg3 = NULL;
17694  expr->info.expr.continued_case = 1;
17695  }
17696 
17697  PICE (expr);
17698  prev = expr;
17699 
17700  if (count > 1)
17701  {
17702  tmp = arg;
17703  arg = arg->next;
17704  tmp->next = NULL;
17705  if (prev)
17706  prev->info.expr.arg2 = arg;
17707  PICE (prev);
17708  }
17709  for (i = 3; i <= count; i++)
17710  {
17711  tmp = arg;
17712  arg = arg->next;
17713  tmp->next = NULL;
17714 
17715  expr = parser_new_node (this_parser, PT_EXPR);
17716  if (expr)
17717  {
17718  expr->info.expr.op = PT_COALESCE;
17719  expr->info.expr.arg1 = prev;
17720  expr->info.expr.arg2 = arg;
17721  expr->info.expr.arg3 = NULL;
17722  expr->info.expr.continued_case = 1;
17723  }
17724  if (prev && prev->info.expr.continued_case >= 1)
17725  prev->info.expr.continued_case++;
17726  PICE (expr);
17727  prev = expr;
17728  }
17729 
17730  if (expr->info.expr.arg2 == NULL)
17731  {
17732  expr->info.expr.arg2 = parser_new_node (this_parser, PT_VALUE);
17733 
17734  if (expr->info.expr.arg2)
17735  {
17736  expr->info.expr.arg2->type_enum = PT_TYPE_NULL;
17737  expr->info.expr.arg2->flag.is_hidden_column = 1;
17738  expr->info.expr.arg2->flag.is_added_by_parser = 1;
17739  }
17740  }
17741 
17742  $$ = expr;
17743  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17744 
17745  DBG_PRINT}}
17746  | CASE expression_ simple_when_clause_list opt_else_expr END
17747  {{
17748 
17749  int i;
17750  PT_NODE *case_oper = $2;
17751  PT_NODE *node, *prev, *tmp, *curr, *p;
17752 
17753  int count = parser_count_list ($3);
17754  node = prev = $3;
17755  if (node)
17756  node->info.expr.continued_case = 0;
17757 
17758  tmp = $3;
17759  do
17760  {
17761  (tmp->info.expr.arg3)->info.expr.arg1 =
17762  parser_copy_tree_list (this_parser, case_oper);
17763  }
17764  while ((tmp = tmp->next))
17765  ;
17766 
17767  curr = node;
17768  for (i = 2; i <= count; i++)
17769  {
17770  curr = curr->next;
17771  if (curr)
17772  curr->info.expr.continued_case = 1;
17773  if (prev)
17774  prev->info.expr.arg2 = curr; /* else res */
17775  PICE (prev);
17776  prev->next = NULL;
17777  prev = curr;
17778  }
17779 
17780  p = $4;
17781  if (prev)
17782  prev->info.expr.arg2 = p;
17783  PICE (prev);
17784 
17785  if (prev && !prev->info.expr.arg2)
17786  {
17787  p = parser_new_node (this_parser, PT_VALUE);
17788  if (p)
17789  {
17790  p->type_enum = PT_TYPE_NULL;
17791  p->flag.is_added_by_parser = 1;
17792  }
17793  prev->info.expr.arg2 = p;
17794  PICE (prev);
17795  }
17796 
17797  if (case_oper)
17798  parser_free_node (this_parser, case_oper);
17799 
17800  $$ = node;
17801  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17802 
17803  DBG_PRINT}}
17804  | CASE searched_when_clause_list opt_else_expr END
17805  {{
17806 
17807  int i;
17808  PT_NODE *node, *prev, *curr, *p;
17809 
17810  int count = parser_count_list ($2);
17811  node = prev = $2;
17812  if (node)
17813  node->info.expr.continued_case = 0;
17814 
17815  curr = node;
17816  for (i = 2; i <= count; i++)
17817  {
17818  curr = curr->next;
17819  if (curr)
17820  curr->info.expr.continued_case = 1;
17821  if (prev)
17822  prev->info.expr.arg2 = curr; /* else res */
17823  PICE (prev);
17824  prev->next = NULL;
17825  prev = curr;
17826  }
17827 
17828  p = $3;
17829  if (prev)
17830  prev->info.expr.arg2 = p;
17831  PICE (prev);
17832 
17833  if (prev && !prev->info.expr.arg2)
17834  {
17835  p = parser_new_node (this_parser, PT_VALUE);
17836  if (p)
17837  {
17838  p->type_enum = PT_TYPE_NULL;
17839  p->flag.is_added_by_parser = 1;
17840  }
17841  prev->info.expr.arg2 = p;
17842  PICE (prev);
17843  }
17844 
17845  $$ = node;
17846  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17847 
17848  DBG_PRINT}}
17849  ;
17850 
17851 opt_else_expr
17852  : /* empty */
17853  {{
17854 
17855  $$ = NULL;
17856 
17857  DBG_PRINT}}
17858  | ELSE expression_
17859  {{
17860 
17861  $$ = $2;
17862  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17863 
17864  DBG_PRINT}}
17865  ;
17866 
17867 simple_when_clause_list
17868  : simple_when_clause_list simple_when_clause
17869  {{
17870 
17871  $$ = parser_make_link ($1, $2);
17872  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17873 
17874  DBG_PRINT}}
17875  | simple_when_clause
17876  {{
17877 
17878  $$ = $1;
17879  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17880 
17881  DBG_PRINT}}
17882  ;
17883 
17884 simple_when_clause
17885  : WHEN expression_ THEN expression_
17886  {{
17887 
17888  PT_NODE *node, *p, *q;
17889  p = $2;
17890  node = parser_new_node (this_parser, PT_EXPR);
17891  if (node)
17892  {
17893  node->info.expr.op = PT_CASE;
17894  node->info.expr.qualifier = PT_SIMPLE_CASE;
17895  q = parser_new_node (this_parser, PT_EXPR);
17896  if (q)
17897  {
17898  q->info.expr.op = PT_EQ;
17899  q->info.expr.arg2 = p;
17900  node->info.expr.arg3 = q;
17901  PICE (q);
17902  }
17903  }
17904 
17905  p = $4;
17906  if (node)
17907  node->info.expr.arg1 = p;
17908  PICE (node);
17909 
17910  $$ = node;
17911  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17912 
17913  DBG_PRINT}}
17914  ;
17915 
17916 searched_when_clause_list
17917  : searched_when_clause_list searched_when_clause
17918  {{
17919 
17920  $$ = parser_make_link ($1, $2);
17921  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17922 
17923  DBG_PRINT}}
17924  | searched_when_clause
17925  {{
17926 
17927  $$ = $1;
17928  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17929 
17930  DBG_PRINT}}
17931  ;
17932 
17933 searched_when_clause
17934  : WHEN search_condition THEN expression_
17935  {{
17936 
17937  PT_NODE *node, *p;
17938  node = parser_new_node (this_parser, PT_EXPR);
17939  if (node)
17940  {
17941  node->info.expr.op = PT_CASE;
17942  node->info.expr.qualifier = PT_SEARCHED_CASE;
17943  }
17944 
17945  p = $2;
17946  if (node)
17947  node->info.expr.arg3 = p;
17948  PICE (node);
17949 
17950  p = $4;
17951  if (node)
17952  node->info.expr.arg1 = p;
17953  PICE (node);
17954 
17955  $$ = node;
17956  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17957 
17958  DBG_PRINT}}
17959  ;
17960 
17961 
17962 extract_expr
17963  : EXTRACT '(' datetime_field FROM expression_ ')'
17964  {{
17965 
17966  PT_NODE *tmp;
17967  tmp = parser_make_expression (this_parser, PT_EXTRACT, $5, NULL, NULL);
17968  if (tmp)
17969  tmp->info.expr.qualifier = $3;
17970  $$ = tmp;
17971  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
17972 
17973  DBG_PRINT}}
17974  ;
17975 
17976 adddate_name
17977  : DATE_ADD
17978  | ADDDATE
17979  ;
17980 
17981 subdate_name
17982  : DATE_SUB
17983  | SUBDATE
17984  ;
17985 
17986 datetime_field
17987  : YEAR_
17988  {{
17989 
17990  $$ = PT_YEAR;
17991 
17992  DBG_PRINT}}
17993  | MONTH_
17994  {{
17995 
17996  $$ = PT_MONTH;
17997 
17998  DBG_PRINT}}
17999  | DAY_
18000  {{
18001 
18002  $$ = PT_DAY;
18003 
18004  DBG_PRINT}}
18005  | HOUR_
18006  {{
18007 
18008  $$ = PT_HOUR;
18009 
18010  DBG_PRINT}}
18011  | MINUTE_
18012  {{
18013 
18014  $$ = PT_MINUTE;
18015 
18016  DBG_PRINT}}
18017  | SECOND_
18018  {{
18019 
18020  $$ = PT_SECOND;
18021 
18022  DBG_PRINT}}
18023  | MILLISECOND_
18024  {{
18025 
18026  $$ = PT_MILLISECOND;
18027 
18028  DBG_PRINT}}
18029  | WEEK
18030  {{
18031 
18032  $$ = PT_WEEK;
18033 
18034  DBG_PRINT}}
18035  | QUARTER
18036  {{
18037 
18038  $$ = PT_QUARTER;
18039 
18040  DBG_PRINT}}
18041  | SECOND_MILLISECOND
18042  {{
18043 
18044  $$ = PT_SECOND_MILLISECOND;
18045 
18046  DBG_PRINT}}
18047  | MINUTE_MILLISECOND
18048  {{
18049 
18050  $$ = PT_MINUTE_MILLISECOND;
18051 
18052  DBG_PRINT}}
18053  | MINUTE_SECOND
18054  {{
18055 
18056  $$ = PT_MINUTE_SECOND;
18057 
18058  DBG_PRINT}}
18059  | HOUR_MILLISECOND
18060  {{
18061 
18062  $$ = PT_HOUR_MILLISECOND;
18063 
18064  DBG_PRINT}}
18065  | HOUR_SECOND
18066  {{
18067 
18068  $$ = PT_HOUR_SECOND;
18069 
18070  DBG_PRINT}}
18071  | HOUR_MINUTE
18072  {{
18073 
18074  $$ = PT_HOUR_MINUTE;
18075 
18076  DBG_PRINT}}
18077  | DAY_MILLISECOND
18078  {{
18079 
18080  $$ = PT_DAY_MILLISECOND;
18081 
18082  DBG_PRINT}}
18083  | DAY_SECOND
18084  {{
18085 
18086  $$ = PT_DAY_SECOND;
18087 
18088  DBG_PRINT}}
18089  | DAY_MINUTE
18090  {{
18091 
18092  $$ = PT_DAY_MINUTE;
18093 
18094  DBG_PRINT}}
18095  | DAY_HOUR
18096  {{
18097 
18098  $$ = PT_DAY_HOUR;
18099 
18100  DBG_PRINT}}
18101  | YEAR_MONTH
18102  {{
18103 
18104  $$ = PT_YEAR_MONTH;
18105 
18106  DBG_PRINT}}
18107  ;
18108 
18109 opt_on_target
18110  : /* empty */
18111  {{
18112 
18113  $$ = NULL;
18114 
18115  DBG_PRINT}}
18116  | ON_ primary
18117  {{
18118 
18119  $$ = $2;
18120  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
18121 
18122  DBG_PRINT}}
18123  ;
18124 
18125 generic_function
18126  : identifier '(' opt_expression_list ')' opt_on_target
18127  {{
18128 
18129  PT_NODE *node = NULL;
18130  if ($5 == NULL)
18131  node = parser_keyword_func ($1->info.name.original, $3);
18132 
18133  if (node == NULL)
18134  {
18135  node = parser_new_node (this_parser, PT_METHOD_CALL);
18136 
18137  if (node)
18138  {
18139  node->info.method_call.method_name = $1;
18140  node->info.method_call.arg_list = $3;
18141  node->info.method_call.on_call_target = $5;
18142  node->info.method_call.call_or_expr = PT_IS_MTHD_EXPR;
18143  }
18144  }
18145 
18146  $$ = node;
18147  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
18148 
18149  DBG_PRINT}}
18150  ;
18151 
18152 generic_function_id
18153  : generic_function
18154  {{
18155 
18156  PT_NODE *node = $1;
18157 
18158  if (node->node_type == PT_METHOD_CALL)
18159  {
18160  if (node && !node->info.method_call.on_call_target)
18161  {
18162  const char *callee;
18163  PT_NODE *name = node->info.method_call.method_name;
18164  PT_NODE *func_node = NULL;
18165 
18166  /* create new PT_FUNCTION node */
18167  func_node = parser_new_node (this_parser, PT_FUNCTION);
18168  if (func_node)
18169  {
18170  func_node->info.function.arg_list = node->info.method_call.arg_list;
18171  func_node->info.function.function_type = PT_GENERIC;
18172  callee = (name ? name->info.name.original : "");
18173  func_node->info.function.generic_name = callee;
18174 
18175  /* free previous PT_METHOD_CALL node */
18176  node->info.method_call.arg_list = NULL;
18177  node->info.method_call.method_name = NULL;
18178  parser_free_node (this_parser, node);
18179 
18180  node = func_node;
18181  }
18182  }
18183 
18184  parser_cannot_prepare = true;
18185  parser_cannot_cache = true;
18186  }
18187 
18188  $$ = node;
18189  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
18190 
18191  DBG_PRINT}}
18192  ;
18193 
18194 opt_expression_list
18195  : /* empty */
18196  {{
18197 
18198  $$ = NULL;
18199 
18200  DBG_PRINT}}
18201  | expression_list
18202  {{
18203 
18204  $$ = $1;
18205  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
18206 
18207  DBG_PRINT}}
18208  ;
18209 
18210 table_set_function_call
18211  : SET subquery
18212  {{
18213 
18214  PT_NODE *func_node;
18215  func_node = parser_new_node (this_parser, PT_FUNCTION);
18216  if (func_node)
18217  {
18218  func_node->info.function.arg_list = $2;
18219  func_node->info.function.function_type = F_TABLE_SET;
18220  }
18221  $$ = func_node;
18222  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
18223 
18224  DBG_PRINT}}
18225  | SEQUENCE subquery
18226  {{
18227 
18228  PT_NODE *func_node;
18229  func_node = parser_new_node (this_parser, PT_FUNCTION);
18230  if (func_node)
18231  {
18232  func_node->info.function.arg_list = $2;
18233  func_node->info.function.function_type = F_TABLE_SEQUENCE;
18234  }
18235  $$ = func_node;
18236  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
18237 
18238  DBG_PRINT}}
18239  | LIST subquery
18240  {{
18241 
18242  PT_NODE *func_node;
18243  func_node = parser_new_node (this_parser, PT_FUNCTION);
18244  if (func_node)
18245  {
18246  func_node->info.function.arg_list = $2;
18247  func_node->info.function.function_type = F_TABLE_SEQUENCE;
18248  }
18249  $$ = func_node;
18250  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
18251 
18252  DBG_PRINT}}
18253  | MULTISET subquery
18254  {{
18255 
18256  PT_NODE *func_node;
18257  func_node = parser_new_node (this_parser, PT_FUNCTION);
18258  if (func_node)
18259  {
18260  func_node->info.function.arg_list = $2;
18261  func_node->info.function.function_type = F_TABLE_MULTISET;
18262  }
18263  $$ = func_node;
18264  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
18265 
18266  DBG_PRINT}}
18267  ;
18268 
18269 search_condition
18270  : search_condition OR boolean_term_xor
18271  {{
18272  PT_NODE *arg1 = pt_convert_to_logical_expr(this_parser, $1, 1,1);
18273  PT_NODE *arg2 = pt_convert_to_logical_expr(this_parser, $3, 1,1);
18274  $$ = parser_make_expression (this_parser, PT_OR, arg1, arg2, NULL);
18275  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
18276 
18277  DBG_PRINT}}
18278  | boolean_term_xor
18279  {{
18280 
18281  $$ = pt_convert_to_logical_expr(this_parser, $1, 1, 1);
18282  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
18283 
18284  DBG_PRINT}}
18285  ;
18286 
18287 boolean_term_xor
18288  : boolean_term_xor XOR boolean_term_is
18289  {{
18290  PT_NODE *arg1 = pt_convert_to_logical_expr(this_parser, $1, 1,1);
18291  PT_NODE *arg2 = pt_convert_to_logical_expr(this_parser, $3, 1,1);
18292  $$ = parser_make_expression (this_parser, PT_XOR, arg1, arg2, NULL);
18293  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
18294 
18295  DBG_PRINT}}
18296  | boolean_term_is
18297  {{
18298 
18299  $$ = $1;
18300  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
18301  DBG_PRINT}}
18302  ;
18303 
18304 boolean_term_is
18305  : boolean_term_is is_op boolean
18306  {{
18307  PT_NODE *arg = pt_convert_to_logical_expr(this_parser, $1, 1,1);
18308  $$ = parser_make_expression (this_parser, $2, arg, $3, NULL);
18309  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
18310 
18311  DBG_PRINT}}
18312  | boolean_term
18313  {{
18314 
18315  $$ = $1;
18316  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
18317 
18318  DBG_PRINT}}
18319  ;
18320 
18321 is_op
18322  : IS NOT
18323  {{
18324 
18325  $$ = PT_IS_NOT;
18326 
18327  DBG_PRINT}}
18328  | IS
18329  {{
18330 
18331  $$ = PT_IS;
18332 
18333  DBG_PRINT}}
18334  ;
18335 
18336 boolean_term
18337  : boolean_term AND boolean_factor
18338  {{
18339  PT_NODE *arg1 = pt_convert_to_logical_expr(this_parser, $1, 1,1);
18340  PT_NODE *arg2 = pt_convert_to_logical_expr(this_parser, $3, 1,1);
18341  $$ = parser_make_expression (this_parser, PT_AND, arg1, arg2, NULL);
18342  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
18343 
18344  DBG_PRINT}}
18345  | boolean_factor
18346  {{
18347 
18348  $$ = $1;
18349  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
18350 
18351  DBG_PRINT}}
18352  ;
18353 
18354 boolean_factor
18355  : NOT predicate
18356  {{
18357 
18358  PT_NODE *arg = pt_convert_to_logical_expr(this_parser, $2, 1,1);
18359  $$ = parser_make_expression (this_parser, PT_NOT, arg, NULL, NULL);
18360  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
18361 
18362  DBG_PRINT}}
18363  | '!' predicate
18364  {{
18365 
18366  PT_NODE *arg = pt_convert_to_logical_expr(this_parser, $2, 1,1);
18367  $$ = parser_make_expression (this_parser, PT_NOT, arg, NULL, NULL);
18368  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
18369 
18370  DBG_PRINT}}
18371  | predicate
18372  {{
18373 
18374  $$ = $1;
18375  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
18376 
18377  DBG_PRINT}}
18378  ;
18379 
18380 predicate
18381  : EXISTS expression_
18382  {{
18383 
18384  $$ = parser_make_expression (this_parser, PT_EXISTS, $2, NULL, NULL);
18385  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
18386 
18387  DBG_PRINT}}
18388  | expression_
18389  {{
18390 
18391  $$ = $1;
18392  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
18393 
18394  DBG_PRINT}}
18395  ;
18396 
18397 predicate_expression
18398  : predicate_expr_sub
18399  {{
18400 
18401  PT_JOIN_TYPE join_type = parser_top_join_type ();
18402  if (join_type == PT_JOIN_RIGHT_OUTER)
18403  parser_restore_wjc ();
18404 
18405  DBG_PRINT}}
18406  opt_paren_plus
18407  {{
18408 
18409  PT_JOIN_TYPE join_type = parser_pop_join_type ();
18410  PT_NODE *e, *attr;
18411 
18412  if ($3)
18413  {
18414  if (join_type == PT_JOIN_RIGHT_OUTER)
18415  join_type = PT_JOIN_FULL_OUTER;
18416  else
18417  join_type = PT_JOIN_LEFT_OUTER;
18418  }
18419 
18420  /*
18421  * marking Oracle style left/right outer join operator
18422  *
18423  * Oracle style outer join support: convert to ANSI standard style
18424  * only permit the following predicate
18425  *
18426  * 'single_column(+) op expression_'
18427  * 'expression_ op single_column(+)'
18428  */
18429 
18430  e = $1;
18431 
18432  if (join_type != PT_JOIN_NONE)
18433  {
18434  if (e && e->node_type == PT_EXPR)
18435  {
18436  switch (join_type)
18437  {
18438  case PT_JOIN_LEFT_OUTER:
18439  attr = e->info.expr.arg2;
18440  break;
18441  case PT_JOIN_RIGHT_OUTER:
18442  attr = e->info.expr.arg1;
18443  break;
18444  case PT_JOIN_FULL_OUTER:
18445  PT_ERROR (this_parser, e,
18446  "a predicate may reference only one outer-joined table");
18447  attr = NULL;
18448  break;
18449  default:
18450  PT_ERROR (this_parser, e, "check syntax at '(+)'");
18451  attr = NULL;
18452  break;
18453  }
18454 
18455  if (attr)
18456  {
18457  while (attr->node_type == PT_DOT_)
18458  attr = attr->info.dot.arg2;
18459 
18460  if (attr->node_type == PT_NAME)
18461  {
18462  switch (join_type)
18463  {
18464  case PT_JOIN_LEFT_OUTER:
18465  PT_EXPR_INFO_SET_FLAG (e, PT_EXPR_INFO_LEFT_OUTER);
18466  parser_found_Oracle_outer = true;
18467  break;
18468  case PT_JOIN_RIGHT_OUTER:
18469  PT_EXPR_INFO_SET_FLAG (e, PT_EXPR_INFO_RIGHT_OUTER);
18470  parser_found_Oracle_outer = true;
18471  break;
18472  default:
18473  break;
18474  }
18475  }
18476  else
18477  {
18478  PT_ERROR (this_parser, e,
18479  "'(+)' operator can be applied only to a column, not to an arbitary expression");
18480  }
18481  }
18482  }
18483  } /* if (join_type != PT_JOIN_INNER) */
18484 
18485  $$ = e;
18486  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
18487 
18488  DBG_PRINT}}
18489  ;
18490 
18491 
18492 predicate_expr_sub
18493  : pred_lhs comp_op normal_expression
18494  {{
18495 
18496  PT_NODE *e, *opd1, *opd2, *subq, *t;
18497  PT_OP_TYPE op;
18498  bool found_paren_set_expr = false;
18499  int lhs_cnt, rhs_cnt = 0;
18500  bool found_match = false;
18501 
18502  opd2 = $3;
18503  e = parser_make_expression (this_parser, $2, $1, NULL, NULL);
18504 
18505  if (e && !pt_has_error (this_parser))
18506  {
18507 
18508  e->info.expr.arg2 = opd2;
18509  opd1 = e->info.expr.arg1;
18510  op = e->info.expr.op;
18511 
18512  /* convert parentheses set expr value into sequence */
18513  if (opd1)
18514  {
18515  if (opd1->node_type == PT_VALUE &&
18516  opd1->type_enum == PT_TYPE_EXPR_SET)
18517  {
18518  opd1->type_enum = PT_TYPE_SEQUENCE;
18519  found_paren_set_expr = true;
18520  }
18521  else if (PT_IS_QUERY_NODE_TYPE (opd1->node_type))
18522  {
18523  if ((subq = pt_get_subquery_list (opd1)) && subq->next == NULL)
18524  {
18525  /* single-column subquery */
18526  }
18527  else
18528  {
18529  if (subq)
18530  {
18531  /* If not PT_TYPE_STAR */
18532  pt_select_list_to_one_col (this_parser, opd1, true);
18533  }
18534  found_paren_set_expr = true;
18535  }
18536  }
18537  }
18538  if (opd2)
18539  {
18540  if (opd2->node_type == PT_VALUE &&
18541  opd2->type_enum == PT_TYPE_EXPR_SET)
18542  {
18543  opd2->type_enum = PT_TYPE_SEQUENCE;
18544  found_paren_set_expr = true;
18545  }
18546  else if (PT_IS_QUERY_NODE_TYPE (opd2->node_type))
18547  {
18548  if ((subq = pt_get_subquery_list (opd2)) && subq->next == NULL)
18549  {
18550  /* single-column subquery */
18551  }
18552  else
18553  {
18554  if (subq)
18555  {
18556  /* If not PT_TYPE_STAR */
18557  pt_select_list_to_one_col (this_parser, opd2, true);
18558  }
18559  found_paren_set_expr = true;
18560  }
18561  }
18562  }
18563  if (found_paren_set_expr == true)
18564  {
18565  /* expression number check */
18566  if ((lhs_cnt = pt_get_expression_count (opd1)) < 0)
18567  {
18568  found_match = true;
18569  }
18570  else
18571  {
18572  for (t = opd2; t; t = t->next)
18573  {
18574  rhs_cnt = pt_get_expression_count (t);
18575  if ((rhs_cnt < 0) || (lhs_cnt == rhs_cnt))
18576  {
18577  /* can not check negative rhs_cnt. go ahead */
18578  found_match = true;
18579  break;
18580  }
18581  }
18582  }
18583 
18584  if (found_match == false)
18585  {
18586  PT_ERRORmf2 (this_parser, e, MSGCAT_SET_PARSER_SEMANTIC,
18587  MSGCAT_SEMANTIC_ATT_CNT_COL_CNT_NE,
18588  lhs_cnt, rhs_cnt);
18589  }
18590  }
18591  if (op == PT_EQ || op == PT_NE || op == PT_GT || op == PT_GE || op == PT_LT || op == PT_LE)
18592  {
18593  /* expression number check */
18594  if (found_paren_set_expr == true &&
18595  pt_check_set_count_set (this_parser, opd1, opd2))
18596  {
18597  /* rewrite parentheses set expr equi-comparions predicate
18598  * as equi-comparison predicates tree of each elements.
18599  * for example, (a, b) = (x, y) -> a = x and b = y
18600  */
18601  if (op == PT_EQ && pt_is_set_type (opd1) && pt_is_set_type (opd2))
18602  {
18603  e = pt_rewrite_set_eq_set (this_parser, e);
18604  }
18605  }
18606  /* mark as single tuple list */
18607  if (PT_IS_QUERY_NODE_TYPE (opd1->node_type))
18608  {
18609  opd1->info.query.flag.single_tuple = 1;
18610  }
18611  if (PT_IS_QUERY_NODE_TYPE (opd2->node_type))
18612  {
18613  opd2->info.query.flag.single_tuple = 1;
18614  }
18615  }
18616  else
18617  {
18618  if (found_paren_set_expr == true)
18619  { /* operator check */
18620  PT_ERRORf (this_parser, e,
18621  "check syntax at %s, illegal operator.",
18622  pt_show_binopcode (op));
18623  }
18624  }
18625  } /* if (e) */
18626  PICE (e);
18627 
18628  $$ = e;
18629  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
18630 
18631  DBG_PRINT}}
18632  | pred_lhs like_op normal_expression ESCAPE escape_literal
18633  {{
18634 
18635  PT_NODE *esc = parser_make_expression (this_parser, PT_LIKE_ESCAPE, $3, $5, NULL);
18636  PT_NODE *node = parser_make_expression (this_parser, $2, $1, esc, NULL);
18637  $$ = node;
18638  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
18639 
18640  DBG_PRINT}}
18641  | pred_lhs like_op normal_expression
18642  {{
18643 
18644  if (prm_get_bool_value (PRM_ID_REQUIRE_LIKE_ESCAPE_CHARACTER)
18645  && prm_get_bool_value (PRM_ID_NO_BACKSLASH_ESCAPES))
18646  {
18647  PT_ERRORmf2 (this_parser, $1, MSGCAT_SET_PARSER_SEMANTIC,
18648  MSGCAT_SEMANTIC_ESCAPE_CHAR_REQUIRED,
18649  prm_get_name (PRM_ID_REQUIRE_LIKE_ESCAPE_CHARACTER),
18650  prm_get_name (PRM_ID_NO_BACKSLASH_ESCAPES));
18651  }
18652  $$ = parser_make_expression (this_parser, $2, $1, $3, NULL);
18653  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
18654 
18655  DBG_PRINT}}
18656  | pred_lhs rlike_op normal_expression
18657  {{
18658 
18659  /* case sensitivity flag */
18660  PT_NODE *node = parser_new_node (this_parser, PT_VALUE);
18661  if (node)
18662  {
18663  node->type_enum = PT_TYPE_INTEGER;
18664  node->info.value.data_value.i =
18665  ($2 == PT_RLIKE_BINARY || $2 == PT_NOT_RLIKE_BINARY ? 1 : 0);
18666 
18667  $$ = parser_make_expression (this_parser, $2, $1, $3, node);
18668  }
18669  else
18670  {
18671  $$ = NULL;
18672  }
18673  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
18674 
18675  DBG_PRINT}}
18676  | pred_lhs null_op
18677  {{
18678 
18679  $$ = parser_make_expression (this_parser, $2, $1, NULL, NULL);
18680  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
18681 
18682  DBG_PRINT}}
18683  | pred_lhs set_op normal_expression
18684  {{
18685 
18686  $$ = parser_make_expression (this_parser, $2, $1, $3, NULL);
18687  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
18688 
18689  DBG_PRINT}}
18690  | pred_lhs between_op normal_expression AND normal_expression
18691  {{
18692 
18693  PT_NODE *node = parser_make_expression (this_parser, PT_BETWEEN_AND, $3, $5, NULL);
18694  $$ = parser_make_expression (this_parser, $2, $1, node, NULL);
18695  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
18696 
18697  DBG_PRINT}}
18698  | pred_lhs in_op in_pred_operand
18699  {{
18700 
18701  PT_NODE *node = parser_make_expression (this_parser, $2, $1, NULL, NULL);
18702  PT_NODE *t = CONTAINER_AT_1 ($3);
18703  bool is_paren = (bool)TO_NUMBER (CONTAINER_AT_0 ($3));
18704  int lhs_cnt, rhs_cnt = 0;
18705  PT_NODE *v, *lhs, *rhs, *subq;
18706  bool found_match = false;
18707  bool found_paren_set_expr = false;
18708 
18709  PARSER_SAVE_ERR_CONTEXT (node, @$.buffer_pos)
18710  if (node)
18711  {
18712  lhs = node->info.expr.arg1;
18713  /* convert lhs parentheses set expr value into
18714  * sequence value */
18715  if (lhs)
18716  {
18717  if (lhs->node_type == PT_VALUE && lhs->type_enum == PT_TYPE_EXPR_SET)
18718  {
18719  lhs->type_enum = PT_TYPE_SEQUENCE;
18720  found_paren_set_expr = true;
18721  }
18722  else if (PT_IS_QUERY_NODE_TYPE (lhs->node_type))
18723  {
18724  if ((subq = pt_get_subquery_list (lhs)) && subq->next == NULL)
18725  {
18726  /* single column subquery */
18727  }
18728  else
18729  {
18730  if (subq)
18731  {
18732  /* If not PT_TYPE_STAR */
18733  pt_select_list_to_one_col (this_parser, lhs, true);
18734  }
18735  found_paren_set_expr = true;
18736  }
18737  }
18738  }
18739 
18740  if (is_paren == true)
18741  { /* convert to multi-set */
18742  v = parser_new_node (this_parser, PT_VALUE);
18743  if (v)
18744  {
18745  v->info.value.data_value.set = t;
18746  v->type_enum = PT_TYPE_MULTISET;
18747  } /* if (v) */
18748  node->info.expr.arg2 = v;
18749  }
18750  else
18751  {
18752  /* convert subquery-starting parentheses set expr
18753  * ( i.e., {subquery, x, y, ...} ) into multi-set */
18754  if (t->node_type == PT_VALUE && t->type_enum == PT_TYPE_EXPR_SET)
18755  {
18756  is_paren = true; /* mark as parentheses set expr */
18757  t->type_enum = PT_TYPE_MULTISET;
18758  }
18759  node->info.expr.arg2 = t;
18760  }
18761 
18762  rhs = node->info.expr.arg2;
18763  if (is_paren == true)
18764  {
18765  rhs = rhs->info.value.data_value.set;
18766  }
18767  else if (rhs->node_type == PT_VALUE
18768  && !(PT_IS_COLLECTION_TYPE (rhs->type_enum)
18769  || rhs->type_enum == PT_TYPE_EXPR_SET))
18770  {
18771  PT_ERRORmf2 (this_parser, rhs, MSGCAT_SET_PARSER_SYNTAX,
18772  MSGCAT_SYNTAX_ERROR_MSG1,
18773  pt_show_binopcode ($2),
18774  "SELECT or '('");
18775  }
18776 
18777  /* for each rhs elements, convert parentheses
18778  * set expr value into sequence value */
18779  for (t = rhs; t; t = t->next)
18780  {
18781  if (t->node_type == PT_VALUE && t->type_enum == PT_TYPE_EXPR_SET)
18782  {
18783  t->type_enum = PT_TYPE_SEQUENCE;
18784  found_paren_set_expr = true;
18785  }
18786  else if (PT_IS_QUERY_NODE_TYPE (t->node_type))
18787  {
18788  if ((subq = pt_get_subquery_list (t)) && subq->next == NULL)
18789  {
18790  /* single column subquery */
18791  }
18792  else
18793  {
18794  if (subq)
18795  {
18796  /* If not PT_TYPE_STAR */
18797  pt_select_list_to_one_col (this_parser, t, true);
18798  }
18799  found_paren_set_expr = true;
18800  }
18801  }
18802  }
18803  if (found_paren_set_expr == true)
18804  {
18805  /* expression number check */
18806  if ((lhs_cnt = pt_get_expression_count (lhs)) < 0)
18807  {
18808  found_match = true;
18809  }
18810  else
18811  {
18812  for (t = rhs; t; t = t->next)
18813  {
18814  if (!PT_IS_QUERY_NODE_TYPE (t->node_type))
18815  {
18816  if (pt_is_set_type (t))
18817  {
18818  if (pt_is_set_type (t->info.value.data_value.set))
18819  {
18820  /* syntax error case : (a,b) in ((1,1),((2,2),(3,3)) */
18821  found_match = false;
18822  rhs_cnt = 0;
18823  break;
18824  }
18825  }
18826  else
18827  {
18828  /* syntax error case : (a,b) in ((1,1),2) */
18829  found_match = false;
18830  rhs_cnt = 0;
18831  break;
18832  }
18833  }
18834  rhs_cnt = pt_get_expression_count (t);
18835  if (rhs_cnt < 0)
18836  {
18837  /* can not check negative rhs_cnt. go ahead */
18838  found_match = true;
18839  break;
18840  }
18841  else if (lhs_cnt != rhs_cnt)
18842  {
18843  found_match = false;
18844  break;
18845  }
18846  else
18847  {
18848  found_match = true;
18849  }
18850  }
18851  }
18852 
18853  if (found_match == false)
18854  {
18855  PT_ERRORmf2 (this_parser, node, MSGCAT_SET_PARSER_SEMANTIC,
18856  MSGCAT_SEMANTIC_ATT_CNT_COL_CNT_NE,
18857  lhs_cnt, rhs_cnt);
18858  }
18859  }
18860  }
18861  rhs = node->info.expr.arg2;
18862  if (PT_IS_COLLECTION_TYPE (rhs->type_enum) && rhs->info.value.data_value.set
18863  && rhs->info.value.data_value.set->next == NULL)
18864  {
18865  /* only one element in set. convert expr as EQ/NE expr. */
18866  PT_NODE *new_arg2;
18867 
18868  new_arg2 = rhs->info.value.data_value.set;
18869 
18870  /* free arg2 */
18871  rhs->info.value.data_value.set = NULL;
18872  parser_free_tree (this_parser, node->info.expr.arg2);
18873 
18874  /* rewrite arg2 */
18875  node->info.expr.arg2 = new_arg2;
18876  node->info.expr.op = (node->info.expr.op == PT_IS_IN) ? PT_EQ : PT_NE;
18877  if (node->info.expr.op == PT_EQ)
18878  {
18879  node = pt_rewrite_set_eq_set (this_parser, node);
18880  }
18881  }
18882 
18883  $$ = node;
18884 
18885  DBG_PRINT}}
18886  ;
18887  | pred_lhs RANGE_ '(' range_list ')'
18888  {{
18889 
18890  $$ = parser_make_expression (this_parser, PT_RANGE, $1, $4, NULL);
18891  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
18892 
18893  DBG_PRINT}}
18894  | pred_lhs IdName
18895  {{
18896  PT_ERRORm (this_parser, $1, MSGCAT_SET_PARSER_SYNTAX,
18897  MSGCAT_SYNTAX_INVALID_RELATIONAL_OP);
18898 
18899  DBG_PRINT}}
18900  ;
18901 
18902 pred_lhs
18903  : normal_expression opt_paren_plus
18904  {{
18905 
18906  PT_JOIN_TYPE join_type = PT_JOIN_NONE;
18907 
18908  if ($2)
18909  {
18910  join_type = PT_JOIN_RIGHT_OUTER;
18911  parser_save_and_set_wjc (1);
18912  }
18913  parser_push_join_type (join_type);
18914 
18915  $$ = $1;
18916  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
18917 
18918  DBG_PRINT}}
18919  ;
18920 
18921 opt_paren_plus
18922  : /* empty */
18923  {{
18924 
18925  $$ = 0;
18926 
18927  DBG_PRINT}}
18928  | paren_plus
18929  {{
18930 
18931  $$ = 1;
18932 
18933  DBG_PRINT}}
18934  ;
18935 
18936 comp_op
18937  : '=' opt_of_all_some_any
18938  {{
18939 
18940  switch ($2)
18941  {
18942  case 0:
18943  $$ = PT_EQ;
18944  break;
18945  case 1:
18946  $$ = PT_EQ_ALL;
18947  break;
18948  case 2:
18949  $$ = PT_EQ_SOME;
18950  break;
18951  case 3:
18952  $$ = PT_EQ_SOME;
18953  break;
18954  }
18955 
18956  DBG_PRINT}}
18957  | COMP_NOT_EQ opt_of_all_some_any
18958  {{
18959 
18960  switch ($2)
18961  {
18962  case 0:
18963  $$ = PT_NE;
18964  break;
18965  case 1:
18966  $$ = PT_NE_ALL;
18967  break;
18968  case 2:
18969  $$ = PT_NE_SOME;
18970  break;
18971  case 3:
18972  $$ = PT_NE_SOME;
18973  break;
18974  }
18975 
18976  DBG_PRINT}}
18977  | '>' opt_of_all_some_any
18978  {{
18979 
18980  switch ($2)
18981  {
18982  case 0:
18983  $$ = PT_GT;
18984  break;
18985  case 1:
18986  $$ = PT_GT_ALL;
18987  break;
18988  case 2:
18989  $$ = PT_GT_SOME;
18990  break;
18991  case 3:
18992  $$ = PT_GT_SOME;
18993  break;
18994  }
18995 
18996  DBG_PRINT}}
18997  | COMP_GE opt_of_all_some_any
18998  {{
18999 
19000  switch ($2)
19001  {
19002  case 0:
19003  $$ = PT_GE;
19004  break;
19005  case 1:
19006  $$ = PT_GE_ALL;
19007  break;
19008  case 2:
19009  $$ = PT_GE_SOME;
19010  break;
19011  case 3:
19012  $$ = PT_GE_SOME;
19013  break;
19014  }
19015 
19016  DBG_PRINT}}
19017  | '<' opt_of_all_some_any
19018  {{
19019 
19020  switch ($2)
19021  {
19022  case 0:
19023  $$ = PT_LT;
19024  break;
19025  case 1:
19026  $$ = PT_LT_ALL;
19027  break;
19028  case 2:
19029  $$ = PT_LT_SOME;
19030  break;
19031  case 3:
19032  $$ = PT_LT_SOME;
19033  break;
19034  }
19035 
19036  DBG_PRINT}}
19037  | COMP_LE opt_of_all_some_any
19038  {{
19039 
19040  switch ($2)
19041  {
19042  case 0:
19043  $$ = PT_LE;
19044  break;
19045  case 1:
19046  $$ = PT_LE_ALL;
19047  break;
19048  case 2:
19049  $$ = PT_LE_SOME;
19050  break;
19051  case 3:
19052  $$ = PT_LE_SOME;
19053  break;
19054  }
19055 
19056  DBG_PRINT}}
19057  | '=''=' opt_of_all_some_any
19058  {{
19059 
19060  push_msg (MSGCAT_SYNTAX_INVALID_EQUAL_OP);
19061  csql_yyerror_explicit (@1.first_line, @1.first_column);
19062 
19063  DBG_PRINT}}
19064  | '!''=' opt_of_all_some_any
19065  {{
19066 
19067  push_msg (MSGCAT_SYNTAX_INVALID_NOT_EQUAL);
19068  csql_yyerror_explicit (@1.first_line, @1.first_column);
19069 
19070  DBG_PRINT}}
19071  | COMP_NULLSAFE_EQ opt_of_all_some_any
19072  {{
19073 
19074  $$ = PT_NULLSAFE_EQ;
19075 
19076  DBG_PRINT}}
19077  ;
19078 
19079 opt_of_all_some_any
19080  : /* empty */
19081  {{
19082 
19083  $$ = 0;
19084 
19085  DBG_PRINT}}
19086  | ALL
19087  {{
19088 
19089  $$ = 1;
19090 
19091  DBG_PRINT}}
19092  | SOME
19093  {{
19094 
19095  $$ = 2;
19096 
19097  DBG_PRINT}}
19098  | ANY
19099  {{
19100 
19101  $$ = 3;
19102 
19103  DBG_PRINT}}
19104  ;
19105 
19106 like_op
19107  : NOT LIKE
19108  {{
19109 
19110  $$ = PT_NOT_LIKE;
19111 
19112  DBG_PRINT}}
19113  | LIKE
19114  {{
19115 
19116  $$ = PT_LIKE;
19117 
19118  DBG_PRINT}}
19119  ;
19120 
19121 rlike_op
19122  : rlike_or_regexp
19123  {{
19124 
19125  $$ = PT_RLIKE;
19126 
19127  DBG_PRINT}}
19128  | NOT rlike_or_regexp
19129  {{
19130 
19131  $$ = PT_NOT_RLIKE;
19132 
19133  DBG_PRINT}}
19134  | rlike_or_regexp BINARY
19135  {{
19136 
19137  $$ = PT_RLIKE_BINARY;
19138 
19139  DBG_PRINT}}
19140  | NOT rlike_or_regexp BINARY
19141  {{
19142 
19143  $$ = PT_NOT_RLIKE_BINARY;
19144 
19145  DBG_PRINT}}
19146  ;
19147 
19148 rlike_or_regexp
19149  : RLIKE
19150  | REGEXP
19151  ;
19152 
19153 null_op
19154  : IS NOT Null
19155  {{
19156 
19157  $$ = PT_IS_NOT_NULL;
19158 
19159  DBG_PRINT}}
19160  | IS Null
19161  {{
19162 
19163  $$ = PT_IS_NULL;
19164 
19165  DBG_PRINT}}
19166  ;
19167 
19168 
19169 between_op
19170  : NOT BETWEEN
19171  {{
19172 
19173  $$ = PT_NOT_BETWEEN;
19174 
19175  DBG_PRINT}}
19176  | BETWEEN
19177  {{
19178 
19179  $$ = PT_BETWEEN;
19180 
19181  DBG_PRINT}}
19182  ;
19183 
19184 in_op
19185  : IN_
19186  {{
19187 
19188  $$ = PT_IS_IN;
19189 
19190  DBG_PRINT}}
19191  | NOT IN_
19192  {{
19193 
19194  $$ = PT_IS_NOT_IN;
19195 
19196  DBG_PRINT}}
19197  ;
19198 
19199 in_pred_operand
19200  : expression_
19201  {{
19202  container_2 ctn;
19203  PT_NODE *exp = $1;
19204  if (exp && exp->flag.is_paren == 0)
19205  {
19206  SET_CONTAINER_2 (ctn, FROM_NUMBER (0), exp);
19207  }
19208  else
19209  {
19210  SET_CONTAINER_2 (ctn, FROM_NUMBER (1), exp);
19211  }
19212 
19213  $$ = ctn;
19214  DBG_PRINT}}
19215  ;
19216 
19217 range_list
19218  : range_list OR range_
19219  {{
19220 
19221  $$ = parser_make_link_or ($1, $3);
19222  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
19223 
19224  DBG_PRINT}}
19225  | range_
19226  {{
19227 
19228  $$ = $1;
19229  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
19230 
19231  DBG_PRINT}}
19232  ;
19233 
19234 range_
19235  : expression_ GE_LE_ expression_
19236  {{
19237 
19238  $$ = parser_make_expression (this_parser, PT_BETWEEN_GE_LE, $1, $3, NULL);
19239  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
19240 
19241  DBG_PRINT}}
19242  | expression_ GE_LT_ expression_
19243  {{
19244 
19245  $$ = parser_make_expression (this_parser, PT_BETWEEN_GE_LT, $1, $3, NULL);
19246  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
19247 
19248  DBG_PRINT}}
19249  | expression_ GT_LE_ expression_
19250  {{
19251 
19252  $$ = parser_make_expression (this_parser, PT_BETWEEN_GT_LE, $1, $3, NULL);
19253  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
19254 
19255  DBG_PRINT}}
19256  | expression_ GT_LT_ expression_
19257  {{
19258 
19259  $$ = parser_make_expression (this_parser, PT_BETWEEN_GT_LT, $1, $3, NULL);
19260  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
19261 
19262  DBG_PRINT}}
19263  | expression_ '='
19264  {{
19265 
19266  $$ = parser_make_expression (this_parser, PT_BETWEEN_EQ_NA, $1, NULL, NULL);
19267  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
19268 
19269  DBG_PRINT}}
19270  | expression_ GE_INF_ Max
19271  {{
19272 
19273  $$ = parser_make_expression (this_parser, PT_BETWEEN_GE_INF, $1, NULL, NULL);
19274  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
19275 
19276  DBG_PRINT}}
19277  | expression_ GT_INF_ Max
19278  {{
19279 
19280  $$ = parser_make_expression (this_parser, PT_BETWEEN_GT_INF, $1, NULL, NULL);
19281  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
19282 
19283  DBG_PRINT}}
19284  | Min INF_LE_ expression_
19285  {{
19286 
19287  $$ = parser_make_expression (this_parser, PT_BETWEEN_INF_LE, $3, NULL, NULL);
19288  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
19289 
19290  DBG_PRINT}}
19291  | Min INF_LT_ expression_
19292  {{
19293 
19294  $$ = parser_make_expression (this_parser, PT_BETWEEN_INF_LT, $3, NULL, NULL);
19295  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
19296 
19297  DBG_PRINT}}
19298  ;
19299 
19300 set_op
19301  : SETEQ
19302  {{
19303 
19304  $$ = PT_SETEQ;
19305 
19306  DBG_PRINT}}
19307  | SETNEQ
19308  {{
19309 
19310  $$ = PT_SETNEQ;
19311 
19312  DBG_PRINT}}
19313  | SUBSET
19314  {{
19315 
19316  $$ = PT_SUBSET;
19317 
19318  DBG_PRINT}}
19319  | SUBSETEQ
19320  {{
19321 
19322  $$ = PT_SUBSETEQ;
19323 
19324  DBG_PRINT}}
19325  | SUPERSETEQ
19326  {{
19327 
19328  $$ = PT_SUPERSETEQ;
19329 
19330  DBG_PRINT}}
19331  | SUPERSET
19332  {{
19333 
19334  $$ = PT_SUPERSET;
19335 
19336  DBG_PRINT}}
19337  ;
19338 
19339 subquery
19340  : '(' csql_query ')'
19341  {{
19342 
19343  PT_NODE *stmt = $2;
19344 
19345  if (parser_within_join_condition)
19346  {
19347  PT_ERRORm (this_parser, stmt, MSGCAT_SET_PARSER_SYNTAX,
19348  MSGCAT_SYNTAX_JOIN_COND_SUBQ);
19349  }
19350 
19351  if (stmt)
19352  stmt->info.query.is_subquery = PT_IS_SUBQUERY;
19353  $$ = stmt;
19354  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
19355 
19356  DBG_PRINT}}
19357  ;
19358 
19359 subquery_without_subquery_and_with_clause
19360  : '(' csql_query_without_subquery_and_with_clause ')'
19361  {{
19362 
19363  PT_NODE *stmt = $2;
19364 
19365  if (parser_within_join_condition)
19366  {
19367  PT_ERRORm (this_parser, stmt, MSGCAT_SET_PARSER_SYNTAX,
19368  MSGCAT_SYNTAX_JOIN_COND_SUBQ);
19369  }
19370 
19371  if (stmt)
19372  stmt->info.query.is_subquery = PT_IS_SUBQUERY;
19373  $$ = stmt;
19374  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
19375 
19376  DBG_PRINT}}
19377  ;
19378 
19379 
19380 path_expression
19381  : path_header path_dot NONE %dprec 6
19382  {{
19383 
19384  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
19385  if (p)
19386  {
19387  p->info.name.original = $3;
19388  }
19389  $$ = p;
19390  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
19391 
19392  DBG_PRINT}}
19393  | path_header path_dot IDENTITY %dprec 5
19394  {{
19395 
19396  $$ = $1;
19397  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
19398 
19399  DBG_PRINT}}
19400  | path_header path_dot OBJECT %dprec 4
19401  {{
19402 
19403  PT_NODE *node = $1;
19404  if (node && node->node_type == PT_NAME)
19405  {
19406  PT_NAME_INFO_SET_FLAG (node, PT_NAME_INFO_EXTERNAL);
19407  }
19408 
19409  $$ = node;
19410  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
19411 
19412  DBG_PRINT}}
19413  | path_header DOT '*' %dprec 3
19414  {{
19415 
19416  PT_NODE *node = $1;
19417  if (node && node->node_type == PT_NAME &&
19418  node->info.name.meta_class == PT_META_CLASS)
19419  {
19420  /* don't allow "class class_variable.*" */
19421  PT_ERROR (this_parser, node, "check syntax at '*'");
19422  }
19423  else
19424  {
19425  if (node)
19426  node->type_enum = PT_TYPE_STAR;
19427  }
19428 
19429  $$ = node;
19430  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
19431 
19432  DBG_PRINT}}
19433  | path_id_list %dprec 2
19434  {{
19435  PT_NODE *dot;
19436  PT_NODE *serial_value = NULL;
19437 
19438  dot = $1;
19439  if (dot
19440  && dot->node_type == PT_DOT_
19441  && dot->info.dot.arg2 && dot->info.dot.arg2->node_type == PT_NAME)
19442  {
19443  PT_NODE *name = dot->info.dot.arg2;
19444 
19445  if (intl_identifier_casecmp (name->info.name.original, "current_value") == 0 ||
19446  intl_identifier_casecmp (name->info.name.original, "currval") == 0)
19447  {
19448  serial_value = parser_new_node (this_parser, PT_EXPR);
19449  serial_value->info.expr.op = PT_CURRENT_VALUE;
19450  serial_value->info.expr.arg1
19451  = dot->info.dot.arg1;
19452  dot->info.dot.arg1 = NULL; /* cut */
19453 
19454  serial_value->info.expr.arg2 = NULL;
19455 
19456  PICE (serial_value);
19457  if (parser_serial_check == 0)
19458  PT_ERRORmf(this_parser, serial_value,
19459  MSGCAT_SET_PARSER_SEMANTIC,
19460  MSGCAT_SEMANTIC_NOT_ALLOWED_HERE,
19461  "serial");
19462 
19463  parser_free_node (this_parser, dot);
19464  dot = serial_value;
19465 
19466  parser_cannot_cache = true;
19467  }
19468  else
19469  if (intl_identifier_casecmp (name->info.name.original, "next_value") == 0 ||
19470  intl_identifier_casecmp (name->info.name.original, "nextval") == 0)
19471  {
19472  serial_value = parser_new_node (this_parser, PT_EXPR);
19473  serial_value->info.expr.op = PT_NEXT_VALUE;
19474 
19475  serial_value->info.expr.arg1
19476  = dot->info.dot.arg1;
19477  dot->info.dot.arg1 = NULL; /* cut */
19478 
19479  serial_value->info.expr.arg2
19480  = parser_new_node (this_parser, PT_VALUE);
19481  if (serial_value->info.expr.arg2)
19482  {
19483  PT_NODE *arg2;
19484 
19485  arg2 = serial_value->info.expr.arg2;
19486  arg2->type_enum = PT_TYPE_INTEGER;
19487  arg2->info.value.data_value.i = 1;
19488  }
19489 
19490  PICE (serial_value);
19491  if (parser_serial_check == 0)
19492  PT_ERRORmf(this_parser, serial_value,
19493  MSGCAT_SET_PARSER_SEMANTIC,
19494  MSGCAT_SEMANTIC_NOT_ALLOWED_HERE,
19495  "serial");
19496 
19497  parser_free_node (this_parser, dot);
19498  dot = serial_value;
19499 
19500  parser_cannot_cache = true;
19501  }
19502  }
19503 
19504  $$ = dot;
19505  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
19506 
19507  DBG_PRINT}}
19508  ;
19509 
19510 path_id_list
19511  : path_id_list path_dot path_id %dprec 1
19512  {{
19513 
19514  PT_NODE *dot = parser_new_node (this_parser, PT_DOT_);
19515  if (dot)
19516  {
19517  dot->info.dot.arg1 = $1;
19518  dot->info.dot.arg2 = $3;
19519  }
19520 
19521  $$ = dot;
19522  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
19523 
19524  DBG_PRINT}}
19525  | path_header %dprec 2
19526  {{
19527 
19528  $$ = $1;
19529  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
19530 
19531  DBG_PRINT}}
19532  ;
19533 
19534 path_header
19535  : param_
19536  {{
19537 
19538  $$ = $1;
19539  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
19540 
19541  DBG_PRINT}}
19542  | CLASS path_id
19543  {{
19544 
19545  PT_NODE *node = $2;
19546  if (node && node->node_type == PT_NAME)
19547  node->info.name.meta_class = PT_META_CLASS;
19548  $$ = node;
19549 
19550  DBG_PRINT}}
19551  | path_id
19552  {{
19553 
19554  PT_NODE *node = $1;
19555  if (node && node->node_type == PT_NAME)
19556  node->info.name.meta_class = PT_NORMAL;
19557  $$ = node;
19558  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
19559 
19560  DBG_PRINT}}
19561  ;
19562 
19563 path_dot
19564  : DOT
19565  | RIGHT_ARROW
19566  ;
19567 
19568 path_id
19569  : identifier '{' identifier '}'
19570  {{
19571 
19572  PT_NODE *corr = $3;
19573  PT_NODE *name = $1;
19574 
19575  if (name)
19576  name->info.name.path_correlation = corr;
19577  $$ = name;
19578  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
19579 
19580  DBG_PRINT}}
19581  | identifier
19582  {{
19583 
19584  $$ = $1;
19585  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
19586 
19587  DBG_PRINT}}
19588  | generic_function_id
19589  {{
19590 
19591  $$ = $1;
19592  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
19593 
19594  DBG_PRINT}}
19595  | table_set_function_call
19596  {{
19597 
19598  $$ = $1;
19599  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
19600 
19601  DBG_PRINT}}
19602  ;
19603 
19604 simple_path_id
19605  : identifier DOT identifier
19606  {{
19607 
19608  PT_NODE *dot = parser_new_node (this_parser, PT_DOT_);
19609  if (dot)
19610  {
19611  dot->info.dot.arg1 = $1;
19612  dot->info.dot.arg2 = $3;
19613  }
19614 
19615  $$ = dot;
19616  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
19617 
19618  DBG_PRINT}}
19619  | identifier
19620  {{
19621 
19622  $$ = $1;
19623  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
19624 
19625  DBG_PRINT}}
19626  ;
19627 
19628 opt_in_out
19629  : /* empty */
19630  {{
19631 
19632  $$ = PT_NOPUT;
19633 
19634  DBG_PRINT}}
19635  | IN_
19636  {{
19637 
19638  $$ = PT_INPUT;
19639 
19640  DBG_PRINT}}
19641  | OUT_
19642  {{
19643 
19644  $$ = PT_OUTPUT;
19645 
19646  DBG_PRINT}}
19647  | INOUT
19648  {{
19649 
19650  $$ = PT_INPUTOUTPUT;
19651 
19652  DBG_PRINT}}
19653  ;
19654 
19655 negative_prec_cast_type
19656  : CHAR_
19657  {{
19658 
19659  $$ = PT_TYPE_CHAR;
19660 
19661  DBG_PRINT}}
19662  | NATIONAL CHAR_
19663  {{
19664 
19665  $$ = PT_TYPE_NCHAR;
19666 
19667  DBG_PRINT}}
19668  | NCHAR
19669  {{
19670 
19671  $$ = PT_TYPE_NCHAR;
19672 
19673  DBG_PRINT}}
19674  ;
19675 
19676 of_cast_data_type
19677  : data_type
19678  {{
19679  $$ = $1;
19680 
19681  DBG_PRINT}}
19682  | negative_prec_cast_type '(' '-' unsigned_integer ')' opt_charset opt_collation
19683  {{
19684  container_2 ctn;
19685  PT_TYPE_ENUM typ = $1;
19686  PT_NODE *len = NULL, *dt = NULL;
19687  int l = 0;
19688  PT_NODE *charset_node = NULL;
19689  PT_NODE *coll_node = NULL;
19690 
19691  len = $4;
19692  charset_node = $6;
19693  coll_node = $7;
19694 
19695  if (len && len->type_enum == PT_TYPE_INTEGER)
19696  {
19697  l = -len->info.value.data_value.i;
19698  }
19699 
19700  if (l != -1)
19701  {
19702  int maxlen = (typ == PT_TYPE_NCHAR)
19703  ? DB_MAX_NCHAR_PRECISION : DB_MAX_CHAR_PRECISION;
19704  PT_ERRORmf3 (this_parser, len,
19705  MSGCAT_SET_PARSER_SEMANTIC,
19706  MSGCAT_SEMANTIC_INV_PREC,
19707  l, -1, maxlen);
19708  }
19709 
19710  dt = parser_new_node (this_parser, PT_DATA_TYPE);
19711  if (dt)
19712  {
19713  int coll_id, charset;
19714 
19715  dt->type_enum = typ;
19716  dt->info.data_type.precision = l;
19717  switch (typ)
19718  {
19719  case PT_TYPE_CHAR:
19720  case PT_TYPE_NCHAR:
19721  if (pt_check_grammar_charset_collation
19722  (this_parser, charset_node, coll_node, &charset, &coll_id) == NO_ERROR)
19723  {
19724  dt->info.data_type.units = charset;
19725  dt->info.data_type.collation_id = coll_id;
19726  }
19727  else
19728  {
19729  dt->info.data_type.units = -1;
19730  dt->info.data_type.collation_id = -1;
19731  }
19732  break;
19733 
19734  default:
19735  break;
19736  }
19737  }
19738 
19739  SET_CONTAINER_2 (ctn, FROM_NUMBER (typ), dt);
19740  $$ = ctn;
19741  if (len)
19742  {
19743  parser_free_node (this_parser, len);
19744  }
19745 
19746  if (charset_node)
19747  {
19748  parser_free_node (this_parser, charset_node);
19749  }
19750 
19751  if (coll_node)
19752  {
19753  parser_free_node (this_parser, coll_node);
19754  }
19755 
19756  DBG_PRINT}}
19757  ;
19758 
19759 data_type
19760  : nested_set primitive_type
19761  {{
19762 
19763  container_2 ctn;
19764  PT_TYPE_ENUM typ, e;
19765  PT_NODE *dt;
19766 
19767  typ = $1;
19768  e = TO_NUMBER (CONTAINER_AT_0 ($2));
19769  dt = CONTAINER_AT_1 ($2);
19770 
19771  if (!dt)
19772  {
19773  dt = parser_new_node (this_parser, PT_DATA_TYPE);
19774  if (dt)
19775  {
19776  dt->type_enum = e;
19777  dt->data_type = NULL;
19778  }
19779  }
19780 
19781  SET_CONTAINER_2 (ctn, FROM_NUMBER (typ), dt);
19782  $$ = ctn;
19783 
19784  DBG_PRINT}}
19785  | nested_set '(' data_type_list ')'
19786  {{
19787 
19788  container_2 ctn;
19789  PT_TYPE_ENUM typ;
19790  PT_NODE *dt;
19791 
19792  typ = $1;
19793  dt = $3;
19794 
19795  SET_CONTAINER_2 (ctn, FROM_NUMBER (typ), dt);
19796  $$ = ctn;
19797 
19798  DBG_PRINT}}
19799  | nested_set '(' ')'
19800  {{
19801 
19802  container_2 ctn;
19803  PT_TYPE_ENUM typ;
19804 
19805  typ = $1;
19806  SET_CONTAINER_2 (ctn, FROM_NUMBER (typ), NULL);
19807  $$ = ctn;
19808 
19809  DBG_PRINT}}
19810  | nested_set set_type
19811  {{
19812 
19813  container_2 ctn;
19814  PT_TYPE_ENUM typ;
19815  PT_NODE *dt;
19816 
19817  typ = $1;
19818  dt = parser_new_node (this_parser, PT_DATA_TYPE);
19819  if (dt)
19820  {
19821  dt->type_enum = $2;
19822  dt->data_type = NULL;
19823  }
19824 
19825  SET_CONTAINER_2 (ctn, FROM_NUMBER (typ), dt);
19826  $$ = ctn;
19827 
19828  DBG_PRINT}}
19829  | set_type
19830  {{
19831 
19832  container_2 ctn;
19833  PT_TYPE_ENUM typ;
19834  typ = $1;
19835  SET_CONTAINER_2 (ctn, FROM_NUMBER (typ), NULL);
19836  $$ = ctn;
19837 
19838  DBG_PRINT}}
19839  | primitive_type
19840  {{
19841 
19842  $$ = $1;
19843 
19844  DBG_PRINT}}
19845  ;
19846 
19847 nested_set
19848  : nested_set set_type
19849  {{
19850 
19851  $$ = $1;
19852 
19853  DBG_PRINT}}
19854  | set_type
19855  {{
19856 
19857  $$ = $1;
19858 
19859  DBG_PRINT}}
19860  ;
19861 
19862 data_type_list
19863  : data_type_list ',' data_type
19864  {{
19865 
19866  PT_NODE *dt;
19867  PT_TYPE_ENUM e;
19868 
19869  e = TO_NUMBER (CONTAINER_AT_0 ($3));
19870  dt = CONTAINER_AT_1 ($3);
19871 
19872  if (dt)
19873  {
19874  if (e == PT_TYPE_SET ||
19875  e == PT_TYPE_MULTISET ||
19876  e == PT_TYPE_SEQUENCE)
19877  {
19878  csql_yyerror("nested data type definition");
19879  }
19880  }
19881 
19882  if (!dt)
19883  {
19884  dt = parser_new_node (this_parser, PT_DATA_TYPE);
19885  if (dt)
19886  {
19887  dt->type_enum = e;
19888  dt->data_type = NULL;
19889  }
19890  }
19891 
19892  $$ = parser_make_link ($1, dt);
19893  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
19894 
19895  DBG_PRINT}}
19896  | data_type
19897  {{
19898 
19899  PT_NODE *dt;
19900  PT_TYPE_ENUM e;
19901 
19902  e = TO_NUMBER (CONTAINER_AT_0 ($1));
19903  dt = CONTAINER_AT_1 ($1);
19904 
19905  if (dt)
19906  {
19907  if (e == PT_TYPE_SET ||
19908  e == PT_TYPE_MULTISET ||
19909  e == PT_TYPE_SEQUENCE)
19910  {
19911  csql_yyerror("nested data type definition");
19912  }
19913  }
19914 
19915  if (!dt)
19916  {
19917  dt = parser_new_node (this_parser, PT_DATA_TYPE);
19918  if (dt)
19919  {
19920  dt->type_enum = e;
19921  dt->data_type = NULL;
19922  }
19923  }
19924 
19925  $$ = dt;
19926  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
19927 
19928  DBG_PRINT}}
19929  ;
19930 
19931 char_bit_type
19932  : CHAR_ opt_varying
19933  {{
19934 
19935  if ($2)
19936  $$ = PT_TYPE_VARCHAR;
19937  else
19938  $$ = PT_TYPE_CHAR;
19939 
19940  DBG_PRINT}}
19941  | VARCHAR
19942  {{
19943 
19944  $$ = PT_TYPE_VARCHAR;
19945 
19946  DBG_PRINT}}
19947  | NATIONAL CHAR_ opt_varying
19948  {{
19949 
19950  if ($3)
19951  $$ = PT_TYPE_VARNCHAR;
19952  else
19953  $$ = PT_TYPE_NCHAR;
19954 
19955  DBG_PRINT}}
19956  | NCHAR opt_varying
19957  {{
19958 
19959  if ($2)
19960  $$ = PT_TYPE_VARNCHAR;
19961  else
19962  $$ = PT_TYPE_NCHAR;
19963 
19964  DBG_PRINT}}
19965  | BIT opt_varying
19966  {{
19967 
19968  if ($2)
19969  $$ = PT_TYPE_VARBIT;
19970  else
19971  $$ = PT_TYPE_BIT;
19972 
19973  DBG_PRINT}}
19974  ;
19975 
19976 opt_varying
19977  : /* empty */
19978  {{
19979 
19980  $$ = 0;
19981 
19982  DBG_PRINT}}
19983  | VARYING
19984  {{
19985 
19986  $$ = 1;
19987 
19988  DBG_PRINT}}
19989  ;
19990 
19991 json_schema
19992  : /* empty */
19993  {{
19994 
19995  $$ = 0;
19996 
19997  DBG_PRINT}}
19998  | '(' CHAR_STRING ')'
19999  {{
20000 
20001  $$ = $2;
20002 
20003  DBG_PRINT}}
20004  ;
20005 
20006 primitive_type
20007  : INTEGER opt_padding
20008  {{
20009 
20010  container_2 ctn;
20011  SET_CONTAINER_2 (ctn, FROM_NUMBER (PT_TYPE_INTEGER), NULL);
20012  $$ = ctn;
20013 
20014  DBG_PRINT}}
20015  | SmallInt
20016  {{
20017 
20018  container_2 ctn;
20019  SET_CONTAINER_2 (ctn, FROM_NUMBER (PT_TYPE_SMALLINT), NULL);
20020  $$ = ctn;
20021 
20022  DBG_PRINT}}
20023  | BIGINT
20024  {{
20025 
20026  container_2 ctn;
20027  SET_CONTAINER_2 (ctn, FROM_NUMBER (PT_TYPE_BIGINT), NULL);
20028  $$ = ctn;
20029 
20030  DBG_PRINT}}
20031  | Double PRECISION
20032  {{
20033 
20034  container_2 ctn;
20035  SET_CONTAINER_2 (ctn, FROM_NUMBER (PT_TYPE_DOUBLE), NULL);
20036  $$ = ctn;
20037 
20038  DBG_PRINT}}
20039  | Double
20040  {{
20041 
20042  container_2 ctn;
20043  SET_CONTAINER_2 (ctn, FROM_NUMBER (PT_TYPE_DOUBLE), NULL);
20044  $$ = ctn;
20045 
20046  DBG_PRINT}}
20047  | Date
20048  {{
20049 
20050  container_2 ctn;
20051  SET_CONTAINER_2 (ctn, FROM_NUMBER (PT_TYPE_DATE), NULL);
20052  $$ = ctn;
20053 
20054  DBG_PRINT}}
20055  | Time
20056  {{
20057 
20058  container_2 ctn;
20059  SET_CONTAINER_2 (ctn, FROM_NUMBER (PT_TYPE_TIME), NULL);
20060  $$ = ctn;
20061 
20062  DBG_PRINT}}
20063  | Utime
20064  {{
20065 
20066  container_2 ctn;
20067  SET_CONTAINER_2 (ctn, FROM_NUMBER (PT_TYPE_TIMESTAMP), NULL);
20068  $$ = ctn;
20069 
20070  DBG_PRINT}}
20071  | TIMESTAMP
20072  {{
20073 
20074  container_2 ctn;
20075  SET_CONTAINER_2 (ctn, FROM_NUMBER (PT_TYPE_TIMESTAMP), NULL);
20076  $$ = ctn;
20077 
20078  DBG_PRINT}}
20079  | TIMESTAMP WITH Time ZONE
20080  {{
20081 
20082  container_2 ctn;
20083  SET_CONTAINER_2 (ctn, FROM_NUMBER (PT_TYPE_TIMESTAMPTZ), NULL);
20084  $$ = ctn;
20085 
20086  DBG_PRINT}}
20087  | TIMESTAMPTZ
20088  {{
20089 
20090  container_2 ctn;
20091  SET_CONTAINER_2 (ctn, FROM_NUMBER (PT_TYPE_TIMESTAMPTZ), NULL);
20092  $$ = ctn;
20093 
20094  DBG_PRINT}}
20095  | TIMESTAMP WITH LOCAL Time ZONE
20096  {{
20097 
20098  container_2 ctn;
20099  SET_CONTAINER_2 (ctn, FROM_NUMBER (PT_TYPE_TIMESTAMPLTZ), NULL);
20100  $$ = ctn;
20101 
20102  DBG_PRINT}}
20103  | TIMESTAMPLTZ
20104  {{
20105 
20106  container_2 ctn;
20107  SET_CONTAINER_2 (ctn, FROM_NUMBER (PT_TYPE_TIMESTAMPLTZ), NULL);
20108  $$ = ctn;
20109 
20110  DBG_PRINT}}
20111  | DATETIME
20112  {{
20113 
20114  container_2 ctn;
20115  SET_CONTAINER_2 (ctn, FROM_NUMBER (PT_TYPE_DATETIME), NULL);
20116  $$ = ctn;
20117 
20118  DBG_PRINT}}
20119  | DATETIME WITH Time ZONE
20120  {{
20121 
20122  container_2 ctn;
20123  SET_CONTAINER_2 (ctn, FROM_NUMBER (PT_TYPE_DATETIMETZ), NULL);
20124  $$ = ctn;
20125 
20126  DBG_PRINT}}
20127  | DATETIMETZ
20128  {{
20129 
20130  container_2 ctn;
20131  SET_CONTAINER_2 (ctn, FROM_NUMBER (PT_TYPE_DATETIMETZ), NULL);
20132  $$ = ctn;
20133 
20134  DBG_PRINT}}
20135  | DATETIME WITH LOCAL Time ZONE
20136  {{
20137 
20138  container_2 ctn;
20139  SET_CONTAINER_2 (ctn, FROM_NUMBER (PT_TYPE_DATETIMELTZ), NULL);
20140  $$ = ctn;
20141 
20142  DBG_PRINT}}
20143  | DATETIMELTZ
20144  {{
20145 
20146  container_2 ctn;
20147  SET_CONTAINER_2 (ctn, FROM_NUMBER (PT_TYPE_DATETIMELTZ), NULL);
20148  $$ = ctn;
20149 
20150  DBG_PRINT}}
20151  | Monetary
20152  {{
20153 
20154  container_2 ctn;
20155  SET_CONTAINER_2 (ctn, FROM_NUMBER (PT_TYPE_MONETARY), NULL);
20156  $$ = ctn;
20157 
20158  DBG_PRINT}}
20159  | JSON json_schema
20160  {{
20161  const char * json_schema_str = $2;
20162  container_2 ctn;
20163  PT_TYPE_ENUM type = PT_TYPE_JSON;
20164  PT_NODE * dt = parser_new_node (this_parser, PT_DATA_TYPE);
20165 
20166  if (dt && json_schema_str)
20167  {
20168  dt->type_enum = type;
20169  dt->info.data_type.json_schema = pt_append_bytes (this_parser,
20170  NULL,
20171  json_schema_str,
20172  strlen (json_schema_str));
20173  SET_CONTAINER_2 (ctn, FROM_NUMBER (type), dt);
20174  }
20175  else
20176  {
20177  SET_CONTAINER_2 (ctn, FROM_NUMBER (type), NULL);
20178  }
20179 
20180  $$ = ctn;
20181  DBG_PRINT}}
20182  | OBJECT
20183  {{
20184  container_2 ctn;
20185  SET_CONTAINER_2 (ctn, FROM_NUMBER (PT_TYPE_OBJECT), NULL);
20186  $$ = ctn;
20187 
20188  DBG_PRINT}}
20189  | String
20190  opt_charset
20191  opt_collation
20192  {{
20193 
20194  container_2 ctn;
20195  PT_TYPE_ENUM typ = PT_TYPE_VARCHAR;
20196  PT_NODE *dt = parser_new_node (this_parser, PT_DATA_TYPE);
20197  PT_NODE *charset_node = $2;
20198  PT_NODE *coll_node = $3;
20199  if (dt)
20200  {
20201  int coll_id, charset;
20202 
20203  dt->type_enum = typ;
20204  dt->info.data_type.precision = DB_MAX_VARCHAR_PRECISION;
20205 
20206  if (pt_check_grammar_charset_collation
20207  (this_parser, charset_node,
20208  coll_node, &charset, &coll_id) == NO_ERROR)
20209  {
20210  dt->info.data_type.units = charset;
20211  dt->info.data_type.collation_id = coll_id;
20212  }
20213  else
20214  {
20215  dt->info.data_type.units = -1;
20216  dt->info.data_type.collation_id = -1;
20217  }
20218 
20219  if (charset_node)
20220  {
20221  dt->info.data_type.has_cs_spec = true;
20222  }
20223  else
20224  {
20225  dt->info.data_type.has_cs_spec = false;
20226  }
20227 
20228  if (coll_node)
20229  {
20230  dt->info.data_type.has_coll_spec = true;
20231  }
20232  else
20233  {
20234  dt->info.data_type.has_coll_spec = false;
20235  }
20236  }
20237  SET_CONTAINER_2 (ctn, FROM_NUMBER (typ), dt);
20238  $$ = ctn;
20239 
20240  if (charset_node)
20241  {
20242  parser_free_node (this_parser, charset_node);
20243  }
20244 
20245  if (coll_node)
20246  {
20247  parser_free_node (this_parser, coll_node);
20248  }
20249 
20250  DBG_PRINT}}
20251  | BLOB_ opt_internal_external
20252  {{
20253 
20254  container_2 ctn;
20255  SET_CONTAINER_2 (ctn, FROM_NUMBER (PT_TYPE_BLOB), NULL);
20256  $$ = ctn;
20257 
20258  DBG_PRINT}}
20259  | CLOB_ opt_internal_external
20260  {{
20261 
20262  container_2 ctn;
20263  SET_CONTAINER_2 (ctn, FROM_NUMBER (PT_TYPE_CLOB), NULL);
20264  $$ = ctn;
20265 
20266  DBG_PRINT}}
20267  | class_name opt_identity
20268  {{
20269 
20270  container_2 ctn;
20271  PT_TYPE_ENUM typ = PT_TYPE_OBJECT;
20272  PT_NODE *dt = parser_new_node (this_parser, PT_DATA_TYPE);
20273 
20274  if (dt)
20275  {
20276  dt->type_enum = typ;
20277  dt->info.data_type.entity = $1;
20278  dt->info.data_type.units = $2;
20279  }
20280 
20281  SET_CONTAINER_2 (ctn, FROM_NUMBER (typ), dt);
20282  $$ = ctn;
20283 
20284  DBG_PRINT}}
20285  | char_bit_type
20286  opt_prec_1
20287  opt_charset
20288  opt_collation
20289  {{
20290 
20291  container_2 ctn;
20292  PT_TYPE_ENUM typ = $1;
20293  PT_NODE *len = NULL, *dt = NULL;
20294  int l = 1;
20295  PT_NODE *charset_node = NULL;
20296  PT_NODE *coll_node = NULL;
20297 
20298  len = $2;
20299  charset_node = $3;
20300  coll_node = $4;
20301 
20302  if (len)
20303  {
20304  int maxlen = DB_MAX_VARCHAR_PRECISION;
20305  l = len->info.value.data_value.i;
20306 
20307  switch (typ)
20308  {
20309  case PT_TYPE_CHAR:
20310  maxlen = DB_MAX_CHAR_PRECISION;
20311  break;
20312 
20313  case PT_TYPE_VARCHAR:
20314  maxlen = DB_MAX_VARCHAR_PRECISION;
20315  break;
20316 
20317  case PT_TYPE_NCHAR:
20318  maxlen = DB_MAX_NCHAR_PRECISION;
20319  break;
20320 
20321  case PT_TYPE_VARNCHAR:
20322  maxlen = DB_MAX_VARNCHAR_PRECISION;
20323  break;
20324 
20325  case PT_TYPE_BIT:
20326  maxlen = DB_MAX_BIT_PRECISION;
20327  break;
20328 
20329  case PT_TYPE_VARBIT:
20330  maxlen = DB_MAX_VARBIT_PRECISION;
20331  break;
20332 
20333  default:
20334  break;
20335  }
20336 
20337  if ((l > maxlen) || (len->type_enum != PT_TYPE_INTEGER))
20338  {
20339  if (typ == PT_TYPE_BIT || typ == PT_TYPE_VARBIT)
20340  {
20341  PT_ERRORmf (this_parser, len, MSGCAT_SET_PARSER_SYNTAX,
20342  MSGCAT_SYNTAX_MAX_BITLEN, maxlen);
20343  }
20344  else
20345  {
20346  PT_ERRORmf (this_parser, len, MSGCAT_SET_PARSER_SYNTAX,
20347  MSGCAT_SYNTAX_MAX_BYTELEN, maxlen);
20348  }
20349  }
20350 
20351  l = (l > maxlen ? maxlen : l);
20352  }
20353  else
20354  {
20355  switch (typ)
20356  {
20357  case PT_TYPE_CHAR:
20358  case PT_TYPE_NCHAR:
20359  case PT_TYPE_BIT:
20360  l = 1;
20361  break;
20362 
20363  case PT_TYPE_VARCHAR:
20364  l = DB_MAX_VARCHAR_PRECISION;
20365  break;
20366 
20367  case PT_TYPE_VARNCHAR:
20368  l = DB_MAX_VARNCHAR_PRECISION;
20369  break;
20370 
20371  case PT_TYPE_VARBIT:
20372  l = DB_MAX_VARBIT_PRECISION;
20373  break;
20374 
20375  default:
20376  break;
20377  }
20378  }
20379 
20380  dt = parser_new_node (this_parser, PT_DATA_TYPE);
20381  if (dt)
20382  {
20383  int coll_id, charset;
20384 
20385  dt->type_enum = typ;
20386  dt->info.data_type.precision = l;
20387  switch (typ)
20388  {
20389  case PT_TYPE_CHAR:
20390  case PT_TYPE_VARCHAR:
20391  case PT_TYPE_NCHAR:
20392  case PT_TYPE_VARNCHAR:
20393  if (pt_check_grammar_charset_collation
20394  (this_parser, charset_node,
20395  coll_node, &charset, &coll_id) == NO_ERROR)
20396  {
20397  dt->info.data_type.units = charset;
20398  dt->info.data_type.collation_id = coll_id;
20399  }
20400  else
20401  {
20402  dt->info.data_type.units = -1;
20403  dt->info.data_type.collation_id = -1;
20404  }
20405 
20406  if (charset_node)
20407  {
20408  dt->info.data_type.has_cs_spec = true;
20409  }
20410  else
20411  {
20412  dt->info.data_type.has_cs_spec = false;
20413  }
20414 
20415  if (coll_node)
20416  {
20417  dt->info.data_type.has_coll_spec = true;
20418  }
20419  else
20420  {
20421  dt->info.data_type.has_coll_spec = false;
20422  }
20423 
20424  break;
20425 
20426  case PT_TYPE_BIT:
20427  case PT_TYPE_VARBIT:
20428  dt->info.data_type.units = INTL_CODESET_RAW_BITS;
20429  break;
20430 
20431  default:
20432  break;
20433  }
20434  }
20435 
20436  SET_CONTAINER_2 (ctn, FROM_NUMBER (typ), dt);
20437  $$ = ctn;
20438  if (len)
20439  parser_free_node (this_parser, len);
20440 
20441  if (charset_node)
20442  {
20443  parser_free_node (this_parser, charset_node);
20444  }
20445 
20446  if (coll_node)
20447  {
20448  parser_free_node (this_parser, coll_node);
20449  }
20450 
20451  DBG_PRINT}}
20452  | NUMERIC opt_prec_2
20453  {{
20454 
20455  container_2 ctn;
20456  PT_TYPE_ENUM typ;
20457  PT_NODE *prec, *scale, *dt;
20458  prec = CONTAINER_AT_0 ($2);
20459  scale = CONTAINER_AT_1 ($2);
20460 
20461  dt = parser_new_node (this_parser, PT_DATA_TYPE);
20462  typ = PT_TYPE_NUMERIC;
20463 
20464  if (dt)
20465  {
20466  dt->type_enum = typ;
20467  dt->info.data_type.precision = prec ? prec->info.value.data_value.i : 15;
20468  dt->info.data_type.dec_precision =
20469  scale ? scale->info.value.data_value.i : 0;
20470 
20471  if (scale && prec)
20472  if (scale->info.value.data_value.i > prec->info.value.data_value.i)
20473  {
20474  PT_ERRORmf2 (this_parser, dt,
20475  MSGCAT_SET_PARSER_SEMANTIC,
20476  MSGCAT_SEMANTIC_INV_PREC_SCALE,
20477  prec->info.value.data_value.i,
20478  scale->info.value.data_value.i);
20479  }
20480  if (prec)
20481  if (prec->info.value.data_value.i > DB_MAX_NUMERIC_PRECISION)
20482  {
20483  PT_ERRORmf2 (this_parser, dt,
20484  MSGCAT_SET_PARSER_SEMANTIC,
20485  MSGCAT_SEMANTIC_PREC_TOO_BIG,
20486  prec->info.value.data_value.i,
20487  DB_MAX_NUMERIC_PRECISION);
20488  }
20489  }
20490 
20491  SET_CONTAINER_2 (ctn, FROM_NUMBER (typ), dt);
20492  $$ = ctn;
20493 
20494  if (prec)
20495  parser_free_node (this_parser, prec);
20496  if (scale)
20497  parser_free_node (this_parser, scale);
20498 
20499  DBG_PRINT}}
20500  | FLOAT_ opt_prec_1
20501  {{
20502 
20503  container_2 ctn;
20504  PT_TYPE_ENUM typ;
20505  PT_NODE *prec, *dt = NULL;
20506  prec = $2;
20507 
20508  if (prec &&
20509  prec->info.value.data_value.i >= 8 &&
20510  prec->info.value.data_value.i <= DB_MAX_NUMERIC_PRECISION)
20511  {
20512  typ = PT_TYPE_DOUBLE;
20513  }
20514  else
20515  {
20516  dt = parser_new_node (this_parser, PT_DATA_TYPE);
20517  typ = PT_TYPE_FLOAT;
20518 
20519  if (dt)
20520  {
20521  dt->type_enum = typ;
20522  dt->info.data_type.precision =
20523  prec ? prec->info.value.data_value.i : 7;
20524  dt->info.data_type.dec_precision = 0;
20525 
20526  if (prec)
20527  if (prec->info.value.data_value.i > DB_MAX_NUMERIC_PRECISION)
20528  {
20529  PT_ERRORmf2 (this_parser, dt,
20530  MSGCAT_SET_PARSER_SEMANTIC,
20531  MSGCAT_SEMANTIC_PREC_TOO_BIG,
20532  prec->info.value.data_value.i,
20533  DB_MAX_NUMERIC_PRECISION);
20534  }
20535  }
20536 
20537  }
20538 
20539  SET_CONTAINER_2 (ctn, FROM_NUMBER (typ), dt);
20540  $$ = ctn;
20541 
20542  if (prec)
20543  parser_free_node (this_parser, prec);
20544 
20545  DBG_PRINT}}
20546  | ENUM '(' char_string_literal_list ')' opt_charset opt_collation
20547  {{
20548  container_2 ctn;
20549  int charset = -1;
20550  int coll_id = -1;
20551 
20552  int elem_cs = -1;
20553  int list_cs = -1;
20554  int has_error = 0;
20555 
20556  PT_NODE *charset_node = $5;
20557  PT_NODE *coll_node = $6;
20558  PT_NODE *elem_list = $3;
20559  PT_NODE *dt, *elem;
20560 
20561  elem = elem_list;
20562  while (elem != NULL)
20563  {
20564  if (elem->data_type == NULL)
20565  {
20566  elem = elem->next;
20567  continue;
20568  }
20569 
20570  assert (elem->node_type == PT_VALUE);
20571  elem->info.value.print_charset = false;
20572 
20573  elem_cs = elem->data_type->info.data_type.units;
20574  if (elem->info.value.has_cs_introducer)
20575  {
20576  if (list_cs == -1)
20577  {
20578  list_cs = elem_cs;
20579  }
20580  else if (list_cs != elem_cs)
20581  {
20582  PT_ERRORm (this_parser, elem,
20583  MSGCAT_SET_PARSER_SEMANTIC,
20584  MSGCAT_SEMANTIC_INCOMPATIBLE_CS_COLL);
20585  has_error = 1;
20586  break;
20587  }
20588  }
20589  elem = elem->next;
20590  } /* END while */
20591 
20592  dt = parser_new_node (this_parser, PT_DATA_TYPE);
20593 
20594  if (!has_error && dt != NULL)
20595  {
20596  dt->type_enum = PT_TYPE_ENUMERATION;
20597  dt->info.data_type.enumeration = elem_list;
20598 
20599  if (charset_node == NULL && coll_node == NULL)
20600  {
20601  if (list_cs == -1)
20602  {
20603  charset = LANG_SYS_CODESET;
20604  }
20605  else
20606  {
20607  charset = list_cs;
20608  }
20609  coll_id = LANG_GET_BINARY_COLLATION (charset);
20610  dt->info.data_type.has_cs_spec = false;
20611  dt->info.data_type.has_coll_spec = false;
20612  }
20613  else if (pt_check_grammar_charset_collation (
20614  this_parser, charset_node,
20615  coll_node, &charset,
20616  &coll_id) == NO_ERROR)
20617  {
20618  if (charset_node)
20619  {
20620  dt->info.data_type.has_cs_spec = true;
20621  }
20622  else
20623  {
20624  dt->info.data_type.has_cs_spec = false;
20625  }
20626  if (coll_node)
20627  {
20628  dt->info.data_type.has_coll_spec = true;
20629  }
20630  else
20631  {
20632  dt->info.data_type.has_coll_spec = false;
20633  }
20634  }
20635  else
20636  {
20637  has_error = 1;
20638  dt->info.data_type.units = -1;
20639  dt->info.data_type.collation_id = -1;
20640  }
20641 
20642  if (!has_error)
20643  {
20644  dt->info.data_type.units = charset;
20645  dt->info.data_type.collation_id = coll_id;
20646  }
20647  }
20648 
20649  PARSER_SAVE_ERR_CONTEXT (dt, @3.buffer_pos)
20650 
20651  SET_CONTAINER_2 (ctn, FROM_NUMBER (PT_TYPE_ENUMERATION), dt);
20652 
20653  $$ = ctn;
20654  DBG_PRINT}}
20655  ;
20656 
20657 opt_internal_external
20658  : /* empty */
20659  {{
20660 
20661  $$ = 0;
20662 
20663  DBG_PRINT}}
20664  | INTERNAL
20665  {{
20666 
20667  $$ = PT_LOB_INTERNAL;
20668 
20669  DBG_PRINT}}
20670  | EXTERNAL
20671  {{
20672 
20673  $$ = PT_LOB_EXTERNAL;
20674 
20675  DBG_PRINT}}
20676  ;
20677 
20678 opt_identity
20679  : /* empty */
20680  {{
20681 
20682  $$ = 0;
20683 
20684  DBG_PRINT}}
20685  | IDENTITY
20686  {{
20687 
20688  $$ = 1;
20689 
20690  DBG_PRINT}}
20691  ;
20692 
20693 opt_prec_1
20694  : /* empty */
20695  {{
20696 
20697  $$ = NULL;
20698 
20699  DBG_PRINT}}
20700  | '(' unsigned_integer ')'
20701  {{
20702 
20703  $$ = $2;
20704 
20705  DBG_PRINT}}
20706  ;
20707 
20708 opt_padding
20709  : /* empty */
20710  {{
20711 
20712  $$ = NULL;
20713 
20714  DBG_PRINT}}
20715  | '(' unsigned_integer ')'
20716  {{
20717 
20718  $$ = NULL;
20719 
20720  DBG_PRINT}}
20721  ;
20722 
20723 opt_prec_2
20724  : /* empty */
20725  {{
20726 
20727  container_2 ctn;
20728  SET_CONTAINER_2 (ctn, NULL, NULL);
20729  $$ = ctn;
20730 
20731  DBG_PRINT}}
20732  | '(' unsigned_integer ')'
20733  {{
20734 
20735  container_2 ctn;
20736  SET_CONTAINER_2 (ctn, $2, NULL);
20737  $$ = ctn;
20738 
20739  DBG_PRINT}}
20740  | '(' unsigned_integer ',' unsigned_integer ')'
20741  {{
20742 
20743  container_2 ctn;
20744  SET_CONTAINER_2 (ctn, $2, $4);
20745  $$ = ctn;
20746 
20747  DBG_PRINT}}
20748  ;
20749 
20750 of_charset
20751  : CHARACTER_SET_
20752  | CHARSET
20753  ;
20754 
20755 opt_collation
20756  : /* empty */
20757  {{
20758 
20759  $$ = NULL;
20760 
20761  DBG_PRINT}}
20762  | collation_spec
20763  {{
20764 
20765  $$=$1;
20766 
20767  DBG_PRINT}}
20768  ;
20769 
20770 collation_spec
20771  : COLLATE char_string_literal
20772  {{
20773 
20774  $$ = $2;
20775 
20776  DBG_PRINT}}
20777  | COLLATE BINARY
20778  {{
20779  PT_NODE *node;
20780 
20781  node = parser_new_node (this_parser, PT_VALUE);
20782 
20783  if (node)
20784  {
20785  node->type_enum = PT_TYPE_CHAR;
20786  node->info.value.string_type = ' ';
20787  node->info.value.data_value.str =
20788  pt_append_bytes (this_parser, NULL, "binary", strlen ("binary"));
20789  PT_NODE_PRINT_VALUE_TO_TEXT (this_parser, node);
20790  }
20791 
20792  $$ = node;
20793  DBG_PRINT}}
20794  | COLLATE IdName
20795  {{
20796  PT_NODE *node;
20797 
20798  node = parser_new_node (this_parser, PT_VALUE);
20799 
20800  if (node)
20801  {
20802  node->type_enum = PT_TYPE_CHAR;
20803  node->info.value.string_type = ' ';
20804  node->info.value.data_value.str =
20805  pt_append_bytes (this_parser, NULL, $2, strlen ($2));
20806  PT_NODE_PRINT_VALUE_TO_TEXT (this_parser, node);
20807  }
20808 
20809  $$ = node;
20810  DBG_PRINT}}
20811  ;
20812 
20813 class_encrypt_spec
20814  : ENCRYPT opt_equalsign opt_encrypt_algorithm
20815  {{
20816  PT_NODE *node = NULL;
20817 
20818  node = parser_new_node (this_parser, PT_VALUE);
20819 
20820  if (node)
20821  {
20822  node->type_enum = PT_TYPE_INTEGER;
20823  node->info.value.data_value.i = $3;
20824  PT_NODE_PRINT_VALUE_TO_TEXT (this_parser, node);
20825  }
20826 
20827  $$ = node;
20828  DBG_PRINT}}
20829  ;
20830 
20831 class_comment_spec
20832  : COMMENT opt_equalsign char_string_literal
20833  {{
20834  PT_NODE *node = $3;
20835 
20836  if (node)
20837  {
20838  node->type_enum = PT_TYPE_VARCHAR;
20839 
20840  if (node->info.value.data_value.str->length >
20841  SM_MAX_CLASS_COMMENT_LENGTH)
20842  {
20843  PT_ERRORmf (this_parser, node, MSGCAT_SET_PARSER_SYNTAX,
20844  MSGCAT_SYNTAX_MAX_CLASS_COMMENT_LEN,
20845  SM_MAX_CLASS_COMMENT_LENGTH);
20846  }
20847  PT_NODE_PRINT_VALUE_TO_TEXT (this_parser, node);
20848  }
20849 
20850  $$ = node;
20851  DBG_PRINT}}
20852  | COMMENT /* 1 */
20853  ON_ /* 2 */
20854  opt_of_column_attribute /* 3 */
20855  { parser_attr_type = PT_NORMAL; } /* 4 */
20856  attr_def_comment_list /* 5 */
20857  {{
20858  PT_NODE *alter_node = parser_get_alter_node();
20859 
20860  if (alter_node != NULL)
20861  {
20862  alter_node->info.alter.code = PT_CHANGE_COLUMN_COMMENT;
20863  alter_node->info.alter.alter_clause.attr_mthd.attr_def_list = $5;
20864  }
20865  DBG_PRINT}}
20866  | COMMENT /* 1 */
20867  ON_ /* 2 */
20868  CLASS ATTRIBUTE /* 3, 4 */
20869  { parser_attr_type = PT_META_ATTR; } /* 5 */
20870  attr_def_comment_list /* 6 */
20871  {{
20872  PT_NODE *alter_node = parser_get_alter_node();
20873 
20874  if (alter_node != NULL)
20875  {
20876  alter_node->info.alter.code = PT_CHANGE_COLUMN_COMMENT;
20877  alter_node->info.alter.alter_clause.attr_mthd.attr_def_list = $6;
20878  }
20879  DBG_PRINT}}
20880  ;
20881 
20882 opt_vclass_comment_spec
20883  : /* empty */
20884  { $$ = NULL; }
20885  | class_comment_spec
20886  { $$ = $1; }
20887  ;
20888 
20889 opt_equalsign
20890  : /* empty */
20891  | '='
20892  ;
20893 
20894 opt_encrypt_algorithm
20895  : /* empty */
20896  { $$ = -1; } /* default algorithm from the system parameter */
20897  | AES
20898  { $$ = 1; } /* TDE_ALGORITHM_AES */
20899  | ARIA
20900  { $$ = 2; } /* TDE_ALGORITHM_ARIA */
20901  ;
20902 
20903 opt_comment_spec
20904  : /* empty */
20905  { $$ = NULL; }
20906  | COMMENT comment_value
20907  { $$ = $2; }
20908  ;
20909 
20910 comment_value
20911  : char_string_literal
20912  {{
20913  PT_NODE *node = $1;
20914 
20915  if (node)
20916  {
20917  node->type_enum = PT_TYPE_VARCHAR;
20918 
20919  if (node->info.value.data_value.str->length >
20920  SM_MAX_COMMENT_LENGTH)
20921  {
20922  PT_ERRORmf (this_parser, node, MSGCAT_SET_PARSER_SYNTAX,
20923  MSGCAT_SYNTAX_MAX_COMMENT_LEN,
20924  SM_MAX_COMMENT_LENGTH);
20925  }
20926  PT_NODE_PRINT_VALUE_TO_TEXT (this_parser, node);
20927  }
20928 
20929  $$ = node;
20930  DBG_PRINT}}
20931  ;
20932 
20933 opt_charset
20934  : /* empty */
20935  {{
20936 
20937  $$ = NULL;
20938 
20939  DBG_PRINT}}
20940  | charset_spec
20941  {{
20942 
20943  $$ = $1;
20944 
20945  DBG_PRINT}}
20946  ;
20947 
20948 charset_spec
20949  : of_charset char_string_literal
20950  {{
20951 
20952  $$ = $2;
20953 
20954  DBG_PRINT}}
20955  | of_charset BINARY
20956  {{
20957  PT_NODE *node;
20958 
20959  node = parser_new_node (this_parser, PT_VALUE);
20960 
20961  if (node)
20962  {
20963  node->type_enum = PT_TYPE_CHAR;
20964  node->info.value.string_type = ' ';
20965  node->info.value.data_value.str =
20966  pt_append_bytes (this_parser, NULL, "binary", strlen ("binary"));
20967  PT_NODE_PRINT_VALUE_TO_TEXT (this_parser, node);
20968  }
20969 
20970  $$ = node;
20971  DBG_PRINT}}
20972  | of_charset IdName
20973  {{
20974  PT_NODE *node;
20975 
20976  node = parser_new_node (this_parser, PT_VALUE);
20977 
20978  if (node)
20979  {
20980  node->type_enum = PT_TYPE_CHAR;
20981  node->info.value.string_type = ' ';
20982  node->info.value.data_value.str =
20983  pt_append_bytes (this_parser, NULL, $2, strlen ($2));
20984  PT_NODE_PRINT_VALUE_TO_TEXT (this_parser, node);
20985  }
20986 
20987  $$ = node;
20988  DBG_PRINT}}
20989  ;
20990 
20991 opt_using_charset
20992  : /* empty */
20993  {{
20994 
20995  int charset = lang_get_client_charset ();
20996  PT_NODE *node;
20997 
20998  node = parser_new_node (this_parser, PT_VALUE);
20999  if (node)
21000  {
21001  node->type_enum = PT_TYPE_INTEGER;
21002  node->info.value.data_value.i = charset;
21003  }
21004 
21005  $$ = node;
21006  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21007 
21008  DBG_PRINT}}
21009  | USING char_string_literal
21010  {{
21011 
21012  PT_NODE *charset_node = $2;
21013  int dummy;
21014  int charset = lang_get_client_charset ();
21015  PT_NODE *node;
21016 
21017  if (charset_node)
21018  {
21019  if (pt_check_grammar_charset_collation
21020  (this_parser, charset_node, NULL, &charset, &dummy) == 0)
21021  {
21022  parser_free_node (this_parser, charset_node);
21023  }
21024  }
21025  node = parser_new_node (this_parser, PT_VALUE);
21026  if (node)
21027  {
21028  node->type_enum = PT_TYPE_INTEGER;
21029  node->info.value.data_value.i = charset;
21030  }
21031 
21032  $$ = node;
21033  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21034 
21035  DBG_PRINT}}
21036  | USING IdName
21037  {{
21038 
21039  PT_NODE *temp_node = NULL;
21040  int dummy;
21041  int charset = lang_charset ();
21042  PT_NODE *node;
21043 
21044  temp_node = parser_new_node (this_parser, PT_VALUE);
21045 
21046  if (temp_node)
21047  {
21048  temp_node->type_enum = PT_TYPE_CHAR;
21049  temp_node->info.value.string_type = ' ';
21050  temp_node->info.value.data_value.str =
21051  pt_append_bytes (this_parser, NULL, $2, strlen ($2));
21052  PT_NODE_PRINT_VALUE_TO_TEXT (this_parser, temp_node);
21053  }
21054 
21055  if (temp_node)
21056  {
21057  if (pt_check_grammar_charset_collation
21058  (this_parser, temp_node, NULL, &charset, &dummy) == 0)
21059  {
21060  parser_free_node (this_parser, temp_node);
21061  }
21062  }
21063 
21064  node = parser_new_node (this_parser, PT_VALUE);
21065  if (node)
21066  {
21067  node->type_enum = PT_TYPE_INTEGER;
21068  node->info.value.data_value.i = charset;
21069  }
21070 
21071  $$ = node;
21072  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21073 
21074  DBG_PRINT}}
21075  | USING BINARY
21076  {{
21077 
21078  PT_NODE *node;
21079 
21080  node = parser_new_node (this_parser, PT_VALUE);
21081  if (node)
21082  {
21083  node->type_enum = PT_TYPE_INTEGER;
21084  node->info.value.data_value.i = INTL_CODESET_BINARY;
21085  }
21086 
21087  $$ = node;
21088  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21089 
21090  DBG_PRINT}}
21091  ;
21092 
21093 set_type
21094  : SET_OF
21095  {{
21096 
21097  $$ = PT_TYPE_SET;
21098 
21099  DBG_PRINT}}
21100  | MULTISET_OF
21101  {{
21102 
21103  $$ = PT_TYPE_MULTISET;
21104 
21105  DBG_PRINT}}
21106  | SEQUENCE_OF
21107  {{
21108 
21109  $$ = PT_TYPE_SEQUENCE;
21110 
21111  DBG_PRINT}}
21112  | of_container opt_of
21113  {{
21114 
21115  $$ = $1;
21116 
21117  DBG_PRINT}}
21118  ;
21119 
21120 opt_of
21121  : /* empty */
21122  | OF
21123  ;
21124 
21125 signed_literal_
21126  : literal_
21127  {{
21128 
21129  $$ = $1;
21130  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21131 
21132  DBG_PRINT}}
21133  | '-' unsigned_integer
21134  {{
21135 
21136  PT_NODE *node = $2;
21137  if (node != NULL)
21138  {
21139  if (node->type_enum == PT_TYPE_BIGINT)
21140  {
21141  node->info.value.data_value.bigint
21142  = -node->info.value.data_value.bigint;
21143  }
21144  else if (node->type_enum == PT_TYPE_NUMERIC)
21145  {
21146  const char *min_big_int = "9223372036854775808";
21147  if (node->info.value.data_value.str->length == 19
21148  && (strcmp ((const char *) node->info.value.data_value.str->bytes,
21149  min_big_int) == 0))
21150  {
21151  node->info.value.data_value.bigint = DB_BIGINT_MIN;
21152  node->type_enum = PT_TYPE_BIGINT;
21153  }
21154  else
21155  {
21156  /*add minus:*/
21157  char *minus_sign;
21158  PARSER_VARCHAR *buf = 0;
21159  minus_sign = pt_append_string (this_parser, NULL, "-");
21160  buf = pt_append_nulstring (this_parser, buf,
21161  minus_sign);
21162  buf = pt_append_nulstring (this_parser, buf,
21163  (const char *) node->info.value.data_value.str->bytes);
21164  node->info.value.data_value.str = buf;
21165  }
21166  }
21167  else
21168  {
21169  node->info.value.data_value.i = -node->info.value.data_value.i;
21170  }
21171 
21172  node->info.value.text = NULL;
21173  PT_NODE_PRINT_VALUE_TO_TEXT (this_parser, node);
21174  }
21175 
21176  $$ = node;
21177  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21178 
21179  DBG_PRINT}}
21180  | '-' unsigned_real
21181  {{
21182 
21183  /* not allowed partition type */
21184  /* this will cause semantic error */
21185  PT_NODE *node = $2;
21186  if (node != NULL)
21187  {
21188  if (node->type_enum == PT_TYPE_FLOAT)
21189  {
21190  node->info.value.data_value.f = -node->info.value.data_value.f;
21191  }
21192  else if (node->type_enum == PT_TYPE_DOUBLE)
21193  {
21194  node->info.value.data_value.d = -node->info.value.data_value.d;
21195  }
21196  else
21197  {
21198  char *minus_sign;
21199  PARSER_VARCHAR *buf = 0;
21200 
21201  assert (node->type_enum == PT_TYPE_NUMERIC);
21202  minus_sign = pt_append_string (this_parser, NULL, "-");
21203  /*add minus:*/
21204  buf = pt_append_nulstring (this_parser, buf,
21205  minus_sign);
21206  buf = pt_append_nulstring (this_parser, buf,
21207  (const char *) node->info.value.data_value.str->bytes);
21208  node->info.value.data_value.str = buf;
21209  }
21210 
21211  node->info.value.text = NULL;
21212  PT_NODE_PRINT_VALUE_TO_TEXT (this_parser, node);
21213  }
21214 
21215  $$ = node;
21216  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21217 
21218  DBG_PRINT}}
21219  | '-' monetary_literal
21220  {{
21221 
21222  /* not allowed partition type */
21223  /* this will cause semantic error */
21224 
21225  PT_NODE *node = $2;
21226 
21227  if (node != NULL)
21228  {
21229  assert (node->type_enum == PT_TYPE_MONETARY);
21230  node->info.value.data_value.money.amount =
21231  - node->info.value.data_value.money.amount;
21232  node->info.value.text = NULL;
21233  PT_NODE_PRINT_VALUE_TO_TEXT (this_parser, node);
21234  }
21235 
21236  $$ = node;
21237  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21238 
21239  DBG_PRINT}}
21240  ;
21241 
21242 literal_
21243  : literal_w_o_param
21244  {{
21245 
21246  $$ = $1;
21247  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21248 
21249  DBG_PRINT}}
21250  | param_
21251  {{
21252 
21253  $$ = $1;
21254  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21255 
21256  DBG_PRINT}}
21257  ;
21258 
21259 literal_w_o_param
21260  : unsigned_integer
21261  {{
21262 
21263  $$ = $1;
21264  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21265 
21266  DBG_PRINT}}
21267  | unsigned_real
21268  {{
21269 
21270  $$ = $1;
21271  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21272 
21273  DBG_PRINT}}
21274  | monetary_literal
21275  {{
21276 
21277  $$ = $1;
21278  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21279 
21280  DBG_PRINT}}
21281  | char_string_literal
21282  {{
21283 
21284  PT_NODE *node = $1;
21285 
21286  pt_value_set_collation_info (this_parser, node, NULL);
21287 
21288  $$ = node;
21289  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21290 
21291  DBG_PRINT}}
21292  | bit_string_literal
21293  {{
21294 
21295  $$ = $1;
21296  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21297 
21298  DBG_PRINT}}
21299  | host_param_input
21300  {{
21301 
21302  $$ = $1;
21303  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21304 
21305  DBG_PRINT}}
21306  | Null
21307  {{
21308 
21309  PT_NODE *node = parser_new_node (this_parser, PT_VALUE);
21310  if (node)
21311  node->type_enum = PT_TYPE_NULL;
21312  $$ = node;
21313  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21314 
21315  DBG_PRINT}}
21316  | constant_set
21317  {{
21318 
21319  $$ = $1;
21320  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21321 
21322  DBG_PRINT}}
21323  | NA
21324  {{
21325 
21326  PT_NODE *node = parser_new_node (this_parser, PT_VALUE);
21327  if (node)
21328  node->type_enum = PT_TYPE_NA;
21329  $$ = node;
21330  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21331 
21332  DBG_PRINT}}
21333  | date_or_time_literal
21334  {{
21335 
21336  $$ = $1;
21337  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21338 
21339  DBG_PRINT}}
21340  | boolean
21341  {{
21342 
21343  $$ = $1;
21344  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21345 
21346  DBG_PRINT}}
21347  | json_literal
21348  {{
21349 
21350  $$ = $1;
21351  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21352  DBG_PRINT}}
21353  ;
21354 
21355 boolean
21356  : True
21357  {{
21358 
21359  PT_NODE *node = parser_new_node (this_parser, PT_VALUE);
21360  if (node)
21361  {
21362  node->info.value.text = "true";
21363  node->info.value.data_value.i = 1;
21364  node->type_enum = PT_TYPE_LOGICAL;
21365  }
21366  $$ = node;
21367  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21368 
21369  DBG_PRINT}}
21370  | False
21371  {{
21372 
21373  PT_NODE *node = parser_new_node (this_parser, PT_VALUE);
21374  if (node)
21375  {
21376  node->info.value.text = "false";
21377  node->info.value.data_value.i = 0;
21378  node->type_enum = PT_TYPE_LOGICAL;
21379  }
21380  $$ = node;
21381  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21382 
21383  DBG_PRINT}}
21384  | UNKNOWN
21385  {{
21386 
21387  PT_NODE *node = parser_new_node (this_parser, PT_VALUE);
21388  if (node)
21389  node->type_enum = PT_TYPE_NULL;
21390  $$ = node;
21391  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21392 
21393  DBG_PRINT}}
21394  ;
21395 
21396 constant_set
21397  : opt_of_container '{' expression_list '}'
21398  {{
21399 
21400  PT_NODE *node = parser_new_node (this_parser, PT_VALUE);
21401  PT_NODE *e;
21402 
21403  if (node)
21404  {
21405  node->info.value.data_value.set = $3;
21406  node->type_enum = $1;
21407 
21408  for (e = node->info.value.data_value.set; e; e = e->next)
21409  {
21410  if (e->type_enum == PT_TYPE_STAR)
21411  {
21412  PT_ERRORf (this_parser, e,
21413  "check syntax at %s, illegal '*' expression.",
21414  pt_short_print (this_parser, e));
21415 
21416  break;
21417  }
21418  }
21419  }
21420 
21421  $$ = node;
21422  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21423 
21424  DBG_PRINT}}
21425  | opt_of_container '{' '}'
21426  {{
21427 
21428  PT_NODE *node = parser_new_node (this_parser, PT_VALUE);
21429 
21430  if (node)
21431  {
21432  node->info.value.data_value.set = 0;
21433  node->type_enum = $1;
21434  }
21435 
21436  $$ = node;
21437  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21438 
21439  DBG_PRINT}}
21440  ;
21441 
21442 opt_of_container
21443  : /* empty */
21444  {{
21445 
21446  $$ = PT_TYPE_SEQUENCE;
21447 
21448  DBG_PRINT}}
21449  | of_container
21450  {{
21451 
21452  $$ = $1;
21453 
21454  DBG_PRINT}}
21455  ;
21456 
21457 of_container
21458  : SET
21459  {{
21460 
21461  $$ = PT_TYPE_SET;
21462 
21463  DBG_PRINT}}
21464  | MULTISET
21465  {{
21466 
21467  $$ = PT_TYPE_MULTISET;
21468 
21469  DBG_PRINT}}
21470  | SEQUENCE
21471  {{
21472 
21473  $$ = PT_TYPE_SEQUENCE;
21474 
21475  DBG_PRINT}}
21476  | LIST
21477  {{
21478 
21479  $$ = PT_TYPE_SEQUENCE;
21480 
21481  DBG_PRINT}}
21482  ;
21483 
21484 identifier_list
21485  : identifier_list ',' identifier
21486  {{
21487 
21488  $$ = parser_make_link ($1, $3);
21489  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21490 
21491  DBG_PRINT}}
21492  | identifier
21493  {{
21494 
21495  $$ = $1;
21496  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21497 
21498  DBG_PRINT}}
21499  ;
21500 
21501 opt_bracketed_identifier_list
21502  : /* EMPTY */
21503  {{
21504  $$ = NULL;
21505  DBG_PRINT}}
21506  | '(' identifier_list ')'
21507  {{
21508  $$ = $2;
21509  DBG_PRINT}}
21510  ;
21511 
21512 simple_path_id_list
21513  : simple_path_id_list ',' simple_path_id
21514  {{
21515 
21516  $$ = parser_make_link ($1, $3);
21517  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21518 
21519  DBG_PRINT}}
21520  | simple_path_id
21521  {{
21522 
21523  $$ = $1;
21524  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21525 
21526  DBG_PRINT}}
21527  ;
21528 
21529 identifier
21530  : IdName
21531  {{//identifier : IdName
21532  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
21533 
21534  if (p)
21535  {
21536  int size_in;
21537  char *str_name = $1;
21538 
21539  size_in = strlen(str_name);
21540 
21541  PARSER_SAVE_ERR_CONTEXT (p, @$.buffer_pos)
21542  str_name = pt_check_identifier (this_parser, p,
21543  str_name, size_in);
21544  p->info.name.original = str_name;
21545  }
21546  $$ = p;
21547 
21548  DBG_PRINT}}
21549  | BracketDelimitedIdName
21550  {{//identifier | BracketDelimitedIdName
21551  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
21552 
21553  if (p)
21554  {
21555  int size_in;
21556  char *str_name = $1;
21557 
21558  size_in = strlen(str_name);
21559 
21560  PARSER_SAVE_ERR_CONTEXT (p, @$.buffer_pos)
21561  str_name = pt_check_identifier (this_parser, p,
21562  str_name, size_in);
21563  p->info.name.original = str_name;
21564  }
21565  $$ = p;
21566 
21567  DBG_PRINT}}
21568  | BacktickDelimitedIdName
21569  {{//identifier | BacktickDelimitedIdName
21570  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
21571 
21572  if (p)
21573  {
21574  int size_in;
21575  char *str_name = $1;
21576 
21577  size_in = strlen(str_name);
21578 
21579  PARSER_SAVE_ERR_CONTEXT (p, @$.buffer_pos)
21580  str_name = pt_check_identifier (this_parser, p,
21581  str_name, size_in);
21582  p->info.name.original = str_name;
21583  }
21584  $$ = p;
21585 
21586  DBG_PRINT}}
21587  | DelimitedIdName
21588  {{//identifier | DelimitedIdName
21589  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
21590 
21591  if (p)
21592  {
21593  int size_in;
21594  char *str_name = $1;
21595 
21596  size_in = strlen(str_name);
21597 
21598  PARSER_SAVE_ERR_CONTEXT (p, @$.buffer_pos)
21599  str_name = pt_check_identifier (this_parser, p,
21600  str_name, size_in);
21601  p->info.name.original = str_name;
21602  }
21603  $$ = p;
21604 
21605  DBG_PRINT}}
21606 /*{{{*/
21607  | ACTIVE
21608  {{
21609 
21610  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
21611  if (p)
21612  p->info.name.original = $1;
21613  $$ = p;
21614  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21615 
21616  DBG_PRINT}}
21617  | ANALYZE
21618  {{
21619 
21620  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
21621  if (p)
21622  p->info.name.original = $1;
21623  $$ = p;
21624  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21625 
21626  DBG_PRINT}}
21627  | ARCHIVE
21628  {{
21629 
21630  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
21631  if (p)
21632  p->info.name.original = $1;
21633  $$ = p;
21634  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21635 
21636  DBG_PRINT}}
21637  | AUTO_INCREMENT
21638  {{
21639 
21640  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
21641  if (p)
21642  p->info.name.original = $1;
21643  $$ = p;
21644  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21645 
21646  DBG_PRINT}}
21647  | CACHE
21648  {{
21649 
21650  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
21651  if (p)
21652  p->info.name.original = $1;
21653  $$ = p;
21654  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21655 
21656  DBG_PRINT}}
21657  | CAPACITY
21658  {{
21659 
21660  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
21661  if (p)
21662  p->info.name.original = $1;
21663  $$ = p;
21664  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21665 
21666  DBG_PRINT}}
21667  | CHARACTER_SET_
21668  {{
21669 
21670  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
21671  if (p)
21672  p->info.name.original = $1;
21673  $$ = p;
21674  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21675 
21676  DBG_PRINT}}
21677  | CHARSET
21678  {{
21679 
21680  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
21681  if (p)
21682  p->info.name.original = $1;
21683  $$ = p;
21684  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21685 
21686  DBG_PRINT}}
21687  | CHR
21688  {{
21689 
21690  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
21691  if (p)
21692  p->info.name.original = $1;
21693  $$ = p;
21694  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21695 
21696  DBG_PRINT}}
21697  | CLOB_TO_CHAR
21698  {{
21699 
21700  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
21701  if (p)
21702  p->info.name.original = $1;
21703  $$ = p;
21704  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21705 
21706  DBG_PRINT}}
21707  | CLOSE
21708  {{
21709 
21710  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
21711  if (p)
21712  p->info.name.original = $1;
21713  $$ = p;
21714  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21715 
21716  DBG_PRINT}}
21717  | COLLATION
21718  {{
21719 
21720  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
21721  if (p)
21722  p->info.name.original = $1;
21723  $$ = p;
21724  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21725 
21726  DBG_PRINT}}
21727  | COLUMNS
21728  {{
21729 
21730  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
21731  if (p)
21732  p->info.name.original = $1;
21733  $$ = p;
21734  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21735 
21736  DBG_PRINT}}
21737  | COMMENT
21738  {{
21739 
21740  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
21741  if (p)
21742  p->info.name.original = $1;
21743  $$ = p;
21744  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21745 
21746  DBG_PRINT}}
21747  | COMMITTED
21748  {{
21749 
21750  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
21751  if (p)
21752  p->info.name.original = $1;
21753  $$ = p;
21754  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21755 
21756  DBG_PRINT}}
21757  | COST
21758  {{
21759 
21760  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
21761  if (p)
21762  p->info.name.original = $1;
21763  $$ = p;
21764  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21765 
21766  DBG_PRINT}}
21767  | CRITICAL
21768  {{
21769  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
21770  if (p)
21771  p->info.name.original = $1;
21772  $$ = p;
21773  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21774 
21775  DBG_PRINT}}
21776  | CUME_DIST
21777  {{
21778  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
21779  if (p != NULL)
21780  {
21781  p->info.name.original = $1;
21782  }
21783  $$ = p;
21784  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21785 
21786  DBG_PRINT}}
21787  | DECREMENT
21788  {{
21789 
21790  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
21791  if (p)
21792  p->info.name.original = $1;
21793  $$ = p;
21794  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21795 
21796  DBG_PRINT}}
21797  | DENSE_RANK
21798  {{
21799 
21800  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
21801  if (p)
21802  p->info.name.original = $1;
21803  $$ = p;
21804  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21805 
21806  DBG_PRINT}}
21807  | ELT
21808  {{
21809 
21810  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
21811  if (p)
21812  p->info.name.original = $1;
21813  $$ = p;
21814  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21815 
21816  DBG_PRINT}}
21817  | EXPLAIN
21818  {{
21819 
21820  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
21821  if (p)
21822  p->info.name.original = $1;
21823  $$ = p;
21824  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21825 
21826  DBG_PRINT}}
21827  | FULLSCAN
21828  {{
21829 
21830  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
21831  if (p)
21832  p->info.name.original = $1;
21833  $$ = p;
21834  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21835 
21836  DBG_PRINT}}
21837  | GE_INF_
21838  {{
21839 
21840  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
21841  if (p)
21842  p->info.name.original = $1;
21843  $$ = p;
21844  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21845 
21846  DBG_PRINT}}
21847  | GE_LE_
21848  {{
21849 
21850  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
21851  if (p)
21852  p->info.name.original = $1;
21853  $$ = p;
21854  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21855 
21856  DBG_PRINT}}
21857  | GE_LT_
21858  {{
21859 
21860  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
21861  if (p)
21862  p->info.name.original = $1;
21863  $$ = p;
21864  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21865 
21866  DBG_PRINT}}
21867  | GRANTS
21868  {{
21869 
21870  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
21871  if (p)
21872  p->info.name.original = $1;
21873  $$ = p;
21874  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21875 
21876  DBG_PRINT}}
21877  | GROUP_CONCAT
21878  {{
21879 
21880  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
21881  if (p)
21882  p->info.name.original = $1;
21883  $$ = p;
21884  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21885 
21886  DBG_PRINT}}
21887  | GROUPS
21888  {{
21889 
21890  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
21891  if (p)
21892  p->info.name.original = $1;
21893  $$ = p;
21894  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21895 
21896  DBG_PRINT}}
21897  | GT_INF_
21898  {{
21899 
21900  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
21901  if (p)
21902  p->info.name.original = $1;
21903  $$ = p;
21904  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21905 
21906  DBG_PRINT}}
21907  | GT_LE_
21908  {{
21909 
21910  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
21911  if (p)
21912  p->info.name.original = $1;
21913  $$ = p;
21914  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21915 
21916  DBG_PRINT}}
21917  | GT_LT_
21918  {{
21919 
21920  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
21921  if (p)
21922  p->info.name.original = $1;
21923  $$ = p;
21924  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21925 
21926  DBG_PRINT}}
21927  | HASH
21928  {{
21929 
21930  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
21931  if (p)
21932  p->info.name.original = $1;
21933  $$ = p;
21934  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21935 
21936  DBG_PRINT}}
21937  | HEADER
21938  {{
21939 
21940  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
21941  if (p)
21942  p->info.name.original = $1;
21943  $$ = p;
21944  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21945 
21946  DBG_PRINT}}
21947  | HEAP
21948  {{
21949 
21950  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
21951  if (p)
21952  p->info.name.original = $1;
21953  $$ = p;
21954  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21955 
21956  DBG_PRINT}}
21957  | INACTIVE
21958  {{
21959 
21960  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
21961  if (p)
21962  p->info.name.original = $1;
21963  $$ = p;
21964  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21965 
21966  DBG_PRINT}}
21967  | INCREMENT
21968  {{
21969 
21970  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
21971  if (p)
21972  p->info.name.original = $1;
21973  $$ = p;
21974  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21975 
21976  DBG_PRINT}}
21977  | INDEX_PREFIX
21978  {{
21979 
21980  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
21981  if (p)
21982  p->info.name.original = $1;
21983  $$ = p;
21984  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21985 
21986  DBG_PRINT}}
21987  | INDEXES
21988  {{
21989 
21990  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
21991  if (p)
21992  p->info.name.original = $1;
21993  $$ = p;
21994  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
21995 
21996  DBG_PRINT}}
21997  | INFINITE_
21998  {{
21999 
22000  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22001  if (p)
22002  p->info.name.original = $1;
22003  $$ = p;
22004  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22005 
22006  DBG_PRINT}}
22007  | INF_LE_
22008  {{
22009 
22010  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22011  if (p)
22012  p->info.name.original = $1;
22013  $$ = p;
22014  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22015 
22016  DBG_PRINT}}
22017  | INF_LT_
22018  {{
22019 
22020  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22021  if (p)
22022  p->info.name.original = $1;
22023  $$ = p;
22024  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22025 
22026  DBG_PRINT}}
22027  | INSTANCES
22028  {{
22029 
22030  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22031  if (p)
22032  p->info.name.original = $1;
22033  $$ = p;
22034  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22035 
22036  DBG_PRINT}}
22037  | INVALIDATE
22038  {{
22039 
22040  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22041  if (p)
22042  p->info.name.original = $1;
22043  $$ = p;
22044  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22045 
22046  DBG_PRINT}}
22047  | INVISIBLE
22048  {{
22049  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22050  if (p)
22051  p->info.name.original = $1;
22052  $$ = p;
22053  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22054  DBG_PRINT}}
22055  | JAVA
22056  {{
22057 
22058  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22059  if (p)
22060  p->info.name.original = $1;
22061  $$ = p;
22062  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22063 
22064  DBG_PRINT}}
22065 
22066  | JOB
22067  {{
22068 
22069  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22070  if (p)
22071  p->info.name.original = $1;
22072  $$ = p;
22073  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22074 
22075  DBG_PRINT}}
22076 
22077  | JSON_ARRAYAGG
22078  {{
22079 
22080  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22081  if (p)
22082  p->info.name.original = $1;
22083  $$ = p;
22084  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22085 
22086  DBG_PRINT}}
22087  | JSON_ARRAY_LEX
22088  {{
22089 
22090  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22091  if (p)
22092  p->info.name.original = $1;
22093  $$ = p;
22094  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22095 
22096  DBG_PRINT}}
22097  | JSON_ARRAY_APPEND
22098  {{
22099 
22100  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22101  if (p)
22102  p->info.name.original = $1;
22103  $$ = p;
22104  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22105 
22106  DBG_PRINT}}
22107  | JSON_ARRAY_INSERT
22108  {{
22109 
22110  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22111  if (p)
22112  p->info.name.original = $1;
22113  $$ = p;
22114  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22115 
22116  DBG_PRINT}}
22117  | JSON_CONTAINS
22118  {{
22119 
22120  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22121  if (p)
22122  p->info.name.original = $1;
22123  $$ = p;
22124  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22125 
22126  DBG_PRINT}}
22127  | JSON_CONTAINS_PATH
22128  {{
22129 
22130  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22131  if (p)
22132  p->info.name.original = $1;
22133  $$ = p;
22134  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22135 
22136  DBG_PRINT}}
22137  | JSON_DEPTH
22138  {{
22139 
22140  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22141  if (p)
22142  p->info.name.original = $1;
22143  $$ = p;
22144  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22145 
22146  DBG_PRINT}}
22147  | JSON_EXTRACT
22148  {{
22149 
22150  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22151  if (p)
22152  p->info.name.original = $1;
22153  $$ = p;
22154  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22155 
22156  DBG_PRINT}}
22157  | JSON_GET_ALL_PATHS
22158  {{
22159 
22160  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22161  if (p)
22162  p->info.name.original = $1;
22163  $$ = p;
22164  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22165 
22166  DBG_PRINT}}
22167  | JSON_INSERT
22168  {{
22169 
22170  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22171  if (p)
22172  p->info.name.original = $1;
22173  $$ = p;
22174  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22175 
22176  DBG_PRINT}}
22177  | JSON_KEYS
22178  {{
22179 
22180  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22181  if (p)
22182  p->info.name.original = $1;
22183  $$ = p;
22184  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22185 
22186  DBG_PRINT}}
22187  | JSON_LENGTH
22188  {{
22189 
22190  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22191  if (p)
22192  p->info.name.original = $1;
22193  $$ = p;
22194  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22195 
22196  DBG_PRINT}}
22197  | JSON_MERGE
22198  {{
22199 
22200  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22201  if (p)
22202  p->info.name.original = $1;
22203  $$ = p;
22204  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22205 
22206  DBG_PRINT}}
22207  | JSON_MERGE_PATCH
22208  {{
22209 
22210  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22211  if (p)
22212  p->info.name.original = $1;
22213  $$ = p;
22214  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22215 
22216  DBG_PRINT}}
22217  | JSON_MERGE_PRESERVE
22218  {{
22219 
22220  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22221  if (p)
22222  p->info.name.original = $1;
22223  $$ = p;
22224  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22225 
22226  DBG_PRINT}}
22227  | JSON_OBJECTAGG
22228  {{
22229 
22230  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22231  if (p)
22232  p->info.name.original = $1;
22233  $$ = p;
22234  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22235 
22236  DBG_PRINT}}
22237  | JSON_OBJECT_LEX
22238  {{
22239 
22240  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22241  if (p)
22242  p->info.name.original = $1;
22243  $$ = p;
22244  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22245 
22246  DBG_PRINT}}
22247  | JSON_PRETTY
22248  {{
22249 
22250  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22251  if (p)
22252  p->info.name.original = $1;
22253  $$ = p;
22254  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22255 
22256  DBG_PRINT}}
22257  | JSON_QUOTE
22258  {{
22259 
22260  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22261  if (p)
22262  p->info.name.original = $1;
22263  $$ = p;
22264  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22265 
22266  DBG_PRINT}}
22267  | JSON_REMOVE
22268  {{
22269 
22270  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22271  if (p)
22272  p->info.name.original = $1;
22273  $$ = p;
22274  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22275 
22276  DBG_PRINT}}
22277  | JSON_REPLACE
22278  {{
22279 
22280  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22281  if (p)
22282  p->info.name.original = $1;
22283  $$ = p;
22284  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22285 
22286  DBG_PRINT}}
22287  | JSON_SEARCH
22288  {{
22289 
22290  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22291  if (p)
22292  p->info.name.original = $1;
22293  $$ = p;
22294  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22295 
22296  DBG_PRINT}}
22297  | JSON_SET
22298  {{
22299 
22300  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22301  if (p)
22302  p->info.name.original = $1;
22303  $$ = p;
22304  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22305 
22306  DBG_PRINT}}
22307  | JSON_TABLE
22308  {{
22309 
22310  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22311  if (p)
22312  p->info.name.original = $1;
22313  $$ = p;
22314  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22315 
22316  DBG_PRINT}}
22317  | JSON_TYPE
22318  {{
22319 
22320  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22321  if (p)
22322  p->info.name.original = $1;
22323  $$ = p;
22324  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22325 
22326  DBG_PRINT}}
22327  | JSON_UNQUOTE
22328  {{
22329 
22330  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22331  if (p)
22332  p->info.name.original = $1;
22333  $$ = p;
22334  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22335 
22336  DBG_PRINT}}
22337  | JSON_VALID
22338  {{
22339 
22340  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22341  if (p)
22342  p->info.name.original = $1;
22343  $$ = p;
22344  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22345 
22346  DBG_PRINT}}
22347  | KEYS
22348  {{
22349 
22350  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22351  if (p)
22352  p->info.name.original = $1;
22353  $$ = p;
22354  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22355 
22356  DBG_PRINT}}
22357  | LAG
22358  {{
22359 
22360  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22361  if (p)
22362  p->info.name.original = $1;
22363  $$ = p;
22364  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22365 
22366  DBG_PRINT}}
22367  | LEAD
22368  {{
22369 
22370  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22371  if (p)
22372  p->info.name.original = $1;
22373  $$ = p;
22374  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22375 
22376  DBG_PRINT}}
22377  | LOCK_
22378  {{
22379 
22380  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22381  if (p)
22382  p->info.name.original = $1;
22383  $$ = p;
22384  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22385 
22386  DBG_PRINT}}
22387  | LOG
22388  {{
22389 
22390  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22391  if (p)
22392  p->info.name.original = $1;
22393  $$ = p;
22394  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22395 
22396  DBG_PRINT}}
22397  | MAXIMUM
22398  {{
22399 
22400  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22401  if (p)
22402  p->info.name.original = $1;
22403  $$ = p;
22404  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22405 
22406  DBG_PRINT}}
22407  | MAXVALUE
22408  {{
22409 
22410  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22411  if (p)
22412  p->info.name.original = $1;
22413  $$ = p;
22414  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22415 
22416  DBG_PRINT}}
22417  | MEMBERS
22418  {{
22419 
22420  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22421  if (p)
22422  p->info.name.original = $1;
22423  $$ = p;
22424  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22425 
22426  DBG_PRINT}}
22427  | MINVALUE
22428  {{
22429 
22430  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22431  if (p)
22432  p->info.name.original = $1;
22433  $$ = p;
22434  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22435 
22436  DBG_PRINT}}
22437  | NAME
22438  {{
22439 
22440  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22441  if (p)
22442  p->info.name.original = $1;
22443  $$ = p;
22444  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22445 
22446  DBG_PRINT}}
22447  | NOCACHE
22448  {{
22449 
22450  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22451  if (p)
22452  p->info.name.original = $1;
22453  $$ = p;
22454  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22455 
22456  DBG_PRINT}}
22457  | NOMAXVALUE
22458  {{
22459 
22460  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22461  if (p)
22462  p->info.name.original = $1;
22463  $$ = p;
22464  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22465 
22466  DBG_PRINT}}
22467  | NOMINVALUE
22468  {{
22469 
22470  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22471  if (p)
22472  p->info.name.original = $1;
22473  $$ = p;
22474  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22475 
22476  DBG_PRINT}}
22477  | OFFSET
22478  {{
22479 
22480  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22481  if (p)
22482  p->info.name.original = $1;
22483  $$ = p;
22484  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22485 
22486  DBG_PRINT}}
22487  | OPEN
22488  {{
22489 
22490  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22491  if (p)
22492  p->info.name.original = $1;
22493  $$ = p;
22494  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22495 
22496  DBG_PRINT}}
22497  | OWNER
22498  {{
22499 
22500  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22501  if (p)
22502  p->info.name.original = $1;
22503  $$ = p;
22504  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22505 
22506  DBG_PRINT}}
22507  | PAGE
22508  {{
22509 
22510  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22511  if (p)
22512  p->info.name.original = $1;
22513  $$ = p;
22514  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22515 
22516  DBG_PRINT}}
22517  | PARTITIONING
22518  {{
22519 
22520  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22521  if (p)
22522  p->info.name.original = $1;
22523  $$ = p;
22524  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22525 
22526  DBG_PRINT}}
22527  | PARTITIONS
22528  {{
22529 
22530  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22531  if (p)
22532  p->info.name.original = $1;
22533  $$ = p;
22534  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22535 
22536  DBG_PRINT}}
22537  | PASSWORD
22538  {{
22539 
22540  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22541  if (p)
22542  p->info.name.original = $1;
22543  $$ = p;
22544  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22545 
22546  DBG_PRINT}}
22547  | PATH
22548  {{
22549 
22550  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22551  if (p)
22552  p->info.name.original = $1;
22553  $$ = p;
22554  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22555 
22556  DBG_PRINT}}
22557  | PERCENT_RANK
22558  {{
22559 
22560  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22561  if (p != NULL)
22562  {
22563  p->info.name.original = $1;
22564  }
22565  $$ = p;
22566  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22567 
22568  DBG_PRINT}}
22569  | PRINT
22570  {{
22571 
22572  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22573  if (p)
22574  p->info.name.original = $1;
22575  $$ = p;
22576  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22577 
22578  DBG_PRINT}}
22579  | PRIORITY
22580  {{
22581 
22582  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22583  if (p)
22584  p->info.name.original = $1;
22585  $$ = p;
22586  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22587 
22588  DBG_PRINT}}
22589  | QUEUES
22590  {{
22591 
22592  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22593  if (p)
22594  p->info.name.original = $1;
22595  $$ = p;
22596  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22597 
22598  DBG_PRINT}}
22599  | RANGE_
22600  {{
22601 
22602  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22603  if (p)
22604  p->info.name.original = $1;
22605  $$ = p;
22606  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22607 
22608  DBG_PRINT}}
22609  | RANK
22610  {{
22611 
22612  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22613  if (p)
22614  p->info.name.original = $1;
22615  $$ = p;
22616  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22617 
22618  DBG_PRINT}}
22619  | REJECT_
22620  {{
22621 
22622  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22623  if (p)
22624  p->info.name.original = $1;
22625  $$ = p;
22626  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22627 
22628  DBG_PRINT}}
22629  | REMOVE
22630  {{
22631 
22632  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22633  if (p)
22634  p->info.name.original = $1;
22635  $$ = p;
22636  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22637 
22638  DBG_PRINT}}
22639  | REORGANIZE
22640  {{
22641 
22642  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22643  if (p)
22644  p->info.name.original = $1;
22645  $$ = p;
22646  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22647 
22648  DBG_PRINT}}
22649  | REPEATABLE
22650  {{
22651 
22652  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22653  if (p)
22654  p->info.name.original = $1;
22655  $$ = p;
22656  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22657 
22658  DBG_PRINT}}
22659  | RETAIN
22660  {{
22661 
22662  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22663  if (p)
22664  p->info.name.original = $1;
22665  $$ = p;
22666  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22667 
22668  DBG_PRINT}}
22669  | REUSE_OID
22670  {{
22671 
22672  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22673  if (p)
22674  p->info.name.original = $1;
22675  $$ = p;
22676  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22677 
22678  DBG_PRINT}}
22679  | DONT_REUSE_OID
22680  {{
22681 
22682  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22683  if (p)
22684  p->info.name.original = $1;
22685  $$ = p;
22686  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22687 
22688  DBG_PRINT}}
22689  | REVERSE
22690  {{
22691 
22692  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22693  if (p)
22694  p->info.name.original = $1;
22695  $$ = p;
22696  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22697 
22698  DBG_PRINT}}
22699  | DISK_SIZE
22700  {{
22701 
22702  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22703  if (p)
22704  p->info.name.original = $1;
22705  $$ = p;
22706  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22707 
22708  DBG_PRINT}}
22709  | ROW_NUMBER
22710  {{
22711 
22712  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22713  if (p)
22714  p->info.name.original = $1;
22715  $$ = p;
22716  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22717 
22718  DBG_PRINT}}
22719  | SECTIONS
22720  {{
22721 
22722  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22723  if (p)
22724  p->info.name.original = $1;
22725  $$ = p;
22726  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22727 
22728  DBG_PRINT}}
22729  | SEPARATOR
22730  {{
22731 
22732  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22733  if (p)
22734  p->info.name.original = $1;
22735  $$ = p;
22736  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22737 
22738  DBG_PRINT}}
22739  | SERIAL
22740  {{
22741 
22742  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22743  if (p)
22744  p->info.name.original = $1;
22745  $$ = p;
22746  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22747 
22748  DBG_PRINT}}
22749  | SHOW
22750  {{
22751 
22752  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22753  if (p)
22754  p->info.name.original = $1;
22755  $$ = p;
22756  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22757 
22758  DBG_PRINT}}
22759  | SLOTS
22760  {{
22761 
22762  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22763  if (p)
22764  p->info.name.original = $1;
22765  $$ = p;
22766  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22767 
22768  DBG_PRINT}}
22769  | SLOTTED
22770  {{
22771 
22772  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22773  if (p)
22774  p->info.name.original = $1;
22775  $$ = p;
22776  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22777 
22778  DBG_PRINT}}
22779  | STABILITY
22780  {{
22781 
22782  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22783  if (p)
22784  p->info.name.original = $1;
22785  $$ = p;
22786  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22787 
22788  DBG_PRINT}}
22789  | START_
22790  {{
22791 
22792  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22793  if (p)
22794  p->info.name.original = $1;
22795  $$ = p;
22796  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22797 
22798  DBG_PRINT}}
22799  | STATEMENT
22800  {{
22801 
22802  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22803  if (p)
22804  p->info.name.original = $1;
22805  $$ = p;
22806  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22807 
22808  DBG_PRINT}}
22809  | STATUS
22810  {{
22811 
22812  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22813  if (p)
22814  p->info.name.original = $1;
22815  $$ = p;
22816  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22817 
22818  DBG_PRINT}}
22819  | STDDEV
22820  {{
22821 
22822  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22823  if (p)
22824  p->info.name.original = $1;
22825  $$ = p;
22826  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22827 
22828  DBG_PRINT}}
22829  | STDDEV_POP
22830  {{
22831 
22832  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22833  if (p)
22834  p->info.name.original = $1;
22835  $$ = p;
22836  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22837 
22838  DBG_PRINT}}
22839  | STDDEV_SAMP
22840  {{
22841 
22842  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22843  if (p)
22844  p->info.name.original = $1;
22845  $$ = p;
22846  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22847 
22848  DBG_PRINT}}
22849  | SYSTEM
22850  {{
22851 
22852  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22853  if (p)
22854  p->info.name.original = $1;
22855  $$ = p;
22856  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22857 
22858  DBG_PRINT}}
22859  | TABLES
22860  {{
22861 
22862  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22863  if (p)
22864  p->info.name.original = $1;
22865  $$ = p;
22866  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22867 
22868  DBG_PRINT}}
22869  | TEXT
22870  {{
22871 
22872  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22873  if (p)
22874  p->info.name.original = $1;
22875  $$ = p;
22876 
22877  DBG_PRINT}}
22878  | THAN
22879  {{
22880 
22881  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22882  if (p)
22883  p->info.name.original = $1;
22884  $$ = p;
22885  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22886 
22887  DBG_PRINT}}
22888  | THREADS
22889  {{
22890 
22891  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22892  if (p)
22893  p->info.name.original = $1;
22894  $$ = p;
22895  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22896 
22897  DBG_PRINT}}
22898  | TIMEOUT
22899  {{
22900 
22901  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22902  if (p)
22903  p->info.name.original = $1;
22904  $$ = p;
22905  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22906 
22907  DBG_PRINT}}
22908  | TRACE
22909  {{
22910 
22911  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22912  if (p)
22913  p->info.name.original = $1;
22914  $$ = p;
22915  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22916 
22917  DBG_PRINT}}
22918  | TRAN
22919  {{
22920 
22921  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22922  if (p)
22923  p->info.name.original = $1;
22924  $$ = p;
22925  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22926 
22927  DBG_PRINT}}
22928  | TRIGGERS
22929  {{
22930 
22931  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22932  if (p)
22933  p->info.name.original = $1;
22934  $$ = p;
22935  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22936 
22937  DBG_PRINT}}
22938  | UNCOMMITTED
22939  {{
22940 
22941  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22942  if (p)
22943  p->info.name.original = $1;
22944  $$ = p;
22945  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22946 
22947  DBG_PRINT}}
22948  | VAR_POP
22949  {{
22950 
22951  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22952  if (p)
22953  p->info.name.original = $1;
22954  $$ = p;
22955  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22956 
22957  DBG_PRINT}}
22958  | VAR_SAMP
22959  {{
22960 
22961  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22962  if (p)
22963  p->info.name.original = $1;
22964  $$ = p;
22965  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22966 
22967  DBG_PRINT}}
22968  | VARIANCE
22969  {{
22970 
22971  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22972  if (p)
22973  p->info.name.original = $1;
22974  $$ = p;
22975  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22976 
22977  DBG_PRINT}}
22978  | VISIBLE
22979  {{
22980  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22981  if (p)
22982  p->info.name.original = $1;
22983  $$ = p;
22984  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22985  DBG_PRINT}}
22986  | VOLUME
22987  {{
22988 
22989  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
22990  if (p)
22991  p->info.name.original = $1;
22992  $$ = p;
22993  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
22994 
22995  DBG_PRINT}}
22996  | WORKSPACE
22997  {{
22998 
22999  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
23000  if (p)
23001  p->info.name.original = $1;
23002  $$ = p;
23003  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23004 
23005  DBG_PRINT}}
23006  | ADDDATE
23007  {{
23008 
23009  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
23010  if (p)
23011  p->info.name.original = $1;
23012  $$ = p;
23013  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23014 
23015  DBG_PRINT}}
23016  | BIT_AND
23017  {{
23018 
23019  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
23020  if (p)
23021  p->info.name.original = $1;
23022  $$ = p;
23023  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23024 
23025  DBG_PRINT}}
23026  | BIT_OR
23027  {{
23028 
23029  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
23030  if (p)
23031  p->info.name.original = $1;
23032  $$ = p;
23033  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23034 
23035  DBG_PRINT}}
23036  | BIT_XOR
23037  {{
23038 
23039  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
23040  if (p)
23041  p->info.name.original = $1;
23042  $$ = p;
23043  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23044 
23045  DBG_PRINT}}
23046  | BUFFER
23047  {{
23048 
23049  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
23050  if (p)
23051  p->info.name.original = $1;
23052  $$ = p;
23053  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23054 
23055  DBG_PRINT}}
23056  | DATE_ADD
23057  {{
23058 
23059  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
23060  if (p)
23061  p->info.name.original = $1;
23062  $$ = p;
23063  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23064 
23065  DBG_PRINT}}
23066  | DATE_SUB
23067  {{
23068 
23069  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
23070  if (p)
23071  p->info.name.original = $1;
23072  $$ = p;
23073  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23074 
23075  DBG_PRINT}}
23076  | IFNULL
23077  {{
23078 
23079  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
23080  if (p)
23081  p->info.name.original = $1;
23082  $$ = p;
23083  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23084 
23085  DBG_PRINT}}
23086  | ISNULL
23087  {{
23088 
23089  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
23090  if (p)
23091  p->info.name.original = $1;
23092  $$ = p;
23093  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23094 
23095  DBG_PRINT}}
23096  | LCASE
23097  {{
23098 
23099  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
23100  if (p)
23101  p->info.name.original = $1;
23102  $$ = p;
23103  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23104 
23105  DBG_PRINT}}
23106  | QUARTER
23107  {{
23108 
23109  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
23110  if (p)
23111  p->info.name.original = $1;
23112  $$ = p;
23113  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23114 
23115  DBG_PRINT}}
23116  | STR_TO_DATE
23117  {{
23118 
23119  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
23120  if (p)
23121  p->info.name.original = $1;
23122  $$ = p;
23123  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23124 
23125  DBG_PRINT}}
23126  | SUBDATE
23127  {{
23128 
23129  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
23130  if (p)
23131  p->info.name.original = $1;
23132  $$ = p;
23133  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23134 
23135  DBG_PRINT}}
23136  | UCASE
23137  {{
23138 
23139  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
23140  if (p)
23141  p->info.name.original = $1;
23142  $$ = p;
23143  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23144 
23145  DBG_PRINT}}
23146  | WEEK
23147  {{
23148 
23149  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
23150  if (p)
23151  p->info.name.original = $1;
23152  $$ = p;
23153  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23154 
23155  DBG_PRINT}}
23156 /*}}}*/
23157  | NTILE
23158  {{
23159 
23160  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
23161  if (p != NULL)
23162  {
23163  p->info.name.original = $1;
23164  }
23165 
23166  $$ = p;
23167  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23168 
23169  DBG_PRINT}}
23170  | FIRST_VALUE
23171  {{
23172 
23173  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
23174  if (p != NULL)
23175  {
23176  p->info.name.original = $1;
23177  }
23178 
23179  $$ = p;
23180  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23181 
23182  DBG_PRINT}}
23183  | LAST_VALUE
23184  {{
23185 
23186  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
23187  if (p != NULL)
23188  {
23189  p->info.name.original = $1;
23190  }
23191 
23192  $$ = p;
23193  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23194 
23195  DBG_PRINT}}
23196  | NTH_VALUE
23197  {{
23198 
23199  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
23200  if (p != NULL)
23201  {
23202  p->info.name.original = $1;
23203  }
23204 
23205  $$ = p;
23206  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23207 
23208  DBG_PRINT}}
23209  | RESPECT
23210  {{
23211 
23212  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
23213  if (p != NULL)
23214  {
23215  p->info.name.original = $1;
23216  }
23217 
23218  $$ = p;
23219  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23220 
23221  DBG_PRINT}}
23222  | NULLS
23223  {{
23224 
23225  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
23226  if (p != NULL)
23227  {
23228  p->info.name.original = $1;
23229  }
23230 
23231  $$ = p;
23232  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23233 
23234  DBG_PRINT}}
23235  | MEDIAN
23236  {{
23237 
23238  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
23239  if (p != NULL)
23240  {
23241  p->info.name.original = $1;
23242  }
23243 
23244  $$ = p;
23245  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23246 
23247  DBG_PRINT}}
23248  | PERCENTILE_CONT
23249  {{
23250 
23251  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
23252  if (p != NULL)
23253  {
23254  p->info.name.original = $1;
23255  }
23256 
23257  $$ = p;
23258  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23259 
23260  DBG_PRINT}}
23261  | PERCENTILE_DISC
23262  {{
23263 
23264  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
23265  if (p != NULL)
23266  {
23267  p->info.name.original = $1;
23268  }
23269 
23270  $$ = p;
23271  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23272 
23273  DBG_PRINT}}
23274  | WITHIN
23275  {{
23276 
23277  PT_NODE *p = parser_new_node (this_parser, PT_NAME);
23278  if (p != NULL)
23279  {
23280  p->info.name.original = $1;
23281  }
23282 
23283  $$ = p;
23284  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23285 
23286  DBG_PRINT}}
23287  ;
23288 
23289 escape_literal
23290  : string_literal_or_input_hv
23291  {{
23292 
23293  PT_NODE *node = $1;
23294  $$ = node;
23295  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23296 
23297  DBG_PRINT}}
23298  | Null
23299  {{
23300 
23301  PT_NODE *node = parser_new_node (this_parser, PT_VALUE);
23302  if (node)
23303  node->type_enum = PT_TYPE_NULL;
23304  $$ = node;
23305  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23306 
23307  DBG_PRINT}}
23308  ;
23309 
23310 string_literal_or_input_hv
23311  : char_string_literal
23312  {{
23313 
23314  PT_NODE *node = $1;
23315 
23316  pt_value_set_collation_info (this_parser, node, NULL);
23317 
23318  $$ = node;
23319  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23320 
23321  DBG_PRINT}}
23322  | host_param_input
23323  {{
23324 
23325  $$ = $1;
23326  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23327 
23328  DBG_PRINT}}
23329  ;
23330 
23331 
23332 char_string_literal
23333  : char_string_literal CHAR_STRING
23334  {{
23335 
23336  PT_NODE *str = $1;
23337  if (str)
23338  {
23339  str->info.value.data_value.str =
23340  pt_append_bytes (this_parser, str->info.value.data_value.str, $2,
23341  strlen ($2));
23342  str->info.value.text = NULL;
23343  PT_NODE_PRINT_VALUE_TO_TEXT (this_parser, str);
23344  }
23345 
23346  $$ = str;
23347  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23348 
23349  DBG_PRINT}}
23350  | char_string
23351  {{
23352 
23353  $$ = $1;
23354  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23355 
23356  DBG_PRINT}}
23357  ;
23358 
23359 char_string
23360  : CHAR_STRING
23361  {{
23362 
23363  PT_NODE *node = NULL;
23364  PT_TYPE_ENUM typ = PT_TYPE_CHAR;
23365  INTL_CODESET charset;
23366  int collation_id;
23367  bool force;
23368 
23369  if (lang_get_parser_use_client_charset ())
23370  {
23371  charset = lang_get_client_charset ();
23372  collation_id = lang_get_client_collation ();
23373  force = false;
23374  }
23375  else
23376  {
23377  charset = LANG_SYS_CODESET;
23378  collation_id = LANG_SYS_COLLATION;
23379  force = true;
23380  }
23381 
23382  node = pt_create_char_string_literal (this_parser,
23383  PT_TYPE_CHAR,
23384  $1, charset);
23385 
23386  if (node)
23387  {
23388  pt_value_set_charset_coll (this_parser, node,
23389  charset, collation_id,
23390  force);
23391  node->info.value.has_cs_introducer = force;
23392  }
23393 
23394  $$ = node;
23395  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23396 
23397  DBG_PRINT}}
23398  | NCHAR_STRING
23399  {{
23400  PT_NODE *node = NULL;
23401  INTL_CODESET charset;
23402  int collation_id;
23403  bool force;
23404 
23405  if (lang_get_parser_use_client_charset ())
23406  {
23407  charset = lang_get_client_charset ();
23408  collation_id = lang_get_client_collation ();
23409  force = false;
23410  }
23411  else
23412  {
23413  charset = LANG_SYS_CODESET;
23414  collation_id = LANG_SYS_COLLATION;
23415  force = true;
23416  }
23417 
23418  node = pt_create_char_string_literal (this_parser,
23419  PT_TYPE_NCHAR,
23420  $1, charset);
23421 
23422  if (node && lang_get_parser_use_client_charset ())
23423  {
23424  pt_value_set_charset_coll (this_parser, node,
23425  charset, collation_id,
23426  force);
23427  node->info.value.has_cs_introducer = force;
23428  }
23429 
23430  $$ = node;
23431  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23432 
23433  DBG_PRINT}}
23434  | BINARY_STRING
23435  {{
23436 
23437  PT_NODE *node = NULL;
23438 
23439  node = pt_create_char_string_literal (this_parser, PT_TYPE_CHAR,
23440  $1, INTL_CODESET_RAW_BYTES);
23441 
23442  if (node)
23443  {
23444  pt_value_set_charset_coll (this_parser, node,
23445  INTL_CODESET_RAW_BYTES,
23446  LANG_COLL_BINARY,
23447  true);
23448  node->info.value.has_cs_introducer = true;
23449  }
23450 
23451  $$ = node;
23452  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23453 
23454  DBG_PRINT}}
23455  | EUCKR_STRING
23456  {{
23457 
23458  PT_NODE *node = NULL;
23459 
23460  node = pt_create_char_string_literal (this_parser, PT_TYPE_CHAR,
23461  $1, INTL_CODESET_KSC5601_EUC);
23462 
23463  if (node)
23464  {
23465  pt_value_set_charset_coll (this_parser, node,
23466  INTL_CODESET_KSC5601_EUC,
23467  LANG_COLL_EUCKR_BINARY,
23468  true);
23469  node->info.value.has_cs_introducer = true;
23470  }
23471 
23472  $$ = node;
23473  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23474 
23475  DBG_PRINT}}
23476  | ISO_STRING
23477  {{
23478 
23479  PT_NODE *node = NULL;
23480 
23481  node = pt_create_char_string_literal (this_parser, PT_TYPE_CHAR,
23482  $1, INTL_CODESET_ISO88591);
23483 
23484  if (node)
23485  {
23486  pt_value_set_charset_coll (this_parser, node,
23487  INTL_CODESET_ISO88591,
23488  LANG_COLL_ISO_BINARY,
23489  true);
23490  node->info.value.has_cs_introducer = true;
23491  }
23492 
23493  $$ = node;
23494  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23495 
23496  DBG_PRINT}}
23497  | UTF8_STRING
23498  {{
23499 
23500  PT_NODE *node = NULL;
23501 
23502  node = pt_create_char_string_literal (this_parser, PT_TYPE_CHAR,
23503  $1, INTL_CODESET_UTF8);
23504 
23505  if (node)
23506  {
23507  pt_value_set_charset_coll (this_parser, node,
23508  INTL_CODESET_UTF8,
23509  LANG_COLL_UTF8_BINARY,
23510  true);
23511  node->info.value.has_cs_introducer = true;
23512  }
23513 
23514  $$ = node;
23515  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23516 
23517  DBG_PRINT}}
23518  ;
23519 
23520 
23521 bit_string_literal
23522  : bit_string_literal CHAR_STRING
23523  {{
23524 
23525  PT_NODE *str = $1;
23526  if (str)
23527  {
23528  str->info.value.data_value.str =
23529  pt_append_bytes (this_parser, str->info.value.data_value.str, $2,
23530  strlen ($2));
23531  str->info.value.text = NULL;
23532  PT_NODE_PRINT_VALUE_TO_TEXT (this_parser, str);
23533  }
23534 
23535  $$ = str;
23536  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23537 
23538  DBG_PRINT}}
23539  | bit_string
23540  {{
23541 
23542  $$ = $1;
23543  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23544 
23545  DBG_PRINT}}
23546  ;
23547 
23548 bit_string
23549  : BIT_STRING
23550  {{
23551 
23552  PT_NODE *node = parser_new_node (this_parser, PT_VALUE);
23553 
23554  if (node)
23555  {
23556  node->type_enum = PT_TYPE_BIT;
23557  node->info.value.string_type = 'B';
23558  node->info.value.data_value.str =
23559  pt_append_bytes (this_parser, NULL, $1, strlen ($1));
23560  PT_NODE_PRINT_VALUE_TO_TEXT (this_parser, node);
23561  }
23562 
23563  $$ = node;
23564  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23565 
23566  DBG_PRINT}}
23567  | HEX_STRING
23568  {{
23569 
23570  PT_NODE *node = parser_new_node (this_parser, PT_VALUE);
23571 
23572  if (node)
23573  {
23574  node->type_enum = PT_TYPE_BIT;
23575  node->info.value.string_type = 'X';
23576  node->info.value.data_value.str =
23577  pt_append_bytes (this_parser, NULL, $1, strlen ($1));
23578  PT_NODE_PRINT_VALUE_TO_TEXT (this_parser, node);
23579  }
23580 
23581  $$ = node;
23582  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23583 
23584  DBG_PRINT}}
23585  ;
23586 
23587 unsigned_integer
23588  : UNSIGNED_INTEGER
23589  {{
23590 
23591  PT_NODE *val = parser_new_node (this_parser, PT_VALUE);
23592  if (val)
23593  {
23594  val->info.value.text = $1;
23595 
23596  if ((strlen (val->info.value.text) <= 9) ||
23597  (strlen (val->info.value.text) == 10 &&
23598  (val->info.value.text[0] == '0' || val->info.value.text[0] == '1')))
23599  {
23600  val->info.value.data_value.i = atol ($1);
23601  val->type_enum = PT_TYPE_INTEGER;
23602  }
23603  else if ((strlen (val->info.value.text) <= 18) ||
23604  (strlen (val->info.value.text) == 19 &&
23605  (val->info.value.text[0] >= '0' &&
23606  val->info.value.text[0] <= '8')))
23607  {
23608  val->info.value.data_value.bigint = atoll ($1);
23609  val->type_enum = PT_TYPE_BIGINT;
23610  }
23611  else
23612  {
23613  const char *max_big_int = "9223372036854775807";
23614 
23615  if ((strlen (val->info.value.text) == 19) &&
23616  (strcmp (val->info.value.text, max_big_int) <= 0))
23617  {
23618  val->info.value.data_value.bigint = atoll ($1);
23619  val->type_enum = PT_TYPE_BIGINT;
23620  }
23621  else
23622  {
23623  val->type_enum = PT_TYPE_NUMERIC;
23624  val->info.value.data_value.str =
23625  pt_append_bytes (this_parser, NULL,
23626  val->info.value.text,
23627  strlen (val->info.
23628  value.text));
23629  }
23630  }
23631  }
23632 
23633  $$ = val;
23634  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23635 
23636  DBG_PRINT}}
23637  ;
23638 
23639 unsigned_int32
23640  : UNSIGNED_INTEGER
23641  {{
23642 
23643  PT_NODE *val;
23644  int result = 0;
23645  int int_val;
23646 
23647  val = parser_new_node (this_parser, PT_VALUE);
23648  if (val)
23649  {
23650  result = parse_int (&int_val, $1, 10);
23651  if (result != 0)
23652  {
23653  PT_ERRORmf (this_parser, val, MSGCAT_SET_PARSER_SYNTAX,
23654  MSGCAT_SYNTAX_INVALID_UNSIGNED_INT32, $1);
23655  }
23656 
23657  val->info.value.data_value.i = int_val;
23658  val->type_enum = PT_TYPE_INTEGER;
23659  }
23660  $$ = val;
23661  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23662 
23663  DBG_PRINT}}
23664  ;
23665 
23666 unsigned_real
23667  : UNSIGNED_REAL
23668  {{
23669 
23670  double dval;
23671  PT_NODE *val = parser_new_node (this_parser, PT_VALUE);
23672  if (val)
23673  {
23674 
23675  if (strchr ($1, 'E') != NULL || strchr ($1, 'e') != NULL)
23676  {
23677 
23678  errno = 0;
23679  dval = strtod ($1, NULL);
23680  if (errno == ERANGE)
23681  {
23682  PT_ERRORmf2 (this_parser, val, MSGCAT_SET_PARSER_SYNTAX,
23683  MSGCAT_SYNTAX_FLT_DBL_OVERFLOW, $1, pt_show_type_enum (PT_TYPE_DOUBLE));
23684  }
23685  val->info.value.text = $1;
23686  val->type_enum = PT_TYPE_DOUBLE;
23687  val->info.value.data_value.d = dval;
23688  }
23689  else if (strchr ($1, 'F') != NULL || strchr ($1, 'f') != NULL)
23690  {
23691 
23692  errno = 0;
23693  dval = strtod ($1, NULL);
23694  if (errno == ERANGE || (dval > FLT_MAX || dval < FLT_MIN))
23695  {
23696  PT_ERRORmf2 (this_parser, val, MSGCAT_SET_PARSER_SYNTAX,
23697  MSGCAT_SYNTAX_FLT_DBL_OVERFLOW, $1, pt_show_type_enum (PT_TYPE_FLOAT));
23698  }
23699  val->info.value.text = $1;
23700  val->type_enum = PT_TYPE_FLOAT;
23701  val->info.value.data_value.f = (float) dval;
23702  }
23703  else
23704  {
23705  val->info.value.text = $1;
23706  val->type_enum = PT_TYPE_NUMERIC;
23707  val->info.value.data_value.str =
23708  pt_append_bytes (this_parser, NULL,
23709  val->info.value.text,
23710  strlen (val->info.value.
23711  text));
23712  }
23713  }
23714 
23715  $$ = val;
23716  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23717 
23718  DBG_PRINT}}
23719  ;
23720 
23721 monetary_literal
23722  : YEN_SIGN of_integer_real_literal
23723  {{
23724 
23725  char *str, *txt;
23726  PT_NODE *val = parser_new_node (this_parser, PT_VALUE);
23727 
23728  str = pt_append_string (this_parser, NULL, YEN_SIGN_TEXT);
23729  txt = $2;
23730 
23731  if (val)
23732  {
23733  pt_value_set_monetary (this_parser, val, str, txt, PT_CURRENCY_YEN);
23734  }
23735 
23736  $$ = val;
23737  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23738 
23739  DBG_PRINT}}
23740  | DOLLAR_SIGN of_integer_real_literal
23741  {{
23742 
23743  char *str, *txt;
23744  PT_NODE *val = parser_new_node (this_parser, PT_VALUE);
23745 
23746  str = pt_append_string (this_parser, NULL, DOLLAR_SIGN_TEXT);
23747  txt = $2;
23748 
23749  if (val)
23750  {
23751  pt_value_set_monetary (this_parser, val, str, txt, PT_CURRENCY_DOLLAR);
23752  }
23753 
23754  $$ = val;
23755  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23756 
23757  DBG_PRINT}}
23758  | WON_SIGN of_integer_real_literal
23759  {{
23760 
23761  char *str, *txt;
23762  PT_NODE *val = parser_new_node (this_parser, PT_VALUE);
23763 
23764  str = pt_append_string (this_parser, NULL, WON_SIGN_TEXT);
23765  txt = $2;
23766 
23767  if (val)
23768  {
23769  pt_value_set_monetary (this_parser, val, str, txt, PT_CURRENCY_WON);
23770  }
23771 
23772  $$ = val;
23773  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23774 
23775  DBG_PRINT}}
23776  | TURKISH_LIRA_SIGN of_integer_real_literal
23777  {{
23778 
23779  char *str, *txt;
23780  PT_NODE *val = parser_new_node (this_parser, PT_VALUE);
23781 
23782  str = pt_append_string (this_parser, NULL, TURKISH_LIRA_TEXT);
23783  txt = $2;
23784 
23785  if (val)
23786  {
23787  pt_value_set_monetary (this_parser, val, str, txt, PT_CURRENCY_TL);
23788  }
23789 
23790  $$ = val;
23791  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
23792 
23793  DBG_PRINT}}
23794  | BRITISH_POUND_SIGN of_integer_real_literal
23795  {{
23796 
23797  char *str, *txt;
23798  PT_NODE *val = parser_new_node (this_parser, PT_VALUE);
23799 
23800  str = pt_append_string (this_parser, NULL, BRITISH_POUND_TEXT);
23801  txt = $2;
23802 
23803  if (val)
23804  {
23805  pt_value_set_monetary (this_parser, val, str, txt, PT_CURRENCY_BRITISH_POUND);
23806  }
23807 
23808  $$ = val;
23809 
23810  DBG_PRINT}}
23811  | CAMBODIAN_RIEL_SIGN of_integer_real_literal
23812  {{
23813 
23814  char *str, *txt;
23815  PT_NODE *val = parser_new_node (this_parser, PT_VALUE);
23816 
23817  str = pt_append_string (this_parser, NULL, CAMBODIAN_RIEL_TEXT);
23818  txt = $2;
23819 
23820  if (val)
23821  {
23822  pt_value_set_monetary (this_parser, val, str, txt, PT_CURRENCY_CAMBODIAN_RIEL);
23823  }
23824 
23825  $$ = val;
23826 
23827  DBG_PRINT}}
23828  | CHINESE_RENMINBI_SIGN of_integer_real_literal
23829  {{
23830 
23831  char *str, *txt;
23832  PT_NODE *val = parser_new_node (this_parser, PT_VALUE);
23833 
23834  str = pt_append_string (this_parser, NULL, CHINESE_RENMINBI_TEXT);
23835  txt = $2;
23836 
23837  if (val)
23838  {
23839  pt_value_set_monetary (this_parser, val, str, txt, PT_CURRENCY_CHINESE_RENMINBI);
23840  }
23841 
23842  $$ = val;
23843 
23844  DBG_PRINT}}
23845  | INDIAN_RUPEE_SIGN of_integer_real_literal
23846  {{
23847 
23848  char *str, *txt;
23849  PT_NODE *val = parser_new_node (this_parser, PT_VALUE);
23850 
23851  str = pt_append_string (this_parser, NULL, INDIAN_RUPEE_TEXT);
23852  txt = $2;
23853 
23854  if (val)
23855  {
23856  pt_value_set_monetary (this_parser, val, str, txt, PT_CURRENCY_INDIAN_RUPEE);
23857  }
23858 
23859  $$ = val;
23860 
23861  DBG_PRINT}}
23862  | RUSSIAN_RUBLE_SIGN of_integer_real_literal
23863  {{
23864 
23865  char *str, *txt;
23866  PT_NODE *val = parser_new_node (this_parser, PT_VALUE);
23867 
23868  str = pt_append_string (this_parser, NULL, RUSSIAN_RUBLE_TEXT);
23869  txt = $2;
23870 
23871  if (val)
23872  {
23873  pt_value_set_monetary (this_parser, val, str, txt, PT_CURRENCY_RUSSIAN_RUBLE);
23874  }
23875 
23876  $$ = val;
23877 
23878  DBG_PRINT}}
23879  | AUSTRALIAN_DOLLAR_SIGN of_integer_real_literal
23880  {{
23881 
23882  char *str, *txt;
23883  PT_NODE *val = parser_new_node (this_parser, PT_VALUE);
23884 
23885  str = pt_append_string (this_parser, NULL, AUSTRALIAN_DOLLAR_TEXT);
23886  txt = $2;
23887 
23888  if (val)
23889  {
23890  pt_value_set_monetary (this_parser, val, str, txt, PT_CURRENCY_AUSTRALIAN_DOLLAR);
23891  }
23892 
23893  $$ = val;
23894 
23895  DBG_PRINT}}
23896  | CANADIAN_DOLLAR_SIGN of_integer_real_literal
23897  {{
23898 
23899  char *str, *txt;
23900  PT_NODE *val = parser_new_node (this_parser, PT_VALUE);
23901 
23902  str = pt_append_string (this_parser, NULL, CANADIAN_DOLLAR_TEXT);
23903  txt = $2;
23904 
23905  if (val)
23906  {
23907  pt_value_set_monetary (this_parser, val, str, txt, PT_CURRENCY_CANADIAN_DOLLAR);
23908  }
23909 
23910  $$ = val;
23911 
23912  DBG_PRINT}}
23913  | BRASILIAN_REAL_SIGN of_integer_real_literal
23914  {{
23915 
23916  char *str, *txt;
23917  PT_NODE *val = parser_new_node (this_parser, PT_VALUE);
23918 
23919  str = pt_append_string (this_parser, NULL, BRASILIAN_REAL_TEXT);
23920  txt = $2;
23921 
23922  if (val)
23923  {
23924  pt_value_set_monetary (this_parser, val, str, txt, PT_CURRENCY_BRASILIAN_REAL);
23925  }
23926 
23927  $$ = val;
23928 
23929  DBG_PRINT}}
23930  | ROMANIAN_LEU_SIGN of_integer_real_literal
23931  {{
23932 
23933  char *str, *txt;
23934  PT_NODE *val = parser_new_node (this_parser, PT_VALUE);
23935 
23936  str = pt_append_string (this_parser, NULL, ROMANIAN_LEU_TEXT);
23937  txt = $2;
23938 
23939  if (val)
23940  {
23941  pt_value_set_monetary (this_parser, val, str, txt, PT_CURRENCY_ROMANIAN_LEU);
23942  }
23943 
23944  $$ = val;
23945 
23946  DBG_PRINT}}
23947  | EURO_SIGN of_integer_real_literal
23948  {{
23949 
23950  char *str, *txt;
23951  PT_NODE *val = parser_new_node (this_parser, PT_VALUE);
23952 
23953  str = pt_append_string (this_parser, NULL, EURO_TEXT);
23954  txt = $2;
23955 
23956  if (val)
23957  {
23958  pt_value_set_monetary (this_parser, val, str, txt, PT_CURRENCY_EURO);
23959  }
23960 
23961  $$ = val;
23962 
23963  DBG_PRINT}}
23964  | SWISS_FRANC_SIGN of_integer_real_literal
23965  {{
23966 
23967  char *str, *txt;
23968  PT_NODE *val = parser_new_node (this_parser, PT_VALUE);
23969 
23970  str = pt_append_string (this_parser, NULL, SWISS_FRANC_TEXT);
23971  txt = $2;
23972 
23973  if (val)
23974  {
23975  pt_value_set_monetary (this_parser, val, str, txt, PT_CURRENCY_SWISS_FRANC);
23976  }
23977 
23978  $$ = val;
23979 
23980  DBG_PRINT}}
23981  | DANISH_KRONE_SIGN of_integer_real_literal
23982  {{
23983 
23984  char *str, *txt;
23985  PT_NODE *val = parser_new_node (this_parser, PT_VALUE);
23986 
23987  str = pt_append_string (this_parser, NULL, DANISH_KRONE_TEXT);
23988  txt = $2;
23989 
23990  if (val)
23991  {
23992  pt_value_set_monetary (this_parser, val, str, txt, PT_CURRENCY_DANISH_KRONE);
23993  }
23994 
23995  $$ = val;
23996 
23997  DBG_PRINT}}
23998  | NORWEGIAN_KRONE_SIGN of_integer_real_literal
23999  {{
24000 
24001  char *str, *txt;
24002  PT_NODE *val = parser_new_node (this_parser, PT_VALUE);
24003 
24004  str = pt_append_string (this_parser, NULL, NORWEGIAN_KRONE_TEXT);
24005  txt = $2;
24006 
24007  if (val)
24008  {
24009  pt_value_set_monetary (this_parser, val, str, txt, PT_CURRENCY_NORWEGIAN_KRONE);
24010  }
24011 
24012  $$ = val;
24013 
24014  DBG_PRINT}}
24015  | BULGARIAN_LEV_SIGN of_integer_real_literal
24016  {{
24017 
24018  char *str, *txt;
24019  PT_NODE *val = parser_new_node (this_parser, PT_VALUE);
24020 
24021  str = pt_append_string (this_parser, NULL, BULGARIAN_LEV_TEXT);
24022  txt = $2;
24023 
24024  if (val)
24025  {
24026  pt_value_set_monetary (this_parser, val, str, txt, PT_CURRENCY_BULGARIAN_LEV);
24027  }
24028 
24029  $$ = val;
24030 
24031  DBG_PRINT}}
24032  | VIETNAMESE_DONG_SIGN of_integer_real_literal
24033  {{
24034 
24035  char *str, *txt;
24036  PT_NODE *val = parser_new_node (this_parser, PT_VALUE);
24037 
24038  str = pt_append_string (this_parser, NULL, VIETNAMESE_DONG_TEXT);
24039  txt = $2;
24040 
24041  if (val)
24042  {
24043  pt_value_set_monetary (this_parser, val, str, txt, PT_CURRENCY_VIETNAMESE_DONG);
24044  }
24045 
24046  $$ = val;
24047 
24048  DBG_PRINT}}
24049  | CZECH_KORUNA_SIGN of_integer_real_literal
24050  {{
24051 
24052  char *str, *txt;
24053  PT_NODE *val = parser_new_node (this_parser, PT_VALUE);
24054 
24055  str = pt_append_string (this_parser, NULL, CZECH_KORUNA_TEXT);
24056  txt = $2;
24057 
24058  if (val)
24059  {
24060  pt_value_set_monetary (this_parser, val, str, txt, PT_CURRENCY_CZECH_KORUNA);
24061  }
24062 
24063  $$ = val;
24064 
24065  DBG_PRINT}}
24066  | POLISH_ZLOTY_SIGN of_integer_real_literal
24067  {{
24068 
24069  char *str, *txt;
24070  PT_NODE *val = parser_new_node (this_parser, PT_VALUE);
24071 
24072  str = pt_append_string (this_parser, NULL, POLISH_ZLOTY_TEXT);
24073  txt = $2;
24074 
24075  if (val)
24076  {
24077  pt_value_set_monetary (this_parser, val, str, txt, PT_CURRENCY_POLISH_ZLOTY);
24078  }
24079 
24080  $$ = val;
24081 
24082  DBG_PRINT}}
24083  | SWEDISH_KRONA_SIGN of_integer_real_literal
24084  {{
24085 
24086  char *str, *txt;
24087  PT_NODE *val = parser_new_node (this_parser, PT_VALUE);
24088 
24089  str = pt_append_string (this_parser, NULL, SWEDISH_KRONA_TEXT);
24090  txt = $2;
24091 
24092  if (val)
24093  {
24094  pt_value_set_monetary (this_parser, val, str, txt, PT_CURRENCY_SWEDISH_KRONA);
24095  }
24096 
24097  $$ = val;
24098 
24099  DBG_PRINT}}
24100  | CROATIAN_KUNA_SIGN of_integer_real_literal
24101  {{
24102 
24103  char *str, *txt;
24104  PT_NODE *val = parser_new_node (this_parser, PT_VALUE);
24105 
24106  str = pt_append_string (this_parser, NULL, CROATIAN_KUNA_TEXT);
24107  txt = $2;
24108 
24109  if (val)
24110  {
24111  pt_value_set_monetary (this_parser, val, str, txt, PT_CURRENCY_CROATIAN_KUNA);
24112  }
24113 
24114  $$ = val;
24115 
24116  DBG_PRINT}}
24117  | SERBIAN_DINAR_SIGN of_integer_real_literal
24118  {{
24119 
24120  char *str, *txt;
24121  PT_NODE *val = parser_new_node (this_parser, PT_VALUE);
24122 
24123  str = pt_append_string (this_parser, NULL, SERBIAN_DINAR_TEXT);
24124  txt = $2;
24125 
24126  if (val)
24127  {
24128  pt_value_set_monetary (this_parser, val, str, txt, PT_CURRENCY_SERBIAN_DINAR);
24129  }
24130 
24131  $$ = val;
24132 
24133  DBG_PRINT}}
24134  ;
24135 
24136 of_integer_real_literal
24137  : integer_text
24138  {{
24139 
24140  $$ = $1;
24141 
24142  DBG_PRINT}}
24143  | opt_plus UNSIGNED_REAL
24144  {{
24145 
24146  $$ = $2;
24147 
24148  DBG_PRINT}}
24149  | '-' UNSIGNED_REAL
24150  {{
24151 
24152  $$ = pt_append_string (this_parser, (char *) "-", $2);
24153 
24154  DBG_PRINT}}
24155  ;
24156 
24157 date_or_time_literal
24158  : Date CHAR_STRING
24159  {{
24160 
24161  PT_NODE *val;
24162  val = pt_create_date_value (this_parser, PT_TYPE_DATE, $2);
24163  $$ = val;
24164  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
24165 
24166  DBG_PRINT}}
24167  | Time CHAR_STRING
24168  {{
24169 
24170  PT_NODE *val;
24171  val = pt_create_date_value (this_parser, PT_TYPE_TIME, $2);
24172  $$ = val;
24173  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
24174 
24175  DBG_PRINT}}
24176  | TIMESTAMP CHAR_STRING
24177  {{
24178 
24179  PT_NODE *val;
24180  val = pt_create_date_value (this_parser, PT_TYPE_TIMESTAMP, $2);
24181  $$ = val;
24182  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
24183 
24184  DBG_PRINT}}
24185  | TIMESTAMP WITH Time ZONE CHAR_STRING
24186  {{
24187 
24188  PT_NODE *val;
24189  val = pt_create_date_value (this_parser, PT_TYPE_TIMESTAMPTZ, $5);
24190  $$ = val;
24191  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
24192 
24193  DBG_PRINT}}
24194  | TIMESTAMPTZ CHAR_STRING
24195  {{
24196 
24197  PT_NODE *val;
24198  val = pt_create_date_value (this_parser, PT_TYPE_TIMESTAMPTZ, $2);
24199  $$ = val;
24200  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
24201 
24202  DBG_PRINT}}
24203  | TIMESTAMPLTZ CHAR_STRING
24204  {{
24205 
24206  PT_NODE *val;
24207  val = pt_create_date_value (this_parser, PT_TYPE_TIMESTAMPLTZ, $2);
24208  $$ = val;
24209  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
24210 
24211  DBG_PRINT}}
24212  | TIMESTAMP WITH LOCAL Time ZONE CHAR_STRING
24213  {{
24214 
24215  PT_NODE *val;
24216  val = pt_create_date_value (this_parser, PT_TYPE_TIMESTAMPLTZ, $6);
24217  $$ = val;
24218  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
24219 
24220  DBG_PRINT}}
24221  | DATETIME CHAR_STRING
24222  {{
24223 
24224  PT_NODE *val;
24225  val = pt_create_date_value (this_parser, PT_TYPE_DATETIME, $2);
24226  $$ = val;
24227  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
24228 
24229  DBG_PRINT}}
24230  | DATETIME WITH Time ZONE CHAR_STRING
24231  {{
24232 
24233  PT_NODE *val;
24234  val = pt_create_date_value (this_parser, PT_TYPE_DATETIMETZ, $5);
24235  $$ = val;
24236  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
24237 
24238  DBG_PRINT}}
24239  | DATETIMETZ CHAR_STRING
24240  {{
24241 
24242  PT_NODE *val;
24243  val = pt_create_date_value (this_parser, PT_TYPE_DATETIMETZ, $2);
24244  $$ = val;
24245  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
24246 
24247  DBG_PRINT}}
24248  | DATETIMELTZ CHAR_STRING
24249  {{
24250 
24251  PT_NODE *val;
24252  val = pt_create_date_value (this_parser, PT_TYPE_DATETIMELTZ, $2);
24253  $$ = val;
24254  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
24255 
24256  DBG_PRINT}}
24257  | DATETIME WITH LOCAL Time ZONE CHAR_STRING
24258  {{
24259 
24260  PT_NODE *val;
24261  val = pt_create_date_value (this_parser, PT_TYPE_DATETIMELTZ, $6);
24262  $$ = val;
24263  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
24264 
24265  DBG_PRINT}}
24266  ;
24267 
24268 json_literal
24269  : JSON CHAR_STRING
24270  {{
24271  PT_NODE *val;
24272  val = pt_create_json_value (this_parser, $2);
24273  $$ = val;
24274  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
24275 
24276  DBG_PRINT}}
24277 
24278 create_as_clause
24279  : opt_replace AS csql_query
24280  {{
24281  container_2 ctn;
24282  SET_CONTAINER_2(ctn, FROM_NUMBER ($1), $3);
24283  $$ = ctn;
24284  DBG_PRINT}}
24285  ;
24286 
24287 partition_clause
24288  : PARTITION opt_by HASH '(' expression_ ')' PARTITIONS literal_w_o_param
24289  {{
24290 
24291  PT_NODE *qc = parser_new_node (this_parser, PT_PARTITION);
24292  if (qc)
24293  {
24294  qc->info.partition.expr = $5;
24295  qc->info.partition.type = PT_PARTITION_HASH;
24296  qc->info.partition.hashsize = $8;
24297  }
24298 
24299  $$ = qc;
24300 
24301  DBG_PRINT}}
24302  | PARTITION opt_by RANGE_ '(' expression_ ')' '(' partition_def_list ')'
24303  {{
24304 
24305  PT_NODE *qc = parser_new_node (this_parser, PT_PARTITION);
24306  if (qc)
24307  {
24308  qc->info.partition.expr = $5;
24309  qc->info.partition.type = PT_PARTITION_RANGE;
24310  qc->info.partition.parts = $8;
24311  qc->info.partition.hashsize = NULL;
24312  }
24313 
24314  $$ = qc;
24315  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
24316 
24317  DBG_PRINT}}
24318  | PARTITION opt_by LIST '(' expression_ ')' '(' partition_def_list ')'
24319  {{
24320 
24321  PT_NODE *qc = parser_new_node (this_parser, PT_PARTITION);
24322  if (qc)
24323  {
24324  qc->info.partition.expr = $5;
24325  qc->info.partition.type = PT_PARTITION_LIST;
24326  qc->info.partition.parts = $8;
24327  qc->info.partition.hashsize = NULL;
24328  }
24329 
24330  $$ = qc;
24331  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
24332 
24333  DBG_PRINT}}
24334  ;
24335 
24336 opt_by
24337  : /* empty */
24338  | BY
24339  ;
24340 
24341 partition_def_list
24342  : partition_def_list ',' partition_def
24343  {{
24344 
24345  $$ = parser_make_link ($1, $3);
24346  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
24347 
24348  DBG_PRINT}}
24349  | partition_def
24350  {{
24351 
24352  $$ = $1;
24353  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
24354 
24355  DBG_PRINT}}
24356  ;
24357 
24358 partition_def
24359  : PARTITION identifier VALUES LESS THAN MAXVALUE opt_comment_spec
24360  {{
24361 
24362  PT_NODE *node = parser_new_node (this_parser, PT_PARTS);
24363  if (node)
24364  {
24365  node->info.parts.name = $2;
24366  node->info.parts.type = PT_PARTITION_RANGE;
24367  node->info.parts.values = NULL;
24368  node->info.parts.comment = $7;
24369  }
24370 
24371  $$ = node;
24372  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
24373 
24374  DBG_PRINT}}
24375  | PARTITION identifier VALUES LESS THAN '(' signed_literal_ ')' opt_comment_spec
24376  {{
24377 
24378  PT_NODE *node = parser_new_node (this_parser, PT_PARTS);
24379  if (node)
24380  {
24381  node->info.parts.name = $2;
24382  node->info.parts.type = PT_PARTITION_RANGE;
24383  node->info.parts.values = $7;
24384  node->info.parts.comment = $9;
24385  }
24386 
24387  $$ = node;
24388  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
24389 
24390  DBG_PRINT}}
24391  | PARTITION identifier VALUES IN_ '(' signed_literal_list ')' opt_comment_spec
24392  {{
24393 
24394  PT_NODE *node = parser_new_node (this_parser, PT_PARTS);
24395  if (node)
24396  {
24397  node->info.parts.name = $2;
24398  node->info.parts.type = PT_PARTITION_LIST;
24399  node->info.parts.values = $6;
24400  node->info.parts.comment = $8;
24401  }
24402 
24403  $$ = node;
24404  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
24405 
24406  DBG_PRINT}}
24407  ;
24408 
24409 alter_partition_clause_for_alter_list
24410  : partition_clause
24411  {{
24412 
24413  PT_NODE *alt = parser_get_alter_node ();
24414 
24415  if (alt)
24416  {
24417  alt->info.alter.code = PT_APPLY_PARTITION;
24418  alt->info.alter.alter_clause.partition.info = $1;
24419  }
24420 
24421  DBG_PRINT}}
24422  | REMOVE PARTITIONING
24423  {{
24424 
24425  PT_NODE *alt = parser_get_alter_node ();
24426 
24427  if (alt)
24428  alt->info.alter.code = PT_REMOVE_PARTITION;
24429 
24430  DBG_PRINT}}
24431  | REORGANIZE PARTITION identifier_list INTO '(' partition_def_list ')'
24432  {{
24433 
24434  PT_NODE *alt = parser_get_alter_node ();
24435 
24436  if (alt)
24437  {
24438  alt->info.alter.code = PT_REORG_PARTITION;
24439  alt->info.alter.alter_clause.partition.name_list = $3;
24440  alt->info.alter.alter_clause.partition.parts = $6;
24441  }
24442 
24443  DBG_PRINT}}
24444  | ANALYZE PARTITION opt_all
24445  {{
24446 
24447  PT_NODE *alt = parser_get_alter_node ();
24448 
24449  if (alt)
24450  {
24451  alt->info.alter.code = PT_ANALYZE_PARTITION;
24452  alt->info.alter.alter_clause.partition.name_list = NULL;
24453  }
24454 
24455  DBG_PRINT}}
24456  | ANALYZE PARTITION identifier_list
24457  {{
24458 
24459  PT_NODE *alt = parser_get_alter_node ();
24460 
24461  if (alt)
24462  {
24463  alt->info.alter.code = PT_ANALYZE_PARTITION;
24464  alt->info.alter.alter_clause.partition.name_list = $3;
24465  }
24466 
24467  DBG_PRINT}}
24468  | COALESCE PARTITION literal_w_o_param
24469  {{
24470 
24471  PT_NODE *alt = parser_get_alter_node ();
24472 
24473  if (alt)
24474  {
24475  alt->info.alter.code = PT_COALESCE_PARTITION;
24476  alt->info.alter.alter_clause.partition.size = $3;
24477  }
24478 
24479  DBG_PRINT}}
24480  | PROMOTE PARTITION identifier_list
24481  {{
24482 
24483  PT_NODE *alt = parser_get_alter_node ();
24484 
24485  if (alt)
24486  {
24487  alt->info.alter.code = PT_PROMOTE_PARTITION;
24488  alt->info.alter.alter_clause.partition.name_list = $3;
24489  }
24490 
24491  DBG_PRINT}}
24492  ;
24493 
24494 opt_all
24495  : /* empty */
24496  | ALL
24497  ;
24498 
24499 execute_using_list
24500  : execute_using_list ',' session_variable_expression
24501  {{
24502 
24503  $$ = parser_make_link ($1, $3);
24504  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
24505 
24506  DBG_PRINT}}
24507  | execute_using_list ',' signed_literal_
24508  {{
24509 
24510  $$ = parser_make_link ($1, $3);
24511  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
24512 
24513  DBG_PRINT}}
24514  | session_variable_expression
24515  {{
24516 
24517  $$ = $1;
24518  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
24519 
24520  DBG_PRINT}}
24521  | signed_literal_
24522  {{
24523 
24524  $$ = $1;
24525  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
24526 
24527  DBG_PRINT}}
24528  ;
24529 
24530 signed_literal_list
24531  : signed_literal_list ',' signed_literal_
24532  {{
24533 
24534  $$ = parser_make_link ($1, $3);
24535  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
24536 
24537  DBG_PRINT}}
24538  | signed_literal_
24539  {{
24540 
24541  $$ = $1;
24542  PARSER_SAVE_ERR_CONTEXT ($$, @$.buffer_pos)
24543 
24544  DBG_PRINT}}
24545  ;
24546 
24547 paren_plus
24548  : '(' '+' ')'
24549  ;
24550 
24551 paren_minus
24552  : '(' '-' ')'
24553  ;
24554 
24555 
24556 bad_tokens_for_error_message_only_dont_mind_this_rule
24557  : '@'
24558  | ']'
24559  | '`'
24560  /*| '^'
24561  | '&'
24562  | '~'*/
24563  ;
24564 
24565 vacuum_stmt
24566  : VACUUM
24567  {{
24568  PT_NODE *node =
24569  parser_new_node (this_parser, PT_VACUUM);
24570  if (node == NULL)
24571  {
24572  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE,
24573  ER_OUT_OF_VIRTUAL_MEMORY, 1,
24574  sizeof (PT_NODE));
24575  }
24576  $$ = node;
24577  DBG_PRINT}}
24578  ;
24579 
24580 json_table_column_behavior_rule
24581  : Null
24582  {{
24583  $$.m_behavior = JSON_TABLE_RETURN_NULL;
24584  $$.m_default_value = NULL;
24585  DBG_PRINT}}
24586  | ERROR_
24587  {{
24588  $$.m_behavior = JSON_TABLE_THROW_ERROR;
24589  $$.m_default_value = NULL;
24590  DBG_PRINT}}
24591  | DEFAULT expression_
24592  {{
24593  PT_NODE * default_value = $2;
24594  if (default_value->node_type != PT_VALUE)
24595  {
24596  PT_ERROR (this_parser, default_value, "invalid JSON_TABLE default");
24597  }
24598  DB_VALUE * temp = pt_value_to_db (this_parser, default_value);
24599  $$.m_behavior = JSON_TABLE_DEFAULT_VALUE;
24600  $$.m_default_value = db_value_copy (temp);
24601 
24602  parser_free_node(this_parser, default_value);
24603  DBG_PRINT}}
24604  ;
24605 
24606 json_table_on_error_rule_optional
24607  : /* empty */
24608  {{
24609  $$.m_behavior = JSON_TABLE_RETURN_NULL;
24610  $$.m_default_value = NULL;
24611  DBG_PRINT}}
24612  | json_table_column_behavior_rule ON_ ERROR_
24613  {{
24614  $$ = $1;
24615  DBG_PRINT}}
24616  ;
24617 
24618 json_table_on_empty_rule_optional
24619  : /* empty */
24620  {{
24621  $$.m_behavior = JSON_TABLE_RETURN_NULL;
24622  $$.m_default_value = NULL;
24623  DBG_PRINT}}
24624  | json_table_column_behavior_rule ON_ EMPTY
24625  {{
24626  $$ = $1;
24627  DBG_PRINT}}
24628  ;
24629 
24630 json_table_column_rule
24631  : identifier For ORDINALITY
24632  {{
24633  PT_NODE *pt_col = parser_new_node (this_parser, PT_JSON_TABLE_COLUMN);
24634  pt_col->info.json_table_column_info.name = $1;
24635  pt_col->info.json_table_column_info.func = JSON_TABLE_ORDINALITY;
24636  pt_col->type_enum = PT_TYPE_INTEGER;
24637  $$ = pt_col;
24638  DBG_PRINT}}
24639  | identifier data_type PATH CHAR_STRING json_table_on_empty_rule_optional json_table_on_error_rule_optional
24640  // $1 $2 $3 $4 $5 $6
24641  {{
24642  PT_NODE *pt_col = parser_new_node (this_parser, PT_JSON_TABLE_COLUMN);
24643  pt_col->info.json_table_column_info.name = $1;
24644  pt_col->type_enum = TO_NUMBER (CONTAINER_AT_0 ($2));
24645  pt_col->data_type = CONTAINER_AT_1 ($2);
24646  pt_col->info.json_table_column_info.path=$4;
24647  pt_col->info.json_table_column_info.func = JSON_TABLE_EXTRACT;
24648  pt_col->info.json_table_column_info.on_empty = $5;
24649  pt_col->info.json_table_column_info.on_error = $6;
24650  $$ = pt_col;
24651  DBG_PRINT}}
24652  | identifier data_type EXISTS PATH CHAR_STRING
24653  {{
24654  PT_NODE *pt_col = parser_new_node (this_parser, PT_JSON_TABLE_COLUMN);
24655  pt_col->info.json_table_column_info.name = $1;
24656  pt_col->type_enum = TO_NUMBER (CONTAINER_AT_0 ($2));
24657  pt_col->data_type = CONTAINER_AT_1 ($2);
24658  pt_col->info.json_table_column_info.path=$5;
24659  pt_col->info.json_table_column_info.func = JSON_TABLE_EXISTS;
24660  $$ = pt_col;
24661  DBG_PRINT}}
24662  | NESTED json_table_node_rule
24663  {{
24664  $$ = $2;
24665  DBG_PRINT}}
24666  | NESTED PATH json_table_node_rule
24667  {{
24668  $$ = $3;
24669  DBG_PRINT}}
24670  ;
24671 
24672 json_table_column_list_rule
24673  : json_table_column_list_rule ',' json_table_column_rule
24674  {{
24675  pt_jt_append_column_or_nested_node ($1, $3);
24676  $$ = $1;
24677  DBG_PRINT}}
24678  | json_table_column_rule
24679  {{
24680  PT_NODE *pt_jt_node = parser_new_node (this_parser, PT_JSON_TABLE_NODE);
24681  pt_jt_append_column_or_nested_node (pt_jt_node, $1);
24682  $$ = pt_jt_node;
24683  DBG_PRINT}}
24684  ;
24685 
24686 json_table_node_rule
24687  : CHAR_STRING COLUMNS '(' json_table_column_list_rule ')'
24688  {{
24689  PT_NODE *jt_node = $4;
24690  assert (jt_node != NULL);
24691  assert (jt_node->node_type == PT_JSON_TABLE_NODE);
24692 
24693  jt_node->info.json_table_node_info.path = $1;
24694 
24695  $$ = jt_node;
24696  DBG_PRINT}}
24697  ;
24698 
24699 json_table_rule
24700  : {{json_table_column_count = 0;
24701  DBG_PRINT}}
24702  '(' expression_ ',' json_table_node_rule ')'
24703  {{
24704  PT_NODE *jt = parser_new_node (this_parser, PT_JSON_TABLE);
24705  jt->info.json_table_info.expr = $3;
24706  jt->info.json_table_info.tree = $5;
24707  json_table_column_count = 0; // reset for next json table, if I am nested
24708 
24709  $$ = jt;
24710  DBG_PRINT}}
24711  ;
24712 
24713 %%
24714 
24715 
24716 extern FILE *yyin;
24717 
24718 void
24719 _push_msg (int code, int line)
24720 {
24721  PRINT_2 ("push msg called: %d at line %d\n", code, line);
24722  g_msg[msg_ptr++] = code;
24723 }
24724 
24725 void
24726 pop_msg ()
24727 {
24728  msg_ptr--;
24729 }
24730 
24731 
24732 extern void csql_yyset_lineno (int line_number);
24733 int yycolumn = 0;
24734 int yycolumn_end = 0;
24735 int dot_flag = 0;
24736 
24737 int parser_function_code = PT_EMPTY;
24738 size_t json_table_column_count = 0;
24739 
24740 static PT_NODE *
24741 parser_make_expr_with_func (PARSER_CONTEXT * parser, FUNC_TYPE func_code,
24742  PT_NODE * args_list)
24743 {
24744  PT_NODE *node = NULL;
24745  PT_NODE *node_function = parser_new_node (parser, PT_FUNCTION);
24746 
24747  if (node_function != NULL)
24748  {
24749  node_function->info.function.function_type = func_code;
24750  node_function->info.function.arg_list = args_list;
24751 
24752  node =
24753  parser_make_expression (parser, PT_FUNCTION_HOLDER, node_function, NULL,
24754  NULL);
24755  }
24756 
24757  return node;
24758 }
24759 
24760 static PT_NODE *
24761 parser_make_func_with_arg_count (PARSER_CONTEXT * parser, FUNC_TYPE func_code, PT_NODE * args_list,
24762  size_t min_args, size_t max_args)
24763 {
24764  size_t count = (size_t) parser_count_list (args_list);
24765  if (min_args > count || (max_args != 0 && max_args < count))
24766  {
24767  // todo - a more clear message
24768  PT_ERRORmf (parser, args_list, MSGCAT_SET_PARSER_SEMANTIC, MSGCAT_SEMANTIC_INVALID_INTERNAL_FUNCTION,
24769  fcode_get_lowercase_name (func_code));
24770  // todo - return null?
24771  }
24772  return parser_make_expr_with_func (parser, func_code, args_list);
24773 }
24774 
24775 static PT_NODE *
24776 parser_make_func_with_arg_count_mod2 (PARSER_CONTEXT * parser, FUNC_TYPE func_code, PT_NODE * args_list,
24777  size_t min_args, size_t max_args, size_t mod2)
24778 {
24779  size_t count = (size_t) parser_count_list (args_list);
24780  assert (mod2 == 0 || mod2 == 1);
24781  if (min_args > count || (max_args != 0 && max_args < count) || (count % 2 != mod2))
24782  {
24783  // todo - a more clear message
24784  PT_ERRORmf (parser, args_list, MSGCAT_SET_PARSER_SEMANTIC, MSGCAT_SEMANTIC_INVALID_INTERNAL_FUNCTION,
24785  fcode_get_lowercase_name (func_code));
24786  // todo - return null?
24787  }
24788  return parser_make_expr_with_func (parser, func_code, args_list);
24789 }
24790 
24791 PT_NODE *
24792 parser_make_expression (PARSER_CONTEXT * parser, PT_OP_TYPE OP, PT_NODE * arg1, PT_NODE * arg2,
24793  PT_NODE * arg3)
24794 {
24795  PT_NODE *expr;
24796  expr = parser_new_node (parser, PT_EXPR);
24797  if (expr)
24798  {
24799  expr->info.expr.op = OP;
24800  if (pt_is_operator_logical (expr->info.expr.op))
24801  {
24802  expr->type_enum = PT_TYPE_LOGICAL;
24803  }
24804 
24805  expr->info.expr.arg1 = arg1;
24806  expr->info.expr.arg2 = arg2;
24807  expr->info.expr.arg3 = arg3;
24808 
24809  if (parser_instnum_check == 1 && !pt_instnum_compatibility (expr))
24810  {
24811  PT_ERRORmf2 (parser, expr, MSGCAT_SET_PARSER_SEMANTIC,
24812  MSGCAT_SEMANTIC_INSTNUM_COMPATIBILITY_ERR,
24813  "INST_NUM() or ROWNUM", "INST_NUM() or ROWNUM");
24814  }
24815 
24816  if (parser_groupbynum_check == 1 && !pt_groupbynum_compatibility (expr))
24817  {
24818  PT_ERRORmf2 (parser, expr, MSGCAT_SET_PARSER_SEMANTIC,
24819  MSGCAT_SEMANTIC_INSTNUM_COMPATIBILITY_ERR,
24820  "GROUPBY_NUM()", "GROUPBY_NUM()");
24821  }
24822 
24823  if (parser_orderbynum_check == 1 && !pt_orderbynum_compatibility (expr))
24824  {
24825  PT_ERRORmf2 (parser, expr, MSGCAT_SET_PARSER_SEMANTIC,
24826  MSGCAT_SEMANTIC_INSTNUM_COMPATIBILITY_ERR,
24827  "ORDERBY_NUM()", "ORDERBY_NUM()");
24828  }
24829 
24830  if (PT_IS_SERIAL(OP))
24831  {
24832  parser_cannot_cache = true;
24833  }
24834 
24835  if (OP == PT_SYS_TIME || OP == PT_CURRENT_TIME || OP == PT_SYS_DATE
24836  || OP == PT_CURRENT_DATE || OP == PT_SYS_DATETIME
24837  || OP == PT_CURRENT_DATETIME || OP == PT_SYS_TIMESTAMP
24838  || OP == PT_CURRENT_TIMESTAMP || OP == PT_UTC_TIME
24839  || OP == PT_UTC_DATE || OP == PT_UNIX_TIMESTAMP
24840  || OP == PT_TZ_OFFSET || OP == PT_UTC_TIMESTAMP)
24841  {
24842  parser_si_datetime = true;
24843  parser_cannot_cache = true;
24844  }
24845  }
24846 
24847  return expr;
24848 }
24849 
24850 static PT_NODE *
24851 parser_make_link (PT_NODE * list, PT_NODE * node)
24852 {
24853  parser_append_node (node, list);
24854  return list;
24855 }
24856 
24857 static PT_NODE *
24858 parser_make_link_or (PT_NODE * list, PT_NODE * node)
24859 {
24860  parser_append_node_or (node, list);
24861  return list;
24862 }
24863 
24864 static bool parser_cannot_cache_stack_default[STACK_SIZE];
24865 static bool *parser_cannot_cache_stack = parser_cannot_cache_stack_default;
24866 static int parser_cannot_cache_sp = 0;
24867 static int parser_cannot_cache_limit = STACK_SIZE;
24868 
24869 static void
24870 parser_save_and_set_cannot_cache (bool value)
24871 {
24872  if (parser_cannot_cache_sp >= parser_cannot_cache_limit)
24873  {
24874  size_t new_size = parser_cannot_cache_limit * 2 * sizeof (bool);
24875  bool *new_p = malloc (new_size);
24876  if (new_p == NULL)
24877  {
24878  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE,
24879  ER_OUT_OF_VIRTUAL_MEMORY, 1, new_size);
24880  return;
24881  }
24882 
24883  memcpy (new_p, parser_cannot_cache_stack, parser_cannot_cache_limit * sizeof (bool));
24884  if (parser_cannot_cache_stack != parser_cannot_cache_stack_default)
24885  free (parser_cannot_cache_stack);
24886 
24887  parser_cannot_cache_stack = new_p;
24888  parser_cannot_cache_limit *= 2;
24889  }
24890 
24891  assert (parser_cannot_cache_sp >= 0);
24892  parser_cannot_cache_stack[parser_cannot_cache_sp++] = parser_cannot_cache;
24893  parser_cannot_cache = value;
24894 }
24895 
24896 static void
24897 parser_restore_cannot_cache ()
24898 {
24899  assert (parser_cannot_cache_sp >= 1);
24900  parser_cannot_cache = parser_cannot_cache_stack[--parser_cannot_cache_sp];
24901 }
24902 
24903 static int parser_si_datetime_saved;
24904 
24905 static void
24906 parser_save_and_set_si_datetime (int value)
24907 {
24908  parser_si_datetime_saved = parser_si_datetime;
24909  parser_si_datetime = value;
24910 }
24911 
24912 static void
24913 parser_restore_si_datetime ()
24914 {
24915  parser_si_datetime = parser_si_datetime_saved;
24916 }
24917 
24918 static int parser_si_tran_id_saved;
24919 
24920 static void
24921 parser_save_and_set_si_tran_id (int value)
24922 {
24923  parser_si_tran_id_saved = parser_si_tran_id;
24924  parser_si_tran_id = value;
24925 }
24926 
24927 static void
24928 parser_restore_si_tran_id ()
24929 {
24930  parser_si_tran_id = parser_si_tran_id_saved;
24931 }
24932 
24933 static int parser_cannot_prepare_saved;
24934 
24935 static void
24936 parser_save_and_set_cannot_prepare (bool value)
24937 {
24938  parser_cannot_prepare_saved = parser_cannot_prepare;
24939  parser_cannot_prepare = value;
24940 }
24941 
24942 static void
24943 parser_restore_cannot_prepare ()
24944 {
24945  parser_cannot_prepare = parser_cannot_prepare_saved;
24946 }
24947 
24948 static int parser_wjc_stack_default[STACK_SIZE];
24949 static int *parser_wjc_stack = parser_wjc_stack_default;
24950 static int parser_wjc_sp = 0;
24951 static int parser_wjc_limit = STACK_SIZE;
24952 
24953 static void
24954 parser_save_and_set_wjc (int value)
24955 {
24956  if (parser_wjc_sp >= parser_wjc_limit)
24957  {
24958  size_t new_size = parser_wjc_limit * 2 * sizeof (int);
24959  int *new_p = malloc (new_size);
24960  if (new_p == NULL)
24961  {
24962  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE,
24963  ER_OUT_OF_VIRTUAL_MEMORY, 1, new_size);
24964  return;
24965  }
24966 
24967  memcpy (new_p, parser_wjc_stack, parser_wjc_limit * sizeof (int));
24968  if (parser_wjc_stack != parser_wjc_stack_default)
24969  free (parser_wjc_stack);
24970 
24971  parser_wjc_stack = new_p;
24972  parser_wjc_limit *= 2;
24973  }
24974 
24975  assert (parser_wjc_sp >= 0);
24976  parser_wjc_stack[parser_wjc_sp++] = parser_within_join_condition;
24977  parser_within_join_condition = value;
24978 }
24979 
24980 static void
24981 parser_restore_wjc ()
24982 {
24983  assert (parser_wjc_sp >= 1);
24984  parser_within_join_condition = parser_wjc_stack[--parser_wjc_sp];
24985 }
24986 
24987 static int parser_instnum_stack_default[STACK_SIZE];
24988 static int *parser_instnum_stack = parser_instnum_stack_default;
24989 static int parser_instnum_sp = 0;
24990 static int parser_instnum_limit = STACK_SIZE;
24991 
24992 static void
24993 parser_save_and_set_ic (int value)
24994 {
24995  if (parser_instnum_sp >= parser_instnum_limit)
24996  {
24997  size_t new_size = parser_instnum_limit * 2 * sizeof (int);
24998  int *new_p = malloc (new_size);
24999  if (new_p == NULL)
25000  {
25001  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE,
25002  ER_OUT_OF_VIRTUAL_MEMORY, 1, new_size);
25003  return;
25004  }
25005 
25006  memcpy (new_p, parser_instnum_stack, parser_instnum_limit * sizeof (int));
25007  if (parser_instnum_stack != parser_instnum_stack_default)
25008  free (parser_instnum_stack);
25009 
25010  parser_instnum_stack = new_p;
25011  parser_instnum_limit *= 2;
25012  }
25013 
25014  assert (parser_instnum_sp >= 0);
25015  parser_instnum_stack[parser_instnum_sp++] = parser_instnum_check;
25016  parser_instnum_check = value;
25017 }
25018 
25019 static void
25020 parser_restore_ic ()
25021 {
25022  assert (parser_instnum_sp >= 1);
25023  parser_instnum_check = parser_instnum_stack[--parser_instnum_sp];
25024 }
25025 
25026 static int parser_groupbynum_stack_default[STACK_SIZE];
25027 static int *parser_groupbynum_stack = parser_groupbynum_stack_default;
25028 static int parser_groupbynum_sp = 0;
25029 static int parser_groupbynum_limit = STACK_SIZE;
25030 
25031 static void
25032 parser_save_and_set_gc (int value)
25033 {
25034  if (parser_groupbynum_sp >= parser_groupbynum_limit)
25035  {
25036  size_t new_size = parser_groupbynum_limit * 2 * sizeof (int);
25037  int *new_p = malloc (new_size);
25038  if (new_p == NULL)
25039  {
25040  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE,
25041  ER_OUT_OF_VIRTUAL_MEMORY, 1, new_size);
25042  return;
25043  }
25044 
25045  memcpy (new_p, parser_groupbynum_stack, parser_groupbynum_limit * sizeof (int));
25046  if (parser_groupbynum_stack != parser_groupbynum_stack_default)
25047  free (parser_groupbynum_stack);
25048 
25049  parser_groupbynum_stack = new_p;
25050  parser_groupbynum_limit *= 2;
25051  }
25052 
25053  assert (parser_groupbynum_sp >= 0);
25054  parser_groupbynum_stack[parser_groupbynum_sp++] = parser_groupbynum_check;
25055  parser_groupbynum_check = value;
25056 }
25057 
25058 static void
25059 parser_restore_gc ()
25060 {
25061  assert (parser_groupbynum_sp >= 1);
25062  parser_groupbynum_check = parser_groupbynum_stack[--parser_groupbynum_sp];
25063 }
25064 
25065 static int parser_orderbynum_stack_default[STACK_SIZE];
25066 static int *parser_orderbynum_stack = parser_orderbynum_stack_default;
25067 static int parser_orderbynum_sp = 0;
25068 static int parser_orderbynum_limit = STACK_SIZE;
25069 
25070 static void
25071 parser_save_and_set_oc (int value)
25072 {
25073  if (parser_orderbynum_sp >= parser_orderbynum_limit)
25074  {
25075  size_t new_size = parser_orderbynum_limit * 2 * sizeof (int);
25076  int *new_p = malloc (new_size);
25077  if (new_p == NULL)
25078  {
25079  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE,
25080  ER_OUT_OF_VIRTUAL_MEMORY, 1, new_size);
25081  return;
25082  }
25083 
25084  memcpy (new_p, parser_orderbynum_stack, parser_orderbynum_limit * sizeof (int));
25085  if (parser_orderbynum_stack != parser_orderbynum_stack_default)
25086  free (parser_orderbynum_stack);
25087 
25088  parser_orderbynum_stack = new_p;
25089  parser_orderbynum_limit *= 2;
25090  }
25091 
25092  assert (parser_orderbynum_sp >= 0);
25093  parser_orderbynum_stack[parser_orderbynum_sp++] = parser_orderbynum_check;
25094  parser_orderbynum_check = value;
25095 }
25096 
25097 static void
25098 parser_restore_oc ()
25099 {
25100  assert (parser_orderbynum_sp >= 1);
25101  parser_orderbynum_check = parser_orderbynum_stack[--parser_orderbynum_sp];
25102 }
25103 
25104 static int parser_sysc_stack_default[STACK_SIZE];
25105 static int *parser_sysc_stack = parser_sysc_stack_default;
25106 static int parser_sysc_sp = 0;
25107 static int parser_sysc_limit = STACK_SIZE;
25108 
25109 static void
25110 parser_save_and_set_sysc (int value)
25111 {
25112  if (parser_sysc_sp >= parser_sysc_limit)
25113  {
25114  size_t new_size = parser_sysc_limit * 2 * sizeof (int);
25115  int *new_p = malloc (new_size);
25116  if (new_p == NULL)
25117  {
25118  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE,
25119  ER_OUT_OF_VIRTUAL_MEMORY, 1, new_size);
25120  return;
25121  }
25122 
25123  memcpy (new_p, parser_sysc_stack, parser_sysc_limit * sizeof (int));
25124  if (parser_sysc_stack != parser_sysc_stack_default)
25125  free (parser_sysc_stack);
25126 
25127  parser_sysc_stack = new_p;
25128  parser_sysc_limit *= 2;
25129  }
25130 
25131  assert (parser_sysc_sp >= 0);
25132  parser_sysc_stack[parser_sysc_sp++] = parser_sysconnectbypath_check;
25133  parser_sysconnectbypath_check = value;
25134 }
25135 
25136 static void
25137 parser_restore_sysc ()
25138 {
25139  assert (parser_sysc_sp >= 1);
25140  parser_sysconnectbypath_check = parser_sysc_stack[--parser_sysc_sp];
25141 }
25142 
25143 static int parser_prc_stack_default[STACK_SIZE];
25144 static int *parser_prc_stack = parser_prc_stack_default;
25145 static int parser_prc_sp = 0;
25146 static int parser_prc_limit = STACK_SIZE;
25147 
25148 static void
25149 parser_save_and_set_prc (int value)
25150 {
25151  if (parser_prc_sp >= parser_prc_limit)
25152  {
25153  size_t new_size = parser_prc_limit * 2 * sizeof (int);
25154  int *new_p = malloc (new_size);
25155  if (new_p == NULL)
25156  {
25157  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE,
25158  ER_OUT_OF_VIRTUAL_MEMORY, 1, new_size);
25159  return;
25160  }
25161 
25162  memcpy (new_p, parser_prc_stack, parser_prc_limit * sizeof (int));
25163  if (parser_prc_stack != parser_prc_stack_default)
25164  free (parser_prc_stack);
25165 
25166  parser_prc_stack = new_p;
25167  parser_prc_limit *= 2;
25168  }
25169 
25170  assert (parser_prc_sp >= 0);
25171  parser_prc_stack[parser_prc_sp++] = parser_prior_check;
25172  parser_prior_check = value;
25173 }
25174 
25175 static void
25176 parser_restore_prc ()
25177 {
25178  assert (parser_prc_sp >= 1);
25179  parser_prior_check = parser_prc_stack[--parser_prc_sp];
25180 }
25181 
25182 static int parser_cbrc_stack_default[STACK_SIZE];
25183 static int *parser_cbrc_stack = parser_cbrc_stack_default;
25184 static int parser_cbrc_sp = 0;
25185 static int parser_cbrc_limit = STACK_SIZE;
25186 
25187 static void
25188 parser_save_and_set_cbrc (int value)
25189 {
25190  if (parser_cbrc_sp >= parser_cbrc_limit)
25191  {
25192  size_t new_size = parser_cbrc_limit * 2 * sizeof (int);
25193  int *new_p = malloc (new_size);
25194  if (new_p == NULL)
25195  {
25196  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE,
25197  ER_OUT_OF_VIRTUAL_MEMORY, 1, new_size);
25198  return;
25199  }
25200 
25201  memcpy (new_p, parser_cbrc_stack, parser_cbrc_limit * sizeof (int));
25202  if (parser_cbrc_stack != parser_cbrc_stack_default)
25203  free (parser_cbrc_stack);
25204 
25205  parser_cbrc_stack = new_p;
25206  parser_cbrc_limit *= 2;
25207  }
25208 
25209  assert (parser_cbrc_sp >= 0);
25210  parser_cbrc_stack[parser_cbrc_sp++] = parser_connectbyroot_check;
25211  parser_connectbyroot_check = value;
25212 }
25213 
25214 static void
25215 parser_restore_cbrc ()
25216 {
25217  assert (parser_cbrc_sp >= 1);
25218  parser_connectbyroot_check = parser_cbrc_stack[--parser_cbrc_sp];
25219 }
25220 
25221 static int parser_serc_stack_default[STACK_SIZE];
25222 static int *parser_serc_stack = parser_serc_stack_default;
25223 static int parser_serc_sp = 0;
25224 static int parser_serc_limit = STACK_SIZE;
25225 
25226 static void
25227 parser_save_and_set_serc (int value)
25228 {
25229  if (parser_serc_sp >= parser_serc_limit)
25230  {
25231  size_t new_size = parser_serc_limit * 2 * sizeof (int);
25232  int *new_p = malloc (new_size);
25233  if (new_p == NULL)
25234  {
25235  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE,
25236  ER_OUT_OF_VIRTUAL_MEMORY, 1, new_size);
25237  return;
25238  }
25239 
25240  memcpy (new_p, parser_serc_stack, parser_serc_limit * sizeof (int));
25241  if (parser_serc_stack != parser_serc_stack_default)
25242  free (parser_serc_stack);
25243 
25244  parser_serc_stack = new_p;
25245  parser_serc_limit *= 2;
25246  }
25247 
25248  assert (parser_serc_sp >= 0);
25249  parser_serc_stack[parser_serc_sp++] = parser_serial_check;
25250  parser_serial_check = value;
25251 }
25252 
25253 static void
25254 parser_restore_serc ()
25255 {
25256  assert (parser_serc_sp >= 1);
25257  parser_serial_check = parser_serc_stack[--parser_serc_sp];
25258 }
25259 
25260 static int parser_pseudoc_stack_default[STACK_SIZE];
25261 static int *parser_pseudoc_stack = parser_pseudoc_stack_default;
25262 static int parser_pseudoc_sp = 0;
25263 static int parser_pseudoc_limit = STACK_SIZE;
25264 
25265 static void
25266 parser_save_and_set_pseudoc (int value)
25267 {
25268  if (parser_pseudoc_sp >= parser_pseudoc_limit)
25269  {
25270  size_t new_size = parser_pseudoc_limit * 2 * sizeof (int);
25271  int *new_p = malloc (new_size);
25272  if (new_p == NULL)
25273  {
25274  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE,
25275  ER_OUT_OF_VIRTUAL_MEMORY, 1, new_size);
25276  return;
25277  }
25278 
25279  memcpy (new_p, parser_pseudoc_stack, parser_pseudoc_limit * sizeof (int));
25280  if (parser_pseudoc_stack != parser_pseudoc_stack_default)
25281  free (parser_pseudoc_stack);
25282 
25283  parser_pseudoc_stack = new_p;
25284  parser_pseudoc_limit *= 2;
25285  }
25286 
25287  assert (parser_pseudoc_sp >= 0);
25288  parser_pseudoc_stack[parser_pseudoc_sp++] = parser_pseudocolumn_check;
25289  parser_pseudocolumn_check = value;
25290 }
25291 
25292 static void
25293 parser_restore_pseudoc ()
25294 {
25295  assert (parser_pseudoc_sp >= 1);
25296  parser_pseudocolumn_check = parser_pseudoc_stack[--parser_pseudoc_sp];
25297 }
25298 
25299 static int parser_sqc_stack_default[STACK_SIZE];
25300 static int *parser_sqc_stack = parser_sqc_stack_default;
25301 static int parser_sqc_sp = 0;
25302 static int parser_sqc_limit = STACK_SIZE;
25303 
25304 static void
25305 parser_save_and_set_sqc (int value)
25306 {
25307  if (parser_sqc_sp >= parser_sqc_limit)
25308  {
25309  size_t new_size = parser_sqc_limit * 2 * sizeof (int);
25310  int *new_p = malloc (new_size);
25311  if (new_p == NULL)
25312  {
25313  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE,
25314  ER_OUT_OF_VIRTUAL_MEMORY, 1, new_size);
25315  return;
25316  }
25317 
25318  memcpy (new_p, parser_sqc_stack, parser_sqc_limit * sizeof (int));
25319  if (parser_sqc_stack != parser_sqc_stack_default)
25320  free (parser_sqc_stack);
25321 
25322  parser_sqc_stack = new_p;
25323  parser_sqc_limit *= 2;
25324  }
25325 
25326  assert (parser_sqc_sp >= 0);
25327  parser_sqc_stack[parser_sqc_sp++] = parser_subquery_check;
25328  parser_subquery_check = value;
25329 }
25330 
25331 static void
25332 parser_restore_sqc ()
25333 {
25334  assert (parser_sqc_sp >= 1);
25335  parser_subquery_check = parser_sqc_stack[--parser_sqc_sp];
25336 }
25337 
25338 static int parser_hvar_stack_default[STACK_SIZE];
25339 static int *parser_hvar_stack = parser_hvar_stack_default;
25340 static int parser_hvar_sp = 0;
25341 static int parser_hvar_limit = STACK_SIZE;
25342 
25343 static void
25344 parser_save_and_set_hvar (int value)
25345 {
25346  if (parser_hvar_sp >= parser_hvar_limit)
25347  {
25348  size_t new_size = parser_hvar_limit * 2 * sizeof (int);
25349  int *new_p = malloc (new_size);
25350  if (new_p == NULL)
25351  {
25352  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE,
25353  ER_OUT_OF_VIRTUAL_MEMORY, 1, new_size);
25354  return;
25355  }
25356 
25357  memcpy (new_p, parser_hvar_stack, parser_hvar_limit * sizeof (int));
25358  if (parser_hvar_stack != parser_hvar_stack_default)
25359  free (parser_hvar_stack);
25360 
25361  parser_hvar_stack = new_p;
25362  parser_hvar_limit *= 2;
25363  }
25364 
25365  assert (parser_hvar_sp >= 0);
25366  parser_hvar_stack[parser_hvar_sp++] = parser_hostvar_check;
25367  parser_hostvar_check = value;
25368 }
25369 
25370 static void
25371 parser_restore_hvar ()
25372 {
25373  assert (parser_hvar_sp >= 1);
25374  parser_hostvar_check = parser_hvar_stack[--parser_hvar_sp];
25375 }
25376 
25377 static int parser_oracle_stack_default[STACK_SIZE];
25378 static int *parser_oracle_stack = parser_oracle_stack_default;
25379 static int parser_oracle_sp = 0;
25380 static int parser_oracle_limit = STACK_SIZE;
25381 
25382 static void
25383 parser_save_found_Oracle_outer ()
25384 {
25385  if (parser_oracle_sp >= parser_oracle_limit)
25386  {
25387  size_t new_size = parser_oracle_limit * 2 * sizeof (int);
25388  int *new_p = malloc (new_size);
25389  if (new_p == NULL)
25390  {
25391  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE,
25392  ER_OUT_OF_VIRTUAL_MEMORY, 1, new_size);
25393  return;
25394  }
25395 
25396  memcpy (new_p, parser_oracle_stack, parser_oracle_limit * sizeof (int));
25397  if (parser_oracle_stack != parser_oracle_stack_default)
25398  free (parser_oracle_stack);
25399 
25400  parser_oracle_stack = new_p;
25401  parser_oracle_limit *= 2;
25402  }
25403 
25404  assert (parser_oracle_sp >= 0);
25405  parser_oracle_stack[parser_oracle_sp++] = parser_found_Oracle_outer;
25406 }
25407 
25408 static void
25409 parser_restore_found_Oracle_outer ()
25410 {
25411  assert (parser_oracle_sp >= 1);
25412  parser_found_Oracle_outer = parser_oracle_stack[--parser_oracle_sp];
25413 }
25414 
25415 static PT_NODE *parser_alter_node_saved;
25416 
25417 static void
25418 parser_save_alter_node (PT_NODE * node)
25419 {
25420  parser_alter_node_saved = node;
25421 }
25422 
25423 static PT_NODE *
25424 parser_get_alter_node ()
25425 {
25426  return parser_alter_node_saved;
25427 }
25428 
25429 static PT_NODE *parser_attr_def_one_saved;
25430 
25431 static void
25432 parser_save_attr_def_one (PT_NODE * node)
25433 {
25434  parser_attr_def_one_saved = node;
25435 }
25436 
25437 static PT_NODE *
25438 parser_get_attr_def_one ()
25439 {
25440  return parser_attr_def_one_saved;
25441 }
25442 
25443 static PT_NODE *parser_orderby_node_stack_default[STACK_SIZE];
25444 static PT_NODE **parser_orderby_node_stack = parser_orderby_node_stack_default;
25445 static int parser_orderby_node_sp = 0;
25446 static int parser_orderby_node_limit = STACK_SIZE;
25447 
25448 static void
25449 parser_push_orderby_node (PT_NODE * node)
25450 {
25451  if (parser_orderby_node_sp >= parser_orderby_node_limit)
25452  {
25453  size_t new_size = parser_orderby_node_limit * 2 * sizeof (PT_NODE **);
25454  PT_NODE **new_p = malloc (new_size);
25455  if (new_p == NULL)
25456  {
25457  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE,
25458  ER_OUT_OF_VIRTUAL_MEMORY, 1, new_size);
25459  return;
25460  }
25461 
25462  memcpy (new_p, parser_orderby_node_stack, parser_orderby_node_limit * sizeof (PT_NODE *));
25463  if (parser_orderby_node_stack != parser_orderby_node_stack_default)
25464  free (parser_orderby_node_stack);
25465 
25466  parser_orderby_node_stack = new_p;
25467  parser_orderby_node_limit *= 2;
25468  }
25469 
25470  assert (parser_orderby_node_sp >= 0);
25471  parser_orderby_node_stack[parser_orderby_node_sp++] = node;
25472 }
25473 
25474 static PT_NODE *
25475 parser_top_orderby_node ()
25476 {
25477  assert (parser_orderby_node_sp >= 1);
25478  return parser_orderby_node_stack[parser_orderby_node_sp - 1];
25479 }
25480 
25481 static PT_NODE *
25482 parser_pop_orderby_node ()
25483 {
25484  assert (parser_orderby_node_sp >= 1);
25485  return parser_orderby_node_stack[--parser_orderby_node_sp];
25486 }
25487 
25488 static PT_NODE *parser_select_node_stack_default[STACK_SIZE];
25489 static PT_NODE **parser_select_node_stack = parser_select_node_stack_default;
25490 static int parser_select_node_sp = 0;
25491 static int parser_select_node_limit = STACK_SIZE;
25492 
25493 static void
25494 parser_push_select_stmt_node (PT_NODE * node)
25495 {
25496  if (parser_select_node_sp >= parser_select_node_limit)
25497  {
25498  size_t new_size = parser_select_node_limit * 2 * sizeof (PT_NODE **);
25499  PT_NODE **new_p = malloc (new_size);
25500  if (new_p == NULL)
25501  {
25502  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE,
25503  ER_OUT_OF_VIRTUAL_MEMORY, 1, new_size);
25504  return;
25505  }
25506 
25507  memcpy (new_p, parser_select_node_stack, parser_select_node_limit * sizeof (PT_NODE *));
25508  if (parser_select_node_stack != parser_select_node_stack_default)
25509  free (parser_select_node_stack);
25510 
25511  parser_select_node_stack = new_p;
25512  parser_select_node_limit *= 2;
25513  }
25514 
25515  assert (parser_select_node_sp >= 0);
25516  parser_select_node_stack[parser_select_node_sp++] = node;
25517 }
25518 
25519 static PT_NODE *
25520 parser_top_select_stmt_node ()
25521 {
25522  assert (parser_select_node_sp >= 1);
25523  return parser_select_node_stack[parser_select_node_sp - 1];
25524 }
25525 
25526 static PT_NODE *
25527 parser_pop_select_stmt_node ()
25528 {
25529  assert (parser_select_node_sp >= 1);
25530  return parser_select_node_stack[--parser_select_node_sp];
25531 }
25532 
25533 static bool
25534 parser_is_select_stmt_node_empty ()
25535 {
25536  return parser_select_node_sp < 1;
25537 }
25538 
25539 static PT_NODE *parser_hint_node_stack_default[STACK_SIZE];
25540 static PT_NODE **parser_hint_node_stack = parser_hint_node_stack_default;
25541 static int parser_hint_node_sp = 0;
25542 static int parser_hint_node_limit = STACK_SIZE;
25543 
25544 static void
25545 parser_push_hint_node (PT_NODE * node)
25546 {
25547  if (parser_hint_node_sp >= parser_hint_node_limit)
25548  {
25549  size_t new_size = parser_hint_node_limit * 2 * sizeof (PT_NODE **);
25550  PT_NODE **new_p = malloc (new_size);
25551  if (new_p == NULL)
25552  {
25553  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE,
25554  ER_OUT_OF_VIRTUAL_MEMORY, 1, new_size);
25555  return;
25556  }
25557 
25558  memcpy (new_p, parser_hint_node_stack, parser_hint_node_limit * sizeof (PT_NODE *));
25559  if (parser_hint_node_stack != parser_hint_node_stack_default)
25560  free (parser_hint_node_stack);
25561 
25562  parser_hint_node_stack = new_p;
25563  parser_hint_node_limit *= 2;
25564  }
25565 
25566  assert (parser_hint_node_sp >= 0);
25567  parser_hint_node_stack[parser_hint_node_sp++] = node;
25568 }
25569 
25570 static PT_NODE *
25571 parser_top_hint_node ()
25572 {
25573  assert (parser_hint_node_sp >= 1);
25574  return parser_hint_node_stack[parser_hint_node_sp - 1];
25575 }
25576 
25577 static PT_NODE *
25578 parser_pop_hint_node ()
25579 {
25580  assert (parser_hint_node_sp >= 1);
25581  return parser_hint_node_stack[--parser_hint_node_sp];
25582 }
25583 
25584 static bool
25585 parser_is_hint_node_empty ()
25586 {
25587  return parser_hint_node_sp < 1;
25588 }
25589 
25590 static int parser_join_type_stack_default[STACK_SIZE];
25591 static int *parser_join_type_stack = parser_join_type_stack_default;
25592 static int parser_join_type_sp = 0;
25593 static int parser_join_type_limit = STACK_SIZE;
25594 
25595 static void
25596 parser_push_join_type (int v)
25597 {
25598  if (parser_join_type_sp >= parser_join_type_limit)
25599  {
25600  size_t new_size = parser_join_type_limit * 2 * sizeof (int);
25601  int *new_p = malloc (new_size);
25602  if (new_p == NULL)
25603  {
25604  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE,
25605  ER_OUT_OF_VIRTUAL_MEMORY, 1, new_size);
25606  return;
25607  }
25608 
25609  memcpy (new_p, parser_join_type_stack, parser_join_type_limit * sizeof (int));
25610  if (parser_join_type_stack != parser_join_type_stack_default)
25611  free (parser_join_type_stack);
25612 
25613  parser_join_type_stack = new_p;
25614  parser_join_type_limit *= 2;
25615  }
25616 
25617  assert (parser_join_type_sp >= 0);
25618  parser_join_type_stack[parser_join_type_sp++] = v;
25619 }
25620 
25621 static int
25622 parser_top_join_type ()
25623 {
25624  assert (parser_join_type_sp >= 1);
25625  return parser_join_type_stack[parser_join_type_sp - 1];
25626 }
25627 
25628 static int
25629 parser_pop_join_type ()
25630 {
25631  assert (parser_join_type_sp >= 1);
25632  return parser_join_type_stack[--parser_join_type_sp];
25633 }
25634 
25635 static bool parser_is_reverse_saved;
25636 
25637 static void
25638 parser_save_is_reverse (bool v)
25639 {
25640  parser_is_reverse_saved = v;
25641 }
25642 
25643 static bool
25644 parser_get_is_reverse ()
25645 {
25646  return parser_is_reverse_saved;
25647 }
25648 
25649 static int
25650 parser_count_list (PT_NODE * list)
25651 {
25652  int i = 0;
25653  PT_NODE *p = list;
25654 
25655  while (p)
25656  {
25657  p = p->next;
25658  i++;
25659  }
25660 
25661  return i;
25662 }
25663 
25664 static int
25665 parser_count_prefix_columns (PT_NODE * list, int * arg_count)
25666 {
25667  int i = 0;
25668  PT_NODE *p = list;
25669 
25670  *arg_count = 0;
25671 
25672  while (p)
25673  {
25674  if (p->node_type == PT_SORT_SPEC)
25675  {
25676  if (p->info.sort_spec.expr->node_type == PT_FUNCTION)
25677  {
25678  PT_NODE *expr = p->info.sort_spec.expr;
25679  PT_NODE *arg_list = expr->info.function.arg_list;
25680  if ((arg_list != NULL) && (arg_list->next == NULL)
25681  && (arg_list->node_type == PT_VALUE))
25682  {
25683  /* it might be a prefixed column */
25684  i++;
25685  }
25686  }
25687  }
25688 
25689  /* count all arguments */
25690  *arg_count = (*arg_count) + 1;
25691  p = p->next;
25692  }
25693 
25694  return i;
25695 }
25696 
25697 static void
25698 parser_initialize_parser_context (void)
25699 {
25700  parser_select_node_sp = 0;
25701  parser_orderby_node_sp = 0;
25702  parser_oracle_sp = 0;
25703  parser_orderbynum_sp = 0;
25704  parser_groupbynum_sp = 0;
25705  parser_instnum_sp = 0;
25706  parser_wjc_sp = 0;
25707  parser_cannot_cache_sp = 0;
25708  parser_hint_node_sp = 0;
25709 
25710  parser_save_is_reverse (false);
25711 }
25712 
25713 
25714 static void
25715 parser_remove_dummy_select (PT_NODE ** ent_inout)
25716 {
25717  PT_NODE *ent = *ent_inout;
25718 
25719  if (ent
25720  && ent->info.spec.derived_table_type == PT_IS_SUBQUERY
25721  && ent->info.spec.as_attr_list == NULL /* no attr_list */ )
25722  {
25723 
25724  PT_NODE *subq, *new_ent;
25725 
25726  /* remove dummy select from FROM clause
25727  *
25728  * for example:
25729  * case 1 (simple spec):
25730  * FROM (SELECT * FROM x) AS s
25731  * -> FROM x AS s
25732  * case 2 (nested spec):
25733  * FROM (SELECT * FROM (SELECT a, b FROM bas) y(p, q)) x
25734  * -> FROM (SELECT a, b FROM bas) x(p, q)
25735  *
25736  * Note: Subqueries with CTEs are not removed
25737  */
25738  if ((subq = ent->info.spec.derived_table)
25739  && subq->node_type == PT_SELECT
25740  && PT_SELECT_INFO_IS_FLAGED (subq, PT_SELECT_INFO_DUMMY))
25741  {
25742  if (subq->info.query.q.select.from && subq->info.query.with == NULL)
25743  {
25744  if (PT_SELECT_INFO_IS_FLAGED (subq, PT_SELECT_INFO_FOR_UPDATE))
25745  {
25746  /* the FOR UPDATE clause cannot be used in subqueries */
25747  PT_ERRORm (this_parser, subq, MSGCAT_SET_PARSER_SEMANTIC,
25748  MSGCAT_SEMANTIC_INVALID_USE_FOR_UPDATE_CLAUSE);
25749  }
25750  else
25751  {
25752  new_ent = subq->info.query.q.select.from;
25753  subq->info.query.q.select.from = NULL;
25754 
25755  /* free, reset new_spec's range_var, as_attr_list */
25756  if (new_ent->info.spec.range_var)
25757  {
25758  parser_free_node (this_parser, new_ent->info.spec.range_var);
25759  new_ent->info.spec.range_var = NULL;
25760  }
25761 
25762  new_ent->info.spec.range_var = ent->info.spec.range_var;
25763  ent->info.spec.range_var = NULL;
25764 
25765  /* free old ent, reset to new_ent */
25766  parser_free_node (this_parser, ent);
25767  *ent_inout = new_ent;
25768  }
25769  }
25770  else
25771  {
25772  /* not dummy */
25773  PT_SELECT_INFO_CLEAR_FLAG (subq, PT_SELECT_INFO_DUMMY);
25774  }
25775  }
25776  }
25777 }
25778 
25779 
25780 static PT_NODE *
25781 parser_make_date_lang (int arg_cnt, PT_NODE * arg3)
25782 {
25783  if (arg3 && arg_cnt == 3)
25784  {
25785  char *lang_str;
25786  PT_NODE *date_lang = parser_new_node (this_parser, PT_VALUE);
25787 
25788  if (date_lang)
25789  {
25790  date_lang->type_enum = PT_TYPE_INTEGER;
25791  if (arg3->type_enum != PT_TYPE_CHAR
25792  && arg3->type_enum != PT_TYPE_NCHAR)
25793  {
25794  PT_ERROR (this_parser, arg3,
25795  "argument 3 must be character string");
25796  }
25797  else if (arg3->info.value.data_value.str != NULL)
25798  {
25799  int flag = 0;
25800  lang_str = (char *) arg3->info.value.data_value.str->bytes;
25801  if (lang_set_flag_from_lang (lang_str, 1, 1, &flag))
25802  {
25803  PT_ERROR (this_parser, arg3, "check syntax at 'date_lang'");
25804  }
25805  date_lang->info.value.data_value.i = (long) flag;
25806  }
25807  }
25808  parser_free_node (this_parser, arg3);
25809 
25810  return date_lang;
25811  }
25812  else
25813  {
25814  PT_NODE *date_lang = parser_new_node (this_parser, PT_VALUE);
25815  if (date_lang)
25816  {
25817  const char *lang_str;
25818  int flag = 0;
25819 
25820  date_lang->type_enum = PT_TYPE_INTEGER;
25821  lang_str = prm_get_string_value (PRM_ID_INTL_DATE_LANG);
25822 
25823  lang_set_flag_from_lang (lang_str, (arg_cnt == 1) ? 0 : 1, 0, &flag);
25824 
25825  date_lang->info.value.data_value.i = (long) flag;
25826  }
25827 
25828  return date_lang;
25829  }
25830 }
25831 
25832 static PT_NODE *
25833 parser_make_number_lang (const int argc)
25834 {
25835  PT_NODE *number_lang = parser_new_node (this_parser, PT_VALUE);
25836 
25837  if (number_lang)
25838  {
25839  const char *lang_str;
25840  int flag = 0;
25841 
25842  number_lang->type_enum = PT_TYPE_INTEGER;
25843  lang_str = prm_get_string_value (PRM_ID_INTL_NUMBER_LANG);
25844 
25845  lang_set_flag_from_lang (lang_str, (argc >= 2) ? 1 : 0, (argc == 3) ? 1 : 0, &flag);
25846 
25847  number_lang->info.value.data_value.i = (long) flag;
25848  }
25849 
25850  return number_lang;
25851 }
25852 
25853 PT_NODE **
25854 parser_main (PARSER_CONTEXT * parser)
25855 {
25856  long desc_index = 0;
25857  long i, top;
25858  int rv;
25859 
25860  PARSER_CONTEXT *this_parser_saved;
25861 
25862  if (!parser)
25863  return 0;
25864 
25865  parser_output_host_index = parser_input_host_index = desc_index = 0;
25866 
25867  this_parser_saved = this_parser;
25868 
25869  this_parser = parser;
25870 
25871  dbcs_start_input ();
25872 
25873  yycolumn = yycolumn_end = 1;
25874  yybuffer_pos=0;
25875  csql_yylloc.buffer_pos=0;
25876  dot_flag = 0;
25877 
25878  g_query_string = NULL;
25879  g_query_string_len = 0;
25880  g_original_buffer_len = 0;
25881 
25882  rv = yyparse ();
25883  pt_cleanup_hint (parser, parser_hint_table);
25884 
25885  if (pt_has_error (parser) || parser->stack_top <= 0 || !parser->node_stack)
25886  {
25887  parser->statements = NULL;
25888  }
25889  else
25890  {
25891  /* create array of result statements */
25892  parser->statements = (PT_NODE **) parser_alloc (parser,
25893  (1 +
25894  parser->stack_top) *
25895  sizeof (PT_NODE *));
25896  if (parser->statements)
25897  {
25898  for (i = 0, top = parser->stack_top; i < top; i++)
25899  {
25900  parser->statements[i] = parser->node_stack[i];
25901  }
25902  parser->statements[top] = NULL;
25903  }
25904  /* record parser_input_host_index into parser->host_var_count for later use;
25905  e.g. parser_set_host_variables(), auto-parameterized query */
25906  parser->host_var_count = parser_input_host_index;
25907  if (parser->host_var_count > 0)
25908  {
25909  /* allocate place holder for host variables */
25910  parser->host_variables = (DB_VALUE *)
25911  malloc (parser->host_var_count * sizeof (DB_VALUE));
25912  if (parser->host_variables)
25913  {
25914  memset (parser->host_variables, 0,
25915  parser->host_var_count * sizeof (DB_VALUE));
25916  }
25917  else
25918  {
25919  parser->statements = NULL;
25920  goto end;
25921  }
25922 
25923  parser->host_var_expected_domains = (TP_DOMAIN **)
25924  malloc (parser->host_var_count * sizeof (TP_DOMAIN *));
25925  if (parser->host_var_expected_domains)
25926  {
25927  for (i = 0; i < parser->host_var_count; i++)
25928  {
25929  parser->host_var_expected_domains[i] =
25930  tp_domain_resolve_default (DB_TYPE_UNKNOWN);
25931  }
25932  }
25933  else
25934  {
25935  free_and_init (parser->host_variables);
25936  parser->statements = NULL;
25937  }
25938  for (i = 0; i < parser->host_var_count; i++)
25939  {
25940  db_make_null (&parser->host_variables[i]);
25941  }
25942  }
25943  }
25944 
25945 end:
25946  this_parser = this_parser_saved;
25947  return parser->statements;
25948 }
25949 
25950 
25951 
25952 
25953 
25954 extern int parser_yyinput_single_mode;
25955 int
25956 parse_one_statement (int state)
25957 {
25958  int rv;
25959 
25960  if (state == 0)
25961  {
25962  // a new session starts. reset line and column number.
25963  csql_yyset_lineno (1);
25964  yycolumn = yycolumn_end = 1;
25965 
25966  return 0;
25967  }
25968 
25969  this_parser->statement_number = 0;
25970 
25971  parser_yyinput_single_mode = 1;
25972 
25973  yybuffer_pos=0;
25974  csql_yylloc.buffer_pos=0;
25975  dot_flag = 0;
25976 
25977  g_query_string = NULL;
25978  g_query_string_len = 0;
25979  g_original_buffer_len = 0;
25980 
25981  rv = yyparse ();
25982  pt_cleanup_hint (this_parser, parser_hint_table);
25983 
25984  if (parser_statement_OK)
25985  this_parser->statement_number = 1;
25986  else
25987  parser_statement_OK = 1;
25988 
25989  if (!parser_yyinput_single_mode) /* eof */
25990  return 1;
25991 
25992  return 0;
25993 }
25994 
25995 
25996 PT_HINT parser_hint_table[] = {
25997  {"ORDERED", NULL, PT_HINT_ORDERED}
25998  ,
25999  {"NO_INDEX_SS", NULL, PT_HINT_NO_INDEX_SS}
26000  ,
26001  {"INDEX_SS", NULL, PT_HINT_INDEX_SS}
26002  ,
26003  {"USE_NL", NULL, PT_HINT_USE_NL}
26004  ,
26005  {"USE_IDX", NULL, PT_HINT_USE_IDX}
26006  ,
26007  {"USE_MERGE", NULL, PT_HINT_USE_MERGE}
26008  ,
26009  {"RECOMPILE", NULL, PT_HINT_RECOMPILE}
26010  ,
26011  {"LOCK_TIMEOUT", NULL, PT_HINT_LK_TIMEOUT}
26012  ,
26013  {"NO_LOGGING", NULL, PT_HINT_NO_LOGGING}
26014  ,
26015  {"QUERY_CACHE", NULL, PT_HINT_QUERY_CACHE}
26016  ,
26017  {"SQL_CACHE", NULL, PT_HINT_QUERY_CACHE}
26018  ,
26019  {"QUERY_NO_CACHE", NULL, PT_HINT_QUERY_NO_CACHE}
26020  ,
26021  {"SQL_NO_CACHE", NULL, PT_HINT_QUERY_NO_CACHE}
26022  ,
26023  {"REEXECUTE", NULL, PT_HINT_REEXECUTE}
26024  ,
26025  {"JDBC_CACHE", NULL, PT_HINT_JDBC_CACHE}
26026  ,
26027  {"USE_DESC_IDX", NULL, PT_HINT_USE_IDX_DESC}
26028  ,
26029  {"NO_COVERING_IDX", NULL, PT_HINT_NO_COVERING_IDX}
26030  ,
26031  {"INSERT_EXECUTION_MODE", NULL, PT_HINT_INSERT_MODE}
26032  ,
26033  {"NO_DESC_IDX", NULL, PT_HINT_NO_IDX_DESC}
26034  ,
26035  {"NO_MULTI_RANGE_OPT", NULL, PT_HINT_NO_MULTI_RANGE_OPT}
26036  ,
26037  {"USE_UPDATE_IDX", NULL, PT_HINT_USE_UPDATE_IDX}
26038  ,
26039  {"USE_INSERT_IDX", NULL, PT_HINT_USE_INSERT_IDX}
26040  ,
26041  {"NO_SORT_LIMIT", NULL, PT_HINT_NO_SORT_LIMIT}
26042  ,
26043  {"NO_HASH_AGGREGATE", NULL, PT_HINT_NO_HASH_AGGREGATE}
26044  ,
26045  {"NO_HASH_LIST_SCAN", NULL, PT_HINT_NO_HASH_LIST_SCAN}
26046  ,
26047  {"SKIP_UPDATE_NULL", NULL, PT_HINT_SKIP_UPDATE_NULL}
26048  ,
26049  {"NO_INDEX_LS", NULL, PT_HINT_NO_INDEX_LS}
26050  ,
26051  {"INDEX_LS", NULL, PT_HINT_INDEX_LS}
26052  ,
26053  {"SELECT_RECORD_INFO", NULL, PT_HINT_SELECT_RECORD_INFO}
26054  ,
26055  {"SELECT_PAGE_INFO", NULL, PT_HINT_SELECT_PAGE_INFO}
26056  ,
26057  {"SELECT_KEY_INFO", NULL, PT_HINT_SELECT_KEY_INFO}
26058  ,
26059  {"SELECT_BTREE_NODE_INFO", NULL, PT_HINT_SELECT_BTREE_NODE_INFO}
26060  ,
26061  {"USE_SBR", NULL, PT_HINT_USE_SBR}
26062  ,
26063  {NULL, NULL, -1} /* mark as end */
26064 };
26065 
26066 
26067 
26068 static int
26069 function_keyword_cmp (const void *f1, const void *f2)
26070 {
26071  return strcasecmp (((FUNCTION_MAP *) f1)->keyword,
26072  ((FUNCTION_MAP *) f2)->keyword);
26073 }
26074 
26075 
26076 
26077 FUNCTION_MAP *
26078 keyword_offset (const char *text)
26079 {
26080  static bool function_keyword_sorted = false;
26081  FUNCTION_MAP dummy;
26082  FUNCTION_MAP *result_key;
26083 
26084  if (function_keyword_sorted == false)
26085  {
26086  qsort (functions,
26087  (sizeof (functions) / sizeof (functions[0])),
26088  sizeof (functions[0]), function_keyword_cmp);
26089 
26090  function_keyword_sorted = true;
26091  }
26092 
26093  if (!text)
26094  {
26095  return NULL;
26096  }
26097 
26098  if (strlen (text) >= MAX_KEYWORD_SIZE)
26099  {
26100  return NULL;
26101  }
26102 
26103  dummy.keyword = text;
26104 
26105  result_key =
26106  (FUNCTION_MAP *) bsearch (&dummy, functions,
26107  (sizeof (functions) / sizeof (functions[0])),
26108  sizeof (FUNCTION_MAP), function_keyword_cmp);
26109 
26110  return result_key;
26111 }
26112 
26113 
26114 PT_NODE *
26115 parser_keyword_func (const char *name, PT_NODE * args)
26116 {
26117  PT_NODE *node;
26118  PT_NODE *top_node;
26119  PT_NODE *a1, *a2, *a3;
26120  FUNCTION_MAP *key;
26121  int c;
26122  PT_NODE *val, *between_ge_lt, *between;
26123 
26124 
26125  parser_function_code = PT_EMPTY;
26126  c = parser_count_list (args);
26127  key = keyword_offset (name);
26128  if (key == NULL)
26129  return NULL;
26130 
26131  parser_function_code = key->op;
26132 
26133  a1 = a2 = a3 = NULL;
26134  switch (key->op)
26135  {
26136  /* arg 0 */
26137  case PT_PI:
26138  case PT_SYS_TIME:
26139  case PT_SYS_DATE:
26140  case PT_SYS_DATETIME:
26141  case PT_SYS_TIMESTAMP:
26142  case PT_CURRENT_TIME:
26143  case PT_CURRENT_DATE:
26144  case PT_CURRENT_DATETIME:
26145  case PT_CURRENT_TIMESTAMP:
26146  case PT_UTC_TIME:
26147  case PT_UTC_DATE:
26148  case PT_VERSION:
26149  case PT_UTC_TIMESTAMP:
26150  if (c != 0)
26151  {
26152  return NULL;
26153  }
26154  return parser_make_expression (this_parser, key->op, NULL, NULL, NULL);
26155 
26156  case PT_ROW_COUNT:
26157  case PT_LAST_INSERT_ID:
26158  case PT_TRACE_STATS:
26159  if (c != 0)
26160  {
26161  return NULL;
26162  }
26163  parser_cannot_cache = true;
26164  parser_cannot_prepare = true;
26165  return parser_make_expression (this_parser, key->op, NULL, NULL, NULL);
26166 
26167  case PT_SYS_GUID:
26168  {
26169  PT_NODE *expr;
26170  if (c != 0)
26171  {
26172  return NULL;
26173  }
26174  parser_cannot_cache = true;
26175 
26176  expr = parser_make_expression (this_parser, key->op, NULL, NULL, NULL);
26177  expr->flag.do_not_fold = 1;
26178 
26179  return expr;
26180  }
26181 
26182  /* arg 0 or 1 */
26183  case PT_RAND:
26184  case PT_RANDOM:
26185  case PT_DRAND:
26186  case PT_DRANDOM:
26187  {
26188  PT_NODE *expr;
26189  parser_cannot_cache = true;
26190 
26191  if (c < 0 || c > 1)
26192  {
26193  return NULL;
26194  }
26195 
26196  if (c == 1)
26197  {
26198  a1 = args;
26199  }
26200  expr = parser_make_expression (this_parser, key->op, a1, NULL, NULL);
26201  expr->flag.do_not_fold = 1;
26202  return expr;
26203  }
26204 
26205  /* arg 1 */
26206  case PT_ABS:
26207  case PT_BIN:
26208  case PT_CEIL:
26209  case PT_CHAR_LENGTH: /* char_length, length, lengthb */
26210  case PT_EXP:
26211  case PT_FLOOR:
26212  case PT_LAST_DAY:
26213  case PT_SIGN:
26214  case PT_SQRT:
26215  case PT_ACOS:
26216  case PT_ASIN:
26217  case PT_COS:
26218  case PT_SIN:
26219  case PT_TAN:
26220  case PT_COT:
26221  case PT_DEGREES:
26222  case PT_RADIANS:
26223  case PT_LN:
26224  case PT_LOG2:
26225  case PT_LOG10:
26226  case PT_TYPEOF:
26227  case PT_MD5:
26228  case PT_SPACE:
26229  case PT_DAYOFMONTH:
26230  case PT_WEEKDAY:
26231  case PT_DAYOFWEEK:
26232  case PT_DAYOFYEAR:
26233  case PT_TODAYS:
26234  case PT_FROMDAYS:
26235  case PT_TIMETOSEC:
26236  case PT_SECTOTIME:
26237  case PT_QUARTERF:
26238  case PT_EXEC_STATS:
26239  case PT_CURRENT_VALUE:
26240  case PT_HEX:
26241  case PT_ASCII:
26242  case PT_INET_ATON:
26243  case PT_INET_NTOA:
26244  case PT_COERCIBILITY:
26245  case PT_SHA_ONE:
26246  case PT_TO_BASE64:
26247  case PT_FROM_BASE64:
26248  case PT_CRC32:
26249  case PT_SCHEMA_DEF:
26250  case PT_DISK_SIZE:
26251  {
26252  PT_NODE *expr;
26253  if (c != 1)
26254  {
26255  return NULL;
26256  }
26257  a1 = args;
26258  if (key->op == PT_COERCIBILITY && a1)
26259  {
26260  a1->flag.do_not_fold = 1;
26261  }
26262 
26263  expr = parser_make_expression (this_parser, key->op, a1, NULL, NULL);
26264  if (key->op == PT_SCHEMA_DEF && a1)
26265  {
26266  if (!PT_IS_VALUE_NODE (a1)
26267  || (a1->type_enum != PT_TYPE_NULL
26268  && !PT_IS_STRING_TYPE(a1->type_enum)))
26269  {
26270  PT_ERRORf (this_parser, a1, "%s argument must be "
26271  "a string literal", pt_short_print (this_parser, expr));
26272  return NULL;
26273  }
26274  }
26275 
26276  return expr;
26277  }
26278 
26279  case PT_UNIX_TIMESTAMP:
26280  if (c > 1)
26281  {
26282  return NULL;
26283  }
26284  if (c == 1)
26285  {
26286  a1 = args;
26287  return parser_make_expression (this_parser, key->op, a1, NULL, NULL);
26288  }
26289  else /* no arguments */
26290  {
26291  return parser_make_expression (this_parser, key->op, NULL, NULL, NULL);
26292  }
26293 
26294  /* arg 2 */
26295  case PT_DATE_FORMAT:
26296  case PT_TIME_FORMAT:
26297  case PT_FORMAT:
26298  case PT_STR_TO_DATE:
26299  if (c != 2)
26300  return NULL;
26301  a1 = args;
26302  a2 = a1->next;
26303  a1->next = NULL;
26304  return parser_make_expression (this_parser, key->op, a1, a2, parser_make_date_lang (2, NULL));
26305 
26306  case PT_LOG:
26307  case PT_MONTHS_BETWEEN:
26308  case PT_NVL:
26309  case PT_POWER:
26310  case PT_ATAN2:
26311  case PT_DATEDIFF:
26312  case PT_TIMEDIFF:
26313  case PT_REPEAT:
26314  case PT_MAKEDATE:
26315  case PT_ADDTIME:
26316  case PT_FINDINSET:
26317  case PT_AES_ENCRYPT:
26318  case PT_AES_DECRYPT:
26319  case PT_SHA_TWO:
26320  case PT_FROM_TZ:
26321  if (c != 2)
26322  return NULL;
26323  a1 = args;
26324  a2 = a1->next;
26325  a1->next = NULL;
26326  return parser_make_expression (this_parser, key->op, a1, a2, NULL);
26327 
26328  case PT_NEXT_VALUE:
26329  if (c == 1)
26330  {
26331  a1 = args;
26332 
26333  /* default value for the second argument is 1. */
26334  a2 = parser_new_node (this_parser, PT_VALUE);
26335  if (a2)
26336  {
26337  a2->type_enum = PT_TYPE_INTEGER;
26338  a2->info.value.data_value.i = 1;
26339  }
26340 
26341  return parser_make_expression (this_parser, key->op, a1, a2, NULL);
26342  }
26343  else if (c == 2)
26344  {
26345  a1 = args;
26346  a2 = a1->next;
26347  a1->next = NULL;
26348 
26349  return parser_make_expression (this_parser, key->op, a1, a2, NULL);
26350  }
26351  else
26352  {
26353  return NULL;
26354  }
26355 
26356  case PT_ATAN:
26357  if (c == 1)
26358  {
26359  a1 = args;
26360  return parser_make_expression (this_parser, key->op, a1, NULL, NULL);
26361  }
26362  else if (c == 2)
26363  {
26364  a1 = args;
26365  a2 = a1->next;
26366  a1->next = NULL;
26367  return parser_make_expression (this_parser, PT_ATAN2, a1, a2, NULL);
26368  }
26369  else
26370  {
26371  return NULL;
26372  }
26373 
26374  /* arg 3 */
26375  case PT_SUBSTRING_INDEX:
26376  case PT_NVL2:
26377  case PT_MAKETIME:
26378  case PT_INDEX_CARDINALITY:
26379  case PT_CONV:
26380  case PT_NEW_TIME:
26381  if (c != 3)
26382  return NULL;
26383  a1 = args;
26384  a2 = a1->next;
26385  a3 = a2->next;
26386  a1->next = a2->next = NULL;
26387  return parser_make_expression (this_parser, key->op, a1, a2, a3);
26388 
26389  /* arg 4 */
26390  case PT_WIDTH_BUCKET:
26391  if (c != 4)
26392  {
26393  return NULL;
26394  }
26395 
26396  a1 = args;
26397  a2 = a1->next; /* a2 is the lower bound, a2->next is the upper bound */
26398  a3 = a2->next->next;
26399  a1->next = a2->next->next = a3->next = NULL;
26400 
26401  val = parser_new_node (this_parser, PT_VALUE);
26402  if (val == NULL)
26403  {
26404  return NULL;
26405  }
26406  val->type_enum = PT_TYPE_NULL;
26407  val->flag.is_added_by_parser = 1;
26408 
26409  between_ge_lt = parser_make_expression (this_parser, PT_BETWEEN_GE_LT, a2, a2->next, NULL);
26410  if (between_ge_lt == NULL)
26411  {
26412  return NULL;
26413  }
26414  a2->next = NULL;
26415 
26416  between = parser_make_expression (this_parser, PT_BETWEEN, val, between_ge_lt, NULL);
26417  if (between == NULL)
26418  {
26419  return NULL;
26420  }
26421 
26422  between->flag.do_not_fold = 1;
26423 
26424  return parser_make_expression (this_parser, key->op, a1, between, a3);
26425 
26426  /* arg 1 + default */
26427  case PT_ROUND:
26428  if (c == 1)
26429  {
26430  a1 = args;
26431  a2 = parser_new_node (this_parser, PT_VALUE);
26432  if (a2)
26433  {
26434  /* default fmt value */
26435  if(a1->node_type == PT_VALUE
26436  && PT_IS_DATE_TIME_TYPE(a1->type_enum))
26437  {
26438  a2->type_enum = PT_TYPE_CHAR;
26439  a2->info.value.data_value.str =
26440  pt_append_bytes(this_parser, NULL, "dd", 2);
26441  }
26442  else if(a1->node_type == PT_VALUE
26443  && PT_IS_NUMERIC_TYPE(a1->type_enum))
26444  {
26445  a2->type_enum = PT_TYPE_INTEGER;
26446  a2->info.value.data_value.i = 0;
26447  }
26448  else
26449  {
26450  a2->type_enum = PT_TYPE_CHAR;
26451  a2->info.value.data_value.str =
26452  pt_append_bytes(this_parser, NULL, "default", 7);
26453  }
26454  }
26455 
26456  return parser_make_expression (this_parser, key->op, a1, a2, NULL);
26457  }
26458 
26459  if (c != 2)
26460  return NULL;
26461  a1 = args;
26462  a2 = a1->next;
26463  a1->next = NULL;
26464 
26465  return parser_make_expression (this_parser, key->op, a1, a2, NULL);
26466 
26467  case PT_TRUNC:
26468  if (c == 1)
26469  {
26470  a1 = args;
26471  a2 = parser_new_node (this_parser, PT_VALUE);
26472  if (a2)
26473  {
26474  /* default fmt value */
26475  if (a1->node_type == PT_VALUE
26476  && PT_IS_NUMERIC_TYPE (a1->type_enum))
26477  {
26478  a2->type_enum = PT_TYPE_INTEGER;
26479  a2->info.value.data_value.i = 0;
26480  }
26481  else
26482  {
26483  a2->type_enum = PT_TYPE_CHAR;
26484  a2->info.value.data_value.str =
26485  pt_append_bytes (this_parser, NULL, "default", 7);
26486  }
26487  }
26488 
26489  return parser_make_expression (this_parser, key->op, a1, a2, NULL);
26490  }
26491 
26492  if (c != 2)
26493  return NULL;
26494  a1 = args;
26495  a2 = a1->next;
26496  a1->next = NULL;
26497 
26498  return parser_make_expression (this_parser, key->op, a1, a2, NULL);
26499 
26500  /* arg 2 + default */
26501  case PT_INSTR: /* instr, instrb */
26502  if (c == 2)
26503  {
26504  a3 = parser_new_node (this_parser, PT_VALUE);
26505  if (a3)
26506  {
26507  a3->type_enum = PT_TYPE_INTEGER;
26508  a3->info.value.data_value.i = 1;
26509  }
26510 
26511  a1 = args;
26512  a2 = a1->next;
26513  a1->next = NULL;
26514 
26515  return parser_make_expression (this_parser, key->op, a1, a2, a3);
26516  }
26517 
26518  if (c != 3)
26519  return NULL;
26520  a1 = args;
26521  a2 = a1->next;
26522  a3 = a2->next;
26523  a1->next = a2->next = NULL;
26524  return parser_make_expression (this_parser, key->op, a1, a2, a3);
26525 
26526  /* arg 1 or 2 */
26527  case PT_WEEKF:
26528  if (c < 1 || c > 2)
26529  return NULL;
26530  if (c == 1)
26531  {
26532  a1 = args;
26533  a2 = parser_new_node (this_parser, PT_VALUE);
26534  if (a2)
26535  {
26536  a2->info.value.data_value.i =
26537  prm_get_integer_value (PRM_ID_DEFAULT_WEEK_FORMAT);
26538  a2->type_enum = PT_TYPE_INTEGER;
26539  }
26540  return parser_make_expression (this_parser, key->op, a1, a2, NULL);
26541  }
26542  else
26543  {
26544  a1 = args;
26545  a2 = a1->next;
26546  a1->next = NULL;
26547  return parser_make_expression (this_parser, key->op, a1, a2, NULL);
26548  }
26549 
26550  case PT_LTRIM:
26551  case PT_RTRIM:
26552  case PT_LIKE_LOWER_BOUND:
26553  case PT_LIKE_UPPER_BOUND:
26554  if (c < 1 || c > 2)
26555  return NULL;
26556  a1 = args;
26557  if (a1)
26558  a2 = a1->next;
26559  a1->next = NULL;
26560  return parser_make_expression (this_parser, key->op, a1, a2, a3);
26561 
26562  case PT_FROM_UNIXTIME:
26563  if (c < 1 || c > 2)
26564  return NULL;
26565  a1 = args;
26566  if (a1)
26567  a2 = a1->next;
26568  a1->next = NULL;
26569  a3 = parser_make_date_lang (2, NULL);
26570  return parser_make_expression (this_parser, key->op, a1, a2, a3);
26571 
26572  /* arg 1 or 2 */
26573  case PT_TO_NUMBER:
26574  if (c < 1 || c > 2)
26575  {
26576  push_msg (MSGCAT_SYNTAX_INVALID_TO_NUMBER);
26577  csql_yyerror_explicit (10, 10);
26578  return NULL;
26579  }
26580 
26581  if (c == 2)
26582  {
26583  PT_NODE *node = args->next;
26584  if (node->node_type != PT_VALUE ||
26585  (node->type_enum != PT_TYPE_CHAR &&
26586  node->type_enum != PT_TYPE_VARCHAR &&
26587  node->type_enum != PT_TYPE_NCHAR &&
26588  node->type_enum != PT_TYPE_VARNCHAR))
26589  {
26590  push_msg (MSGCAT_SYNTAX_INVALID_TO_NUMBER);
26591  csql_yyerror_explicit (10, 10);
26592  return NULL;
26593  }
26594  }
26595 
26596  a1 = args;
26597  if (a1)
26598  a2 = a1->next;
26599  a1->next = NULL;
26600  return parser_make_expression (this_parser, key->op, a1, a2, parser_make_number_lang (c));
26601 
26602  /* arg 2 or 3 */
26603  case PT_LPAD:
26604  case PT_RPAD:
26605  case PT_SUBSTRING: /* substr, substrb */
26606 
26607  if (c < 2 || c > 3)
26608  return NULL;
26609 
26610  a1 = args;
26611  a2 = a1->next;
26612  if (a2)
26613  {
26614  a3 = a2->next;
26615  a2->next = NULL;
26616  }
26617 
26618  a1->next = NULL;
26619 
26620  node = parser_make_expression (this_parser, key->op, a1, a2, a3);
26621  if (key->op == PT_SUBSTRING)
26622  {
26623  node->info.expr.qualifier = PT_SUBSTR;
26624  PICE (node);
26625  }
26626 
26627  return node;
26628 
26629  case PT_ORDERBY_NUM:
26630  if (c != 0)
26631  return NULL;
26632 
26633  node = parser_new_node (this_parser, PT_EXPR);
26634  if (node)
26635  {
26636  node->info.expr.op = PT_ORDERBY_NUM;
26637  PT_EXPR_INFO_SET_FLAG (node, PT_EXPR_INFO_ORDERBYNUM_C);
26638  }
26639 
26640  if (parser_orderbynum_check == 0)
26641  PT_ERRORmf2 (this_parser, node, MSGCAT_SET_PARSER_SEMANTIC,
26642  MSGCAT_SEMANTIC_INSTNUM_COMPATIBILITY_ERR,
26643  "ORDERBY_NUM()", "ORDERBY_NUM()");
26644 
26645  parser_groupby_exception = PT_ORDERBY_NUM;
26646  return node;
26647 
26648  case PT_INST_NUM:
26649  if (c != 0)
26650  return NULL;
26651 
26652  node = parser_new_node (this_parser, PT_EXPR);
26653 
26654  if (node)
26655  {
26656  node->info.expr.op = PT_INST_NUM;
26657  PT_EXPR_INFO_SET_FLAG (node, PT_EXPR_INFO_INSTNUM_C);
26658  }
26659 
26660  if (parser_instnum_check == 0)
26661  PT_ERRORmf2 (this_parser, node, MSGCAT_SET_PARSER_SEMANTIC,
26662  MSGCAT_SEMANTIC_INSTNUM_COMPATIBILITY_ERR,
26663  "INST_NUM() or ROWNUM", "INST_NUM() or ROWNUM");
26664 
26665  parser_groupby_exception = PT_INST_NUM;
26666  return node;
26667 
26668  case PT_INCR:
26669  case PT_DECR:
26670  if (c != 1)
26671  return NULL;
26672  node = parser_make_expression (this_parser, key->op, args, NULL, NULL);
26673 
26674  if ((args->node_type != PT_NAME && args->node_type != PT_DOT_) ||
26675  (args->node_type == PT_NAME && args->info.name.tag_click_counter) ||
26676  (args->node_type == PT_DOT_ && args->info.dot.tag_click_counter))
26677  {
26678  PT_ERRORf (this_parser, node,
26679  "%s argument must be identifier or dotted identifier(path expression)",
26680  pt_short_print (this_parser, node));
26681  }
26682 
26683  if (parser_select_level != 1)
26684  {
26685  PT_ERRORf (this_parser, node,
26686  "%s can be used at top select statement only.",
26687  pt_short_print (this_parser, node));
26688  }
26689  node->flag.is_hidden_column = 1;
26690  parser_hidden_incr_list =
26691  parser_append_node (node, parser_hidden_incr_list);
26692  if ((a1 = parser_copy_tree (this_parser, node->info.expr.arg1)) == NULL)
26693  {
26694  return NULL;
26695  }
26696 
26697  parser_cannot_cache = true;
26698 
26699  if (a1->node_type == PT_NAME)
26700  a1->info.name.tag_click_counter = 1;
26701  else if (a1->node_type == PT_DOT_)
26702  a1->info.dot.tag_click_counter = 1;
26703 
26704  top_node = parser_is_select_stmt_node_empty () ? NULL : parser_top_select_stmt_node ();
26705  if (top_node)
26706  {
26707  top_node->flag.is_click_counter = 1;
26708  }
26709 
26710  return a1;
26711 
26712  case PT_TO_CHAR:
26713  case PT_TO_DATE:
26714  case PT_TO_TIME:
26715  case PT_TO_TIMESTAMP:
26716  case PT_TO_DATETIME:
26717  case PT_TO_DATETIME_TZ:
26718  case PT_TO_TIMESTAMP_TZ:
26719  if (c < 1 || c > 3)
26720  return NULL;
26721  a1 = args;
26722  a2 = a1->next;
26723  a1->next = NULL;
26724 
26725  if (a2)
26726  {
26727  a3 = a2->next;
26728  }
26729 
26730  if (a2)
26731  {
26732  a2->next = NULL;
26733  }
26734 
26735  if (c == 1)
26736  {
26737  a2 = parser_new_node (this_parser, PT_VALUE);
26738 
26739  if (a2)
26740  {
26741  a2->type_enum = PT_TYPE_NULL;
26742  a2->flag.is_added_by_parser = 1;
26743  }
26744  }
26745 
26746  return parser_make_expression (this_parser, key->op, a1, a2,
26747  parser_make_date_lang (c, a3));
26748 
26749  case PT_BIT_TO_BLOB:
26750  case PT_CHAR_TO_BLOB:
26751  case PT_CHAR_TO_CLOB:
26752  case PT_BLOB_LENGTH:
26753  case PT_CLOB_LENGTH:
26754  if (c != 1)
26755  {
26756  return NULL;
26757  }
26758 
26759  a1 = args;
26760  /*
26761  a2 = parser_new_node (this_parser, PT_VALUE);
26762  if (a2)
26763  {
26764  if (key->op == PT_BIT_TO_BLOB ||
26765  key->op == PT_CHAR_TO_BLOB)
26766  {
26767  a2->type_enum = PT_TYPE_BLOB;
26768  }
26769  else if (key->op == PT_CHAR_TO_CLOB)
26770  {
26771  a2->type_enum = PT_TYPE_CLOB;
26772  }
26773  else if (key->op == PT_BLOB_LENGTH ||
26774  key->op == PT_CLOB_LENGTH)
26775  {
26776  a2->type_enum = PT_TYPE_BIGINT;
26777  }
26778  }
26779  */
26780  return parser_make_expression (this_parser, key->op, a1, NULL, NULL);
26781 
26782  case PT_BLOB_TO_BIT:
26783  if (c != 1)
26784  {
26785  return NULL;
26786  }
26787 
26788  a1 = args;
26789  return parser_make_expression (this_parser, key->op, a1, NULL, NULL);
26790 
26791  case PT_BLOB_FROM_FILE:
26792  case PT_CLOB_FROM_FILE:
26793  if (c != 1)
26794  {
26795  return NULL;
26796  }
26797  else
26798  {
26799  PT_NODE *node;
26800 
26801  a1 = args;
26802  a2 = parser_new_node (this_parser, PT_VALUE);
26803  if (a2)
26804  {
26805  if (key->op == PT_BLOB_FROM_FILE)
26806  {
26807  a2->type_enum = PT_TYPE_BLOB;
26808  }
26809  else if (key->op == PT_CLOB_FROM_FILE)
26810  {
26811  a2->type_enum = PT_TYPE_CLOB;
26812  }
26813  }
26814 
26815  /* Those two functions should be evaluated at the compile time */
26816  parser_cannot_cache = true;
26817  parser_cannot_prepare = true;
26818  node = parser_make_expression (this_parser, key->op, a1, a2, NULL);
26819 
26820  if (a1->node_type != PT_VALUE || a1->type_enum != PT_TYPE_CHAR)
26821  {
26822  PT_ERRORf (this_parser, node,
26823  "%s argument must be a string liternal",
26824  pt_short_print (this_parser, node));
26825  return NULL;
26826  }
26827  return node;
26828  }
26829 
26830  case PT_DECODE:
26831  {
26832  int i;
26833  PT_NODE *case_oper, *p, *q, *r, *nodep, *node, *curr, *prev;
26834  int count;
26835 
26836  if (c < 3)
26837  return NULL;
26838 
26839  case_oper = args;
26840  p = args->next;
26841  args->next = NULL;
26842  curr = p->next;
26843  p->next = NULL;
26844 
26845  node = parser_new_node (this_parser, PT_EXPR);
26846  if (node)
26847  {
26848  node->info.expr.op = PT_DECODE;
26849  q = parser_new_node (this_parser, PT_EXPR);
26850  if (q)
26851  {
26852  q->info.expr.op = PT_EQ;
26853  q->info.expr.qualifier = PT_EQ_TORDER;
26854  q->info.expr.arg1 =
26855  parser_copy_tree_list (this_parser, case_oper);
26856  q->info.expr.arg2 = p;
26857  node->info.expr.arg3 = q;
26858  PICE (q);
26859  }
26860 
26861  p = curr->next;
26862  curr->next = NULL;
26863  node->info.expr.arg1 = curr;
26864  PICE (node);
26865  }
26866 
26867  prev = node;
26868  count = parser_count_list (p);
26869  for (i = 1; i <= count; i++)
26870  {
26871  if (i % 2 == 0)
26872  {
26873  r = p->next;
26874  p->next = NULL;
26875  nodep = parser_new_node (this_parser, PT_EXPR);
26876  if (nodep)
26877  {
26878  nodep->info.expr.op = PT_DECODE;
26879  q = parser_new_node (this_parser, PT_EXPR);
26880  if (q)
26881  {
26882  q->info.expr.op = PT_EQ;
26883  q->info.expr.qualifier = PT_EQ_TORDER;
26884  q->info.expr.arg1 =
26885  parser_copy_tree_list (this_parser, case_oper);
26886  q->info.expr.arg2 = p;
26887  nodep->info.expr.arg3 = q;
26888  PICE (nodep);
26889  }
26890  nodep->info.expr.arg1 = r;
26891  nodep->info.expr.continued_case = 1;
26892  }
26893  PICE (nodep);
26894 
26895  if (prev)
26896  prev->info.expr.arg2 = nodep;
26897  PICE (prev);
26898  prev = nodep;
26899 
26900  p = r->next;
26901  r->next = NULL;
26902  }
26903  }
26904 
26905  /* default value */
26906  if (i % 2 == 0)
26907  {
26908  if (prev)
26909  prev->info.expr.arg2 = p;
26910  PICE (prev);
26911  }
26912  else if (prev && prev->info.expr.arg2 == NULL)
26913  {
26914  p = parser_new_node (this_parser, PT_VALUE);
26915  if (p)
26916  {
26917  p->type_enum = PT_TYPE_NULL;
26918  p->flag.is_added_by_parser = 1;
26919  }
26920  prev->info.expr.arg2 = p;
26921  PICE (prev);
26922  }
26923 
26924  if (case_oper)
26925  parser_free_node (this_parser, case_oper);
26926 
26927  return node;
26928  }
26929 
26930  case PT_LEAST:
26931  case PT_GREATEST:
26932  {
26933  PT_NODE *prev, *expr, *arg, *tmp;
26934  int i;
26935  arg = args;
26936 
26937  if (c < 1)
26938  return NULL;
26939 
26940  expr = parser_new_node (this_parser, PT_EXPR);
26941  if (expr)
26942  {
26943  expr->info.expr.op = key->op;
26944  expr->info.expr.arg1 = arg;
26945  expr->info.expr.arg2 = NULL;
26946  expr->info.expr.arg3 = NULL;
26947  expr->info.expr.continued_case = 1;
26948  }
26949 
26950  PICE (expr);
26951  prev = expr;
26952 
26953  if (c > 1)
26954  {
26955  tmp = arg;
26956  arg = arg->next;
26957  tmp->next = NULL;
26958 
26959  if (prev)
26960  prev->info.expr.arg2 = arg;
26961  PICE (prev);
26962  }
26963  for (i = 3; i <= c; i++)
26964  {
26965  tmp = arg;
26966  arg = arg->next;
26967  tmp->next = NULL;
26968 
26969  expr = parser_new_node (this_parser, PT_EXPR);
26970  if (expr)
26971  {
26972  expr->info.expr.op = key->op;
26973  expr->info.expr.arg1 = prev;
26974  expr->info.expr.arg2 = arg;
26975  expr->info.expr.arg3 = NULL;
26976  expr->info.expr.continued_case = 1;
26977  }
26978 
26979  if (prev && prev->info.expr.continued_case >= 1)
26980  prev->info.expr.continued_case++;
26981  PICE (expr);
26982  prev = expr;
26983  }
26984 
26985  if (expr && expr->info.expr.arg2 == NULL)
26986  {
26987  expr->info.expr.arg2 =
26988  parser_copy_tree_list (this_parser, expr->info.expr.arg1);
26989  expr->info.expr.arg2->flag.is_hidden_column = 1;
26990  }
26991 
26992  return expr;
26993  }
26994 
26995  case PT_CONCAT:
26996  case PT_CONCAT_WS:
26997  case PT_FIELD:
26998  {
26999  PT_NODE *prev, *expr, *arg, *tmp, *sep, *val;
27000  int i, ws;
27001  arg = args;
27002 
27003  ws = (key->op != PT_CONCAT) ? 1 : 0;
27004  if (c < 1 + ws)
27005  return NULL;
27006 
27007  if (key->op != PT_CONCAT)
27008  {
27009  sep = arg;
27010  arg = arg->next;
27011  }
27012  else
27013  {
27014  sep = NULL;
27015  }
27016 
27017  expr = parser_new_node (this_parser, PT_EXPR);
27018  if (expr)
27019  {
27020  expr->info.expr.op = key->op;
27021  expr->info.expr.arg1 = arg;
27022  expr->info.expr.arg2 = NULL;
27023  if (key->op == PT_FIELD && sep)
27024  {
27025  val = parser_new_node (this_parser, PT_VALUE);
27026  if (val)
27027  {
27028  val->type_enum = PT_TYPE_INTEGER;
27029  val->info.value.data_value.i = 1;
27030  val->flag.is_hidden_column = 1;
27031  }
27032  expr->info.expr.arg3 = parser_copy_tree (this_parser, sep);
27033  expr->info.expr.arg3->next = val;
27034  }
27035  else
27036  {
27037  expr->info.expr.arg3 = sep;
27038  }
27039  expr->info.expr.continued_case = 1;
27040  }
27041 
27042  PICE (expr);
27043  prev = expr;
27044 
27045  if (c > 1 + ws)
27046  {
27047  tmp = arg;
27048  arg = arg->next;
27049  tmp->next = NULL;
27050 
27051  if (prev)
27052  prev->info.expr.arg2 = arg;
27053  PICE (prev);
27054  }
27055  for (i = 3 + ws; i <= c; i++)
27056  {
27057  tmp = arg;
27058  arg = arg->next;
27059  tmp->next = NULL;
27060 
27061  expr = parser_new_node (this_parser, PT_EXPR);
27062  if (expr)
27063  {
27064  expr->info.expr.op = key->op;
27065  expr->info.expr.arg1 = prev;
27066  expr->info.expr.arg2 = arg;
27067  if (sep)
27068  {
27069  expr->info.expr.arg3 =
27070  parser_copy_tree (this_parser, sep);
27071  if (key->op == PT_FIELD)
27072  {
27073  val = parser_new_node (this_parser, PT_VALUE);
27074  if (val)
27075  {
27076  val->type_enum = PT_TYPE_INTEGER;
27077  val->info.value.data_value.i = i - ws;
27078  val->flag.is_hidden_column = 1;
27079  }
27080  expr->info.expr.arg3->next = val;
27081  }
27082  }
27083  else
27084  {
27085  expr->info.expr.arg3 = NULL;
27086  }
27087  expr->info.expr.continued_case = 1;
27088  }
27089 
27090  if (prev && prev->info.expr.continued_case >= 1)
27091  prev->info.expr.continued_case++;
27092  PICE (expr);
27093  prev = expr;
27094  }
27095 
27096  if (key->op == PT_FIELD && expr && expr->info.expr.arg2 == NULL)
27097  {
27098  val = parser_new_node (this_parser, PT_VALUE);
27099  if (val)
27100  {
27101  val->type_enum = PT_TYPE_NULL;
27102  val->flag.is_hidden_column = 1;
27103  val->flag.is_added_by_parser = 1;
27104  }
27105  expr->info.expr.arg2 = val;
27106  }
27107 
27108  return expr;
27109  }
27110 
27111  case PT_LOCATE:
27112  if (c < 2 || c > 3)
27113  return NULL;
27114 
27115  a1 = args;
27116  a2 = a1->next;
27117  if (a2)
27118  {
27119  a3 = a2->next;
27120  a2->next = NULL;
27121  }
27122  a1->next = NULL;
27123 
27124  node = parser_make_expression (this_parser, key->op, a1, a2, a3);
27125  return node;
27126 
27127  case PT_MID:
27128  if (c != 3)
27129  return NULL;
27130 
27131  a1 = args;
27132  a2 = a1->next;
27133  a3 = a2->next;
27134  a1->next = NULL;
27135  a2->next = NULL;
27136  a3->next = NULL;
27137 
27138  node = parser_make_expression (this_parser, key->op, a1, a2, a3);
27139  return node;
27140 
27141  case PT_STRCMP:
27142  if (c != 2)
27143  return NULL;
27144 
27145  a1 = args;
27146  a2 = a1->next;
27147  a1->next = NULL;
27148 
27149  node = parser_make_expression (this_parser, key->op, a1, a2, a3);
27150  return node;
27151 
27152  case PT_REVERSE:
27153  case PT_TZ_OFFSET:
27154  case PT_CONV_TZ:
27155  if (c != 1)
27156  return NULL;
27157 
27158  a1 = args;
27159  node = parser_make_expression (this_parser, key->op, a1, NULL, NULL);
27160  return node;
27161 
27162  case PT_BIT_COUNT:
27163  if (c != 1)
27164  return NULL;
27165 
27166  a1 = args;
27167  node = parser_make_expression (this_parser, key->op, a1, NULL, NULL);
27168  return node;
27169 
27170  case PT_GROUPBY_NUM:
27171  if (c != 0)
27172  return NULL;
27173 
27174  node = parser_new_node (this_parser, PT_FUNCTION);
27175 
27176  if (node)
27177  {
27178  node->info.function.function_type = PT_GROUPBY_NUM;
27179  node->info.function.arg_list = NULL;
27180  node->info.function.all_or_distinct = PT_ALL;
27181  }
27182 
27183  if (parser_groupbynum_check == 0)
27184  PT_ERRORmf2 (this_parser, node, MSGCAT_SET_PARSER_SEMANTIC,
27185  MSGCAT_SEMANTIC_INSTNUM_COMPATIBILITY_ERR,
27186  "GROUPBY_NUM()", "GROUPBY_NUM()");
27187  return node;
27188 
27189  case PT_LIST_DBS:
27190  if (c != 0)
27191  return NULL;
27192  node = parser_make_expression (this_parser, key->op, NULL, NULL, NULL);
27193  return node;
27194 
27195  case PT_SLEEP:
27196  if (c != 1)
27197  {
27198  return NULL;
27199  }
27200 
27201  a1 = args;
27202  node = parser_make_expression (this_parser, key->op, a1, NULL, NULL);
27203  if (node != NULL)
27204  {
27205  node->flag.do_not_fold = 1;
27206  }
27207 
27208  return node;
27209 
27210  default:
27211  return NULL;
27212  }
27213 
27214  return NULL;
27215 }
27216 
27217 
27218 static void
27219 resolve_alias_in_expr_node (PT_NODE * node, PT_NODE * list)
27220 {
27221  if (!node)
27222  {
27223  return;
27224  }
27225 
27226  switch (node->node_type)
27227  {
27228  case PT_SORT_SPEC:
27229  if (node->info.sort_spec.expr
27230  && node->info.sort_spec.expr->node_type == PT_NAME)
27231  {
27232  resolve_alias_in_name_node (&node->info.sort_spec.expr, list);
27233  }
27234  else
27235  {
27236  resolve_alias_in_expr_node (node->info.sort_spec.expr, list);
27237  }
27238  break;
27239 
27240  case PT_EXPR:
27241  if (node->info.expr.arg1 && node->info.expr.arg1->node_type == PT_NAME)
27242  {
27243  resolve_alias_in_name_node (&node->info.expr.arg1, list);
27244  }
27245  else
27246  {
27247  resolve_alias_in_expr_node (node->info.expr.arg1, list);
27248  }
27249  if (node->info.expr.arg2 && node->info.expr.arg2->node_type == PT_NAME)
27250  {
27251  resolve_alias_in_name_node (&node->info.expr.arg2, list);
27252  }
27253  else
27254  {
27255  resolve_alias_in_expr_node (node->info.expr.arg2, list);
27256  }
27257  if (node->info.expr.arg3 && node->info.expr.arg3->node_type == PT_NAME)
27258  {
27259  resolve_alias_in_name_node (&node->info.expr.arg3, list);
27260  }
27261  else
27262  {
27263  resolve_alias_in_expr_node (node->info.expr.arg3, list);
27264  }
27265  break;
27266 
27267  default:;
27268  }
27269 }
27270 
27271 
27272 static void
27273 resolve_alias_in_name_node (PT_NODE ** node, PT_NODE * list)
27274 {
27275  PT_NODE *col;
27276  char *n_str, *c_str;
27277  bool resolved = false;
27278 
27279  n_str = parser_print_tree (this_parser, *node);
27280 
27281  for (col = list; col; col = col->next)
27282  {
27283  if (col->node_type == PT_NAME)
27284  {
27285  c_str = parser_print_tree (this_parser, col);
27286  if (c_str == NULL)
27287  {
27288  continue;
27289  }
27290 
27291  if (intl_identifier_casecmp (n_str, c_str) == 0)
27292  {
27293  resolved = true;
27294  break;
27295  }
27296  }
27297  }
27298 
27299  if (resolved != true)
27300  {
27301  for (col = list; col; col = col->next)
27302  {
27303  if (col->alias_print
27304  && intl_identifier_casecmp (n_str, col->alias_print) == 0)
27305  {
27306  parser_free_node (this_parser, *node);
27307  *node = parser_copy_tree (this_parser, col);
27308  (*node)->next = NULL;
27309  break;
27310  }
27311  }
27312  }
27313 }
27314 
27315 static char *
27316 pt_check_identifier (PARSER_CONTEXT *parser, PT_NODE *p, const char *str,
27317  const int str_size)
27318 {
27319  char *invalid_pos = NULL;
27320  int composed_size;
27321 
27322  if (intl_check_string ((char *) str, str_size, &invalid_pos, LANG_SYS_CODESET) == INTL_UTF8_INVALID)
27323  {
27324  PT_ERRORmf (parser, NULL, MSGCAT_SET_ERROR, -(ER_INVALID_CHAR),
27325  (invalid_pos != NULL) ? invalid_pos - str : 0);
27326  return NULL;
27327  }
27328  else if (intl_identifier_fix ((char *) str, -1, true) != NO_ERROR)
27329  {
27330  PT_ERRORf (parser, p, "invalid identifier : %s", str);
27331  return NULL;
27332  }
27333 
27334  if (LANG_SYS_CODESET == INTL_CODESET_UTF8
27335  && unicode_string_need_compose (str, str_size, &composed_size,
27336  lang_get_generic_unicode_norm ()))
27337  {
27338  char *composed = NULL;
27339  bool is_composed = false;
27340 
27341  composed = parser_allocate_string_buffer (parser, composed_size + 1,
27342  sizeof (char));
27343  if (composed == NULL)
27344  {
27345  PT_ERRORf (parser, p, "cannot alloc %d bytes", composed_size + 1);
27346  return NULL;
27347  }
27348 
27349  unicode_compose_string (str, str_size, composed, &composed_size,
27350  &is_composed, lang_get_generic_unicode_norm ());
27351  composed[composed_size] = '\0';
27352  assert (composed_size <= str_size);
27353 
27354  if (is_composed)
27355  {
27356  return composed;
27357  }
27358  }
27359 
27360  return (char *)str;
27361 }
27362 
27363 static PT_NODE *
27364 pt_create_char_string_literal (PARSER_CONTEXT *parser, const PT_TYPE_ENUM char_type,
27365  const char *str, const INTL_CODESET codeset)
27366 {
27367  int str_size = strlen (str);
27368  PT_NODE *node = NULL;
27369  char *invalid_pos = NULL;
27370  int composed_size;
27371 
27372  if (intl_check_string (str, str_size, &invalid_pos, codeset) != INTL_UTF8_VALID)
27373  {
27374  PT_ERRORmf (parser, NULL,
27375  MSGCAT_SET_ERROR, -(ER_INVALID_CHAR),
27376  (invalid_pos != NULL) ? invalid_pos - str : 0);
27377  }
27378 
27379  if (codeset == INTL_CODESET_UTF8
27380  && unicode_string_need_compose (str, str_size, &composed_size,
27381  lang_get_generic_unicode_norm ()))
27382  {
27383  char *composed = NULL;
27384  bool is_composed = false;
27385 
27386  composed = parser_allocate_string_buffer (parser, composed_size + 1,
27387  sizeof (char));
27388 
27389  if (composed != NULL)
27390  {
27391  unicode_compose_string (str, str_size, composed, &composed_size,
27392  &is_composed, lang_get_generic_unicode_norm ());
27393  composed[composed_size] = '\0';
27394 
27395  assert (composed_size <= str_size);
27396 
27397  if (is_composed)
27398  {
27399  str = composed;
27400  str_size = composed_size;
27401  }
27402  }
27403  else
27404  {
27405  str = NULL;
27406  PT_ERRORf (parser, NULL, "cannot alloc %d bytes", composed_size + 1);
27407  }
27408  }
27409 
27410  node = parser_new_node (parser, PT_VALUE);
27411  if (node)
27412  {
27413  unsigned char *string;
27414  int length;
27415 
27416  node->info.value.data_value.str = pt_append_bytes (parser, NULL, str, str_size);
27417  string = node->info.value.data_value.str->bytes;
27418  length = node->info.value.data_value.str->length;
27419 
27420  node->type_enum = char_type;
27421  if (string)
27422  {
27423  if (string[length - 1] == 0x20)
27424  {
27425  if (char_type == PT_TYPE_CHAR)
27426  {
27427  node->type_enum = PT_TYPE_VARCHAR;
27428  }
27429  else if (char_type == PT_TYPE_NCHAR)
27430  {
27431  node->type_enum = PT_TYPE_VARNCHAR;
27432  }
27433  }
27434  }
27435 
27436  if (char_type == PT_TYPE_NCHAR)
27437  {
27438  node->info.value.string_type = 'N';
27439  }
27440  else
27441  {
27442  node->info.value.string_type = ' ';
27443  }
27444 
27445  PT_NODE_PRINT_VALUE_TO_TEXT (parser, node);
27446  }
27447 
27448  return node;
27449 }
27450 
27451 static PT_NODE *
27452 pt_create_date_value (PARSER_CONTEXT *parser, const PT_TYPE_ENUM type,
27453  const char *str)
27454 {
27455  PT_NODE *node = NULL;
27456 
27457  node = parser_new_node (parser, PT_VALUE);
27458 
27459  if (node)
27460  {
27461  node->type_enum = type;
27462 
27463  node->info.value.data_value.str = pt_append_bytes (parser, NULL, str, strlen (str));
27464  PT_NODE_PRINT_VALUE_TO_TEXT (parser, node);
27465  }
27466 
27467  return node;
27468 }
27469 
27470 static void
27471 pt_value_set_charset_coll (PARSER_CONTEXT *parser, PT_NODE *node,
27472  const int codeset_id, const int collation_id,
27473  bool force)
27474 {
27475  PT_NODE *dt = NULL;
27476 
27477  assert (node->node_type == PT_VALUE);
27478  assert (PT_HAS_COLLATION (node->type_enum));
27479  assert (node->data_type == NULL);
27480 
27481  if (!force && codeset_id == LANG_SYS_CODESET
27482  && collation_id == LANG_SYS_COLLATION)
27483  {
27484  /* not necessary to add a new node, by default constants get the
27485  * coercible (system) charset and collation */
27486  return;
27487  }
27488 
27489  dt = parser_new_node (parser, PT_DATA_TYPE);
27490  if (dt)
27491  {
27492  dt->type_enum = node->type_enum;
27493  dt->info.data_type.precision = TP_FLOATING_PRECISION_VALUE;
27494  dt->info.data_type.units = codeset_id;
27495  dt->info.data_type.collation_id = collation_id;
27496 
27497  node->data_type = dt;
27498  if (collation_id != LANG_GET_BINARY_COLLATION (codeset_id))
27499  {
27500  assert (collation_id != LANG_SYS_COLLATION);
27501  node->info.value.print_collation = true;
27502  }
27503  }
27504 }
27505 
27506 static void
27507 pt_value_set_collation_info (PARSER_CONTEXT *parser, PT_NODE *node,
27508  PT_NODE *coll_node)
27509 {
27510  LANG_COLLATION *lang_coll = NULL;
27511 
27512  if (node == NULL)
27513  {
27514  return;
27515  }
27516 
27517  assert (node->node_type == PT_VALUE);
27518 
27519  if (node->data_type != NULL
27520  && node->data_type->info.data_type.units != LANG_SYS_CODESET)
27521  {
27522  assert (node->node_type == PT_VALUE);
27523  assert (PT_HAS_COLLATION (node->type_enum));
27524 
27525  node->info.value.print_charset = true;
27526  }
27527 
27528  /* coll_node is the optional collation specified by user with COLLATE */
27529  if (coll_node == NULL)
27530  {
27531  int client_collation = lang_get_client_collation ();
27532 
27533  if (client_collation == LANG_SYS_COLLATION)
27534  {
27535  /* no need for collation info */
27536  return;
27537  }
27538  else
27539  {
27540  lang_coll = lang_get_collation (client_collation);
27541  assert (lang_coll != NULL);
27542  }
27543  }
27544  else
27545  {
27546  assert (coll_node->node_type == PT_VALUE);
27547 
27548  assert (coll_node->info.value.data_value.str != NULL);
27549  lang_coll = lang_get_collation_by_name ((const char *) coll_node->info.value.data_value.str->bytes);
27550  }
27551 
27552  if (lang_coll != NULL)
27553  {
27554  if (node->data_type != NULL)
27555  {
27556  /* check charset-collation compatibility */
27557  if (lang_coll->codeset != node->data_type->info.data_type.units)
27558  {
27559  /* set an error only when charset and collation given by user
27560  are not compatible */
27561  if (coll_node != NULL)
27562  {
27563  if (!node->info.value.has_cs_introducer)
27564  {
27565  node->data_type->info.data_type.units =
27566  lang_coll->codeset;
27567  node->data_type->info.data_type.collation_id =
27568  lang_coll->coll.coll_id;
27569  }
27570  else
27571  {
27572  PT_ERRORm (parser, coll_node, MSGCAT_SET_PARSER_SEMANTIC,
27573  MSGCAT_SEMANTIC_INCOMPATIBLE_CS_COLL);
27574  return;
27575  }
27576  }
27577  else
27578  {
27579  /* COLLATE was not specified: leave the default collation of
27580  charset set by charset introducer */
27581  assert (node->info.value.print_collation == false);
27582 
27583  return;
27584  }
27585  }
27586  else
27587  {
27588  node->data_type->info.data_type.collation_id = lang_coll->coll.coll_id;
27589 
27590  if (LANG_GET_BINARY_COLLATION (node->data_type->info.data_type.units)
27591  == lang_coll->coll.coll_id)
27592  {
27593  /* do not print collation */
27594  return;
27595  }
27596  }
27597  }
27598  else
27599  {
27600  pt_value_set_charset_coll (parser, node, lang_coll->codeset,
27601  lang_coll->coll.coll_id, false);
27602  }
27603  }
27604  else
27605  {
27606  PT_ERRORmf (parser, coll_node, MSGCAT_SET_PARSER_SEMANTIC,
27607  MSGCAT_SEMANTIC_UNKNOWN_COLL,
27608  coll_node->info.value.data_value.str->bytes);
27609  return;
27610  }
27611 
27612  node->info.value.print_collation = true;
27613 }
27614 
27615 static void
27616 pt_value_set_monetary (PARSER_CONTEXT *parser, PT_NODE *node,
27617  const char *currency_str, const char *value, DB_CURRENCY type)
27618 {
27619  double dval;
27620 
27621  assert (node != NULL);
27622  assert (node->node_type == PT_VALUE);
27623  assert (value != NULL);
27624 
27625  errno = 0;
27626  dval = strtod (value, NULL);
27627  if (errno == ERANGE)
27628  {
27629  PT_ERRORmf2 (parser, node, MSGCAT_SET_PARSER_SYNTAX,
27630  MSGCAT_SYNTAX_FLT_DBL_OVERFLOW, value, pt_show_type_enum (PT_TYPE_MONETARY));
27631  }
27632 
27633  node->info.value.data_value.money.type = type;
27634  node->info.value.text = pt_append_string (parser, currency_str, value);
27635  node->type_enum = PT_TYPE_MONETARY;
27636  node->info.value.data_value.money.amount = dval;
27637 
27638  return;
27639 }
27640 
27641 static PT_NODE *
27642 pt_set_collation_modifier (PARSER_CONTEXT *parser, PT_NODE *node,
27643  PT_NODE *coll_node)
27644 {
27645  LANG_COLLATION *lang_coll = NULL;
27646  bool do_wrap_with_cast = false;
27647 
27648  assert (coll_node != NULL);
27649  assert (coll_node->node_type == PT_VALUE);
27650 
27651  assert (coll_node->info.value.data_value.str != NULL);
27652  lang_coll = lang_get_collation_by_name ((const char *) coll_node->info.value.data_value.str->bytes);
27653 
27654  if (lang_coll == NULL)
27655  {
27656  PT_ERRORmf (parser, coll_node, MSGCAT_SET_PARSER_SEMANTIC,
27657  MSGCAT_SEMANTIC_UNKNOWN_COLL, coll_node->info.value.data_value.str->bytes);
27658  return node;
27659  }
27660 
27661  if (node->node_type == PT_VALUE)
27662  {
27663  if (!(PT_HAS_COLLATION (node->type_enum)))
27664  {
27665  PT_ERRORm (parser, coll_node, MSGCAT_SET_PARSER_SEMANTIC,
27666  MSGCAT_SEMANTIC_COLLATE_NOT_ALLOWED);
27667  return node;
27668  }
27669  PT_SET_NODE_COLL_MODIFIER (node, lang_coll->coll.coll_id);
27670  pt_value_set_collation_info (parser, node, coll_node);
27671  }
27672  else if (node->node_type == PT_EXPR)
27673  {
27674  if (node->info.expr.op == PT_EVALUATE_VARIABLE || node->info.expr.op == PT_DEFINE_VARIABLE)
27675  {
27676  PT_ERRORm (parser, coll_node, MSGCAT_SET_PARSER_SEMANTIC, MSGCAT_SEMANTIC_COLLATE_NOT_ALLOWED);
27677  return node;
27678  }
27679  else if (node->info.expr.op == PT_CAST
27680  && PT_EXPR_INFO_IS_FLAGED (node, PT_EXPR_INFO_CAST_COLL_MODIFIER))
27681  {
27682  LANG_COLLATION *lc_node = lang_get_collation (PT_GET_COLLATION_MODIFIER (node));
27683  if (lc_node->codeset != lang_coll->codeset)
27684  {
27685  PT_ERRORmf2 (parser, node, MSGCAT_SET_PARSER_SEMANTIC, MSGCAT_SEMANTIC_CS_MATCH_COLLATE,
27686  lang_get_codeset_name (lc_node->codeset),
27687  lang_get_codeset_name (lang_coll->codeset));
27688  return node;
27689  }
27690  }
27691  PT_SET_NODE_COLL_MODIFIER (node, lang_coll->coll.coll_id);
27692  if (!pt_is_comp_op (node->info.expr.op))
27693  {
27694  do_wrap_with_cast = true;
27695  }
27696  }
27697  else if (node->node_type == PT_NAME || node->node_type == PT_DOT_ || node->node_type == PT_FUNCTION)
27698  {
27699  PT_SET_NODE_COLL_MODIFIER (node, lang_coll->coll.coll_id);
27700  do_wrap_with_cast = true;
27701  }
27702  else
27703  {
27704  PT_ERRORm (parser, node, MSGCAT_SET_PARSER_SEMANTIC, MSGCAT_SEMANTIC_COLLATE_NOT_ALLOWED);
27705  assert (do_wrap_with_cast == false);
27706  }
27707 
27708  if (do_wrap_with_cast)
27709  {
27710  PT_NODE *cast_expr = parser_make_expression (parser, PT_CAST, node, NULL, NULL);
27711  if (cast_expr != NULL)
27712  {
27713  cast_expr->info.expr.cast_type = NULL;
27714  PT_EXPR_INFO_SET_FLAG (cast_expr, PT_EXPR_INFO_CAST_COLL_MODIFIER);
27715  node = cast_expr;
27716  PT_SET_NODE_COLL_MODIFIER (cast_expr, lang_coll->coll.coll_id);
27717  }
27718  }
27719 
27720  return node;
27721 }
27722 
27723 static PT_NODE *
27724 pt_create_json_value (PARSER_CONTEXT *parser, const char *str)
27725 {
27726  PT_NODE *node = NULL;
27727 
27728  node = parser_new_node (parser, PT_VALUE);
27729  if (node)
27730  {
27731  node->type_enum = PT_TYPE_JSON;
27732 
27733  node->info.value.data_value.str = pt_append_bytes (parser, NULL, str, strlen (str));
27734  PT_NODE_PRINT_VALUE_TO_TEXT (parser, node);
27735  }
27736 
27737  return node;
27738 }
27739 
27740 static void
27741 pt_jt_append_column_or_nested_node (PT_NODE * jt_node, PT_NODE * jt_col_or_nested)
27742 {
27743  assert (jt_node != NULL && jt_node->node_type == PT_JSON_TABLE_NODE);
27744  assert (jt_col_or_nested != NULL);
27745 
27746  if (jt_col_or_nested->node_type == PT_JSON_TABLE_COLUMN)
27747  {
27748  jt_col_or_nested->info.json_table_column_info.index = json_table_column_count++;
27749  jt_node->info.json_table_node_info.columns =
27750  parser_append_node (jt_col_or_nested, jt_node->info.json_table_node_info.columns);
27751  }
27752  else
27753  {
27754  assert (jt_col_or_nested->node_type == PT_JSON_TABLE_NODE);
27755  jt_node->info.json_table_node_info.nested_paths =
27756  parser_append_node (jt_col_or_nested, jt_node->info.json_table_node_info.nested_paths);
27757  }
27758 }
27759 
27760 static PT_NODE *
27761 pt_create_paren_expr_list (PT_NODE * exp)
27762 {
27763  PT_NODE *val, *tmp;
27764 
27765  if (exp && exp->next == NULL)
27766  {
27767  if (exp->node_type == PT_EXPR)
27768  {
27769  exp->info.expr.paren_type = 1;
27770  }
27771  exp->flag.is_paren = 1;
27772  }
27773  else
27774  {
27775  val = parser_new_node (this_parser, PT_VALUE);
27776  if (val)
27777  {
27778  for (tmp = exp; tmp; tmp = tmp->next)
27779  {
27780  if (tmp->node_type == PT_VALUE && tmp->type_enum == PT_TYPE_EXPR_SET)
27781  {
27782  tmp->type_enum = PT_TYPE_SEQUENCE;
27783  }
27784  }
27785 
27786  val->info.value.data_value.set = exp;
27787  val->type_enum = PT_TYPE_EXPR_SET;
27788  }
27789  exp = val;
27790  parser_groupby_exception = PT_EXPR;
27791  }
27792  return exp;
27793 }