1 /* header */
2 /* src/interfaces/ecpg/preproc/ecpg.header */
3
4 /* Copyright comment */
5 %{
6 #include "postgres_fe.h"
7
8 #include "preproc_extern.h"
9 #include "ecpg_config.h"
10 #include <unistd.h>
11
12 /* Location tracking support --- simpler than bison's default */
13 #define YYLLOC_DEFAULT(Current, Rhs, N) \
14 do { \
15 if (N) \
16 (Current) = (Rhs)[1]; \
17 else \
18 (Current) = (Rhs)[0]; \
19 } while (0)
20
21 /*
22 * The %name-prefix option below will make bison call base_yylex, but we
23 * really want it to call filtered_base_yylex (see parser.c).
24 */
25 #define base_yylex filtered_base_yylex
26
27 /*
28 * This is only here so the string gets into the POT. Bison uses it
29 * internally.
30 */
31 #define bison_gettext_dummy gettext_noop("syntax error")
32
33 /*
34 * Variables containing simple states.
35 */
36 int struct_level = 0;
37 int braces_open; /* brace level counter */
38 char *current_function;
39 int ecpg_internal_var = 0;
40 char *connection = NULL;
41 char *input_filename = NULL;
42
43 static int FoundInto = 0;
44 static int initializer = 0;
45 static int pacounter = 1;
46 static char pacounter_buffer[sizeof(int) * CHAR_BIT * 10 / 3]; /* a rough guess at the size we need */
47 static struct this_type actual_type[STRUCT_DEPTH];
48 static char *actual_startline[STRUCT_DEPTH];
49 static int varchar_counter = 1;
50 static int bytea_counter = 1;
51
52 /* temporarily store struct members while creating the data structure */
53 struct ECPGstruct_member *struct_member_list[STRUCT_DEPTH] = { NULL };
54
55 /* also store struct type so we can do a sizeof() later */
56 static char *ECPGstruct_sizeof = NULL;
57
58 /* for forward declarations we have to store some data as well */
59 static char *forward_name = NULL;
60
61 struct ECPGtype ecpg_no_indicator = {ECPGt_NO_INDICATOR, NULL, NULL, NULL, {NULL}, 0};
62 struct variable no_indicator = {"no_indicator", &ecpg_no_indicator, 0, NULL};
63
64 static struct ECPGtype ecpg_query = {ECPGt_char_variable, NULL, NULL, NULL, {NULL}, 0};
65
66 static void vmmerror(int error_code, enum errortype type, const char *error, va_list ap) pg_attribute_printf(3, 0);
67
68 /*
69 * Handle parsing errors and warnings
70 */
71 static void
72 vmmerror(int error_code, enum errortype type, const char *error, va_list ap)
73 {
74 /* localize the error message string */
75 error = _(error);
76
77 fprintf(stderr, "%s:%d: ", input_filename, base_yylineno);
78
79 switch(type)
80 {
81 case ET_WARNING:
82 fprintf(stderr, _("WARNING: "));
83 break;
84 case ET_ERROR:
85 fprintf(stderr, _("ERROR: "));
86 break;
87 }
88
89 vfprintf(stderr, error, ap);
90
91 fprintf(stderr, "\n");
92
93 switch(type)
94 {
95 case ET_WARNING:
96 break;
97 case ET_ERROR:
get_one_option(int optid,const struct my_option *,char *)98 ret_value = error_code;
99 break;
100 }
101 }
102
103 void
104 mmerror(int error_code, enum errortype type, const char *error, ...)
105 {
106 va_list ap;
107
108 va_start(ap, error);
109 vmmerror(error_code, type, error, ap);
110 va_end(ap);
111 }
die(const char * fmt,...)112
113 void
114 mmfatal(int error_code, const char *error, ...)
115 {
116 va_list ap;
117
118 va_start(ap, error);
119 vmmerror(error_code, ET_ERROR, error, ap);
120 va_end(ap);
121
122 if (base_yyin)
123 fclose(base_yyin);
124 if (base_yyout)
125 fclose(base_yyout);
126
127 if (strcmp(output_filename, "-") != 0 && unlink(output_filename) != 0)
128 fprintf(stderr, _("could not remove output file \"%s\"\n"), output_filename);
129 exit(error_code);
130 }
131
132 /*
133 * string concatenation
134 */
135
136 static char *
verbose(const char * fmt,...)137 cat2_str(char *str1, char *str2)
138 {
139 char * res_str = (char *)mm_alloc(strlen(str1) + strlen(str2) + 2);
140
141 strcpy(res_str, str1);
142 if (strlen(str1) != 0 && strlen(str2) != 0)
143 strcat(res_str, " ");
144 strcat(res_str, str2);
145 free(str1);
146 free(str2);
147 return res_str;
148 }
149
150 static char *
151 cat_str(int count, ...)
152 {
main(int argc,char ** argv)153 va_list args;
154 int i;
155 char *res_str;
156
157 va_start(args, count);
158
159 res_str = va_arg(args, char *);
160
161 /* now add all other strings */
162 for (i = 1; i < count; i++)
163 res_str = cat2_str(res_str, va_arg(args, char *));
164
165 va_end(args);
166
167 return res_str;
168 }
169
170 static char *
171 make2_str(char *str1, char *str2)
172 {
173 char * res_str = (char *)mm_alloc(strlen(str1) + strlen(str2) + 1);
174
175 strcpy(res_str, str1);
176 strcat(res_str, str2);
177 free(str1);
178 free(str2);
179 return res_str;
180 }
181
182 static char *
183 make3_str(char *str1, char *str2, char *str3)
184 {
185 char * res_str = (char *)mm_alloc(strlen(str1) + strlen(str2) +strlen(str3) + 1);
186
187 strcpy(res_str, str1);
188 strcat(res_str, str2);
189 strcat(res_str, str3);
190 free(str1);
191 free(str2);
192 free(str3);
193 return res_str;
194 }
195
196 /* and the rest */
197 static char *
198 make_name(void)
199 {
200 return mm_strdup(base_yytext);
201 }
202
203 static char *
204 create_questionmarks(char *name, bool array)
205 {
206 struct variable *p = find_variable(name);
207 int count;
208 char *result = EMPTY;
209
210 /* In case we have a struct, we have to print as many "?" as there are attributes in the struct
convert_slashes(char * s)211 * An array is only allowed together with an element argument
212 * This is essentially only used for inserts, but using a struct as input parameter is an error anywhere else
213 * so we don't have to worry here. */
214
215 if (p->type->type == ECPGt_struct || (array && p->type->type == ECPGt_array && p->type->u.element->type == ECPGt_struct))
216 {
217 struct ECPGstruct_member *m;
218
219 if (p->type->type == ECPGt_struct)
220 m = p->type->u.members;
221 else
222 m = p->type->u.element->u.members;
223
224 for (count = 0; m != NULL; m=m->next, count++);
225 }
226 else
227 count = 1;
228
229 for (; count > 0; count --)
230 {
231 sprintf(pacounter_buffer, "$%d", pacounter++);
232 result = cat_str(3, result, mm_strdup(pacounter_buffer), mm_strdup(" , "));
233 }
234
235 /* removed the trailing " ," */
236
237 result[strlen(result)-3] = '\0';
238 return result;
239 }
240
241 static char *
get_plugindir()242 adjust_outofscope_cursor_vars(struct cursor *cur)
243 {
244 /* Informix accepts DECLARE with variables that are out of scope when OPEN is called.
245 * For instance you can DECLARE a cursor in one function, and OPEN/FETCH/CLOSE
246 * it in another functions. This is very useful for e.g. event-driver programming,
247 * but may also lead to dangerous programming. The limitation when this is allowed
248 * and doesn't cause problems have to be documented, like the allocated variables
249 * must not be realloc()'ed.
250 *
251 * We have to change the variables to our own struct and just store the pointer
252 * instead of the variable. Do it only for local variables, not for globals.
253 */
254
255 char *result = EMPTY;
256 int insert;
257
258 for (insert = 1; insert >= 0; insert--)
259 {
260 struct arguments *list;
261 struct arguments *ptr;
262 struct arguments *newlist = NULL;
263 struct variable *newvar, *newind;
264
265 list = (insert ? cur->argsinsert : cur->argsresult);
266
267 for (ptr = list; ptr != NULL; ptr = ptr->next)
268 {
269 char var_text[20];
270 char *original_var;
271 bool skip_set_var = false;
272 bool var_ptr = false;
273
274 /* change variable name to "ECPGget_var(<counter>)" */
275 original_var = ptr->variable->name;
276 sprintf(var_text, "%d))", ecpg_internal_var);
277
278 /* Don't emit ECPGset_var() calls for global variables */
279 if (ptr->variable->brace_level == 0)
280 {
281 newvar = ptr->variable;
282 skip_set_var = true;
283 }
284 else if ((ptr->variable->type->type == ECPGt_char_variable)
285 && (strncmp(ptr->variable->name, "ECPGprepared_statement", strlen("ECPGprepared_statement")) == 0))
286 {
287 newvar = ptr->variable;
288 skip_set_var = true;
289 }
290 else if ((ptr->variable->type->type != ECPGt_varchar
291 && ptr->variable->type->type != ECPGt_char
292 && ptr->variable->type->type != ECPGt_unsigned_char
293 && ptr->variable->type->type != ECPGt_string
294 && ptr->variable->type->type != ECPGt_bytea)
295 && atoi(ptr->variable->type->size) > 1)
296 {
297 newvar = new_variable(cat_str(4, mm_strdup("("),
298 mm_strdup(ecpg_type_name(ptr->variable->type->u.element->type)),
299 mm_strdup(" *)(ECPGget_var("),
300 mm_strdup(var_text)),
301 ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type,
302 mm_strdup("1"),
303 ptr->variable->type->u.element->counter),
304 ptr->variable->type->size),
305 0);
306 }
307 else if ((ptr->variable->type->type == ECPGt_varchar
308 || ptr->variable->type->type == ECPGt_char
309 || ptr->variable->type->type == ECPGt_unsigned_char
310 || ptr->variable->type->type == ECPGt_string
311 || ptr->variable->type->type == ECPGt_bytea)
312 && atoi(ptr->variable->type->size) > 1)
313 {
314 newvar = new_variable(cat_str(4, mm_strdup("("),
315 mm_strdup(ecpg_type_name(ptr->variable->type->type)),
316 mm_strdup(" *)(ECPGget_var("),
317 mm_strdup(var_text)),
318 ECPGmake_simple_type(ptr->variable->type->type,
319 ptr->variable->type->size,
320 ptr->variable->type->counter),
321 0);
322 if (ptr->variable->type->type == ECPGt_varchar ||
323 ptr->variable->type->type == ECPGt_bytea)
324 var_ptr = true;
325 }
326 else if (ptr->variable->type->type == ECPGt_struct
327 || ptr->variable->type->type == ECPGt_union)
328 {
329 newvar = new_variable(cat_str(5, mm_strdup("(*("),
330 mm_strdup(ptr->variable->type->type_name),
331 mm_strdup(" *)(ECPGget_var("),
332 mm_strdup(var_text),
333 mm_strdup(")")),
334 ECPGmake_struct_type(ptr->variable->type->u.members,
335 ptr->variable->type->type,
336 ptr->variable->type->type_name,
337 ptr->variable->type->struct_sizeof),
338 0);
339 var_ptr = true;
340 }
341 else if (ptr->variable->type->type == ECPGt_array)
342 {
343 if (ptr->variable->type->u.element->type == ECPGt_struct
344 || ptr->variable->type->u.element->type == ECPGt_union)
345 {
346 newvar = new_variable(cat_str(5, mm_strdup("(*("),
347 mm_strdup(ptr->variable->type->u.element->type_name),
348 mm_strdup(" *)(ECPGget_var("),
349 mm_strdup(var_text),
350 mm_strdup(")")),
351 ECPGmake_struct_type(ptr->variable->type->u.element->u.members,
352 ptr->variable->type->u.element->type,
353 ptr->variable->type->u.element->type_name,
354 ptr->variable->type->u.element->struct_sizeof),
355 0);
356 }
357 else
358 {
359 newvar = new_variable(cat_str(4, mm_strdup("("),
360 mm_strdup(ecpg_type_name(ptr->variable->type->u.element->type)),
361 mm_strdup(" *)(ECPGget_var("),
362 mm_strdup(var_text)),
363 ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type,
364 ptr->variable->type->u.element->size,
365 ptr->variable->type->u.element->counter),
366 ptr->variable->type->size),
367 0);
368 var_ptr = true;
369 }
370 }
371 else
372 {
373 newvar = new_variable(cat_str(4, mm_strdup("*("),
374 mm_strdup(ecpg_type_name(ptr->variable->type->type)),
375 mm_strdup(" *)(ECPGget_var("),
376 mm_strdup(var_text)),
377 ECPGmake_simple_type(ptr->variable->type->type,
378 ptr->variable->type->size,
379 ptr->variable->type->counter),
380 0);
381 var_ptr = true;
382 }
383
384 /* create call to "ECPGset_var(<counter>, <connection>, <pointer>. <line number>)" */
385 if (!skip_set_var)
386 {
387 sprintf(var_text, "%d, %s", ecpg_internal_var++, var_ptr ? "&(" : "(");
388 result = cat_str(5, result, mm_strdup("ECPGset_var("),
389 mm_strdup(var_text), mm_strdup(original_var),
390 mm_strdup("), __LINE__);\n"));
391 }
392
393 /* now the indicator if there is one and it's not a global variable */
394 if ((ptr->indicator->type->type == ECPGt_NO_INDICATOR) || (ptr->indicator->brace_level == 0))
395 {
396 newind = ptr->indicator;
397 }
398 else
399 {
400 /* change variable name to "ECPGget_var(<counter>)" */
401 original_var = ptr->indicator->name;
402 sprintf(var_text, "%d))", ecpg_internal_var);
403 var_ptr = false;
404
405 if (ptr->indicator->type->type == ECPGt_struct
406 || ptr->indicator->type->type == ECPGt_union)
407 {
408 newind = new_variable(cat_str(5, mm_strdup("(*("),
409 mm_strdup(ptr->indicator->type->type_name),
410 mm_strdup(" *)(ECPGget_var("),
411 mm_strdup(var_text),
412 mm_strdup(")")),
413 ECPGmake_struct_type(ptr->indicator->type->u.members,
414 ptr->indicator->type->type,
415 ptr->indicator->type->type_name,
416 ptr->indicator->type->struct_sizeof),
417 0);
418 var_ptr = true;
419 }
420 else if (ptr->indicator->type->type == ECPGt_array)
421 {
422 if (ptr->indicator->type->u.element->type == ECPGt_struct
423 || ptr->indicator->type->u.element->type == ECPGt_union)
424 {
425 newind = new_variable(cat_str(5, mm_strdup("(*("),
426 mm_strdup(ptr->indicator->type->u.element->type_name),
427 mm_strdup(" *)(ECPGget_var("),
428 mm_strdup(var_text),
429 mm_strdup(")")),
430 ECPGmake_struct_type(ptr->indicator->type->u.element->u.members,
431 ptr->indicator->type->u.element->type,
432 ptr->indicator->type->u.element->type_name,
433 ptr->indicator->type->u.element->struct_sizeof),
434 0);
435 }
436 else
437 {
438 newind = new_variable(cat_str(4, mm_strdup("("),
439 mm_strdup(ecpg_type_name(ptr->indicator->type->u.element->type)),
440 mm_strdup(" *)(ECPGget_var("), mm_strdup(var_text)),
441 ECPGmake_array_type(ECPGmake_simple_type(ptr->indicator->type->u.element->type,
442 ptr->indicator->type->u.element->size,
443 ptr->indicator->type->u.element->counter),
444 ptr->indicator->type->size),
445 0);
446 var_ptr = true;
447 }
448 }
449 else if (atoi(ptr->indicator->type->size) > 1)
450 {
451 newind = new_variable(cat_str(4, mm_strdup("("),
452 mm_strdup(ecpg_type_name(ptr->indicator->type->type)),
453 mm_strdup(" *)(ECPGget_var("),
454 mm_strdup(var_text)),
455 ECPGmake_simple_type(ptr->indicator->type->type,
456 ptr->indicator->type->size,
457 ptr->variable->type->counter),
458 0);
459 }
460 else
461 {
462 newind = new_variable(cat_str(4, mm_strdup("*("),
463 mm_strdup(ecpg_type_name(ptr->indicator->type->type)),
464 mm_strdup(" *)(ECPGget_var("),
465 mm_strdup(var_text)),
466 ECPGmake_simple_type(ptr->indicator->type->type,
467 ptr->indicator->type->size,
468 ptr->variable->type->counter),
469 0);
470 var_ptr = true;
471 }
472
473 /* create call to "ECPGset_var(<counter>, <pointer>. <line number>)" */
474 sprintf(var_text, "%d, %s", ecpg_internal_var++, var_ptr ? "&(" : "(");
475 result = cat_str(5, result, mm_strdup("ECPGset_var("),
476 mm_strdup(var_text), mm_strdup(original_var),
477 mm_strdup("), __LINE__);\n"));
478 }
479
480 add_variable_to_tail(&newlist, newvar, newind);
481 }
482
483 if (insert)
484 cur->argsinsert_oos = newlist;
485 else
486 cur->argsresult_oos = newlist;
487 }
488
489 return result;
490 }
491
492 /* This tests whether the cursor was declared and opened in the same function. */
493 #define SAMEFUNC(cur) \
494 ((cur->function == NULL) || \
495 (cur->function != NULL && strcmp(cur->function, current_function) == 0))
496
497 static struct cursor *
498 add_additional_variables(char *name, bool insert)
499 {
500 struct cursor *ptr;
501 struct arguments *p;
502 int (* strcmp_fn)(const char *, const char *) = ((name[0] == ':' || name[0] == '"') ? strcmp : pg_strcasecmp);
503
504 for (ptr = cur; ptr != NULL; ptr=ptr->next)
505 {
506 if (strcmp_fn(ptr->name, name) == 0)
507 break;
508 }
509
510 if (ptr == NULL)
511 {
512 mmerror(PARSE_ERROR, ET_ERROR, "cursor \"%s\" does not exist", name);
513 return NULL;
514 }
515
516 if (insert)
517 {
518 /* add all those input variables that were given earlier
519 * note that we have to append here but have to keep the existing order */
520 for (p = (SAMEFUNC(ptr) ? ptr->argsinsert : ptr->argsinsert_oos); p; p = p->next)
521 add_variable_to_tail(&argsinsert, p->variable, p->indicator);
522 }
523
524 /* add all those output variables that were given earlier */
525 for (p = (SAMEFUNC(ptr) ? ptr->argsresult : ptr->argsresult_oos); p; p = p->next)
526 add_variable_to_tail(&argsresult, p->variable, p->indicator);
527
528 return ptr;
create_db_instance()529 }
530
531 static void
532 add_typedef(char *name, char *dimension, char *length, enum ECPGttype type_enum,
533 char *type_dimension, char *type_index, int initializer, int array)
534 {
535 /* add entry to list */
536 struct typedefs *ptr, *this;
537
538 if ((type_enum == ECPGt_struct ||
539 type_enum == ECPGt_union) &&
540 initializer == 1)
541 mmerror(PARSE_ERROR, ET_ERROR, "initializer not allowed in type definition");
542 else if (INFORMIX_MODE && strcmp(name, "string") == 0)
543 mmerror(PARSE_ERROR, ET_ERROR, "type name \"string\" is reserved in Informix mode");
544 else
545 {
546 for (ptr = types; ptr != NULL; ptr = ptr->next)
547 {
548 if (strcmp(name, ptr->name) == 0)
549 /* re-definition is a bug */
550 mmerror(PARSE_ERROR, ET_ERROR, "type \"%s\" is already defined", name);
551 }
552 adjust_array(type_enum, &dimension, &length, type_dimension, type_index, array, true);
553
554 this = (struct typedefs *) mm_alloc(sizeof(struct typedefs));
555
556 /* initial definition */
557 this->next = types;
558 this->name = name;
559 this->brace_level = braces_open;
560 this->type = (struct this_type *) mm_alloc(sizeof(struct this_type));
561 this->type->type_enum = type_enum;
562 this->type->type_str = mm_strdup(name);
563 this->type->type_dimension = dimension; /* dimension of array */
564 this->type->type_index = length; /* length of string */
565 this->type->type_sizeof = ECPGstruct_sizeof;
566 this->struct_member_list = (type_enum == ECPGt_struct || type_enum == ECPGt_union) ?
567 ECPGstruct_member_dup(struct_member_list[struct_level]) : NULL;
568
569 if (type_enum != ECPGt_varchar &&
570 type_enum != ECPGt_bytea &&
571 type_enum != ECPGt_char &&
572 type_enum != ECPGt_unsigned_char &&
573 type_enum != ECPGt_string &&
574 atoi(this->type->type_index) >= 0)
575 mmerror(PARSE_ERROR, ET_ERROR, "multidimensional arrays for simple data types are not supported");
576
577 types = this;
578 }
579 }
580 %}
581
582 %expect 0
583 %name-prefix="base_yy"
584 %locations
585
586 %union {
587 double dval;
588 char *str;
589 int ival;
590 struct when action;
591 struct index index;
592 int tagname;
593 struct this_type type;
594 enum ECPGttype type_enum;
595 enum ECPGdtype dtype_enum;
596 struct fetch_desc descriptor;
597 struct su_symbol struct_union;
598 struct prep prep;
599 struct exec exec;
600 }
601 /* tokens */
602 /* src/interfaces/ecpg/preproc/ecpg.tokens */
603
604 /* special embedded SQL tokens */
605 %token SQL_ALLOCATE SQL_AUTOCOMMIT SQL_BOOL SQL_BREAK
606 SQL_CARDINALITY SQL_CONNECT
607 SQL_COUNT
608 SQL_DATETIME_INTERVAL_CODE
609 SQL_DATETIME_INTERVAL_PRECISION SQL_DESCRIBE
610 SQL_DESCRIPTOR SQL_DISCONNECT SQL_FOUND
611 SQL_FREE SQL_GET SQL_GO SQL_GOTO SQL_IDENTIFIED
612 SQL_INDICATOR SQL_KEY_MEMBER SQL_LENGTH
613 SQL_LONG SQL_NULLABLE SQL_OCTET_LENGTH
614 SQL_OPEN SQL_OUTPUT SQL_REFERENCE
615 SQL_RETURNED_LENGTH SQL_RETURNED_OCTET_LENGTH SQL_SCALE
616 SQL_SECTION SQL_SHORT SQL_SIGNED SQL_SQLERROR
617 SQL_SQLPRINT SQL_SQLWARNING SQL_START SQL_STOP
618 SQL_STRUCT SQL_UNSIGNED SQL_VAR SQL_WHENEVER
619
620 /* C tokens */
621 %token S_ADD S_AND S_ANYTHING S_AUTO S_CONST S_DEC S_DIV
622 S_DOTPOINT S_EQUAL S_EXTERN S_INC S_LSHIFT S_MEMPOINT
623 S_MEMBER S_MOD S_MUL S_NEQUAL S_OR S_REGISTER S_RSHIFT
624 S_STATIC S_SUB S_VOLATILE
625 S_TYPEDEF
626
627 %token CSTRING CVARIABLE CPP_LINE IP
628 %token DOLCONST ECONST NCONST UCONST UIDENT
629 /* types */
630 %type <str> stmt
631 %type <str> CallStmt
632 %type <str> CreateRoleStmt
633 %type <str> opt_with
634 %type <str> OptRoleList
635 %type <str> AlterOptRoleList
636 %type <str> AlterOptRoleElem
637 %type <str> CreateOptRoleElem
638 %type <str> CreateUserStmt
639 %type <str> AlterRoleStmt
640 %type <str> opt_in_database
641 %type <str> AlterRoleSetStmt
642 %type <str> DropRoleStmt
643 %type <str> CreateGroupStmt
644 %type <str> AlterGroupStmt
645 %type <str> add_drop
646 %type <str> CreateSchemaStmt
647 %type <str> OptSchemaName
648 %type <str> OptSchemaEltList
649 %type <str> schema_stmt
650 %type <str> VariableSetStmt
651 %type <str> set_rest
652 %type <str> generic_set
653 %type <str> set_rest_more
654 %type <str> var_name
655 %type <str> var_list
656 %type <str> var_value
657 %type <str> iso_level
658 %type <str> opt_boolean_or_string
659 %type <str> zone_value
660 %type <str> opt_encoding
661 %type <str> NonReservedWord_or_Sconst
662 %type <str> VariableResetStmt
663 %type <str> reset_rest
664 %type <str> generic_reset
665 %type <str> SetResetClause
666 %type <str> FunctionSetResetClause
667 %type <str> VariableShowStmt
668 %type <str> ConstraintsSetStmt
669 %type <str> constraints_set_list
670 %type <str> constraints_set_mode
671 %type <str> CheckPointStmt
672 %type <str> DiscardStmt
673 %type <str> AlterTableStmt
674 %type <str> alter_table_cmds
675 %type <str> partition_cmd
676 %type <str> index_partition_cmd
677 %type <str> alter_table_cmd
678 %type <str> alter_column_default
679 %type <str> opt_drop_behavior
680 %type <str> opt_collate_clause
681 %type <str> alter_using
682 %type <str> replica_identity
683 %type <str> reloptions
684 %type <str> opt_reloptions
685 %type <str> reloption_list
686 %type <str> reloption_elem
687 %type <str> alter_identity_column_option_list
688 %type <str> alter_identity_column_option
689 %type <str> PartitionBoundSpec
690 %type <str> hash_partbound_elem
691 %type <str> hash_partbound
692 %type <str> AlterCompositeTypeStmt
693 %type <str> alter_type_cmds
694 %type <str> alter_type_cmd
695 %type <str> ClosePortalStmt
696 %type <str> CopyStmt
697 %type <str> copy_from
698 %type <str> opt_program
699 %type <str> copy_file_name
700 %type <str> copy_options
701 %type <str> copy_opt_list
702 %type <str> copy_opt_item
703 %type <str> opt_binary
704 %type <str> copy_delimiter
705 %type <str> opt_using
706 %type <str> copy_generic_opt_list
707 %type <str> copy_generic_opt_elem
708 %type <str> copy_generic_opt_arg
709 %type <str> copy_generic_opt_arg_list
710 %type <str> copy_generic_opt_arg_list_item
711 %type <str> CreateStmt
712 %type <str> OptTemp
713 %type <str> OptTableElementList
714 %type <str> OptTypedTableElementList
715 %type <str> TableElementList
716 %type <str> TypedTableElementList
717 %type <str> TableElement
718 %type <str> TypedTableElement
719 %type <str> columnDef
720 %type <str> columnOptions
721 %type <str> ColQualList
722 %type <str> ColConstraint
723 %type <str> ColConstraintElem
724 %type <str> generated_when
725 %type <str> ConstraintAttr
726 %type <str> TableLikeClause
727 %type <str> TableLikeOptionList
728 %type <str> TableLikeOption
729 %type <str> TableConstraint
730 %type <str> ConstraintElem
731 %type <str> opt_no_inherit
732 %type <str> opt_column_list
733 %type <str> columnList
734 %type <str> columnElem
735 %type <str> opt_c_include
736 %type <str> key_match
737 %type <str> ExclusionConstraintList
738 %type <str> ExclusionConstraintElem
739 %type <str> ExclusionWhereClause
740 %type <str> key_actions
741 %type <str> key_update
742 %type <str> key_delete
743 %type <str> key_action
744 %type <str> OptInherit
745 %type <str> OptPartitionSpec
746 %type <str> PartitionSpec
747 %type <str> part_strategy
748 %type <str> part_params
749 %type <str> part_elem
750 %type <str> table_access_method_clause
751 %type <str> OptWith
752 %type <str> OnCommitOption
753 %type <str> OptTableSpace
754 %type <str> OptConsTableSpace
755 %type <str> ExistingIndex
756 %type <str> CreateStatsStmt
757 %type <str> create_as_target
758 %type <str> opt_with_data
759 %type <str> CreateMatViewStmt
760 %type <str> create_mv_target
761 %type <str> OptNoLog
762 %type <str> RefreshMatViewStmt
763 %type <str> CreateSeqStmt
764 %type <str> AlterSeqStmt
765 %type <str> OptSeqOptList
766 %type <str> OptParenthesizedSeqOptList
767 %type <str> SeqOptList
768 %type <str> SeqOptElem
769 %type <str> opt_by
770 %type <str> NumericOnly
771 %type <str> NumericOnly_list
772 %type <str> CreatePLangStmt
773 %type <str> opt_trusted
774 %type <str> handler_name
775 %type <str> opt_inline_handler
776 %type <str> validator_clause
777 %type <str> opt_validator
778 %type <str> DropPLangStmt
779 %type <str> opt_procedural
780 %type <str> CreateTableSpaceStmt
781 %type <str> OptTableSpaceOwner
782 %type <str> DropTableSpaceStmt
783 %type <str> CreateExtensionStmt
784 %type <str> create_extension_opt_list
785 %type <str> create_extension_opt_item
786 %type <str> AlterExtensionStmt
787 %type <str> alter_extension_opt_list
788 %type <str> alter_extension_opt_item
789 %type <str> AlterExtensionContentsStmt
790 %type <str> CreateFdwStmt
791 %type <str> fdw_option
792 %type <str> fdw_options
793 %type <str> opt_fdw_options
794 %type <str> AlterFdwStmt
795 %type <str> create_generic_options
796 %type <str> generic_option_list
797 %type <str> alter_generic_options
798 %type <str> alter_generic_option_list
799 %type <str> alter_generic_option_elem
800 %type <str> generic_option_elem
801 %type <str> generic_option_name
802 %type <str> generic_option_arg
803 %type <str> CreateForeignServerStmt
804 %type <str> opt_type
805 %type <str> foreign_server_version
806 %type <str> opt_foreign_server_version
807 %type <str> AlterForeignServerStmt
808 %type <str> CreateForeignTableStmt
809 %type <str> AlterForeignTableStmt
810 %type <str> ImportForeignSchemaStmt
811 %type <str> import_qualification_type
812 %type <str> import_qualification
813 %type <str> CreateUserMappingStmt
814 %type <str> auth_ident
815 %type <str> DropUserMappingStmt
816 %type <str> AlterUserMappingStmt
817 %type <str> CreatePolicyStmt
818 %type <str> AlterPolicyStmt
819 %type <str> RowSecurityOptionalExpr
820 %type <str> RowSecurityOptionalWithCheck
821 %type <str> RowSecurityDefaultToRole
822 %type <str> RowSecurityOptionalToRole
823 %type <str> RowSecurityDefaultPermissive
824 %type <str> RowSecurityDefaultForCmd
825 %type <str> row_security_cmd
826 %type <str> CreateAmStmt
827 %type <str> am_type
828 %type <str> CreateTrigStmt
829 %type <str> TriggerActionTime
830 %type <str> TriggerEvents
831 %type <str> TriggerOneEvent
832 %type <str> TriggerReferencing
833 %type <str> TriggerTransitions
834 %type <str> TriggerTransition
835 %type <str> TransitionOldOrNew
836 %type <str> TransitionRowOrTable
837 %type <str> TransitionRelName
838 %type <str> TriggerForSpec
839 %type <str> TriggerForOptEach
840 %type <str> TriggerForType
841 %type <str> TriggerWhen
842 %type <str> FUNCTION_or_PROCEDURE
843 %type <str> TriggerFuncArgs
844 %type <str> TriggerFuncArg
845 %type <str> OptConstrFromTable
846 %type <str> ConstraintAttributeSpec
847 %type <str> ConstraintAttributeElem
848 %type <str> CreateEventTrigStmt
849 %type <str> event_trigger_when_list
850 %type <str> event_trigger_when_item
851 %type <str> event_trigger_value_list
852 %type <str> AlterEventTrigStmt
853 %type <str> enable_trigger
854 %type <str> CreateAssertionStmt
855 %type <str> DefineStmt
856 %type <str> definition
857 %type <str> def_list
858 %type <str> def_elem
859 %type <str> def_arg
860 %type <str> old_aggr_definition
861 %type <str> old_aggr_list
862 %type <str> old_aggr_elem
863 %type <str> opt_enum_val_list
864 %type <str> enum_val_list
865 %type <str> AlterEnumStmt
866 %type <str> opt_if_not_exists
867 %type <str> CreateOpClassStmt
868 %type <str> opclass_item_list
869 %type <str> opclass_item
870 %type <str> opt_default
871 %type <str> opt_opfamily
872 %type <str> opclass_purpose
873 %type <str> opt_recheck
874 %type <str> CreateOpFamilyStmt
875 %type <str> AlterOpFamilyStmt
876 %type <str> opclass_drop_list
877 %type <str> opclass_drop
878 %type <str> DropOpClassStmt
879 %type <str> DropOpFamilyStmt
880 %type <str> DropOwnedStmt
881 %type <str> ReassignOwnedStmt
882 %type <str> DropStmt
883 %type <str> drop_type_any_name
884 %type <str> drop_type_name
885 %type <str> drop_type_name_on_any_name
886 %type <str> any_name_list
887 %type <str> any_name
888 %type <str> attrs
889 %type <str> type_name_list
890 %type <str> TruncateStmt
891 %type <str> opt_restart_seqs
892 %type <str> CommentStmt
893 %type <str> comment_type_any_name
894 %type <str> comment_type_name
895 %type <str> comment_text
896 %type <str> SecLabelStmt
897 %type <str> opt_provider
898 %type <str> security_label_type_any_name
899 %type <str> security_label_type_name
900 %type <str> security_label
901 %type <str> FetchStmt
902 %type <str> fetch_args
903 %type <str> from_in
904 %type <str> opt_from_in
905 %type <str> GrantStmt
906 %type <str> RevokeStmt
907 %type <str> privileges
908 %type <str> privilege_list
909 %type <str> privilege
910 %type <str> privilege_target
911 %type <str> grantee_list
912 %type <str> grantee
913 %type <str> opt_grant_grant_option
914 %type <str> GrantRoleStmt
915 %type <str> RevokeRoleStmt
916 %type <str> opt_grant_admin_option
917 %type <str> opt_granted_by
918 %type <str> AlterDefaultPrivilegesStmt
919 %type <str> DefACLOptionList
920 %type <str> DefACLOption
921 %type <str> DefACLAction
922 %type <str> defacl_privilege_target
923 %type <str> IndexStmt
924 %type <str> opt_unique
925 %type <str> opt_concurrently
926 %type <str> opt_index_name
927 %type <str> access_method_clause
928 %type <str> index_params
929 %type <str> index_elem
930 %type <str> opt_include
931 %type <str> index_including_params
932 %type <str> opt_collate
933 %type <str> opt_class
934 %type <str> opt_asc_desc
935 %type <str> opt_nulls_order
936 %type <str> CreateFunctionStmt
937 %type <str> opt_or_replace
938 %type <str> func_args
939 %type <str> func_args_list
940 %type <str> function_with_argtypes_list
941 %type <str> function_with_argtypes
942 %type <str> func_args_with_defaults
943 %type <str> func_args_with_defaults_list
944 %type <str> func_arg
945 %type <str> arg_class
946 %type <str> param_name
947 %type <str> func_return
948 %type <str> func_type
949 %type <str> func_arg_with_default
950 %type <str> aggr_arg
951 %type <str> aggr_args
952 %type <str> aggr_args_list
953 %type <str> aggregate_with_argtypes
954 %type <str> aggregate_with_argtypes_list
955 %type <str> createfunc_opt_list
956 %type <str> common_func_opt_item
957 %type <str> createfunc_opt_item
958 %type <str> func_as
959 %type <str> transform_type_list
960 %type <str> opt_definition
961 %type <str> table_func_column
962 %type <str> table_func_column_list
963 %type <str> AlterFunctionStmt
964 %type <str> alterfunc_opt_list
965 %type <str> opt_restrict
966 %type <str> RemoveFuncStmt
967 %type <str> RemoveAggrStmt
968 %type <str> RemoveOperStmt
969 %type <str> oper_argtypes
970 %type <str> any_operator
971 %type <str> operator_with_argtypes_list
972 %type <str> operator_with_argtypes
973 %type <str> DoStmt
974 %type <str> dostmt_opt_list
975 %type <str> dostmt_opt_item
976 %type <str> CreateCastStmt
977 %type <str> cast_context
978 %type <str> DropCastStmt
979 %type <str> opt_if_exists
980 %type <str> CreateTransformStmt
981 %type <str> transform_element_list
982 %type <str> DropTransformStmt
983 %type <str> ReindexStmt
984 %type <str> reindex_target_type
985 %type <str> reindex_target_multitable
986 %type <str> reindex_option_list
987 %type <str> reindex_option_elem
988 %type <str> AlterTblSpcStmt
989 %type <str> RenameStmt
990 %type <str> opt_column
991 %type <str> opt_set_data
992 %type <str> AlterObjectDependsStmt
993 %type <str> AlterObjectSchemaStmt
994 %type <str> AlterOperatorStmt
995 %type <str> operator_def_list
996 %type <str> operator_def_elem
997 %type <str> operator_def_arg
998 %type <str> AlterOwnerStmt
999 %type <str> CreatePublicationStmt
1000 %type <str> opt_publication_for_tables
1001 %type <str> publication_for_tables
1002 %type <str> AlterPublicationStmt
1003 %type <str> CreateSubscriptionStmt
1004 %type <str> publication_name_list
1005 %type <str> publication_name_item
1006 %type <str> AlterSubscriptionStmt
1007 %type <str> DropSubscriptionStmt
1008 %type <str> RuleStmt
1009 %type <str> RuleActionList
1010 %type <str> RuleActionMulti
1011 %type <str> RuleActionStmt
1012 %type <str> RuleActionStmtOrEmpty
1013 %type <str> event
1014 %type <str> opt_instead
1015 %type <str> NotifyStmt
1016 %type <str> notify_payload
1017 %type <str> ListenStmt
1018 %type <str> UnlistenStmt
1019 %type <str> TransactionStmt
1020 %type <str> opt_transaction
1021 %type <str> transaction_mode_item
1022 %type <str> transaction_mode_list
1023 %type <str> transaction_mode_list_or_empty
1024 %type <str> opt_transaction_chain
1025 %type <str> ViewStmt
1026 %type <str> opt_check_option
1027 %type <str> LoadStmt
1028 %type <str> CreatedbStmt
1029 %type <str> createdb_opt_list
1030 %type <str> createdb_opt_items
1031 %type <str> createdb_opt_item
1032 %type <str> createdb_opt_name
1033 %type <str> opt_equal
1034 %type <str> AlterDatabaseStmt
1035 %type <str> AlterDatabaseSetStmt
1036 %type <str> DropdbStmt
1037 %type <str> AlterCollationStmt
1038 %type <str> AlterSystemStmt
1039 %type <str> CreateDomainStmt
1040 %type <str> AlterDomainStmt
1041 %type <str> opt_as
1042 %type <str> AlterTSDictionaryStmt
1043 %type <str> AlterTSConfigurationStmt
1044 %type <str> any_with
1045 %type <str> CreateConversionStmt
1046 %type <str> ClusterStmt
1047 %type <str> cluster_index_specification
1048 %type <str> VacuumStmt
1049 %type <str> AnalyzeStmt
1050 %type <str> vac_analyze_option_list
1051 %type <str> analyze_keyword
1052 %type <str> vac_analyze_option_elem
1053 %type <str> vac_analyze_option_name
1054 %type <str> vac_analyze_option_arg
1055 %type <str> opt_analyze
1056 %type <str> opt_verbose
1057 %type <str> opt_full
1058 %type <str> opt_freeze
1059 %type <str> opt_name_list
1060 %type <str> vacuum_relation
1061 %type <str> vacuum_relation_list
1062 %type <str> opt_vacuum_relation_list
1063 %type <str> ExplainStmt
1064 %type <str> ExplainableStmt
1065 %type <str> explain_option_list
1066 %type <str> explain_option_elem
1067 %type <str> explain_option_name
1068 %type <str> explain_option_arg
1069 %type <prep> PrepareStmt
1070 %type <str> prep_type_clause
1071 %type <str> PreparableStmt
1072 %type <exec> ExecuteStmt
1073 %type <str> execute_param_clause
1074 %type <str> InsertStmt
1075 %type <str> insert_target
1076 %type <str> insert_rest
1077 %type <str> override_kind
1078 %type <str> insert_column_list
1079 %type <str> insert_column_item
1080 %type <str> opt_on_conflict
1081 %type <str> opt_conf_expr
1082 %type <str> returning_clause
1083 %type <str> DeleteStmt
1084 %type <str> using_clause
1085 %type <str> LockStmt
1086 %type <str> opt_lock
1087 %type <str> lock_type
1088 %type <str> opt_nowait
1089 %type <str> opt_nowait_or_skip
1090 %type <str> UpdateStmt
1091 %type <str> set_clause_list
1092 %type <str> set_clause
1093 %type <str> set_target
1094 %type <str> set_target_list
1095 %type <str> DeclareCursorStmt
1096 %type <str> cursor_name
1097 %type <str> cursor_options
1098 %type <str> opt_hold
1099 %type <str> SelectStmt
1100 %type <str> select_with_parens
1101 %type <str> select_no_parens
1102 %type <str> select_clause
1103 %type <str> simple_select
1104 %type <str> with_clause
1105 %type <str> cte_list
1106 %type <str> common_table_expr
1107 %type <str> opt_materialized
1108 %type <str> opt_with_clause
1109 %type <str> into_clause
1110 %type <str> OptTempTableName
1111 %type <str> opt_table
1112 %type <str> all_or_distinct
1113 %type <str> distinct_clause
1114 %type <str> opt_all_clause
1115 %type <str> opt_sort_clause
1116 %type <str> sort_clause
1117 %type <str> sortby_list
1118 %type <str> sortby
1119 %type <str> select_limit
1120 %type <str> opt_select_limit
1121 %type <str> limit_clause
1122 %type <str> offset_clause
1123 %type <str> select_limit_value
1124 %type <str> select_offset_value
1125 %type <str> select_fetch_first_value
1126 %type <str> I_or_F_const
1127 %type <str> row_or_rows
1128 %type <str> first_or_next
1129 %type <str> group_clause
1130 %type <str> group_by_list
1131 %type <str> group_by_item
1132 %type <str> empty_grouping_set
1133 %type <str> rollup_clause
1134 %type <str> cube_clause
1135 %type <str> grouping_sets_clause
1136 %type <str> having_clause
1137 %type <str> for_locking_clause
1138 %type <str> opt_for_locking_clause
1139 %type <str> for_locking_items
1140 %type <str> for_locking_item
1141 %type <str> for_locking_strength
1142 %type <str> locked_rels_list
1143 %type <str> values_clause
1144 %type <str> from_clause
1145 %type <str> from_list
1146 %type <str> table_ref
1147 %type <str> joined_table
1148 %type <str> alias_clause
1149 %type <str> opt_alias_clause
1150 %type <str> func_alias_clause
1151 %type <str> join_type
1152 %type <str> join_outer
1153 %type <str> join_qual
1154 %type <str> relation_expr
1155 %type <str> relation_expr_list
1156 %type <str> relation_expr_opt_alias
1157 %type <str> tablesample_clause
1158 %type <str> opt_repeatable_clause
1159 %type <str> func_table
1160 %type <str> rowsfrom_item
1161 %type <str> rowsfrom_list
1162 %type <str> opt_col_def_list
1163 %type <str> opt_ordinality
1164 %type <str> where_clause
1165 %type <str> where_or_current_clause
1166 %type <str> OptTableFuncElementList
1167 %type <str> TableFuncElementList
1168 %type <str> TableFuncElement
1169 %type <str> xmltable
1170 %type <str> xmltable_column_list
1171 %type <str> xmltable_column_el
1172 %type <str> xmltable_column_option_list
1173 %type <str> xmltable_column_option_el
1174 %type <str> xml_namespace_list
1175 %type <str> xml_namespace_el
1176 %type <str> Typename
1177 %type <index> opt_array_bounds
1178 %type <str> SimpleTypename
1179 %type <str> ConstTypename
1180 %type <str> GenericType
1181 %type <str> opt_type_modifiers
1182 %type <str> Numeric
1183 %type <str> opt_float
1184 %type <str> Bit
1185 %type <str> ConstBit
1186 %type <str> BitWithLength
1187 %type <str> BitWithoutLength
1188 %type <str> Character
1189 %type <str> ConstCharacter
1190 %type <str> CharacterWithLength
1191 %type <str> CharacterWithoutLength
1192 %type <str> character
1193 %type <str> opt_varying
1194 %type <str> ConstDatetime
1195 %type <str> ConstInterval
1196 %type <str> opt_timezone
1197 %type <str> opt_interval
1198 %type <str> interval_second
1199 %type <str> a_expr
1200 %type <str> b_expr
1201 %type <str> c_expr
1202 %type <str> func_application
1203 %type <str> func_expr
1204 %type <str> func_expr_windowless
1205 %type <str> func_expr_common_subexpr
1206 %type <str> xml_root_version
1207 %type <str> opt_xml_root_standalone
1208 %type <str> xml_attributes
1209 %type <str> xml_attribute_list
1210 %type <str> xml_attribute_el
1211 %type <str> document_or_content
1212 %type <str> xml_whitespace_option
1213 %type <str> xmlexists_argument
1214 %type <str> xml_passing_mech
1215 %type <str> within_group_clause
1216 %type <str> filter_clause
1217 %type <str> window_clause
1218 %type <str> window_definition_list
1219 %type <str> window_definition
1220 %type <str> over_clause
1221 %type <str> window_specification
1222 %type <str> opt_existing_window_name
1223 %type <str> opt_partition_clause
1224 %type <str> opt_frame_clause
1225 %type <str> frame_extent
1226 %type <str> frame_bound
1227 %type <str> opt_window_exclusion_clause
1228 %type <str> row
1229 %type <str> explicit_row
1230 %type <str> implicit_row
1231 %type <str> sub_type
1232 %type <str> all_Op
1233 %type <str> MathOp
1234 %type <str> qual_Op
1235 %type <str> qual_all_Op
1236 %type <str> subquery_Op
1237 %type <str> expr_list
1238 %type <str> func_arg_list
1239 %type <str> func_arg_expr
1240 %type <str> type_list
1241 %type <str> array_expr
1242 %type <str> array_expr_list
1243 %type <str> extract_list
1244 %type <str> extract_arg
1245 %type <str> overlay_list
1246 %type <str> overlay_placing
1247 %type <str> position_list
1248 %type <str> substr_list
1249 %type <str> substr_from
1250 %type <str> substr_for
1251 %type <str> trim_list
1252 %type <str> in_expr
1253 %type <str> case_expr
1254 %type <str> when_clause_list
1255 %type <str> when_clause
1256 %type <str> case_default
1257 %type <str> case_arg
1258 %type <str> columnref
1259 %type <str> indirection_el
1260 %type <str> opt_slice_bound
1261 %type <str> indirection
1262 %type <str> opt_indirection
1263 %type <str> opt_asymmetric
1264 %type <str> opt_target_list
1265 %type <str> target_list
1266 %type <str> target_el
1267 %type <str> qualified_name_list
1268 %type <str> qualified_name
1269 %type <str> name_list
1270 %type <str> name
1271 %type <str> database_name
1272 %type <str> access_method
1273 %type <str> attr_name
1274 %type <str> index_name
1275 %type <str> file_name
1276 %type <str> func_name
1277 %type <str> AexprConst
1278 %type <str> Iconst
1279 %type <str> SignedIconst
1280 %type <str> RoleId
1281 %type <str> RoleSpec
1282 %type <str> role_list
1283 %type <str> NonReservedWord
1284 %type <str> unreserved_keyword
1285 %type <str> col_name_keyword
1286 %type <str> type_func_name_keyword
1287 %type <str> reserved_keyword
1288 /* ecpgtype */
1289 /* src/interfaces/ecpg/preproc/ecpg.type */
1290 %type <str> ECPGAllocateDescr
1291 %type <str> ECPGCKeywords
1292 %type <str> ECPGColId
1293 %type <str> ECPGColLabel
1294 %type <str> ECPGColLabelCommon
1295 %type <str> ECPGConnect
1296 %type <str> ECPGCursorStmt
1297 %type <str> ECPGDeallocateDescr
1298 %type <str> ECPGDeclaration
1299 %type <str> ECPGDeclare
1300 %type <str> ECPGDescribe
1301 %type <str> ECPGDisconnect
1302 %type <str> ECPGExecuteImmediateStmt
1303 %type <str> ECPGFree
1304 %type <str> ECPGGetDescHeaderItem
1305 %type <str> ECPGGetDescItem
1306 %type <str> ECPGGetDescriptorHeader
1307 %type <str> ECPGKeywords
1308 %type <str> ECPGKeywords_rest
1309 %type <str> ECPGKeywords_vanames
1310 %type <str> ECPGOpen
1311 %type <str> ECPGSetAutocommit
1312 %type <str> ECPGSetConnection
1313 %type <str> ECPGSetDescHeaderItem
1314 %type <str> ECPGSetDescItem
1315 %type <str> ECPGSetDescriptorHeader
1316 %type <str> ECPGTypeName
1317 %type <str> ECPGTypedef
1318 %type <str> ECPGVar
1319 %type <str> ECPGVarDeclaration
1320 %type <str> ECPGWhenever
1321 %type <str> ECPGunreserved_interval
1322 %type <str> UsingConst
1323 %type <str> UsingValue
1324 %type <str> all_unreserved_keyword
1325 %type <str> c_anything
1326 %type <str> c_args
1327 %type <str> c_list
1328 %type <str> c_stuff
1329 %type <str> c_stuff_item
1330 %type <str> c_term
1331 %type <str> c_thing
1332 %type <str> char_variable
1333 %type <str> char_civar
1334 %type <str> civar
1335 %type <str> civarind
1336 %type <str> ColId
1337 %type <str> ColLabel
1338 %type <str> connect_options
1339 %type <str> connection_object
1340 %type <str> connection_target
1341 %type <str> coutputvariable
1342 %type <str> cvariable
1343 %type <str> db_prefix
1344 %type <str> CreateAsStmt
1345 %type <str> DeallocateStmt
1346 %type <str> dis_name
1347 %type <str> ecpg_bconst
1348 %type <str> ecpg_fconst
1349 %type <str> ecpg_ident
1350 %type <str> ecpg_interval
1351 %type <str> ecpg_into
1352 %type <str> ecpg_fetch_into
1353 %type <str> ecpg_param
1354 %type <str> ecpg_sconst
1355 %type <str> ecpg_using
1356 %type <str> ecpg_xconst
1357 %type <str> enum_definition
1358 %type <str> enum_type
1359 %type <str> execstring
1360 %type <str> execute_rest
1361 %type <str> indicator
1362 %type <str> into_descriptor
1363 %type <str> into_sqlda
1364 %type <str> Iresult
1365 %type <str> on_off
1366 %type <str> opt_bit_field
1367 %type <str> opt_connection_name
1368 %type <str> opt_database_name
1369 %type <str> opt_ecpg_into
1370 %type <str> opt_ecpg_fetch_into
1371 %type <str> opt_ecpg_using
1372 %type <str> opt_initializer
1373 %type <str> opt_options
1374 %type <str> opt_output
1375 %type <str> opt_pointer
1376 %type <str> opt_port
1377 %type <str> opt_reference
1378 %type <str> opt_scale
1379 %type <str> opt_server
1380 %type <str> opt_user
1381 %type <str> opt_opt_value
1382 %type <str> ora_user
1383 %type <str> precision
1384 %type <str> prepared_name
1385 %type <str> quoted_ident_stringvar
1386 %type <str> s_struct_union
1387 %type <str> server
1388 %type <str> server_name
1389 %type <str> single_vt_declaration
1390 %type <str> storage_clause
1391 %type <str> storage_declaration
1392 %type <str> storage_modifier
1393 %type <str> struct_union_type
1394 %type <str> struct_union_type_with_symbol
1395 %type <str> symbol
1396 %type <str> type_declaration
1397 %type <str> type_function_name
1398 %type <str> user_name
1399 %type <str> using_descriptor
1400 %type <str> var_declaration
1401 %type <str> var_type_declarations
1402 %type <str> variable
1403 %type <str> variable_declarations
1404 %type <str> variable_list
1405 %type <str> vt_declarations
1406
1407 %type <str> Op
1408 %type <str> IntConstVar
1409 %type <str> AllConstVar
1410 %type <str> CSTRING
1411 %type <str> CPP_LINE
1412 %type <str> CVARIABLE
1413 %type <str> DOLCONST
1414 %type <str> ECONST
1415 %type <str> NCONST
1416 %type <str> SCONST
1417 %type <str> UCONST
1418 %type <str> UIDENT
1419
1420 %type <struct_union> s_struct_union_symbol
1421
1422 %type <descriptor> ECPGGetDescriptor
1423 %type <descriptor> ECPGSetDescriptor
1424
1425 %type <type_enum> simple_type
1426 %type <type_enum> signed_type
1427 %type <type_enum> unsigned_type
1428
1429 %type <dtype_enum> descriptor_item
1430 %type <dtype_enum> desc_header_item
1431
1432 %type <type> var_type
1433
1434 %type <action> action
1435 /* orig_tokens */
1436 %token IDENT FCONST SCONST BCONST XCONST Op
1437 %token ICONST PARAM
1438 %token TYPECAST DOT_DOT COLON_EQUALS EQUALS_GREATER
1439 %token LESS_EQUALS GREATER_EQUALS NOT_EQUALS
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449 %token ABORT_P ABSOLUTE_P ACCESS ACTION ADD_P ADMIN AFTER
1450 AGGREGATE ALL ALSO ALTER ALWAYS ANALYSE ANALYZE AND ANY ARRAY AS ASC
1451 ASSERTION ASSIGNMENT ASYMMETRIC AT ATTACH ATTRIBUTE AUTHORIZATION
1452
1453 BACKWARD BEFORE BEGIN_P BETWEEN BIGINT BINARY BIT
1454 BOOLEAN_P BOTH BY
1455
1456 CACHE CALL CALLED CASCADE CASCADED CASE CAST CATALOG_P CHAIN CHAR_P
1457 CHARACTER CHARACTERISTICS CHECK CHECKPOINT CLASS CLOSE
1458 CLUSTER COALESCE COLLATE COLLATION COLUMN COLUMNS COMMENT COMMENTS COMMIT
1459 COMMITTED CONCURRENTLY CONFIGURATION CONFLICT CONNECTION CONSTRAINT
1460 CONSTRAINTS CONTENT_P CONTINUE_P CONVERSION_P COPY COST CREATE
1461 CROSS CSV CUBE CURRENT_P
1462 CURRENT_CATALOG CURRENT_DATE CURRENT_ROLE CURRENT_SCHEMA
1463 CURRENT_TIME CURRENT_TIMESTAMP CURRENT_USER CURSOR CYCLE
1464
1465 DATA_P DATABASE DAY_P DEALLOCATE DEC DECIMAL_P DECLARE DEFAULT DEFAULTS
1466 DEFERRABLE DEFERRED DEFINER DELETE_P DELIMITER DELIMITERS DEPENDS DESC
1467 DETACH DICTIONARY DISABLE_P DISCARD DISTINCT DO DOCUMENT_P DOMAIN_P
1468 DOUBLE_P DROP
1469
1470 EACH ELSE ENABLE_P ENCODING ENCRYPTED END_P ENUM_P ESCAPE EVENT EXCEPT
1471 EXCLUDE EXCLUDING EXCLUSIVE EXECUTE EXISTS EXPLAIN
1472 EXTENSION EXTERNAL EXTRACT
1473
1474 FALSE_P FAMILY FETCH FILTER FIRST_P FLOAT_P FOLLOWING FOR
1475 FORCE FOREIGN FORWARD FREEZE FROM FULL FUNCTION FUNCTIONS
1476
1477 GENERATED GLOBAL GRANT GRANTED GREATEST GROUP_P GROUPING GROUPS
1478
1479 HANDLER HAVING HEADER_P HOLD HOUR_P
1480
1481 IDENTITY_P IF_P ILIKE IMMEDIATE IMMUTABLE IMPLICIT_P IMPORT_P IN_P INCLUDE
1482 INCLUDING INCREMENT INDEX INDEXES INHERIT INHERITS INITIALLY INLINE_P
1483 INNER_P INOUT INPUT_P INSENSITIVE INSERT INSTEAD INT_P INTEGER
1484 INTERSECT INTERVAL INTO INVOKER IS ISNULL ISOLATION
1485
1486 JOIN
1487
1488 KEY
1489
1490 LABEL LANGUAGE LARGE_P LAST_P LATERAL_P
1491 LEADING LEAKPROOF LEAST LEFT LEVEL LIKE LIMIT LISTEN LOAD LOCAL
1492 LOCALTIME LOCALTIMESTAMP LOCATION LOCK_P LOCKED LOGGED
1493
1494 MAPPING MATCH MATERIALIZED MAXVALUE METHOD MINUTE_P MINVALUE MODE MONTH_P MOVE
1495
1496 NAME_P NAMES NATIONAL NATURAL NCHAR NEW NEXT NO NONE
1497 NOT NOTHING NOTIFY NOTNULL NOWAIT NULL_P NULLIF
1498 NULLS_P NUMERIC
1499
1500 OBJECT_P OF OFF OFFSET OIDS OLD ON ONLY OPERATOR OPTION OPTIONS OR
1501 ORDER ORDINALITY OTHERS OUT_P OUTER_P
1502 OVER OVERLAPS OVERLAY OVERRIDING OWNED OWNER
1503
1504 PARALLEL PARSER PARTIAL PARTITION PASSING PASSWORD PLACING PLANS POLICY
1505 POSITION PRECEDING PRECISION PRESERVE PREPARE PREPARED PRIMARY
1506 PRIOR PRIVILEGES PROCEDURAL PROCEDURE PROCEDURES PROGRAM PUBLICATION
1507
1508 QUOTE
1509
1510 RANGE READ REAL REASSIGN RECHECK RECURSIVE REF REFERENCES REFERENCING
1511 REFRESH REINDEX RELATIVE_P RELEASE RENAME REPEATABLE REPLACE REPLICA
1512 RESET RESTART RESTRICT RETURNING RETURNS REVOKE RIGHT ROLE ROLLBACK ROLLUP
1513 ROUTINE ROUTINES ROW ROWS RULE
1514
1515 SAVEPOINT SCHEMA SCHEMAS SCROLL SEARCH SECOND_P SECURITY SELECT SEQUENCE SEQUENCES
1516 SERIALIZABLE SERVER SESSION SESSION_USER SET SETS SETOF SHARE SHOW
1517 SIMILAR SIMPLE SKIP SMALLINT SNAPSHOT SOME SQL_P STABLE STANDALONE_P
1518 START STATEMENT STATISTICS STDIN STDOUT STORAGE STORED STRICT_P STRIP_P
1519 SUBSCRIPTION SUBSTRING SUPPORT SYMMETRIC SYSID SYSTEM_P
1520
1521 TABLE TABLES TABLESAMPLE TABLESPACE TEMP TEMPLATE TEMPORARY TEXT_P THEN
1522 TIES TIME TIMESTAMP TO TRAILING TRANSACTION TRANSFORM
1523 TREAT TRIGGER TRIM TRUE_P
1524 TRUNCATE TRUSTED TYPE_P TYPES_P
1525
1526 UNBOUNDED UNCOMMITTED UNENCRYPTED UNION UNIQUE UNKNOWN UNLISTEN UNLOGGED
1527 UNTIL UPDATE USER USING
1528
1529 VACUUM VALID VALIDATE VALIDATOR VALUE_P VALUES VARCHAR VARIADIC VARYING
1530 VERBOSE VERSION_P VIEW VIEWS VOLATILE
1531
1532 WHEN WHERE WHITESPACE_P WINDOW WITH WITHIN WITHOUT WORK WRAPPER WRITE
1533
1534 XML_P XMLATTRIBUTES XMLCONCAT XMLELEMENT XMLEXISTS XMLFOREST XMLNAMESPACES
1535 XMLPARSE XMLPI XMLROOT XMLSERIALIZE XMLTABLE
1536
1537 YEAR_P YES_P
1538
1539 ZONE
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551 %token NOT_LA NULLS_LA WITH_LA
1552
1553
1554
1555 %nonassoc SET
1556 %left UNION EXCEPT
1557 %left INTERSECT
1558 %left OR
1559 %left AND
1560 %right NOT
1561 %nonassoc IS ISNULL NOTNULL
1562 %nonassoc '<' '>' '=' LESS_EQUALS GREATER_EQUALS NOT_EQUALS
1563 %nonassoc BETWEEN IN_P LIKE ILIKE SIMILAR NOT_LA
1564 %nonassoc ESCAPE
1565 %left POSTFIXOP
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593 %nonassoc UNBOUNDED
1594 %nonassoc IDENT
1595 %nonassoc CSTRING
1596 %nonassoc UIDENT GENERATED NULL_P PARTITION RANGE ROWS GROUPS PRECEDING FOLLOWING CUBE ROLLUP
1597 %left Op OPERATOR
1598 %left '+' '-'
1599 %left '*' '/' '%'
1600 %left '^'
1601
1602 %left AT
1603 %left COLLATE
1604 %right UMINUS
1605 %left '[' ']'
1606 %left '(' ')'
1607 %left TYPECAST
1608 %left '.'
1609
1610
1611
1612
1613
1614
1615
1616 %left JOIN CROSS LEFT FULL RIGHT INNER_P NATURAL
1617
1618 %right PRESERVE STRIP_P
1619
1620 %%
1621 prog: statements;
1622 /* rules */
1623 stmt:
1624 AlterEventTrigStmt
1625 { output_statement($1, 0, ECPGst_normal); }
1626 | AlterCollationStmt
1627 { output_statement($1, 0, ECPGst_normal); }
1628 | AlterDatabaseStmt
1629 { output_statement($1, 0, ECPGst_normal); }
1630 | AlterDatabaseSetStmt
1631 { output_statement($1, 0, ECPGst_normal); }
1632 | AlterDefaultPrivilegesStmt
1633 { output_statement($1, 0, ECPGst_normal); }
1634 | AlterDomainStmt
1635 { output_statement($1, 0, ECPGst_normal); }
1636 | AlterEnumStmt
1637 { output_statement($1, 0, ECPGst_normal); }
1638 | AlterExtensionStmt
1639 { output_statement($1, 0, ECPGst_normal); }
1640 | AlterExtensionContentsStmt
1641 { output_statement($1, 0, ECPGst_normal); }
1642 | AlterFdwStmt
1643 { output_statement($1, 0, ECPGst_normal); }
1644 | AlterForeignServerStmt
1645 { output_statement($1, 0, ECPGst_normal); }
1646 | AlterForeignTableStmt
1647 { output_statement($1, 0, ECPGst_normal); }
1648 | AlterFunctionStmt
1649 { output_statement($1, 0, ECPGst_normal); }
1650 | AlterGroupStmt
1651 { output_statement($1, 0, ECPGst_normal); }
1652 | AlterObjectDependsStmt
1653 { output_statement($1, 0, ECPGst_normal); }
1654 | AlterObjectSchemaStmt
1655 { output_statement($1, 0, ECPGst_normal); }
1656 | AlterOwnerStmt
1657 { output_statement($1, 0, ECPGst_normal); }
1658 | AlterOperatorStmt
1659 { output_statement($1, 0, ECPGst_normal); }
1660 | AlterPolicyStmt
1661 { output_statement($1, 0, ECPGst_normal); }
1662 | AlterSeqStmt
1663 { output_statement($1, 0, ECPGst_normal); }
1664 | AlterSystemStmt
1665 { output_statement($1, 0, ECPGst_normal); }
1666 | AlterTableStmt
1667 { output_statement($1, 0, ECPGst_normal); }
1668 | AlterTblSpcStmt
1669 { output_statement($1, 0, ECPGst_normal); }
1670 | AlterCompositeTypeStmt
1671 { output_statement($1, 0, ECPGst_normal); }
1672 | AlterPublicationStmt
1673 { output_statement($1, 0, ECPGst_normal); }
1674 | AlterRoleSetStmt
1675 { output_statement($1, 0, ECPGst_normal); }
1676 | AlterRoleStmt
1677 { output_statement($1, 0, ECPGst_normal); }
1678 | AlterSubscriptionStmt
1679 { output_statement($1, 0, ECPGst_normal); }
1680 | AlterTSConfigurationStmt
1681 { output_statement($1, 0, ECPGst_normal); }
1682 | AlterTSDictionaryStmt
1683 { output_statement($1, 0, ECPGst_normal); }
1684 | AlterUserMappingStmt
1685 { output_statement($1, 0, ECPGst_normal); }
1686 | AnalyzeStmt
1687 { output_statement($1, 0, ECPGst_normal); }
1688 | CallStmt
1689 { output_statement($1, 0, ECPGst_normal); }
1690 | CheckPointStmt
1691 { output_statement($1, 0, ECPGst_normal); }
1692 | ClosePortalStmt
1693 {
1694 if (INFORMIX_MODE)
1695 {
1696 if (pg_strcasecmp($1+strlen("close "), "database") == 0)
1697 {
1698 if (connection)
1699 mmerror(PARSE_ERROR, ET_ERROR, "AT option not allowed in CLOSE DATABASE statement");
1700
1701 fprintf(base_yyout, "{ ECPGdisconnect(__LINE__, \"CURRENT\");");
1702 whenever_action(2);
1703 free($1);
1704 break;
1705 }
1706 }
1707
1708 output_statement($1, 0, ECPGst_normal);
1709 }
1710 | ClusterStmt
1711 { output_statement($1, 0, ECPGst_normal); }
1712 | CommentStmt
1713 { output_statement($1, 0, ECPGst_normal); }
1714 | ConstraintsSetStmt
1715 { output_statement($1, 0, ECPGst_normal); }
1716 | CopyStmt
1717 { output_statement($1, 0, ECPGst_normal); }
1718 | CreateAmStmt
1719 { output_statement($1, 0, ECPGst_normal); }
1720 | CreateAsStmt
1721 { output_statement($1, 0, ECPGst_normal); }
1722 | CreateAssertionStmt
1723 { output_statement($1, 0, ECPGst_normal); }
1724 | CreateCastStmt
1725 { output_statement($1, 0, ECPGst_normal); }
1726 | CreateConversionStmt
1727 { output_statement($1, 0, ECPGst_normal); }
1728 | CreateDomainStmt
1729 { output_statement($1, 0, ECPGst_normal); }
1730 | CreateExtensionStmt
1731 { output_statement($1, 0, ECPGst_normal); }
1732 | CreateFdwStmt
1733 { output_statement($1, 0, ECPGst_normal); }
1734 | CreateForeignServerStmt
1735 { output_statement($1, 0, ECPGst_normal); }
1736 | CreateForeignTableStmt
1737 { output_statement($1, 0, ECPGst_normal); }
1738 | CreateFunctionStmt
1739 { output_statement($1, 0, ECPGst_normal); }
1740 | CreateGroupStmt
1741 { output_statement($1, 0, ECPGst_normal); }
1742 | CreateMatViewStmt
1743 { output_statement($1, 0, ECPGst_normal); }
1744 | CreateOpClassStmt
1745 { output_statement($1, 0, ECPGst_normal); }
1746 | CreateOpFamilyStmt
1747 { output_statement($1, 0, ECPGst_normal); }
1748 | CreatePublicationStmt
1749 { output_statement($1, 0, ECPGst_normal); }
1750 | AlterOpFamilyStmt
1751 { output_statement($1, 0, ECPGst_normal); }
1752 | CreatePolicyStmt
1753 { output_statement($1, 0, ECPGst_normal); }
1754 | CreatePLangStmt
1755 { output_statement($1, 0, ECPGst_normal); }
1756 | CreateSchemaStmt
1757 { output_statement($1, 0, ECPGst_normal); }
1758 | CreateSeqStmt
1759 { output_statement($1, 0, ECPGst_normal); }
1760 | CreateStmt
1761 { output_statement($1, 0, ECPGst_normal); }
1762 | CreateSubscriptionStmt
1763 { output_statement($1, 0, ECPGst_normal); }
1764 | CreateStatsStmt
1765 { output_statement($1, 0, ECPGst_normal); }
1766 | CreateTableSpaceStmt
1767 { output_statement($1, 0, ECPGst_normal); }
1768 | CreateTransformStmt
1769 { output_statement($1, 0, ECPGst_normal); }
1770 | CreateTrigStmt
1771 { output_statement($1, 0, ECPGst_normal); }
1772 | CreateEventTrigStmt
1773 { output_statement($1, 0, ECPGst_normal); }
1774 | CreateRoleStmt
1775 { output_statement($1, 0, ECPGst_normal); }
1776 | CreateUserStmt
1777 { output_statement($1, 0, ECPGst_normal); }
1778 | CreateUserMappingStmt
1779 { output_statement($1, 0, ECPGst_normal); }
1780 | CreatedbStmt
1781 { output_statement($1, 0, ECPGst_normal); }
1782 | DeallocateStmt
1783 {
1784 output_deallocate_prepare_statement($1);
1785 }
1786 | DeclareCursorStmt
1787 { output_simple_statement($1, (strncmp($1, "ECPGset_var", strlen("ECPGset_var")) == 0) ? 4 : 0); }
1788 | DefineStmt
1789 { output_statement($1, 0, ECPGst_normal); }
1790 | DeleteStmt
1791 { output_statement($1, 1, ECPGst_prepnormal); }
1792 | DiscardStmt
1793 { output_statement($1, 1, ECPGst_normal); }
1794 | DoStmt
1795 { output_statement($1, 0, ECPGst_normal); }
1796 | DropCastStmt
1797 { output_statement($1, 0, ECPGst_normal); }
1798 | DropOpClassStmt
1799 { output_statement($1, 0, ECPGst_normal); }
1800 | DropOpFamilyStmt
1801 { output_statement($1, 0, ECPGst_normal); }
1802 | DropOwnedStmt
1803 { output_statement($1, 0, ECPGst_normal); }
1804 | DropPLangStmt
1805 { output_statement($1, 0, ECPGst_normal); }
1806 | DropStmt
1807 { output_statement($1, 0, ECPGst_normal); }
1808 | DropSubscriptionStmt
1809 { output_statement($1, 0, ECPGst_normal); }
1810 | DropTableSpaceStmt
1811 { output_statement($1, 0, ECPGst_normal); }
1812 | DropTransformStmt
1813 { output_statement($1, 0, ECPGst_normal); }
1814 | DropRoleStmt
1815 { output_statement($1, 0, ECPGst_normal); }
1816 | DropUserMappingStmt
1817 { output_statement($1, 0, ECPGst_normal); }
1818 | DropdbStmt
1819 { output_statement($1, 0, ECPGst_normal); }
1820 | ExecuteStmt
1821 {
1822 if ($1.type == NULL || strlen($1.type) == 0)
1823 output_statement($1.name, 1, ECPGst_execute);
1824 else
1825 {
1826 if ($1.name[0] != '"')
1827 /* case of char_variable */
1828 add_variable_to_tail(&argsinsert, find_variable($1.name), &no_indicator);
1829 else
1830 {
1831 /* case of ecpg_ident or CSTRING */
1832 char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
1833 char *str = mm_strdup($1.name + 1);
1834
1835 /* It must be cut off double quotation because new_variable() double-quotes. */
1836 str[strlen(str) - 1] = '\0';
1837 sprintf(length, "%d", (int) strlen(str));
1838 add_variable_to_tail(&argsinsert, new_variable(str, ECPGmake_simple_type(ECPGt_const, length, 0), 0), &no_indicator);
1839 }
1840 output_statement(cat_str(3, mm_strdup("execute"), mm_strdup("$0"), $1.type), 0, ECPGst_exec_with_exprlist);
1841 }
1842 }
1843 | ExplainStmt
1844 { output_statement($1, 0, ECPGst_normal); }
1845 | FetchStmt
1846 { output_statement($1, 1, ECPGst_normal); }
1847 | GrantStmt
1848 { output_statement($1, 0, ECPGst_normal); }
1849 | GrantRoleStmt
1850 { output_statement($1, 0, ECPGst_normal); }
1851 | ImportForeignSchemaStmt
1852 { output_statement($1, 0, ECPGst_normal); }
1853 | IndexStmt
1854 { output_statement($1, 0, ECPGst_normal); }
1855 | InsertStmt
1856 { output_statement($1, 1, ECPGst_prepnormal); }
1857 | ListenStmt
1858 { output_statement($1, 0, ECPGst_normal); }
1859 | RefreshMatViewStmt
1860 { output_statement($1, 0, ECPGst_normal); }
1861 | LoadStmt
1862 { output_statement($1, 0, ECPGst_normal); }
1863 | LockStmt
1864 { output_statement($1, 0, ECPGst_normal); }
1865 | NotifyStmt
1866 { output_statement($1, 0, ECPGst_normal); }
1867 | PrepareStmt
1868 {
1869 if ($1.type == NULL)
1870 output_prepare_statement($1.name, $1.stmt);
1871 else if (strlen($1.type) == 0)
1872 {
1873 char *stmt = cat_str(3, mm_strdup("\""), $1.stmt, mm_strdup("\""));
1874 output_prepare_statement($1.name, stmt);
1875 }
1876 else
1877 {
1878 if ($1.name[0] != '"')
1879 /* case of char_variable */
1880 add_variable_to_tail(&argsinsert, find_variable($1.name), &no_indicator);
1881 else
1882 {
1883 char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
1884 char *str = mm_strdup($1.name + 1);
1885
1886 /* It must be cut off double quotation because new_variable() double-quotes. */
1887 str[strlen(str) - 1] = '\0';
1888 sprintf(length, "%d", (int) strlen(str));
1889 add_variable_to_tail(&argsinsert, new_variable(str, ECPGmake_simple_type(ECPGt_const, length, 0), 0), &no_indicator);
1890 }
1891 output_statement(cat_str(5, mm_strdup("prepare"), mm_strdup("$0"), $1.type, mm_strdup("as"), $1.stmt), 0, ECPGst_prepare);
1892 }
1893 }
1894 | ReassignOwnedStmt
1895 { output_statement($1, 0, ECPGst_normal); }
1896 | ReindexStmt
1897 { output_statement($1, 0, ECPGst_normal); }
1898 | RemoveAggrStmt
1899 { output_statement($1, 0, ECPGst_normal); }
1900 | RemoveFuncStmt
1901 { output_statement($1, 0, ECPGst_normal); }
1902 | RemoveOperStmt
1903 { output_statement($1, 0, ECPGst_normal); }
1904 | RenameStmt
1905 { output_statement($1, 0, ECPGst_normal); }
1906 | RevokeStmt
1907 { output_statement($1, 0, ECPGst_normal); }
1908 | RevokeRoleStmt
1909 { output_statement($1, 0, ECPGst_normal); }
1910 | RuleStmt
1911 { output_statement($1, 0, ECPGst_normal); }
1912 | SecLabelStmt
1913 { output_statement($1, 0, ECPGst_normal); }
1914 | SelectStmt
1915 { output_statement($1, 1, ECPGst_prepnormal); }
1916 | TransactionStmt
1917 {
1918 fprintf(base_yyout, "{ ECPGtrans(__LINE__, %s, \"%s\");", connection ? connection : "NULL", $1);
1919 whenever_action(2);
1920 free($1);
1921 }
1922 | TruncateStmt
1923 { output_statement($1, 0, ECPGst_normal); }
1924 | UnlistenStmt
1925 { output_statement($1, 0, ECPGst_normal); }
1926 | UpdateStmt
1927 { output_statement($1, 1, ECPGst_prepnormal); }
1928 | VacuumStmt
1929 { output_statement($1, 0, ECPGst_normal); }
1930 | VariableResetStmt
1931 { output_statement($1, 0, ECPGst_normal); }
1932 | VariableSetStmt
1933 { output_statement($1, 0, ECPGst_normal); }
1934 | VariableShowStmt
1935 { output_statement($1, 0, ECPGst_normal); }
1936 | ViewStmt
1937 { output_statement($1, 0, ECPGst_normal); }
1938 | ECPGAllocateDescr
1939 {
1940 fprintf(base_yyout,"ECPGallocate_desc(__LINE__, %s);",$1);
1941 whenever_action(0);
1942 free($1);
1943 }
1944 | ECPGConnect
1945 {
1946 if (connection)
1947 mmerror(PARSE_ERROR, ET_ERROR, "AT option not allowed in CONNECT statement");
1948
1949 fprintf(base_yyout, "{ ECPGconnect(__LINE__, %d, %s, %d); ", compat, $1, autocommit);
1950 reset_variables();
1951 whenever_action(2);
1952 free($1);
1953 }
1954 | ECPGCursorStmt
1955 {
1956 output_simple_statement($1, (strncmp($1, "ECPGset_var", strlen("ECPGset_var")) == 0) ? 4 : 0);
1957 }
1958 | ECPGDeallocateDescr
1959 {
1960 fprintf(base_yyout,"ECPGdeallocate_desc(__LINE__, %s);",$1);
1961 whenever_action(0);
1962 free($1);
1963 }
1964 | ECPGDeclare
1965 {
1966 output_simple_statement($1, 0);
1967 }
1968 | ECPGDescribe
1969 {
1970 fprintf(base_yyout, "{ ECPGdescribe(__LINE__, %d, %s,", compat, $1);
1971 dump_variables(argsresult, 1);
1972 fputs("ECPGt_EORT);", base_yyout);
1973 fprintf(base_yyout, "}");
1974 output_line_number();
1975
1976 free($1);
1977 }
1978 | ECPGDisconnect
1979 {
1980 if (connection)
1981 mmerror(PARSE_ERROR, ET_ERROR, "AT option not allowed in DISCONNECT statement");
1982
1983 fprintf(base_yyout, "{ ECPGdisconnect(__LINE__, %s);",
1984 $1 ? $1 : "\"CURRENT\"");
1985 whenever_action(2);
1986 free($1);
1987 }
1988 | ECPGExecuteImmediateStmt { output_statement($1, 0, ECPGst_exec_immediate); }
1989 | ECPGFree
1990 {
1991 const char *con = connection ? connection : "NULL";
1992
1993 if (strcmp($1, "all") == 0)
1994 fprintf(base_yyout, "{ ECPGdeallocate_all(__LINE__, %d, %s);", compat, con);
1995 else if ($1[0] == ':')
1996 fprintf(base_yyout, "{ ECPGdeallocate(__LINE__, %d, %s, %s);", compat, con, $1+1);
1997 else
1998 fprintf(base_yyout, "{ ECPGdeallocate(__LINE__, %d, %s, \"%s\");", compat, con, $1);
1999
2000 whenever_action(2);
2001 free($1);
2002 }
2003 | ECPGGetDescriptor
2004 {
2005 lookup_descriptor($1.name, connection);
2006 output_get_descr($1.name, $1.str);
2007 free($1.name);
2008 free($1.str);
2009 }
2010 | ECPGGetDescriptorHeader
2011 {
2012 lookup_descriptor($1, connection);
2013 output_get_descr_header($1);
2014 free($1);
2015 }
2016 | ECPGOpen
2017 {
2018 struct cursor *ptr;
2019
2020 if ((ptr = add_additional_variables($1, true)) != NULL)
2021 {
2022 connection = ptr->connection ? mm_strdup(ptr->connection) : NULL;
2023 output_statement(mm_strdup(ptr->command), 0, ECPGst_normal);
2024 ptr->opened = true;
2025 }
2026 }
2027 | ECPGSetAutocommit
2028 {
2029 fprintf(base_yyout, "{ ECPGsetcommit(__LINE__, \"%s\", %s);", $1, connection ? connection : "NULL");
2030 whenever_action(2);
2031 free($1);
2032 }
2033 | ECPGSetConnection
2034 {
2035 if (connection)
2036 mmerror(PARSE_ERROR, ET_ERROR, "AT option not allowed in SET CONNECTION statement");
2037
2038 fprintf(base_yyout, "{ ECPGsetconn(__LINE__, %s);", $1);
2039 whenever_action(2);
2040 free($1);
2041 }
2042 | ECPGSetDescriptor
2043 {
2044 lookup_descriptor($1.name, connection);
2045 output_set_descr($1.name, $1.str);
2046 free($1.name);
2047 free($1.str);
2048 }
2049 | ECPGSetDescriptorHeader
2050 {
2051 lookup_descriptor($1, connection);
2052 output_set_descr_header($1);
2053 free($1);
2054 }
2055 | ECPGTypedef
2056 {
2057 if (connection)
2058 mmerror(PARSE_ERROR, ET_ERROR, "AT option not allowed in TYPE statement");
2059
2060 fprintf(base_yyout, "%s", $1);
2061 free($1);
2062 output_line_number();
2063 }
2064 | ECPGVar
2065 {
2066 if (connection)
2067 mmerror(PARSE_ERROR, ET_ERROR, "AT option not allowed in VAR statement");
2068
2069 output_simple_statement($1, 0);
2070 }
2071 | ECPGWhenever
2072 {
2073 if (connection)
2074 mmerror(PARSE_ERROR, ET_ERROR, "AT option not allowed in WHENEVER statement");
2075
2076 output_simple_statement($1, 0);
2077 }
2078 |
2079 { $$ = NULL; }
2080 ;
2081
2082
2083 CallStmt:
2084 CALL func_application
2085 {
2086 $$ = cat_str(2,mm_strdup("call"),$2);
2087 }
2088 ;
2089
2090
2091 CreateRoleStmt:
2092 CREATE ROLE RoleId opt_with OptRoleList
2093 {
2094 $$ = cat_str(4,mm_strdup("create role"),$3,$4,$5);
2095 }
2096 ;
2097
2098
2099 opt_with:
2100 WITH
2101 {
2102 $$ = mm_strdup("with");
2103 }
2104 | WITH_LA
2105 {
2106 $$ = mm_strdup("with");
2107 }
2108 |
2109 {
2110 $$=EMPTY; }
2111 ;
2112
2113
2114 OptRoleList:
2115 OptRoleList CreateOptRoleElem
2116 {
2117 $$ = cat_str(2,$1,$2);
2118 }
2119 |
2120 {
2121 $$=EMPTY; }
2122 ;
2123
2124
2125 AlterOptRoleList:
2126 AlterOptRoleList AlterOptRoleElem
2127 {
2128 $$ = cat_str(2,$1,$2);
2129 }
2130 |
2131 {
2132 $$=EMPTY; }
2133 ;
2134
2135
2136 AlterOptRoleElem:
2137 PASSWORD ecpg_sconst
2138 {
2139 $$ = cat_str(2,mm_strdup("password"),$2);
2140 }
2141 | PASSWORD NULL_P
2142 {
2143 $$ = mm_strdup("password null");
2144 }
2145 | ENCRYPTED PASSWORD ecpg_sconst
2146 {
2147 $$ = cat_str(2,mm_strdup("encrypted password"),$3);
2148 }
2149 | UNENCRYPTED PASSWORD ecpg_sconst
2150 {
2151 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
2152 $$ = cat_str(2,mm_strdup("unencrypted password"),$3);
2153 }
2154 | INHERIT
2155 {
2156 $$ = mm_strdup("inherit");
2157 }
2158 | CONNECTION LIMIT SignedIconst
2159 {
2160 $$ = cat_str(2,mm_strdup("connection limit"),$3);
2161 }
2162 | VALID UNTIL ecpg_sconst
2163 {
2164 $$ = cat_str(2,mm_strdup("valid until"),$3);
2165 }
2166 | USER role_list
2167 {
2168 $$ = cat_str(2,mm_strdup("user"),$2);
2169 }
2170 | ecpg_ident
2171 {
2172 $$ = $1;
2173 }
2174 ;
2175
2176
2177 CreateOptRoleElem:
2178 AlterOptRoleElem
2179 {
2180 $$ = $1;
2181 }
2182 | SYSID Iconst
2183 {
2184 $$ = cat_str(2,mm_strdup("sysid"),$2);
2185 }
2186 | ADMIN role_list
2187 {
2188 $$ = cat_str(2,mm_strdup("admin"),$2);
2189 }
2190 | ROLE role_list
2191 {
2192 $$ = cat_str(2,mm_strdup("role"),$2);
2193 }
2194 | IN_P ROLE role_list
2195 {
2196 $$ = cat_str(2,mm_strdup("in role"),$3);
2197 }
2198 | IN_P GROUP_P role_list
2199 {
2200 $$ = cat_str(2,mm_strdup("in group"),$3);
2201 }
2202 ;
2203
2204
2205 CreateUserStmt:
2206 CREATE USER RoleId opt_with OptRoleList
2207 {
2208 $$ = cat_str(4,mm_strdup("create user"),$3,$4,$5);
2209 }
2210 ;
2211
2212
2213 AlterRoleStmt:
2214 ALTER ROLE RoleSpec opt_with AlterOptRoleList
2215 {
2216 $$ = cat_str(4,mm_strdup("alter role"),$3,$4,$5);
2217 }
2218 | ALTER USER RoleSpec opt_with AlterOptRoleList
2219 {
2220 $$ = cat_str(4,mm_strdup("alter user"),$3,$4,$5);
2221 }
2222 ;
2223
2224
2225 opt_in_database:
2226
2227 {
2228 $$=EMPTY; }
2229 | IN_P DATABASE database_name
2230 {
2231 $$ = cat_str(2,mm_strdup("in database"),$3);
2232 }
2233 ;
2234
2235
2236 AlterRoleSetStmt:
2237 ALTER ROLE RoleSpec opt_in_database SetResetClause
2238 {
2239 $$ = cat_str(4,mm_strdup("alter role"),$3,$4,$5);
2240 }
2241 | ALTER ROLE ALL opt_in_database SetResetClause
2242 {
2243 $$ = cat_str(3,mm_strdup("alter role all"),$4,$5);
2244 }
2245 | ALTER USER RoleSpec opt_in_database SetResetClause
2246 {
2247 $$ = cat_str(4,mm_strdup("alter user"),$3,$4,$5);
2248 }
2249 | ALTER USER ALL opt_in_database SetResetClause
2250 {
2251 $$ = cat_str(3,mm_strdup("alter user all"),$4,$5);
2252 }
2253 ;
2254
2255
2256 DropRoleStmt:
2257 DROP ROLE role_list
2258 {
2259 $$ = cat_str(2,mm_strdup("drop role"),$3);
2260 }
2261 | DROP ROLE IF_P EXISTS role_list
2262 {
2263 $$ = cat_str(2,mm_strdup("drop role if exists"),$5);
2264 }
2265 | DROP USER role_list
2266 {
2267 $$ = cat_str(2,mm_strdup("drop user"),$3);
2268 }
2269 | DROP USER IF_P EXISTS role_list
2270 {
2271 $$ = cat_str(2,mm_strdup("drop user if exists"),$5);
2272 }
2273 | DROP GROUP_P role_list
2274 {
2275 $$ = cat_str(2,mm_strdup("drop group"),$3);
2276 }
2277 | DROP GROUP_P IF_P EXISTS role_list
2278 {
2279 $$ = cat_str(2,mm_strdup("drop group if exists"),$5);
2280 }
2281 ;
2282
2283
2284 CreateGroupStmt:
2285 CREATE GROUP_P RoleId opt_with OptRoleList
2286 {
2287 $$ = cat_str(4,mm_strdup("create group"),$3,$4,$5);
2288 }
2289 ;
2290
2291
2292 AlterGroupStmt:
2293 ALTER GROUP_P RoleSpec add_drop USER role_list
2294 {
2295 $$ = cat_str(5,mm_strdup("alter group"),$3,$4,mm_strdup("user"),$6);
2296 }
2297 ;
2298
2299
2300 add_drop:
2301 ADD_P
2302 {
2303 $$ = mm_strdup("add");
2304 }
2305 | DROP
2306 {
2307 $$ = mm_strdup("drop");
2308 }
2309 ;
2310
2311
2312 CreateSchemaStmt:
2313 CREATE SCHEMA OptSchemaName AUTHORIZATION RoleSpec OptSchemaEltList
2314 {
2315 $$ = cat_str(5,mm_strdup("create schema"),$3,mm_strdup("authorization"),$5,$6);
2316 }
2317 | CREATE SCHEMA ColId OptSchemaEltList
2318 {
2319 $$ = cat_str(3,mm_strdup("create schema"),$3,$4);
2320 }
2321 | CREATE SCHEMA IF_P NOT EXISTS OptSchemaName AUTHORIZATION RoleSpec OptSchemaEltList
2322 {
2323 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
2324 $$ = cat_str(5,mm_strdup("create schema if not exists"),$6,mm_strdup("authorization"),$8,$9);
2325 }
2326 | CREATE SCHEMA IF_P NOT EXISTS ColId OptSchemaEltList
2327 {
2328 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
2329 $$ = cat_str(3,mm_strdup("create schema if not exists"),$6,$7);
2330 }
2331 ;
2332
2333
2334 OptSchemaName:
2335 ColId
2336 {
2337 $$ = $1;
2338 }
2339 |
2340 {
2341 $$=EMPTY; }
2342 ;
2343
2344
2345 OptSchemaEltList:
2346 OptSchemaEltList schema_stmt
2347 {
2348 $$ = cat_str(2,$1,$2);
2349 }
2350 |
2351 {
2352 $$=EMPTY; }
2353 ;
2354
2355
2356 schema_stmt:
2357 CreateStmt
2358 {
2359 $$ = $1;
2360 }
2361 | IndexStmt
2362 {
2363 $$ = $1;
2364 }
2365 | CreateSeqStmt
2366 {
2367 $$ = $1;
2368 }
2369 | CreateTrigStmt
2370 {
2371 $$ = $1;
2372 }
2373 | GrantStmt
2374 {
2375 $$ = $1;
2376 }
2377 | ViewStmt
2378 {
2379 $$ = $1;
2380 }
2381 ;
2382
2383
2384 VariableSetStmt:
2385 SET set_rest
2386 {
2387 $$ = cat_str(2,mm_strdup("set"),$2);
2388 }
2389 | SET LOCAL set_rest
2390 {
2391 $$ = cat_str(2,mm_strdup("set local"),$3);
2392 }
2393 | SET SESSION set_rest
2394 {
2395 $$ = cat_str(2,mm_strdup("set session"),$3);
2396 }
2397 ;
2398
2399
2400 set_rest:
2401 TRANSACTION transaction_mode_list
2402 {
2403 $$ = cat_str(2,mm_strdup("transaction"),$2);
2404 }
2405 | SESSION CHARACTERISTICS AS TRANSACTION transaction_mode_list
2406 {
2407 $$ = cat_str(2,mm_strdup("session characteristics as transaction"),$5);
2408 }
2409 | set_rest_more
2410 {
2411 $$ = $1;
2412 }
2413 ;
2414
2415
2416 generic_set:
2417 var_name TO var_list
2418 {
2419 $$ = cat_str(3,$1,mm_strdup("to"),$3);
2420 }
2421 | var_name '=' var_list
2422 {
2423 $$ = cat_str(3,$1,mm_strdup("="),$3);
2424 }
2425 | var_name TO DEFAULT
2426 {
2427 $$ = cat_str(2,$1,mm_strdup("to default"));
2428 }
2429 | var_name '=' DEFAULT
2430 {
2431 $$ = cat_str(2,$1,mm_strdup("= default"));
2432 }
2433 ;
2434
2435
2436 set_rest_more:
2437 generic_set
2438 {
2439 $$ = $1;
2440 }
2441 | var_name FROM CURRENT_P
2442 {
2443 $$ = cat_str(2,$1,mm_strdup("from current"));
2444 }
2445 | TIME ZONE zone_value
2446 {
2447 $$ = cat_str(2,mm_strdup("time zone"),$3);
2448 }
2449 | CATALOG_P ecpg_sconst
2450 {
2451 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
2452 $$ = cat_str(2,mm_strdup("catalog"),$2);
2453 }
2454 | SCHEMA ecpg_sconst
2455 {
2456 $$ = cat_str(2,mm_strdup("schema"),$2);
2457 }
2458 | NAMES opt_encoding
2459 {
2460 $$ = cat_str(2,mm_strdup("names"),$2);
2461 }
2462 | ROLE NonReservedWord_or_Sconst
2463 {
2464 $$ = cat_str(2,mm_strdup("role"),$2);
2465 }
2466 | SESSION AUTHORIZATION NonReservedWord_or_Sconst
2467 {
2468 $$ = cat_str(2,mm_strdup("session authorization"),$3);
2469 }
2470 | SESSION AUTHORIZATION DEFAULT
2471 {
2472 $$ = mm_strdup("session authorization default");
2473 }
2474 | XML_P OPTION document_or_content
2475 {
2476 $$ = cat_str(2,mm_strdup("xml option"),$3);
2477 }
2478 | TRANSACTION SNAPSHOT ecpg_sconst
2479 {
2480 $$ = cat_str(2,mm_strdup("transaction snapshot"),$3);
2481 }
2482 ;
2483
2484
2485 var_name:
2486 ECPGColId
2487 {
2488 $$ = $1;
2489 }
2490 | var_name '.' ColId
2491 {
2492 $$ = cat_str(3,$1,mm_strdup("."),$3);
2493 }
2494 ;
2495
2496
2497 var_list:
2498 var_value
2499 {
2500 $$ = $1;
2501 }
2502 | var_list ',' var_value
2503 {
2504 $$ = cat_str(3,$1,mm_strdup(","),$3);
2505 }
2506 ;
2507
2508
2509 var_value:
2510 opt_boolean_or_string
2511 {
2512 $$ = $1;
2513 }
2514 | NumericOnly
2515 {
2516 if ($1[0] == '$')
2517 {
2518 free($1);
2519 $1 = mm_strdup("$0");
2520 }
2521
2522 $$ = $1;
2523 }
2524 ;
2525
2526
2527 iso_level:
2528 READ UNCOMMITTED
2529 {
2530 $$ = mm_strdup("read uncommitted");
2531 }
2532 | READ COMMITTED
2533 {
2534 $$ = mm_strdup("read committed");
2535 }
2536 | REPEATABLE READ
2537 {
2538 $$ = mm_strdup("repeatable read");
2539 }
2540 | SERIALIZABLE
2541 {
2542 $$ = mm_strdup("serializable");
2543 }
2544 ;
2545
2546
2547 opt_boolean_or_string:
2548 TRUE_P
2549 {
2550 $$ = mm_strdup("true");
2551 }
2552 | FALSE_P
2553 {
2554 $$ = mm_strdup("false");
2555 }
2556 | ON
2557 {
2558 $$ = mm_strdup("on");
2559 }
2560 | NonReservedWord_or_Sconst
2561 {
2562 $$ = $1;
2563 }
2564 ;
2565
2566
2567 zone_value:
2568 ecpg_sconst
2569 {
2570 $$ = $1;
2571 }
2572 | ecpg_ident
2573 {
2574 $$ = $1;
2575 }
2576 | ConstInterval ecpg_sconst opt_interval
2577 {
2578 $$ = cat_str(3,$1,$2,$3);
2579 }
2580 | ConstInterval '(' Iconst ')' ecpg_sconst
2581 {
2582 $$ = cat_str(5,$1,mm_strdup("("),$3,mm_strdup(")"),$5);
2583 }
2584 | NumericOnly
2585 {
2586 $$ = $1;
2587 }
2588 | DEFAULT
2589 {
2590 $$ = mm_strdup("default");
2591 }
2592 | LOCAL
2593 {
2594 $$ = mm_strdup("local");
2595 }
2596 ;
2597
2598
2599 opt_encoding:
2600 ecpg_sconst
2601 {
2602 $$ = $1;
2603 }
2604 | DEFAULT
2605 {
2606 $$ = mm_strdup("default");
2607 }
2608 |
2609 {
2610 $$=EMPTY; }
2611 ;
2612
2613
2614 NonReservedWord_or_Sconst:
2615 NonReservedWord
2616 {
2617 $$ = $1;
2618 }
2619 | ecpg_sconst
2620 {
2621 $$ = $1;
2622 }
2623 ;
2624
2625
2626 VariableResetStmt:
2627 RESET reset_rest
2628 {
2629 $$ = cat_str(2,mm_strdup("reset"),$2);
2630 }
2631 ;
2632
2633
2634 reset_rest:
2635 generic_reset
2636 {
2637 $$ = $1;
2638 }
2639 | TIME ZONE
2640 {
2641 $$ = mm_strdup("time zone");
2642 }
2643 | TRANSACTION ISOLATION LEVEL
2644 {
2645 $$ = mm_strdup("transaction isolation level");
2646 }
2647 | SESSION AUTHORIZATION
2648 {
2649 $$ = mm_strdup("session authorization");
2650 }
2651 ;
2652
2653
2654 generic_reset:
2655 var_name
2656 {
2657 $$ = $1;
2658 }
2659 | ALL
2660 {
2661 $$ = mm_strdup("all");
2662 }
2663 ;
2664
2665
2666 SetResetClause:
2667 SET set_rest
2668 {
2669 $$ = cat_str(2,mm_strdup("set"),$2);
2670 }
2671 | VariableResetStmt
2672 {
2673 $$ = $1;
2674 }
2675 ;
2676
2677
2678 FunctionSetResetClause:
2679 SET set_rest_more
2680 {
2681 $$ = cat_str(2,mm_strdup("set"),$2);
2682 }
2683 | VariableResetStmt
2684 {
2685 $$ = $1;
2686 }
2687 ;
2688
2689
2690 VariableShowStmt:
2691 SHOW var_name ecpg_into
2692 {
2693 $$ = cat_str(2,mm_strdup("show"),$2);
2694 }
2695 | SHOW TIME ZONE ecpg_into
2696 {
2697 $$ = mm_strdup("show time zone");
2698 }
2699 | SHOW TRANSACTION ISOLATION LEVEL ecpg_into
2700 {
2701 $$ = mm_strdup("show transaction isolation level");
2702 }
2703 | SHOW SESSION AUTHORIZATION ecpg_into
2704 {
2705 $$ = mm_strdup("show session authorization");
2706 }
2707 | SHOW ALL
2708 {
2709 mmerror(PARSE_ERROR, ET_ERROR, "SHOW ALL is not implemented");
2710 $$ = EMPTY;
2711 }
2712 ;
2713
2714
2715 ConstraintsSetStmt:
2716 SET CONSTRAINTS constraints_set_list constraints_set_mode
2717 {
2718 $$ = cat_str(3,mm_strdup("set constraints"),$3,$4);
2719 }
2720 ;
2721
2722
2723 constraints_set_list:
2724 ALL
2725 {
2726 $$ = mm_strdup("all");
2727 }
2728 | qualified_name_list
2729 {
2730 $$ = $1;
2731 }
2732 ;
2733
2734
2735 constraints_set_mode:
2736 DEFERRED
2737 {
2738 $$ = mm_strdup("deferred");
2739 }
2740 | IMMEDIATE
2741 {
2742 $$ = mm_strdup("immediate");
2743 }
2744 ;
2745
2746
2747 CheckPointStmt:
2748 CHECKPOINT
2749 {
2750 $$ = mm_strdup("checkpoint");
2751 }
2752 ;
2753
2754
2755 DiscardStmt:
2756 DISCARD ALL
2757 {
2758 $$ = mm_strdup("discard all");
2759 }
2760 | DISCARD TEMP
2761 {
2762 $$ = mm_strdup("discard temp");
2763 }
2764 | DISCARD TEMPORARY
2765 {
2766 $$ = mm_strdup("discard temporary");
2767 }
2768 | DISCARD PLANS
2769 {
2770 $$ = mm_strdup("discard plans");
2771 }
2772 | DISCARD SEQUENCES
2773 {
2774 $$ = mm_strdup("discard sequences");
2775 }
2776 ;
2777
2778
2779 AlterTableStmt:
2780 ALTER TABLE relation_expr alter_table_cmds
2781 {
2782 $$ = cat_str(3,mm_strdup("alter table"),$3,$4);
2783 }
2784 | ALTER TABLE IF_P EXISTS relation_expr alter_table_cmds
2785 {
2786 $$ = cat_str(3,mm_strdup("alter table if exists"),$5,$6);
2787 }
2788 | ALTER TABLE relation_expr partition_cmd
2789 {
2790 $$ = cat_str(3,mm_strdup("alter table"),$3,$4);
2791 }
2792 | ALTER TABLE IF_P EXISTS relation_expr partition_cmd
2793 {
2794 $$ = cat_str(3,mm_strdup("alter table if exists"),$5,$6);
2795 }
2796 | ALTER TABLE ALL IN_P TABLESPACE name SET TABLESPACE name opt_nowait
2797 {
2798 $$ = cat_str(5,mm_strdup("alter table all in tablespace"),$6,mm_strdup("set tablespace"),$9,$10);
2799 }
2800 | ALTER TABLE ALL IN_P TABLESPACE name OWNED BY role_list SET TABLESPACE name opt_nowait
2801 {
2802 $$ = cat_str(7,mm_strdup("alter table all in tablespace"),$6,mm_strdup("owned by"),$9,mm_strdup("set tablespace"),$12,$13);
2803 }
2804 | ALTER INDEX qualified_name alter_table_cmds
2805 {
2806 $$ = cat_str(3,mm_strdup("alter index"),$3,$4);
2807 }
2808 | ALTER INDEX IF_P EXISTS qualified_name alter_table_cmds
2809 {
2810 $$ = cat_str(3,mm_strdup("alter index if exists"),$5,$6);
2811 }
2812 | ALTER INDEX qualified_name index_partition_cmd
2813 {
2814 $$ = cat_str(3,mm_strdup("alter index"),$3,$4);
2815 }
2816 | ALTER INDEX ALL IN_P TABLESPACE name SET TABLESPACE name opt_nowait
2817 {
2818 $$ = cat_str(5,mm_strdup("alter index all in tablespace"),$6,mm_strdup("set tablespace"),$9,$10);
2819 }
2820 | ALTER INDEX ALL IN_P TABLESPACE name OWNED BY role_list SET TABLESPACE name opt_nowait
2821 {
2822 $$ = cat_str(7,mm_strdup("alter index all in tablespace"),$6,mm_strdup("owned by"),$9,mm_strdup("set tablespace"),$12,$13);
2823 }
2824 | ALTER SEQUENCE qualified_name alter_table_cmds
2825 {
2826 $$ = cat_str(3,mm_strdup("alter sequence"),$3,$4);
2827 }
2828 | ALTER SEQUENCE IF_P EXISTS qualified_name alter_table_cmds
2829 {
2830 $$ = cat_str(3,mm_strdup("alter sequence if exists"),$5,$6);
2831 }
2832 | ALTER VIEW qualified_name alter_table_cmds
2833 {
2834 $$ = cat_str(3,mm_strdup("alter view"),$3,$4);
2835 }
2836 | ALTER VIEW IF_P EXISTS qualified_name alter_table_cmds
2837 {
2838 $$ = cat_str(3,mm_strdup("alter view if exists"),$5,$6);
2839 }
2840 | ALTER MATERIALIZED VIEW qualified_name alter_table_cmds
2841 {
2842 $$ = cat_str(3,mm_strdup("alter materialized view"),$4,$5);
2843 }
2844 | ALTER MATERIALIZED VIEW IF_P EXISTS qualified_name alter_table_cmds
2845 {
2846 $$ = cat_str(3,mm_strdup("alter materialized view if exists"),$6,$7);
2847 }
2848 | ALTER MATERIALIZED VIEW ALL IN_P TABLESPACE name SET TABLESPACE name opt_nowait
2849 {
2850 $$ = cat_str(5,mm_strdup("alter materialized view all in tablespace"),$7,mm_strdup("set tablespace"),$10,$11);
2851 }
2852 | ALTER MATERIALIZED VIEW ALL IN_P TABLESPACE name OWNED BY role_list SET TABLESPACE name opt_nowait
2853 {
2854 $$ = cat_str(7,mm_strdup("alter materialized view all in tablespace"),$7,mm_strdup("owned by"),$10,mm_strdup("set tablespace"),$13,$14);
2855 }
2856 ;
2857
2858
2859 alter_table_cmds:
2860 alter_table_cmd
2861 {
2862 $$ = $1;
2863 }
2864 | alter_table_cmds ',' alter_table_cmd
2865 {
2866 $$ = cat_str(3,$1,mm_strdup(","),$3);
2867 }
2868 ;
2869
2870
2871 partition_cmd:
2872 ATTACH PARTITION qualified_name PartitionBoundSpec
2873 {
2874 $$ = cat_str(3,mm_strdup("attach partition"),$3,$4);
2875 }
2876 | DETACH PARTITION qualified_name
2877 {
2878 $$ = cat_str(2,mm_strdup("detach partition"),$3);
2879 }
2880 ;
2881
2882
2883 index_partition_cmd:
2884 ATTACH PARTITION qualified_name
2885 {
2886 $$ = cat_str(2,mm_strdup("attach partition"),$3);
2887 }
2888 ;
2889
2890
2891 alter_table_cmd:
2892 ADD_P columnDef
2893 {
2894 $$ = cat_str(2,mm_strdup("add"),$2);
2895 }
2896 | ADD_P IF_P NOT EXISTS columnDef
2897 {
2898 $$ = cat_str(2,mm_strdup("add if not exists"),$5);
2899 }
2900 | ADD_P COLUMN columnDef
2901 {
2902 $$ = cat_str(2,mm_strdup("add column"),$3);
2903 }
2904 | ADD_P COLUMN IF_P NOT EXISTS columnDef
2905 {
2906 $$ = cat_str(2,mm_strdup("add column if not exists"),$6);
2907 }
2908 | ALTER opt_column ColId alter_column_default
2909 {
2910 $$ = cat_str(4,mm_strdup("alter"),$2,$3,$4);
2911 }
2912 | ALTER opt_column ColId DROP NOT NULL_P
2913 {
2914 $$ = cat_str(4,mm_strdup("alter"),$2,$3,mm_strdup("drop not null"));
2915 }
2916 | ALTER opt_column ColId SET NOT NULL_P
2917 {
2918 $$ = cat_str(4,mm_strdup("alter"),$2,$3,mm_strdup("set not null"));
2919 }
2920 | ALTER opt_column ColId SET STATISTICS SignedIconst
2921 {
2922 $$ = cat_str(5,mm_strdup("alter"),$2,$3,mm_strdup("set statistics"),$6);
2923 }
2924 | ALTER opt_column Iconst SET STATISTICS SignedIconst
2925 {
2926 $$ = cat_str(5,mm_strdup("alter"),$2,$3,mm_strdup("set statistics"),$6);
2927 }
2928 | ALTER opt_column ColId SET reloptions
2929 {
2930 $$ = cat_str(5,mm_strdup("alter"),$2,$3,mm_strdup("set"),$5);
2931 }
2932 | ALTER opt_column ColId RESET reloptions
2933 {
2934 $$ = cat_str(5,mm_strdup("alter"),$2,$3,mm_strdup("reset"),$5);
2935 }
2936 | ALTER opt_column ColId SET STORAGE ColId
2937 {
2938 $$ = cat_str(5,mm_strdup("alter"),$2,$3,mm_strdup("set storage"),$6);
2939 }
2940 | ALTER opt_column ColId ADD_P GENERATED generated_when AS IDENTITY_P OptParenthesizedSeqOptList
2941 {
2942 $$ = cat_str(7,mm_strdup("alter"),$2,$3,mm_strdup("add generated"),$6,mm_strdup("as identity"),$9);
2943 }
2944 | ALTER opt_column ColId alter_identity_column_option_list
2945 {
2946 $$ = cat_str(4,mm_strdup("alter"),$2,$3,$4);
2947 }
2948 | ALTER opt_column ColId DROP IDENTITY_P
2949 {
2950 $$ = cat_str(4,mm_strdup("alter"),$2,$3,mm_strdup("drop identity"));
2951 }
2952 | ALTER opt_column ColId DROP IDENTITY_P IF_P EXISTS
2953 {
2954 $$ = cat_str(4,mm_strdup("alter"),$2,$3,mm_strdup("drop identity if exists"));
2955 }
2956 | DROP opt_column IF_P EXISTS ColId opt_drop_behavior
2957 {
2958 $$ = cat_str(5,mm_strdup("drop"),$2,mm_strdup("if exists"),$5,$6);
2959 }
2960 | DROP opt_column ColId opt_drop_behavior
2961 {
2962 $$ = cat_str(4,mm_strdup("drop"),$2,$3,$4);
2963 }
2964 | ALTER opt_column ColId opt_set_data TYPE_P Typename opt_collate_clause alter_using
2965 {
2966 $$ = cat_str(8,mm_strdup("alter"),$2,$3,$4,mm_strdup("type"),$6,$7,$8);
2967 }
2968 | ALTER opt_column ColId alter_generic_options
2969 {
2970 $$ = cat_str(4,mm_strdup("alter"),$2,$3,$4);
2971 }
2972 | ADD_P TableConstraint
2973 {
2974 $$ = cat_str(2,mm_strdup("add"),$2);
2975 }
2976 | ALTER CONSTRAINT name ConstraintAttributeSpec
2977 {
2978 $$ = cat_str(3,mm_strdup("alter constraint"),$3,$4);
2979 }
2980 | VALIDATE CONSTRAINT name
2981 {
2982 $$ = cat_str(2,mm_strdup("validate constraint"),$3);
2983 }
2984 | DROP CONSTRAINT IF_P EXISTS name opt_drop_behavior
2985 {
2986 $$ = cat_str(3,mm_strdup("drop constraint if exists"),$5,$6);
2987 }
2988 | DROP CONSTRAINT name opt_drop_behavior
2989 {
2990 $$ = cat_str(3,mm_strdup("drop constraint"),$3,$4);
2991 }
2992 | SET WITHOUT OIDS
2993 {
2994 $$ = mm_strdup("set without oids");
2995 }
2996 | CLUSTER ON name
2997 {
2998 $$ = cat_str(2,mm_strdup("cluster on"),$3);
2999 }
3000 | SET WITHOUT CLUSTER
3001 {
3002 $$ = mm_strdup("set without cluster");
3003 }
3004 | SET LOGGED
3005 {
3006 $$ = mm_strdup("set logged");
3007 }
3008 | SET UNLOGGED
3009 {
3010 $$ = mm_strdup("set unlogged");
3011 }
3012 | ENABLE_P TRIGGER name
3013 {
3014 $$ = cat_str(2,mm_strdup("enable trigger"),$3);
3015 }
3016 | ENABLE_P ALWAYS TRIGGER name
3017 {
3018 $$ = cat_str(2,mm_strdup("enable always trigger"),$4);
3019 }
3020 | ENABLE_P REPLICA TRIGGER name
3021 {
3022 $$ = cat_str(2,mm_strdup("enable replica trigger"),$4);
3023 }
3024 | ENABLE_P TRIGGER ALL
3025 {
3026 $$ = mm_strdup("enable trigger all");
3027 }
3028 | ENABLE_P TRIGGER USER
3029 {
3030 $$ = mm_strdup("enable trigger user");
3031 }
3032 | DISABLE_P TRIGGER name
3033 {
3034 $$ = cat_str(2,mm_strdup("disable trigger"),$3);
3035 }
3036 | DISABLE_P TRIGGER ALL
3037 {
3038 $$ = mm_strdup("disable trigger all");
3039 }
3040 | DISABLE_P TRIGGER USER
3041 {
3042 $$ = mm_strdup("disable trigger user");
3043 }
3044 | ENABLE_P RULE name
3045 {
3046 $$ = cat_str(2,mm_strdup("enable rule"),$3);
3047 }
3048 | ENABLE_P ALWAYS RULE name
3049 {
3050 $$ = cat_str(2,mm_strdup("enable always rule"),$4);
3051 }
3052 | ENABLE_P REPLICA RULE name
3053 {
3054 $$ = cat_str(2,mm_strdup("enable replica rule"),$4);
3055 }
3056 | DISABLE_P RULE name
3057 {
3058 $$ = cat_str(2,mm_strdup("disable rule"),$3);
3059 }
3060 | INHERIT qualified_name
3061 {
3062 $$ = cat_str(2,mm_strdup("inherit"),$2);
3063 }
3064 | NO INHERIT qualified_name
3065 {
3066 $$ = cat_str(2,mm_strdup("no inherit"),$3);
3067 }
3068 | OF any_name
3069 {
3070 $$ = cat_str(2,mm_strdup("of"),$2);
3071 }
3072 | NOT OF
3073 {
3074 $$ = mm_strdup("not of");
3075 }
3076 | OWNER TO RoleSpec
3077 {
3078 $$ = cat_str(2,mm_strdup("owner to"),$3);
3079 }
3080 | SET TABLESPACE name
3081 {
3082 $$ = cat_str(2,mm_strdup("set tablespace"),$3);
3083 }
3084 | SET reloptions
3085 {
3086 $$ = cat_str(2,mm_strdup("set"),$2);
3087 }
3088 | RESET reloptions
3089 {
3090 $$ = cat_str(2,mm_strdup("reset"),$2);
3091 }
3092 | REPLICA IDENTITY_P replica_identity
3093 {
3094 $$ = cat_str(2,mm_strdup("replica identity"),$3);
3095 }
3096 | ENABLE_P ROW LEVEL SECURITY
3097 {
3098 $$ = mm_strdup("enable row level security");
3099 }
3100 | DISABLE_P ROW LEVEL SECURITY
3101 {
3102 $$ = mm_strdup("disable row level security");
3103 }
3104 | FORCE ROW LEVEL SECURITY
3105 {
3106 $$ = mm_strdup("force row level security");
3107 }
3108 | NO FORCE ROW LEVEL SECURITY
3109 {
3110 $$ = mm_strdup("no force row level security");
3111 }
3112 | alter_generic_options
3113 {
3114 $$ = $1;
3115 }
3116 ;
3117
3118
3119 alter_column_default:
3120 SET DEFAULT a_expr
3121 {
3122 $$ = cat_str(2,mm_strdup("set default"),$3);
3123 }
3124 | DROP DEFAULT
3125 {
3126 $$ = mm_strdup("drop default");
3127 }
3128 ;
3129
3130
3131 opt_drop_behavior:
3132 CASCADE
3133 {
3134 $$ = mm_strdup("cascade");
3135 }
3136 | RESTRICT
3137 {
3138 $$ = mm_strdup("restrict");
3139 }
3140 |
3141 {
3142 $$=EMPTY; }
3143 ;
3144
3145
3146 opt_collate_clause:
3147 COLLATE any_name
3148 {
3149 $$ = cat_str(2,mm_strdup("collate"),$2);
3150 }
3151 |
3152 {
3153 $$=EMPTY; }
3154 ;
3155
3156
3157 alter_using:
3158 USING a_expr
3159 {
3160 $$ = cat_str(2,mm_strdup("using"),$2);
3161 }
3162 |
3163 {
3164 $$=EMPTY; }
3165 ;
3166
3167
3168 replica_identity:
3169 NOTHING
3170 {
3171 $$ = mm_strdup("nothing");
3172 }
3173 | FULL
3174 {
3175 $$ = mm_strdup("full");
3176 }
3177 | DEFAULT
3178 {
3179 $$ = mm_strdup("default");
3180 }
3181 | USING INDEX name
3182 {
3183 $$ = cat_str(2,mm_strdup("using index"),$3);
3184 }
3185 ;
3186
3187
3188 reloptions:
3189 '(' reloption_list ')'
3190 {
3191 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
3192 }
3193 ;
3194
3195
3196 opt_reloptions:
3197 WITH reloptions
3198 {
3199 $$ = cat_str(2,mm_strdup("with"),$2);
3200 }
3201 |
3202 {
3203 $$=EMPTY; }
3204 ;
3205
3206
3207 reloption_list:
3208 reloption_elem
3209 {
3210 $$ = $1;
3211 }
3212 | reloption_list ',' reloption_elem
3213 {
3214 $$ = cat_str(3,$1,mm_strdup(","),$3);
3215 }
3216 ;
3217
3218
3219 reloption_elem:
3220 ColLabel '=' def_arg
3221 {
3222 $$ = cat_str(3,$1,mm_strdup("="),$3);
3223 }
3224 | ColLabel
3225 {
3226 $$ = $1;
3227 }
3228 | ColLabel '.' ColLabel '=' def_arg
3229 {
3230 $$ = cat_str(5,$1,mm_strdup("."),$3,mm_strdup("="),$5);
3231 }
3232 | ColLabel '.' ColLabel
3233 {
3234 $$ = cat_str(3,$1,mm_strdup("."),$3);
3235 }
3236 ;
3237
3238
3239 alter_identity_column_option_list:
3240 alter_identity_column_option
3241 {
3242 $$ = $1;
3243 }
3244 | alter_identity_column_option_list alter_identity_column_option
3245 {
3246 $$ = cat_str(2,$1,$2);
3247 }
3248 ;
3249
3250
3251 alter_identity_column_option:
3252 RESTART
3253 {
3254 $$ = mm_strdup("restart");
3255 }
3256 | RESTART opt_with NumericOnly
3257 {
3258 $$ = cat_str(3,mm_strdup("restart"),$2,$3);
3259 }
3260 | SET SeqOptElem
3261 {
3262 $$ = cat_str(2,mm_strdup("set"),$2);
3263 }
3264 | SET GENERATED generated_when
3265 {
3266 $$ = cat_str(2,mm_strdup("set generated"),$3);
3267 }
3268 ;
3269
3270
3271 PartitionBoundSpec:
3272 FOR VALUES WITH '(' hash_partbound ')'
3273 {
3274 $$ = cat_str(3,mm_strdup("for values with ("),$5,mm_strdup(")"));
3275 }
3276 | FOR VALUES IN_P '(' expr_list ')'
3277 {
3278 $$ = cat_str(3,mm_strdup("for values in ("),$5,mm_strdup(")"));
3279 }
3280 | FOR VALUES FROM '(' expr_list ')' TO '(' expr_list ')'
3281 {
3282 $$ = cat_str(5,mm_strdup("for values from ("),$5,mm_strdup(") to ("),$9,mm_strdup(")"));
3283 }
3284 | DEFAULT
3285 {
3286 $$ = mm_strdup("default");
3287 }
3288 ;
3289
3290
3291 hash_partbound_elem:
3292 NonReservedWord Iconst
3293 {
3294 $$ = cat_str(2,$1,$2);
3295 }
3296 ;
3297
3298
3299 hash_partbound:
3300 hash_partbound_elem
3301 {
3302 $$ = $1;
3303 }
3304 | hash_partbound ',' hash_partbound_elem
3305 {
3306 $$ = cat_str(3,$1,mm_strdup(","),$3);
3307 }
3308 ;
3309
3310
3311 AlterCompositeTypeStmt:
3312 ALTER TYPE_P any_name alter_type_cmds
3313 {
3314 $$ = cat_str(3,mm_strdup("alter type"),$3,$4);
3315 }
3316 ;
3317
3318
3319 alter_type_cmds:
3320 alter_type_cmd
3321 {
3322 $$ = $1;
3323 }
3324 | alter_type_cmds ',' alter_type_cmd
3325 {
3326 $$ = cat_str(3,$1,mm_strdup(","),$3);
3327 }
3328 ;
3329
3330
3331 alter_type_cmd:
3332 ADD_P ATTRIBUTE TableFuncElement opt_drop_behavior
3333 {
3334 $$ = cat_str(3,mm_strdup("add attribute"),$3,$4);
3335 }
3336 | DROP ATTRIBUTE IF_P EXISTS ColId opt_drop_behavior
3337 {
3338 $$ = cat_str(3,mm_strdup("drop attribute if exists"),$5,$6);
3339 }
3340 | DROP ATTRIBUTE ColId opt_drop_behavior
3341 {
3342 $$ = cat_str(3,mm_strdup("drop attribute"),$3,$4);
3343 }
3344 | ALTER ATTRIBUTE ColId opt_set_data TYPE_P Typename opt_collate_clause opt_drop_behavior
3345 {
3346 $$ = cat_str(7,mm_strdup("alter attribute"),$3,$4,mm_strdup("type"),$6,$7,$8);
3347 }
3348 ;
3349
3350
3351 ClosePortalStmt:
3352 CLOSE cursor_name
3353 {
3354 char *cursor_marker = $2[0] == ':' ? mm_strdup("$0") : $2;
3355 $$ = cat2_str(mm_strdup("close"), cursor_marker);
3356 }
3357 | CLOSE ALL
3358 {
3359 $$ = mm_strdup("close all");
3360 }
3361 ;
3362
3363
3364 CopyStmt:
3365 COPY opt_binary qualified_name opt_column_list copy_from opt_program copy_file_name copy_delimiter opt_with copy_options where_clause
3366 {
3367 if (strcmp($6, "from") == 0 &&
3368 (strcmp($7, "stdin") == 0 || strcmp($7, "stdout") == 0))
3369 mmerror(PARSE_ERROR, ET_WARNING, "COPY FROM STDIN is not implemented");
3370
3371 $$ = cat_str(11,mm_strdup("copy"),$2,$3,$4,$5,$6,$7,$8,$9,$10,$11);
3372 }
3373 | COPY '(' PreparableStmt ')' TO opt_program copy_file_name opt_with copy_options
3374 {
3375 $$ = cat_str(7,mm_strdup("copy ("),$3,mm_strdup(") to"),$6,$7,$8,$9);
3376 }
3377 ;
3378
3379
3380 copy_from:
3381 FROM
3382 {
3383 $$ = mm_strdup("from");
3384 }
3385 | TO
3386 {
3387 $$ = mm_strdup("to");
3388 }
3389 ;
3390
3391
3392 opt_program:
3393 PROGRAM
3394 {
3395 $$ = mm_strdup("program");
3396 }
3397 |
3398 {
3399 $$=EMPTY; }
3400 ;
3401
3402
3403 copy_file_name:
3404 ecpg_sconst
3405 {
3406 $$ = $1;
3407 }
3408 | STDIN
3409 {
3410 $$ = mm_strdup("stdin");
3411 }
3412 | STDOUT
3413 {
3414 $$ = mm_strdup("stdout");
3415 }
3416 ;
3417
3418
3419 copy_options:
3420 copy_opt_list
3421 {
3422 $$ = $1;
3423 }
3424 | '(' copy_generic_opt_list ')'
3425 {
3426 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
3427 }
3428 ;
3429
3430
3431 copy_opt_list:
3432 copy_opt_list copy_opt_item
3433 {
3434 $$ = cat_str(2,$1,$2);
3435 }
3436 |
3437 {
3438 $$=EMPTY; }
3439 ;
3440
3441
3442 copy_opt_item:
3443 BINARY
3444 {
3445 $$ = mm_strdup("binary");
3446 }
3447 | FREEZE
3448 {
3449 $$ = mm_strdup("freeze");
3450 }
3451 | DELIMITER opt_as ecpg_sconst
3452 {
3453 $$ = cat_str(3,mm_strdup("delimiter"),$2,$3);
3454 }
3455 | NULL_P opt_as ecpg_sconst
3456 {
3457 $$ = cat_str(3,mm_strdup("null"),$2,$3);
3458 }
3459 | CSV
3460 {
3461 $$ = mm_strdup("csv");
3462 }
3463 | HEADER_P
3464 {
3465 $$ = mm_strdup("header");
3466 }
3467 | QUOTE opt_as ecpg_sconst
3468 {
3469 $$ = cat_str(3,mm_strdup("quote"),$2,$3);
3470 }
3471 | ESCAPE opt_as ecpg_sconst
3472 {
3473 $$ = cat_str(3,mm_strdup("escape"),$2,$3);
3474 }
3475 | FORCE QUOTE columnList
3476 {
3477 $$ = cat_str(2,mm_strdup("force quote"),$3);
3478 }
3479 | FORCE QUOTE '*'
3480 {
3481 $$ = mm_strdup("force quote *");
3482 }
3483 | FORCE NOT NULL_P columnList
3484 {
3485 $$ = cat_str(2,mm_strdup("force not null"),$4);
3486 }
3487 | FORCE NULL_P columnList
3488 {
3489 $$ = cat_str(2,mm_strdup("force null"),$3);
3490 }
3491 | ENCODING ecpg_sconst
3492 {
3493 $$ = cat_str(2,mm_strdup("encoding"),$2);
3494 }
3495 ;
3496
3497
3498 opt_binary:
3499 BINARY
3500 {
3501 $$ = mm_strdup("binary");
3502 }
3503 |
3504 {
3505 $$=EMPTY; }
3506 ;
3507
3508
3509 copy_delimiter:
3510 opt_using DELIMITERS ecpg_sconst
3511 {
3512 $$ = cat_str(3,$1,mm_strdup("delimiters"),$3);
3513 }
3514 |
3515 {
3516 $$=EMPTY; }
3517 ;
3518
3519
3520 opt_using:
3521 USING
3522 {
3523 $$ = mm_strdup("using");
3524 }
3525 |
3526 {
3527 $$=EMPTY; }
3528 ;
3529
3530
3531 copy_generic_opt_list:
3532 copy_generic_opt_elem
3533 {
3534 $$ = $1;
3535 }
3536 | copy_generic_opt_list ',' copy_generic_opt_elem
3537 {
3538 $$ = cat_str(3,$1,mm_strdup(","),$3);
3539 }
3540 ;
3541
3542
3543 copy_generic_opt_elem:
3544 ColLabel copy_generic_opt_arg
3545 {
3546 $$ = cat_str(2,$1,$2);
3547 }
3548 ;
3549
3550
3551 copy_generic_opt_arg:
3552 opt_boolean_or_string
3553 {
3554 $$ = $1;
3555 }
3556 | NumericOnly
3557 {
3558 $$ = $1;
3559 }
3560 | '*'
3561 {
3562 $$ = mm_strdup("*");
3563 }
3564 | '(' copy_generic_opt_arg_list ')'
3565 {
3566 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
3567 }
3568 |
3569 {
3570 $$=EMPTY; }
3571 ;
3572
3573
3574 copy_generic_opt_arg_list:
3575 copy_generic_opt_arg_list_item
3576 {
3577 $$ = $1;
3578 }
3579 | copy_generic_opt_arg_list ',' copy_generic_opt_arg_list_item
3580 {
3581 $$ = cat_str(3,$1,mm_strdup(","),$3);
3582 }
3583 ;
3584
3585
3586 copy_generic_opt_arg_list_item:
3587 opt_boolean_or_string
3588 {
3589 $$ = $1;
3590 }
3591 ;
3592
3593
3594 CreateStmt:
3595 CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')' OptInherit OptPartitionSpec table_access_method_clause OptWith OnCommitOption OptTableSpace
3596 {
3597 $$ = cat_str(13,mm_strdup("create"),$2,mm_strdup("table"),$4,mm_strdup("("),$6,mm_strdup(")"),$8,$9,$10,$11,$12,$13);
3598 }
3599 | CREATE OptTemp TABLE IF_P NOT EXISTS qualified_name '(' OptTableElementList ')' OptInherit OptPartitionSpec table_access_method_clause OptWith OnCommitOption OptTableSpace
3600 {
3601 $$ = cat_str(13,mm_strdup("create"),$2,mm_strdup("table if not exists"),$7,mm_strdup("("),$9,mm_strdup(")"),$11,$12,$13,$14,$15,$16);
3602 }
3603 | CREATE OptTemp TABLE qualified_name OF any_name OptTypedTableElementList OptPartitionSpec table_access_method_clause OptWith OnCommitOption OptTableSpace
3604 {
3605 $$ = cat_str(12,mm_strdup("create"),$2,mm_strdup("table"),$4,mm_strdup("of"),$6,$7,$8,$9,$10,$11,$12);
3606 }
3607 | CREATE OptTemp TABLE IF_P NOT EXISTS qualified_name OF any_name OptTypedTableElementList OptPartitionSpec table_access_method_clause OptWith OnCommitOption OptTableSpace
3608 {
3609 $$ = cat_str(12,mm_strdup("create"),$2,mm_strdup("table if not exists"),$7,mm_strdup("of"),$9,$10,$11,$12,$13,$14,$15);
3610 }
3611 | CREATE OptTemp TABLE qualified_name PARTITION OF qualified_name OptTypedTableElementList PartitionBoundSpec OptPartitionSpec table_access_method_clause OptWith OnCommitOption OptTableSpace
3612 {
3613 $$ = cat_str(13,mm_strdup("create"),$2,mm_strdup("table"),$4,mm_strdup("partition of"),$7,$8,$9,$10,$11,$12,$13,$14);
3614 }
3615 | CREATE OptTemp TABLE IF_P NOT EXISTS qualified_name PARTITION OF qualified_name OptTypedTableElementList PartitionBoundSpec OptPartitionSpec table_access_method_clause OptWith OnCommitOption OptTableSpace
3616 {
3617 $$ = cat_str(13,mm_strdup("create"),$2,mm_strdup("table if not exists"),$7,mm_strdup("partition of"),$10,$11,$12,$13,$14,$15,$16,$17);
3618 }
3619 ;
3620
3621
3622 OptTemp:
3623 TEMPORARY
3624 {
3625 $$ = mm_strdup("temporary");
3626 }
3627 | TEMP
3628 {
3629 $$ = mm_strdup("temp");
3630 }
3631 | LOCAL TEMPORARY
3632 {
3633 $$ = mm_strdup("local temporary");
3634 }
3635 | LOCAL TEMP
3636 {
3637 $$ = mm_strdup("local temp");
3638 }
3639 | GLOBAL TEMPORARY
3640 {
3641 $$ = mm_strdup("global temporary");
3642 }
3643 | GLOBAL TEMP
3644 {
3645 $$ = mm_strdup("global temp");
3646 }
3647 | UNLOGGED
3648 {
3649 $$ = mm_strdup("unlogged");
3650 }
3651 |
3652 {
3653 $$=EMPTY; }
3654 ;
3655
3656
3657 OptTableElementList:
3658 TableElementList
3659 {
3660 $$ = $1;
3661 }
3662 |
3663 {
3664 $$=EMPTY; }
3665 ;
3666
3667
3668 OptTypedTableElementList:
3669 '(' TypedTableElementList ')'
3670 {
3671 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
3672 }
3673 |
3674 {
3675 $$=EMPTY; }
3676 ;
3677
3678
3679 TableElementList:
3680 TableElement
3681 {
3682 $$ = $1;
3683 }
3684 | TableElementList ',' TableElement
3685 {
3686 $$ = cat_str(3,$1,mm_strdup(","),$3);
3687 }
3688 ;
3689
3690
3691 TypedTableElementList:
3692 TypedTableElement
3693 {
3694 $$ = $1;
3695 }
3696 | TypedTableElementList ',' TypedTableElement
3697 {
3698 $$ = cat_str(3,$1,mm_strdup(","),$3);
3699 }
3700 ;
3701
3702
3703 TableElement:
3704 columnDef
3705 {
3706 $$ = $1;
3707 }
3708 | TableLikeClause
3709 {
3710 $$ = $1;
3711 }
3712 | TableConstraint
3713 {
3714 $$ = $1;
3715 }
3716 ;
3717
3718
3719 TypedTableElement:
3720 columnOptions
3721 {
3722 $$ = $1;
3723 }
3724 | TableConstraint
3725 {
3726 $$ = $1;
3727 }
3728 ;
3729
3730
3731 columnDef:
3732 ColId Typename create_generic_options ColQualList
3733 {
3734 $$ = cat_str(4,$1,$2,$3,$4);
3735 }
3736 ;
3737
3738
3739 columnOptions:
3740 ColId ColQualList
3741 {
3742 $$ = cat_str(2,$1,$2);
3743 }
3744 | ColId WITH OPTIONS ColQualList
3745 {
3746 $$ = cat_str(3,$1,mm_strdup("with options"),$4);
3747 }
3748 ;
3749
3750
3751 ColQualList:
3752 ColQualList ColConstraint
3753 {
3754 $$ = cat_str(2,$1,$2);
3755 }
3756 |
3757 {
3758 $$=EMPTY; }
3759 ;
3760
3761
3762 ColConstraint:
3763 CONSTRAINT name ColConstraintElem
3764 {
3765 $$ = cat_str(3,mm_strdup("constraint"),$2,$3);
3766 }
3767 | ColConstraintElem
3768 {
3769 $$ = $1;
3770 }
3771 | ConstraintAttr
3772 {
3773 $$ = $1;
3774 }
3775 | COLLATE any_name
3776 {
3777 $$ = cat_str(2,mm_strdup("collate"),$2);
3778 }
3779 ;
3780
3781
3782 ColConstraintElem:
3783 NOT NULL_P
3784 {
3785 $$ = mm_strdup("not null");
3786 }
3787 | NULL_P
3788 {
3789 $$ = mm_strdup("null");
3790 }
3791 | UNIQUE opt_definition OptConsTableSpace
3792 {
3793 $$ = cat_str(3,mm_strdup("unique"),$2,$3);
3794 }
3795 | PRIMARY KEY opt_definition OptConsTableSpace
3796 {
3797 $$ = cat_str(3,mm_strdup("primary key"),$3,$4);
3798 }
3799 | CHECK '(' a_expr ')' opt_no_inherit
3800 {
3801 $$ = cat_str(4,mm_strdup("check ("),$3,mm_strdup(")"),$5);
3802 }
3803 | DEFAULT b_expr
3804 {
3805 $$ = cat_str(2,mm_strdup("default"),$2);
3806 }
3807 | GENERATED generated_when AS IDENTITY_P OptParenthesizedSeqOptList
3808 {
3809 $$ = cat_str(4,mm_strdup("generated"),$2,mm_strdup("as identity"),$5);
3810 }
3811 | GENERATED generated_when AS '(' a_expr ')' STORED
3812 {
3813 $$ = cat_str(5,mm_strdup("generated"),$2,mm_strdup("as ("),$5,mm_strdup(") stored"));
3814 }
3815 | REFERENCES qualified_name opt_column_list key_match key_actions
3816 {
3817 $$ = cat_str(5,mm_strdup("references"),$2,$3,$4,$5);
3818 }
3819 ;
3820
3821
3822 generated_when:
3823 ALWAYS
3824 {
3825 $$ = mm_strdup("always");
3826 }
3827 | BY DEFAULT
3828 {
3829 $$ = mm_strdup("by default");
3830 }
3831 ;
3832
3833
3834 ConstraintAttr:
3835 DEFERRABLE
3836 {
3837 $$ = mm_strdup("deferrable");
3838 }
3839 | NOT DEFERRABLE
3840 {
3841 $$ = mm_strdup("not deferrable");
3842 }
3843 | INITIALLY DEFERRED
3844 {
3845 $$ = mm_strdup("initially deferred");
3846 }
3847 | INITIALLY IMMEDIATE
3848 {
3849 $$ = mm_strdup("initially immediate");
3850 }
3851 ;
3852
3853
3854 TableLikeClause:
3855 LIKE qualified_name TableLikeOptionList
3856 {
3857 $$ = cat_str(3,mm_strdup("like"),$2,$3);
3858 }
3859 ;
3860
3861
3862 TableLikeOptionList:
3863 TableLikeOptionList INCLUDING TableLikeOption
3864 {
3865 $$ = cat_str(3,$1,mm_strdup("including"),$3);
3866 }
3867 | TableLikeOptionList EXCLUDING TableLikeOption
3868 {
3869 $$ = cat_str(3,$1,mm_strdup("excluding"),$3);
3870 }
3871 |
3872 {
3873 $$=EMPTY; }
3874 ;
3875
3876
3877 TableLikeOption:
3878 COMMENTS
3879 {
3880 $$ = mm_strdup("comments");
3881 }
3882 | CONSTRAINTS
3883 {
3884 $$ = mm_strdup("constraints");
3885 }
3886 | DEFAULTS
3887 {
3888 $$ = mm_strdup("defaults");
3889 }
3890 | IDENTITY_P
3891 {
3892 $$ = mm_strdup("identity");
3893 }
3894 | GENERATED
3895 {
3896 $$ = mm_strdup("generated");
3897 }
3898 | INDEXES
3899 {
3900 $$ = mm_strdup("indexes");
3901 }
3902 | STATISTICS
3903 {
3904 $$ = mm_strdup("statistics");
3905 }
3906 | STORAGE
3907 {
3908 $$ = mm_strdup("storage");
3909 }
3910 | ALL
3911 {
3912 $$ = mm_strdup("all");
3913 }
3914 ;
3915
3916
3917 TableConstraint:
3918 CONSTRAINT name ConstraintElem
3919 {
3920 $$ = cat_str(3,mm_strdup("constraint"),$2,$3);
3921 }
3922 | ConstraintElem
3923 {
3924 $$ = $1;
3925 }
3926 ;
3927
3928
3929 ConstraintElem:
3930 CHECK '(' a_expr ')' ConstraintAttributeSpec
3931 {
3932 $$ = cat_str(4,mm_strdup("check ("),$3,mm_strdup(")"),$5);
3933 }
3934 | UNIQUE '(' columnList ')' opt_c_include opt_definition OptConsTableSpace ConstraintAttributeSpec
3935 {
3936 $$ = cat_str(7,mm_strdup("unique ("),$3,mm_strdup(")"),$5,$6,$7,$8);
3937 }
3938 | UNIQUE ExistingIndex ConstraintAttributeSpec
3939 {
3940 $$ = cat_str(3,mm_strdup("unique"),$2,$3);
3941 }
3942 | PRIMARY KEY '(' columnList ')' opt_c_include opt_definition OptConsTableSpace ConstraintAttributeSpec
3943 {
3944 $$ = cat_str(7,mm_strdup("primary key ("),$4,mm_strdup(")"),$6,$7,$8,$9);
3945 }
3946 | PRIMARY KEY ExistingIndex ConstraintAttributeSpec
3947 {
3948 $$ = cat_str(3,mm_strdup("primary key"),$3,$4);
3949 }
3950 | EXCLUDE access_method_clause '(' ExclusionConstraintList ')' opt_c_include opt_definition OptConsTableSpace ExclusionWhereClause ConstraintAttributeSpec
3951 {
3952 $$ = cat_str(10,mm_strdup("exclude"),$2,mm_strdup("("),$4,mm_strdup(")"),$6,$7,$8,$9,$10);
3953 }
3954 | FOREIGN KEY '(' columnList ')' REFERENCES qualified_name opt_column_list key_match key_actions ConstraintAttributeSpec
3955 {
3956 $$ = cat_str(8,mm_strdup("foreign key ("),$4,mm_strdup(") references"),$7,$8,$9,$10,$11);
3957 }
3958 ;
3959
3960
3961 opt_no_inherit:
3962 NO INHERIT
3963 {
3964 $$ = mm_strdup("no inherit");
3965 }
3966 |
3967 {
3968 $$=EMPTY; }
3969 ;
3970
3971
3972 opt_column_list:
3973 '(' columnList ')'
3974 {
3975 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
3976 }
3977 |
3978 {
3979 $$=EMPTY; }
3980 ;
3981
3982
3983 columnList:
3984 columnElem
3985 {
3986 $$ = $1;
3987 }
3988 | columnList ',' columnElem
3989 {
3990 $$ = cat_str(3,$1,mm_strdup(","),$3);
3991 }
3992 ;
3993
3994
3995 columnElem:
3996 ColId
3997 {
3998 $$ = $1;
3999 }
4000 ;
4001
4002
4003 opt_c_include:
4004 INCLUDE '(' columnList ')'
4005 {
4006 $$ = cat_str(3,mm_strdup("include ("),$3,mm_strdup(")"));
4007 }
4008 |
4009 {
4010 $$=EMPTY; }
4011 ;
4012
4013
4014 key_match:
4015 MATCH FULL
4016 {
4017 $$ = mm_strdup("match full");
4018 }
4019 | MATCH PARTIAL
4020 {
4021 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
4022 $$ = mm_strdup("match partial");
4023 }
4024 | MATCH SIMPLE
4025 {
4026 $$ = mm_strdup("match simple");
4027 }
4028 |
4029 {
4030 $$=EMPTY; }
4031 ;
4032
4033
4034 ExclusionConstraintList:
4035 ExclusionConstraintElem
4036 {
4037 $$ = $1;
4038 }
4039 | ExclusionConstraintList ',' ExclusionConstraintElem
4040 {
4041 $$ = cat_str(3,$1,mm_strdup(","),$3);
4042 }
4043 ;
4044
4045
4046 ExclusionConstraintElem:
4047 index_elem WITH any_operator
4048 {
4049 $$ = cat_str(3,$1,mm_strdup("with"),$3);
4050 }
4051 | index_elem WITH OPERATOR '(' any_operator ')'
4052 {
4053 $$ = cat_str(4,$1,mm_strdup("with operator ("),$5,mm_strdup(")"));
4054 }
4055 ;
4056
4057
4058 ExclusionWhereClause:
4059 WHERE '(' a_expr ')'
4060 {
4061 $$ = cat_str(3,mm_strdup("where ("),$3,mm_strdup(")"));
4062 }
4063 |
4064 {
4065 $$=EMPTY; }
4066 ;
4067
4068
4069 key_actions:
4070 key_update
4071 {
4072 $$ = $1;
4073 }
4074 | key_delete
4075 {
4076 $$ = $1;
4077 }
4078 | key_update key_delete
4079 {
4080 $$ = cat_str(2,$1,$2);
4081 }
4082 | key_delete key_update
4083 {
4084 $$ = cat_str(2,$1,$2);
4085 }
4086 |
4087 {
4088 $$=EMPTY; }
4089 ;
4090
4091
4092 key_update:
4093 ON UPDATE key_action
4094 {
4095 $$ = cat_str(2,mm_strdup("on update"),$3);
4096 }
4097 ;
4098
4099
4100 key_delete:
4101 ON DELETE_P key_action
4102 {
4103 $$ = cat_str(2,mm_strdup("on delete"),$3);
4104 }
4105 ;
4106
4107
4108 key_action:
4109 NO ACTION
4110 {
4111 $$ = mm_strdup("no action");
4112 }
4113 | RESTRICT
4114 {
4115 $$ = mm_strdup("restrict");
4116 }
4117 | CASCADE
4118 {
4119 $$ = mm_strdup("cascade");
4120 }
4121 | SET NULL_P
4122 {
4123 $$ = mm_strdup("set null");
4124 }
4125 | SET DEFAULT
4126 {
4127 $$ = mm_strdup("set default");
4128 }
4129 ;
4130
4131
4132 OptInherit:
4133 INHERITS '(' qualified_name_list ')'
4134 {
4135 $$ = cat_str(3,mm_strdup("inherits ("),$3,mm_strdup(")"));
4136 }
4137 |
4138 {
4139 $$=EMPTY; }
4140 ;
4141
4142
4143 OptPartitionSpec:
4144 PartitionSpec
4145 {
4146 $$ = $1;
4147 }
4148 |
4149 {
4150 $$=EMPTY; }
4151 ;
4152
4153
4154 PartitionSpec:
4155 PARTITION BY part_strategy '(' part_params ')'
4156 {
4157 $$ = cat_str(5,mm_strdup("partition by"),$3,mm_strdup("("),$5,mm_strdup(")"));
4158 }
4159 ;
4160
4161
4162 part_strategy:
4163 ecpg_ident
4164 {
4165 $$ = $1;
4166 }
4167 | unreserved_keyword
4168 {
4169 $$ = $1;
4170 }
4171 ;
4172
4173
4174 part_params:
4175 part_elem
4176 {
4177 $$ = $1;
4178 }
4179 | part_params ',' part_elem
4180 {
4181 $$ = cat_str(3,$1,mm_strdup(","),$3);
4182 }
4183 ;
4184
4185
4186 part_elem:
4187 ColId opt_collate opt_class
4188 {
4189 $$ = cat_str(3,$1,$2,$3);
4190 }
4191 | func_expr_windowless opt_collate opt_class
4192 {
4193 $$ = cat_str(3,$1,$2,$3);
4194 }
4195 | '(' a_expr ')' opt_collate opt_class
4196 {
4197 $$ = cat_str(5,mm_strdup("("),$2,mm_strdup(")"),$4,$5);
4198 }
4199 ;
4200
4201
4202 table_access_method_clause:
4203 USING access_method
4204 {
4205 $$ = cat_str(2,mm_strdup("using"),$2);
4206 }
4207 |
4208 {
4209 $$=EMPTY; }
4210 ;
4211
4212
4213 OptWith:
4214 WITH reloptions
4215 {
4216 $$ = cat_str(2,mm_strdup("with"),$2);
4217 }
4218 | WITHOUT OIDS
4219 {
4220 $$ = mm_strdup("without oids");
4221 }
4222 |
4223 {
4224 $$=EMPTY; }
4225 ;
4226
4227
4228 OnCommitOption:
4229 ON COMMIT DROP
4230 {
4231 $$ = mm_strdup("on commit drop");
4232 }
4233 | ON COMMIT DELETE_P ROWS
4234 {
4235 $$ = mm_strdup("on commit delete rows");
4236 }
4237 | ON COMMIT PRESERVE ROWS
4238 {
4239 $$ = mm_strdup("on commit preserve rows");
4240 }
4241 |
4242 {
4243 $$=EMPTY; }
4244 ;
4245
4246
4247 OptTableSpace:
4248 TABLESPACE name
4249 {
4250 $$ = cat_str(2,mm_strdup("tablespace"),$2);
4251 }
4252 |
4253 {
4254 $$=EMPTY; }
4255 ;
4256
4257
4258 OptConsTableSpace:
4259 USING INDEX TABLESPACE name
4260 {
4261 $$ = cat_str(2,mm_strdup("using index tablespace"),$4);
4262 }
4263 |
4264 {
4265 $$=EMPTY; }
4266 ;
4267
4268
4269 ExistingIndex:
4270 USING INDEX index_name
4271 {
4272 $$ = cat_str(2,mm_strdup("using index"),$3);
4273 }
4274 ;
4275
4276
4277 CreateStatsStmt:
4278 CREATE STATISTICS any_name opt_name_list ON expr_list FROM from_list
4279 {
4280 $$ = cat_str(7,mm_strdup("create statistics"),$3,$4,mm_strdup("on"),$6,mm_strdup("from"),$8);
4281 }
4282 | CREATE STATISTICS IF_P NOT EXISTS any_name opt_name_list ON expr_list FROM from_list
4283 {
4284 $$ = cat_str(7,mm_strdup("create statistics if not exists"),$6,$7,mm_strdup("on"),$9,mm_strdup("from"),$11);
4285 }
4286 ;
4287
4288
4289 create_as_target:
4290 qualified_name opt_column_list table_access_method_clause OptWith OnCommitOption OptTableSpace
4291 {
4292 $$ = cat_str(6,$1,$2,$3,$4,$5,$6);
4293 }
4294 ;
4295
4296
4297 opt_with_data:
4298 WITH DATA_P
4299 {
4300 $$ = mm_strdup("with data");
4301 }
4302 | WITH NO DATA_P
4303 {
4304 $$ = mm_strdup("with no data");
4305 }
4306 |
4307 {
4308 $$=EMPTY; }
4309 ;
4310
4311
4312 CreateMatViewStmt:
4313 CREATE OptNoLog MATERIALIZED VIEW create_mv_target AS SelectStmt opt_with_data
4314 {
4315 $$ = cat_str(7,mm_strdup("create"),$2,mm_strdup("materialized view"),$5,mm_strdup("as"),$7,$8);
4316 }
4317 | CREATE OptNoLog MATERIALIZED VIEW IF_P NOT EXISTS create_mv_target AS SelectStmt opt_with_data
4318 {
4319 $$ = cat_str(7,mm_strdup("create"),$2,mm_strdup("materialized view if not exists"),$8,mm_strdup("as"),$10,$11);
4320 }
4321 ;
4322
4323
4324 create_mv_target:
4325 qualified_name opt_column_list table_access_method_clause opt_reloptions OptTableSpace
4326 {
4327 $$ = cat_str(5,$1,$2,$3,$4,$5);
4328 }
4329 ;
4330
4331
4332 OptNoLog:
4333 UNLOGGED
4334 {
4335 $$ = mm_strdup("unlogged");
4336 }
4337 |
4338 {
4339 $$=EMPTY; }
4340 ;
4341
4342
4343 RefreshMatViewStmt:
4344 REFRESH MATERIALIZED VIEW opt_concurrently qualified_name opt_with_data
4345 {
4346 $$ = cat_str(4,mm_strdup("refresh materialized view"),$4,$5,$6);
4347 }
4348 ;
4349
4350
4351 CreateSeqStmt:
4352 CREATE OptTemp SEQUENCE qualified_name OptSeqOptList
4353 {
4354 $$ = cat_str(5,mm_strdup("create"),$2,mm_strdup("sequence"),$4,$5);
4355 }
4356 | CREATE OptTemp SEQUENCE IF_P NOT EXISTS qualified_name OptSeqOptList
4357 {
4358 $$ = cat_str(5,mm_strdup("create"),$2,mm_strdup("sequence if not exists"),$7,$8);
4359 }
4360 ;
4361
4362
4363 AlterSeqStmt:
4364 ALTER SEQUENCE qualified_name SeqOptList
4365 {
4366 $$ = cat_str(3,mm_strdup("alter sequence"),$3,$4);
4367 }
4368 | ALTER SEQUENCE IF_P EXISTS qualified_name SeqOptList
4369 {
4370 $$ = cat_str(3,mm_strdup("alter sequence if exists"),$5,$6);
4371 }
4372 ;
4373
4374
4375 OptSeqOptList:
4376 SeqOptList
4377 {
4378 $$ = $1;
4379 }
4380 |
4381 {
4382 $$=EMPTY; }
4383 ;
4384
4385
4386 OptParenthesizedSeqOptList:
4387 '(' SeqOptList ')'
4388 {
4389 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
4390 }
4391 |
4392 {
4393 $$=EMPTY; }
4394 ;
4395
4396
4397 SeqOptList:
4398 SeqOptElem
4399 {
4400 $$ = $1;
4401 }
4402 | SeqOptList SeqOptElem
4403 {
4404 $$ = cat_str(2,$1,$2);
4405 }
4406 ;
4407
4408
4409 SeqOptElem:
4410 AS SimpleTypename
4411 {
4412 $$ = cat_str(2,mm_strdup("as"),$2);
4413 }
4414 | CACHE NumericOnly
4415 {
4416 $$ = cat_str(2,mm_strdup("cache"),$2);
4417 }
4418 | CYCLE
4419 {
4420 $$ = mm_strdup("cycle");
4421 }
4422 | NO CYCLE
4423 {
4424 $$ = mm_strdup("no cycle");
4425 }
4426 | INCREMENT opt_by NumericOnly
4427 {
4428 $$ = cat_str(3,mm_strdup("increment"),$2,$3);
4429 }
4430 | MAXVALUE NumericOnly
4431 {
4432 $$ = cat_str(2,mm_strdup("maxvalue"),$2);
4433 }
4434 | MINVALUE NumericOnly
4435 {
4436 $$ = cat_str(2,mm_strdup("minvalue"),$2);
4437 }
4438 | NO MAXVALUE
4439 {
4440 $$ = mm_strdup("no maxvalue");
4441 }
4442 | NO MINVALUE
4443 {
4444 $$ = mm_strdup("no minvalue");
4445 }
4446 | OWNED BY any_name
4447 {
4448 $$ = cat_str(2,mm_strdup("owned by"),$3);
4449 }
4450 | SEQUENCE NAME_P any_name
4451 {
4452 $$ = cat_str(2,mm_strdup("sequence name"),$3);
4453 }
4454 | START opt_with NumericOnly
4455 {
4456 $$ = cat_str(3,mm_strdup("start"),$2,$3);
4457 }
4458 | RESTART
4459 {
4460 $$ = mm_strdup("restart");
4461 }
4462 | RESTART opt_with NumericOnly
4463 {
4464 $$ = cat_str(3,mm_strdup("restart"),$2,$3);
4465 }
4466 ;
4467
4468
4469 opt_by:
4470 BY
4471 {
4472 $$ = mm_strdup("by");
4473 }
4474 |
4475 {
4476 $$=EMPTY; }
4477 ;
4478
4479
4480 NumericOnly:
4481 ecpg_fconst
4482 {
4483 $$ = $1;
4484 }
4485 | '+' ecpg_fconst
4486 {
4487 $$ = cat_str(2,mm_strdup("+"),$2);
4488 }
4489 | '-' ecpg_fconst
4490 {
4491 $$ = cat_str(2,mm_strdup("-"),$2);
4492 }
4493 | SignedIconst
4494 {
4495 $$ = $1;
4496 }
4497 ;
4498
4499
4500 NumericOnly_list:
4501 NumericOnly
4502 {
4503 $$ = $1;
4504 }
4505 | NumericOnly_list ',' NumericOnly
4506 {
4507 $$ = cat_str(3,$1,mm_strdup(","),$3);
4508 }
4509 ;
4510
4511
4512 CreatePLangStmt:
4513 CREATE opt_or_replace opt_trusted opt_procedural LANGUAGE NonReservedWord_or_Sconst
4514 {
4515 $$ = cat_str(6,mm_strdup("create"),$2,$3,$4,mm_strdup("language"),$6);
4516 }
4517 | CREATE opt_or_replace opt_trusted opt_procedural LANGUAGE NonReservedWord_or_Sconst HANDLER handler_name opt_inline_handler opt_validator
4518 {
4519 $$ = cat_str(10,mm_strdup("create"),$2,$3,$4,mm_strdup("language"),$6,mm_strdup("handler"),$8,$9,$10);
4520 }
4521 ;
4522
4523
4524 opt_trusted:
4525 TRUSTED
4526 {
4527 $$ = mm_strdup("trusted");
4528 }
4529 |
4530 {
4531 $$=EMPTY; }
4532 ;
4533
4534
4535 handler_name:
4536 name
4537 {
4538 $$ = $1;
4539 }
4540 | name attrs
4541 {
4542 $$ = cat_str(2,$1,$2);
4543 }
4544 ;
4545
4546
4547 opt_inline_handler:
4548 INLINE_P handler_name
4549 {
4550 $$ = cat_str(2,mm_strdup("inline"),$2);
4551 }
4552 |
4553 {
4554 $$=EMPTY; }
4555 ;
4556
4557
4558 validator_clause:
4559 VALIDATOR handler_name
4560 {
4561 $$ = cat_str(2,mm_strdup("validator"),$2);
4562 }
4563 | NO VALIDATOR
4564 {
4565 $$ = mm_strdup("no validator");
4566 }
4567 ;
4568
4569
4570 opt_validator:
4571 validator_clause
4572 {
4573 $$ = $1;
4574 }
4575 |
4576 {
4577 $$=EMPTY; }
4578 ;
4579
4580
4581 DropPLangStmt:
4582 DROP opt_procedural LANGUAGE NonReservedWord_or_Sconst opt_drop_behavior
4583 {
4584 $$ = cat_str(5,mm_strdup("drop"),$2,mm_strdup("language"),$4,$5);
4585 }
4586 | DROP opt_procedural LANGUAGE IF_P EXISTS NonReservedWord_or_Sconst opt_drop_behavior
4587 {
4588 $$ = cat_str(5,mm_strdup("drop"),$2,mm_strdup("language if exists"),$6,$7);
4589 }
4590 ;
4591
4592
4593 opt_procedural:
4594 PROCEDURAL
4595 {
4596 $$ = mm_strdup("procedural");
4597 }
4598 |
4599 {
4600 $$=EMPTY; }
4601 ;
4602
4603
4604 CreateTableSpaceStmt:
4605 CREATE TABLESPACE name OptTableSpaceOwner LOCATION ecpg_sconst opt_reloptions
4606 {
4607 $$ = cat_str(6,mm_strdup("create tablespace"),$3,$4,mm_strdup("location"),$6,$7);
4608 }
4609 ;
4610
4611
4612 OptTableSpaceOwner:
4613 OWNER RoleSpec
4614 {
4615 $$ = cat_str(2,mm_strdup("owner"),$2);
4616 }
4617 |
4618 {
4619 $$=EMPTY; }
4620 ;
4621
4622
4623 DropTableSpaceStmt:
4624 DROP TABLESPACE name
4625 {
4626 $$ = cat_str(2,mm_strdup("drop tablespace"),$3);
4627 }
4628 | DROP TABLESPACE IF_P EXISTS name
4629 {
4630 $$ = cat_str(2,mm_strdup("drop tablespace if exists"),$5);
4631 }
4632 ;
4633
4634
4635 CreateExtensionStmt:
4636 CREATE EXTENSION name opt_with create_extension_opt_list
4637 {
4638 $$ = cat_str(4,mm_strdup("create extension"),$3,$4,$5);
4639 }
4640 | CREATE EXTENSION IF_P NOT EXISTS name opt_with create_extension_opt_list
4641 {
4642 $$ = cat_str(4,mm_strdup("create extension if not exists"),$6,$7,$8);
4643 }
4644 ;
4645
4646
4647 create_extension_opt_list:
4648 create_extension_opt_list create_extension_opt_item
4649 {
4650 $$ = cat_str(2,$1,$2);
4651 }
4652 |
4653 {
4654 $$=EMPTY; }
4655 ;
4656
4657
4658 create_extension_opt_item:
4659 SCHEMA name
4660 {
4661 $$ = cat_str(2,mm_strdup("schema"),$2);
4662 }
4663 | VERSION_P NonReservedWord_or_Sconst
4664 {
4665 $$ = cat_str(2,mm_strdup("version"),$2);
4666 }
4667 | FROM NonReservedWord_or_Sconst
4668 {
4669 $$ = cat_str(2,mm_strdup("from"),$2);
4670 }
4671 | CASCADE
4672 {
4673 $$ = mm_strdup("cascade");
4674 }
4675 ;
4676
4677
4678 AlterExtensionStmt:
4679 ALTER EXTENSION name UPDATE alter_extension_opt_list
4680 {
4681 $$ = cat_str(4,mm_strdup("alter extension"),$3,mm_strdup("update"),$5);
4682 }
4683 ;
4684
4685
4686 alter_extension_opt_list:
4687 alter_extension_opt_list alter_extension_opt_item
4688 {
4689 $$ = cat_str(2,$1,$2);
4690 }
4691 |
4692 {
4693 $$=EMPTY; }
4694 ;
4695
4696
4697 alter_extension_opt_item:
4698 TO NonReservedWord_or_Sconst
4699 {
4700 $$ = cat_str(2,mm_strdup("to"),$2);
4701 }
4702 ;
4703
4704
4705 AlterExtensionContentsStmt:
4706 ALTER EXTENSION name add_drop ACCESS METHOD name
4707 {
4708 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("access method"),$7);
4709 }
4710 | ALTER EXTENSION name add_drop AGGREGATE aggregate_with_argtypes
4711 {
4712 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("aggregate"),$6);
4713 }
4714 | ALTER EXTENSION name add_drop CAST '(' Typename AS Typename ')'
4715 {
4716 $$ = cat_str(8,mm_strdup("alter extension"),$3,$4,mm_strdup("cast ("),$7,mm_strdup("as"),$9,mm_strdup(")"));
4717 }
4718 | ALTER EXTENSION name add_drop COLLATION any_name
4719 {
4720 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("collation"),$6);
4721 }
4722 | ALTER EXTENSION name add_drop CONVERSION_P any_name
4723 {
4724 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("conversion"),$6);
4725 }
4726 | ALTER EXTENSION name add_drop DOMAIN_P Typename
4727 {
4728 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("domain"),$6);
4729 }
4730 | ALTER EXTENSION name add_drop FUNCTION function_with_argtypes
4731 {
4732 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("function"),$6);
4733 }
4734 | ALTER EXTENSION name add_drop opt_procedural LANGUAGE name
4735 {
4736 $$ = cat_str(6,mm_strdup("alter extension"),$3,$4,$5,mm_strdup("language"),$7);
4737 }
4738 | ALTER EXTENSION name add_drop OPERATOR operator_with_argtypes
4739 {
4740 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("operator"),$6);
4741 }
4742 | ALTER EXTENSION name add_drop OPERATOR CLASS any_name USING access_method
4743 {
4744 $$ = cat_str(7,mm_strdup("alter extension"),$3,$4,mm_strdup("operator class"),$7,mm_strdup("using"),$9);
4745 }
4746 | ALTER EXTENSION name add_drop OPERATOR FAMILY any_name USING access_method
4747 {
4748 $$ = cat_str(7,mm_strdup("alter extension"),$3,$4,mm_strdup("operator family"),$7,mm_strdup("using"),$9);
4749 }
4750 | ALTER EXTENSION name add_drop PROCEDURE function_with_argtypes
4751 {
4752 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("procedure"),$6);
4753 }
4754 | ALTER EXTENSION name add_drop ROUTINE function_with_argtypes
4755 {
4756 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("routine"),$6);
4757 }
4758 | ALTER EXTENSION name add_drop SCHEMA name
4759 {
4760 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("schema"),$6);
4761 }
4762 | ALTER EXTENSION name add_drop EVENT TRIGGER name
4763 {
4764 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("event trigger"),$7);
4765 }
4766 | ALTER EXTENSION name add_drop TABLE any_name
4767 {
4768 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("table"),$6);
4769 }
4770 | ALTER EXTENSION name add_drop TEXT_P SEARCH PARSER any_name
4771 {
4772 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("text search parser"),$8);
4773 }
4774 | ALTER EXTENSION name add_drop TEXT_P SEARCH DICTIONARY any_name
4775 {
4776 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("text search dictionary"),$8);
4777 }
4778 | ALTER EXTENSION name add_drop TEXT_P SEARCH TEMPLATE any_name
4779 {
4780 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("text search template"),$8);
4781 }
4782 | ALTER EXTENSION name add_drop TEXT_P SEARCH CONFIGURATION any_name
4783 {
4784 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("text search configuration"),$8);
4785 }
4786 | ALTER EXTENSION name add_drop SEQUENCE any_name
4787 {
4788 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("sequence"),$6);
4789 }
4790 | ALTER EXTENSION name add_drop VIEW any_name
4791 {
4792 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("view"),$6);
4793 }
4794 | ALTER EXTENSION name add_drop MATERIALIZED VIEW any_name
4795 {
4796 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("materialized view"),$7);
4797 }
4798 | ALTER EXTENSION name add_drop FOREIGN TABLE any_name
4799 {
4800 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("foreign table"),$7);
4801 }
4802 | ALTER EXTENSION name add_drop FOREIGN DATA_P WRAPPER name
4803 {
4804 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("foreign data wrapper"),$8);
4805 }
4806 | ALTER EXTENSION name add_drop SERVER name
4807 {
4808 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("server"),$6);
4809 }
4810 | ALTER EXTENSION name add_drop TRANSFORM FOR Typename LANGUAGE name
4811 {
4812 $$ = cat_str(7,mm_strdup("alter extension"),$3,$4,mm_strdup("transform for"),$7,mm_strdup("language"),$9);
4813 }
4814 | ALTER EXTENSION name add_drop TYPE_P Typename
4815 {
4816 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("type"),$6);
4817 }
4818 ;
4819
4820
4821 CreateFdwStmt:
4822 CREATE FOREIGN DATA_P WRAPPER name opt_fdw_options create_generic_options
4823 {
4824 $$ = cat_str(4,mm_strdup("create foreign data wrapper"),$5,$6,$7);
4825 }
4826 ;
4827
4828
4829 fdw_option:
4830 HANDLER handler_name
4831 {
4832 $$ = cat_str(2,mm_strdup("handler"),$2);
4833 }
4834 | NO HANDLER
4835 {
4836 $$ = mm_strdup("no handler");
4837 }
4838 | VALIDATOR handler_name
4839 {
4840 $$ = cat_str(2,mm_strdup("validator"),$2);
4841 }
4842 | NO VALIDATOR
4843 {
4844 $$ = mm_strdup("no validator");
4845 }
4846 ;
4847
4848
4849 fdw_options:
4850 fdw_option
4851 {
4852 $$ = $1;
4853 }
4854 | fdw_options fdw_option
4855 {
4856 $$ = cat_str(2,$1,$2);
4857 }
4858 ;
4859
4860
4861 opt_fdw_options:
4862 fdw_options
4863 {
4864 $$ = $1;
4865 }
4866 |
4867 {
4868 $$=EMPTY; }
4869 ;
4870
4871
4872 AlterFdwStmt:
4873 ALTER FOREIGN DATA_P WRAPPER name opt_fdw_options alter_generic_options
4874 {
4875 $$ = cat_str(4,mm_strdup("alter foreign data wrapper"),$5,$6,$7);
4876 }
4877 | ALTER FOREIGN DATA_P WRAPPER name fdw_options
4878 {
4879 $$ = cat_str(3,mm_strdup("alter foreign data wrapper"),$5,$6);
4880 }
4881 ;
4882
4883
4884 create_generic_options:
4885 OPTIONS '(' generic_option_list ')'
4886 {
4887 $$ = cat_str(3,mm_strdup("options ("),$3,mm_strdup(")"));
4888 }
4889 |
4890 {
4891 $$=EMPTY; }
4892 ;
4893
4894
4895 generic_option_list:
4896 generic_option_elem
4897 {
4898 $$ = $1;
4899 }
4900 | generic_option_list ',' generic_option_elem
4901 {
4902 $$ = cat_str(3,$1,mm_strdup(","),$3);
4903 }
4904 ;
4905
4906
4907 alter_generic_options:
4908 OPTIONS '(' alter_generic_option_list ')'
4909 {
4910 $$ = cat_str(3,mm_strdup("options ("),$3,mm_strdup(")"));
4911 }
4912 ;
4913
4914
4915 alter_generic_option_list:
4916 alter_generic_option_elem
4917 {
4918 $$ = $1;
4919 }
4920 | alter_generic_option_list ',' alter_generic_option_elem
4921 {
4922 $$ = cat_str(3,$1,mm_strdup(","),$3);
4923 }
4924 ;
4925
4926
4927 alter_generic_option_elem:
4928 generic_option_elem
4929 {
4930 $$ = $1;
4931 }
4932 | SET generic_option_elem
4933 {
4934 $$ = cat_str(2,mm_strdup("set"),$2);
4935 }
4936 | ADD_P generic_option_elem
4937 {
4938 $$ = cat_str(2,mm_strdup("add"),$2);
4939 }
4940 | DROP generic_option_name
4941 {
4942 $$ = cat_str(2,mm_strdup("drop"),$2);
4943 }
4944 ;
4945
4946
4947 generic_option_elem:
4948 generic_option_name generic_option_arg
4949 {
4950 $$ = cat_str(2,$1,$2);
4951 }
4952 ;
4953
4954
4955 generic_option_name:
4956 ColLabel
4957 {
4958 $$ = $1;
4959 }
4960 ;
4961
4962
4963 generic_option_arg:
4964 ecpg_sconst
4965 {
4966 $$ = $1;
4967 }
4968 ;
4969
4970
4971 CreateForeignServerStmt:
4972 CREATE SERVER name opt_type opt_foreign_server_version FOREIGN DATA_P WRAPPER name create_generic_options
4973 {
4974 $$ = cat_str(7,mm_strdup("create server"),$3,$4,$5,mm_strdup("foreign data wrapper"),$9,$10);
4975 }
4976 | CREATE SERVER IF_P NOT EXISTS name opt_type opt_foreign_server_version FOREIGN DATA_P WRAPPER name create_generic_options
4977 {
4978 $$ = cat_str(7,mm_strdup("create server if not exists"),$6,$7,$8,mm_strdup("foreign data wrapper"),$12,$13);
4979 }
4980 ;
4981
4982
4983 opt_type:
4984 TYPE_P ecpg_sconst
4985 {
4986 $$ = cat_str(2,mm_strdup("type"),$2);
4987 }
4988 |
4989 {
4990 $$=EMPTY; }
4991 ;
4992
4993
4994 foreign_server_version:
4995 VERSION_P ecpg_sconst
4996 {
4997 $$ = cat_str(2,mm_strdup("version"),$2);
4998 }
4999 | VERSION_P NULL_P
5000 {
5001 $$ = mm_strdup("version null");
5002 }
5003 ;
5004
5005
5006 opt_foreign_server_version:
5007 foreign_server_version
5008 {
5009 $$ = $1;
5010 }
5011 |
5012 {
5013 $$=EMPTY; }
5014 ;
5015
5016
5017 AlterForeignServerStmt:
5018 ALTER SERVER name foreign_server_version alter_generic_options
5019 {
5020 $$ = cat_str(4,mm_strdup("alter server"),$3,$4,$5);
5021 }
5022 | ALTER SERVER name foreign_server_version
5023 {
5024 $$ = cat_str(3,mm_strdup("alter server"),$3,$4);
5025 }
5026 | ALTER SERVER name alter_generic_options
5027 {
5028 $$ = cat_str(3,mm_strdup("alter server"),$3,$4);
5029 }
5030 ;
5031
5032
5033 CreateForeignTableStmt:
5034 CREATE FOREIGN TABLE qualified_name '(' OptTableElementList ')' OptInherit SERVER name create_generic_options
5035 {
5036 $$ = cat_str(9,mm_strdup("create foreign table"),$4,mm_strdup("("),$6,mm_strdup(")"),$8,mm_strdup("server"),$10,$11);
5037 }
5038 | CREATE FOREIGN TABLE IF_P NOT EXISTS qualified_name '(' OptTableElementList ')' OptInherit SERVER name create_generic_options
5039 {
5040 $$ = cat_str(9,mm_strdup("create foreign table if not exists"),$7,mm_strdup("("),$9,mm_strdup(")"),$11,mm_strdup("server"),$13,$14);
5041 }
5042 | CREATE FOREIGN TABLE qualified_name PARTITION OF qualified_name OptTypedTableElementList PartitionBoundSpec SERVER name create_generic_options
5043 {
5044 $$ = cat_str(9,mm_strdup("create foreign table"),$4,mm_strdup("partition of"),$7,$8,$9,mm_strdup("server"),$11,$12);
5045 }
5046 | CREATE FOREIGN TABLE IF_P NOT EXISTS qualified_name PARTITION OF qualified_name OptTypedTableElementList PartitionBoundSpec SERVER name create_generic_options
5047 {
5048 $$ = cat_str(9,mm_strdup("create foreign table if not exists"),$7,mm_strdup("partition of"),$10,$11,$12,mm_strdup("server"),$14,$15);
5049 }
5050 ;
5051
5052
5053 AlterForeignTableStmt:
5054 ALTER FOREIGN TABLE relation_expr alter_table_cmds
5055 {
5056 $$ = cat_str(3,mm_strdup("alter foreign table"),$4,$5);
5057 }
5058 | ALTER FOREIGN TABLE IF_P EXISTS relation_expr alter_table_cmds
5059 {
5060 $$ = cat_str(3,mm_strdup("alter foreign table if exists"),$6,$7);
5061 }
5062 ;
5063
5064
5065 ImportForeignSchemaStmt:
5066 IMPORT_P FOREIGN SCHEMA name import_qualification FROM SERVER name INTO name create_generic_options
5067 {
5068 $$ = cat_str(8,mm_strdup("import foreign schema"),$4,$5,mm_strdup("from server"),$8,mm_strdup("into"),$10,$11);
5069 }
5070 ;
5071
5072
5073 import_qualification_type:
5074 LIMIT TO
5075 {
5076 $$ = mm_strdup("limit to");
5077 }
5078 | EXCEPT
5079 {
5080 $$ = mm_strdup("except");
5081 }
5082 ;
5083
5084
5085 import_qualification:
5086 import_qualification_type '(' relation_expr_list ')'
5087 {
5088 $$ = cat_str(4,$1,mm_strdup("("),$3,mm_strdup(")"));
5089 }
5090 |
5091 {
5092 $$=EMPTY; }
5093 ;
5094
5095
5096 CreateUserMappingStmt:
5097 CREATE USER MAPPING FOR auth_ident SERVER name create_generic_options
5098 {
5099 $$ = cat_str(5,mm_strdup("create user mapping for"),$5,mm_strdup("server"),$7,$8);
5100 }
5101 | CREATE USER MAPPING IF_P NOT EXISTS FOR auth_ident SERVER name create_generic_options
5102 {
5103 $$ = cat_str(5,mm_strdup("create user mapping if not exists for"),$8,mm_strdup("server"),$10,$11);
5104 }
5105 ;
5106
5107
5108 auth_ident:
5109 RoleSpec
5110 {
5111 $$ = $1;
5112 }
5113 | USER
5114 {
5115 $$ = mm_strdup("user");
5116 }
5117 ;
5118
5119
5120 DropUserMappingStmt:
5121 DROP USER MAPPING FOR auth_ident SERVER name
5122 {
5123 $$ = cat_str(4,mm_strdup("drop user mapping for"),$5,mm_strdup("server"),$7);
5124 }
5125 | DROP USER MAPPING IF_P EXISTS FOR auth_ident SERVER name
5126 {
5127 $$ = cat_str(4,mm_strdup("drop user mapping if exists for"),$7,mm_strdup("server"),$9);
5128 }
5129 ;
5130
5131
5132 AlterUserMappingStmt:
5133 ALTER USER MAPPING FOR auth_ident SERVER name alter_generic_options
5134 {
5135 $$ = cat_str(5,mm_strdup("alter user mapping for"),$5,mm_strdup("server"),$7,$8);
5136 }
5137 ;
5138
5139
5140 CreatePolicyStmt:
5141 CREATE POLICY name ON qualified_name RowSecurityDefaultPermissive RowSecurityDefaultForCmd RowSecurityDefaultToRole RowSecurityOptionalExpr RowSecurityOptionalWithCheck
5142 {
5143 $$ = cat_str(9,mm_strdup("create policy"),$3,mm_strdup("on"),$5,$6,$7,$8,$9,$10);
5144 }
5145 ;
5146
5147
5148 AlterPolicyStmt:
5149 ALTER POLICY name ON qualified_name RowSecurityOptionalToRole RowSecurityOptionalExpr RowSecurityOptionalWithCheck
5150 {
5151 $$ = cat_str(7,mm_strdup("alter policy"),$3,mm_strdup("on"),$5,$6,$7,$8);
5152 }
5153 ;
5154
5155
5156 RowSecurityOptionalExpr:
5157 USING '(' a_expr ')'
5158 {
5159 $$ = cat_str(3,mm_strdup("using ("),$3,mm_strdup(")"));
5160 }
5161 |
5162 {
5163 $$=EMPTY; }
5164 ;
5165
5166
5167 RowSecurityOptionalWithCheck:
5168 WITH CHECK '(' a_expr ')'
5169 {
5170 $$ = cat_str(3,mm_strdup("with check ("),$4,mm_strdup(")"));
5171 }
5172 |
5173 {
5174 $$=EMPTY; }
5175 ;
5176
5177
5178 RowSecurityDefaultToRole:
5179 TO role_list
5180 {
5181 $$ = cat_str(2,mm_strdup("to"),$2);
5182 }
5183 |
5184 {
5185 $$=EMPTY; }
5186 ;
5187
5188
5189 RowSecurityOptionalToRole:
5190 TO role_list
5191 {
5192 $$ = cat_str(2,mm_strdup("to"),$2);
5193 }
5194 |
5195 {
5196 $$=EMPTY; }
5197 ;
5198
5199
5200 RowSecurityDefaultPermissive:
5201 AS ecpg_ident
5202 {
5203 $$ = cat_str(2,mm_strdup("as"),$2);
5204 }
5205 |
5206 {
5207 $$=EMPTY; }
5208 ;
5209
5210
5211 RowSecurityDefaultForCmd:
5212 FOR row_security_cmd
5213 {
5214 $$ = cat_str(2,mm_strdup("for"),$2);
5215 }
5216 |
5217 {
5218 $$=EMPTY; }
5219 ;
5220
5221
5222 row_security_cmd:
5223 ALL
5224 {
5225 $$ = mm_strdup("all");
5226 }
5227 | SELECT
5228 {
5229 $$ = mm_strdup("select");
5230 }
5231 | INSERT
5232 {
5233 $$ = mm_strdup("insert");
5234 }
5235 | UPDATE
5236 {
5237 $$ = mm_strdup("update");
5238 }
5239 | DELETE_P
5240 {
5241 $$ = mm_strdup("delete");
5242 }
5243 ;
5244
5245
5246 CreateAmStmt:
5247 CREATE ACCESS METHOD name TYPE_P am_type HANDLER handler_name
5248 {
5249 $$ = cat_str(6,mm_strdup("create access method"),$4,mm_strdup("type"),$6,mm_strdup("handler"),$8);
5250 }
5251 ;
5252
5253
5254 am_type:
5255 INDEX
5256 {
5257 $$ = mm_strdup("index");
5258 }
5259 | TABLE
5260 {
5261 $$ = mm_strdup("table");
5262 }
5263 ;
5264
5265
5266 CreateTrigStmt:
5267 CREATE TRIGGER name TriggerActionTime TriggerEvents ON qualified_name TriggerReferencing TriggerForSpec TriggerWhen EXECUTE FUNCTION_or_PROCEDURE func_name '(' TriggerFuncArgs ')'
5268 {
5269 $$ = cat_str(15,mm_strdup("create trigger"),$3,$4,$5,mm_strdup("on"),$7,$8,$9,$10,mm_strdup("execute"),$12,$13,mm_strdup("("),$15,mm_strdup(")"));
5270 }
5271 | CREATE CONSTRAINT TRIGGER name AFTER TriggerEvents ON qualified_name OptConstrFromTable ConstraintAttributeSpec FOR EACH ROW TriggerWhen EXECUTE FUNCTION_or_PROCEDURE func_name '(' TriggerFuncArgs ')'
5272 {
5273 $$ = cat_str(16,mm_strdup("create constraint trigger"),$4,mm_strdup("after"),$6,mm_strdup("on"),$8,$9,$10,mm_strdup("for each row"),$14,mm_strdup("execute"),$16,$17,mm_strdup("("),$19,mm_strdup(")"));
5274 }
5275 ;
5276
5277
5278 TriggerActionTime:
5279 BEFORE
5280 {
5281 $$ = mm_strdup("before");
5282 }
5283 | AFTER
5284 {
5285 $$ = mm_strdup("after");
5286 }
5287 | INSTEAD OF
5288 {
5289 $$ = mm_strdup("instead of");
5290 }
5291 ;
5292
5293
5294 TriggerEvents:
5295 TriggerOneEvent
5296 {
5297 $$ = $1;
5298 }
5299 | TriggerEvents OR TriggerOneEvent
5300 {
5301 $$ = cat_str(3,$1,mm_strdup("or"),$3);
5302 }
5303 ;
5304
5305
5306 TriggerOneEvent:
5307 INSERT
5308 {
5309 $$ = mm_strdup("insert");
5310 }
5311 | DELETE_P
5312 {
5313 $$ = mm_strdup("delete");
5314 }
5315 | UPDATE
5316 {
5317 $$ = mm_strdup("update");
5318 }
5319 | UPDATE OF columnList
5320 {
5321 $$ = cat_str(2,mm_strdup("update of"),$3);
5322 }
5323 | TRUNCATE
5324 {
5325 $$ = mm_strdup("truncate");
5326 }
5327 ;
5328
5329
5330 TriggerReferencing:
5331 REFERENCING TriggerTransitions
5332 {
5333 $$ = cat_str(2,mm_strdup("referencing"),$2);
5334 }
5335 |
5336 {
5337 $$=EMPTY; }
5338 ;
5339
5340
5341 TriggerTransitions:
5342 TriggerTransition
5343 {
5344 $$ = $1;
5345 }
5346 | TriggerTransitions TriggerTransition
5347 {
5348 $$ = cat_str(2,$1,$2);
5349 }
5350 ;
5351
5352
5353 TriggerTransition:
5354 TransitionOldOrNew TransitionRowOrTable opt_as TransitionRelName
5355 {
5356 $$ = cat_str(4,$1,$2,$3,$4);
5357 }
5358 ;
5359
5360
5361 TransitionOldOrNew:
5362 NEW
5363 {
5364 $$ = mm_strdup("new");
5365 }
5366 | OLD
5367 {
5368 $$ = mm_strdup("old");
5369 }
5370 ;
5371
5372
5373 TransitionRowOrTable:
5374 TABLE
5375 {
5376 $$ = mm_strdup("table");
5377 }
5378 | ROW
5379 {
5380 $$ = mm_strdup("row");
5381 }
5382 ;
5383
5384
5385 TransitionRelName:
5386 ColId
5387 {
5388 $$ = $1;
5389 }
5390 ;
5391
5392
5393 TriggerForSpec:
5394 FOR TriggerForOptEach TriggerForType
5395 {
5396 $$ = cat_str(3,mm_strdup("for"),$2,$3);
5397 }
5398 |
5399 {
5400 $$=EMPTY; }
5401 ;
5402
5403
5404 TriggerForOptEach:
5405 EACH
5406 {
5407 $$ = mm_strdup("each");
5408 }
5409 |
5410 {
5411 $$=EMPTY; }
5412 ;
5413
5414
5415 TriggerForType:
5416 ROW
5417 {
5418 $$ = mm_strdup("row");
5419 }
5420 | STATEMENT
5421 {
5422 $$ = mm_strdup("statement");
5423 }
5424 ;
5425
5426
5427 TriggerWhen:
5428 WHEN '(' a_expr ')'
5429 {
5430 $$ = cat_str(3,mm_strdup("when ("),$3,mm_strdup(")"));
5431 }
5432 |
5433 {
5434 $$=EMPTY; }
5435 ;
5436
5437
5438 FUNCTION_or_PROCEDURE:
5439 FUNCTION
5440 {
5441 $$ = mm_strdup("function");
5442 }
5443 | PROCEDURE
5444 {
5445 $$ = mm_strdup("procedure");
5446 }
5447 ;
5448
5449
5450 TriggerFuncArgs:
5451 TriggerFuncArg
5452 {
5453 $$ = $1;
5454 }
5455 | TriggerFuncArgs ',' TriggerFuncArg
5456 {
5457 $$ = cat_str(3,$1,mm_strdup(","),$3);
5458 }
5459 |
5460 {
5461 $$=EMPTY; }
5462 ;
5463
5464
5465 TriggerFuncArg:
5466 Iconst
5467 {
5468 $$ = $1;
5469 }
5470 | ecpg_fconst
5471 {
5472 $$ = $1;
5473 }
5474 | ecpg_sconst
5475 {
5476 $$ = $1;
5477 }
5478 | ColLabel
5479 {
5480 $$ = $1;
5481 }
5482 ;
5483
5484
5485 OptConstrFromTable:
5486 FROM qualified_name
5487 {
5488 $$ = cat_str(2,mm_strdup("from"),$2);
5489 }
5490 |
5491 {
5492 $$=EMPTY; }
5493 ;
5494
5495
5496 ConstraintAttributeSpec:
5497
5498 {
5499 $$=EMPTY; }
5500 | ConstraintAttributeSpec ConstraintAttributeElem
5501 {
5502 $$ = cat_str(2,$1,$2);
5503 }
5504 ;
5505
5506
5507 ConstraintAttributeElem:
5508 NOT DEFERRABLE
5509 {
5510 $$ = mm_strdup("not deferrable");
5511 }
5512 | DEFERRABLE
5513 {
5514 $$ = mm_strdup("deferrable");
5515 }
5516 | INITIALLY IMMEDIATE
5517 {
5518 $$ = mm_strdup("initially immediate");
5519 }
5520 | INITIALLY DEFERRED
5521 {
5522 $$ = mm_strdup("initially deferred");
5523 }
5524 | NOT VALID
5525 {
5526 $$ = mm_strdup("not valid");
5527 }
5528 | NO INHERIT
5529 {
5530 $$ = mm_strdup("no inherit");
5531 }
5532 ;
5533
5534
5535 CreateEventTrigStmt:
5536 CREATE EVENT TRIGGER name ON ColLabel EXECUTE FUNCTION_or_PROCEDURE func_name '(' ')'
5537 {
5538 $$ = cat_str(8,mm_strdup("create event trigger"),$4,mm_strdup("on"),$6,mm_strdup("execute"),$8,$9,mm_strdup("( )"));
5539 }
5540 | CREATE EVENT TRIGGER name ON ColLabel WHEN event_trigger_when_list EXECUTE FUNCTION_or_PROCEDURE func_name '(' ')'
5541 {
5542 $$ = cat_str(10,mm_strdup("create event trigger"),$4,mm_strdup("on"),$6,mm_strdup("when"),$8,mm_strdup("execute"),$10,$11,mm_strdup("( )"));
5543 }
5544 ;
5545
5546
5547 event_trigger_when_list:
5548 event_trigger_when_item
5549 {
5550 $$ = $1;
5551 }
5552 | event_trigger_when_list AND event_trigger_when_item
5553 {
5554 $$ = cat_str(3,$1,mm_strdup("and"),$3);
5555 }
5556 ;
5557
5558
5559 event_trigger_when_item:
5560 ColId IN_P '(' event_trigger_value_list ')'
5561 {
5562 $$ = cat_str(4,$1,mm_strdup("in ("),$4,mm_strdup(")"));
5563 }
5564 ;
5565
5566
5567 event_trigger_value_list:
5568 SCONST
5569 {
5570 $$ = mm_strdup("sconst");
5571 }
5572 | event_trigger_value_list ',' SCONST
5573 {
5574 $$ = cat_str(2,$1,mm_strdup(", sconst"));
5575 }
5576 ;
5577
5578
5579 AlterEventTrigStmt:
5580 ALTER EVENT TRIGGER name enable_trigger
5581 {
5582 $$ = cat_str(3,mm_strdup("alter event trigger"),$4,$5);
5583 }
5584 ;
5585
5586
5587 enable_trigger:
5588 ENABLE_P
5589 {
5590 $$ = mm_strdup("enable");
5591 }
5592 | ENABLE_P REPLICA
5593 {
5594 $$ = mm_strdup("enable replica");
5595 }
5596 | ENABLE_P ALWAYS
5597 {
5598 $$ = mm_strdup("enable always");
5599 }
5600 | DISABLE_P
5601 {
5602 $$ = mm_strdup("disable");
5603 }
5604 ;
5605
5606
5607 CreateAssertionStmt:
5608 CREATE ASSERTION any_name CHECK '(' a_expr ')' ConstraintAttributeSpec
5609 {
5610 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
5611 $$ = cat_str(6,mm_strdup("create assertion"),$3,mm_strdup("check ("),$6,mm_strdup(")"),$8);
5612 }
5613 ;
5614
5615
5616 DefineStmt:
5617 CREATE opt_or_replace AGGREGATE func_name aggr_args definition
5618 {
5619 $$ = cat_str(6,mm_strdup("create"),$2,mm_strdup("aggregate"),$4,$5,$6);
5620 }
5621 | CREATE opt_or_replace AGGREGATE func_name old_aggr_definition
5622 {
5623 $$ = cat_str(5,mm_strdup("create"),$2,mm_strdup("aggregate"),$4,$5);
5624 }
5625 | CREATE OPERATOR any_operator definition
5626 {
5627 $$ = cat_str(3,mm_strdup("create operator"),$3,$4);
5628 }
5629 | CREATE TYPE_P any_name definition
5630 {
5631 $$ = cat_str(3,mm_strdup("create type"),$3,$4);
5632 }
5633 | CREATE TYPE_P any_name
5634 {
5635 $$ = cat_str(2,mm_strdup("create type"),$3);
5636 }
5637 | CREATE TYPE_P any_name AS '(' OptTableFuncElementList ')'
5638 {
5639 $$ = cat_str(5,mm_strdup("create type"),$3,mm_strdup("as ("),$6,mm_strdup(")"));
5640 }
5641 | CREATE TYPE_P any_name AS ENUM_P '(' opt_enum_val_list ')'
5642 {
5643 $$ = cat_str(5,mm_strdup("create type"),$3,mm_strdup("as enum ("),$7,mm_strdup(")"));
5644 }
5645 | CREATE TYPE_P any_name AS RANGE definition
5646 {
5647 $$ = cat_str(4,mm_strdup("create type"),$3,mm_strdup("as range"),$6);
5648 }
5649 | CREATE TEXT_P SEARCH PARSER any_name definition
5650 {
5651 $$ = cat_str(3,mm_strdup("create text search parser"),$5,$6);
5652 }
5653 | CREATE TEXT_P SEARCH DICTIONARY any_name definition
5654 {
5655 $$ = cat_str(3,mm_strdup("create text search dictionary"),$5,$6);
5656 }
5657 | CREATE TEXT_P SEARCH TEMPLATE any_name definition
5658 {
5659 $$ = cat_str(3,mm_strdup("create text search template"),$5,$6);
5660 }
5661 | CREATE TEXT_P SEARCH CONFIGURATION any_name definition
5662 {
5663 $$ = cat_str(3,mm_strdup("create text search configuration"),$5,$6);
5664 }
5665 | CREATE COLLATION any_name definition
5666 {
5667 $$ = cat_str(3,mm_strdup("create collation"),$3,$4);
5668 }
5669 | CREATE COLLATION IF_P NOT EXISTS any_name definition
5670 {
5671 $$ = cat_str(3,mm_strdup("create collation if not exists"),$6,$7);
5672 }
5673 | CREATE COLLATION any_name FROM any_name
5674 {
5675 $$ = cat_str(4,mm_strdup("create collation"),$3,mm_strdup("from"),$5);
5676 }
5677 | CREATE COLLATION IF_P NOT EXISTS any_name FROM any_name
5678 {
5679 $$ = cat_str(4,mm_strdup("create collation if not exists"),$6,mm_strdup("from"),$8);
5680 }
5681 ;
5682
5683
5684 definition:
5685 '(' def_list ')'
5686 {
5687 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
5688 }
5689 ;
5690
5691
5692 def_list:
5693 def_elem
5694 {
5695 $$ = $1;
5696 }
5697 | def_list ',' def_elem
5698 {
5699 $$ = cat_str(3,$1,mm_strdup(","),$3);
5700 }
5701 ;
5702
5703
5704 def_elem:
5705 ColLabel '=' def_arg
5706 {
5707 $$ = cat_str(3,$1,mm_strdup("="),$3);
5708 }
5709 | ColLabel
5710 {
5711 $$ = $1;
5712 }
5713 ;
5714
5715
5716 def_arg:
5717 func_type
5718 {
5719 $$ = $1;
5720 }
5721 | reserved_keyword
5722 {
5723 $$ = $1;
5724 }
5725 | qual_all_Op
5726 {
5727 $$ = $1;
5728 }
5729 | NumericOnly
5730 {
5731 $$ = $1;
5732 }
5733 | ecpg_sconst
5734 {
5735 $$ = $1;
5736 }
5737 | NONE
5738 {
5739 $$ = mm_strdup("none");
5740 }
5741 ;
5742
5743
5744 old_aggr_definition:
5745 '(' old_aggr_list ')'
5746 {
5747 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
5748 }
5749 ;
5750
5751
5752 old_aggr_list:
5753 old_aggr_elem
5754 {
5755 $$ = $1;
5756 }
5757 | old_aggr_list ',' old_aggr_elem
5758 {
5759 $$ = cat_str(3,$1,mm_strdup(","),$3);
5760 }
5761 ;
5762
5763
5764 old_aggr_elem:
5765 ecpg_ident '=' def_arg
5766 {
5767 $$ = cat_str(3,$1,mm_strdup("="),$3);
5768 }
5769 ;
5770
5771
5772 opt_enum_val_list:
5773 enum_val_list
5774 {
5775 $$ = $1;
5776 }
5777 |
5778 {
5779 $$=EMPTY; }
5780 ;
5781
5782
5783 enum_val_list:
5784 ecpg_sconst
5785 {
5786 $$ = $1;
5787 }
5788 | enum_val_list ',' ecpg_sconst
5789 {
5790 $$ = cat_str(3,$1,mm_strdup(","),$3);
5791 }
5792 ;
5793
5794
5795 AlterEnumStmt:
5796 ALTER TYPE_P any_name ADD_P VALUE_P opt_if_not_exists ecpg_sconst
5797 {
5798 $$ = cat_str(5,mm_strdup("alter type"),$3,mm_strdup("add value"),$6,$7);
5799 }
5800 | ALTER TYPE_P any_name ADD_P VALUE_P opt_if_not_exists ecpg_sconst BEFORE ecpg_sconst
5801 {
5802 $$ = cat_str(7,mm_strdup("alter type"),$3,mm_strdup("add value"),$6,$7,mm_strdup("before"),$9);
5803 }
5804 | ALTER TYPE_P any_name ADD_P VALUE_P opt_if_not_exists ecpg_sconst AFTER ecpg_sconst
5805 {
5806 $$ = cat_str(7,mm_strdup("alter type"),$3,mm_strdup("add value"),$6,$7,mm_strdup("after"),$9);
5807 }
5808 | ALTER TYPE_P any_name RENAME VALUE_P ecpg_sconst TO ecpg_sconst
5809 {
5810 $$ = cat_str(6,mm_strdup("alter type"),$3,mm_strdup("rename value"),$6,mm_strdup("to"),$8);
5811 }
5812 ;
5813
5814
5815 opt_if_not_exists:
5816 IF_P NOT EXISTS
5817 {
5818 $$ = mm_strdup("if not exists");
5819 }
5820 |
5821 {
5822 $$=EMPTY; }
5823 ;
5824
5825
5826 CreateOpClassStmt:
5827 CREATE OPERATOR CLASS any_name opt_default FOR TYPE_P Typename USING access_method opt_opfamily AS opclass_item_list
5828 {
5829 $$ = cat_str(10,mm_strdup("create operator class"),$4,$5,mm_strdup("for type"),$8,mm_strdup("using"),$10,$11,mm_strdup("as"),$13);
5830 }
5831 ;
5832
5833
5834 opclass_item_list:
5835 opclass_item
5836 {
5837 $$ = $1;
5838 }
5839 | opclass_item_list ',' opclass_item
5840 {
5841 $$ = cat_str(3,$1,mm_strdup(","),$3);
5842 }
5843 ;
5844
5845
5846 opclass_item:
5847 OPERATOR Iconst any_operator opclass_purpose opt_recheck
5848 {
5849 $$ = cat_str(5,mm_strdup("operator"),$2,$3,$4,$5);
5850 }
5851 | OPERATOR Iconst operator_with_argtypes opclass_purpose opt_recheck
5852 {
5853 $$ = cat_str(5,mm_strdup("operator"),$2,$3,$4,$5);
5854 }
5855 | FUNCTION Iconst function_with_argtypes
5856 {
5857 $$ = cat_str(3,mm_strdup("function"),$2,$3);
5858 }
5859 | FUNCTION Iconst '(' type_list ')' function_with_argtypes
5860 {
5861 $$ = cat_str(6,mm_strdup("function"),$2,mm_strdup("("),$4,mm_strdup(")"),$6);
5862 }
5863 | STORAGE Typename
5864 {
5865 $$ = cat_str(2,mm_strdup("storage"),$2);
5866 }
5867 ;
5868
5869
5870 opt_default:
5871 DEFAULT
5872 {
5873 $$ = mm_strdup("default");
5874 }
5875 |
5876 {
5877 $$=EMPTY; }
5878 ;
5879
5880
5881 opt_opfamily:
5882 FAMILY any_name
5883 {
5884 $$ = cat_str(2,mm_strdup("family"),$2);
5885 }
5886 |
5887 {
5888 $$=EMPTY; }
5889 ;
5890
5891
5892 opclass_purpose:
5893 FOR SEARCH
5894 {
5895 $$ = mm_strdup("for search");
5896 }
5897 | FOR ORDER BY any_name
5898 {
5899 $$ = cat_str(2,mm_strdup("for order by"),$4);
5900 }
5901 |
5902 {
5903 $$=EMPTY; }
5904 ;
5905
5906
5907 opt_recheck:
5908 RECHECK
5909 {
5910 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
5911 $$ = mm_strdup("recheck");
5912 }
5913 |
5914 {
5915 $$=EMPTY; }
5916 ;
5917
5918
5919 CreateOpFamilyStmt:
5920 CREATE OPERATOR FAMILY any_name USING access_method
5921 {
5922 $$ = cat_str(4,mm_strdup("create operator family"),$4,mm_strdup("using"),$6);
5923 }
5924 ;
5925
5926
5927 AlterOpFamilyStmt:
5928 ALTER OPERATOR FAMILY any_name USING access_method ADD_P opclass_item_list
5929 {
5930 $$ = cat_str(6,mm_strdup("alter operator family"),$4,mm_strdup("using"),$6,mm_strdup("add"),$8);
5931 }
5932 | ALTER OPERATOR FAMILY any_name USING access_method DROP opclass_drop_list
5933 {
5934 $$ = cat_str(6,mm_strdup("alter operator family"),$4,mm_strdup("using"),$6,mm_strdup("drop"),$8);
5935 }
5936 ;
5937
5938
5939 opclass_drop_list:
5940 opclass_drop
5941 {
5942 $$ = $1;
5943 }
5944 | opclass_drop_list ',' opclass_drop
5945 {
5946 $$ = cat_str(3,$1,mm_strdup(","),$3);
5947 }
5948 ;
5949
5950
5951 opclass_drop:
5952 OPERATOR Iconst '(' type_list ')'
5953 {
5954 $$ = cat_str(5,mm_strdup("operator"),$2,mm_strdup("("),$4,mm_strdup(")"));
5955 }
5956 | FUNCTION Iconst '(' type_list ')'
5957 {
5958 $$ = cat_str(5,mm_strdup("function"),$2,mm_strdup("("),$4,mm_strdup(")"));
5959 }
5960 ;
5961
5962
5963 DropOpClassStmt:
5964 DROP OPERATOR CLASS any_name USING access_method opt_drop_behavior
5965 {
5966 $$ = cat_str(5,mm_strdup("drop operator class"),$4,mm_strdup("using"),$6,$7);
5967 }
5968 | DROP OPERATOR CLASS IF_P EXISTS any_name USING access_method opt_drop_behavior
5969 {
5970 $$ = cat_str(5,mm_strdup("drop operator class if exists"),$6,mm_strdup("using"),$8,$9);
5971 }
5972 ;
5973
5974
5975 DropOpFamilyStmt:
5976 DROP OPERATOR FAMILY any_name USING access_method opt_drop_behavior
5977 {
5978 $$ = cat_str(5,mm_strdup("drop operator family"),$4,mm_strdup("using"),$6,$7);
5979 }
5980 | DROP OPERATOR FAMILY IF_P EXISTS any_name USING access_method opt_drop_behavior
5981 {
5982 $$ = cat_str(5,mm_strdup("drop operator family if exists"),$6,mm_strdup("using"),$8,$9);
5983 }
5984 ;
5985
5986
5987 DropOwnedStmt:
5988 DROP OWNED BY role_list opt_drop_behavior
5989 {
5990 $$ = cat_str(3,mm_strdup("drop owned by"),$4,$5);
5991 }
5992 ;
5993
5994
5995 ReassignOwnedStmt:
5996 REASSIGN OWNED BY role_list TO RoleSpec
5997 {
5998 $$ = cat_str(4,mm_strdup("reassign owned by"),$4,mm_strdup("to"),$6);
5999 }
6000 ;
6001
6002
6003 DropStmt:
6004 DROP drop_type_any_name IF_P EXISTS any_name_list opt_drop_behavior
6005 {
6006 $$ = cat_str(5,mm_strdup("drop"),$2,mm_strdup("if exists"),$5,$6);
6007 }
6008 | DROP drop_type_any_name any_name_list opt_drop_behavior
6009 {
6010 $$ = cat_str(4,mm_strdup("drop"),$2,$3,$4);
6011 }
6012 | DROP drop_type_name IF_P EXISTS name_list opt_drop_behavior
6013 {
6014 $$ = cat_str(5,mm_strdup("drop"),$2,mm_strdup("if exists"),$5,$6);
6015 }
6016 | DROP drop_type_name name_list opt_drop_behavior
6017 {
6018 $$ = cat_str(4,mm_strdup("drop"),$2,$3,$4);
6019 }
6020 | DROP drop_type_name_on_any_name name ON any_name opt_drop_behavior
6021 {
6022 $$ = cat_str(6,mm_strdup("drop"),$2,$3,mm_strdup("on"),$5,$6);
6023 }
6024 | DROP drop_type_name_on_any_name IF_P EXISTS name ON any_name opt_drop_behavior
6025 {
6026 $$ = cat_str(7,mm_strdup("drop"),$2,mm_strdup("if exists"),$5,mm_strdup("on"),$7,$8);
6027 }
6028 | DROP TYPE_P type_name_list opt_drop_behavior
6029 {
6030 $$ = cat_str(3,mm_strdup("drop type"),$3,$4);
6031 }
6032 | DROP TYPE_P IF_P EXISTS type_name_list opt_drop_behavior
6033 {
6034 $$ = cat_str(3,mm_strdup("drop type if exists"),$5,$6);
6035 }
6036 | DROP DOMAIN_P type_name_list opt_drop_behavior
6037 {
6038 $$ = cat_str(3,mm_strdup("drop domain"),$3,$4);
6039 }
6040 | DROP DOMAIN_P IF_P EXISTS type_name_list opt_drop_behavior
6041 {
6042 $$ = cat_str(3,mm_strdup("drop domain if exists"),$5,$6);
6043 }
6044 | DROP INDEX CONCURRENTLY any_name_list opt_drop_behavior
6045 {
6046 $$ = cat_str(3,mm_strdup("drop index concurrently"),$4,$5);
6047 }
6048 | DROP INDEX CONCURRENTLY IF_P EXISTS any_name_list opt_drop_behavior
6049 {
6050 $$ = cat_str(3,mm_strdup("drop index concurrently if exists"),$6,$7);
6051 }
6052 ;
6053
6054
6055 drop_type_any_name:
6056 TABLE
6057 {
6058 $$ = mm_strdup("table");
6059 }
6060 | SEQUENCE
6061 {
6062 $$ = mm_strdup("sequence");
6063 }
6064 | VIEW
6065 {
6066 $$ = mm_strdup("view");
6067 }
6068 | MATERIALIZED VIEW
6069 {
6070 $$ = mm_strdup("materialized view");
6071 }
6072 | INDEX
6073 {
6074 $$ = mm_strdup("index");
6075 }
6076 | FOREIGN TABLE
6077 {
6078 $$ = mm_strdup("foreign table");
6079 }
6080 | COLLATION
6081 {
6082 $$ = mm_strdup("collation");
6083 }
6084 | CONVERSION_P
6085 {
6086 $$ = mm_strdup("conversion");
6087 }
6088 | STATISTICS
6089 {
6090 $$ = mm_strdup("statistics");
6091 }
6092 | TEXT_P SEARCH PARSER
6093 {
6094 $$ = mm_strdup("text search parser");
6095 }
6096 | TEXT_P SEARCH DICTIONARY
6097 {
6098 $$ = mm_strdup("text search dictionary");
6099 }
6100 | TEXT_P SEARCH TEMPLATE
6101 {
6102 $$ = mm_strdup("text search template");
6103 }
6104 | TEXT_P SEARCH CONFIGURATION
6105 {
6106 $$ = mm_strdup("text search configuration");
6107 }
6108 ;
6109
6110
6111 drop_type_name:
6112 ACCESS METHOD
6113 {
6114 $$ = mm_strdup("access method");
6115 }
6116 | EVENT TRIGGER
6117 {
6118 $$ = mm_strdup("event trigger");
6119 }
6120 | EXTENSION
6121 {
6122 $$ = mm_strdup("extension");
6123 }
6124 | FOREIGN DATA_P WRAPPER
6125 {
6126 $$ = mm_strdup("foreign data wrapper");
6127 }
6128 | PUBLICATION
6129 {
6130 $$ = mm_strdup("publication");
6131 }
6132 | SCHEMA
6133 {
6134 $$ = mm_strdup("schema");
6135 }
6136 | SERVER
6137 {
6138 $$ = mm_strdup("server");
6139 }
6140 ;
6141
6142
6143 drop_type_name_on_any_name:
6144 POLICY
6145 {
6146 $$ = mm_strdup("policy");
6147 }
6148 | RULE
6149 {
6150 $$ = mm_strdup("rule");
6151 }
6152 | TRIGGER
6153 {
6154 $$ = mm_strdup("trigger");
6155 }
6156 ;
6157
6158
6159 any_name_list:
6160 any_name
6161 {
6162 $$ = $1;
6163 }
6164 | any_name_list ',' any_name
6165 {
6166 $$ = cat_str(3,$1,mm_strdup(","),$3);
6167 }
6168 ;
6169
6170
6171 any_name:
6172 ColId
6173 {
6174 $$ = $1;
6175 }
6176 | ColId attrs
6177 {
6178 $$ = cat_str(2,$1,$2);
6179 }
6180 ;
6181
6182
6183 attrs:
6184 '.' attr_name
6185 {
6186 $$ = cat_str(2,mm_strdup("."),$2);
6187 }
6188 | attrs '.' attr_name
6189 {
6190 $$ = cat_str(3,$1,mm_strdup("."),$3);
6191 }
6192 ;
6193
6194
6195 type_name_list:
6196 Typename
6197 {
6198 $$ = $1;
6199 }
6200 | type_name_list ',' Typename
6201 {
6202 $$ = cat_str(3,$1,mm_strdup(","),$3);
6203 }
6204 ;
6205
6206
6207 TruncateStmt:
6208 TRUNCATE opt_table relation_expr_list opt_restart_seqs opt_drop_behavior
6209 {
6210 $$ = cat_str(5,mm_strdup("truncate"),$2,$3,$4,$5);
6211 }
6212 ;
6213
6214
6215 opt_restart_seqs:
6216 CONTINUE_P IDENTITY_P
6217 {
6218 $$ = mm_strdup("continue identity");
6219 }
6220 | RESTART IDENTITY_P
6221 {
6222 $$ = mm_strdup("restart identity");
6223 }
6224 |
6225 {
6226 $$=EMPTY; }
6227 ;
6228
6229
6230 CommentStmt:
6231 COMMENT ON comment_type_any_name any_name IS comment_text
6232 {
6233 $$ = cat_str(5,mm_strdup("comment on"),$3,$4,mm_strdup("is"),$6);
6234 }
6235 | COMMENT ON comment_type_name name IS comment_text
6236 {
6237 $$ = cat_str(5,mm_strdup("comment on"),$3,$4,mm_strdup("is"),$6);
6238 }
6239 | COMMENT ON TYPE_P Typename IS comment_text
6240 {
6241 $$ = cat_str(4,mm_strdup("comment on type"),$4,mm_strdup("is"),$6);
6242 }
6243 | COMMENT ON DOMAIN_P Typename IS comment_text
6244 {
6245 $$ = cat_str(4,mm_strdup("comment on domain"),$4,mm_strdup("is"),$6);
6246 }
6247 | COMMENT ON AGGREGATE aggregate_with_argtypes IS comment_text
6248 {
6249 $$ = cat_str(4,mm_strdup("comment on aggregate"),$4,mm_strdup("is"),$6);
6250 }
6251 | COMMENT ON FUNCTION function_with_argtypes IS comment_text
6252 {
6253 $$ = cat_str(4,mm_strdup("comment on function"),$4,mm_strdup("is"),$6);
6254 }
6255 | COMMENT ON OPERATOR operator_with_argtypes IS comment_text
6256 {
6257 $$ = cat_str(4,mm_strdup("comment on operator"),$4,mm_strdup("is"),$6);
6258 }
6259 | COMMENT ON CONSTRAINT name ON any_name IS comment_text
6260 {
6261 $$ = cat_str(6,mm_strdup("comment on constraint"),$4,mm_strdup("on"),$6,mm_strdup("is"),$8);
6262 }
6263 | COMMENT ON CONSTRAINT name ON DOMAIN_P any_name IS comment_text
6264 {
6265 $$ = cat_str(6,mm_strdup("comment on constraint"),$4,mm_strdup("on domain"),$7,mm_strdup("is"),$9);
6266 }
6267 | COMMENT ON POLICY name ON any_name IS comment_text
6268 {
6269 $$ = cat_str(6,mm_strdup("comment on policy"),$4,mm_strdup("on"),$6,mm_strdup("is"),$8);
6270 }
6271 | COMMENT ON PROCEDURE function_with_argtypes IS comment_text
6272 {
6273 $$ = cat_str(4,mm_strdup("comment on procedure"),$4,mm_strdup("is"),$6);
6274 }
6275 | COMMENT ON ROUTINE function_with_argtypes IS comment_text
6276 {
6277 $$ = cat_str(4,mm_strdup("comment on routine"),$4,mm_strdup("is"),$6);
6278 }
6279 | COMMENT ON RULE name ON any_name IS comment_text
6280 {
6281 $$ = cat_str(6,mm_strdup("comment on rule"),$4,mm_strdup("on"),$6,mm_strdup("is"),$8);
6282 }
6283 | COMMENT ON TRANSFORM FOR Typename LANGUAGE name IS comment_text
6284 {
6285 $$ = cat_str(6,mm_strdup("comment on transform for"),$5,mm_strdup("language"),$7,mm_strdup("is"),$9);
6286 }
6287 | COMMENT ON TRIGGER name ON any_name IS comment_text
6288 {
6289 $$ = cat_str(6,mm_strdup("comment on trigger"),$4,mm_strdup("on"),$6,mm_strdup("is"),$8);
6290 }
6291 | COMMENT ON OPERATOR CLASS any_name USING access_method IS comment_text
6292 {
6293 $$ = cat_str(6,mm_strdup("comment on operator class"),$5,mm_strdup("using"),$7,mm_strdup("is"),$9);
6294 }
6295 | COMMENT ON OPERATOR FAMILY any_name USING access_method IS comment_text
6296 {
6297 $$ = cat_str(6,mm_strdup("comment on operator family"),$5,mm_strdup("using"),$7,mm_strdup("is"),$9);
6298 }
6299 | COMMENT ON LARGE_P OBJECT_P NumericOnly IS comment_text
6300 {
6301 $$ = cat_str(4,mm_strdup("comment on large object"),$5,mm_strdup("is"),$7);
6302 }
6303 | COMMENT ON CAST '(' Typename AS Typename ')' IS comment_text
6304 {
6305 $$ = cat_str(6,mm_strdup("comment on cast ("),$5,mm_strdup("as"),$7,mm_strdup(") is"),$10);
6306 }
6307 ;
6308
6309
6310 comment_type_any_name:
6311 COLUMN
6312 {
6313 $$ = mm_strdup("column");
6314 }
6315 | INDEX
6316 {
6317 $$ = mm_strdup("index");
6318 }
6319 | SEQUENCE
6320 {
6321 $$ = mm_strdup("sequence");
6322 }
6323 | STATISTICS
6324 {
6325 $$ = mm_strdup("statistics");
6326 }
6327 | TABLE
6328 {
6329 $$ = mm_strdup("table");
6330 }
6331 | VIEW
6332 {
6333 $$ = mm_strdup("view");
6334 }
6335 | MATERIALIZED VIEW
6336 {
6337 $$ = mm_strdup("materialized view");
6338 }
6339 | COLLATION
6340 {
6341 $$ = mm_strdup("collation");
6342 }
6343 | CONVERSION_P
6344 {
6345 $$ = mm_strdup("conversion");
6346 }
6347 | FOREIGN TABLE
6348 {
6349 $$ = mm_strdup("foreign table");
6350 }
6351 | TEXT_P SEARCH CONFIGURATION
6352 {
6353 $$ = mm_strdup("text search configuration");
6354 }
6355 | TEXT_P SEARCH DICTIONARY
6356 {
6357 $$ = mm_strdup("text search dictionary");
6358 }
6359 | TEXT_P SEARCH PARSER
6360 {
6361 $$ = mm_strdup("text search parser");
6362 }
6363 | TEXT_P SEARCH TEMPLATE
6364 {
6365 $$ = mm_strdup("text search template");
6366 }
6367 ;
6368
6369
6370 comment_type_name:
6371 ACCESS METHOD
6372 {
6373 $$ = mm_strdup("access method");
6374 }
6375 | DATABASE
6376 {
6377 $$ = mm_strdup("database");
6378 }
6379 | EVENT TRIGGER
6380 {
6381 $$ = mm_strdup("event trigger");
6382 }
6383 | EXTENSION
6384 {
6385 $$ = mm_strdup("extension");
6386 }
6387 | FOREIGN DATA_P WRAPPER
6388 {
6389 $$ = mm_strdup("foreign data wrapper");
6390 }
6391 | opt_procedural LANGUAGE
6392 {
6393 $$ = cat_str(2,$1,mm_strdup("language"));
6394 }
6395 | PUBLICATION
6396 {
6397 $$ = mm_strdup("publication");
6398 }
6399 | ROLE
6400 {
6401 $$ = mm_strdup("role");
6402 }
6403 | SCHEMA
6404 {
6405 $$ = mm_strdup("schema");
6406 }
6407 | SERVER
6408 {
6409 $$ = mm_strdup("server");
6410 }
6411 | SUBSCRIPTION
6412 {
6413 $$ = mm_strdup("subscription");
6414 }
6415 | TABLESPACE
6416 {
6417 $$ = mm_strdup("tablespace");
6418 }
6419 ;
6420
6421
6422 comment_text:
6423 ecpg_sconst
6424 {
6425 $$ = $1;
6426 }
6427 | NULL_P
6428 {
6429 $$ = mm_strdup("null");
6430 }
6431 ;
6432
6433
6434 SecLabelStmt:
6435 SECURITY LABEL opt_provider ON security_label_type_any_name any_name IS security_label
6436 {
6437 $$ = cat_str(7,mm_strdup("security label"),$3,mm_strdup("on"),$5,$6,mm_strdup("is"),$8);
6438 }
6439 | SECURITY LABEL opt_provider ON security_label_type_name name IS security_label
6440 {
6441 $$ = cat_str(7,mm_strdup("security label"),$3,mm_strdup("on"),$5,$6,mm_strdup("is"),$8);
6442 }
6443 | SECURITY LABEL opt_provider ON TYPE_P Typename IS security_label
6444 {
6445 $$ = cat_str(6,mm_strdup("security label"),$3,mm_strdup("on type"),$6,mm_strdup("is"),$8);
6446 }
6447 | SECURITY LABEL opt_provider ON DOMAIN_P Typename IS security_label
6448 {
6449 $$ = cat_str(6,mm_strdup("security label"),$3,mm_strdup("on domain"),$6,mm_strdup("is"),$8);
6450 }
6451 | SECURITY LABEL opt_provider ON AGGREGATE aggregate_with_argtypes IS security_label
6452 {
6453 $$ = cat_str(6,mm_strdup("security label"),$3,mm_strdup("on aggregate"),$6,mm_strdup("is"),$8);
6454 }
6455 | SECURITY LABEL opt_provider ON FUNCTION function_with_argtypes IS security_label
6456 {
6457 $$ = cat_str(6,mm_strdup("security label"),$3,mm_strdup("on function"),$6,mm_strdup("is"),$8);
6458 }
6459 | SECURITY LABEL opt_provider ON LARGE_P OBJECT_P NumericOnly IS security_label
6460 {
6461 $$ = cat_str(6,mm_strdup("security label"),$3,mm_strdup("on large object"),$7,mm_strdup("is"),$9);
6462 }
6463 | SECURITY LABEL opt_provider ON PROCEDURE function_with_argtypes IS security_label
6464 {
6465 $$ = cat_str(6,mm_strdup("security label"),$3,mm_strdup("on procedure"),$6,mm_strdup("is"),$8);
6466 }
6467 | SECURITY LABEL opt_provider ON ROUTINE function_with_argtypes IS security_label
6468 {
6469 $$ = cat_str(6,mm_strdup("security label"),$3,mm_strdup("on routine"),$6,mm_strdup("is"),$8);
6470 }
6471 ;
6472
6473
6474 opt_provider:
6475 FOR NonReservedWord_or_Sconst
6476 {
6477 $$ = cat_str(2,mm_strdup("for"),$2);
6478 }
6479 |
6480 {
6481 $$=EMPTY; }
6482 ;
6483
6484
6485 security_label_type_any_name:
6486 COLUMN
6487 {
6488 $$ = mm_strdup("column");
6489 }
6490 | FOREIGN TABLE
6491 {
6492 $$ = mm_strdup("foreign table");
6493 }
6494 | SEQUENCE
6495 {
6496 $$ = mm_strdup("sequence");
6497 }
6498 | TABLE
6499 {
6500 $$ = mm_strdup("table");
6501 }
6502 | VIEW
6503 {
6504 $$ = mm_strdup("view");
6505 }
6506 | MATERIALIZED VIEW
6507 {
6508 $$ = mm_strdup("materialized view");
6509 }
6510 ;
6511
6512
6513 security_label_type_name:
6514 DATABASE
6515 {
6516 $$ = mm_strdup("database");
6517 }
6518 | EVENT TRIGGER
6519 {
6520 $$ = mm_strdup("event trigger");
6521 }
6522 | opt_procedural LANGUAGE
6523 {
6524 $$ = cat_str(2,$1,mm_strdup("language"));
6525 }
6526 | PUBLICATION
6527 {
6528 $$ = mm_strdup("publication");
6529 }
6530 | ROLE
6531 {
6532 $$ = mm_strdup("role");
6533 }
6534 | SCHEMA
6535 {
6536 $$ = mm_strdup("schema");
6537 }
6538 | SUBSCRIPTION
6539 {
6540 $$ = mm_strdup("subscription");
6541 }
6542 | TABLESPACE
6543 {
6544 $$ = mm_strdup("tablespace");
6545 }
6546 ;
6547
6548
6549 security_label:
6550 ecpg_sconst
6551 {
6552 $$ = $1;
6553 }
6554 | NULL_P
6555 {
6556 $$ = mm_strdup("null");
6557 }
6558 ;
6559
6560
6561 FetchStmt:
6562 FETCH fetch_args
6563 {
6564 $$ = cat_str(2,mm_strdup("fetch"),$2);
6565 }
6566 | MOVE fetch_args
6567 {
6568 $$ = cat_str(2,mm_strdup("move"),$2);
6569 }
6570 | FETCH fetch_args ecpg_fetch_into
6571 {
6572 $$ = cat2_str(mm_strdup("fetch"), $2);
6573 }
6574 | FETCH FORWARD cursor_name opt_ecpg_fetch_into
6575 {
6576 char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
6577 add_additional_variables($3, false);
6578 $$ = cat_str(2, mm_strdup("fetch forward"), cursor_marker);
6579 }
6580 | FETCH FORWARD from_in cursor_name opt_ecpg_fetch_into
6581 {
6582 char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
6583 add_additional_variables($4, false);
6584 $$ = cat_str(2, mm_strdup("fetch forward from"), cursor_marker);
6585 }
6586 | FETCH BACKWARD cursor_name opt_ecpg_fetch_into
6587 {
6588 char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
6589 add_additional_variables($3, false);
6590 $$ = cat_str(2, mm_strdup("fetch backward"), cursor_marker);
6591 }
6592 | FETCH BACKWARD from_in cursor_name opt_ecpg_fetch_into
6593 {
6594 char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
6595 add_additional_variables($4, false);
6596 $$ = cat_str(2, mm_strdup("fetch backward from"), cursor_marker);
6597 }
6598 | MOVE FORWARD cursor_name
6599 {
6600 char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
6601 add_additional_variables($3, false);
6602 $$ = cat_str(2, mm_strdup("move forward"), cursor_marker);
6603 }
6604 | MOVE FORWARD from_in cursor_name
6605 {
6606 char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
6607 add_additional_variables($4, false);
6608 $$ = cat_str(2, mm_strdup("move forward from"), cursor_marker);
6609 }
6610 | MOVE BACKWARD cursor_name
6611 {
6612 char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
6613 add_additional_variables($3, false);
6614 $$ = cat_str(2, mm_strdup("move backward"), cursor_marker);
6615 }
6616 | MOVE BACKWARD from_in cursor_name
6617 {
6618 char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
6619 add_additional_variables($4, false);
6620 $$ = cat_str(2, mm_strdup("move backward from"), cursor_marker);
6621 }
6622 ;
6623
6624
6625 fetch_args:
6626 cursor_name
6627 {
6628 add_additional_variables($1, false);
6629 if ($1[0] == ':')
6630 {
6631 free($1);
6632 $1 = mm_strdup("$0");
6633 }
6634
6635 $$ = $1;
6636 }
6637 | from_in cursor_name
6638 {
6639 add_additional_variables($2, false);
6640 if ($2[0] == ':')
6641 {
6642 free($2);
6643 $2 = mm_strdup("$0");
6644 }
6645
6646 $$ = cat_str(2,$1,$2);
6647 }
6648 | NEXT opt_from_in cursor_name
6649 {
6650 add_additional_variables($3, false);
6651 if ($3[0] == ':')
6652 {
6653 free($3);
6654 $3 = mm_strdup("$0");
6655 }
6656
6657 $$ = cat_str(3,mm_strdup("next"),$2,$3);
6658 }
6659 | PRIOR opt_from_in cursor_name
6660 {
6661 add_additional_variables($3, false);
6662 if ($3[0] == ':')
6663 {
6664 free($3);
6665 $3 = mm_strdup("$0");
6666 }
6667
6668 $$ = cat_str(3,mm_strdup("prior"),$2,$3);
6669 }
6670 | FIRST_P opt_from_in cursor_name
6671 {
6672 add_additional_variables($3, false);
6673 if ($3[0] == ':')
6674 {
6675 free($3);
6676 $3 = mm_strdup("$0");
6677 }
6678
6679 $$ = cat_str(3,mm_strdup("first"),$2,$3);
6680 }
6681 | LAST_P opt_from_in cursor_name
6682 {
6683 add_additional_variables($3, false);
6684 if ($3[0] == ':')
6685 {
6686 free($3);
6687 $3 = mm_strdup("$0");
6688 }
6689
6690 $$ = cat_str(3,mm_strdup("last"),$2,$3);
6691 }
6692 | ABSOLUTE_P SignedIconst opt_from_in cursor_name
6693 {
6694 add_additional_variables($4, false);
6695 if ($4[0] == ':')
6696 {
6697 free($4);
6698 $4 = mm_strdup("$0");
6699 }
6700 if ($2[0] == '$')
6701 {
6702 free($2);
6703 $2 = mm_strdup("$0");
6704 }
6705
6706 $$ = cat_str(4,mm_strdup("absolute"),$2,$3,$4);
6707 }
6708 | RELATIVE_P SignedIconst opt_from_in cursor_name
6709 {
6710 add_additional_variables($4, false);
6711 if ($4[0] == ':')
6712 {
6713 free($4);
6714 $4 = mm_strdup("$0");
6715 }
6716 if ($2[0] == '$')
6717 {
6718 free($2);
6719 $2 = mm_strdup("$0");
6720 }
6721
6722 $$ = cat_str(4,mm_strdup("relative"),$2,$3,$4);
6723 }
6724 | SignedIconst opt_from_in cursor_name
6725 {
6726 add_additional_variables($3, false);
6727 if ($3[0] == ':')
6728 {
6729 free($3);
6730 $3 = mm_strdup("$0");
6731 }
6732 if ($1[0] == '$')
6733 {
6734 free($1);
6735 $1 = mm_strdup("$0");
6736 }
6737
6738 $$ = cat_str(3,$1,$2,$3);
6739 }
6740 | ALL opt_from_in cursor_name
6741 {
6742 add_additional_variables($3, false);
6743 if ($3[0] == ':')
6744 {
6745 free($3);
6746 $3 = mm_strdup("$0");
6747 }
6748
6749 $$ = cat_str(3,mm_strdup("all"),$2,$3);
6750 }
6751 | FORWARD SignedIconst opt_from_in cursor_name
6752 {
6753 add_additional_variables($4, false);
6754 if ($4[0] == ':')
6755 {
6756 free($4);
6757 $4 = mm_strdup("$0");
6758 }
6759 if ($2[0] == '$')
6760 {
6761 free($2);
6762 $2 = mm_strdup("$0");
6763 }
6764
6765 $$ = cat_str(4,mm_strdup("forward"),$2,$3,$4);
6766 }
6767 | FORWARD ALL opt_from_in cursor_name
6768 {
6769 add_additional_variables($4, false);
6770 if ($4[0] == ':')
6771 {
6772 free($4);
6773 $4 = mm_strdup("$0");
6774 }
6775
6776 $$ = cat_str(3,mm_strdup("forward all"),$3,$4);
6777 }
6778 | BACKWARD SignedIconst opt_from_in cursor_name
6779 {
6780 add_additional_variables($4, false);
6781 if ($4[0] == ':')
6782 {
6783 free($4);
6784 $4 = mm_strdup("$0");
6785 }
6786 if ($2[0] == '$')
6787 {
6788 free($2);
6789 $2 = mm_strdup("$0");
6790 }
6791
6792 $$ = cat_str(4,mm_strdup("backward"),$2,$3,$4);
6793 }
6794 | BACKWARD ALL opt_from_in cursor_name
6795 {
6796 add_additional_variables($4, false);
6797 if ($4[0] == ':')
6798 {
6799 free($4);
6800 $4 = mm_strdup("$0");
6801 }
6802
6803 $$ = cat_str(3,mm_strdup("backward all"),$3,$4);
6804 }
6805 ;
6806
6807
6808 from_in:
6809 FROM
6810 {
6811 $$ = mm_strdup("from");
6812 }
6813 | IN_P
6814 {
6815 $$ = mm_strdup("in");
6816 }
6817 ;
6818
6819
6820 opt_from_in:
6821 from_in
6822 {
6823 $$ = $1;
6824 }
6825 |
6826 {
6827 $$=EMPTY; }
6828 ;
6829
6830
6831 GrantStmt:
6832 GRANT privileges ON privilege_target TO grantee_list opt_grant_grant_option
6833 {
6834 $$ = cat_str(7,mm_strdup("grant"),$2,mm_strdup("on"),$4,mm_strdup("to"),$6,$7);
6835 }
6836 ;
6837
6838
6839 RevokeStmt:
6840 REVOKE privileges ON privilege_target FROM grantee_list opt_drop_behavior
6841 {
6842 $$ = cat_str(7,mm_strdup("revoke"),$2,mm_strdup("on"),$4,mm_strdup("from"),$6,$7);
6843 }
6844 | REVOKE GRANT OPTION FOR privileges ON privilege_target FROM grantee_list opt_drop_behavior
6845 {
6846 $$ = cat_str(7,mm_strdup("revoke grant option for"),$5,mm_strdup("on"),$7,mm_strdup("from"),$9,$10);
6847 }
6848 ;
6849
6850
6851 privileges:
6852 privilege_list
6853 {
6854 $$ = $1;
6855 }
6856 | ALL
6857 {
6858 $$ = mm_strdup("all");
6859 }
6860 | ALL PRIVILEGES
6861 {
6862 $$ = mm_strdup("all privileges");
6863 }
6864 | ALL '(' columnList ')'
6865 {
6866 $$ = cat_str(3,mm_strdup("all ("),$3,mm_strdup(")"));
6867 }
6868 | ALL PRIVILEGES '(' columnList ')'
6869 {
6870 $$ = cat_str(3,mm_strdup("all privileges ("),$4,mm_strdup(")"));
6871 }
6872 ;
6873
6874
6875 privilege_list:
6876 privilege
6877 {
6878 $$ = $1;
6879 }
6880 | privilege_list ',' privilege
6881 {
6882 $$ = cat_str(3,$1,mm_strdup(","),$3);
6883 }
6884 ;
6885
6886
6887 privilege:
6888 SELECT opt_column_list
6889 {
6890 $$ = cat_str(2,mm_strdup("select"),$2);
6891 }
6892 | REFERENCES opt_column_list
6893 {
6894 $$ = cat_str(2,mm_strdup("references"),$2);
6895 }
6896 | CREATE opt_column_list
6897 {
6898 $$ = cat_str(2,mm_strdup("create"),$2);
6899 }
6900 | ColId opt_column_list
6901 {
6902 $$ = cat_str(2,$1,$2);
6903 }
6904 ;
6905
6906
6907 privilege_target:
6908 qualified_name_list
6909 {
6910 $$ = $1;
6911 }
6912 | TABLE qualified_name_list
6913 {
6914 $$ = cat_str(2,mm_strdup("table"),$2);
6915 }
6916 | SEQUENCE qualified_name_list
6917 {
6918 $$ = cat_str(2,mm_strdup("sequence"),$2);
6919 }
6920 | FOREIGN DATA_P WRAPPER name_list
6921 {
6922 $$ = cat_str(2,mm_strdup("foreign data wrapper"),$4);
6923 }
6924 | FOREIGN SERVER name_list
6925 {
6926 $$ = cat_str(2,mm_strdup("foreign server"),$3);
6927 }
6928 | FUNCTION function_with_argtypes_list
6929 {
6930 $$ = cat_str(2,mm_strdup("function"),$2);
6931 }
6932 | PROCEDURE function_with_argtypes_list
6933 {
6934 $$ = cat_str(2,mm_strdup("procedure"),$2);
6935 }
6936 | ROUTINE function_with_argtypes_list
6937 {
6938 $$ = cat_str(2,mm_strdup("routine"),$2);
6939 }
6940 | DATABASE name_list
6941 {
6942 $$ = cat_str(2,mm_strdup("database"),$2);
6943 }
6944 | DOMAIN_P any_name_list
6945 {
6946 $$ = cat_str(2,mm_strdup("domain"),$2);
6947 }
6948 | LANGUAGE name_list
6949 {
6950 $$ = cat_str(2,mm_strdup("language"),$2);
6951 }
6952 | LARGE_P OBJECT_P NumericOnly_list
6953 {
6954 $$ = cat_str(2,mm_strdup("large object"),$3);
6955 }
6956 | SCHEMA name_list
6957 {
6958 $$ = cat_str(2,mm_strdup("schema"),$2);
6959 }
6960 | TABLESPACE name_list
6961 {
6962 $$ = cat_str(2,mm_strdup("tablespace"),$2);
6963 }
6964 | TYPE_P any_name_list
6965 {
6966 $$ = cat_str(2,mm_strdup("type"),$2);
6967 }
6968 | ALL TABLES IN_P SCHEMA name_list
6969 {
6970 $$ = cat_str(2,mm_strdup("all tables in schema"),$5);
6971 }
6972 | ALL SEQUENCES IN_P SCHEMA name_list
6973 {
6974 $$ = cat_str(2,mm_strdup("all sequences in schema"),$5);
6975 }
6976 | ALL FUNCTIONS IN_P SCHEMA name_list
6977 {
6978 $$ = cat_str(2,mm_strdup("all functions in schema"),$5);
6979 }
6980 | ALL PROCEDURES IN_P SCHEMA name_list
6981 {
6982 $$ = cat_str(2,mm_strdup("all procedures in schema"),$5);
6983 }
6984 | ALL ROUTINES IN_P SCHEMA name_list
6985 {
6986 $$ = cat_str(2,mm_strdup("all routines in schema"),$5);
6987 }
6988 ;
6989
6990
6991 grantee_list:
6992 grantee
6993 {
6994 $$ = $1;
6995 }
6996 | grantee_list ',' grantee
6997 {
6998 $$ = cat_str(3,$1,mm_strdup(","),$3);
6999 }
7000 ;
7001
7002
7003 grantee:
7004 RoleSpec
7005 {
7006 $$ = $1;
7007 }
7008 | GROUP_P RoleSpec
7009 {
7010 $$ = cat_str(2,mm_strdup("group"),$2);
7011 }
7012 ;
7013
7014
7015 opt_grant_grant_option:
7016 WITH GRANT OPTION
7017 {
7018 $$ = mm_strdup("with grant option");
7019 }
7020 |
7021 {
7022 $$=EMPTY; }
7023 ;
7024
7025
7026 GrantRoleStmt:
7027 GRANT privilege_list TO role_list opt_grant_admin_option opt_granted_by
7028 {
7029 $$ = cat_str(6,mm_strdup("grant"),$2,mm_strdup("to"),$4,$5,$6);
7030 }
7031 ;
7032
7033
7034 RevokeRoleStmt:
7035 REVOKE privilege_list FROM role_list opt_granted_by opt_drop_behavior
7036 {
7037 $$ = cat_str(6,mm_strdup("revoke"),$2,mm_strdup("from"),$4,$5,$6);
7038 }
7039 | REVOKE ADMIN OPTION FOR privilege_list FROM role_list opt_granted_by opt_drop_behavior
7040 {
7041 $$ = cat_str(6,mm_strdup("revoke admin option for"),$5,mm_strdup("from"),$7,$8,$9);
7042 }
7043 ;
7044
7045
7046 opt_grant_admin_option:
7047 WITH ADMIN OPTION
7048 {
7049 $$ = mm_strdup("with admin option");
7050 }
7051 |
7052 {
7053 $$=EMPTY; }
7054 ;
7055
7056
7057 opt_granted_by:
7058 GRANTED BY RoleSpec
7059 {
7060 $$ = cat_str(2,mm_strdup("granted by"),$3);
7061 }
7062 |
7063 {
7064 $$=EMPTY; }
7065 ;
7066
7067
7068 AlterDefaultPrivilegesStmt:
7069 ALTER DEFAULT PRIVILEGES DefACLOptionList DefACLAction
7070 {
7071 $$ = cat_str(3,mm_strdup("alter default privileges"),$4,$5);
7072 }
7073 ;
7074
7075
7076 DefACLOptionList:
7077 DefACLOptionList DefACLOption
7078 {
7079 $$ = cat_str(2,$1,$2);
7080 }
7081 |
7082 {
7083 $$=EMPTY; }
7084 ;
7085
7086
7087 DefACLOption:
7088 IN_P SCHEMA name_list
7089 {
7090 $$ = cat_str(2,mm_strdup("in schema"),$3);
7091 }
7092 | FOR ROLE role_list
7093 {
7094 $$ = cat_str(2,mm_strdup("for role"),$3);
7095 }
7096 | FOR USER role_list
7097 {
7098 $$ = cat_str(2,mm_strdup("for user"),$3);
7099 }
7100 ;
7101
7102
7103 DefACLAction:
7104 GRANT privileges ON defacl_privilege_target TO grantee_list opt_grant_grant_option
7105 {
7106 $$ = cat_str(7,mm_strdup("grant"),$2,mm_strdup("on"),$4,mm_strdup("to"),$6,$7);
7107 }
7108 | REVOKE privileges ON defacl_privilege_target FROM grantee_list opt_drop_behavior
7109 {
7110 $$ = cat_str(7,mm_strdup("revoke"),$2,mm_strdup("on"),$4,mm_strdup("from"),$6,$7);
7111 }
7112 | REVOKE GRANT OPTION FOR privileges ON defacl_privilege_target FROM grantee_list opt_drop_behavior
7113 {
7114 $$ = cat_str(7,mm_strdup("revoke grant option for"),$5,mm_strdup("on"),$7,mm_strdup("from"),$9,$10);
7115 }
7116 ;
7117
7118
7119 defacl_privilege_target:
7120 TABLES
7121 {
7122 $$ = mm_strdup("tables");
7123 }
7124 | FUNCTIONS
7125 {
7126 $$ = mm_strdup("functions");
7127 }
7128 | ROUTINES
7129 {
7130 $$ = mm_strdup("routines");
7131 }
7132 | SEQUENCES
7133 {
7134 $$ = mm_strdup("sequences");
7135 }
7136 | TYPES_P
7137 {
7138 $$ = mm_strdup("types");
7139 }
7140 | SCHEMAS
7141 {
7142 $$ = mm_strdup("schemas");
7143 }
7144 ;
7145
7146
7147 IndexStmt:
7148 CREATE opt_unique INDEX opt_concurrently opt_index_name ON relation_expr access_method_clause '(' index_params ')' opt_include opt_reloptions OptTableSpace where_clause
7149 {
7150 $$ = cat_str(15,mm_strdup("create"),$2,mm_strdup("index"),$4,$5,mm_strdup("on"),$7,$8,mm_strdup("("),$10,mm_strdup(")"),$12,$13,$14,$15);
7151 }
7152 | CREATE opt_unique INDEX opt_concurrently IF_P NOT EXISTS index_name ON relation_expr access_method_clause '(' index_params ')' opt_include opt_reloptions OptTableSpace where_clause
7153 {
7154 $$ = cat_str(16,mm_strdup("create"),$2,mm_strdup("index"),$4,mm_strdup("if not exists"),$8,mm_strdup("on"),$10,$11,mm_strdup("("),$13,mm_strdup(")"),$15,$16,$17,$18);
7155 }
7156 ;
7157
7158
7159 opt_unique:
7160 UNIQUE
7161 {
7162 $$ = mm_strdup("unique");
7163 }
7164 |
7165 {
7166 $$=EMPTY; }
7167 ;
7168
7169
7170 opt_concurrently:
7171 CONCURRENTLY
7172 {
7173 $$ = mm_strdup("concurrently");
7174 }
7175 |
7176 {
7177 $$=EMPTY; }
7178 ;
7179
7180
7181 opt_index_name:
7182 index_name
7183 {
7184 $$ = $1;
7185 }
7186 |
7187 {
7188 $$=EMPTY; }
7189 ;
7190
7191
7192 access_method_clause:
7193 USING access_method
7194 {
7195 $$ = cat_str(2,mm_strdup("using"),$2);
7196 }
7197 |
7198 {
7199 $$=EMPTY; }
7200 ;
7201
7202
7203 index_params:
7204 index_elem
7205 {
7206 $$ = $1;
7207 }
7208 | index_params ',' index_elem
7209 {
7210 $$ = cat_str(3,$1,mm_strdup(","),$3);
7211 }
7212 ;
7213
7214
7215 index_elem:
7216 ColId opt_collate opt_class opt_asc_desc opt_nulls_order
7217 {
7218 $$ = cat_str(5,$1,$2,$3,$4,$5);
7219 }
7220 | func_expr_windowless opt_collate opt_class opt_asc_desc opt_nulls_order
7221 {
7222 $$ = cat_str(5,$1,$2,$3,$4,$5);
7223 }
7224 | '(' a_expr ')' opt_collate opt_class opt_asc_desc opt_nulls_order
7225 {
7226 $$ = cat_str(7,mm_strdup("("),$2,mm_strdup(")"),$4,$5,$6,$7);
7227 }
7228 ;
7229
7230
7231 opt_include:
7232 INCLUDE '(' index_including_params ')'
7233 {
7234 $$ = cat_str(3,mm_strdup("include ("),$3,mm_strdup(")"));
7235 }
7236 |
7237 {
7238 $$=EMPTY; }
7239 ;
7240
7241
7242 index_including_params:
7243 index_elem
7244 {
7245 $$ = $1;
7246 }
7247 | index_including_params ',' index_elem
7248 {
7249 $$ = cat_str(3,$1,mm_strdup(","),$3);
7250 }
7251 ;
7252
7253
7254 opt_collate:
7255 COLLATE any_name
7256 {
7257 $$ = cat_str(2,mm_strdup("collate"),$2);
7258 }
7259 |
7260 {
7261 $$=EMPTY; }
7262 ;
7263
7264
7265 opt_class:
7266 any_name
7267 {
7268 $$ = $1;
7269 }
7270 |
7271 {
7272 $$=EMPTY; }
7273 ;
7274
7275
7276 opt_asc_desc:
7277 ASC
7278 {
7279 $$ = mm_strdup("asc");
7280 }
7281 | DESC
7282 {
7283 $$ = mm_strdup("desc");
7284 }
7285 |
7286 {
7287 $$=EMPTY; }
7288 ;
7289
7290
7291 opt_nulls_order:
7292 NULLS_LA FIRST_P
7293 {
7294 $$ = mm_strdup("nulls first");
7295 }
7296 | NULLS_LA LAST_P
7297 {
7298 $$ = mm_strdup("nulls last");
7299 }
7300 |
7301 {
7302 $$=EMPTY; }
7303 ;
7304
7305
7306 CreateFunctionStmt:
7307 CREATE opt_or_replace FUNCTION func_name func_args_with_defaults RETURNS func_return createfunc_opt_list
7308 {
7309 $$ = cat_str(8,mm_strdup("create"),$2,mm_strdup("function"),$4,$5,mm_strdup("returns"),$7,$8);
7310 }
7311 | CREATE opt_or_replace FUNCTION func_name func_args_with_defaults RETURNS TABLE '(' table_func_column_list ')' createfunc_opt_list
7312 {
7313 $$ = cat_str(9,mm_strdup("create"),$2,mm_strdup("function"),$4,$5,mm_strdup("returns table ("),$9,mm_strdup(")"),$11);
7314 }
7315 | CREATE opt_or_replace FUNCTION func_name func_args_with_defaults createfunc_opt_list
7316 {
7317 $$ = cat_str(6,mm_strdup("create"),$2,mm_strdup("function"),$4,$5,$6);
7318 }
7319 | CREATE opt_or_replace PROCEDURE func_name func_args_with_defaults createfunc_opt_list
7320 {
7321 $$ = cat_str(6,mm_strdup("create"),$2,mm_strdup("procedure"),$4,$5,$6);
7322 }
7323 ;
7324
7325
7326 opt_or_replace:
7327 OR REPLACE
7328 {
7329 $$ = mm_strdup("or replace");
7330 }
7331 |
7332 {
7333 $$=EMPTY; }
7334 ;
7335
7336
7337 func_args:
7338 '(' func_args_list ')'
7339 {
7340 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
7341 }
7342 | '(' ')'
7343 {
7344 $$ = mm_strdup("( )");
7345 }
7346 ;
7347
7348
7349 func_args_list:
7350 func_arg
7351 {
7352 $$ = $1;
7353 }
7354 | func_args_list ',' func_arg
7355 {
7356 $$ = cat_str(3,$1,mm_strdup(","),$3);
7357 }
7358 ;
7359
7360
7361 function_with_argtypes_list:
7362 function_with_argtypes
7363 {
7364 $$ = $1;
7365 }
7366 | function_with_argtypes_list ',' function_with_argtypes
7367 {
7368 $$ = cat_str(3,$1,mm_strdup(","),$3);
7369 }
7370 ;
7371
7372
7373 function_with_argtypes:
7374 func_name func_args
7375 {
7376 $$ = cat_str(2,$1,$2);
7377 }
7378 | type_func_name_keyword
7379 {
7380 $$ = $1;
7381 }
7382 | ColId
7383 {
7384 $$ = $1;
7385 }
7386 | ColId indirection
7387 {
7388 $$ = cat_str(2,$1,$2);
7389 }
7390 ;
7391
7392
7393 func_args_with_defaults:
7394 '(' func_args_with_defaults_list ')'
7395 {
7396 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
7397 }
7398 | '(' ')'
7399 {
7400 $$ = mm_strdup("( )");
7401 }
7402 ;
7403
7404
7405 func_args_with_defaults_list:
7406 func_arg_with_default
7407 {
7408 $$ = $1;
7409 }
7410 | func_args_with_defaults_list ',' func_arg_with_default
7411 {
7412 $$ = cat_str(3,$1,mm_strdup(","),$3);
7413 }
7414 ;
7415
7416
7417 func_arg:
7418 arg_class param_name func_type
7419 {
7420 $$ = cat_str(3,$1,$2,$3);
7421 }
7422 | param_name arg_class func_type
7423 {
7424 $$ = cat_str(3,$1,$2,$3);
7425 }
7426 | param_name func_type
7427 {
7428 $$ = cat_str(2,$1,$2);
7429 }
7430 | arg_class func_type
7431 {
7432 $$ = cat_str(2,$1,$2);
7433 }
7434 | func_type
7435 {
7436 $$ = $1;
7437 }
7438 ;
7439
7440
7441 arg_class:
7442 IN_P
7443 {
7444 $$ = mm_strdup("in");
7445 }
7446 | OUT_P
7447 {
7448 $$ = mm_strdup("out");
7449 }
7450 | INOUT
7451 {
7452 $$ = mm_strdup("inout");
7453 }
7454 | IN_P OUT_P
7455 {
7456 $$ = mm_strdup("in out");
7457 }
7458 | VARIADIC
7459 {
7460 $$ = mm_strdup("variadic");
7461 }
7462 ;
7463
7464
7465 param_name:
7466 type_function_name
7467 {
7468 $$ = $1;
7469 }
7470 ;
7471
7472
7473 func_return:
7474 func_type
7475 {
7476 $$ = $1;
7477 }
7478 ;
7479
7480
7481 func_type:
7482 Typename
7483 {
7484 $$ = $1;
7485 }
7486 | type_function_name attrs '%' TYPE_P
7487 {
7488 $$ = cat_str(3,$1,$2,mm_strdup("% type"));
7489 }
7490 | SETOF type_function_name attrs '%' TYPE_P
7491 {
7492 $$ = cat_str(4,mm_strdup("setof"),$2,$3,mm_strdup("% type"));
7493 }
7494 ;
7495
7496
7497 func_arg_with_default:
7498 func_arg
7499 {
7500 $$ = $1;
7501 }
7502 | func_arg DEFAULT a_expr
7503 {
7504 $$ = cat_str(3,$1,mm_strdup("default"),$3);
7505 }
7506 | func_arg '=' a_expr
7507 {
7508 $$ = cat_str(3,$1,mm_strdup("="),$3);
7509 }
7510 ;
7511
7512
7513 aggr_arg:
7514 func_arg
7515 {
7516 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
7517 $$ = $1;
7518 }
7519 ;
7520
7521
7522 aggr_args:
7523 '(' '*' ')'
7524 {
7525 $$ = mm_strdup("( * )");
7526 }
7527 | '(' aggr_args_list ')'
7528 {
7529 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
7530 }
7531 | '(' ORDER BY aggr_args_list ')'
7532 {
7533 $$ = cat_str(3,mm_strdup("( order by"),$4,mm_strdup(")"));
7534 }
7535 | '(' aggr_args_list ORDER BY aggr_args_list ')'
7536 {
7537 $$ = cat_str(5,mm_strdup("("),$2,mm_strdup("order by"),$5,mm_strdup(")"));
7538 }
7539 ;
7540
7541
7542 aggr_args_list:
7543 aggr_arg
7544 {
7545 $$ = $1;
7546 }
7547 | aggr_args_list ',' aggr_arg
7548 {
7549 $$ = cat_str(3,$1,mm_strdup(","),$3);
7550 }
7551 ;
7552
7553
7554 aggregate_with_argtypes:
7555 func_name aggr_args
7556 {
7557 $$ = cat_str(2,$1,$2);
7558 }
7559 ;
7560
7561
7562 aggregate_with_argtypes_list:
7563 aggregate_with_argtypes
7564 {
7565 $$ = $1;
7566 }
7567 | aggregate_with_argtypes_list ',' aggregate_with_argtypes
7568 {
7569 $$ = cat_str(3,$1,mm_strdup(","),$3);
7570 }
7571 ;
7572
7573
7574 createfunc_opt_list:
7575 createfunc_opt_item
7576 {
7577 $$ = $1;
7578 }
7579 | createfunc_opt_list createfunc_opt_item
7580 {
7581 $$ = cat_str(2,$1,$2);
7582 }
7583 ;
7584
7585
7586 common_func_opt_item:
7587 CALLED ON NULL_P INPUT_P
7588 {
7589 $$ = mm_strdup("called on null input");
7590 }
7591 | RETURNS NULL_P ON NULL_P INPUT_P
7592 {
7593 $$ = mm_strdup("returns null on null input");
7594 }
7595 | STRICT_P
7596 {
7597 $$ = mm_strdup("strict");
7598 }
7599 | IMMUTABLE
7600 {
7601 $$ = mm_strdup("immutable");
7602 }
7603 | STABLE
7604 {
7605 $$ = mm_strdup("stable");
7606 }
7607 | VOLATILE
7608 {
7609 $$ = mm_strdup("volatile");
7610 }
7611 | EXTERNAL SECURITY DEFINER
7612 {
7613 $$ = mm_strdup("external security definer");
7614 }
7615 | EXTERNAL SECURITY INVOKER
7616 {
7617 $$ = mm_strdup("external security invoker");
7618 }
7619 | SECURITY DEFINER
7620 {
7621 $$ = mm_strdup("security definer");
7622 }
7623 | SECURITY INVOKER
7624 {
7625 $$ = mm_strdup("security invoker");
7626 }
7627 | LEAKPROOF
7628 {
7629 $$ = mm_strdup("leakproof");
7630 }
7631 | NOT LEAKPROOF
7632 {
7633 $$ = mm_strdup("not leakproof");
7634 }
7635 | COST NumericOnly
7636 {
7637 $$ = cat_str(2,mm_strdup("cost"),$2);
7638 }
7639 | ROWS NumericOnly
7640 {
7641 $$ = cat_str(2,mm_strdup("rows"),$2);
7642 }
7643 | SUPPORT any_name
7644 {
7645 $$ = cat_str(2,mm_strdup("support"),$2);
7646 }
7647 | FunctionSetResetClause
7648 {
7649 $$ = $1;
7650 }
7651 | PARALLEL ColId
7652 {
7653 $$ = cat_str(2,mm_strdup("parallel"),$2);
7654 }
7655 ;
7656
7657
7658 createfunc_opt_item:
7659 AS func_as
7660 {
7661 $$ = cat_str(2,mm_strdup("as"),$2);
7662 }
7663 | LANGUAGE NonReservedWord_or_Sconst
7664 {
7665 $$ = cat_str(2,mm_strdup("language"),$2);
7666 }
7667 | TRANSFORM transform_type_list
7668 {
7669 $$ = cat_str(2,mm_strdup("transform"),$2);
7670 }
7671 | WINDOW
7672 {
7673 $$ = mm_strdup("window");
7674 }
7675 | common_func_opt_item
7676 {
7677 $$ = $1;
7678 }
7679 ;
7680
7681
7682 func_as:
7683 ecpg_sconst
7684 {
7685 $$ = $1;
7686 }
7687 | ecpg_sconst ',' ecpg_sconst
7688 {
7689 $$ = cat_str(3,$1,mm_strdup(","),$3);
7690 }
7691 ;
7692
7693
7694 transform_type_list:
7695 FOR TYPE_P Typename
7696 {
7697 $$ = cat_str(2,mm_strdup("for type"),$3);
7698 }
7699 | transform_type_list ',' FOR TYPE_P Typename
7700 {
7701 $$ = cat_str(3,$1,mm_strdup(", for type"),$5);
7702 }
7703 ;
7704
7705
7706 opt_definition:
7707 WITH definition
7708 {
7709 $$ = cat_str(2,mm_strdup("with"),$2);
7710 }
7711 |
7712 {
7713 $$=EMPTY; }
7714 ;
7715
7716
7717 table_func_column:
7718 param_name func_type
7719 {
7720 $$ = cat_str(2,$1,$2);
7721 }
7722 ;
7723
7724
7725 table_func_column_list:
7726 table_func_column
7727 {
7728 $$ = $1;
7729 }
7730 | table_func_column_list ',' table_func_column
7731 {
7732 $$ = cat_str(3,$1,mm_strdup(","),$3);
7733 }
7734 ;
7735
7736
7737 AlterFunctionStmt:
7738 ALTER FUNCTION function_with_argtypes alterfunc_opt_list opt_restrict
7739 {
7740 $$ = cat_str(4,mm_strdup("alter function"),$3,$4,$5);
7741 }
7742 | ALTER PROCEDURE function_with_argtypes alterfunc_opt_list opt_restrict
7743 {
7744 $$ = cat_str(4,mm_strdup("alter procedure"),$3,$4,$5);
7745 }
7746 | ALTER ROUTINE function_with_argtypes alterfunc_opt_list opt_restrict
7747 {
7748 $$ = cat_str(4,mm_strdup("alter routine"),$3,$4,$5);
7749 }
7750 ;
7751
7752
7753 alterfunc_opt_list:
7754 common_func_opt_item
7755 {
7756 $$ = $1;
7757 }
7758 | alterfunc_opt_list common_func_opt_item
7759 {
7760 $$ = cat_str(2,$1,$2);
7761 }
7762 ;
7763
7764
7765 opt_restrict:
7766 RESTRICT
7767 {
7768 $$ = mm_strdup("restrict");
7769 }
7770 |
7771 {
7772 $$=EMPTY; }
7773 ;
7774
7775
7776 RemoveFuncStmt:
7777 DROP FUNCTION function_with_argtypes_list opt_drop_behavior
7778 {
7779 $$ = cat_str(3,mm_strdup("drop function"),$3,$4);
7780 }
7781 | DROP FUNCTION IF_P EXISTS function_with_argtypes_list opt_drop_behavior
7782 {
7783 $$ = cat_str(3,mm_strdup("drop function if exists"),$5,$6);
7784 }
7785 | DROP PROCEDURE function_with_argtypes_list opt_drop_behavior
7786 {
7787 $$ = cat_str(3,mm_strdup("drop procedure"),$3,$4);
7788 }
7789 | DROP PROCEDURE IF_P EXISTS function_with_argtypes_list opt_drop_behavior
7790 {
7791 $$ = cat_str(3,mm_strdup("drop procedure if exists"),$5,$6);
7792 }
7793 | DROP ROUTINE function_with_argtypes_list opt_drop_behavior
7794 {
7795 $$ = cat_str(3,mm_strdup("drop routine"),$3,$4);
7796 }
7797 | DROP ROUTINE IF_P EXISTS function_with_argtypes_list opt_drop_behavior
7798 {
7799 $$ = cat_str(3,mm_strdup("drop routine if exists"),$5,$6);
7800 }
7801 ;
7802
7803
7804 RemoveAggrStmt:
7805 DROP AGGREGATE aggregate_with_argtypes_list opt_drop_behavior
7806 {
7807 $$ = cat_str(3,mm_strdup("drop aggregate"),$3,$4);
7808 }
7809 | DROP AGGREGATE IF_P EXISTS aggregate_with_argtypes_list opt_drop_behavior
7810 {
7811 $$ = cat_str(3,mm_strdup("drop aggregate if exists"),$5,$6);
7812 }
7813 ;
7814
7815
7816 RemoveOperStmt:
7817 DROP OPERATOR operator_with_argtypes_list opt_drop_behavior
7818 {
7819 $$ = cat_str(3,mm_strdup("drop operator"),$3,$4);
7820 }
7821 | DROP OPERATOR IF_P EXISTS operator_with_argtypes_list opt_drop_behavior
7822 {
7823 $$ = cat_str(3,mm_strdup("drop operator if exists"),$5,$6);
7824 }
7825 ;
7826
7827
7828 oper_argtypes:
7829 '(' Typename ')'
7830 {
7831 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
7832 }
7833 | '(' Typename ',' Typename ')'
7834 {
7835 $$ = cat_str(5,mm_strdup("("),$2,mm_strdup(","),$4,mm_strdup(")"));
7836 }
7837 | '(' NONE ',' Typename ')'
7838 {
7839 $$ = cat_str(3,mm_strdup("( none ,"),$4,mm_strdup(")"));
7840 }
7841 | '(' Typename ',' NONE ')'
7842 {
7843 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(", none )"));
7844 }
7845 ;
7846
7847
7848 any_operator:
7849 all_Op
7850 {
7851 $$ = $1;
7852 }
7853 | ColId '.' any_operator
7854 {
7855 $$ = cat_str(3,$1,mm_strdup("."),$3);
7856 }
7857 ;
7858
7859
7860 operator_with_argtypes_list:
7861 operator_with_argtypes
7862 {
7863 $$ = $1;
7864 }
7865 | operator_with_argtypes_list ',' operator_with_argtypes
7866 {
7867 $$ = cat_str(3,$1,mm_strdup(","),$3);
7868 }
7869 ;
7870
7871
7872 operator_with_argtypes:
7873 any_operator oper_argtypes
7874 {
7875 $$ = cat_str(2,$1,$2);
7876 }
7877 ;
7878
7879
7880 DoStmt:
7881 DO dostmt_opt_list
7882 {
7883 $$ = cat_str(2,mm_strdup("do"),$2);
7884 }
7885 ;
7886
7887
7888 dostmt_opt_list:
7889 dostmt_opt_item
7890 {
7891 $$ = $1;
7892 }
7893 | dostmt_opt_list dostmt_opt_item
7894 {
7895 $$ = cat_str(2,$1,$2);
7896 }
7897 ;
7898
7899
7900 dostmt_opt_item:
7901 ecpg_sconst
7902 {
7903 $$ = $1;
7904 }
7905 | LANGUAGE NonReservedWord_or_Sconst
7906 {
7907 $$ = cat_str(2,mm_strdup("language"),$2);
7908 }
7909 ;
7910
7911
7912 CreateCastStmt:
7913 CREATE CAST '(' Typename AS Typename ')' WITH FUNCTION function_with_argtypes cast_context
7914 {
7915 $$ = cat_str(7,mm_strdup("create cast ("),$4,mm_strdup("as"),$6,mm_strdup(") with function"),$10,$11);
7916 }
7917 | CREATE CAST '(' Typename AS Typename ')' WITHOUT FUNCTION cast_context
7918 {
7919 $$ = cat_str(6,mm_strdup("create cast ("),$4,mm_strdup("as"),$6,mm_strdup(") without function"),$10);
7920 }
7921 | CREATE CAST '(' Typename AS Typename ')' WITH INOUT cast_context
7922 {
7923 $$ = cat_str(6,mm_strdup("create cast ("),$4,mm_strdup("as"),$6,mm_strdup(") with inout"),$10);
7924 }
7925 ;
7926
7927
7928 cast_context:
7929 AS IMPLICIT_P
7930 {
7931 $$ = mm_strdup("as implicit");
7932 }
7933 | AS ASSIGNMENT
7934 {
7935 $$ = mm_strdup("as assignment");
7936 }
7937 |
7938 {
7939 $$=EMPTY; }
7940 ;
7941
7942
7943 DropCastStmt:
7944 DROP CAST opt_if_exists '(' Typename AS Typename ')' opt_drop_behavior
7945 {
7946 $$ = cat_str(8,mm_strdup("drop cast"),$3,mm_strdup("("),$5,mm_strdup("as"),$7,mm_strdup(")"),$9);
7947 }
7948 ;
7949
7950
7951 opt_if_exists:
7952 IF_P EXISTS
7953 {
7954 $$ = mm_strdup("if exists");
7955 }
7956 |
7957 {
7958 $$=EMPTY; }
7959 ;
7960
7961
7962 CreateTransformStmt:
7963 CREATE opt_or_replace TRANSFORM FOR Typename LANGUAGE name '(' transform_element_list ')'
7964 {
7965 $$ = cat_str(9,mm_strdup("create"),$2,mm_strdup("transform for"),$5,mm_strdup("language"),$7,mm_strdup("("),$9,mm_strdup(")"));
7966 }
7967 ;
7968
7969
7970 transform_element_list:
7971 FROM SQL_P WITH FUNCTION function_with_argtypes ',' TO SQL_P WITH FUNCTION function_with_argtypes
7972 {
7973 $$ = cat_str(4,mm_strdup("from sql with function"),$5,mm_strdup(", to sql with function"),$11);
7974 }
7975 | TO SQL_P WITH FUNCTION function_with_argtypes ',' FROM SQL_P WITH FUNCTION function_with_argtypes
7976 {
7977 $$ = cat_str(4,mm_strdup("to sql with function"),$5,mm_strdup(", from sql with function"),$11);
7978 }
7979 | FROM SQL_P WITH FUNCTION function_with_argtypes
7980 {
7981 $$ = cat_str(2,mm_strdup("from sql with function"),$5);
7982 }
7983 | TO SQL_P WITH FUNCTION function_with_argtypes
7984 {
7985 $$ = cat_str(2,mm_strdup("to sql with function"),$5);
7986 }
7987 ;
7988
7989
7990 DropTransformStmt:
7991 DROP TRANSFORM opt_if_exists FOR Typename LANGUAGE name opt_drop_behavior
7992 {
7993 $$ = cat_str(7,mm_strdup("drop transform"),$3,mm_strdup("for"),$5,mm_strdup("language"),$7,$8);
7994 }
7995 ;
7996
7997
7998 ReindexStmt:
7999 REINDEX reindex_target_type opt_concurrently qualified_name
8000 {
8001 $$ = cat_str(4,mm_strdup("reindex"),$2,$3,$4);
8002 }
8003 | REINDEX reindex_target_multitable opt_concurrently name
8004 {
8005 $$ = cat_str(4,mm_strdup("reindex"),$2,$3,$4);
8006 }
8007 | REINDEX '(' reindex_option_list ')' reindex_target_type opt_concurrently qualified_name
8008 {
8009 $$ = cat_str(6,mm_strdup("reindex ("),$3,mm_strdup(")"),$5,$6,$7);
8010 }
8011 | REINDEX '(' reindex_option_list ')' reindex_target_multitable opt_concurrently name
8012 {
8013 $$ = cat_str(6,mm_strdup("reindex ("),$3,mm_strdup(")"),$5,$6,$7);
8014 }
8015 ;
8016
8017
8018 reindex_target_type:
8019 INDEX
8020 {
8021 $$ = mm_strdup("index");
8022 }
8023 | TABLE
8024 {
8025 $$ = mm_strdup("table");
8026 }
8027 ;
8028
8029
8030 reindex_target_multitable:
8031 SCHEMA
8032 {
8033 $$ = mm_strdup("schema");
8034 }
8035 | SYSTEM_P
8036 {
8037 $$ = mm_strdup("system");
8038 }
8039 | DATABASE
8040 {
8041 $$ = mm_strdup("database");
8042 }
8043 ;
8044
8045
8046 reindex_option_list:
8047 reindex_option_elem
8048 {
8049 $$ = $1;
8050 }
8051 | reindex_option_list ',' reindex_option_elem
8052 {
8053 $$ = cat_str(3,$1,mm_strdup(","),$3);
8054 }
8055 ;
8056
8057
8058 reindex_option_elem:
8059 VERBOSE
8060 {
8061 $$ = mm_strdup("verbose");
8062 }
8063 ;
8064
8065
8066 AlterTblSpcStmt:
8067 ALTER TABLESPACE name SET reloptions
8068 {
8069 $$ = cat_str(4,mm_strdup("alter tablespace"),$3,mm_strdup("set"),$5);
8070 }
8071 | ALTER TABLESPACE name RESET reloptions
8072 {
8073 $$ = cat_str(4,mm_strdup("alter tablespace"),$3,mm_strdup("reset"),$5);
8074 }
8075 ;
8076
8077
8078 RenameStmt:
8079 ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
8080 {
8081 $$ = cat_str(4,mm_strdup("alter aggregate"),$3,mm_strdup("rename to"),$6);
8082 }
8083 | ALTER COLLATION any_name RENAME TO name
8084 {
8085 $$ = cat_str(4,mm_strdup("alter collation"),$3,mm_strdup("rename to"),$6);
8086 }
8087 | ALTER CONVERSION_P any_name RENAME TO name
8088 {
8089 $$ = cat_str(4,mm_strdup("alter conversion"),$3,mm_strdup("rename to"),$6);
8090 }
8091 | ALTER DATABASE database_name RENAME TO database_name
8092 {
8093 $$ = cat_str(4,mm_strdup("alter database"),$3,mm_strdup("rename to"),$6);
8094 }
8095 | ALTER DOMAIN_P any_name RENAME TO name
8096 {
8097 $$ = cat_str(4,mm_strdup("alter domain"),$3,mm_strdup("rename to"),$6);
8098 }
8099 | ALTER DOMAIN_P any_name RENAME CONSTRAINT name TO name
8100 {
8101 $$ = cat_str(6,mm_strdup("alter domain"),$3,mm_strdup("rename constraint"),$6,mm_strdup("to"),$8);
8102 }
8103 | ALTER FOREIGN DATA_P WRAPPER name RENAME TO name
8104 {
8105 $$ = cat_str(4,mm_strdup("alter foreign data wrapper"),$5,mm_strdup("rename to"),$8);
8106 }
8107 | ALTER FUNCTION function_with_argtypes RENAME TO name
8108 {
8109 $$ = cat_str(4,mm_strdup("alter function"),$3,mm_strdup("rename to"),$6);
8110 }
8111 | ALTER GROUP_P RoleId RENAME TO RoleId
8112 {
8113 $$ = cat_str(4,mm_strdup("alter group"),$3,mm_strdup("rename to"),$6);
8114 }
8115 | ALTER opt_procedural LANGUAGE name RENAME TO name
8116 {
8117 $$ = cat_str(6,mm_strdup("alter"),$2,mm_strdup("language"),$4,mm_strdup("rename to"),$7);
8118 }
8119 | ALTER OPERATOR CLASS any_name USING access_method RENAME TO name
8120 {
8121 $$ = cat_str(6,mm_strdup("alter operator class"),$4,mm_strdup("using"),$6,mm_strdup("rename to"),$9);
8122 }
8123 | ALTER OPERATOR FAMILY any_name USING access_method RENAME TO name
8124 {
8125 $$ = cat_str(6,mm_strdup("alter operator family"),$4,mm_strdup("using"),$6,mm_strdup("rename to"),$9);
8126 }
8127 | ALTER POLICY name ON qualified_name RENAME TO name
8128 {
8129 $$ = cat_str(6,mm_strdup("alter policy"),$3,mm_strdup("on"),$5,mm_strdup("rename to"),$8);
8130 }
8131 | ALTER POLICY IF_P EXISTS name ON qualified_name RENAME TO name
8132 {
8133 $$ = cat_str(6,mm_strdup("alter policy if exists"),$5,mm_strdup("on"),$7,mm_strdup("rename to"),$10);
8134 }
8135 | ALTER PROCEDURE function_with_argtypes RENAME TO name
8136 {
8137 $$ = cat_str(4,mm_strdup("alter procedure"),$3,mm_strdup("rename to"),$6);
8138 }
8139 | ALTER PUBLICATION name RENAME TO name
8140 {
8141 $$ = cat_str(4,mm_strdup("alter publication"),$3,mm_strdup("rename to"),$6);
8142 }
8143 | ALTER ROUTINE function_with_argtypes RENAME TO name
8144 {
8145 $$ = cat_str(4,mm_strdup("alter routine"),$3,mm_strdup("rename to"),$6);
8146 }
8147 | ALTER SCHEMA name RENAME TO name
8148 {
8149 $$ = cat_str(4,mm_strdup("alter schema"),$3,mm_strdup("rename to"),$6);
8150 }
8151 | ALTER SERVER name RENAME TO name
8152 {
8153 $$ = cat_str(4,mm_strdup("alter server"),$3,mm_strdup("rename to"),$6);
8154 }
8155 | ALTER SUBSCRIPTION name RENAME TO name
8156 {
8157 $$ = cat_str(4,mm_strdup("alter subscription"),$3,mm_strdup("rename to"),$6);
8158 }
8159 | ALTER TABLE relation_expr RENAME TO name
8160 {
8161 $$ = cat_str(4,mm_strdup("alter table"),$3,mm_strdup("rename to"),$6);
8162 }
8163 | ALTER TABLE IF_P EXISTS relation_expr RENAME TO name
8164 {
8165 $$ = cat_str(4,mm_strdup("alter table if exists"),$5,mm_strdup("rename to"),$8);
8166 }
8167 | ALTER SEQUENCE qualified_name RENAME TO name
8168 {
8169 $$ = cat_str(4,mm_strdup("alter sequence"),$3,mm_strdup("rename to"),$6);
8170 }
8171 | ALTER SEQUENCE IF_P EXISTS qualified_name RENAME TO name
8172 {
8173 $$ = cat_str(4,mm_strdup("alter sequence if exists"),$5,mm_strdup("rename to"),$8);
8174 }
8175 | ALTER VIEW qualified_name RENAME TO name
8176 {
8177 $$ = cat_str(4,mm_strdup("alter view"),$3,mm_strdup("rename to"),$6);
8178 }
8179 | ALTER VIEW IF_P EXISTS qualified_name RENAME TO name
8180 {
8181 $$ = cat_str(4,mm_strdup("alter view if exists"),$5,mm_strdup("rename to"),$8);
8182 }
8183 | ALTER MATERIALIZED VIEW qualified_name RENAME TO name
8184 {
8185 $$ = cat_str(4,mm_strdup("alter materialized view"),$4,mm_strdup("rename to"),$7);
8186 }
8187 | ALTER MATERIALIZED VIEW IF_P EXISTS qualified_name RENAME TO name
8188 {
8189 $$ = cat_str(4,mm_strdup("alter materialized view if exists"),$6,mm_strdup("rename to"),$9);
8190 }
8191 | ALTER INDEX qualified_name RENAME TO name
8192 {
8193 $$ = cat_str(4,mm_strdup("alter index"),$3,mm_strdup("rename to"),$6);
8194 }
8195 | ALTER INDEX IF_P EXISTS qualified_name RENAME TO name
8196 {
8197 $$ = cat_str(4,mm_strdup("alter index if exists"),$5,mm_strdup("rename to"),$8);
8198 }
8199 | ALTER FOREIGN TABLE relation_expr RENAME TO name
8200 {
8201 $$ = cat_str(4,mm_strdup("alter foreign table"),$4,mm_strdup("rename to"),$7);
8202 }
8203 | ALTER FOREIGN TABLE IF_P EXISTS relation_expr RENAME TO name
8204 {
8205 $$ = cat_str(4,mm_strdup("alter foreign table if exists"),$6,mm_strdup("rename to"),$9);
8206 }
8207 | ALTER TABLE relation_expr RENAME opt_column name TO name
8208 {
8209 $$ = cat_str(7,mm_strdup("alter table"),$3,mm_strdup("rename"),$5,$6,mm_strdup("to"),$8);
8210 }
8211 | ALTER TABLE IF_P EXISTS relation_expr RENAME opt_column name TO name
8212 {
8213 $$ = cat_str(7,mm_strdup("alter table if exists"),$5,mm_strdup("rename"),$7,$8,mm_strdup("to"),$10);
8214 }
8215 | ALTER MATERIALIZED VIEW qualified_name RENAME opt_column name TO name
8216 {
8217 $$ = cat_str(7,mm_strdup("alter materialized view"),$4,mm_strdup("rename"),$6,$7,mm_strdup("to"),$9);
8218 }
8219 | ALTER MATERIALIZED VIEW IF_P EXISTS qualified_name RENAME opt_column name TO name
8220 {
8221 $$ = cat_str(7,mm_strdup("alter materialized view if exists"),$6,mm_strdup("rename"),$8,$9,mm_strdup("to"),$11);
8222 }
8223 | ALTER TABLE relation_expr RENAME CONSTRAINT name TO name
8224 {
8225 $$ = cat_str(6,mm_strdup("alter table"),$3,mm_strdup("rename constraint"),$6,mm_strdup("to"),$8);
8226 }
8227 | ALTER TABLE IF_P EXISTS relation_expr RENAME CONSTRAINT name TO name
8228 {
8229 $$ = cat_str(6,mm_strdup("alter table if exists"),$5,mm_strdup("rename constraint"),$8,mm_strdup("to"),$10);
8230 }
8231 | ALTER FOREIGN TABLE relation_expr RENAME opt_column name TO name
8232 {
8233 $$ = cat_str(7,mm_strdup("alter foreign table"),$4,mm_strdup("rename"),$6,$7,mm_strdup("to"),$9);
8234 }
8235 | ALTER FOREIGN TABLE IF_P EXISTS relation_expr RENAME opt_column name TO name
8236 {
8237 $$ = cat_str(7,mm_strdup("alter foreign table if exists"),$6,mm_strdup("rename"),$8,$9,mm_strdup("to"),$11);
8238 }
8239 | ALTER RULE name ON qualified_name RENAME TO name
8240 {
8241 $$ = cat_str(6,mm_strdup("alter rule"),$3,mm_strdup("on"),$5,mm_strdup("rename to"),$8);
8242 }
8243 | ALTER TRIGGER name ON qualified_name RENAME TO name
8244 {
8245 $$ = cat_str(6,mm_strdup("alter trigger"),$3,mm_strdup("on"),$5,mm_strdup("rename to"),$8);
8246 }
8247 | ALTER EVENT TRIGGER name RENAME TO name
8248 {
8249 $$ = cat_str(4,mm_strdup("alter event trigger"),$4,mm_strdup("rename to"),$7);
8250 }
8251 | ALTER ROLE RoleId RENAME TO RoleId
8252 {
8253 $$ = cat_str(4,mm_strdup("alter role"),$3,mm_strdup("rename to"),$6);
8254 }
8255 | ALTER USER RoleId RENAME TO RoleId
8256 {
8257 $$ = cat_str(4,mm_strdup("alter user"),$3,mm_strdup("rename to"),$6);
8258 }
8259 | ALTER TABLESPACE name RENAME TO name
8260 {
8261 $$ = cat_str(4,mm_strdup("alter tablespace"),$3,mm_strdup("rename to"),$6);
8262 }
8263 | ALTER STATISTICS any_name RENAME TO name
8264 {
8265 $$ = cat_str(4,mm_strdup("alter statistics"),$3,mm_strdup("rename to"),$6);
8266 }
8267 | ALTER TEXT_P SEARCH PARSER any_name RENAME TO name
8268 {
8269 $$ = cat_str(4,mm_strdup("alter text search parser"),$5,mm_strdup("rename to"),$8);
8270 }
8271 | ALTER TEXT_P SEARCH DICTIONARY any_name RENAME TO name
8272 {
8273 $$ = cat_str(4,mm_strdup("alter text search dictionary"),$5,mm_strdup("rename to"),$8);
8274 }
8275 | ALTER TEXT_P SEARCH TEMPLATE any_name RENAME TO name
8276 {
8277 $$ = cat_str(4,mm_strdup("alter text search template"),$5,mm_strdup("rename to"),$8);
8278 }
8279 | ALTER TEXT_P SEARCH CONFIGURATION any_name RENAME TO name
8280 {
8281 $$ = cat_str(4,mm_strdup("alter text search configuration"),$5,mm_strdup("rename to"),$8);
8282 }
8283 | ALTER TYPE_P any_name RENAME TO name
8284 {
8285 $$ = cat_str(4,mm_strdup("alter type"),$3,mm_strdup("rename to"),$6);
8286 }
8287 | ALTER TYPE_P any_name RENAME ATTRIBUTE name TO name opt_drop_behavior
8288 {
8289 $$ = cat_str(7,mm_strdup("alter type"),$3,mm_strdup("rename attribute"),$6,mm_strdup("to"),$8,$9);
8290 }
8291 ;
8292
8293
8294 opt_column:
8295 COLUMN
8296 {
8297 $$ = mm_strdup("column");
8298 }
8299 |
8300 {
8301 $$=EMPTY; }
8302 ;
8303
8304
8305 opt_set_data:
8306 SET DATA_P
8307 {
8308 $$ = mm_strdup("set data");
8309 }
8310 |
8311 {
8312 $$=EMPTY; }
8313 ;
8314
8315
8316 AlterObjectDependsStmt:
8317 ALTER FUNCTION function_with_argtypes DEPENDS ON EXTENSION name
8318 {
8319 $$ = cat_str(4,mm_strdup("alter function"),$3,mm_strdup("depends on extension"),$7);
8320 }
8321 | ALTER PROCEDURE function_with_argtypes DEPENDS ON EXTENSION name
8322 {
8323 $$ = cat_str(4,mm_strdup("alter procedure"),$3,mm_strdup("depends on extension"),$7);
8324 }
8325 | ALTER ROUTINE function_with_argtypes DEPENDS ON EXTENSION name
8326 {
8327 $$ = cat_str(4,mm_strdup("alter routine"),$3,mm_strdup("depends on extension"),$7);
8328 }
8329 | ALTER TRIGGER name ON qualified_name DEPENDS ON EXTENSION name
8330 {
8331 $$ = cat_str(6,mm_strdup("alter trigger"),$3,mm_strdup("on"),$5,mm_strdup("depends on extension"),$9);
8332 }
8333 | ALTER MATERIALIZED VIEW qualified_name DEPENDS ON EXTENSION name
8334 {
8335 $$ = cat_str(4,mm_strdup("alter materialized view"),$4,mm_strdup("depends on extension"),$8);
8336 }
8337 | ALTER INDEX qualified_name DEPENDS ON EXTENSION name
8338 {
8339 $$ = cat_str(4,mm_strdup("alter index"),$3,mm_strdup("depends on extension"),$7);
8340 }
8341 ;
8342
8343
8344 AlterObjectSchemaStmt:
8345 ALTER AGGREGATE aggregate_with_argtypes SET SCHEMA name
8346 {
8347 $$ = cat_str(4,mm_strdup("alter aggregate"),$3,mm_strdup("set schema"),$6);
8348 }
8349 | ALTER COLLATION any_name SET SCHEMA name
8350 {
8351 $$ = cat_str(4,mm_strdup("alter collation"),$3,mm_strdup("set schema"),$6);
8352 }
8353 | ALTER CONVERSION_P any_name SET SCHEMA name
8354 {
8355 $$ = cat_str(4,mm_strdup("alter conversion"),$3,mm_strdup("set schema"),$6);
8356 }
8357 | ALTER DOMAIN_P any_name SET SCHEMA name
8358 {
8359 $$ = cat_str(4,mm_strdup("alter domain"),$3,mm_strdup("set schema"),$6);
8360 }
8361 | ALTER EXTENSION name SET SCHEMA name
8362 {
8363 $$ = cat_str(4,mm_strdup("alter extension"),$3,mm_strdup("set schema"),$6);
8364 }
8365 | ALTER FUNCTION function_with_argtypes SET SCHEMA name
8366 {
8367 $$ = cat_str(4,mm_strdup("alter function"),$3,mm_strdup("set schema"),$6);
8368 }
8369 | ALTER OPERATOR operator_with_argtypes SET SCHEMA name
8370 {
8371 $$ = cat_str(4,mm_strdup("alter operator"),$3,mm_strdup("set schema"),$6);
8372 }
8373 | ALTER OPERATOR CLASS any_name USING access_method SET SCHEMA name
8374 {
8375 $$ = cat_str(6,mm_strdup("alter operator class"),$4,mm_strdup("using"),$6,mm_strdup("set schema"),$9);
8376 }
8377 | ALTER OPERATOR FAMILY any_name USING access_method SET SCHEMA name
8378 {
8379 $$ = cat_str(6,mm_strdup("alter operator family"),$4,mm_strdup("using"),$6,mm_strdup("set schema"),$9);
8380 }
8381 | ALTER PROCEDURE function_with_argtypes SET SCHEMA name
8382 {
8383 $$ = cat_str(4,mm_strdup("alter procedure"),$3,mm_strdup("set schema"),$6);
8384 }
8385 | ALTER ROUTINE function_with_argtypes SET SCHEMA name
8386 {
8387 $$ = cat_str(4,mm_strdup("alter routine"),$3,mm_strdup("set schema"),$6);
8388 }
8389 | ALTER TABLE relation_expr SET SCHEMA name
8390 {
8391 $$ = cat_str(4,mm_strdup("alter table"),$3,mm_strdup("set schema"),$6);
8392 }
8393 | ALTER TABLE IF_P EXISTS relation_expr SET SCHEMA name
8394 {
8395 $$ = cat_str(4,mm_strdup("alter table if exists"),$5,mm_strdup("set schema"),$8);
8396 }
8397 | ALTER STATISTICS any_name SET SCHEMA name
8398 {
8399 $$ = cat_str(4,mm_strdup("alter statistics"),$3,mm_strdup("set schema"),$6);
8400 }
8401 | ALTER TEXT_P SEARCH PARSER any_name SET SCHEMA name
8402 {
8403 $$ = cat_str(4,mm_strdup("alter text search parser"),$5,mm_strdup("set schema"),$8);
8404 }
8405 | ALTER TEXT_P SEARCH DICTIONARY any_name SET SCHEMA name
8406 {
8407 $$ = cat_str(4,mm_strdup("alter text search dictionary"),$5,mm_strdup("set schema"),$8);
8408 }
8409 | ALTER TEXT_P SEARCH TEMPLATE any_name SET SCHEMA name
8410 {
8411 $$ = cat_str(4,mm_strdup("alter text search template"),$5,mm_strdup("set schema"),$8);
8412 }
8413 | ALTER TEXT_P SEARCH CONFIGURATION any_name SET SCHEMA name
8414 {
8415 $$ = cat_str(4,mm_strdup("alter text search configuration"),$5,mm_strdup("set schema"),$8);
8416 }
8417 | ALTER SEQUENCE qualified_name SET SCHEMA name
8418 {
8419 $$ = cat_str(4,mm_strdup("alter sequence"),$3,mm_strdup("set schema"),$6);
8420 }
8421 | ALTER SEQUENCE IF_P EXISTS qualified_name SET SCHEMA name
8422 {
8423 $$ = cat_str(4,mm_strdup("alter sequence if exists"),$5,mm_strdup("set schema"),$8);
8424 }
8425 | ALTER VIEW qualified_name SET SCHEMA name
8426 {
8427 $$ = cat_str(4,mm_strdup("alter view"),$3,mm_strdup("set schema"),$6);
8428 }
8429 | ALTER VIEW IF_P EXISTS qualified_name SET SCHEMA name
8430 {
8431 $$ = cat_str(4,mm_strdup("alter view if exists"),$5,mm_strdup("set schema"),$8);
8432 }
8433 | ALTER MATERIALIZED VIEW qualified_name SET SCHEMA name
8434 {
8435 $$ = cat_str(4,mm_strdup("alter materialized view"),$4,mm_strdup("set schema"),$7);
8436 }
8437 | ALTER MATERIALIZED VIEW IF_P EXISTS qualified_name SET SCHEMA name
8438 {
8439 $$ = cat_str(4,mm_strdup("alter materialized view if exists"),$6,mm_strdup("set schema"),$9);
8440 }
8441 | ALTER FOREIGN TABLE relation_expr SET SCHEMA name
8442 {
8443 $$ = cat_str(4,mm_strdup("alter foreign table"),$4,mm_strdup("set schema"),$7);
8444 }
8445 | ALTER FOREIGN TABLE IF_P EXISTS relation_expr SET SCHEMA name
8446 {
8447 $$ = cat_str(4,mm_strdup("alter foreign table if exists"),$6,mm_strdup("set schema"),$9);
8448 }
8449 | ALTER TYPE_P any_name SET SCHEMA name
8450 {
8451 $$ = cat_str(4,mm_strdup("alter type"),$3,mm_strdup("set schema"),$6);
8452 }
8453 ;
8454
8455
8456 AlterOperatorStmt:
8457 ALTER OPERATOR operator_with_argtypes SET '(' operator_def_list ')'
8458 {
8459 $$ = cat_str(5,mm_strdup("alter operator"),$3,mm_strdup("set ("),$6,mm_strdup(")"));
8460 }
8461 ;
8462
8463
8464 operator_def_list:
8465 operator_def_elem
8466 {
8467 $$ = $1;
8468 }
8469 | operator_def_list ',' operator_def_elem
8470 {
8471 $$ = cat_str(3,$1,mm_strdup(","),$3);
8472 }
8473 ;
8474
8475
8476 operator_def_elem:
8477 ColLabel '=' NONE
8478 {
8479 $$ = cat_str(2,$1,mm_strdup("= none"));
8480 }
8481 | ColLabel '=' operator_def_arg
8482 {
8483 $$ = cat_str(3,$1,mm_strdup("="),$3);
8484 }
8485 ;
8486
8487
8488 operator_def_arg:
8489 func_type
8490 {
8491 $$ = $1;
8492 }
8493 | reserved_keyword
8494 {
8495 $$ = $1;
8496 }
8497 | qual_all_Op
8498 {
8499 $$ = $1;
8500 }
8501 | NumericOnly
8502 {
8503 $$ = $1;
8504 }
8505 | ecpg_sconst
8506 {
8507 $$ = $1;
8508 }
8509 ;
8510
8511
8512 AlterOwnerStmt:
8513 ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
8514 {
8515 $$ = cat_str(4,mm_strdup("alter aggregate"),$3,mm_strdup("owner to"),$6);
8516 }
8517 | ALTER COLLATION any_name OWNER TO RoleSpec
8518 {
8519 $$ = cat_str(4,mm_strdup("alter collation"),$3,mm_strdup("owner to"),$6);
8520 }
8521 | ALTER CONVERSION_P any_name OWNER TO RoleSpec
8522 {
8523 $$ = cat_str(4,mm_strdup("alter conversion"),$3,mm_strdup("owner to"),$6);
8524 }
8525 | ALTER DATABASE database_name OWNER TO RoleSpec
8526 {
8527 $$ = cat_str(4,mm_strdup("alter database"),$3,mm_strdup("owner to"),$6);
8528 }
8529 | ALTER DOMAIN_P any_name OWNER TO RoleSpec
8530 {
8531 $$ = cat_str(4,mm_strdup("alter domain"),$3,mm_strdup("owner to"),$6);
8532 }
8533 | ALTER FUNCTION function_with_argtypes OWNER TO RoleSpec
8534 {
8535 $$ = cat_str(4,mm_strdup("alter function"),$3,mm_strdup("owner to"),$6);
8536 }
8537 | ALTER opt_procedural LANGUAGE name OWNER TO RoleSpec
8538 {
8539 $$ = cat_str(6,mm_strdup("alter"),$2,mm_strdup("language"),$4,mm_strdup("owner to"),$7);
8540 }
8541 | ALTER LARGE_P OBJECT_P NumericOnly OWNER TO RoleSpec
8542 {
8543 $$ = cat_str(4,mm_strdup("alter large object"),$4,mm_strdup("owner to"),$7);
8544 }
8545 | ALTER OPERATOR operator_with_argtypes OWNER TO RoleSpec
8546 {
8547 $$ = cat_str(4,mm_strdup("alter operator"),$3,mm_strdup("owner to"),$6);
8548 }
8549 | ALTER OPERATOR CLASS any_name USING access_method OWNER TO RoleSpec
8550 {
8551 $$ = cat_str(6,mm_strdup("alter operator class"),$4,mm_strdup("using"),$6,mm_strdup("owner to"),$9);
8552 }
8553 | ALTER OPERATOR FAMILY any_name USING access_method OWNER TO RoleSpec
8554 {
8555 $$ = cat_str(6,mm_strdup("alter operator family"),$4,mm_strdup("using"),$6,mm_strdup("owner to"),$9);
8556 }
8557 | ALTER PROCEDURE function_with_argtypes OWNER TO RoleSpec
8558 {
8559 $$ = cat_str(4,mm_strdup("alter procedure"),$3,mm_strdup("owner to"),$6);
8560 }
8561 | ALTER ROUTINE function_with_argtypes OWNER TO RoleSpec
8562 {
8563 $$ = cat_str(4,mm_strdup("alter routine"),$3,mm_strdup("owner to"),$6);
8564 }
8565 | ALTER SCHEMA name OWNER TO RoleSpec
8566 {
8567 $$ = cat_str(4,mm_strdup("alter schema"),$3,mm_strdup("owner to"),$6);
8568 }
8569 | ALTER TYPE_P any_name OWNER TO RoleSpec
8570 {
8571 $$ = cat_str(4,mm_strdup("alter type"),$3,mm_strdup("owner to"),$6);
8572 }
8573 | ALTER TABLESPACE name OWNER TO RoleSpec
8574 {
8575 $$ = cat_str(4,mm_strdup("alter tablespace"),$3,mm_strdup("owner to"),$6);
8576 }
8577 | ALTER STATISTICS any_name OWNER TO RoleSpec
8578 {
8579 $$ = cat_str(4,mm_strdup("alter statistics"),$3,mm_strdup("owner to"),$6);
8580 }
8581 | ALTER TEXT_P SEARCH DICTIONARY any_name OWNER TO RoleSpec
8582 {
8583 $$ = cat_str(4,mm_strdup("alter text search dictionary"),$5,mm_strdup("owner to"),$8);
8584 }
8585 | ALTER TEXT_P SEARCH CONFIGURATION any_name OWNER TO RoleSpec
8586 {
8587 $$ = cat_str(4,mm_strdup("alter text search configuration"),$5,mm_strdup("owner to"),$8);
8588 }
8589 | ALTER FOREIGN DATA_P WRAPPER name OWNER TO RoleSpec
8590 {
8591 $$ = cat_str(4,mm_strdup("alter foreign data wrapper"),$5,mm_strdup("owner to"),$8);
8592 }
8593 | ALTER SERVER name OWNER TO RoleSpec
8594 {
8595 $$ = cat_str(4,mm_strdup("alter server"),$3,mm_strdup("owner to"),$6);
8596 }
8597 | ALTER EVENT TRIGGER name OWNER TO RoleSpec
8598 {
8599 $$ = cat_str(4,mm_strdup("alter event trigger"),$4,mm_strdup("owner to"),$7);
8600 }
8601 | ALTER PUBLICATION name OWNER TO RoleSpec
8602 {
8603 $$ = cat_str(4,mm_strdup("alter publication"),$3,mm_strdup("owner to"),$6);
8604 }
8605 | ALTER SUBSCRIPTION name OWNER TO RoleSpec
8606 {
8607 $$ = cat_str(4,mm_strdup("alter subscription"),$3,mm_strdup("owner to"),$6);
8608 }
8609 ;
8610
8611
8612 CreatePublicationStmt:
8613 CREATE PUBLICATION name opt_publication_for_tables opt_definition
8614 {
8615 $$ = cat_str(4,mm_strdup("create publication"),$3,$4,$5);
8616 }
8617 ;
8618
8619
8620 opt_publication_for_tables:
8621 publication_for_tables
8622 {
8623 $$ = $1;
8624 }
8625 |
8626 {
8627 $$=EMPTY; }
8628 ;
8629
8630
8631 publication_for_tables:
8632 FOR TABLE relation_expr_list
8633 {
8634 $$ = cat_str(2,mm_strdup("for table"),$3);
8635 }
8636 | FOR ALL TABLES
8637 {
8638 $$ = mm_strdup("for all tables");
8639 }
8640 ;
8641
8642
8643 AlterPublicationStmt:
8644 ALTER PUBLICATION name SET definition
8645 {
8646 $$ = cat_str(4,mm_strdup("alter publication"),$3,mm_strdup("set"),$5);
8647 }
8648 | ALTER PUBLICATION name ADD_P TABLE relation_expr_list
8649 {
8650 $$ = cat_str(4,mm_strdup("alter publication"),$3,mm_strdup("add table"),$6);
8651 }
8652 | ALTER PUBLICATION name SET TABLE relation_expr_list
8653 {
8654 $$ = cat_str(4,mm_strdup("alter publication"),$3,mm_strdup("set table"),$6);
8655 }
8656 | ALTER PUBLICATION name DROP TABLE relation_expr_list
8657 {
8658 $$ = cat_str(4,mm_strdup("alter publication"),$3,mm_strdup("drop table"),$6);
8659 }
8660 ;
8661
8662
8663 CreateSubscriptionStmt:
8664 CREATE SUBSCRIPTION name CONNECTION ecpg_sconst PUBLICATION publication_name_list opt_definition
8665 {
8666 $$ = cat_str(7,mm_strdup("create subscription"),$3,mm_strdup("connection"),$5,mm_strdup("publication"),$7,$8);
8667 }
8668 ;
8669
8670
8671 publication_name_list:
8672 publication_name_item
8673 {
8674 $$ = $1;
8675 }
8676 | publication_name_list ',' publication_name_item
8677 {
8678 $$ = cat_str(3,$1,mm_strdup(","),$3);
8679 }
8680 ;
8681
8682
8683 publication_name_item:
8684 ColLabel
8685 {
8686 $$ = $1;
8687 }
8688 ;
8689
8690
8691 AlterSubscriptionStmt:
8692 ALTER SUBSCRIPTION name SET definition
8693 {
8694 $$ = cat_str(4,mm_strdup("alter subscription"),$3,mm_strdup("set"),$5);
8695 }
8696 | ALTER SUBSCRIPTION name CONNECTION ecpg_sconst
8697 {
8698 $$ = cat_str(4,mm_strdup("alter subscription"),$3,mm_strdup("connection"),$5);
8699 }
8700 | ALTER SUBSCRIPTION name REFRESH PUBLICATION opt_definition
8701 {
8702 $$ = cat_str(4,mm_strdup("alter subscription"),$3,mm_strdup("refresh publication"),$6);
8703 }
8704 | ALTER SUBSCRIPTION name SET PUBLICATION publication_name_list opt_definition
8705 {
8706 $$ = cat_str(5,mm_strdup("alter subscription"),$3,mm_strdup("set publication"),$6,$7);
8707 }
8708 | ALTER SUBSCRIPTION name ENABLE_P
8709 {
8710 $$ = cat_str(3,mm_strdup("alter subscription"),$3,mm_strdup("enable"));
8711 }
8712 | ALTER SUBSCRIPTION name DISABLE_P
8713 {
8714 $$ = cat_str(3,mm_strdup("alter subscription"),$3,mm_strdup("disable"));
8715 }
8716 ;
8717
8718
8719 DropSubscriptionStmt:
8720 DROP SUBSCRIPTION name opt_drop_behavior
8721 {
8722 $$ = cat_str(3,mm_strdup("drop subscription"),$3,$4);
8723 }
8724 | DROP SUBSCRIPTION IF_P EXISTS name opt_drop_behavior
8725 {
8726 $$ = cat_str(3,mm_strdup("drop subscription if exists"),$5,$6);
8727 }
8728 ;
8729
8730
8731 RuleStmt:
8732 CREATE opt_or_replace RULE name AS ON event TO qualified_name where_clause DO opt_instead RuleActionList
8733 {
8734 $$ = cat_str(12,mm_strdup("create"),$2,mm_strdup("rule"),$4,mm_strdup("as on"),$7,mm_strdup("to"),$9,$10,mm_strdup("do"),$12,$13);
8735 }
8736 ;
8737
8738
8739 RuleActionList:
8740 NOTHING
8741 {
8742 $$ = mm_strdup("nothing");
8743 }
8744 | RuleActionStmt
8745 {
8746 $$ = $1;
8747 }
8748 | '(' RuleActionMulti ')'
8749 {
8750 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
8751 }
8752 ;
8753
8754
8755 RuleActionMulti:
8756 RuleActionMulti ';' RuleActionStmtOrEmpty
8757 {
8758 $$ = cat_str(3,$1,mm_strdup(";"),$3);
8759 }
8760 | RuleActionStmtOrEmpty
8761 {
8762 $$ = $1;
8763 }
8764 ;
8765
8766
8767 RuleActionStmt:
8768 SelectStmt
8769 {
8770 $$ = $1;
8771 }
8772 | InsertStmt
8773 {
8774 $$ = $1;
8775 }
8776 | UpdateStmt
8777 {
8778 $$ = $1;
8779 }
8780 | DeleteStmt
8781 {
8782 $$ = $1;
8783 }
8784 | NotifyStmt
8785 {
8786 $$ = $1;
8787 }
8788 ;
8789
8790
8791 RuleActionStmtOrEmpty:
8792 RuleActionStmt
8793 {
8794 $$ = $1;
8795 }
8796 |
8797 {
8798 $$=EMPTY; }
8799 ;
8800
8801
8802 event:
8803 SELECT
8804 {
8805 $$ = mm_strdup("select");
8806 }
8807 | UPDATE
8808 {
8809 $$ = mm_strdup("update");
8810 }
8811 | DELETE_P
8812 {
8813 $$ = mm_strdup("delete");
8814 }
8815 | INSERT
8816 {
8817 $$ = mm_strdup("insert");
8818 }
8819 ;
8820
8821
8822 opt_instead:
8823 INSTEAD
8824 {
8825 $$ = mm_strdup("instead");
8826 }
8827 | ALSO
8828 {
8829 $$ = mm_strdup("also");
8830 }
8831 |
8832 {
8833 $$=EMPTY; }
8834 ;
8835
8836
8837 NotifyStmt:
8838 NOTIFY ColId notify_payload
8839 {
8840 $$ = cat_str(3,mm_strdup("notify"),$2,$3);
8841 }
8842 ;
8843
8844
8845 notify_payload:
8846 ',' ecpg_sconst
8847 {
8848 $$ = cat_str(2,mm_strdup(","),$2);
8849 }
8850 |
8851 {
8852 $$=EMPTY; }
8853 ;
8854
8855
8856 ListenStmt:
8857 LISTEN ColId
8858 {
8859 $$ = cat_str(2,mm_strdup("listen"),$2);
8860 }
8861 ;
8862
8863
8864 UnlistenStmt:
8865 UNLISTEN ColId
8866 {
8867 $$ = cat_str(2,mm_strdup("unlisten"),$2);
8868 }
8869 | UNLISTEN '*'
8870 {
8871 $$ = mm_strdup("unlisten *");
8872 }
8873 ;
8874
8875
8876 TransactionStmt:
8877 ABORT_P opt_transaction opt_transaction_chain
8878 {
8879 $$ = cat_str(3,mm_strdup("abort"),$2,$3);
8880 }
8881 | BEGIN_P opt_transaction transaction_mode_list_or_empty
8882 {
8883 $$ = cat_str(3,mm_strdup("begin"),$2,$3);
8884 }
8885 | START TRANSACTION transaction_mode_list_or_empty
8886 {
8887 $$ = cat_str(2,mm_strdup("start transaction"),$3);
8888 }
8889 | COMMIT opt_transaction opt_transaction_chain
8890 {
8891 $$ = cat_str(3,mm_strdup("commit"),$2,$3);
8892 }
8893 | END_P opt_transaction opt_transaction_chain
8894 {
8895 $$ = cat_str(3,mm_strdup("end"),$2,$3);
8896 }
8897 | ROLLBACK opt_transaction opt_transaction_chain
8898 {
8899 $$ = cat_str(3,mm_strdup("rollback"),$2,$3);
8900 }
8901 | SAVEPOINT ColId
8902 {
8903 $$ = cat_str(2,mm_strdup("savepoint"),$2);
8904 }
8905 | RELEASE SAVEPOINT ColId
8906 {
8907 $$ = cat_str(2,mm_strdup("release savepoint"),$3);
8908 }
8909 | RELEASE ColId
8910 {
8911 $$ = cat_str(2,mm_strdup("release"),$2);
8912 }
8913 | ROLLBACK opt_transaction TO SAVEPOINT ColId
8914 {
8915 $$ = cat_str(4,mm_strdup("rollback"),$2,mm_strdup("to savepoint"),$5);
8916 }
8917 | ROLLBACK opt_transaction TO ColId
8918 {
8919 $$ = cat_str(4,mm_strdup("rollback"),$2,mm_strdup("to"),$4);
8920 }
8921 | PREPARE TRANSACTION ecpg_sconst
8922 {
8923 $$ = cat_str(2,mm_strdup("prepare transaction"),$3);
8924 }
8925 | COMMIT PREPARED ecpg_sconst
8926 {
8927 $$ = cat_str(2,mm_strdup("commit prepared"),$3);
8928 }
8929 | ROLLBACK PREPARED ecpg_sconst
8930 {
8931 $$ = cat_str(2,mm_strdup("rollback prepared"),$3);
8932 }
8933 ;
8934
8935
8936 opt_transaction:
8937 WORK
8938 {
8939 $$ = mm_strdup("work");
8940 }
8941 | TRANSACTION
8942 {
8943 $$ = mm_strdup("transaction");
8944 }
8945 |
8946 {
8947 $$=EMPTY; }
8948 ;
8949
8950
8951 transaction_mode_item:
8952 ISOLATION LEVEL iso_level
8953 {
8954 $$ = cat_str(2,mm_strdup("isolation level"),$3);
8955 }
8956 | READ ONLY
8957 {
8958 $$ = mm_strdup("read only");
8959 }
8960 | READ WRITE
8961 {
8962 $$ = mm_strdup("read write");
8963 }
8964 | DEFERRABLE
8965 {
8966 $$ = mm_strdup("deferrable");
8967 }
8968 | NOT DEFERRABLE
8969 {
8970 $$ = mm_strdup("not deferrable");
8971 }
8972 ;
8973
8974
8975 transaction_mode_list:
8976 transaction_mode_item
8977 {
8978 $$ = $1;
8979 }
8980 | transaction_mode_list ',' transaction_mode_item
8981 {
8982 $$ = cat_str(3,$1,mm_strdup(","),$3);
8983 }
8984 | transaction_mode_list transaction_mode_item
8985 {
8986 $$ = cat_str(2,$1,$2);
8987 }
8988 ;
8989
8990
8991 transaction_mode_list_or_empty:
8992 transaction_mode_list
8993 {
8994 $$ = $1;
8995 }
8996 |
8997 {
8998 $$=EMPTY; }
8999 ;
9000
9001
9002 opt_transaction_chain:
9003 AND CHAIN
9004 {
9005 $$ = mm_strdup("and chain");
9006 }
9007 | AND NO CHAIN
9008 {
9009 $$ = mm_strdup("and no chain");
9010 }
9011 |
9012 {
9013 $$=EMPTY; }
9014 ;
9015
9016
9017 ViewStmt:
9018 CREATE OptTemp VIEW qualified_name opt_column_list opt_reloptions AS SelectStmt opt_check_option
9019 {
9020 $$ = cat_str(9,mm_strdup("create"),$2,mm_strdup("view"),$4,$5,$6,mm_strdup("as"),$8,$9);
9021 }
9022 | CREATE OR REPLACE OptTemp VIEW qualified_name opt_column_list opt_reloptions AS SelectStmt opt_check_option
9023 {
9024 $$ = cat_str(9,mm_strdup("create or replace"),$4,mm_strdup("view"),$6,$7,$8,mm_strdup("as"),$10,$11);
9025 }
9026 | CREATE OptTemp RECURSIVE VIEW qualified_name '(' columnList ')' opt_reloptions AS SelectStmt opt_check_option
9027 {
9028 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
9029 $$ = cat_str(11,mm_strdup("create"),$2,mm_strdup("recursive view"),$5,mm_strdup("("),$7,mm_strdup(")"),$9,mm_strdup("as"),$11,$12);
9030 }
9031 | CREATE OR REPLACE OptTemp RECURSIVE VIEW qualified_name '(' columnList ')' opt_reloptions AS SelectStmt opt_check_option
9032 {
9033 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
9034 $$ = cat_str(11,mm_strdup("create or replace"),$4,mm_strdup("recursive view"),$7,mm_strdup("("),$9,mm_strdup(")"),$11,mm_strdup("as"),$13,$14);
9035 }
9036 ;
9037
9038
9039 opt_check_option:
9040 WITH CHECK OPTION
9041 {
9042 $$ = mm_strdup("with check option");
9043 }
9044 | WITH CASCADED CHECK OPTION
9045 {
9046 $$ = mm_strdup("with cascaded check option");
9047 }
9048 | WITH LOCAL CHECK OPTION
9049 {
9050 $$ = mm_strdup("with local check option");
9051 }
9052 |
9053 {
9054 $$=EMPTY; }
9055 ;
9056
9057
9058 LoadStmt:
9059 LOAD file_name
9060 {
9061 $$ = cat_str(2,mm_strdup("load"),$2);
9062 }
9063 ;
9064
9065
9066 CreatedbStmt:
9067 CREATE DATABASE database_name opt_with createdb_opt_list
9068 {
9069 $$ = cat_str(4,mm_strdup("create database"),$3,$4,$5);
9070 }
9071 ;
9072
9073
9074 createdb_opt_list:
9075 createdb_opt_items
9076 {
9077 $$ = $1;
9078 }
9079 |
9080 {
9081 $$=EMPTY; }
9082 ;
9083
9084
9085 createdb_opt_items:
9086 createdb_opt_item
9087 {
9088 $$ = $1;
9089 }
9090 | createdb_opt_items createdb_opt_item
9091 {
9092 $$ = cat_str(2,$1,$2);
9093 }
9094 ;
9095
9096
9097 createdb_opt_item:
9098 createdb_opt_name opt_equal SignedIconst
9099 {
9100 $$ = cat_str(3,$1,$2,$3);
9101 }
9102 | createdb_opt_name opt_equal opt_boolean_or_string
9103 {
9104 $$ = cat_str(3,$1,$2,$3);
9105 }
9106 | createdb_opt_name opt_equal DEFAULT
9107 {
9108 $$ = cat_str(3,$1,$2,mm_strdup("default"));
9109 }
9110 ;
9111
9112
9113 createdb_opt_name:
9114 ecpg_ident
9115 {
9116 $$ = $1;
9117 }
9118 | CONNECTION LIMIT
9119 {
9120 $$ = mm_strdup("connection limit");
9121 }
9122 | ENCODING
9123 {
9124 $$ = mm_strdup("encoding");
9125 }
9126 | LOCATION
9127 {
9128 $$ = mm_strdup("location");
9129 }
9130 | OWNER
9131 {
9132 $$ = mm_strdup("owner");
9133 }
9134 | TABLESPACE
9135 {
9136 $$ = mm_strdup("tablespace");
9137 }
9138 | TEMPLATE
9139 {
9140 $$ = mm_strdup("template");
9141 }
9142 ;
9143
9144
9145 opt_equal:
9146 '='
9147 {
9148 $$ = mm_strdup("=");
9149 }
9150 |
9151 {
9152 $$=EMPTY; }
9153 ;
9154
9155
9156 AlterDatabaseStmt:
9157 ALTER DATABASE database_name WITH createdb_opt_list
9158 {
9159 $$ = cat_str(4,mm_strdup("alter database"),$3,mm_strdup("with"),$5);
9160 }
9161 | ALTER DATABASE database_name createdb_opt_list
9162 {
9163 $$ = cat_str(3,mm_strdup("alter database"),$3,$4);
9164 }
9165 | ALTER DATABASE database_name SET TABLESPACE name
9166 {
9167 $$ = cat_str(4,mm_strdup("alter database"),$3,mm_strdup("set tablespace"),$6);
9168 }
9169 ;
9170
9171
9172 AlterDatabaseSetStmt:
9173 ALTER DATABASE database_name SetResetClause
9174 {
9175 $$ = cat_str(3,mm_strdup("alter database"),$3,$4);
9176 }
9177 ;
9178
9179
9180 DropdbStmt:
9181 DROP DATABASE database_name
9182 {
9183 $$ = cat_str(2,mm_strdup("drop database"),$3);
9184 }
9185 | DROP DATABASE IF_P EXISTS database_name
9186 {
9187 $$ = cat_str(2,mm_strdup("drop database if exists"),$5);
9188 }
9189 ;
9190
9191
9192 AlterCollationStmt:
9193 ALTER COLLATION any_name REFRESH VERSION_P
9194 {
9195 $$ = cat_str(3,mm_strdup("alter collation"),$3,mm_strdup("refresh version"));
9196 }
9197 ;
9198
9199
9200 AlterSystemStmt:
9201 ALTER SYSTEM_P SET generic_set
9202 {
9203 $$ = cat_str(2,mm_strdup("alter system set"),$4);
9204 }
9205 | ALTER SYSTEM_P RESET generic_reset
9206 {
9207 $$ = cat_str(2,mm_strdup("alter system reset"),$4);
9208 }
9209 ;
9210
9211
9212 CreateDomainStmt:
9213 CREATE DOMAIN_P any_name opt_as Typename ColQualList
9214 {
9215 $$ = cat_str(5,mm_strdup("create domain"),$3,$4,$5,$6);
9216 }
9217 ;
9218
9219
9220 AlterDomainStmt:
9221 ALTER DOMAIN_P any_name alter_column_default
9222 {
9223 $$ = cat_str(3,mm_strdup("alter domain"),$3,$4);
9224 }
9225 | ALTER DOMAIN_P any_name DROP NOT NULL_P
9226 {
9227 $$ = cat_str(3,mm_strdup("alter domain"),$3,mm_strdup("drop not null"));
9228 }
9229 | ALTER DOMAIN_P any_name SET NOT NULL_P
9230 {
9231 $$ = cat_str(3,mm_strdup("alter domain"),$3,mm_strdup("set not null"));
9232 }
9233 | ALTER DOMAIN_P any_name ADD_P TableConstraint
9234 {
9235 $$ = cat_str(4,mm_strdup("alter domain"),$3,mm_strdup("add"),$5);
9236 }
9237 | ALTER DOMAIN_P any_name DROP CONSTRAINT name opt_drop_behavior
9238 {
9239 $$ = cat_str(5,mm_strdup("alter domain"),$3,mm_strdup("drop constraint"),$6,$7);
9240 }
9241 | ALTER DOMAIN_P any_name DROP CONSTRAINT IF_P EXISTS name opt_drop_behavior
9242 {
9243 $$ = cat_str(5,mm_strdup("alter domain"),$3,mm_strdup("drop constraint if exists"),$8,$9);
9244 }
9245 | ALTER DOMAIN_P any_name VALIDATE CONSTRAINT name
9246 {
9247 $$ = cat_str(4,mm_strdup("alter domain"),$3,mm_strdup("validate constraint"),$6);
9248 }
9249 ;
9250
9251
9252 opt_as:
9253 AS
9254 {
9255 $$ = mm_strdup("as");
9256 }
9257 |
9258 {
9259 $$=EMPTY; }
9260 ;
9261
9262
9263 AlterTSDictionaryStmt:
9264 ALTER TEXT_P SEARCH DICTIONARY any_name definition
9265 {
9266 $$ = cat_str(3,mm_strdup("alter text search dictionary"),$5,$6);
9267 }
9268 ;
9269
9270
9271 AlterTSConfigurationStmt:
9272 ALTER TEXT_P SEARCH CONFIGURATION any_name ADD_P MAPPING FOR name_list any_with any_name_list
9273 {
9274 $$ = cat_str(6,mm_strdup("alter text search configuration"),$5,mm_strdup("add mapping for"),$9,$10,$11);
9275 }
9276 | ALTER TEXT_P SEARCH CONFIGURATION any_name ALTER MAPPING FOR name_list any_with any_name_list
9277 {
9278 $$ = cat_str(6,mm_strdup("alter text search configuration"),$5,mm_strdup("alter mapping for"),$9,$10,$11);
9279 }
9280 | ALTER TEXT_P SEARCH CONFIGURATION any_name ALTER MAPPING REPLACE any_name any_with any_name
9281 {
9282 $$ = cat_str(6,mm_strdup("alter text search configuration"),$5,mm_strdup("alter mapping replace"),$9,$10,$11);
9283 }
9284 | ALTER TEXT_P SEARCH CONFIGURATION any_name ALTER MAPPING FOR name_list REPLACE any_name any_with any_name
9285 {
9286 $$ = cat_str(8,mm_strdup("alter text search configuration"),$5,mm_strdup("alter mapping for"),$9,mm_strdup("replace"),$11,$12,$13);
9287 }
9288 | ALTER TEXT_P SEARCH CONFIGURATION any_name DROP MAPPING FOR name_list
9289 {
9290 $$ = cat_str(4,mm_strdup("alter text search configuration"),$5,mm_strdup("drop mapping for"),$9);
9291 }
9292 | ALTER TEXT_P SEARCH CONFIGURATION any_name DROP MAPPING IF_P EXISTS FOR name_list
9293 {
9294 $$ = cat_str(4,mm_strdup("alter text search configuration"),$5,mm_strdup("drop mapping if exists for"),$11);
9295 }
9296 ;
9297
9298
9299 any_with:
9300 WITH
9301 {
9302 $$ = mm_strdup("with");
9303 }
9304 | WITH_LA
9305 {
9306 $$ = mm_strdup("with");
9307 }
9308 ;
9309
9310
9311 CreateConversionStmt:
9312 CREATE opt_default CONVERSION_P any_name FOR ecpg_sconst TO ecpg_sconst FROM any_name
9313 {
9314 $$ = cat_str(10,mm_strdup("create"),$2,mm_strdup("conversion"),$4,mm_strdup("for"),$6,mm_strdup("to"),$8,mm_strdup("from"),$10);
9315 }
9316 ;
9317
9318
9319 ClusterStmt:
9320 CLUSTER opt_verbose qualified_name cluster_index_specification
9321 {
9322 $$ = cat_str(4,mm_strdup("cluster"),$2,$3,$4);
9323 }
9324 | CLUSTER opt_verbose
9325 {
9326 $$ = cat_str(2,mm_strdup("cluster"),$2);
9327 }
9328 | CLUSTER opt_verbose index_name ON qualified_name
9329 {
9330 $$ = cat_str(5,mm_strdup("cluster"),$2,$3,mm_strdup("on"),$5);
9331 }
9332 ;
9333
9334
9335 cluster_index_specification:
9336 USING index_name
9337 {
9338 $$ = cat_str(2,mm_strdup("using"),$2);
9339 }
9340 |
9341 {
9342 $$=EMPTY; }
9343 ;
9344
9345
9346 VacuumStmt:
9347 VACUUM opt_full opt_freeze opt_verbose opt_analyze opt_vacuum_relation_list
9348 {
9349 $$ = cat_str(6,mm_strdup("vacuum"),$2,$3,$4,$5,$6);
9350 }
9351 | VACUUM '(' vac_analyze_option_list ')' opt_vacuum_relation_list
9352 {
9353 $$ = cat_str(4,mm_strdup("vacuum ("),$3,mm_strdup(")"),$5);
9354 }
9355 ;
9356
9357
9358 AnalyzeStmt:
9359 analyze_keyword opt_verbose opt_vacuum_relation_list
9360 {
9361 $$ = cat_str(3,$1,$2,$3);
9362 }
9363 | analyze_keyword '(' vac_analyze_option_list ')' opt_vacuum_relation_list
9364 {
9365 $$ = cat_str(5,$1,mm_strdup("("),$3,mm_strdup(")"),$5);
9366 }
9367 ;
9368
9369
9370 vac_analyze_option_list:
9371 vac_analyze_option_elem
9372 {
9373 $$ = $1;
9374 }
9375 | vac_analyze_option_list ',' vac_analyze_option_elem
9376 {
9377 $$ = cat_str(3,$1,mm_strdup(","),$3);
9378 }
9379 ;
9380
9381
9382 analyze_keyword:
9383 ANALYZE
9384 {
9385 $$ = mm_strdup("analyze");
9386 }
9387 | ANALYSE
9388 {
9389 $$ = mm_strdup("analyse");
9390 }
9391 ;
9392
9393
9394 vac_analyze_option_elem:
9395 vac_analyze_option_name vac_analyze_option_arg
9396 {
9397 $$ = cat_str(2,$1,$2);
9398 }
9399 ;
9400
9401
9402 vac_analyze_option_name:
9403 NonReservedWord
9404 {
9405 $$ = $1;
9406 }
9407 | analyze_keyword
9408 {
9409 $$ = $1;
9410 }
9411 ;
9412
9413
9414 vac_analyze_option_arg:
9415 opt_boolean_or_string
9416 {
9417 $$ = $1;
9418 }
9419 | NumericOnly
9420 {
9421 $$ = $1;
9422 }
9423 |
9424 {
9425 $$=EMPTY; }
9426 ;
9427
9428
9429 opt_analyze:
9430 analyze_keyword
9431 {
9432 $$ = $1;
9433 }
9434 |
9435 {
9436 $$=EMPTY; }
9437 ;
9438
9439
9440 opt_verbose:
9441 VERBOSE
9442 {
9443 $$ = mm_strdup("verbose");
9444 }
9445 |
9446 {
9447 $$=EMPTY; }
9448 ;
9449
9450
9451 opt_full:
9452 FULL
9453 {
9454 $$ = mm_strdup("full");
9455 }
9456 |
9457 {
9458 $$=EMPTY; }
9459 ;
9460
9461
9462 opt_freeze:
9463 FREEZE
9464 {
9465 $$ = mm_strdup("freeze");
9466 }
9467 |
9468 {
9469 $$=EMPTY; }
9470 ;
9471
9472
9473 opt_name_list:
9474 '(' name_list ')'
9475 {
9476 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
9477 }
9478 |
9479 {
9480 $$=EMPTY; }
9481 ;
9482
9483
9484 vacuum_relation:
9485 qualified_name opt_name_list
9486 {
9487 $$ = cat_str(2,$1,$2);
9488 }
9489 ;
9490
9491
9492 vacuum_relation_list:
9493 vacuum_relation
9494 {
9495 $$ = $1;
9496 }
9497 | vacuum_relation_list ',' vacuum_relation
9498 {
9499 $$ = cat_str(3,$1,mm_strdup(","),$3);
9500 }
9501 ;
9502
9503
9504 opt_vacuum_relation_list:
9505 vacuum_relation_list
9506 {
9507 $$ = $1;
9508 }
9509 |
9510 {
9511 $$=EMPTY; }
9512 ;
9513
9514
9515 ExplainStmt:
9516 EXPLAIN ExplainableStmt
9517 {
9518 $$ = cat_str(2,mm_strdup("explain"),$2);
9519 }
9520 | EXPLAIN analyze_keyword opt_verbose ExplainableStmt
9521 {
9522 $$ = cat_str(4,mm_strdup("explain"),$2,$3,$4);
9523 }
9524 | EXPLAIN VERBOSE ExplainableStmt
9525 {
9526 $$ = cat_str(2,mm_strdup("explain verbose"),$3);
9527 }
9528 | EXPLAIN '(' explain_option_list ')' ExplainableStmt
9529 {
9530 $$ = cat_str(4,mm_strdup("explain ("),$3,mm_strdup(")"),$5);
9531 }
9532 ;
9533
9534
9535 ExplainableStmt:
9536 SelectStmt
9537 {
9538 $$ = $1;
9539 }
9540 | InsertStmt
9541 {
9542 $$ = $1;
9543 }
9544 | UpdateStmt
9545 {
9546 $$ = $1;
9547 }
9548 | DeleteStmt
9549 {
9550 $$ = $1;
9551 }
9552 | DeclareCursorStmt
9553 {
9554 $$ = $1;
9555 }
9556 | CreateAsStmt
9557 {
9558 $$ = $1;
9559 }
9560 | CreateMatViewStmt
9561 {
9562 $$ = $1;
9563 }
9564 | RefreshMatViewStmt
9565 {
9566 $$ = $1;
9567 }
9568 | ExecuteStmt
9569 {
9570 $$ = $1.name;
9571 }
9572 ;
9573
9574
9575 explain_option_list:
9576 explain_option_elem
9577 {
9578 $$ = $1;
9579 }
9580 | explain_option_list ',' explain_option_elem
9581 {
9582 $$ = cat_str(3,$1,mm_strdup(","),$3);
9583 }
9584 ;
9585
9586
9587 explain_option_elem:
9588 explain_option_name explain_option_arg
9589 {
9590 $$ = cat_str(2,$1,$2);
9591 }
9592 ;
9593
9594
9595 explain_option_name:
9596 NonReservedWord
9597 {
9598 $$ = $1;
9599 }
9600 | analyze_keyword
9601 {
9602 $$ = $1;
9603 }
9604 ;
9605
9606
9607 explain_option_arg:
9608 opt_boolean_or_string
9609 {
9610 $$ = $1;
9611 }
9612 | NumericOnly
9613 {
9614 $$ = $1;
9615 }
9616 |
9617 {
9618 $$=EMPTY; }
9619 ;
9620
9621
9622 PrepareStmt:
9623 PREPARE prepared_name prep_type_clause AS PreparableStmt
9624 {
9625 $$.name = $2;
9626 $$.type = $3;
9627 $$.stmt = $5;
9628 }
9629 | PREPARE prepared_name FROM execstring
9630 {
9631 $$.name = $2;
9632 $$.type = NULL;
9633 $$.stmt = $4;
9634 }
9635 ;
9636
9637
9638 prep_type_clause:
9639 '(' type_list ')'
9640 {
9641 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
9642 }
9643 |
9644 {
9645 $$=EMPTY; }
9646 ;
9647
9648
9649 PreparableStmt:
9650 SelectStmt
9651 {
9652 $$ = $1;
9653 }
9654 | InsertStmt
9655 {
9656 $$ = $1;
9657 }
9658 | UpdateStmt
9659 {
9660 $$ = $1;
9661 }
9662 | DeleteStmt
9663 {
9664 $$ = $1;
9665 }
9666 ;
9667
9668
9669 ExecuteStmt:
9670 EXECUTE prepared_name execute_param_clause execute_rest
9671 {
9672 $$.name = $2;
9673 $$.type = $3;
9674 }
9675 | CREATE OptTemp TABLE create_as_target AS EXECUTE prepared_name execute_param_clause opt_with_data execute_rest
9676 {
9677 $$.name = cat_str(8,mm_strdup("create"),$2,mm_strdup("table"),$4,mm_strdup("as execute"),$7,$8,$9);
9678 }
9679 | CREATE OptTemp TABLE IF_P NOT EXISTS create_as_target AS EXECUTE prepared_name execute_param_clause opt_with_data execute_rest
9680 {
9681 $$.name = cat_str(8,mm_strdup("create"),$2,mm_strdup("table if not exists"),$7,mm_strdup("as execute"),$10,$11,$12);
9682 }
9683 ;
9684
9685
9686 execute_param_clause:
9687 '(' expr_list ')'
9688 {
9689 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
9690 }
9691 |
9692 {
9693 $$=EMPTY; }
9694 ;
9695
9696
9697 InsertStmt:
9698 opt_with_clause INSERT INTO insert_target insert_rest opt_on_conflict returning_clause
9699 {
9700 $$ = cat_str(6,$1,mm_strdup("insert into"),$4,$5,$6,$7);
9701 }
9702 ;
9703
9704
9705 insert_target:
9706 qualified_name
9707 {
9708 $$ = $1;
9709 }
9710 | qualified_name AS ColId
9711 {
9712 $$ = cat_str(3,$1,mm_strdup("as"),$3);
9713 }
9714 ;
9715
9716
9717 insert_rest:
9718 SelectStmt
9719 {
9720 $$ = $1;
9721 }
9722 | OVERRIDING override_kind VALUE_P SelectStmt
9723 {
9724 $$ = cat_str(4,mm_strdup("overriding"),$2,mm_strdup("value"),$4);
9725 }
9726 | '(' insert_column_list ')' SelectStmt
9727 {
9728 $$ = cat_str(4,mm_strdup("("),$2,mm_strdup(")"),$4);
9729 }
9730 | '(' insert_column_list ')' OVERRIDING override_kind VALUE_P SelectStmt
9731 {
9732 $$ = cat_str(6,mm_strdup("("),$2,mm_strdup(") overriding"),$5,mm_strdup("value"),$7);
9733 }
9734 | DEFAULT VALUES
9735 {
9736 $$ = mm_strdup("default values");
9737 }
9738 ;
9739
9740
9741 override_kind:
9742 USER
9743 {
9744 $$ = mm_strdup("user");
9745 }
9746 | SYSTEM_P
9747 {
9748 $$ = mm_strdup("system");
9749 }
9750 ;
9751
9752
9753 insert_column_list:
9754 insert_column_item
9755 {
9756 $$ = $1;
9757 }
9758 | insert_column_list ',' insert_column_item
9759 {
9760 $$ = cat_str(3,$1,mm_strdup(","),$3);
9761 }
9762 ;
9763
9764
9765 insert_column_item:
9766 ColId opt_indirection
9767 {
9768 $$ = cat_str(2,$1,$2);
9769 }
9770 ;
9771
9772
9773 opt_on_conflict:
9774 ON CONFLICT opt_conf_expr DO UPDATE SET set_clause_list where_clause
9775 {
9776 $$ = cat_str(5,mm_strdup("on conflict"),$3,mm_strdup("do update set"),$7,$8);
9777 }
9778 | ON CONFLICT opt_conf_expr DO NOTHING
9779 {
9780 $$ = cat_str(3,mm_strdup("on conflict"),$3,mm_strdup("do nothing"));
9781 }
9782 |
9783 {
9784 $$=EMPTY; }
9785 ;
9786
9787
9788 opt_conf_expr:
9789 '(' index_params ')' where_clause
9790 {
9791 $$ = cat_str(4,mm_strdup("("),$2,mm_strdup(")"),$4);
9792 }
9793 | ON CONSTRAINT name
9794 {
9795 $$ = cat_str(2,mm_strdup("on constraint"),$3);
9796 }
9797 |
9798 {
9799 $$=EMPTY; }
9800 ;
9801
9802
9803 returning_clause:
9804 RETURNING target_list opt_ecpg_into
9805 {
9806 $$ = cat_str(2,mm_strdup("returning"),$2);
9807 }
9808 |
9809 {
9810 $$=EMPTY; }
9811 ;
9812
9813
9814 DeleteStmt:
9815 opt_with_clause DELETE_P FROM relation_expr_opt_alias using_clause where_or_current_clause returning_clause
9816 {
9817 $$ = cat_str(6,$1,mm_strdup("delete from"),$4,$5,$6,$7);
9818 }
9819 ;
9820
9821
9822 using_clause:
9823 USING from_list
9824 {
9825 $$ = cat_str(2,mm_strdup("using"),$2);
9826 }
9827 |
9828 {
9829 $$=EMPTY; }
9830 ;
9831
9832
9833 LockStmt:
9834 LOCK_P opt_table relation_expr_list opt_lock opt_nowait
9835 {
9836 $$ = cat_str(5,mm_strdup("lock"),$2,$3,$4,$5);
9837 }
9838 ;
9839
9840
9841 opt_lock:
9842 IN_P lock_type MODE
9843 {
9844 $$ = cat_str(3,mm_strdup("in"),$2,mm_strdup("mode"));
9845 }
9846 |
9847 {
9848 $$=EMPTY; }
9849 ;
9850
9851
9852 lock_type:
9853 ACCESS SHARE
9854 {
9855 $$ = mm_strdup("access share");
9856 }
9857 | ROW SHARE
9858 {
9859 $$ = mm_strdup("row share");
9860 }
9861 | ROW EXCLUSIVE
9862 {
9863 $$ = mm_strdup("row exclusive");
9864 }
9865 | SHARE UPDATE EXCLUSIVE
9866 {
9867 $$ = mm_strdup("share update exclusive");
9868 }
9869 | SHARE
9870 {
9871 $$ = mm_strdup("share");
9872 }
9873 | SHARE ROW EXCLUSIVE
9874 {
9875 $$ = mm_strdup("share row exclusive");
9876 }
9877 | EXCLUSIVE
9878 {
9879 $$ = mm_strdup("exclusive");
9880 }
9881 | ACCESS EXCLUSIVE
9882 {
9883 $$ = mm_strdup("access exclusive");
9884 }
9885 ;
9886
9887
9888 opt_nowait:
9889 NOWAIT
9890 {
9891 $$ = mm_strdup("nowait");
9892 }
9893 |
9894 {
9895 $$=EMPTY; }
9896 ;
9897
9898
9899 opt_nowait_or_skip:
9900 NOWAIT
9901 {
9902 $$ = mm_strdup("nowait");
9903 }
9904 | SKIP LOCKED
9905 {
9906 $$ = mm_strdup("skip locked");
9907 }
9908 |
9909 {
9910 $$=EMPTY; }
9911 ;
9912
9913
9914 UpdateStmt:
9915 opt_with_clause UPDATE relation_expr_opt_alias SET set_clause_list from_clause where_or_current_clause returning_clause
9916 {
9917 $$ = cat_str(8,$1,mm_strdup("update"),$3,mm_strdup("set"),$5,$6,$7,$8);
9918 }
9919 ;
9920
9921
9922 set_clause_list:
9923 set_clause
9924 {
9925 $$ = $1;
9926 }
9927 | set_clause_list ',' set_clause
9928 {
9929 $$ = cat_str(3,$1,mm_strdup(","),$3);
9930 }
9931 ;
9932
9933
9934 set_clause:
9935 set_target '=' a_expr
9936 {
9937 $$ = cat_str(3,$1,mm_strdup("="),$3);
9938 }
9939 | '(' set_target_list ')' '=' a_expr
9940 {
9941 $$ = cat_str(4,mm_strdup("("),$2,mm_strdup(") ="),$5);
9942 }
9943 ;
9944
9945
9946 set_target:
9947 ColId opt_indirection
9948 {
9949 $$ = cat_str(2,$1,$2);
9950 }
9951 ;
9952
9953
9954 set_target_list:
9955 set_target
9956 {
9957 $$ = $1;
9958 }
9959 | set_target_list ',' set_target
9960 {
9961 $$ = cat_str(3,$1,mm_strdup(","),$3);
9962 }
9963 ;
9964
9965
9966 DeclareCursorStmt:
9967 DECLARE cursor_name cursor_options CURSOR opt_hold FOR SelectStmt
9968 {
9969 struct cursor *ptr, *this;
9970 char *cursor_marker = $2[0] == ':' ? mm_strdup("$0") : mm_strdup($2);
9971 char *comment, *c1, *c2;
9972 int (* strcmp_fn)(const char *, const char *) = (($2[0] == ':' || $2[0] == '"') ? strcmp : pg_strcasecmp);
9973
9974 for (ptr = cur; ptr != NULL; ptr = ptr->next)
9975 {
9976 if (strcmp_fn($2, ptr->name) == 0)
9977 {
9978 if ($2[0] == ':')
9979 mmerror(PARSE_ERROR, ET_ERROR, "using variable \"%s\" in different declare statements is not supported", $2+1);
9980 else
9981 mmerror(PARSE_ERROR, ET_ERROR, "cursor \"%s\" is already defined", $2);
9982 }
9983 }
9984
9985 this = (struct cursor *) mm_alloc(sizeof(struct cursor));
9986
9987 this->next = cur;
9988 this->name = $2;
9989 this->function = (current_function ? mm_strdup(current_function) : NULL);
9990 this->connection = connection;
9991 this->opened = false;
9992 this->command = cat_str(7, mm_strdup("declare"), cursor_marker, $3, mm_strdup("cursor"), $5, mm_strdup("for"), $7);
9993 this->argsinsert = argsinsert;
9994 this->argsinsert_oos = NULL;
9995 this->argsresult = argsresult;
9996 this->argsresult_oos = NULL;
9997 argsinsert = argsresult = NULL;
9998 cur = this;
9999
10000 c1 = mm_strdup(this->command);
10001 if ((c2 = strstr(c1, "*/")) != NULL)
10002 {
10003 /* We put this text into a comment, so we better remove [*][/]. */
10004 c2[0] = '.';
10005 c2[1] = '.';
10006 }
10007 comment = cat_str(3, mm_strdup("/*"), c1, mm_strdup("*/"));
10008
10009 $$ = cat2_str(adjust_outofscope_cursor_vars(this), comment);
10010 }
10011 ;
10012
10013
10014 cursor_name:
10015 name
10016 {
10017 $$ = $1;
10018 }
10019 | char_civar
10020 {
10021 char *curname = mm_alloc(strlen($1) + 2);
10022 sprintf(curname, ":%s", $1);
10023 free($1);
10024 $1 = curname;
10025 $$ = $1;
10026 }
10027 ;
10028
10029
10030 cursor_options:
10031
10032 {
10033 $$=EMPTY; }
10034 | cursor_options NO SCROLL
10035 {
10036 $$ = cat_str(2,$1,mm_strdup("no scroll"));
10037 }
10038 | cursor_options SCROLL
10039 {
10040 $$ = cat_str(2,$1,mm_strdup("scroll"));
10041 }
10042 | cursor_options BINARY
10043 {
10044 $$ = cat_str(2,$1,mm_strdup("binary"));
10045 }
10046 | cursor_options INSENSITIVE
10047 {
10048 $$ = cat_str(2,$1,mm_strdup("insensitive"));
10049 }
10050 ;
10051
10052
10053 opt_hold:
10054
10055 {
10056 if (compat == ECPG_COMPAT_INFORMIX_SE && autocommit)
10057 $$ = mm_strdup("with hold");
10058 else
10059 $$ = EMPTY;
10060 }
10061 | WITH HOLD
10062 {
10063 $$ = mm_strdup("with hold");
10064 }
10065 | WITHOUT HOLD
10066 {
10067 $$ = mm_strdup("without hold");
10068 }
10069 ;
10070
10071
10072 SelectStmt:
10073 select_no_parens %prec UMINUS
10074 {
10075 $$ = $1;
10076 }
10077 | select_with_parens %prec UMINUS
10078 {
10079 $$ = $1;
10080 }
10081 ;
10082
10083
10084 select_with_parens:
10085 '(' select_no_parens ')'
10086 {
10087 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
10088 }
10089 | '(' select_with_parens ')'
10090 {
10091 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
10092 }
10093 ;
10094
10095
10096 select_no_parens:
10097 simple_select
10098 {
10099 $$ = $1;
10100 }
10101 | select_clause sort_clause
10102 {
10103 $$ = cat_str(2,$1,$2);
10104 }
10105 | select_clause opt_sort_clause for_locking_clause opt_select_limit
10106 {
10107 $$ = cat_str(4,$1,$2,$3,$4);
10108 }
10109 | select_clause opt_sort_clause select_limit opt_for_locking_clause
10110 {
10111 $$ = cat_str(4,$1,$2,$3,$4);
10112 }
10113 | with_clause select_clause
10114 {
10115 $$ = cat_str(2,$1,$2);
10116 }
10117 | with_clause select_clause sort_clause
10118 {
10119 $$ = cat_str(3,$1,$2,$3);
10120 }
10121 | with_clause select_clause opt_sort_clause for_locking_clause opt_select_limit
10122 {
10123 $$ = cat_str(5,$1,$2,$3,$4,$5);
10124 }
10125 | with_clause select_clause opt_sort_clause select_limit opt_for_locking_clause
10126 {
10127 $$ = cat_str(5,$1,$2,$3,$4,$5);
10128 }
10129 ;
10130
10131
10132 select_clause:
10133 simple_select
10134 {
10135 $$ = $1;
10136 }
10137 | select_with_parens
10138 {
10139 $$ = $1;
10140 }
10141 ;
10142
10143
10144 simple_select:
10145 SELECT opt_all_clause opt_target_list into_clause from_clause where_clause group_clause having_clause window_clause
10146 {
10147 $$ = cat_str(9,mm_strdup("select"),$2,$3,$4,$5,$6,$7,$8,$9);
10148 }
10149 | SELECT distinct_clause target_list into_clause from_clause where_clause group_clause having_clause window_clause
10150 {
10151 $$ = cat_str(9,mm_strdup("select"),$2,$3,$4,$5,$6,$7,$8,$9);
10152 }
10153 | values_clause
10154 {
10155 $$ = $1;
10156 }
10157 | TABLE relation_expr
10158 {
10159 $$ = cat_str(2,mm_strdup("table"),$2);
10160 }
10161 | select_clause UNION all_or_distinct select_clause
10162 {
10163 $$ = cat_str(4,$1,mm_strdup("union"),$3,$4);
10164 }
10165 | select_clause INTERSECT all_or_distinct select_clause
10166 {
10167 $$ = cat_str(4,$1,mm_strdup("intersect"),$3,$4);
10168 }
10169 | select_clause EXCEPT all_or_distinct select_clause
10170 {
10171 $$ = cat_str(4,$1,mm_strdup("except"),$3,$4);
10172 }
10173 ;
10174
10175
10176 with_clause:
10177 WITH cte_list
10178 {
10179 $$ = cat_str(2,mm_strdup("with"),$2);
10180 }
10181 | WITH_LA cte_list
10182 {
10183 $$ = cat_str(2,mm_strdup("with"),$2);
10184 }
10185 | WITH RECURSIVE cte_list
10186 {
10187 $$ = cat_str(2,mm_strdup("with recursive"),$3);
10188 }
10189 ;
10190
10191
10192 cte_list:
10193 common_table_expr
10194 {
10195 $$ = $1;
10196 }
10197 | cte_list ',' common_table_expr
10198 {
10199 $$ = cat_str(3,$1,mm_strdup(","),$3);
10200 }
10201 ;
10202
10203
10204 common_table_expr:
10205 name opt_name_list AS opt_materialized '(' PreparableStmt ')'
10206 {
10207 $$ = cat_str(7,$1,$2,mm_strdup("as"),$4,mm_strdup("("),$6,mm_strdup(")"));
10208 }
10209 ;
10210
10211
10212 opt_materialized:
10213 MATERIALIZED
10214 {
10215 $$ = mm_strdup("materialized");
10216 }
10217 | NOT MATERIALIZED
10218 {
10219 $$ = mm_strdup("not materialized");
10220 }
10221 |
10222 {
10223 $$=EMPTY; }
10224 ;
10225
10226
10227 opt_with_clause:
10228 with_clause
10229 {
10230 $$ = $1;
10231 }
10232 |
10233 {
10234 $$=EMPTY; }
10235 ;
10236
10237
10238 into_clause:
10239 INTO OptTempTableName
10240 {
10241 FoundInto = 1;
10242 $$= cat2_str(mm_strdup("into"), $2);
10243 }
10244 | ecpg_into { $$ = EMPTY; }
10245 |
10246 {
10247 $$=EMPTY; }
10248 ;
10249
10250
10251 OptTempTableName:
10252 TEMPORARY opt_table qualified_name
10253 {
10254 $$ = cat_str(3,mm_strdup("temporary"),$2,$3);
10255 }
10256 | TEMP opt_table qualified_name
10257 {
10258 $$ = cat_str(3,mm_strdup("temp"),$2,$3);
10259 }
10260 | LOCAL TEMPORARY opt_table qualified_name
10261 {
10262 $$ = cat_str(3,mm_strdup("local temporary"),$3,$4);
10263 }
10264 | LOCAL TEMP opt_table qualified_name
10265 {
10266 $$ = cat_str(3,mm_strdup("local temp"),$3,$4);
10267 }
10268 | GLOBAL TEMPORARY opt_table qualified_name
10269 {
10270 $$ = cat_str(3,mm_strdup("global temporary"),$3,$4);
10271 }
10272 | GLOBAL TEMP opt_table qualified_name
10273 {
10274 $$ = cat_str(3,mm_strdup("global temp"),$3,$4);
10275 }
10276 | UNLOGGED opt_table qualified_name
10277 {
10278 $$ = cat_str(3,mm_strdup("unlogged"),$2,$3);
10279 }
10280 | TABLE qualified_name
10281 {
10282 $$ = cat_str(2,mm_strdup("table"),$2);
10283 }
10284 | qualified_name
10285 {
10286 $$ = $1;
10287 }
10288 ;
10289
10290
10291 opt_table:
10292 TABLE
10293 {
10294 $$ = mm_strdup("table");
10295 }
10296 |
10297 {
10298 $$=EMPTY; }
10299 ;
10300
10301
10302 all_or_distinct:
10303 ALL
10304 {
10305 $$ = mm_strdup("all");
10306 }
10307 | DISTINCT
10308 {
10309 $$ = mm_strdup("distinct");
10310 }
10311 |
10312 {
10313 $$=EMPTY; }
10314 ;
10315
10316
10317 distinct_clause:
10318 DISTINCT
10319 {
10320 $$ = mm_strdup("distinct");
10321 }
10322 | DISTINCT ON '(' expr_list ')'
10323 {
10324 $$ = cat_str(3,mm_strdup("distinct on ("),$4,mm_strdup(")"));
10325 }
10326 ;
10327
10328
10329 opt_all_clause:
10330 ALL
10331 {
10332 $$ = mm_strdup("all");
10333 }
10334 |
10335 {
10336 $$=EMPTY; }
10337 ;
10338
10339
10340 opt_sort_clause:
10341 sort_clause
10342 {
10343 $$ = $1;
10344 }
10345 |
10346 {
10347 $$=EMPTY; }
10348 ;
10349
10350
10351 sort_clause:
10352 ORDER BY sortby_list
10353 {
10354 $$ = cat_str(2,mm_strdup("order by"),$3);
10355 }
10356 ;
10357
10358
10359 sortby_list:
10360 sortby
10361 {
10362 $$ = $1;
10363 }
10364 | sortby_list ',' sortby
10365 {
10366 $$ = cat_str(3,$1,mm_strdup(","),$3);
10367 }
10368 ;
10369
10370
10371 sortby:
10372 a_expr USING qual_all_Op opt_nulls_order
10373 {
10374 $$ = cat_str(4,$1,mm_strdup("using"),$3,$4);
10375 }
10376 | a_expr opt_asc_desc opt_nulls_order
10377 {
10378 $$ = cat_str(3,$1,$2,$3);
10379 }
10380 ;
10381
10382
10383 select_limit:
10384 limit_clause offset_clause
10385 {
10386 $$ = cat_str(2,$1,$2);
10387 }
10388 | offset_clause limit_clause
10389 {
10390 $$ = cat_str(2,$1,$2);
10391 }
10392 | limit_clause
10393 {
10394 $$ = $1;
10395 }
10396 | offset_clause
10397 {
10398 $$ = $1;
10399 }
10400 ;
10401
10402
10403 opt_select_limit:
10404 select_limit
10405 {
10406 $$ = $1;
10407 }
10408 |
10409 {
10410 $$=EMPTY; }
10411 ;
10412
10413
10414 limit_clause:
10415 LIMIT select_limit_value
10416 {
10417 $$ = cat_str(2,mm_strdup("limit"),$2);
10418 }
10419 | LIMIT select_limit_value ',' select_offset_value
10420 {
10421 mmerror(PARSE_ERROR, ET_WARNING, "no longer supported LIMIT #,# syntax passed to server");
10422 $$ = cat_str(4, mm_strdup("limit"), $2, mm_strdup(","), $4);
10423 }
10424 | FETCH first_or_next select_fetch_first_value row_or_rows ONLY
10425 {
10426 $$ = cat_str(5,mm_strdup("fetch"),$2,$3,$4,mm_strdup("only"));
10427 }
10428 | FETCH first_or_next row_or_rows ONLY
10429 {
10430 $$ = cat_str(4,mm_strdup("fetch"),$2,$3,mm_strdup("only"));
10431 }
10432 ;
10433
10434
10435 offset_clause:
10436 OFFSET select_offset_value
10437 {
10438 $$ = cat_str(2,mm_strdup("offset"),$2);
10439 }
10440 | OFFSET select_fetch_first_value row_or_rows
10441 {
10442 $$ = cat_str(3,mm_strdup("offset"),$2,$3);
10443 }
10444 ;
10445
10446
10447 select_limit_value:
10448 a_expr
10449 {
10450 $$ = $1;
10451 }
10452 | ALL
10453 {
10454 $$ = mm_strdup("all");
10455 }
10456 ;
10457
10458
10459 select_offset_value:
10460 a_expr
10461 {
10462 $$ = $1;
10463 }
10464 ;
10465
10466
10467 select_fetch_first_value:
10468 c_expr
10469 {
10470 $$ = $1;
10471 }
10472 | '+' I_or_F_const
10473 {
10474 $$ = cat_str(2,mm_strdup("+"),$2);
10475 }
10476 | '-' I_or_F_const
10477 {
10478 $$ = cat_str(2,mm_strdup("-"),$2);
10479 }
10480 ;
10481
10482
10483 I_or_F_const:
10484 Iconst
10485 {
10486 $$ = $1;
10487 }
10488 | ecpg_fconst
10489 {
10490 $$ = $1;
10491 }
10492 ;
10493
10494
10495 row_or_rows:
10496 ROW
10497 {
10498 $$ = mm_strdup("row");
10499 }
10500 | ROWS
10501 {
10502 $$ = mm_strdup("rows");
10503 }
10504 ;
10505
10506
10507 first_or_next:
10508 FIRST_P
10509 {
10510 $$ = mm_strdup("first");
10511 }
10512 | NEXT
10513 {
10514 $$ = mm_strdup("next");
10515 }
10516 ;
10517
10518
10519 group_clause:
10520 GROUP_P BY group_by_list
10521 {
10522 $$ = cat_str(2,mm_strdup("group by"),$3);
10523 }
10524 |
10525 {
10526 $$=EMPTY; }
10527 ;
10528
10529
10530 group_by_list:
10531 group_by_item
10532 {
10533 $$ = $1;
10534 }
10535 | group_by_list ',' group_by_item
10536 {
10537 $$ = cat_str(3,$1,mm_strdup(","),$3);
10538 }
10539 ;
10540
10541
10542 group_by_item:
10543 a_expr
10544 {
10545 $$ = $1;
10546 }
10547 | empty_grouping_set
10548 {
10549 $$ = $1;
10550 }
10551 | cube_clause
10552 {
10553 $$ = $1;
10554 }
10555 | rollup_clause
10556 {
10557 $$ = $1;
10558 }
10559 | grouping_sets_clause
10560 {
10561 $$ = $1;
10562 }
10563 ;
10564
10565
10566 empty_grouping_set:
10567 '(' ')'
10568 {
10569 $$ = mm_strdup("( )");
10570 }
10571 ;
10572
10573
10574 rollup_clause:
10575 ROLLUP '(' expr_list ')'
10576 {
10577 $$ = cat_str(3,mm_strdup("rollup ("),$3,mm_strdup(")"));
10578 }
10579 ;
10580
10581
10582 cube_clause:
10583 CUBE '(' expr_list ')'
10584 {
10585 $$ = cat_str(3,mm_strdup("cube ("),$3,mm_strdup(")"));
10586 }
10587 ;
10588
10589
10590 grouping_sets_clause:
10591 GROUPING SETS '(' group_by_list ')'
10592 {
10593 $$ = cat_str(3,mm_strdup("grouping sets ("),$4,mm_strdup(")"));
10594 }
10595 ;
10596
10597
10598 having_clause:
10599 HAVING a_expr
10600 {
10601 $$ = cat_str(2,mm_strdup("having"),$2);
10602 }
10603 |
10604 {
10605 $$=EMPTY; }
10606 ;
10607
10608
10609 for_locking_clause:
10610 for_locking_items
10611 {
10612 $$ = $1;
10613 }
10614 | FOR READ ONLY
10615 {
10616 $$ = mm_strdup("for read only");
10617 }
10618 ;
10619
10620
10621 opt_for_locking_clause:
10622 for_locking_clause
10623 {
10624 $$ = $1;
10625 }
10626 |
10627 {
10628 $$=EMPTY; }
10629 ;
10630
10631
10632 for_locking_items:
10633 for_locking_item
10634 {
10635 $$ = $1;
10636 }
10637 | for_locking_items for_locking_item
10638 {
10639 $$ = cat_str(2,$1,$2);
10640 }
10641 ;
10642
10643
10644 for_locking_item:
10645 for_locking_strength locked_rels_list opt_nowait_or_skip
10646 {
10647 $$ = cat_str(3,$1,$2,$3);
10648 }
10649 ;
10650
10651
10652 for_locking_strength:
10653 FOR UPDATE
10654 {
10655 $$ = mm_strdup("for update");
10656 }
10657 | FOR NO KEY UPDATE
10658 {
10659 $$ = mm_strdup("for no key update");
10660 }
10661 | FOR SHARE
10662 {
10663 $$ = mm_strdup("for share");
10664 }
10665 | FOR KEY SHARE
10666 {
10667 $$ = mm_strdup("for key share");
10668 }
10669 ;
10670
10671
10672 locked_rels_list:
10673 OF qualified_name_list
10674 {
10675 $$ = cat_str(2,mm_strdup("of"),$2);
10676 }
10677 |
10678 {
10679 $$=EMPTY; }
10680 ;
10681
10682
10683 values_clause:
10684 VALUES '(' expr_list ')'
10685 {
10686 $$ = cat_str(3,mm_strdup("values ("),$3,mm_strdup(")"));
10687 }
10688 | values_clause ',' '(' expr_list ')'
10689 {
10690 $$ = cat_str(4,$1,mm_strdup(", ("),$4,mm_strdup(")"));
10691 }
10692 ;
10693
10694
10695 from_clause:
10696 FROM from_list
10697 {
10698 $$ = cat_str(2,mm_strdup("from"),$2);
10699 }
10700 |
10701 {
10702 $$=EMPTY; }
10703 ;
10704
10705
10706 from_list:
10707 table_ref
10708 {
10709 $$ = $1;
10710 }
10711 | from_list ',' table_ref
10712 {
10713 $$ = cat_str(3,$1,mm_strdup(","),$3);
10714 }
10715 ;
10716
10717
10718 table_ref:
10719 relation_expr opt_alias_clause
10720 {
10721 $$ = cat_str(2,$1,$2);
10722 }
10723 | relation_expr opt_alias_clause tablesample_clause
10724 {
10725 $$ = cat_str(3,$1,$2,$3);
10726 }
10727 | func_table func_alias_clause
10728 {
10729 $$ = cat_str(2,$1,$2);
10730 }
10731 | LATERAL_P func_table func_alias_clause
10732 {
10733 $$ = cat_str(3,mm_strdup("lateral"),$2,$3);
10734 }
10735 | xmltable opt_alias_clause
10736 {
10737 $$ = cat_str(2,$1,$2);
10738 }
10739 | LATERAL_P xmltable opt_alias_clause
10740 {
10741 $$ = cat_str(3,mm_strdup("lateral"),$2,$3);
10742 }
10743 | select_with_parens opt_alias_clause
10744 {
10745 if ($2 == NULL)
10746 mmerror(PARSE_ERROR, ET_ERROR, "subquery in FROM must have an alias");
10747
10748 $$ = cat_str(2,$1,$2);
10749 }
10750 | LATERAL_P select_with_parens opt_alias_clause
10751 {
10752 if ($3 == NULL)
10753 mmerror(PARSE_ERROR, ET_ERROR, "subquery in FROM must have an alias");
10754
10755 $$ = cat_str(3,mm_strdup("lateral"),$2,$3);
10756 }
10757 | joined_table
10758 {
10759 $$ = $1;
10760 }
10761 | '(' joined_table ')' alias_clause
10762 {
10763 $$ = cat_str(4,mm_strdup("("),$2,mm_strdup(")"),$4);
10764 }
10765 ;
10766
10767
10768 joined_table:
10769 '(' joined_table ')'
10770 {
10771 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
10772 }
10773 | table_ref CROSS JOIN table_ref
10774 {
10775 $$ = cat_str(3,$1,mm_strdup("cross join"),$4);
10776 }
10777 | table_ref join_type JOIN table_ref join_qual
10778 {
10779 $$ = cat_str(5,$1,$2,mm_strdup("join"),$4,$5);
10780 }
10781 | table_ref JOIN table_ref join_qual
10782 {
10783 $$ = cat_str(4,$1,mm_strdup("join"),$3,$4);
10784 }
10785 | table_ref NATURAL join_type JOIN table_ref
10786 {
10787 $$ = cat_str(5,$1,mm_strdup("natural"),$3,mm_strdup("join"),$5);
10788 }
10789 | table_ref NATURAL JOIN table_ref
10790 {
10791 $$ = cat_str(3,$1,mm_strdup("natural join"),$4);
10792 }
10793 ;
10794
10795
10796 alias_clause:
10797 AS ColId '(' name_list ')'
10798 {
10799 $$ = cat_str(5,mm_strdup("as"),$2,mm_strdup("("),$4,mm_strdup(")"));
10800 }
10801 | AS ColId
10802 {
10803 $$ = cat_str(2,mm_strdup("as"),$2);
10804 }
10805 | ColId '(' name_list ')'
10806 {
10807 $$ = cat_str(4,$1,mm_strdup("("),$3,mm_strdup(")"));
10808 }
10809 | ColId
10810 {
10811 $$ = $1;
10812 }
10813 ;
10814
10815
10816 opt_alias_clause:
10817 alias_clause
10818 {
10819 $$ = $1;
10820 }
10821 |
10822 {
10823 $$=EMPTY; }
10824 ;
10825
10826
10827 func_alias_clause:
10828 alias_clause
10829 {
10830 $$ = $1;
10831 }
10832 | AS '(' TableFuncElementList ')'
10833 {
10834 $$ = cat_str(3,mm_strdup("as ("),$3,mm_strdup(")"));
10835 }
10836 | AS ColId '(' TableFuncElementList ')'
10837 {
10838 $$ = cat_str(5,mm_strdup("as"),$2,mm_strdup("("),$4,mm_strdup(")"));
10839 }
10840 | ColId '(' TableFuncElementList ')'
10841 {
10842 $$ = cat_str(4,$1,mm_strdup("("),$3,mm_strdup(")"));
10843 }
10844 |
10845 {
10846 $$=EMPTY; }
10847 ;
10848
10849
10850 join_type:
10851 FULL join_outer
10852 {
10853 $$ = cat_str(2,mm_strdup("full"),$2);
10854 }
10855 | LEFT join_outer
10856 {
10857 $$ = cat_str(2,mm_strdup("left"),$2);
10858 }
10859 | RIGHT join_outer
10860 {
10861 $$ = cat_str(2,mm_strdup("right"),$2);
10862 }
10863 | INNER_P
10864 {
10865 $$ = mm_strdup("inner");
10866 }
10867 ;
10868
10869
10870 join_outer:
10871 OUTER_P
10872 {
10873 $$ = mm_strdup("outer");
10874 }
10875 |
10876 {
10877 $$=EMPTY; }
10878 ;
10879
10880
10881 join_qual:
10882 USING '(' name_list ')'
10883 {
10884 $$ = cat_str(3,mm_strdup("using ("),$3,mm_strdup(")"));
10885 }
10886 | ON a_expr
10887 {
10888 $$ = cat_str(2,mm_strdup("on"),$2);
10889 }
10890 ;
10891
10892
10893 relation_expr:
10894 qualified_name
10895 {
10896 $$ = $1;
10897 }
10898 | qualified_name '*'
10899 {
10900 $$ = cat_str(2,$1,mm_strdup("*"));
10901 }
10902 | ONLY qualified_name
10903 {
10904 $$ = cat_str(2,mm_strdup("only"),$2);
10905 }
10906 | ONLY '(' qualified_name ')'
10907 {
10908 $$ = cat_str(3,mm_strdup("only ("),$3,mm_strdup(")"));
10909 }
10910 ;
10911
10912
10913 relation_expr_list:
10914 relation_expr
10915 {
10916 $$ = $1;
10917 }
10918 | relation_expr_list ',' relation_expr
10919 {
10920 $$ = cat_str(3,$1,mm_strdup(","),$3);
10921 }
10922 ;
10923
10924
10925 relation_expr_opt_alias:
10926 relation_expr %prec UMINUS
10927 {
10928 $$ = $1;
10929 }
10930 | relation_expr ColId
10931 {
10932 $$ = cat_str(2,$1,$2);
10933 }
10934 | relation_expr AS ColId
10935 {
10936 $$ = cat_str(3,$1,mm_strdup("as"),$3);
10937 }
10938 ;
10939
10940
10941 tablesample_clause:
10942 TABLESAMPLE func_name '(' expr_list ')' opt_repeatable_clause
10943 {
10944 $$ = cat_str(6,mm_strdup("tablesample"),$2,mm_strdup("("),$4,mm_strdup(")"),$6);
10945 }
10946 ;
10947
10948
10949 opt_repeatable_clause:
10950 REPEATABLE '(' a_expr ')'
10951 {
10952 $$ = cat_str(3,mm_strdup("repeatable ("),$3,mm_strdup(")"));
10953 }
10954 |
10955 {
10956 $$=EMPTY; }
10957 ;
10958
10959
10960 func_table:
10961 func_expr_windowless opt_ordinality
10962 {
10963 $$ = cat_str(2,$1,$2);
10964 }
10965 | ROWS FROM '(' rowsfrom_list ')' opt_ordinality
10966 {
10967 $$ = cat_str(4,mm_strdup("rows from ("),$4,mm_strdup(")"),$6);
10968 }
10969 ;
10970
10971
10972 rowsfrom_item:
10973 func_expr_windowless opt_col_def_list
10974 {
10975 $$ = cat_str(2,$1,$2);
10976 }
10977 ;
10978
10979
10980 rowsfrom_list:
10981 rowsfrom_item
10982 {
10983 $$ = $1;
10984 }
10985 | rowsfrom_list ',' rowsfrom_item
10986 {
10987 $$ = cat_str(3,$1,mm_strdup(","),$3);
10988 }
10989 ;
10990
10991
10992 opt_col_def_list:
10993 AS '(' TableFuncElementList ')'
10994 {
10995 $$ = cat_str(3,mm_strdup("as ("),$3,mm_strdup(")"));
10996 }
10997 |
10998 {
10999 $$=EMPTY; }
11000 ;
11001
11002
11003 opt_ordinality:
11004 WITH_LA ORDINALITY
11005 {
11006 $$ = mm_strdup("with ordinality");
11007 }
11008 |
11009 {
11010 $$=EMPTY; }
11011 ;
11012
11013
11014 where_clause:
11015 WHERE a_expr
11016 {
11017 $$ = cat_str(2,mm_strdup("where"),$2);
11018 }
11019 |
11020 {
11021 $$=EMPTY; }
11022 ;
11023
11024
11025 where_or_current_clause:
11026 WHERE a_expr
11027 {
11028 $$ = cat_str(2,mm_strdup("where"),$2);
11029 }
11030 | WHERE CURRENT_P OF cursor_name
11031 {
11032 char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
11033 $$ = cat_str(2,mm_strdup("where current of"), cursor_marker);
11034 }
11035 |
11036 {
11037 $$=EMPTY; }
11038 ;
11039
11040
11041 OptTableFuncElementList:
11042 TableFuncElementList
11043 {
11044 $$ = $1;
11045 }
11046 |
11047 {
11048 $$=EMPTY; }
11049 ;
11050
11051
11052 TableFuncElementList:
11053 TableFuncElement
11054 {
11055 $$ = $1;
11056 }
11057 | TableFuncElementList ',' TableFuncElement
11058 {
11059 $$ = cat_str(3,$1,mm_strdup(","),$3);
11060 }
11061 ;
11062
11063
11064 TableFuncElement:
11065 ColId Typename opt_collate_clause
11066 {
11067 $$ = cat_str(3,$1,$2,$3);
11068 }
11069 ;
11070
11071
11072 xmltable:
11073 XMLTABLE '(' c_expr xmlexists_argument COLUMNS xmltable_column_list ')'
11074 {
11075 $$ = cat_str(6,mm_strdup("xmltable ("),$3,$4,mm_strdup("columns"),$6,mm_strdup(")"));
11076 }
11077 | XMLTABLE '(' XMLNAMESPACES '(' xml_namespace_list ')' ',' c_expr xmlexists_argument COLUMNS xmltable_column_list ')'
11078 {
11079 $$ = cat_str(8,mm_strdup("xmltable ( xmlnamespaces ("),$5,mm_strdup(") ,"),$8,$9,mm_strdup("columns"),$11,mm_strdup(")"));
11080 }
11081 ;
11082
11083
11084 xmltable_column_list:
11085 xmltable_column_el
11086 {
11087 $$ = $1;
11088 }
11089 | xmltable_column_list ',' xmltable_column_el
11090 {
11091 $$ = cat_str(3,$1,mm_strdup(","),$3);
11092 }
11093 ;
11094
11095
11096 xmltable_column_el:
11097 ColId Typename
11098 {
11099 $$ = cat_str(2,$1,$2);
11100 }
11101 | ColId Typename xmltable_column_option_list
11102 {
11103 $$ = cat_str(3,$1,$2,$3);
11104 }
11105 | ColId FOR ORDINALITY
11106 {
11107 $$ = cat_str(2,$1,mm_strdup("for ordinality"));
11108 }
11109 ;
11110
11111
11112 xmltable_column_option_list:
11113 xmltable_column_option_el
11114 {
11115 $$ = $1;
11116 }
11117 | xmltable_column_option_list xmltable_column_option_el
11118 {
11119 $$ = cat_str(2,$1,$2);
11120 }
11121 ;
11122
11123
11124 xmltable_column_option_el:
11125 ecpg_ident b_expr
11126 {
11127 $$ = cat_str(2,$1,$2);
11128 }
11129 | DEFAULT b_expr
11130 {
11131 $$ = cat_str(2,mm_strdup("default"),$2);
11132 }
11133 | NOT NULL_P
11134 {
11135 $$ = mm_strdup("not null");
11136 }
11137 | NULL_P
11138 {
11139 $$ = mm_strdup("null");
11140 }
11141 ;
11142
11143
11144 xml_namespace_list:
11145 xml_namespace_el
11146 {
11147 $$ = $1;
11148 }
11149 | xml_namespace_list ',' xml_namespace_el
11150 {
11151 $$ = cat_str(3,$1,mm_strdup(","),$3);
11152 }
11153 ;
11154
11155
11156 xml_namespace_el:
11157 b_expr AS ColLabel
11158 {
11159 $$ = cat_str(3,$1,mm_strdup("as"),$3);
11160 }
11161 | DEFAULT b_expr
11162 {
11163 $$ = cat_str(2,mm_strdup("default"),$2);
11164 }
11165 ;
11166
11167
11168 Typename:
11169 SimpleTypename opt_array_bounds
11170 { $$ = cat2_str($1, $2.str); }
11171 | SETOF SimpleTypename opt_array_bounds
11172 { $$ = cat_str(3, mm_strdup("setof"), $2, $3.str); }
11173 | SimpleTypename ARRAY '[' Iconst ']'
11174 {
11175 $$ = cat_str(4,$1,mm_strdup("array ["),$4,mm_strdup("]"));
11176 }
11177 | SETOF SimpleTypename ARRAY '[' Iconst ']'
11178 {
11179 $$ = cat_str(5,mm_strdup("setof"),$2,mm_strdup("array ["),$5,mm_strdup("]"));
11180 }
11181 | SimpleTypename ARRAY
11182 {
11183 $$ = cat_str(2,$1,mm_strdup("array"));
11184 }
11185 | SETOF SimpleTypename ARRAY
11186 {
11187 $$ = cat_str(3,mm_strdup("setof"),$2,mm_strdup("array"));
11188 }
11189 ;
11190
11191
11192 opt_array_bounds:
11193 opt_array_bounds '[' ']'
11194 {
11195 $$.index1 = $1.index1;
11196 $$.index2 = $1.index2;
11197 if (strcmp($$.index1, "-1") == 0)
11198 $$.index1 = mm_strdup("0");
11199 else if (strcmp($1.index2, "-1") == 0)
11200 $$.index2 = mm_strdup("0");
11201 $$.str = cat_str(2, $1.str, mm_strdup("[]"));
11202 }
11203 | opt_array_bounds '[' Iresult ']'
11204 {
11205 $$.index1 = $1.index1;
11206 $$.index2 = $1.index2;
11207 if (strcmp($1.index1, "-1") == 0)
11208 $$.index1 = mm_strdup($3);
11209 else if (strcmp($1.index2, "-1") == 0)
11210 $$.index2 = mm_strdup($3);
11211 $$.str = cat_str(4, $1.str, mm_strdup("["), $3, mm_strdup("]"));
11212 }
11213 |
11214 {
11215 $$.index1 = mm_strdup("-1");
11216 $$.index2 = mm_strdup("-1");
11217 $$.str= EMPTY;
11218 }
11219 ;
11220
11221
11222 SimpleTypename:
11223 GenericType
11224 {
11225 $$ = $1;
11226 }
11227 | Numeric
11228 {
11229 $$ = $1;
11230 }
11231 | Bit
11232 {
11233 $$ = $1;
11234 }
11235 | Character
11236 {
11237 $$ = $1;
11238 }
11239 | ConstDatetime
11240 {
11241 $$ = $1;
11242 }
11243 | ConstInterval opt_interval
11244 {
11245 $$ = cat_str(2,$1,$2);
11246 }
11247 | ConstInterval '(' Iconst ')'
11248 {
11249 $$ = cat_str(4,$1,mm_strdup("("),$3,mm_strdup(")"));
11250 }
11251 ;
11252
11253
11254 ConstTypename:
11255 Numeric
11256 {
11257 $$ = $1;
11258 }
11259 | ConstBit
11260 {
11261 $$ = $1;
11262 }
11263 | ConstCharacter
11264 {
11265 $$ = $1;
11266 }
11267 | ConstDatetime
11268 {
11269 $$ = $1;
11270 }
11271 ;
11272
11273
11274 GenericType:
11275 type_function_name opt_type_modifiers
11276 {
11277 $$ = cat_str(2,$1,$2);
11278 }
11279 | type_function_name attrs opt_type_modifiers
11280 {
11281 $$ = cat_str(3,$1,$2,$3);
11282 }
11283 ;
11284
11285
11286 opt_type_modifiers:
11287 '(' expr_list ')'
11288 {
11289 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
11290 }
11291 |
11292 {
11293 $$=EMPTY; }
11294 ;
11295
11296
11297 Numeric:
11298 INT_P
11299 {
11300 $$ = mm_strdup("int");
11301 }
11302 | INTEGER
11303 {
11304 $$ = mm_strdup("integer");
11305 }
11306 | SMALLINT
11307 {
11308 $$ = mm_strdup("smallint");
11309 }
11310 | BIGINT
11311 {
11312 $$ = mm_strdup("bigint");
11313 }
11314 | REAL
11315 {
11316 $$ = mm_strdup("real");
11317 }
11318 | FLOAT_P opt_float
11319 {
11320 $$ = cat_str(2,mm_strdup("float"),$2);
11321 }
11322 | DOUBLE_P PRECISION
11323 {
11324 $$ = mm_strdup("double precision");
11325 }
11326 | DECIMAL_P opt_type_modifiers
11327 {
11328 $$ = cat_str(2,mm_strdup("decimal"),$2);
11329 }
11330 | DEC opt_type_modifiers
11331 {
11332 $$ = cat_str(2,mm_strdup("dec"),$2);
11333 }
11334 | NUMERIC opt_type_modifiers
11335 {
11336 $$ = cat_str(2,mm_strdup("numeric"),$2);
11337 }
11338 | BOOLEAN_P
11339 {
11340 $$ = mm_strdup("boolean");
11341 }
11342 ;
11343
11344
11345 opt_float:
11346 '(' Iconst ')'
11347 {
11348 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
11349 }
11350 |
11351 {
11352 $$=EMPTY; }
11353 ;
11354
11355
11356 Bit:
11357 BitWithLength
11358 {
11359 $$ = $1;
11360 }
11361 | BitWithoutLength
11362 {
11363 $$ = $1;
11364 }
11365 ;
11366
11367
11368 ConstBit:
11369 BitWithLength
11370 {
11371 $$ = $1;
11372 }
11373 | BitWithoutLength
11374 {
11375 $$ = $1;
11376 }
11377 ;
11378
11379
11380 BitWithLength:
11381 BIT opt_varying '(' expr_list ')'
11382 {
11383 $$ = cat_str(5,mm_strdup("bit"),$2,mm_strdup("("),$4,mm_strdup(")"));
11384 }
11385 ;
11386
11387
11388 BitWithoutLength:
11389 BIT opt_varying
11390 {
11391 $$ = cat_str(2,mm_strdup("bit"),$2);
11392 }
11393 ;
11394
11395
11396 Character:
11397 CharacterWithLength
11398 {
11399 $$ = $1;
11400 }
11401 | CharacterWithoutLength
11402 {
11403 $$ = $1;
11404 }
11405 ;
11406
11407
11408 ConstCharacter:
11409 CharacterWithLength
11410 {
11411 $$ = $1;
11412 }
11413 | CharacterWithoutLength
11414 {
11415 $$ = $1;
11416 }
11417 ;
11418
11419
11420 CharacterWithLength:
11421 character '(' Iconst ')'
11422 {
11423 $$ = cat_str(4,$1,mm_strdup("("),$3,mm_strdup(")"));
11424 }
11425 ;
11426
11427
11428 CharacterWithoutLength:
11429 character
11430 {
11431 $$ = $1;
11432 }
11433 ;
11434
11435
11436 character:
11437 CHARACTER opt_varying
11438 {
11439 $$ = cat_str(2,mm_strdup("character"),$2);
11440 }
11441 | CHAR_P opt_varying
11442 {
11443 $$ = cat_str(2,mm_strdup("char"),$2);
11444 }
11445 | VARCHAR
11446 {
11447 $$ = mm_strdup("varchar");
11448 }
11449 | NATIONAL CHARACTER opt_varying
11450 {
11451 $$ = cat_str(2,mm_strdup("national character"),$3);
11452 }
11453 | NATIONAL CHAR_P opt_varying
11454 {
11455 $$ = cat_str(2,mm_strdup("national char"),$3);
11456 }
11457 | NCHAR opt_varying
11458 {
11459 $$ = cat_str(2,mm_strdup("nchar"),$2);
11460 }
11461 ;
11462
11463
11464 opt_varying:
11465 VARYING
11466 {
11467 $$ = mm_strdup("varying");
11468 }
11469 |
11470 {
11471 $$=EMPTY; }
11472 ;
11473
11474
11475 ConstDatetime:
11476 TIMESTAMP '(' Iconst ')' opt_timezone
11477 {
11478 $$ = cat_str(4,mm_strdup("timestamp ("),$3,mm_strdup(")"),$5);
11479 }
11480 | TIMESTAMP opt_timezone
11481 {
11482 $$ = cat_str(2,mm_strdup("timestamp"),$2);
11483 }
11484 | TIME '(' Iconst ')' opt_timezone
11485 {
11486 $$ = cat_str(4,mm_strdup("time ("),$3,mm_strdup(")"),$5);
11487 }
11488 | TIME opt_timezone
11489 {
11490 $$ = cat_str(2,mm_strdup("time"),$2);
11491 }
11492 ;
11493
11494
11495 ConstInterval:
11496 INTERVAL
11497 {
11498 $$ = mm_strdup("interval");
11499 }
11500 ;
11501
11502
11503 opt_timezone:
11504 WITH_LA TIME ZONE
11505 {
11506 $$ = mm_strdup("with time zone");
11507 }
11508 | WITHOUT TIME ZONE
11509 {
11510 $$ = mm_strdup("without time zone");
11511 }
11512 |
11513 {
11514 $$=EMPTY; }
11515 ;
11516
11517
11518 opt_interval:
11519 YEAR_P
11520 {
11521 $$ = mm_strdup("year");
11522 }
11523 | MONTH_P
11524 {
11525 $$ = mm_strdup("month");
11526 }
11527 | DAY_P
11528 {
11529 $$ = mm_strdup("day");
11530 }
11531 | HOUR_P
11532 {
11533 $$ = mm_strdup("hour");
11534 }
11535 | MINUTE_P
11536 {
11537 $$ = mm_strdup("minute");
11538 }
11539 | interval_second
11540 {
11541 $$ = $1;
11542 }
11543 | YEAR_P TO MONTH_P
11544 {
11545 $$ = mm_strdup("year to month");
11546 }
11547 | DAY_P TO HOUR_P
11548 {
11549 $$ = mm_strdup("day to hour");
11550 }
11551 | DAY_P TO MINUTE_P
11552 {
11553 $$ = mm_strdup("day to minute");
11554 }
11555 | DAY_P TO interval_second
11556 {
11557 $$ = cat_str(2,mm_strdup("day to"),$3);
11558 }
11559 | HOUR_P TO MINUTE_P
11560 {
11561 $$ = mm_strdup("hour to minute");
11562 }
11563 | HOUR_P TO interval_second
11564 {
11565 $$ = cat_str(2,mm_strdup("hour to"),$3);
11566 }
11567 | MINUTE_P TO interval_second
11568 {
11569 $$ = cat_str(2,mm_strdup("minute to"),$3);
11570 }
11571 |
11572 {
11573 $$=EMPTY; }
11574 ;
11575
11576
11577 interval_second:
11578 SECOND_P
11579 {
11580 $$ = mm_strdup("second");
11581 }
11582 | SECOND_P '(' Iconst ')'
11583 {
11584 $$ = cat_str(3,mm_strdup("second ("),$3,mm_strdup(")"));
11585 }
11586 ;
11587
11588
11589 a_expr:
11590 c_expr
11591 {
11592 $$ = $1;
11593 }
11594 | a_expr TYPECAST Typename
11595 {
11596 $$ = cat_str(3,$1,mm_strdup("::"),$3);
11597 }
11598 | a_expr COLLATE any_name
11599 {
11600 $$ = cat_str(3,$1,mm_strdup("collate"),$3);
11601 }
11602 | a_expr AT TIME ZONE a_expr %prec AT
11603 {
11604 $$ = cat_str(3,$1,mm_strdup("at time zone"),$5);
11605 }
11606 | '+' a_expr %prec UMINUS
11607 {
11608 $$ = cat_str(2,mm_strdup("+"),$2);
11609 }
11610 | '-' a_expr %prec UMINUS
11611 {
11612 $$ = cat_str(2,mm_strdup("-"),$2);
11613 }
11614 | a_expr '+' a_expr
11615 {
11616 $$ = cat_str(3,$1,mm_strdup("+"),$3);
11617 }
11618 | a_expr '-' a_expr
11619 {
11620 $$ = cat_str(3,$1,mm_strdup("-"),$3);
11621 }
11622 | a_expr '*' a_expr
11623 {
11624 $$ = cat_str(3,$1,mm_strdup("*"),$3);
11625 }
11626 | a_expr '/' a_expr
11627 {
11628 $$ = cat_str(3,$1,mm_strdup("/"),$3);
11629 }
11630 | a_expr '%' a_expr
11631 {
11632 $$ = cat_str(3,$1,mm_strdup("%"),$3);
11633 }
11634 | a_expr '^' a_expr
11635 {
11636 $$ = cat_str(3,$1,mm_strdup("^"),$3);
11637 }
11638 | a_expr '<' a_expr
11639 {
11640 $$ = cat_str(3,$1,mm_strdup("<"),$3);
11641 }
11642 | a_expr '>' a_expr
11643 {
11644 $$ = cat_str(3,$1,mm_strdup(">"),$3);
11645 }
11646 | a_expr '=' a_expr
11647 {
11648 $$ = cat_str(3,$1,mm_strdup("="),$3);
11649 }
11650 | a_expr LESS_EQUALS a_expr
11651 {
11652 $$ = cat_str(3,$1,mm_strdup("<="),$3);
11653 }
11654 | a_expr GREATER_EQUALS a_expr
11655 {
11656 $$ = cat_str(3,$1,mm_strdup(">="),$3);
11657 }
11658 | a_expr NOT_EQUALS a_expr
11659 {
11660 $$ = cat_str(3,$1,mm_strdup("<>"),$3);
11661 }
11662 | a_expr qual_Op a_expr %prec Op
11663 {
11664 $$ = cat_str(3,$1,$2,$3);
11665 }
11666 | qual_Op a_expr %prec Op
11667 {
11668 $$ = cat_str(2,$1,$2);
11669 }
11670 | a_expr qual_Op %prec POSTFIXOP
11671 {
11672 $$ = cat_str(2,$1,$2);
11673 }
11674 | a_expr AND a_expr
11675 {
11676 $$ = cat_str(3,$1,mm_strdup("and"),$3);
11677 }
11678 | a_expr OR a_expr
11679 {
11680 $$ = cat_str(3,$1,mm_strdup("or"),$3);
11681 }
11682 | NOT a_expr
11683 {
11684 $$ = cat_str(2,mm_strdup("not"),$2);
11685 }
11686 | NOT_LA a_expr %prec NOT
11687 {
11688 $$ = cat_str(2,mm_strdup("not"),$2);
11689 }
11690 | a_expr LIKE a_expr
11691 {
11692 $$ = cat_str(3,$1,mm_strdup("like"),$3);
11693 }
11694 | a_expr LIKE a_expr ESCAPE a_expr %prec LIKE
11695 {
11696 $$ = cat_str(5,$1,mm_strdup("like"),$3,mm_strdup("escape"),$5);
11697 }
11698 | a_expr NOT_LA LIKE a_expr %prec NOT_LA
11699 {
11700 $$ = cat_str(3,$1,mm_strdup("not like"),$4);
11701 }
11702 | a_expr NOT_LA LIKE a_expr ESCAPE a_expr %prec NOT_LA
11703 {
11704 $$ = cat_str(5,$1,mm_strdup("not like"),$4,mm_strdup("escape"),$6);
11705 }
11706 | a_expr ILIKE a_expr
11707 {
11708 $$ = cat_str(3,$1,mm_strdup("ilike"),$3);
11709 }
11710 | a_expr ILIKE a_expr ESCAPE a_expr %prec ILIKE
11711 {
11712 $$ = cat_str(5,$1,mm_strdup("ilike"),$3,mm_strdup("escape"),$5);
11713 }
11714 | a_expr NOT_LA ILIKE a_expr %prec NOT_LA
11715 {
11716 $$ = cat_str(3,$1,mm_strdup("not ilike"),$4);
11717 }
11718 | a_expr NOT_LA ILIKE a_expr ESCAPE a_expr %prec NOT_LA
11719 {
11720 $$ = cat_str(5,$1,mm_strdup("not ilike"),$4,mm_strdup("escape"),$6);
11721 }
11722 | a_expr SIMILAR TO a_expr %prec SIMILAR
11723 {
11724 $$ = cat_str(3,$1,mm_strdup("similar to"),$4);
11725 }
11726 | a_expr SIMILAR TO a_expr ESCAPE a_expr %prec SIMILAR
11727 {
11728 $$ = cat_str(5,$1,mm_strdup("similar to"),$4,mm_strdup("escape"),$6);
11729 }
11730 | a_expr NOT_LA SIMILAR TO a_expr %prec NOT_LA
11731 {
11732 $$ = cat_str(3,$1,mm_strdup("not similar to"),$5);
11733 }
11734 | a_expr NOT_LA SIMILAR TO a_expr ESCAPE a_expr %prec NOT_LA
11735 {
11736 $$ = cat_str(5,$1,mm_strdup("not similar to"),$5,mm_strdup("escape"),$7);
11737 }
11738 | a_expr IS NULL_P %prec IS
11739 {
11740 $$ = cat_str(2,$1,mm_strdup("is null"));
11741 }
11742 | a_expr ISNULL
11743 {
11744 $$ = cat_str(2,$1,mm_strdup("isnull"));
11745 }
11746 | a_expr IS NOT NULL_P %prec IS
11747 {
11748 $$ = cat_str(2,$1,mm_strdup("is not null"));
11749 }
11750 | a_expr NOTNULL
11751 {
11752 $$ = cat_str(2,$1,mm_strdup("notnull"));
11753 }
11754 | row OVERLAPS row
11755 {
11756 $$ = cat_str(3,$1,mm_strdup("overlaps"),$3);
11757 }
11758 | a_expr IS TRUE_P %prec IS
11759 {
11760 $$ = cat_str(2,$1,mm_strdup("is true"));
11761 }
11762 | a_expr IS NOT TRUE_P %prec IS
11763 {
11764 $$ = cat_str(2,$1,mm_strdup("is not true"));
11765 }
11766 | a_expr IS FALSE_P %prec IS
11767 {
11768 $$ = cat_str(2,$1,mm_strdup("is false"));
11769 }
11770 | a_expr IS NOT FALSE_P %prec IS
11771 {
11772 $$ = cat_str(2,$1,mm_strdup("is not false"));
11773 }
11774 | a_expr IS UNKNOWN %prec IS
11775 {
11776 $$ = cat_str(2,$1,mm_strdup("is unknown"));
11777 }
11778 | a_expr IS NOT UNKNOWN %prec IS
11779 {
11780 $$ = cat_str(2,$1,mm_strdup("is not unknown"));
11781 }
11782 | a_expr IS DISTINCT FROM a_expr %prec IS
11783 {
11784 $$ = cat_str(3,$1,mm_strdup("is distinct from"),$5);
11785 }
11786 | a_expr IS NOT DISTINCT FROM a_expr %prec IS
11787 {
11788 $$ = cat_str(3,$1,mm_strdup("is not distinct from"),$6);
11789 }
11790 | a_expr IS OF '(' type_list ')' %prec IS
11791 {
11792 $$ = cat_str(4,$1,mm_strdup("is of ("),$5,mm_strdup(")"));
11793 }
11794 | a_expr IS NOT OF '(' type_list ')' %prec IS
11795 {
11796 $$ = cat_str(4,$1,mm_strdup("is not of ("),$6,mm_strdup(")"));
11797 }
11798 | a_expr BETWEEN opt_asymmetric b_expr AND a_expr %prec BETWEEN
11799 {
11800 $$ = cat_str(6,$1,mm_strdup("between"),$3,$4,mm_strdup("and"),$6);
11801 }
11802 | a_expr NOT_LA BETWEEN opt_asymmetric b_expr AND a_expr %prec NOT_LA
11803 {
11804 $$ = cat_str(6,$1,mm_strdup("not between"),$4,$5,mm_strdup("and"),$7);
11805 }
11806 | a_expr BETWEEN SYMMETRIC b_expr AND a_expr %prec BETWEEN
11807 {
11808 $$ = cat_str(5,$1,mm_strdup("between symmetric"),$4,mm_strdup("and"),$6);
11809 }
11810 | a_expr NOT_LA BETWEEN SYMMETRIC b_expr AND a_expr %prec NOT_LA
11811 {
11812 $$ = cat_str(5,$1,mm_strdup("not between symmetric"),$5,mm_strdup("and"),$7);
11813 }
11814 | a_expr IN_P in_expr
11815 {
11816 $$ = cat_str(3,$1,mm_strdup("in"),$3);
11817 }
11818 | a_expr NOT_LA IN_P in_expr %prec NOT_LA
11819 {
11820 $$ = cat_str(3,$1,mm_strdup("not in"),$4);
11821 }
11822 | a_expr subquery_Op sub_type select_with_parens %prec Op
11823 {
11824 $$ = cat_str(4,$1,$2,$3,$4);
11825 }
11826 | a_expr subquery_Op sub_type '(' a_expr ')' %prec Op
11827 {
11828 $$ = cat_str(6,$1,$2,$3,mm_strdup("("),$5,mm_strdup(")"));
11829 }
11830 | UNIQUE select_with_parens
11831 {
11832 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
11833 $$ = cat_str(2,mm_strdup("unique"),$2);
11834 }
11835 | a_expr IS DOCUMENT_P %prec IS
11836 {
11837 $$ = cat_str(2,$1,mm_strdup("is document"));
11838 }
11839 | a_expr IS NOT DOCUMENT_P %prec IS
11840 {
11841 $$ = cat_str(2,$1,mm_strdup("is not document"));
11842 }
11843 | DEFAULT
11844 {
11845 $$ = mm_strdup("default");
11846 }
11847 ;
11848
11849
11850 b_expr:
11851 c_expr
11852 {
11853 $$ = $1;
11854 }
11855 | b_expr TYPECAST Typename
11856 {
11857 $$ = cat_str(3,$1,mm_strdup("::"),$3);
11858 }
11859 | '+' b_expr %prec UMINUS
11860 {
11861 $$ = cat_str(2,mm_strdup("+"),$2);
11862 }
11863 | '-' b_expr %prec UMINUS
11864 {
11865 $$ = cat_str(2,mm_strdup("-"),$2);
11866 }
11867 | b_expr '+' b_expr
11868 {
11869 $$ = cat_str(3,$1,mm_strdup("+"),$3);
11870 }
11871 | b_expr '-' b_expr
11872 {
11873 $$ = cat_str(3,$1,mm_strdup("-"),$3);
11874 }
11875 | b_expr '*' b_expr
11876 {
11877 $$ = cat_str(3,$1,mm_strdup("*"),$3);
11878 }
11879 | b_expr '/' b_expr
11880 {
11881 $$ = cat_str(3,$1,mm_strdup("/"),$3);
11882 }
11883 | b_expr '%' b_expr
11884 {
11885 $$ = cat_str(3,$1,mm_strdup("%"),$3);
11886 }
11887 | b_expr '^' b_expr
11888 {
11889 $$ = cat_str(3,$1,mm_strdup("^"),$3);
11890 }
11891 | b_expr '<' b_expr
11892 {
11893 $$ = cat_str(3,$1,mm_strdup("<"),$3);
11894 }
11895 | b_expr '>' b_expr
11896 {
11897 $$ = cat_str(3,$1,mm_strdup(">"),$3);
11898 }
11899 | b_expr '=' b_expr
11900 {
11901 $$ = cat_str(3,$1,mm_strdup("="),$3);
11902 }
11903 | b_expr LESS_EQUALS b_expr
11904 {
11905 $$ = cat_str(3,$1,mm_strdup("<="),$3);
11906 }
11907 | b_expr GREATER_EQUALS b_expr
11908 {
11909 $$ = cat_str(3,$1,mm_strdup(">="),$3);
11910 }
11911 | b_expr NOT_EQUALS b_expr
11912 {
11913 $$ = cat_str(3,$1,mm_strdup("<>"),$3);
11914 }
11915 | b_expr qual_Op b_expr %prec Op
11916 {
11917 $$ = cat_str(3,$1,$2,$3);
11918 }
11919 | qual_Op b_expr %prec Op
11920 {
11921 $$ = cat_str(2,$1,$2);
11922 }
11923 | b_expr qual_Op %prec POSTFIXOP
11924 {
11925 $$ = cat_str(2,$1,$2);
11926 }
11927 | b_expr IS DISTINCT FROM b_expr %prec IS
11928 {
11929 $$ = cat_str(3,$1,mm_strdup("is distinct from"),$5);
11930 }
11931 | b_expr IS NOT DISTINCT FROM b_expr %prec IS
11932 {
11933 $$ = cat_str(3,$1,mm_strdup("is not distinct from"),$6);
11934 }
11935 | b_expr IS OF '(' type_list ')' %prec IS
11936 {
11937 $$ = cat_str(4,$1,mm_strdup("is of ("),$5,mm_strdup(")"));
11938 }
11939 | b_expr IS NOT OF '(' type_list ')' %prec IS
11940 {
11941 $$ = cat_str(4,$1,mm_strdup("is not of ("),$6,mm_strdup(")"));
11942 }
11943 | b_expr IS DOCUMENT_P %prec IS
11944 {
11945 $$ = cat_str(2,$1,mm_strdup("is document"));
11946 }
11947 | b_expr IS NOT DOCUMENT_P %prec IS
11948 {
11949 $$ = cat_str(2,$1,mm_strdup("is not document"));
11950 }
11951 ;
11952
11953
11954 c_expr:
11955 columnref
11956 {
11957 $$ = $1;
11958 }
11959 | AexprConst
11960 {
11961 $$ = $1;
11962 }
11963 | ecpg_param opt_indirection
11964 {
11965 $$ = cat_str(2,$1,$2);
11966 }
11967 | '(' a_expr ')' opt_indirection
11968 {
11969 $$ = cat_str(4,mm_strdup("("),$2,mm_strdup(")"),$4);
11970 }
11971 | case_expr
11972 {
11973 $$ = $1;
11974 }
11975 | func_expr
11976 {
11977 $$ = $1;
11978 }
11979 | select_with_parens %prec UMINUS
11980 {
11981 $$ = $1;
11982 }
11983 | select_with_parens indirection
11984 {
11985 $$ = cat_str(2,$1,$2);
11986 }
11987 | EXISTS select_with_parens
11988 {
11989 $$ = cat_str(2,mm_strdup("exists"),$2);
11990 }
11991 | ARRAY select_with_parens
11992 {
11993 $$ = cat_str(2,mm_strdup("array"),$2);
11994 }
11995 | ARRAY array_expr
11996 {
11997 $$ = cat_str(2,mm_strdup("array"),$2);
11998 }
11999 | explicit_row
12000 {
12001 $$ = $1;
12002 }
12003 | implicit_row
12004 {
12005 $$ = $1;
12006 }
12007 | GROUPING '(' expr_list ')'
12008 {
12009 $$ = cat_str(3,mm_strdup("grouping ("),$3,mm_strdup(")"));
12010 }
12011 ;
12012
12013
12014 func_application:
12015 func_name '(' ')'
12016 {
12017 $$ = cat_str(2,$1,mm_strdup("( )"));
12018 }
12019 | func_name '(' func_arg_list opt_sort_clause ')'
12020 {
12021 $$ = cat_str(5,$1,mm_strdup("("),$3,$4,mm_strdup(")"));
12022 }
12023 | func_name '(' VARIADIC func_arg_expr opt_sort_clause ')'
12024 {
12025 $$ = cat_str(5,$1,mm_strdup("( variadic"),$4,$5,mm_strdup(")"));
12026 }
12027 | func_name '(' func_arg_list ',' VARIADIC func_arg_expr opt_sort_clause ')'
12028 {
12029 $$ = cat_str(7,$1,mm_strdup("("),$3,mm_strdup(", variadic"),$6,$7,mm_strdup(")"));
12030 }
12031 | func_name '(' ALL func_arg_list opt_sort_clause ')'
12032 {
12033 $$ = cat_str(5,$1,mm_strdup("( all"),$4,$5,mm_strdup(")"));
12034 }
12035 | func_name '(' DISTINCT func_arg_list opt_sort_clause ')'
12036 {
12037 $$ = cat_str(5,$1,mm_strdup("( distinct"),$4,$5,mm_strdup(")"));
12038 }
12039 | func_name '(' '*' ')'
12040 {
12041 $$ = cat_str(2,$1,mm_strdup("( * )"));
12042 }
12043 ;
12044
12045
12046 func_expr:
12047 func_application within_group_clause filter_clause over_clause
12048 {
12049 $$ = cat_str(4,$1,$2,$3,$4);
12050 }
12051 | func_expr_common_subexpr
12052 {
12053 $$ = $1;
12054 }
12055 ;
12056
12057
12058 func_expr_windowless:
12059 func_application
12060 {
12061 $$ = $1;
12062 }
12063 | func_expr_common_subexpr
12064 {
12065 $$ = $1;
12066 }
12067 ;
12068
12069
12070 func_expr_common_subexpr:
12071 COLLATION FOR '(' a_expr ')'
12072 {
12073 $$ = cat_str(3,mm_strdup("collation for ("),$4,mm_strdup(")"));
12074 }
12075 | CURRENT_DATE
12076 {
12077 $$ = mm_strdup("current_date");
12078 }
12079 | CURRENT_TIME
12080 {
12081 $$ = mm_strdup("current_time");
12082 }
12083 | CURRENT_TIME '(' Iconst ')'
12084 {
12085 $$ = cat_str(3,mm_strdup("current_time ("),$3,mm_strdup(")"));
12086 }
12087 | CURRENT_TIMESTAMP
12088 {
12089 $$ = mm_strdup("current_timestamp");
12090 }
12091 | CURRENT_TIMESTAMP '(' Iconst ')'
12092 {
12093 $$ = cat_str(3,mm_strdup("current_timestamp ("),$3,mm_strdup(")"));
12094 }
12095 | LOCALTIME
12096 {
12097 $$ = mm_strdup("localtime");
12098 }
12099 | LOCALTIME '(' Iconst ')'
12100 {
12101 $$ = cat_str(3,mm_strdup("localtime ("),$3,mm_strdup(")"));
12102 }
12103 | LOCALTIMESTAMP
12104 {
12105 $$ = mm_strdup("localtimestamp");
12106 }
12107 | LOCALTIMESTAMP '(' Iconst ')'
12108 {
12109 $$ = cat_str(3,mm_strdup("localtimestamp ("),$3,mm_strdup(")"));
12110 }
12111 | CURRENT_ROLE
12112 {
12113 $$ = mm_strdup("current_role");
12114 }
12115 | CURRENT_USER
12116 {
12117 $$ = mm_strdup("current_user");
12118 }
12119 | SESSION_USER
12120 {
12121 $$ = mm_strdup("session_user");
12122 }
12123 | USER
12124 {
12125 $$ = mm_strdup("user");
12126 }
12127 | CURRENT_CATALOG
12128 {
12129 $$ = mm_strdup("current_catalog");
12130 }
12131 | CURRENT_SCHEMA
12132 {
12133 $$ = mm_strdup("current_schema");
12134 }
12135 | CAST '(' a_expr AS Typename ')'
12136 {
12137 $$ = cat_str(5,mm_strdup("cast ("),$3,mm_strdup("as"),$5,mm_strdup(")"));
12138 }
12139 | EXTRACT '(' extract_list ')'
12140 {
12141 $$ = cat_str(3,mm_strdup("extract ("),$3,mm_strdup(")"));
12142 }
12143 | OVERLAY '(' overlay_list ')'
12144 {
12145 $$ = cat_str(3,mm_strdup("overlay ("),$3,mm_strdup(")"));
12146 }
12147 | POSITION '(' position_list ')'
12148 {
12149 $$ = cat_str(3,mm_strdup("position ("),$3,mm_strdup(")"));
12150 }
12151 | SUBSTRING '(' substr_list ')'
12152 {
12153 $$ = cat_str(3,mm_strdup("substring ("),$3,mm_strdup(")"));
12154 }
12155 | TREAT '(' a_expr AS Typename ')'
12156 {
12157 $$ = cat_str(5,mm_strdup("treat ("),$3,mm_strdup("as"),$5,mm_strdup(")"));
12158 }
12159 | TRIM '(' BOTH trim_list ')'
12160 {
12161 $$ = cat_str(3,mm_strdup("trim ( both"),$4,mm_strdup(")"));
12162 }
12163 | TRIM '(' LEADING trim_list ')'
12164 {
12165 $$ = cat_str(3,mm_strdup("trim ( leading"),$4,mm_strdup(")"));
12166 }
12167 | TRIM '(' TRAILING trim_list ')'
12168 {
12169 $$ = cat_str(3,mm_strdup("trim ( trailing"),$4,mm_strdup(")"));
12170 }
12171 | TRIM '(' trim_list ')'
12172 {
12173 $$ = cat_str(3,mm_strdup("trim ("),$3,mm_strdup(")"));
12174 }
12175 | NULLIF '(' a_expr ',' a_expr ')'
12176 {
12177 $$ = cat_str(5,mm_strdup("nullif ("),$3,mm_strdup(","),$5,mm_strdup(")"));
12178 }
12179 | COALESCE '(' expr_list ')'
12180 {
12181 $$ = cat_str(3,mm_strdup("coalesce ("),$3,mm_strdup(")"));
12182 }
12183 | GREATEST '(' expr_list ')'
12184 {
12185 $$ = cat_str(3,mm_strdup("greatest ("),$3,mm_strdup(")"));
12186 }
12187 | LEAST '(' expr_list ')'
12188 {
12189 $$ = cat_str(3,mm_strdup("least ("),$3,mm_strdup(")"));
12190 }
12191 | XMLCONCAT '(' expr_list ')'
12192 {
12193 $$ = cat_str(3,mm_strdup("xmlconcat ("),$3,mm_strdup(")"));
12194 }
12195 | XMLELEMENT '(' NAME_P ColLabel ')'
12196 {
12197 $$ = cat_str(3,mm_strdup("xmlelement ( name"),$4,mm_strdup(")"));
12198 }
12199 | XMLELEMENT '(' NAME_P ColLabel ',' xml_attributes ')'
12200 {
12201 $$ = cat_str(5,mm_strdup("xmlelement ( name"),$4,mm_strdup(","),$6,mm_strdup(")"));
12202 }
12203 | XMLELEMENT '(' NAME_P ColLabel ',' expr_list ')'
12204 {
12205 $$ = cat_str(5,mm_strdup("xmlelement ( name"),$4,mm_strdup(","),$6,mm_strdup(")"));
12206 }
12207 | XMLELEMENT '(' NAME_P ColLabel ',' xml_attributes ',' expr_list ')'
12208 {
12209 $$ = cat_str(7,mm_strdup("xmlelement ( name"),$4,mm_strdup(","),$6,mm_strdup(","),$8,mm_strdup(")"));
12210 }
12211 | XMLEXISTS '(' c_expr xmlexists_argument ')'
12212 {
12213 $$ = cat_str(4,mm_strdup("xmlexists ("),$3,$4,mm_strdup(")"));
12214 }
12215 | XMLFOREST '(' xml_attribute_list ')'
12216 {
12217 $$ = cat_str(3,mm_strdup("xmlforest ("),$3,mm_strdup(")"));
12218 }
12219 | XMLPARSE '(' document_or_content a_expr xml_whitespace_option ')'
12220 {
12221 $$ = cat_str(5,mm_strdup("xmlparse ("),$3,$4,$5,mm_strdup(")"));
12222 }
12223 | XMLPI '(' NAME_P ColLabel ')'
12224 {
12225 $$ = cat_str(3,mm_strdup("xmlpi ( name"),$4,mm_strdup(")"));
12226 }
12227 | XMLPI '(' NAME_P ColLabel ',' a_expr ')'
12228 {
12229 $$ = cat_str(5,mm_strdup("xmlpi ( name"),$4,mm_strdup(","),$6,mm_strdup(")"));
12230 }
12231 | XMLROOT '(' a_expr ',' xml_root_version opt_xml_root_standalone ')'
12232 {
12233 $$ = cat_str(6,mm_strdup("xmlroot ("),$3,mm_strdup(","),$5,$6,mm_strdup(")"));
12234 }
12235 | XMLSERIALIZE '(' document_or_content a_expr AS SimpleTypename ')'
12236 {
12237 $$ = cat_str(6,mm_strdup("xmlserialize ("),$3,$4,mm_strdup("as"),$6,mm_strdup(")"));
12238 }
12239 ;
12240
12241
12242 xml_root_version:
12243 VERSION_P a_expr
12244 {
12245 $$ = cat_str(2,mm_strdup("version"),$2);
12246 }
12247 | VERSION_P NO VALUE_P
12248 {
12249 $$ = mm_strdup("version no value");
12250 }
12251 ;
12252
12253
12254 opt_xml_root_standalone:
12255 ',' STANDALONE_P YES_P
12256 {
12257 $$ = mm_strdup(", standalone yes");
12258 }
12259 | ',' STANDALONE_P NO
12260 {
12261 $$ = mm_strdup(", standalone no");
12262 }
12263 | ',' STANDALONE_P NO VALUE_P
12264 {
12265 $$ = mm_strdup(", standalone no value");
12266 }
12267 |
12268 {
12269 $$=EMPTY; }
12270 ;
12271
12272
12273 xml_attributes:
12274 XMLATTRIBUTES '(' xml_attribute_list ')'
12275 {
12276 $$ = cat_str(3,mm_strdup("xmlattributes ("),$3,mm_strdup(")"));
12277 }
12278 ;
12279
12280
12281 xml_attribute_list:
12282 xml_attribute_el
12283 {
12284 $$ = $1;
12285 }
12286 | xml_attribute_list ',' xml_attribute_el
12287 {
12288 $$ = cat_str(3,$1,mm_strdup(","),$3);
12289 }
12290 ;
12291
12292
12293 xml_attribute_el:
12294 a_expr AS ColLabel
12295 {
12296 $$ = cat_str(3,$1,mm_strdup("as"),$3);
12297 }
12298 | a_expr
12299 {
12300 $$ = $1;
12301 }
12302 ;
12303
12304
12305 document_or_content:
12306 DOCUMENT_P
12307 {
12308 $$ = mm_strdup("document");
12309 }
12310 | CONTENT_P
12311 {
12312 $$ = mm_strdup("content");
12313 }
12314 ;
12315
12316
12317 xml_whitespace_option:
12318 PRESERVE WHITESPACE_P
12319 {
12320 $$ = mm_strdup("preserve whitespace");
12321 }
12322 | STRIP_P WHITESPACE_P
12323 {
12324 $$ = mm_strdup("strip whitespace");
12325 }
12326 |
12327 {
12328 $$=EMPTY; }
12329 ;
12330
12331
12332 xmlexists_argument:
12333 PASSING c_expr
12334 {
12335 $$ = cat_str(2,mm_strdup("passing"),$2);
12336 }
12337 | PASSING c_expr xml_passing_mech
12338 {
12339 $$ = cat_str(3,mm_strdup("passing"),$2,$3);
12340 }
12341 | PASSING xml_passing_mech c_expr
12342 {
12343 $$ = cat_str(3,mm_strdup("passing"),$2,$3);
12344 }
12345 | PASSING xml_passing_mech c_expr xml_passing_mech
12346 {
12347 $$ = cat_str(4,mm_strdup("passing"),$2,$3,$4);
12348 }
12349 ;
12350
12351
12352 xml_passing_mech:
12353 BY REF
12354 {
12355 $$ = mm_strdup("by ref");
12356 }
12357 | BY VALUE_P
12358 {
12359 $$ = mm_strdup("by value");
12360 }
12361 ;
12362
12363
12364 within_group_clause:
12365 WITHIN GROUP_P '(' sort_clause ')'
12366 {
12367 $$ = cat_str(3,mm_strdup("within group ("),$4,mm_strdup(")"));
12368 }
12369 |
12370 {
12371 $$=EMPTY; }
12372 ;
12373
12374
12375 filter_clause:
12376 FILTER '(' WHERE a_expr ')'
12377 {
12378 $$ = cat_str(3,mm_strdup("filter ( where"),$4,mm_strdup(")"));
12379 }
12380 |
12381 {
12382 $$=EMPTY; }
12383 ;
12384
12385
12386 window_clause:
12387 WINDOW window_definition_list
12388 {
12389 $$ = cat_str(2,mm_strdup("window"),$2);
12390 }
12391 |
12392 {
12393 $$=EMPTY; }
12394 ;
12395
12396
12397 window_definition_list:
12398 window_definition
12399 {
12400 $$ = $1;
12401 }
12402 | window_definition_list ',' window_definition
12403 {
12404 $$ = cat_str(3,$1,mm_strdup(","),$3);
12405 }
12406 ;
12407
12408
12409 window_definition:
12410 ColId AS window_specification
12411 {
12412 $$ = cat_str(3,$1,mm_strdup("as"),$3);
12413 }
12414 ;
12415
12416
12417 over_clause:
12418 OVER window_specification
12419 {
12420 $$ = cat_str(2,mm_strdup("over"),$2);
12421 }
12422 | OVER ColId
12423 {
12424 $$ = cat_str(2,mm_strdup("over"),$2);
12425 }
12426 |
12427 {
12428 $$=EMPTY; }
12429 ;
12430
12431
12432 window_specification:
12433 '(' opt_existing_window_name opt_partition_clause opt_sort_clause opt_frame_clause ')'
12434 {
12435 $$ = cat_str(6,mm_strdup("("),$2,$3,$4,$5,mm_strdup(")"));
12436 }
12437 ;
12438
12439
12440 opt_existing_window_name:
12441 ColId
12442 {
12443 $$ = $1;
12444 }
12445 | %prec Op
12446 {
12447 $$=EMPTY; }
12448 ;
12449
12450
12451 opt_partition_clause:
12452 PARTITION BY expr_list
12453 {
12454 $$ = cat_str(2,mm_strdup("partition by"),$3);
12455 }
12456 |
12457 {
12458 $$=EMPTY; }
12459 ;
12460
12461
12462 opt_frame_clause:
12463 RANGE frame_extent opt_window_exclusion_clause
12464 {
12465 $$ = cat_str(3,mm_strdup("range"),$2,$3);
12466 }
12467 | ROWS frame_extent opt_window_exclusion_clause
12468 {
12469 $$ = cat_str(3,mm_strdup("rows"),$2,$3);
12470 }
12471 | GROUPS frame_extent opt_window_exclusion_clause
12472 {
12473 $$ = cat_str(3,mm_strdup("groups"),$2,$3);
12474 }
12475 |
12476 {
12477 $$=EMPTY; }
12478 ;
12479
12480
12481 frame_extent:
12482 frame_bound
12483 {
12484 $$ = $1;
12485 }
12486 | BETWEEN frame_bound AND frame_bound
12487 {
12488 $$ = cat_str(4,mm_strdup("between"),$2,mm_strdup("and"),$4);
12489 }
12490 ;
12491
12492
12493 frame_bound:
12494 UNBOUNDED PRECEDING
12495 {
12496 $$ = mm_strdup("unbounded preceding");
12497 }
12498 | UNBOUNDED FOLLOWING
12499 {
12500 $$ = mm_strdup("unbounded following");
12501 }
12502 | CURRENT_P ROW
12503 {
12504 $$ = mm_strdup("current row");
12505 }
12506 | a_expr PRECEDING
12507 {
12508 $$ = cat_str(2,$1,mm_strdup("preceding"));
12509 }
12510 | a_expr FOLLOWING
12511 {
12512 $$ = cat_str(2,$1,mm_strdup("following"));
12513 }
12514 ;
12515
12516
12517 opt_window_exclusion_clause:
12518 EXCLUDE CURRENT_P ROW
12519 {
12520 $$ = mm_strdup("exclude current row");
12521 }
12522 | EXCLUDE GROUP_P
12523 {
12524 $$ = mm_strdup("exclude group");
12525 }
12526 | EXCLUDE TIES
12527 {
12528 $$ = mm_strdup("exclude ties");
12529 }
12530 | EXCLUDE NO OTHERS
12531 {
12532 $$ = mm_strdup("exclude no others");
12533 }
12534 |
12535 {
12536 $$=EMPTY; }
12537 ;
12538
12539
12540 row:
12541 ROW '(' expr_list ')'
12542 {
12543 $$ = cat_str(3,mm_strdup("row ("),$3,mm_strdup(")"));
12544 }
12545 | ROW '(' ')'
12546 {
12547 $$ = mm_strdup("row ( )");
12548 }
12549 | '(' expr_list ',' a_expr ')'
12550 {
12551 $$ = cat_str(5,mm_strdup("("),$2,mm_strdup(","),$4,mm_strdup(")"));
12552 }
12553 ;
12554
12555
12556 explicit_row:
12557 ROW '(' expr_list ')'
12558 {
12559 $$ = cat_str(3,mm_strdup("row ("),$3,mm_strdup(")"));
12560 }
12561 | ROW '(' ')'
12562 {
12563 $$ = mm_strdup("row ( )");
12564 }
12565 ;
12566
12567
12568 implicit_row:
12569 '(' expr_list ',' a_expr ')'
12570 {
12571 $$ = cat_str(5,mm_strdup("("),$2,mm_strdup(","),$4,mm_strdup(")"));
12572 }
12573 ;
12574
12575
12576 sub_type:
12577 ANY
12578 {
12579 $$ = mm_strdup("any");
12580 }
12581 | SOME
12582 {
12583 $$ = mm_strdup("some");
12584 }
12585 | ALL
12586 {
12587 $$ = mm_strdup("all");
12588 }
12589 ;
12590
12591
12592 all_Op:
12593 Op
12594 {
12595 $$ = $1;
12596 }
12597 | MathOp
12598 {
12599 $$ = $1;
12600 }
12601 ;
12602
12603
12604 MathOp:
12605 '+'
12606 {
12607 $$ = mm_strdup("+");
12608 }
12609 | '-'
12610 {
12611 $$ = mm_strdup("-");
12612 }
12613 | '*'
12614 {
12615 $$ = mm_strdup("*");
12616 }
12617 | '/'
12618 {
12619 $$ = mm_strdup("/");
12620 }
12621 | '%'
12622 {
12623 $$ = mm_strdup("%");
12624 }
12625 | '^'
12626 {
12627 $$ = mm_strdup("^");
12628 }
12629 | '<'
12630 {
12631 $$ = mm_strdup("<");
12632 }
12633 | '>'
12634 {
12635 $$ = mm_strdup(">");
12636 }
12637 | '='
12638 {
12639 $$ = mm_strdup("=");
12640 }
12641 | LESS_EQUALS
12642 {
12643 $$ = mm_strdup("<=");
12644 }
12645 | GREATER_EQUALS
12646 {
12647 $$ = mm_strdup(">=");
12648 }
12649 | NOT_EQUALS
12650 {
12651 $$ = mm_strdup("<>");
12652 }
12653 ;
12654
12655
12656 qual_Op:
12657 Op
12658 {
12659 $$ = $1;
12660 }
12661 | OPERATOR '(' any_operator ')'
12662 {
12663 $$ = cat_str(3,mm_strdup("operator ("),$3,mm_strdup(")"));
12664 }
12665 ;
12666
12667
12668 qual_all_Op:
12669 all_Op
12670 {
12671 $$ = $1;
12672 }
12673 | OPERATOR '(' any_operator ')'
12674 {
12675 $$ = cat_str(3,mm_strdup("operator ("),$3,mm_strdup(")"));
12676 }
12677 ;
12678
12679
12680 subquery_Op:
12681 all_Op
12682 {
12683 $$ = $1;
12684 }
12685 | OPERATOR '(' any_operator ')'
12686 {
12687 $$ = cat_str(3,mm_strdup("operator ("),$3,mm_strdup(")"));
12688 }
12689 | LIKE
12690 {
12691 $$ = mm_strdup("like");
12692 }
12693 | NOT_LA LIKE
12694 {
12695 $$ = mm_strdup("not like");
12696 }
12697 | ILIKE
12698 {
12699 $$ = mm_strdup("ilike");
12700 }
12701 | NOT_LA ILIKE
12702 {
12703 $$ = mm_strdup("not ilike");
12704 }
12705 ;
12706
12707
12708 expr_list:
12709 a_expr
12710 {
12711 $$ = $1;
12712 }
12713 | expr_list ',' a_expr
12714 {
12715 $$ = cat_str(3,$1,mm_strdup(","),$3);
12716 }
12717 ;
12718
12719
12720 func_arg_list:
12721 func_arg_expr
12722 {
12723 $$ = $1;
12724 }
12725 | func_arg_list ',' func_arg_expr
12726 {
12727 $$ = cat_str(3,$1,mm_strdup(","),$3);
12728 }
12729 ;
12730
12731
12732 func_arg_expr:
12733 a_expr
12734 {
12735 $$ = $1;
12736 }
12737 | param_name COLON_EQUALS a_expr
12738 {
12739 $$ = cat_str(3,$1,mm_strdup(":="),$3);
12740 }
12741 | param_name EQUALS_GREATER a_expr
12742 {
12743 $$ = cat_str(3,$1,mm_strdup("=>"),$3);
12744 }
12745 ;
12746
12747
12748 type_list:
12749 Typename
12750 {
12751 $$ = $1;
12752 }
12753 | type_list ',' Typename
12754 {
12755 $$ = cat_str(3,$1,mm_strdup(","),$3);
12756 }
12757 ;
12758
12759
12760 array_expr:
12761 '[' expr_list ']'
12762 {
12763 $$ = cat_str(3,mm_strdup("["),$2,mm_strdup("]"));
12764 }
12765 | '[' array_expr_list ']'
12766 {
12767 $$ = cat_str(3,mm_strdup("["),$2,mm_strdup("]"));
12768 }
12769 | '[' ']'
12770 {
12771 $$ = mm_strdup("[ ]");
12772 }
12773 ;
12774
12775
12776 array_expr_list:
12777 array_expr
12778 {
12779 $$ = $1;
12780 }
12781 | array_expr_list ',' array_expr
12782 {
12783 $$ = cat_str(3,$1,mm_strdup(","),$3);
12784 }
12785 ;
12786
12787
12788 extract_list:
12789 extract_arg FROM a_expr
12790 {
12791 $$ = cat_str(3,$1,mm_strdup("from"),$3);
12792 }
12793 |
12794 {
12795 $$=EMPTY; }
12796 ;
12797
12798
12799 extract_arg:
12800 ecpg_ident
12801 {
12802 $$ = $1;
12803 }
12804 | YEAR_P
12805 {
12806 $$ = mm_strdup("year");
12807 }
12808 | MONTH_P
12809 {
12810 $$ = mm_strdup("month");
12811 }
12812 | DAY_P
12813 {
12814 $$ = mm_strdup("day");
12815 }
12816 | HOUR_P
12817 {
12818 $$ = mm_strdup("hour");
12819 }
12820 | MINUTE_P
12821 {
12822 $$ = mm_strdup("minute");
12823 }
12824 | SECOND_P
12825 {
12826 $$ = mm_strdup("second");
12827 }
12828 | ecpg_sconst
12829 {
12830 $$ = $1;
12831 }
12832 ;
12833
12834
12835 overlay_list:
12836 a_expr overlay_placing substr_from substr_for
12837 {
12838 $$ = cat_str(4,$1,$2,$3,$4);
12839 }
12840 | a_expr overlay_placing substr_from
12841 {
12842 $$ = cat_str(3,$1,$2,$3);
12843 }
12844 ;
12845
12846
12847 overlay_placing:
12848 PLACING a_expr
12849 {
12850 $$ = cat_str(2,mm_strdup("placing"),$2);
12851 }
12852 ;
12853
12854
12855 position_list:
12856 b_expr IN_P b_expr
12857 {
12858 $$ = cat_str(3,$1,mm_strdup("in"),$3);
12859 }
12860 |
12861 {
12862 $$=EMPTY; }
12863 ;
12864
12865
12866 substr_list:
12867 a_expr substr_from substr_for
12868 {
12869 $$ = cat_str(3,$1,$2,$3);
12870 }
12871 | a_expr substr_for substr_from
12872 {
12873 $$ = cat_str(3,$1,$2,$3);
12874 }
12875 | a_expr substr_from
12876 {
12877 $$ = cat_str(2,$1,$2);
12878 }
12879 | a_expr substr_for
12880 {
12881 $$ = cat_str(2,$1,$2);
12882 }
12883 | expr_list
12884 {
12885 $$ = $1;
12886 }
12887 |
12888 {
12889 $$=EMPTY; }
12890 ;
12891
12892
12893 substr_from:
12894 FROM a_expr
12895 {
12896 $$ = cat_str(2,mm_strdup("from"),$2);
12897 }
12898 ;
12899
12900
12901 substr_for:
12902 FOR a_expr
12903 {
12904 $$ = cat_str(2,mm_strdup("for"),$2);
12905 }
12906 ;
12907
12908
12909 trim_list:
12910 a_expr FROM expr_list
12911 {
12912 $$ = cat_str(3,$1,mm_strdup("from"),$3);
12913 }
12914 | FROM expr_list
12915 {
12916 $$ = cat_str(2,mm_strdup("from"),$2);
12917 }
12918 | expr_list
12919 {
12920 $$ = $1;
12921 }
12922 ;
12923
12924
12925 in_expr:
12926 select_with_parens
12927 {
12928 $$ = $1;
12929 }
12930 | '(' expr_list ')'
12931 {
12932 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
12933 }
12934 ;
12935
12936
12937 case_expr:
12938 CASE case_arg when_clause_list case_default END_P
12939 {
12940 $$ = cat_str(5,mm_strdup("case"),$2,$3,$4,mm_strdup("end"));
12941 }
12942 ;
12943
12944
12945 when_clause_list:
12946 when_clause
12947 {
12948 $$ = $1;
12949 }
12950 | when_clause_list when_clause
12951 {
12952 $$ = cat_str(2,$1,$2);
12953 }
12954 ;
12955
12956
12957 when_clause:
12958 WHEN a_expr THEN a_expr
12959 {
12960 $$ = cat_str(4,mm_strdup("when"),$2,mm_strdup("then"),$4);
12961 }
12962 ;
12963
12964
12965 case_default:
12966 ELSE a_expr
12967 {
12968 $$ = cat_str(2,mm_strdup("else"),$2);
12969 }
12970 |
12971 {
12972 $$=EMPTY; }
12973 ;
12974
12975
12976 case_arg:
12977 a_expr
12978 {
12979 $$ = $1;
12980 }
12981 |
12982 {
12983 $$=EMPTY; }
12984 ;
12985
12986
12987 columnref:
12988 ColId
12989 {
12990 $$ = $1;
12991 }
12992 | ColId indirection
12993 {
12994 $$ = cat_str(2,$1,$2);
12995 }
12996 ;
12997
12998
12999 indirection_el:
13000 '.' attr_name
13001 {
13002 $$ = cat_str(2,mm_strdup("."),$2);
13003 }
13004 | '.' '*'
13005 {
13006 $$ = mm_strdup(". *");
13007 }
13008 | '[' a_expr ']'
13009 {
13010 $$ = cat_str(3,mm_strdup("["),$2,mm_strdup("]"));
13011 }
13012 | '[' opt_slice_bound ':' opt_slice_bound ']'
13013 {
13014 $$ = cat_str(5,mm_strdup("["),$2,mm_strdup(":"),$4,mm_strdup("]"));
13015 }
13016 ;
13017
13018
13019 opt_slice_bound:
13020 a_expr
13021 {
13022 $$ = $1;
13023 }
13024 |
13025 {
13026 $$=EMPTY; }
13027 ;
13028
13029
13030 indirection:
13031 indirection_el
13032 {
13033 $$ = $1;
13034 }
13035 | indirection indirection_el
13036 {
13037 $$ = cat_str(2,$1,$2);
13038 }
13039 ;
13040
13041
13042 opt_indirection:
13043
13044 {
13045 $$=EMPTY; }
13046 | opt_indirection indirection_el
13047 {
13048 $$ = cat_str(2,$1,$2);
13049 }
13050 ;
13051
13052
13053 opt_asymmetric:
13054 ASYMMETRIC
13055 {
13056 $$ = mm_strdup("asymmetric");
13057 }
13058 |
13059 {
13060 $$=EMPTY; }
13061 ;
13062
13063
13064 opt_target_list:
13065 target_list
13066 {
13067 $$ = $1;
13068 }
13069 |
13070 {
13071 $$=EMPTY; }
13072 ;
13073
13074
13075 target_list:
13076 target_el
13077 {
13078 $$ = $1;
13079 }
13080 | target_list ',' target_el
13081 {
13082 $$ = cat_str(3,$1,mm_strdup(","),$3);
13083 }
13084 ;
13085
13086
13087 target_el:
13088 a_expr AS ColLabel
13089 {
13090 $$ = cat_str(3,$1,mm_strdup("as"),$3);
13091 }
13092 | a_expr ecpg_ident
13093 {
13094 $$ = cat_str(2,$1,$2);
13095 }
13096 | a_expr
13097 {
13098 $$ = $1;
13099 }
13100 | '*'
13101 {
13102 $$ = mm_strdup("*");
13103 }
13104 ;
13105
13106
13107 qualified_name_list:
13108 qualified_name
13109 {
13110 $$ = $1;
13111 }
13112 | qualified_name_list ',' qualified_name
13113 {
13114 $$ = cat_str(3,$1,mm_strdup(","),$3);
13115 }
13116 ;
13117
13118
13119 qualified_name:
13120 ColId
13121 {
13122 $$ = $1;
13123 }
13124 | ColId indirection
13125 {
13126 $$ = cat_str(2,$1,$2);
13127 }
13128 ;
13129
13130
13131 name_list:
13132 name
13133 {
13134 $$ = $1;
13135 }
13136 | name_list ',' name
13137 {
13138 $$ = cat_str(3,$1,mm_strdup(","),$3);
13139 }
13140 ;
13141
13142
13143 name:
13144 ColId
13145 {
13146 $$ = $1;
13147 }
13148 ;
13149
13150
13151 database_name:
13152 ColId
13153 {
13154 $$ = $1;
13155 }
13156 ;
13157
13158
13159 access_method:
13160 ColId
13161 {
13162 $$ = $1;
13163 }
13164 ;
13165
13166
13167 attr_name:
13168 ColLabel
13169 {
13170 $$ = $1;
13171 }
13172 ;
13173
13174
13175 index_name:
13176 ColId
13177 {
13178 $$ = $1;
13179 }
13180 ;
13181
13182
13183 file_name:
13184 ecpg_sconst
13185 {
13186 $$ = $1;
13187 }
13188 ;
13189
13190
13191 func_name:
13192 type_function_name
13193 {
13194 $$ = $1;
13195 }
13196 | ColId indirection
13197 {
13198 $$ = cat_str(2,$1,$2);
13199 }
13200 ;
13201
13202
13203 AexprConst:
13204 Iconst
13205 {
13206 $$ = $1;
13207 }
13208 | ecpg_fconst
13209 {
13210 $$ = $1;
13211 }
13212 | ecpg_sconst
13213 {
13214 $$ = $1;
13215 }
13216 | ecpg_bconst
13217 {
13218 $$ = $1;
13219 }
13220 | XCONST
13221 {
13222 $$ = mm_strdup("xconst");
13223 }
13224 | func_name ecpg_sconst
13225 {
13226 $$ = cat_str(2,$1,$2);
13227 }
13228 | func_name '(' func_arg_list opt_sort_clause ')' ecpg_sconst
13229 {
13230 $$ = cat_str(6,$1,mm_strdup("("),$3,$4,mm_strdup(")"),$6);
13231 }
13232 | ConstTypename ecpg_sconst
13233 {
13234 $$ = cat_str(2,$1,$2);
13235 }
13236 | ConstInterval ecpg_sconst opt_interval
13237 {
13238 $$ = cat_str(3,$1,$2,$3);
13239 }
13240 | ConstInterval '(' Iconst ')' ecpg_sconst
13241 {
13242 $$ = cat_str(5,$1,mm_strdup("("),$3,mm_strdup(")"),$5);
13243 }
13244 | TRUE_P
13245 {
13246 $$ = mm_strdup("true");
13247 }
13248 | FALSE_P
13249 {
13250 $$ = mm_strdup("false");
13251 }
13252 | NULL_P
13253 {
13254 $$ = mm_strdup("null");
13255 }
13256 | civar { $$ = $1; }
13257 | civarind { $$ = $1; }
13258 ;
13259
13260
13261 Iconst:
13262 ICONST
13263 { $$ = make_name(); }
13264 ;
13265
13266
13267 SignedIconst:
13268 Iconst
13269 {
13270 $$ = $1;
13271 }
13272 | civar { $$ = $1; }
13273 | '+' Iconst
13274 {
13275 $$ = cat_str(2,mm_strdup("+"),$2);
13276 }
13277 | '-' Iconst
13278 {
13279 $$ = cat_str(2,mm_strdup("-"),$2);
13280 }
13281 ;
13282
13283
13284 RoleId:
13285 RoleSpec
13286 {
13287 $$ = $1;
13288 }
13289 ;
13290
13291
13292 RoleSpec:
13293 NonReservedWord
13294 {
13295 $$ = $1;
13296 }
13297 | CURRENT_USER
13298 {
13299 $$ = mm_strdup("current_user");
13300 }
13301 | SESSION_USER
13302 {
13303 $$ = mm_strdup("session_user");
13304 }
13305 ;
13306
13307
13308 role_list:
13309 RoleSpec
13310 {
13311 $$ = $1;
13312 }
13313 | role_list ',' RoleSpec
13314 {
13315 $$ = cat_str(3,$1,mm_strdup(","),$3);
13316 }
13317 ;
13318
13319
13320 NonReservedWord:
13321 ecpg_ident
13322 {
13323 $$ = $1;
13324 }
13325 | unreserved_keyword
13326 {
13327 $$ = $1;
13328 }
13329 | col_name_keyword
13330 {
13331 $$ = $1;
13332 }
13333 | type_func_name_keyword
13334 {
13335 $$ = $1;
13336 }
13337 ;
13338
13339
13340 unreserved_keyword:
13341 ABORT_P
13342 {
13343 $$ = mm_strdup("abort");
13344 }
13345 | ABSOLUTE_P
13346 {
13347 $$ = mm_strdup("absolute");
13348 }
13349 | ACCESS
13350 {
13351 $$ = mm_strdup("access");
13352 }
13353 | ACTION
13354 {
13355 $$ = mm_strdup("action");
13356 }
13357 | ADD_P
13358 {
13359 $$ = mm_strdup("add");
13360 }
13361 | ADMIN
13362 {
13363 $$ = mm_strdup("admin");
13364 }
13365 | AFTER
13366 {
13367 $$ = mm_strdup("after");
13368 }
13369 | AGGREGATE
13370 {
13371 $$ = mm_strdup("aggregate");
13372 }
13373 | ALSO
13374 {
13375 $$ = mm_strdup("also");
13376 }
13377 | ALTER
13378 {
13379 $$ = mm_strdup("alter");
13380 }
13381 | ALWAYS
13382 {
13383 $$ = mm_strdup("always");
13384 }
13385 | ASSERTION
13386 {
13387 $$ = mm_strdup("assertion");
13388 }
13389 | ASSIGNMENT
13390 {
13391 $$ = mm_strdup("assignment");
13392 }
13393 | AT
13394 {
13395 $$ = mm_strdup("at");
13396 }
13397 | ATTACH
13398 {
13399 $$ = mm_strdup("attach");
13400 }
13401 | ATTRIBUTE
13402 {
13403 $$ = mm_strdup("attribute");
13404 }
13405 | BACKWARD
13406 {
13407 $$ = mm_strdup("backward");
13408 }
13409 | BEFORE
13410 {
13411 $$ = mm_strdup("before");
13412 }
13413 | BEGIN_P
13414 {
13415 $$ = mm_strdup("begin");
13416 }
13417 | BY
13418 {
13419 $$ = mm_strdup("by");
13420 }
13421 | CACHE
13422 {
13423 $$ = mm_strdup("cache");
13424 }
13425 | CALL
13426 {
13427 $$ = mm_strdup("call");
13428 }
13429 | CALLED
13430 {
13431 $$ = mm_strdup("called");
13432 }
13433 | CASCADE
13434 {
13435 $$ = mm_strdup("cascade");
13436 }
13437 | CASCADED
13438 {
13439 $$ = mm_strdup("cascaded");
13440 }
13441 | CATALOG_P
13442 {
13443 $$ = mm_strdup("catalog");
13444 }
13445 | CHAIN
13446 {
13447 $$ = mm_strdup("chain");
13448 }
13449 | CHARACTERISTICS
13450 {
13451 $$ = mm_strdup("characteristics");
13452 }
13453 | CHECKPOINT
13454 {
13455 $$ = mm_strdup("checkpoint");
13456 }
13457 | CLASS
13458 {
13459 $$ = mm_strdup("class");
13460 }
13461 | CLOSE
13462 {
13463 $$ = mm_strdup("close");
13464 }
13465 | CLUSTER
13466 {
13467 $$ = mm_strdup("cluster");
13468 }
13469 | COLUMNS
13470 {
13471 $$ = mm_strdup("columns");
13472 }
13473 | COMMENT
13474 {
13475 $$ = mm_strdup("comment");
13476 }
13477 | COMMENTS
13478 {
13479 $$ = mm_strdup("comments");
13480 }
13481 | COMMIT
13482 {
13483 $$ = mm_strdup("commit");
13484 }
13485 | COMMITTED
13486 {
13487 $$ = mm_strdup("committed");
13488 }
13489 | CONFIGURATION
13490 {
13491 $$ = mm_strdup("configuration");
13492 }
13493 | CONFLICT
13494 {
13495 $$ = mm_strdup("conflict");
13496 }
13497 | CONSTRAINTS
13498 {
13499 $$ = mm_strdup("constraints");
13500 }
13501 | CONTENT_P
13502 {
13503 $$ = mm_strdup("content");
13504 }
13505 | CONTINUE_P
13506 {
13507 $$ = mm_strdup("continue");
13508 }
13509 | CONVERSION_P
13510 {
13511 $$ = mm_strdup("conversion");
13512 }
13513 | COPY
13514 {
13515 $$ = mm_strdup("copy");
13516 }
13517 | COST
13518 {
13519 $$ = mm_strdup("cost");
13520 }
13521 | CSV
13522 {
13523 $$ = mm_strdup("csv");
13524 }
13525 | CUBE
13526 {
13527 $$ = mm_strdup("cube");
13528 }
13529 | CURSOR
13530 {
13531 $$ = mm_strdup("cursor");
13532 }
13533 | CYCLE
13534 {
13535 $$ = mm_strdup("cycle");
13536 }
13537 | DATA_P
13538 {
13539 $$ = mm_strdup("data");
13540 }
13541 | DATABASE
13542 {
13543 $$ = mm_strdup("database");
13544 }
13545 | DEALLOCATE
13546 {
13547 $$ = mm_strdup("deallocate");
13548 }
13549 | DECLARE
13550 {
13551 $$ = mm_strdup("declare");
13552 }
13553 | DEFAULTS
13554 {
13555 $$ = mm_strdup("defaults");
13556 }
13557 | DEFERRED
13558 {
13559 $$ = mm_strdup("deferred");
13560 }
13561 | DEFINER
13562 {
13563 $$ = mm_strdup("definer");
13564 }
13565 | DELETE_P
13566 {
13567 $$ = mm_strdup("delete");
13568 }
13569 | DELIMITER
13570 {
13571 $$ = mm_strdup("delimiter");
13572 }
13573 | DELIMITERS
13574 {
13575 $$ = mm_strdup("delimiters");
13576 }
13577 | DEPENDS
13578 {
13579 $$ = mm_strdup("depends");
13580 }
13581 | DETACH
13582 {
13583 $$ = mm_strdup("detach");
13584 }
13585 | DICTIONARY
13586 {
13587 $$ = mm_strdup("dictionary");
13588 }
13589 | DISABLE_P
13590 {
13591 $$ = mm_strdup("disable");
13592 }
13593 | DISCARD
13594 {
13595 $$ = mm_strdup("discard");
13596 }
13597 | DOCUMENT_P
13598 {
13599 $$ = mm_strdup("document");
13600 }
13601 | DOMAIN_P
13602 {
13603 $$ = mm_strdup("domain");
13604 }
13605 | DOUBLE_P
13606 {
13607 $$ = mm_strdup("double");
13608 }
13609 | DROP
13610 {
13611 $$ = mm_strdup("drop");
13612 }
13613 | EACH
13614 {
13615 $$ = mm_strdup("each");
13616 }
13617 | ENABLE_P
13618 {
13619 $$ = mm_strdup("enable");
13620 }
13621 | ENCODING
13622 {
13623 $$ = mm_strdup("encoding");
13624 }
13625 | ENCRYPTED
13626 {
13627 $$ = mm_strdup("encrypted");
13628 }
13629 | ENUM_P
13630 {
13631 $$ = mm_strdup("enum");
13632 }
13633 | ESCAPE
13634 {
13635 $$ = mm_strdup("escape");
13636 }
13637 | EVENT
13638 {
13639 $$ = mm_strdup("event");
13640 }
13641 | EXCLUDE
13642 {
13643 $$ = mm_strdup("exclude");
13644 }
13645 | EXCLUDING
13646 {
13647 $$ = mm_strdup("excluding");
13648 }
13649 | EXCLUSIVE
13650 {
13651 $$ = mm_strdup("exclusive");
13652 }
13653 | EXECUTE
13654 {
13655 $$ = mm_strdup("execute");
13656 }
13657 | EXPLAIN
13658 {
13659 $$ = mm_strdup("explain");
13660 }
13661 | EXTENSION
13662 {
13663 $$ = mm_strdup("extension");
13664 }
13665 | EXTERNAL
13666 {
13667 $$ = mm_strdup("external");
13668 }
13669 | FAMILY
13670 {
13671 $$ = mm_strdup("family");
13672 }
13673 | FILTER
13674 {
13675 $$ = mm_strdup("filter");
13676 }
13677 | FIRST_P
13678 {
13679 $$ = mm_strdup("first");
13680 }
13681 | FOLLOWING
13682 {
13683 $$ = mm_strdup("following");
13684 }
13685 | FORCE
13686 {
13687 $$ = mm_strdup("force");
13688 }
13689 | FORWARD
13690 {
13691 $$ = mm_strdup("forward");
13692 }
13693 | FUNCTION
13694 {
13695 $$ = mm_strdup("function");
13696 }
13697 | FUNCTIONS
13698 {
13699 $$ = mm_strdup("functions");
13700 }
13701 | GENERATED
13702 {
13703 $$ = mm_strdup("generated");
13704 }
13705 | GLOBAL
13706 {
13707 $$ = mm_strdup("global");
13708 }
13709 | GRANTED
13710 {
13711 $$ = mm_strdup("granted");
13712 }
13713 | GROUPS
13714 {
13715 $$ = mm_strdup("groups");
13716 }
13717 | HANDLER
13718 {
13719 $$ = mm_strdup("handler");
13720 }
13721 | HEADER_P
13722 {
13723 $$ = mm_strdup("header");
13724 }
13725 | HOLD
13726 {
13727 $$ = mm_strdup("hold");
13728 }
13729 | IDENTITY_P
13730 {
13731 $$ = mm_strdup("identity");
13732 }
13733 | IF_P
13734 {
13735 $$ = mm_strdup("if");
13736 }
13737 | IMMEDIATE
13738 {
13739 $$ = mm_strdup("immediate");
13740 }
13741 | IMMUTABLE
13742 {
13743 $$ = mm_strdup("immutable");
13744 }
13745 | IMPLICIT_P
13746 {
13747 $$ = mm_strdup("implicit");
13748 }
13749 | IMPORT_P
13750 {
13751 $$ = mm_strdup("import");
13752 }
13753 | INCLUDE
13754 {
13755 $$ = mm_strdup("include");
13756 }
13757 | INCLUDING
13758 {
13759 $$ = mm_strdup("including");
13760 }
13761 | INCREMENT
13762 {
13763 $$ = mm_strdup("increment");
13764 }
13765 | INDEX
13766 {
13767 $$ = mm_strdup("index");
13768 }
13769 | INDEXES
13770 {
13771 $$ = mm_strdup("indexes");
13772 }
13773 | INHERIT
13774 {
13775 $$ = mm_strdup("inherit");
13776 }
13777 | INHERITS
13778 {
13779 $$ = mm_strdup("inherits");
13780 }
13781 | INLINE_P
13782 {
13783 $$ = mm_strdup("inline");
13784 }
13785 | INSENSITIVE
13786 {
13787 $$ = mm_strdup("insensitive");
13788 }
13789 | INSERT
13790 {
13791 $$ = mm_strdup("insert");
13792 }
13793 | INSTEAD
13794 {
13795 $$ = mm_strdup("instead");
13796 }
13797 | INVOKER
13798 {
13799 $$ = mm_strdup("invoker");
13800 }
13801 | ISOLATION
13802 {
13803 $$ = mm_strdup("isolation");
13804 }
13805 | KEY
13806 {
13807 $$ = mm_strdup("key");
13808 }
13809 | LABEL
13810 {
13811 $$ = mm_strdup("label");
13812 }
13813 | LANGUAGE
13814 {
13815 $$ = mm_strdup("language");
13816 }
13817 | LARGE_P
13818 {
13819 $$ = mm_strdup("large");
13820 }
13821 | LAST_P
13822 {
13823 $$ = mm_strdup("last");
13824 }
13825 | LEAKPROOF
13826 {
13827 $$ = mm_strdup("leakproof");
13828 }
13829 | LEVEL
13830 {
13831 $$ = mm_strdup("level");
13832 }
13833 | LISTEN
13834 {
13835 $$ = mm_strdup("listen");
13836 }
13837 | LOAD
13838 {
13839 $$ = mm_strdup("load");
13840 }
13841 | LOCAL
13842 {
13843 $$ = mm_strdup("local");
13844 }
13845 | LOCATION
13846 {
13847 $$ = mm_strdup("location");
13848 }
13849 | LOCK_P
13850 {
13851 $$ = mm_strdup("lock");
13852 }
13853 | LOCKED
13854 {
13855 $$ = mm_strdup("locked");
13856 }
13857 | LOGGED
13858 {
13859 $$ = mm_strdup("logged");
13860 }
13861 | MAPPING
13862 {
13863 $$ = mm_strdup("mapping");
13864 }
13865 | MATCH
13866 {
13867 $$ = mm_strdup("match");
13868 }
13869 | MATERIALIZED
13870 {
13871 $$ = mm_strdup("materialized");
13872 }
13873 | MAXVALUE
13874 {
13875 $$ = mm_strdup("maxvalue");
13876 }
13877 | METHOD
13878 {
13879 $$ = mm_strdup("method");
13880 }
13881 | MINVALUE
13882 {
13883 $$ = mm_strdup("minvalue");
13884 }
13885 | MODE
13886 {
13887 $$ = mm_strdup("mode");
13888 }
13889 | MOVE
13890 {
13891 $$ = mm_strdup("move");
13892 }
13893 | NAME_P
13894 {
13895 $$ = mm_strdup("name");
13896 }
13897 | NAMES
13898 {
13899 $$ = mm_strdup("names");
13900 }
13901 | NEW
13902 {
13903 $$ = mm_strdup("new");
13904 }
13905 | NEXT
13906 {
13907 $$ = mm_strdup("next");
13908 }
13909 | NO
13910 {
13911 $$ = mm_strdup("no");
13912 }
13913 | NOTHING
13914 {
13915 $$ = mm_strdup("nothing");
13916 }
13917 | NOTIFY
13918 {
13919 $$ = mm_strdup("notify");
13920 }
13921 | NOWAIT
13922 {
13923 $$ = mm_strdup("nowait");
13924 }
13925 | NULLS_P
13926 {
13927 $$ = mm_strdup("nulls");
13928 }
13929 | OBJECT_P
13930 {
13931 $$ = mm_strdup("object");
13932 }
13933 | OF
13934 {
13935 $$ = mm_strdup("of");
13936 }
13937 | OFF
13938 {
13939 $$ = mm_strdup("off");
13940 }
13941 | OIDS
13942 {
13943 $$ = mm_strdup("oids");
13944 }
13945 | OLD
13946 {
13947 $$ = mm_strdup("old");
13948 }
13949 | OPERATOR
13950 {
13951 $$ = mm_strdup("operator");
13952 }
13953 | OPTION
13954 {
13955 $$ = mm_strdup("option");
13956 }
13957 | OPTIONS
13958 {
13959 $$ = mm_strdup("options");
13960 }
13961 | ORDINALITY
13962 {
13963 $$ = mm_strdup("ordinality");
13964 }
13965 | OTHERS
13966 {
13967 $$ = mm_strdup("others");
13968 }
13969 | OVER
13970 {
13971 $$ = mm_strdup("over");
13972 }
13973 | OVERRIDING
13974 {
13975 $$ = mm_strdup("overriding");
13976 }
13977 | OWNED
13978 {
13979 $$ = mm_strdup("owned");
13980 }
13981 | OWNER
13982 {
13983 $$ = mm_strdup("owner");
13984 }
13985 | PARALLEL
13986 {
13987 $$ = mm_strdup("parallel");
13988 }
13989 | PARSER
13990 {
13991 $$ = mm_strdup("parser");
13992 }
13993 | PARTIAL
13994 {
13995 $$ = mm_strdup("partial");
13996 }
13997 | PARTITION
13998 {
13999 $$ = mm_strdup("partition");
14000 }
14001 | PASSING
14002 {
14003 $$ = mm_strdup("passing");
14004 }
14005 | PASSWORD
14006 {
14007 $$ = mm_strdup("password");
14008 }
14009 | PLANS
14010 {
14011 $$ = mm_strdup("plans");
14012 }
14013 | POLICY
14014 {
14015 $$ = mm_strdup("policy");
14016 }
14017 | PRECEDING
14018 {
14019 $$ = mm_strdup("preceding");
14020 }
14021 | PREPARE
14022 {
14023 $$ = mm_strdup("prepare");
14024 }
14025 | PREPARED
14026 {
14027 $$ = mm_strdup("prepared");
14028 }
14029 | PRESERVE
14030 {
14031 $$ = mm_strdup("preserve");
14032 }
14033 | PRIOR
14034 {
14035 $$ = mm_strdup("prior");
14036 }
14037 | PRIVILEGES
14038 {
14039 $$ = mm_strdup("privileges");
14040 }
14041 | PROCEDURAL
14042 {
14043 $$ = mm_strdup("procedural");
14044 }
14045 | PROCEDURE
14046 {
14047 $$ = mm_strdup("procedure");
14048 }
14049 | PROCEDURES
14050 {
14051 $$ = mm_strdup("procedures");
14052 }
14053 | PROGRAM
14054 {
14055 $$ = mm_strdup("program");
14056 }
14057 | PUBLICATION
14058 {
14059 $$ = mm_strdup("publication");
14060 }
14061 | QUOTE
14062 {
14063 $$ = mm_strdup("quote");
14064 }
14065 | RANGE
14066 {
14067 $$ = mm_strdup("range");
14068 }
14069 | READ
14070 {
14071 $$ = mm_strdup("read");
14072 }
14073 | REASSIGN
14074 {
14075 $$ = mm_strdup("reassign");
14076 }
14077 | RECHECK
14078 {
14079 $$ = mm_strdup("recheck");
14080 }
14081 | RECURSIVE
14082 {
14083 $$ = mm_strdup("recursive");
14084 }
14085 | REF
14086 {
14087 $$ = mm_strdup("ref");
14088 }
14089 | REFERENCING
14090 {
14091 $$ = mm_strdup("referencing");
14092 }
14093 | REFRESH
14094 {
14095 $$ = mm_strdup("refresh");
14096 }
14097 | REINDEX
14098 {
14099 $$ = mm_strdup("reindex");
14100 }
14101 | RELATIVE_P
14102 {
14103 $$ = mm_strdup("relative");
14104 }
14105 | RELEASE
14106 {
14107 $$ = mm_strdup("release");
14108 }
14109 | RENAME
14110 {
14111 $$ = mm_strdup("rename");
14112 }
14113 | REPEATABLE
14114 {
14115 $$ = mm_strdup("repeatable");
14116 }
14117 | REPLACE
14118 {
14119 $$ = mm_strdup("replace");
14120 }
14121 | REPLICA
14122 {
14123 $$ = mm_strdup("replica");
14124 }
14125 | RESET
14126 {
14127 $$ = mm_strdup("reset");
14128 }
14129 | RESTART
14130 {
14131 $$ = mm_strdup("restart");
14132 }
14133 | RESTRICT
14134 {
14135 $$ = mm_strdup("restrict");
14136 }
14137 | RETURNS
14138 {
14139 $$ = mm_strdup("returns");
14140 }
14141 | REVOKE
14142 {
14143 $$ = mm_strdup("revoke");
14144 }
14145 | ROLE
14146 {
14147 $$ = mm_strdup("role");
14148 }
14149 | ROLLBACK
14150 {
14151 $$ = mm_strdup("rollback");
14152 }
14153 | ROLLUP
14154 {
14155 $$ = mm_strdup("rollup");
14156 }
14157 | ROUTINE
14158 {
14159 $$ = mm_strdup("routine");
14160 }
14161 | ROUTINES
14162 {
14163 $$ = mm_strdup("routines");
14164 }
14165 | ROWS
14166 {
14167 $$ = mm_strdup("rows");
14168 }
14169 | RULE
14170 {
14171 $$ = mm_strdup("rule");
14172 }
14173 | SAVEPOINT
14174 {
14175 $$ = mm_strdup("savepoint");
14176 }
14177 | SCHEMA
14178 {
14179 $$ = mm_strdup("schema");
14180 }
14181 | SCHEMAS
14182 {
14183 $$ = mm_strdup("schemas");
14184 }
14185 | SCROLL
14186 {
14187 $$ = mm_strdup("scroll");
14188 }
14189 | SEARCH
14190 {
14191 $$ = mm_strdup("search");
14192 }
14193 | SECURITY
14194 {
14195 $$ = mm_strdup("security");
14196 }
14197 | SEQUENCE
14198 {
14199 $$ = mm_strdup("sequence");
14200 }
14201 | SEQUENCES
14202 {
14203 $$ = mm_strdup("sequences");
14204 }
14205 | SERIALIZABLE
14206 {
14207 $$ = mm_strdup("serializable");
14208 }
14209 | SERVER
14210 {
14211 $$ = mm_strdup("server");
14212 }
14213 | SESSION
14214 {
14215 $$ = mm_strdup("session");
14216 }
14217 | SET
14218 {
14219 $$ = mm_strdup("set");
14220 }
14221 | SETS
14222 {
14223 $$ = mm_strdup("sets");
14224 }
14225 | SHARE
14226 {
14227 $$ = mm_strdup("share");
14228 }
14229 | SHOW
14230 {
14231 $$ = mm_strdup("show");
14232 }
14233 | SIMPLE
14234 {
14235 $$ = mm_strdup("simple");
14236 }
14237 | SKIP
14238 {
14239 $$ = mm_strdup("skip");
14240 }
14241 | SNAPSHOT
14242 {
14243 $$ = mm_strdup("snapshot");
14244 }
14245 | SQL_P
14246 {
14247 $$ = mm_strdup("sql");
14248 }
14249 | STABLE
14250 {
14251 $$ = mm_strdup("stable");
14252 }
14253 | STANDALONE_P
14254 {
14255 $$ = mm_strdup("standalone");
14256 }
14257 | START
14258 {
14259 $$ = mm_strdup("start");
14260 }
14261 | STATEMENT
14262 {
14263 $$ = mm_strdup("statement");
14264 }
14265 | STATISTICS
14266 {
14267 $$ = mm_strdup("statistics");
14268 }
14269 | STDIN
14270 {
14271 $$ = mm_strdup("stdin");
14272 }
14273 | STDOUT
14274 {
14275 $$ = mm_strdup("stdout");
14276 }
14277 | STORAGE
14278 {
14279 $$ = mm_strdup("storage");
14280 }
14281 | STORED
14282 {
14283 $$ = mm_strdup("stored");
14284 }
14285 | STRICT_P
14286 {
14287 $$ = mm_strdup("strict");
14288 }
14289 | STRIP_P
14290 {
14291 $$ = mm_strdup("strip");
14292 }
14293 | SUBSCRIPTION
14294 {
14295 $$ = mm_strdup("subscription");
14296 }
14297 | SUPPORT
14298 {
14299 $$ = mm_strdup("support");
14300 }
14301 | SYSID
14302 {
14303 $$ = mm_strdup("sysid");
14304 }
14305 | SYSTEM_P
14306 {
14307 $$ = mm_strdup("system");
14308 }
14309 | TABLES
14310 {
14311 $$ = mm_strdup("tables");
14312 }
14313 | TABLESPACE
14314 {
14315 $$ = mm_strdup("tablespace");
14316 }
14317 | TEMP
14318 {
14319 $$ = mm_strdup("temp");
14320 }
14321 | TEMPLATE
14322 {
14323 $$ = mm_strdup("template");
14324 }
14325 | TEMPORARY
14326 {
14327 $$ = mm_strdup("temporary");
14328 }
14329 | TEXT_P
14330 {
14331 $$ = mm_strdup("text");
14332 }
14333 | TIES
14334 {
14335 $$ = mm_strdup("ties");
14336 }
14337 | TRANSACTION
14338 {
14339 $$ = mm_strdup("transaction");
14340 }
14341 | TRANSFORM
14342 {
14343 $$ = mm_strdup("transform");
14344 }
14345 | TRIGGER
14346 {
14347 $$ = mm_strdup("trigger");
14348 }
14349 | TRUNCATE
14350 {
14351 $$ = mm_strdup("truncate");
14352 }
14353 | TRUSTED
14354 {
14355 $$ = mm_strdup("trusted");
14356 }
14357 | TYPE_P
14358 {
14359 $$ = mm_strdup("type");
14360 }
14361 | TYPES_P
14362 {
14363 $$ = mm_strdup("types");
14364 }
14365 | UNBOUNDED
14366 {
14367 $$ = mm_strdup("unbounded");
14368 }
14369 | UNCOMMITTED
14370 {
14371 $$ = mm_strdup("uncommitted");
14372 }
14373 | UNENCRYPTED
14374 {
14375 $$ = mm_strdup("unencrypted");
14376 }
14377 | UNKNOWN
14378 {
14379 $$ = mm_strdup("unknown");
14380 }
14381 | UNLISTEN
14382 {
14383 $$ = mm_strdup("unlisten");
14384 }
14385 | UNLOGGED
14386 {
14387 $$ = mm_strdup("unlogged");
14388 }
14389 | UNTIL
14390 {
14391 $$ = mm_strdup("until");
14392 }
14393 | UPDATE
14394 {
14395 $$ = mm_strdup("update");
14396 }
14397 | VACUUM
14398 {
14399 $$ = mm_strdup("vacuum");
14400 }
14401 | VALID
14402 {
14403 $$ = mm_strdup("valid");
14404 }
14405 | VALIDATE
14406 {
14407 $$ = mm_strdup("validate");
14408 }
14409 | VALIDATOR
14410 {
14411 $$ = mm_strdup("validator");
14412 }
14413 | VALUE_P
14414 {
14415 $$ = mm_strdup("value");
14416 }
14417 | VARYING
14418 {
14419 $$ = mm_strdup("varying");
14420 }
14421 | VERSION_P
14422 {
14423 $$ = mm_strdup("version");
14424 }
14425 | VIEW
14426 {
14427 $$ = mm_strdup("view");
14428 }
14429 | VIEWS
14430 {
14431 $$ = mm_strdup("views");
14432 }
14433 | VOLATILE
14434 {
14435 $$ = mm_strdup("volatile");
14436 }
14437 | WHITESPACE_P
14438 {
14439 $$ = mm_strdup("whitespace");
14440 }
14441 | WITHIN
14442 {
14443 $$ = mm_strdup("within");
14444 }
14445 | WITHOUT
14446 {
14447 $$ = mm_strdup("without");
14448 }
14449 | WORK
14450 {
14451 $$ = mm_strdup("work");
14452 }
14453 | WRAPPER
14454 {
14455 $$ = mm_strdup("wrapper");
14456 }
14457 | WRITE
14458 {
14459 $$ = mm_strdup("write");
14460 }
14461 | XML_P
14462 {
14463 $$ = mm_strdup("xml");
14464 }
14465 | YES_P
14466 {
14467 $$ = mm_strdup("yes");
14468 }
14469 | ZONE
14470 {
14471 $$ = mm_strdup("zone");
14472 }
14473 ;
14474
14475
14476 col_name_keyword:
14477 BETWEEN
14478 {
14479 $$ = mm_strdup("between");
14480 }
14481 | BIGINT
14482 {
14483 $$ = mm_strdup("bigint");
14484 }
14485 | BIT
14486 {
14487 $$ = mm_strdup("bit");
14488 }
14489 | BOOLEAN_P
14490 {
14491 $$ = mm_strdup("boolean");
14492 }
14493 | CHARACTER
14494 {
14495 $$ = mm_strdup("character");
14496 }
14497 | COALESCE
14498 {
14499 $$ = mm_strdup("coalesce");
14500 }
14501 | DEC
14502 {
14503 $$ = mm_strdup("dec");
14504 }
14505 | DECIMAL_P
14506 {
14507 $$ = mm_strdup("decimal");
14508 }
14509 | EXISTS
14510 {
14511 $$ = mm_strdup("exists");
14512 }
14513 | EXTRACT
14514 {
14515 $$ = mm_strdup("extract");
14516 }
14517 | FLOAT_P
14518 {
14519 $$ = mm_strdup("float");
14520 }
14521 | GREATEST
14522 {
14523 $$ = mm_strdup("greatest");
14524 }
14525 | GROUPING
14526 {
14527 $$ = mm_strdup("grouping");
14528 }
14529 | INOUT
14530 {
14531 $$ = mm_strdup("inout");
14532 }
14533 | INTEGER
14534 {
14535 $$ = mm_strdup("integer");
14536 }
14537 | INTERVAL
14538 {
14539 $$ = mm_strdup("interval");
14540 }
14541 | LEAST
14542 {
14543 $$ = mm_strdup("least");
14544 }
14545 | NATIONAL
14546 {
14547 $$ = mm_strdup("national");
14548 }
14549 | NCHAR
14550 {
14551 $$ = mm_strdup("nchar");
14552 }
14553 | NONE
14554 {
14555 $$ = mm_strdup("none");
14556 }
14557 | NULLIF
14558 {
14559 $$ = mm_strdup("nullif");
14560 }
14561 | NUMERIC
14562 {
14563 $$ = mm_strdup("numeric");
14564 }
14565 | OUT_P
14566 {
14567 $$ = mm_strdup("out");
14568 }
14569 | OVERLAY
14570 {
14571 $$ = mm_strdup("overlay");
14572 }
14573 | POSITION
14574 {
14575 $$ = mm_strdup("position");
14576 }
14577 | PRECISION
14578 {
14579 $$ = mm_strdup("precision");
14580 }
14581 | REAL
14582 {
14583 $$ = mm_strdup("real");
14584 }
14585 | ROW
14586 {
14587 $$ = mm_strdup("row");
14588 }
14589 | SETOF
14590 {
14591 $$ = mm_strdup("setof");
14592 }
14593 | SMALLINT
14594 {
14595 $$ = mm_strdup("smallint");
14596 }
14597 | SUBSTRING
14598 {
14599 $$ = mm_strdup("substring");
14600 }
14601 | TIME
14602 {
14603 $$ = mm_strdup("time");
14604 }
14605 | TIMESTAMP
14606 {
14607 $$ = mm_strdup("timestamp");
14608 }
14609 | TREAT
14610 {
14611 $$ = mm_strdup("treat");
14612 }
14613 | TRIM
14614 {
14615 $$ = mm_strdup("trim");
14616 }
14617 | VARCHAR
14618 {
14619 $$ = mm_strdup("varchar");
14620 }
14621 | XMLATTRIBUTES
14622 {
14623 $$ = mm_strdup("xmlattributes");
14624 }
14625 | XMLCONCAT
14626 {
14627 $$ = mm_strdup("xmlconcat");
14628 }
14629 | XMLELEMENT
14630 {
14631 $$ = mm_strdup("xmlelement");
14632 }
14633 | XMLEXISTS
14634 {
14635 $$ = mm_strdup("xmlexists");
14636 }
14637 | XMLFOREST
14638 {
14639 $$ = mm_strdup("xmlforest");
14640 }
14641 | XMLNAMESPACES
14642 {
14643 $$ = mm_strdup("xmlnamespaces");
14644 }
14645 | XMLPARSE
14646 {
14647 $$ = mm_strdup("xmlparse");
14648 }
14649 | XMLPI
14650 {
14651 $$ = mm_strdup("xmlpi");
14652 }
14653 | XMLROOT
14654 {
14655 $$ = mm_strdup("xmlroot");
14656 }
14657 | XMLSERIALIZE
14658 {
14659 $$ = mm_strdup("xmlserialize");
14660 }
14661 | XMLTABLE
14662 {
14663 $$ = mm_strdup("xmltable");
14664 }
14665 ;
14666
14667
14668 type_func_name_keyword:
14669 AUTHORIZATION
14670 {
14671 $$ = mm_strdup("authorization");
14672 }
14673 | BINARY
14674 {
14675 $$ = mm_strdup("binary");
14676 }
14677 | COLLATION
14678 {
14679 $$ = mm_strdup("collation");
14680 }
14681 | CONCURRENTLY
14682 {
14683 $$ = mm_strdup("concurrently");
14684 }
14685 | CROSS
14686 {
14687 $$ = mm_strdup("cross");
14688 }
14689 | CURRENT_SCHEMA
14690 {
14691 $$ = mm_strdup("current_schema");
14692 }
14693 | FREEZE
14694 {
14695 $$ = mm_strdup("freeze");
14696 }
14697 | FULL
14698 {
14699 $$ = mm_strdup("full");
14700 }
14701 | ILIKE
14702 {
14703 $$ = mm_strdup("ilike");
14704 }
14705 | INNER_P
14706 {
14707 $$ = mm_strdup("inner");
14708 }
14709 | IS
14710 {
14711 $$ = mm_strdup("is");
14712 }
14713 | ISNULL
14714 {
14715 $$ = mm_strdup("isnull");
14716 }
14717 | JOIN
14718 {
14719 $$ = mm_strdup("join");
14720 }
14721 | LEFT
14722 {
14723 $$ = mm_strdup("left");
14724 }
14725 | LIKE
14726 {
14727 $$ = mm_strdup("like");
14728 }
14729 | NATURAL
14730 {
14731 $$ = mm_strdup("natural");
14732 }
14733 | NOTNULL
14734 {
14735 $$ = mm_strdup("notnull");
14736 }
14737 | OUTER_P
14738 {
14739 $$ = mm_strdup("outer");
14740 }
14741 | OVERLAPS
14742 {
14743 $$ = mm_strdup("overlaps");
14744 }
14745 | RIGHT
14746 {
14747 $$ = mm_strdup("right");
14748 }
14749 | SIMILAR
14750 {
14751 $$ = mm_strdup("similar");
14752 }
14753 | TABLESAMPLE
14754 {
14755 $$ = mm_strdup("tablesample");
14756 }
14757 | VERBOSE
14758 {
14759 $$ = mm_strdup("verbose");
14760 }
14761 ;
14762
14763
14764 reserved_keyword:
14765 ALL
14766 {
14767 $$ = mm_strdup("all");
14768 }
14769 | ANALYSE
14770 {
14771 $$ = mm_strdup("analyse");
14772 }
14773 | ANALYZE
14774 {
14775 $$ = mm_strdup("analyze");
14776 }
14777 | AND
14778 {
14779 $$ = mm_strdup("and");
14780 }
14781 | ANY
14782 {
14783 $$ = mm_strdup("any");
14784 }
14785 | ARRAY
14786 {
14787 $$ = mm_strdup("array");
14788 }
14789 | AS
14790 {
14791 $$ = mm_strdup("as");
14792 }
14793 | ASC
14794 {
14795 $$ = mm_strdup("asc");
14796 }
14797 | ASYMMETRIC
14798 {
14799 $$ = mm_strdup("asymmetric");
14800 }
14801 | BOTH
14802 {
14803 $$ = mm_strdup("both");
14804 }
14805 | CASE
14806 {
14807 $$ = mm_strdup("case");
14808 }
14809 | CAST
14810 {
14811 $$ = mm_strdup("cast");
14812 }
14813 | CHECK
14814 {
14815 $$ = mm_strdup("check");
14816 }
14817 | COLLATE
14818 {
14819 $$ = mm_strdup("collate");
14820 }
14821 | COLUMN
14822 {
14823 $$ = mm_strdup("column");
14824 }
14825 | CONSTRAINT
14826 {
14827 $$ = mm_strdup("constraint");
14828 }
14829 | CREATE
14830 {
14831 $$ = mm_strdup("create");
14832 }
14833 | CURRENT_CATALOG
14834 {
14835 $$ = mm_strdup("current_catalog");
14836 }
14837 | CURRENT_DATE
14838 {
14839 $$ = mm_strdup("current_date");
14840 }
14841 | CURRENT_ROLE
14842 {
14843 $$ = mm_strdup("current_role");
14844 }
14845 | CURRENT_TIME
14846 {
14847 $$ = mm_strdup("current_time");
14848 }
14849 | CURRENT_TIMESTAMP
14850 {
14851 $$ = mm_strdup("current_timestamp");
14852 }
14853 | CURRENT_USER
14854 {
14855 $$ = mm_strdup("current_user");
14856 }
14857 | DEFAULT
14858 {
14859 $$ = mm_strdup("default");
14860 }
14861 | DEFERRABLE
14862 {
14863 $$ = mm_strdup("deferrable");
14864 }
14865 | DESC
14866 {
14867 $$ = mm_strdup("desc");
14868 }
14869 | DISTINCT
14870 {
14871 $$ = mm_strdup("distinct");
14872 }
14873 | DO
14874 {
14875 $$ = mm_strdup("do");
14876 }
14877 | ELSE
14878 {
14879 $$ = mm_strdup("else");
14880 }
14881 | END_P
14882 {
14883 $$ = mm_strdup("end");
14884 }
14885 | EXCEPT
14886 {
14887 $$ = mm_strdup("except");
14888 }
14889 | FALSE_P
14890 {
14891 $$ = mm_strdup("false");
14892 }
14893 | FETCH
14894 {
14895 $$ = mm_strdup("fetch");
14896 }
14897 | FOR
14898 {
14899 $$ = mm_strdup("for");
14900 }
14901 | FOREIGN
14902 {
14903 $$ = mm_strdup("foreign");
14904 }
14905 | FROM
14906 {
14907 $$ = mm_strdup("from");
14908 }
14909 | GRANT
14910 {
14911 $$ = mm_strdup("grant");
14912 }
14913 | GROUP_P
14914 {
14915 $$ = mm_strdup("group");
14916 }
14917 | HAVING
14918 {
14919 $$ = mm_strdup("having");
14920 }
14921 | IN_P
14922 {
14923 $$ = mm_strdup("in");
14924 }
14925 | INITIALLY
14926 {
14927 $$ = mm_strdup("initially");
14928 }
14929 | INTERSECT
14930 {
14931 $$ = mm_strdup("intersect");
14932 }
14933 | INTO
14934 {
14935 $$ = mm_strdup("into");
14936 }
14937 | LATERAL_P
14938 {
14939 $$ = mm_strdup("lateral");
14940 }
14941 | LEADING
14942 {
14943 $$ = mm_strdup("leading");
14944 }
14945 | LIMIT
14946 {
14947 $$ = mm_strdup("limit");
14948 }
14949 | LOCALTIME
14950 {
14951 $$ = mm_strdup("localtime");
14952 }
14953 | LOCALTIMESTAMP
14954 {
14955 $$ = mm_strdup("localtimestamp");
14956 }
14957 | NOT
14958 {
14959 $$ = mm_strdup("not");
14960 }
14961 | NULL_P
14962 {
14963 $$ = mm_strdup("null");
14964 }
14965 | OFFSET
14966 {
14967 $$ = mm_strdup("offset");
14968 }
14969 | ON
14970 {
14971 $$ = mm_strdup("on");
14972 }
14973 | ONLY
14974 {
14975 $$ = mm_strdup("only");
14976 }
14977 | OR
14978 {
14979 $$ = mm_strdup("or");
14980 }
14981 | ORDER
14982 {
14983 $$ = mm_strdup("order");
14984 }
14985 | PLACING
14986 {
14987 $$ = mm_strdup("placing");
14988 }
14989 | PRIMARY
14990 {
14991 $$ = mm_strdup("primary");
14992 }
14993 | REFERENCES
14994 {
14995 $$ = mm_strdup("references");
14996 }
14997 | RETURNING
14998 {
14999 $$ = mm_strdup("returning");
15000 }
15001 | SELECT
15002 {
15003 $$ = mm_strdup("select");
15004 }
15005 | SESSION_USER
15006 {
15007 $$ = mm_strdup("session_user");
15008 }
15009 | SOME
15010 {
15011 $$ = mm_strdup("some");
15012 }
15013 | SYMMETRIC
15014 {
15015 $$ = mm_strdup("symmetric");
15016 }
15017 | TABLE
15018 {
15019 $$ = mm_strdup("table");
15020 }
15021 | THEN
15022 {
15023 $$ = mm_strdup("then");
15024 }
15025 | TRAILING
15026 {
15027 $$ = mm_strdup("trailing");
15028 }
15029 | TRUE_P
15030 {
15031 $$ = mm_strdup("true");
15032 }
15033 | UNIQUE
15034 {
15035 $$ = mm_strdup("unique");
15036 }
15037 | USER
15038 {
15039 $$ = mm_strdup("user");
15040 }
15041 | USING
15042 {
15043 $$ = mm_strdup("using");
15044 }
15045 | VARIADIC
15046 {
15047 $$ = mm_strdup("variadic");
15048 }
15049 | WHEN
15050 {
15051 $$ = mm_strdup("when");
15052 }
15053 | WHERE
15054 {
15055 $$ = mm_strdup("where");
15056 }
15057 | WINDOW
15058 {
15059 $$ = mm_strdup("window");
15060 }
15061 | WITH
15062 {
15063 $$ = mm_strdup("with");
15064 }
15065 ;
15066
15067
15068 /* trailer */
15069 /* src/interfaces/ecpg/preproc/ecpg.trailer */
15070
15071 statements: /*EMPTY*/
15072 | statements statement
15073 ;
15074
15075 statement: ecpgstart at stmt ';' { connection = NULL; }
15076 | ecpgstart stmt ';'
15077 | ecpgstart ECPGVarDeclaration
15078 {
15079 fprintf(base_yyout, "%s", $2);
15080 free($2);
15081 output_line_number();
15082 }
15083 | ECPGDeclaration
15084 | c_thing { fprintf(base_yyout, "%s", $1); free($1); }
15085 | CPP_LINE { fprintf(base_yyout, "%s", $1); free($1); }
15086 | '{' { braces_open++; fputs("{", base_yyout); }
15087 | '}'
15088 {
15089 remove_typedefs(braces_open);
15090 remove_variables(braces_open--);
15091 if (braces_open == 0)
15092 {
15093 free(current_function);
15094 current_function = NULL;
15095 }
15096 fputs("}", base_yyout);
15097 }
15098 ;
15099
15100 CreateAsStmt: CREATE OptTemp TABLE create_as_target AS {FoundInto = 0;} SelectStmt opt_with_data
15101 {
15102 if (FoundInto == 1)
15103 mmerror(PARSE_ERROR, ET_ERROR, "CREATE TABLE AS cannot specify INTO");
15104
15105 $$ = cat_str(7, mm_strdup("create"), $2, mm_strdup("table"), $4, mm_strdup("as"), $7, $8);
15106 }
15107 | CREATE OptTemp TABLE IF_P NOT EXISTS create_as_target AS {FoundInto = 0;} SelectStmt opt_with_data
15108 {
15109 if (FoundInto == 1)
15110 mmerror(PARSE_ERROR, ET_ERROR, "CREATE TABLE AS cannot specify INTO");
15111
15112 $$ = cat_str(7, mm_strdup("create"), $2, mm_strdup("table if not exists"), $7, mm_strdup("as"), $10, $11);
15113 }
15114 ;
15115
15116 at: AT connection_object
15117 {
15118 connection = $2;
15119 /*
15120 * Do we have a variable as connection target? Remove the variable
15121 * from the variable list or else it will be used twice.
15122 */
15123 if (argsinsert != NULL)
15124 argsinsert = NULL;
15125 }
15126 ;
15127
15128 /*
15129 * the exec sql connect statement: connect to the given database
15130 */
15131 ECPGConnect: SQL_CONNECT TO connection_target opt_connection_name opt_user
15132 { $$ = cat_str(5, $3, mm_strdup(","), $5, mm_strdup(","), $4); }
15133 | SQL_CONNECT TO DEFAULT
15134 { $$ = mm_strdup("NULL, NULL, NULL, \"DEFAULT\""); }
15135 /* also allow ORACLE syntax */
15136 | SQL_CONNECT ora_user
15137 { $$ = cat_str(3, mm_strdup("NULL,"), $2, mm_strdup(", NULL")); }
15138 | DATABASE connection_target
15139 { $$ = cat2_str($2, mm_strdup(", NULL, NULL, NULL")); }
15140 ;
15141
15142 connection_target: opt_database_name opt_server opt_port
15143 {
15144 /* old style: dbname[@server][:port] */
15145 if (strlen($2) > 0 && *($2) != '@')
15146 mmerror(PARSE_ERROR, ET_ERROR, "expected \"@\", found \"%s\"", $2);
15147
15148 /* C strings need to be handled differently */
15149 if ($1[0] == '\"')
15150 $$ = $1;
15151 else
15152 $$ = make3_str(mm_strdup("\""), make3_str($1, $2, $3), mm_strdup("\""));
15153 }
15154 | db_prefix ':' server opt_port '/' opt_database_name opt_options
15155 {
15156 /* new style: <tcp|unix>:postgresql://server[:port][/dbname] */
15157 if (strncmp($1, "unix:postgresql", strlen("unix:postgresql")) != 0 && strncmp($1, "tcp:postgresql", strlen("tcp:postgresql")) != 0)
15158 mmerror(PARSE_ERROR, ET_ERROR, "only protocols \"tcp\" and \"unix\" and database type \"postgresql\" are supported");
15159
15160 if (strncmp($3, "//", strlen("//")) != 0)
15161 mmerror(PARSE_ERROR, ET_ERROR, "expected \"://\", found \"%s\"", $3);
15162
15163 if (strncmp($1, "unix", strlen("unix")) == 0 &&
15164 strncmp($3 + strlen("//"), "localhost", strlen("localhost")) != 0 &&
15165 strncmp($3 + strlen("//"), "127.0.0.1", strlen("127.0.0.1")) != 0)
15166 mmerror(PARSE_ERROR, ET_ERROR, "Unix-domain sockets only work on \"localhost\" but not on \"%s\"", $3 + strlen("//"));
15167
15168 $$ = make3_str(make3_str(mm_strdup("\""), $1, mm_strdup(":")), $3, make3_str(make3_str($4, mm_strdup("/"), $6), $7, mm_strdup("\"")));
15169 }
15170 | char_variable
15171 {
15172 $$ = $1;
15173 }
15174 | ecpg_sconst
15175 {
15176 /* We can only process double quoted strings not single quotes ones,
15177 * so we change the quotes.
15178 * Note, that the rule for ecpg_sconst adds these single quotes. */
15179 $1[0] = '\"';
15180 $1[strlen($1)-1] = '\"';
15181 $$ = $1;
15182 }
15183 ;
15184
15185 opt_database_name: database_name { $$ = $1; }
15186 | /*EMPTY*/ { $$ = EMPTY; }
15187 ;
15188
15189 db_prefix: ecpg_ident cvariable
15190 {
15191 if (strcmp($2, "postgresql") != 0 && strcmp($2, "postgres") != 0)
15192 mmerror(PARSE_ERROR, ET_ERROR, "expected \"postgresql\", found \"%s\"", $2);
15193
15194 if (strcmp($1, "tcp") != 0 && strcmp($1, "unix") != 0)
15195 mmerror(PARSE_ERROR, ET_ERROR, "invalid connection type: %s", $1);
15196
15197 $$ = make3_str($1, mm_strdup(":"), $2);
15198 }
15199 ;
15200
15201 server: Op server_name
15202 {
15203 if (strcmp($1, "@") != 0 && strcmp($1, "//") != 0)
15204 mmerror(PARSE_ERROR, ET_ERROR, "expected \"@\" or \"://\", found \"%s\"", $1);
15205
15206 $$ = make2_str($1, $2);
15207 }
15208 ;
15209
15210 opt_server: server { $$ = $1; }
15211 | /*EMPTY*/ { $$ = EMPTY; }
15212 ;
15213
15214 server_name: ColId { $$ = $1; }
15215 | ColId '.' server_name { $$ = make3_str($1, mm_strdup("."), $3); }
15216 | IP { $$ = make_name(); }
15217 ;
15218
15219 opt_port: ':' Iconst { $$ = make2_str(mm_strdup(":"), $2); }
15220 | /*EMPTY*/ { $$ = EMPTY; }
15221 ;
15222
15223 opt_connection_name: AS connection_object { $$ = $2; }
15224 | /*EMPTY*/ { $$ = mm_strdup("NULL"); }
15225 ;
15226
15227 opt_user: USER ora_user { $$ = $2; }
15228 | /*EMPTY*/ { $$ = mm_strdup("NULL, NULL"); }
15229 ;
15230
15231 ora_user: user_name
15232 { $$ = cat2_str($1, mm_strdup(", NULL")); }
15233 | user_name '/' user_name
15234 { $$ = cat_str(3, $1, mm_strdup(","), $3); }
15235 | user_name SQL_IDENTIFIED BY user_name
15236 { $$ = cat_str(3, $1, mm_strdup(","), $4); }
15237 | user_name USING user_name
15238 { $$ = cat_str(3, $1, mm_strdup(","), $3); }
15239 ;
15240
15241 user_name: RoleId
15242 {
15243 if ($1[0] == '\"')
15244 $$ = $1;
15245 else
15246 $$ = make3_str(mm_strdup("\""), $1, mm_strdup("\""));
15247 }
15248 | ecpg_sconst
15249 {
15250 if ($1[0] == '\"')
15251 $$ = $1;
15252 else
15253 $$ = make3_str(mm_strdup("\""), $1, mm_strdup("\""));
15254 }
15255 | civar
15256 {
15257 enum ECPGttype type = argsinsert->variable->type->type;
15258
15259 /* if array see what's inside */
15260 if (type == ECPGt_array)
15261 type = argsinsert->variable->type->u.element->type;
15262
15263 /* handle varchars */
15264 if (type == ECPGt_varchar)
15265 $$ = make2_str(mm_strdup(argsinsert->variable->name), mm_strdup(".arr"));
15266 else
15267 $$ = mm_strdup(argsinsert->variable->name);
15268 }
15269 ;
15270
15271 char_variable: cvariable
15272 {
15273 /* check if we have a string variable */
15274 struct variable *p = find_variable($1);
15275 enum ECPGttype type = p->type->type;
15276
15277 /* If we have just one character this is not a string */
15278 if (atol(p->type->size) == 1)
15279 mmerror(PARSE_ERROR, ET_ERROR, "invalid data type");
15280 else
15281 {
15282 /* if array see what's inside */
15283 if (type == ECPGt_array)
15284 type = p->type->u.element->type;
15285
15286 switch (type)
15287 {
15288 case ECPGt_char:
15289 case ECPGt_unsigned_char:
15290 case ECPGt_string:
15291 $$ = $1;
15292 break;
15293 case ECPGt_varchar:
15294 $$ = make2_str($1, mm_strdup(".arr"));
15295 break;
15296 default:
15297 mmerror(PARSE_ERROR, ET_ERROR, "invalid data type");
15298 $$ = $1;
15299 break;
15300 }
15301 }
15302 }
15303 ;
15304
15305 opt_options: Op connect_options
15306 {
15307 if (strlen($1) == 0)
15308 mmerror(PARSE_ERROR, ET_ERROR, "incomplete statement");
15309
15310 if (strcmp($1, "?") != 0)
15311 mmerror(PARSE_ERROR, ET_ERROR, "unrecognized token \"%s\"", $1);
15312
15313 $$ = make2_str(mm_strdup("?"), $2);
15314 }
15315 | /*EMPTY*/ { $$ = EMPTY; }
15316 ;
15317
15318 connect_options: ColId opt_opt_value
15319 {
15320 $$ = make2_str($1, $2);
15321 }
15322 | ColId opt_opt_value Op connect_options
15323 {
15324 if (strlen($3) == 0)
15325 mmerror(PARSE_ERROR, ET_ERROR, "incomplete statement");
15326
15327 if (strcmp($3, "&") != 0)
15328 mmerror(PARSE_ERROR, ET_ERROR, "unrecognized token \"%s\"", $3);
15329
15330 $$ = cat_str(3, make2_str($1, $2), $3, $4);
15331 }
15332 ;
15333
15334 opt_opt_value: /*EMPTY*/
15335 { $$ = EMPTY; }
15336 | '=' Iconst
15337 { $$ = make2_str(mm_strdup("="), $2); }
15338 | '=' ecpg_ident
15339 { $$ = make2_str(mm_strdup("="), $2); }
15340 | '=' civar
15341 { $$ = make2_str(mm_strdup("="), $2); }
15342 ;
15343
15344 prepared_name: name
15345 {
15346 if ($1[0] == '\"' && $1[strlen($1)-1] == '\"') /* already quoted? */
15347 $$ = $1;
15348 else /* not quoted => convert to lowercase */
15349 {
15350 size_t i;
15351
15352 for (i = 0; i< strlen($1); i++)
15353 $1[i] = tolower((unsigned char) $1[i]);
15354
15355 $$ = make3_str(mm_strdup("\""), $1, mm_strdup("\""));
15356 }
15357 }
15358 | char_variable { $$ = $1; }
15359 ;
15360
15361 /*
15362 * Declare a prepared cursor. The syntax is different from the standard
15363 * declare statement, so we create a new rule.
15364 */
15365 ECPGCursorStmt: DECLARE cursor_name cursor_options CURSOR opt_hold FOR prepared_name
15366 {
15367 struct cursor *ptr, *this;
15368 char *cursor_marker = $2[0] == ':' ? mm_strdup("$0") : mm_strdup($2);
15369 int (* strcmp_fn)(const char *, const char *) = (($2[0] == ':' || $2[0] == '"') ? strcmp : pg_strcasecmp);
15370 struct variable *thisquery = (struct variable *)mm_alloc(sizeof(struct variable));
15371 const char *con = connection ? connection : "NULL";
15372 char *comment;
15373
15374 for (ptr = cur; ptr != NULL; ptr = ptr->next)
15375 {
15376 if (strcmp_fn($2, ptr->name) == 0)
15377 {
15378 /* re-definition is a bug */
15379 if ($2[0] == ':')
15380 mmerror(PARSE_ERROR, ET_ERROR, "using variable \"%s\" in different declare statements is not supported", $2+1);
15381 else
15382 mmerror(PARSE_ERROR, ET_ERROR, "cursor \"%s\" is already defined", $2);
15383 }
15384 }
15385
15386 this = (struct cursor *) mm_alloc(sizeof(struct cursor));
15387
15388 /* initial definition */
15389 this->next = cur;
15390 this->name = $2;
15391 this->function = (current_function ? mm_strdup(current_function) : NULL);
15392 this->connection = connection;
15393 this->command = cat_str(6, mm_strdup("declare"), cursor_marker, $3, mm_strdup("cursor"), $5, mm_strdup("for $1"));
15394 this->argsresult = NULL;
15395 this->argsresult_oos = NULL;
15396
15397 thisquery->type = &ecpg_query;
15398 thisquery->brace_level = 0;
15399 thisquery->next = NULL;
15400 thisquery->name = (char *) mm_alloc(sizeof("ECPGprepared_statement(, , __LINE__)") + strlen(con) + strlen($7));
15401 sprintf(thisquery->name, "ECPGprepared_statement(%s, %s, __LINE__)", con, $7);
15402
15403 this->argsinsert = NULL;
15404 this->argsinsert_oos = NULL;
15405 if ($2[0] == ':')
15406 {
15407 struct variable *var = find_variable($2 + 1);
15408 remove_variable_from_list(&argsinsert, var);
15409 add_variable_to_head(&(this->argsinsert), var, &no_indicator);
15410 }
15411 add_variable_to_head(&(this->argsinsert), thisquery, &no_indicator);
15412
15413 cur = this;
15414
15415 comment = cat_str(3, mm_strdup("/*"), mm_strdup(this->command), mm_strdup("*/"));
15416
15417 $$ = cat_str(2, adjust_outofscope_cursor_vars(this),
15418 comment);
15419 }
15420 ;
15421
15422 ECPGExecuteImmediateStmt: EXECUTE IMMEDIATE execstring
15423 {
15424 /* execute immediate means prepare the statement and
15425 * immediately execute it */
15426 $$ = $3;
15427 };
15428 /*
15429 * variable declaration outside exec sql declare block
15430 */
15431 ECPGVarDeclaration: single_vt_declaration;
15432
15433 single_vt_declaration: type_declaration { $$ = $1; }
15434 | var_declaration { $$ = $1; }
15435 ;
15436
15437 precision: NumericOnly { $$ = $1; };
15438
15439 opt_scale: ',' NumericOnly { $$ = $2; }
15440 | /* EMPTY */ { $$ = EMPTY; }
15441 ;
15442
15443 ecpg_interval: opt_interval { $$ = $1; }
15444 | YEAR_P TO MINUTE_P { $$ = mm_strdup("year to minute"); }
15445 | YEAR_P TO SECOND_P { $$ = mm_strdup("year to second"); }
15446 | DAY_P TO DAY_P { $$ = mm_strdup("day to day"); }
15447 | MONTH_P TO MONTH_P { $$ = mm_strdup("month to month"); }
15448 ;
15449
15450 /*
15451 * variable declaration inside exec sql declare block
15452 */
15453 ECPGDeclaration: sql_startdeclare
15454 { fputs("/* exec sql begin declare section */", base_yyout); }
15455 var_type_declarations sql_enddeclare
15456 {
15457 fprintf(base_yyout, "%s/* exec sql end declare section */", $3);
15458 free($3);
15459 output_line_number();
15460 }
15461 ;
15462
15463 sql_startdeclare: ecpgstart BEGIN_P DECLARE SQL_SECTION ';' {};
15464
15465 sql_enddeclare: ecpgstart END_P DECLARE SQL_SECTION ';' {};
15466
15467 var_type_declarations: /*EMPTY*/ { $$ = EMPTY; }
15468 | vt_declarations { $$ = $1; }
15469 ;
15470
15471 vt_declarations: single_vt_declaration { $$ = $1; }
15472 | CPP_LINE { $$ = $1; }
15473 | vt_declarations single_vt_declaration { $$ = cat2_str($1, $2); }
15474 | vt_declarations CPP_LINE { $$ = cat2_str($1, $2); }
15475 ;
15476
15477 variable_declarations: var_declaration { $$ = $1; }
15478 | variable_declarations var_declaration { $$ = cat2_str($1, $2); }
15479 ;
15480
15481 type_declaration: S_TYPEDEF
15482 {
15483 /* reset this variable so we see if there was */
15484 /* an initializer specified */
15485 initializer = 0;
15486 }
15487 var_type opt_pointer ECPGColLabelCommon opt_array_bounds ';'
15488 {
15489 add_typedef($5, $6.index1, $6.index2, $3.type_enum, $3.type_dimension, $3.type_index, initializer, *$4 ? 1 : 0);
15490
15491 fprintf(base_yyout, "typedef %s %s %s %s;\n", $3.type_str, *$4 ? "*" : "", $5, $6.str);
15492 output_line_number();
15493 $$ = mm_strdup("");
15494 };
15495
15496 var_declaration: storage_declaration
15497 var_type
15498 {
15499 actual_type[struct_level].type_enum = $2.type_enum;
15500 actual_type[struct_level].type_str = $2.type_str;
15501 actual_type[struct_level].type_dimension = $2.type_dimension;
15502 actual_type[struct_level].type_index = $2.type_index;
15503 actual_type[struct_level].type_sizeof = $2.type_sizeof;
15504
15505 actual_startline[struct_level] = hashline_number();
15506 }
15507 variable_list ';'
15508 {
15509 $$ = cat_str(5, actual_startline[struct_level], $1, $2.type_str, $4, mm_strdup(";\n"));
15510 }
15511 | var_type
15512 {
15513 actual_type[struct_level].type_enum = $1.type_enum;
15514 actual_type[struct_level].type_str = $1.type_str;
15515 actual_type[struct_level].type_dimension = $1.type_dimension;
15516 actual_type[struct_level].type_index = $1.type_index;
15517 actual_type[struct_level].type_sizeof = $1.type_sizeof;
15518
15519 actual_startline[struct_level] = hashline_number();
15520 }
15521 variable_list ';'
15522 {
15523 $$ = cat_str(4, actual_startline[struct_level], $1.type_str, $3, mm_strdup(";\n"));
15524 }
15525 | struct_union_type_with_symbol ';'
15526 {
15527 $$ = cat2_str($1, mm_strdup(";"));
15528 }
15529 ;
15530
15531 opt_bit_field: ':' Iconst { $$ =cat2_str(mm_strdup(":"), $2); }
15532 | /* EMPTY */ { $$ = EMPTY; }
15533 ;
15534
15535 storage_declaration: storage_clause storage_modifier
15536 {$$ = cat2_str ($1, $2); }
15537 | storage_clause {$$ = $1; }
15538 | storage_modifier {$$ = $1; }
15539 ;
15540
15541 storage_clause : S_EXTERN { $$ = mm_strdup("extern"); }
15542 | S_STATIC { $$ = mm_strdup("static"); }
15543 | S_REGISTER { $$ = mm_strdup("register"); }
15544 | S_AUTO { $$ = mm_strdup("auto"); }
15545 ;
15546
15547 storage_modifier : S_CONST { $$ = mm_strdup("const"); }
15548 | S_VOLATILE { $$ = mm_strdup("volatile"); }
15549 ;
15550
15551 var_type: simple_type
15552 {
15553 $$.type_enum = $1;
15554 $$.type_str = mm_strdup(ecpg_type_name($1));
15555 $$.type_dimension = mm_strdup("-1");
15556 $$.type_index = mm_strdup("-1");
15557 $$.type_sizeof = NULL;
15558 }
15559 | struct_union_type
15560 {
15561 $$.type_str = $1;
15562 $$.type_dimension = mm_strdup("-1");
15563 $$.type_index = mm_strdup("-1");
15564
15565 if (strncmp($1, "struct", sizeof("struct")-1) == 0)
15566 {
15567 $$.type_enum = ECPGt_struct;
15568 $$.type_sizeof = ECPGstruct_sizeof;
15569 }
15570 else
15571 {
15572 $$.type_enum = ECPGt_union;
15573 $$.type_sizeof = NULL;
15574 }
15575 }
15576 | enum_type
15577 {
15578 $$.type_str = $1;
15579 $$.type_enum = ECPGt_int;
15580 $$.type_dimension = mm_strdup("-1");
15581 $$.type_index = mm_strdup("-1");
15582 $$.type_sizeof = NULL;
15583 }
15584 | ECPGColLabelCommon '(' precision opt_scale ')'
15585 {
15586 if (strcmp($1, "numeric") == 0)
15587 {
15588 $$.type_enum = ECPGt_numeric;
15589 $$.type_str = mm_strdup("numeric");
15590 }
15591 else if (strcmp($1, "decimal") == 0)
15592 {
15593 $$.type_enum = ECPGt_decimal;
15594 $$.type_str = mm_strdup("decimal");
15595 }
15596 else
15597 {
15598 mmerror(PARSE_ERROR, ET_ERROR, "only data types numeric and decimal have precision/scale argument");
15599 $$.type_enum = ECPGt_numeric;
15600 $$.type_str = mm_strdup("numeric");
15601 }
15602
15603 $$.type_dimension = mm_strdup("-1");
15604 $$.type_index = mm_strdup("-1");
15605 $$.type_sizeof = NULL;
15606 }
15607 | ECPGColLabelCommon ecpg_interval
15608 {
15609 if (strlen($2) != 0 && strcmp ($1, "datetime") != 0 && strcmp ($1, "interval") != 0)
15610 mmerror (PARSE_ERROR, ET_ERROR, "interval specification not allowed here");
15611
15612 /*
15613 * Check for type names that the SQL grammar treats as
15614 * unreserved keywords
15615 */
15616 if (strcmp($1, "varchar") == 0)
15617 {
15618 $$.type_enum = ECPGt_varchar;
15619 $$.type_str = EMPTY; /*mm_strdup("varchar");*/
15620 $$.type_dimension = mm_strdup("-1");
15621 $$.type_index = mm_strdup("-1");
15622 $$.type_sizeof = NULL;
15623 }
15624 else if (strcmp($1, "bytea") == 0)
15625 {
15626 $$.type_enum = ECPGt_bytea;
15627 $$.type_str = EMPTY;
15628 $$.type_dimension = mm_strdup("-1");
15629 $$.type_index = mm_strdup("-1");
15630 $$.type_sizeof = NULL;
15631 }
15632 else if (strcmp($1, "float") == 0)
15633 {
15634 $$.type_enum = ECPGt_float;
15635 $$.type_str = mm_strdup("float");
15636 $$.type_dimension = mm_strdup("-1");
15637 $$.type_index = mm_strdup("-1");
15638 $$.type_sizeof = NULL;
15639 }
15640 else if (strcmp($1, "double") == 0)
15641 {
15642 $$.type_enum = ECPGt_double;
15643 $$.type_str = mm_strdup("double");
15644 $$.type_dimension = mm_strdup("-1");
15645 $$.type_index = mm_strdup("-1");
15646 $$.type_sizeof = NULL;
15647 }
15648 else if (strcmp($1, "numeric") == 0)
15649 {
15650 $$.type_enum = ECPGt_numeric;
15651 $$.type_str = mm_strdup("numeric");
15652 $$.type_dimension = mm_strdup("-1");
15653 $$.type_index = mm_strdup("-1");
15654 $$.type_sizeof = NULL;
15655 }
15656 else if (strcmp($1, "decimal") == 0)
15657 {
15658 $$.type_enum = ECPGt_decimal;
15659 $$.type_str = mm_strdup("decimal");
15660 $$.type_dimension = mm_strdup("-1");
15661 $$.type_index = mm_strdup("-1");
15662 $$.type_sizeof = NULL;
15663 }
15664 else if (strcmp($1, "date") == 0)
15665 {
15666 $$.type_enum = ECPGt_date;
15667 $$.type_str = mm_strdup("date");
15668 $$.type_dimension = mm_strdup("-1");
15669 $$.type_index = mm_strdup("-1");
15670 $$.type_sizeof = NULL;
15671 }
15672 else if (strcmp($1, "timestamp") == 0)
15673 {
15674 $$.type_enum = ECPGt_timestamp;
15675 $$.type_str = mm_strdup("timestamp");
15676 $$.type_dimension = mm_strdup("-1");
15677 $$.type_index = mm_strdup("-1");
15678 $$.type_sizeof = NULL;
15679 }
15680 else if (strcmp($1, "interval") == 0)
15681 {
15682 $$.type_enum = ECPGt_interval;
15683 $$.type_str = mm_strdup("interval");
15684 $$.type_dimension = mm_strdup("-1");
15685 $$.type_index = mm_strdup("-1");
15686 $$.type_sizeof = NULL;
15687 }
15688 else if (strcmp($1, "datetime") == 0)
15689 {
15690 $$.type_enum = ECPGt_timestamp;
15691 $$.type_str = mm_strdup("timestamp");
15692 $$.type_dimension = mm_strdup("-1");
15693 $$.type_index = mm_strdup("-1");
15694 $$.type_sizeof = NULL;
15695 }
15696 else if ((strcmp($1, "string") == 0) && INFORMIX_MODE)
15697 {
15698 $$.type_enum = ECPGt_string;
15699 $$.type_str = mm_strdup("char");
15700 $$.type_dimension = mm_strdup("-1");
15701 $$.type_index = mm_strdup("-1");
15702 $$.type_sizeof = NULL;
15703 }
15704 else
15705 {
15706 /* this is for typedef'ed types */
15707 struct typedefs *this = get_typedef($1);
15708
15709 $$.type_str = (this->type->type_enum == ECPGt_varchar || this->type->type_enum == ECPGt_bytea) ? EMPTY : mm_strdup(this->name);
15710 $$.type_enum = this->type->type_enum;
15711 $$.type_dimension = this->type->type_dimension;
15712 $$.type_index = this->type->type_index;
15713 if (this->type->type_sizeof && strlen(this->type->type_sizeof) != 0)
15714 $$.type_sizeof = this->type->type_sizeof;
15715 else
15716 $$.type_sizeof = cat_str(3, mm_strdup("sizeof("), mm_strdup(this->name), mm_strdup(")"));
15717
15718 struct_member_list[struct_level] = ECPGstruct_member_dup(this->struct_member_list);
15719 }
15720 }
15721 | s_struct_union_symbol
15722 {
15723 /* this is for named structs/unions */
15724 char *name;
15725 struct typedefs *this;
15726 bool forward = (forward_name != NULL && strcmp($1.symbol, forward_name) == 0 && strcmp($1.su, "struct") == 0);
15727
15728 name = cat2_str($1.su, $1.symbol);
15729 /* Do we have a forward definition? */
15730 if (!forward)
15731 {
15732 /* No */
15733
15734 this = get_typedef(name);
15735 $$.type_str = mm_strdup(this->name);
15736 $$.type_enum = this->type->type_enum;
15737 $$.type_dimension = this->type->type_dimension;
15738 $$.type_index = this->type->type_index;
15739 $$.type_sizeof = this->type->type_sizeof;
15740 struct_member_list[struct_level] = ECPGstruct_member_dup(this->struct_member_list);
15741 free(name);
15742 }
15743 else
15744 {
15745 $$.type_str = name;
15746 $$.type_enum = ECPGt_long;
15747 $$.type_dimension = mm_strdup("-1");
15748 $$.type_index = mm_strdup("-1");
15749 $$.type_sizeof = mm_strdup("");
15750 struct_member_list[struct_level] = NULL;
15751 }
15752 }
15753 ;
15754
15755 enum_type: ENUM_P symbol enum_definition
15756 { $$ = cat_str(3, mm_strdup("enum"), $2, $3); }
15757 | ENUM_P enum_definition
15758 { $$ = cat2_str(mm_strdup("enum"), $2); }
15759 | ENUM_P symbol
15760 { $$ = cat2_str(mm_strdup("enum"), $2); }
15761 ;
15762
15763 enum_definition: '{' c_list '}'
15764 { $$ = cat_str(3, mm_strdup("{"), $2, mm_strdup("}")); };
15765
15766 struct_union_type_with_symbol: s_struct_union_symbol
15767 {
15768 struct_member_list[struct_level++] = NULL;
15769 if (struct_level >= STRUCT_DEPTH)
15770 mmerror(PARSE_ERROR, ET_ERROR, "too many levels in nested structure/union definition");
15771 forward_name = mm_strdup($1.symbol);
15772 }
15773 '{' variable_declarations '}'
15774 {
15775 struct typedefs *ptr, *this;
15776 struct this_type su_type;
15777
15778 ECPGfree_struct_member(struct_member_list[struct_level]);
15779 struct_member_list[struct_level] = NULL;
15780 struct_level--;
15781 if (strncmp($1.su, "struct", sizeof("struct")-1) == 0)
15782 su_type.type_enum = ECPGt_struct;
15783 else
15784 su_type.type_enum = ECPGt_union;
15785 su_type.type_str = cat2_str($1.su, $1.symbol);
15786 free(forward_name);
15787 forward_name = NULL;
15788
15789 /* This is essentially a typedef but needs the keyword struct/union as well.
15790 * So we create the typedef for each struct definition with symbol */
15791 for (ptr = types; ptr != NULL; ptr = ptr->next)
15792 {
15793 if (strcmp(su_type.type_str, ptr->name) == 0)
15794 /* re-definition is a bug */
15795 mmerror(PARSE_ERROR, ET_ERROR, "type \"%s\" is already defined", su_type.type_str);
15796 }
15797
15798 this = (struct typedefs *) mm_alloc(sizeof(struct typedefs));
15799
15800 /* initial definition */
15801 this->next = types;
15802 this->name = mm_strdup(su_type.type_str);
15803 this->brace_level = braces_open;
15804 this->type = (struct this_type *) mm_alloc(sizeof(struct this_type));
15805 this->type->type_enum = su_type.type_enum;
15806 this->type->type_str = mm_strdup(su_type.type_str);
15807 this->type->type_dimension = mm_strdup("-1"); /* dimension of array */
15808 this->type->type_index = mm_strdup("-1"); /* length of string */
15809 this->type->type_sizeof = ECPGstruct_sizeof;
15810 this->struct_member_list = struct_member_list[struct_level];
15811
15812 types = this;
15813 $$ = cat_str(4, su_type.type_str, mm_strdup("{"), $4, mm_strdup("}"));
15814 }
15815 ;
15816
15817 struct_union_type: struct_union_type_with_symbol { $$ = $1; }
15818 | s_struct_union
15819 {
15820 struct_member_list[struct_level++] = NULL;
15821 if (struct_level >= STRUCT_DEPTH)
15822 mmerror(PARSE_ERROR, ET_ERROR, "too many levels in nested structure/union definition");
15823 }
15824 '{' variable_declarations '}'
15825 {
15826 ECPGfree_struct_member(struct_member_list[struct_level]);
15827 struct_member_list[struct_level] = NULL;
15828 struct_level--;
15829 $$ = cat_str(4, $1, mm_strdup("{"), $4, mm_strdup("}"));
15830 }
15831 ;
15832
15833 s_struct_union_symbol: SQL_STRUCT symbol
15834 {
15835 $$.su = mm_strdup("struct");
15836 $$.symbol = $2;
15837 ECPGstruct_sizeof = cat_str(3, mm_strdup("sizeof("), cat2_str(mm_strdup($$.su), mm_strdup($$.symbol)), mm_strdup(")"));
15838 }
15839 | UNION symbol
15840 {
15841 $$.su = mm_strdup("union");
15842 $$.symbol = $2;
15843 }
15844 ;
15845
15846 s_struct_union: SQL_STRUCT
15847 {
15848 ECPGstruct_sizeof = mm_strdup(""); /* This must not be NULL to distinguish from simple types. */
15849 $$ = mm_strdup("struct");
15850 }
15851 | UNION
15852 {
15853 $$ = mm_strdup("union");
15854 }
15855 ;
15856
15857 simple_type: unsigned_type { $$=$1; }
15858 | opt_signed signed_type { $$=$2; }
15859 ;
15860
15861 unsigned_type: SQL_UNSIGNED SQL_SHORT { $$ = ECPGt_unsigned_short; }
15862 | SQL_UNSIGNED SQL_SHORT INT_P { $$ = ECPGt_unsigned_short; }
15863 | SQL_UNSIGNED { $$ = ECPGt_unsigned_int; }
15864 | SQL_UNSIGNED INT_P { $$ = ECPGt_unsigned_int; }
15865 | SQL_UNSIGNED SQL_LONG { $$ = ECPGt_unsigned_long; }
15866 | SQL_UNSIGNED SQL_LONG INT_P { $$ = ECPGt_unsigned_long; }
15867 | SQL_UNSIGNED SQL_LONG SQL_LONG
15868 {
15869 #ifdef HAVE_LONG_LONG_INT
15870 $$ = ECPGt_unsigned_long_long;
15871 #else
15872 $$ = ECPGt_unsigned_long;
15873 #endif
15874 }
15875 | SQL_UNSIGNED SQL_LONG SQL_LONG INT_P
15876 {
15877 #ifdef HAVE_LONG_LONG_INT
15878 $$ = ECPGt_unsigned_long_long;
15879 #else
15880 $$ = ECPGt_unsigned_long;
15881 #endif
15882 }
15883 | SQL_UNSIGNED CHAR_P { $$ = ECPGt_unsigned_char; }
15884 ;
15885
15886 signed_type: SQL_SHORT { $$ = ECPGt_short; }
15887 | SQL_SHORT INT_P { $$ = ECPGt_short; }
15888 | INT_P { $$ = ECPGt_int; }
15889 | SQL_LONG { $$ = ECPGt_long; }
15890 | SQL_LONG INT_P { $$ = ECPGt_long; }
15891 | SQL_LONG SQL_LONG
15892 {
15893 #ifdef HAVE_LONG_LONG_INT
15894 $$ = ECPGt_long_long;
15895 #else
15896 $$ = ECPGt_long;
15897 #endif
15898 }
15899 | SQL_LONG SQL_LONG INT_P
15900 {
15901 #ifdef HAVE_LONG_LONG_INT
15902 $$ = ECPGt_long_long;
15903 #else
15904 $$ = ECPGt_long;
15905 #endif
15906 }
15907 | SQL_BOOL { $$ = ECPGt_bool; }
15908 | CHAR_P { $$ = ECPGt_char; }
15909 | DOUBLE_P { $$ = ECPGt_double; }
15910 ;
15911
15912 opt_signed: SQL_SIGNED
15913 | /* EMPTY */
15914 ;
15915
15916 variable_list: variable
15917 { $$ = $1; }
15918 | variable_list ',' variable
15919 {
15920 if (actual_type[struct_level].type_enum == ECPGt_varchar || actual_type[struct_level].type_enum == ECPGt_bytea)
15921 $$ = cat_str(3, $1, mm_strdup(";"), $3);
15922 else
15923 $$ = cat_str(3, $1, mm_strdup(","), $3);
15924 }
15925 ;
15926
15927 variable: opt_pointer ECPGColLabel opt_array_bounds opt_bit_field opt_initializer
15928 {
15929 struct ECPGtype * type;
15930 char *dimension = $3.index1; /* dimension of array */
15931 char *length = $3.index2; /* length of string */
15932 char *dim_str;
15933 char *vcn;
15934 int *varlen_type_counter;
15935 char *struct_name;
15936
15937 adjust_array(actual_type[struct_level].type_enum, &dimension, &length, actual_type[struct_level].type_dimension, actual_type[struct_level].type_index, strlen($1), false);
15938 switch (actual_type[struct_level].type_enum)
15939 {
15940 case ECPGt_struct:
15941 case ECPGt_union:
15942 if (atoi(dimension) < 0)
15943 type = ECPGmake_struct_type(struct_member_list[struct_level], actual_type[struct_level].type_enum, actual_type[struct_level].type_str, actual_type[struct_level].type_sizeof);
15944 else
15945 type = ECPGmake_array_type(ECPGmake_struct_type(struct_member_list[struct_level], actual_type[struct_level].type_enum, actual_type[struct_level].type_str, actual_type[struct_level].type_sizeof), dimension);
15946
15947 $$ = cat_str(5, $1, mm_strdup($2), $3.str, $4, $5);
15948 break;
15949
15950 case ECPGt_varchar:
15951 case ECPGt_bytea:
15952 if (actual_type[struct_level].type_enum == ECPGt_varchar)
15953 {
15954 varlen_type_counter = &varchar_counter;
15955 struct_name = " struct varchar_";
15956 }
15957 else
15958 {
15959 varlen_type_counter = &bytea_counter;
15960 struct_name = " struct bytea_";
15961 }
15962 if (atoi(dimension) < 0)
15963 type = ECPGmake_simple_type(actual_type[struct_level].type_enum, length, *varlen_type_counter);
15964 else
15965 type = ECPGmake_array_type(ECPGmake_simple_type(actual_type[struct_level].type_enum, length, *varlen_type_counter), dimension);
15966
15967 if (strcmp(dimension, "0") == 0 || abs(atoi(dimension)) == 1)
15968 dim_str=mm_strdup("");
15969 else
15970 dim_str=cat_str(3, mm_strdup("["), mm_strdup(dimension), mm_strdup("]"));
15971 /* cannot check for atoi <= 0 because a defined constant will yield 0 here as well */
15972 if (atoi(length) < 0 || strcmp(length, "0") == 0)
15973 mmerror(PARSE_ERROR, ET_ERROR, "pointers to varchar are not implemented");
15974
15975 /* make sure varchar struct name is unique by adding a unique counter to its definition */
15976 vcn = (char *) mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
15977 sprintf(vcn, "%d", *varlen_type_counter);
15978 if (strcmp(dimension, "0") == 0)
15979 $$ = cat_str(7, make2_str(mm_strdup(struct_name), vcn), mm_strdup(" { int len; char arr["), mm_strdup(length), mm_strdup("]; } *"), mm_strdup($2), $4, $5);
15980 else
15981 $$ = cat_str(8, make2_str(mm_strdup(struct_name), vcn), mm_strdup(" { int len; char arr["), mm_strdup(length), mm_strdup("]; } "), mm_strdup($2), dim_str, $4, $5);
15982 (*varlen_type_counter)++;
15983 break;
15984
15985 case ECPGt_char:
15986 case ECPGt_unsigned_char:
15987 case ECPGt_string:
15988 if (atoi(dimension) == -1)
15989 {
15990 int i = strlen($5);
15991
15992 if (atoi(length) == -1 && i > 0) /* char <var>[] = "string" */
15993 {
15994 /* if we have an initializer but no string size set, let's use the initializer's length */
15995 free(length);
15996 length = mm_alloc(i+sizeof("sizeof()"));
15997 sprintf(length, "sizeof(%s)", $5+2);
15998 }
15999 type = ECPGmake_simple_type(actual_type[struct_level].type_enum, length, 0);
16000 }
16001 else
16002 type = ECPGmake_array_type(ECPGmake_simple_type(actual_type[struct_level].type_enum, length, 0), dimension);
16003
16004 $$ = cat_str(5, $1, mm_strdup($2), $3.str, $4, $5);
16005 break;
16006
16007 default:
16008 if (atoi(dimension) < 0)
16009 type = ECPGmake_simple_type(actual_type[struct_level].type_enum, mm_strdup("1"), 0);
16010 else
16011 type = ECPGmake_array_type(ECPGmake_simple_type(actual_type[struct_level].type_enum, mm_strdup("1"), 0), dimension);
16012
16013 $$ = cat_str(5, $1, mm_strdup($2), $3.str, $4, $5);
16014 break;
16015 }
16016
16017 if (struct_level == 0)
16018 new_variable($2, type, braces_open);
16019 else
16020 ECPGmake_struct_member($2, type, &(struct_member_list[struct_level - 1]));
16021
16022 free($2);
16023 }
16024 ;
16025
16026 opt_initializer: /*EMPTY*/
16027 { $$ = EMPTY; }
16028 | '=' c_term
16029 {
16030 initializer = 1;
16031 $$ = cat2_str(mm_strdup("="), $2);
16032 }
16033 ;
16034
16035 opt_pointer: /*EMPTY*/ { $$ = EMPTY; }
16036 | '*' { $$ = mm_strdup("*"); }
16037 | '*' '*' { $$ = mm_strdup("**"); }
16038 ;
16039
16040 /*
16041 * We try to simulate the correct DECLARE syntax here so we get dynamic SQL
16042 */
16043 ECPGDeclare: DECLARE STATEMENT ecpg_ident
16044 {
16045 /* this is only supported for compatibility */
16046 $$ = cat_str(3, mm_strdup("/* declare statement"), $3, mm_strdup("*/"));
16047 }
16048 ;
16049 /*
16050 * the exec sql disconnect statement: disconnect from the given database
16051 */
16052 ECPGDisconnect: SQL_DISCONNECT dis_name { $$ = $2; }
16053 ;
16054
16055 dis_name: connection_object { $$ = $1; }
16056 | CURRENT_P { $$ = mm_strdup("\"CURRENT\""); }
16057 | ALL { $$ = mm_strdup("\"ALL\""); }
16058 | /* EMPTY */ { $$ = mm_strdup("\"CURRENT\""); }
16059 ;
16060
16061 connection_object: database_name { $$ = make3_str(mm_strdup("\""), $1, mm_strdup("\"")); }
16062 | DEFAULT { $$ = mm_strdup("\"DEFAULT\""); }
16063 | char_variable { $$ = $1; }
16064 ;
16065
16066 execstring: char_variable
16067 { $$ = $1; }
16068 | CSTRING
16069 { $$ = make3_str(mm_strdup("\""), $1, mm_strdup("\"")); }
16070 ;
16071
16072 /*
16073 * the exec sql free command to deallocate a previously
16074 * prepared statement
16075 */
16076 ECPGFree: SQL_FREE cursor_name { $$ = $2; }
16077 | SQL_FREE ALL { $$ = mm_strdup("all"); }
16078 ;
16079
16080 /*
16081 * open is an open cursor, at the moment this has to be removed
16082 */
16083 ECPGOpen: SQL_OPEN cursor_name opt_ecpg_using
16084 {
16085 if ($2[0] == ':')
16086 remove_variable_from_list(&argsinsert, find_variable($2 + 1));
16087 $$ = $2;
16088 }
16089 ;
16090
16091 opt_ecpg_using: /*EMPTY*/ { $$ = EMPTY; }
16092 | ecpg_using { $$ = $1; }
16093 ;
16094
16095 ecpg_using: USING using_list { $$ = EMPTY; }
16096 | using_descriptor { $$ = $1; }
16097 ;
16098
16099 using_descriptor: USING SQL_P SQL_DESCRIPTOR quoted_ident_stringvar
16100 {
16101 add_variable_to_head(&argsinsert, descriptor_variable($4,0), &no_indicator);
16102 $$ = EMPTY;
16103 }
16104 | USING SQL_DESCRIPTOR name
16105 {
16106 add_variable_to_head(&argsinsert, sqlda_variable($3), &no_indicator);
16107 $$ = EMPTY;
16108 }
16109 ;
16110
16111 into_descriptor: INTO SQL_P SQL_DESCRIPTOR quoted_ident_stringvar
16112 {
16113 add_variable_to_head(&argsresult, descriptor_variable($4,1), &no_indicator);
16114 $$ = EMPTY;
16115 }
16116 | INTO SQL_DESCRIPTOR name
16117 {
16118 add_variable_to_head(&argsresult, sqlda_variable($3), &no_indicator);
16119 $$ = EMPTY;
16120 }
16121 ;
16122
16123 into_sqlda: INTO name
16124 {
16125 add_variable_to_head(&argsresult, sqlda_variable($2), &no_indicator);
16126 $$ = EMPTY;
16127 }
16128 ;
16129
16130 using_list: UsingValue | UsingValue ',' using_list;
16131
16132 UsingValue: UsingConst
16133 {
16134 char *length = mm_alloc(32);
16135
16136 sprintf(length, "%d", (int) strlen($1));
16137 add_variable_to_head(&argsinsert, new_variable($1, ECPGmake_simple_type(ECPGt_const, length, 0), 0), &no_indicator);
16138 }
16139 | civar { $$ = EMPTY; }
16140 | civarind { $$ = EMPTY; }
16141 ;
16142
16143 UsingConst: Iconst { $$ = $1; }
16144 | '+' Iconst { $$ = cat_str(2, mm_strdup("+"), $2); }
16145 | '-' Iconst { $$ = cat_str(2, mm_strdup("-"), $2); }
16146 | ecpg_fconst { $$ = $1; }
16147 | '+' ecpg_fconst { $$ = cat_str(2, mm_strdup("+"), $2); }
16148 | '-' ecpg_fconst { $$ = cat_str(2, mm_strdup("-"), $2); }
16149 | ecpg_sconst { $$ = $1; }
16150 | ecpg_bconst { $$ = $1; }
16151 | ecpg_xconst { $$ = $1; }
16152 ;
16153
16154 /*
16155 * We accept DESCRIBE [OUTPUT] but do nothing with DESCRIBE INPUT so far.
16156 */
16157 ECPGDescribe: SQL_DESCRIBE INPUT_P prepared_name using_descriptor
16158 {
16159 const char *con = connection ? connection : "NULL";
16160 mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
16161 $$ = (char *) mm_alloc(sizeof("1, , ") + strlen(con) + strlen($3));
16162 sprintf($$, "1, %s, %s", con, $3);
16163 }
16164 | SQL_DESCRIBE opt_output prepared_name using_descriptor
16165 {
16166 const char *con = connection ? connection : "NULL";
16167 struct variable *var;
16168
16169 var = argsinsert->variable;
16170 remove_variable_from_list(&argsinsert, var);
16171 add_variable_to_head(&argsresult, var, &no_indicator);
16172
16173 $$ = (char *) mm_alloc(sizeof("0, , ") + strlen(con) + strlen($3));
16174 sprintf($$, "0, %s, %s", con, $3);
16175 }
16176 | SQL_DESCRIBE opt_output prepared_name into_descriptor
16177 {
16178 const char *con = connection ? connection : "NULL";
16179 $$ = (char *) mm_alloc(sizeof("0, , ") + strlen(con) + strlen($3));
16180 sprintf($$, "0, %s, %s", con, $3);
16181 }
16182 | SQL_DESCRIBE INPUT_P prepared_name into_sqlda
16183 {
16184 const char *con = connection ? connection : "NULL";
16185 mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
16186 $$ = (char *) mm_alloc(sizeof("1, , ") + strlen(con) + strlen($3));
16187 sprintf($$, "1, %s, %s", con, $3);
16188 }
16189 | SQL_DESCRIBE opt_output prepared_name into_sqlda
16190 {
16191 const char *con = connection ? connection : "NULL";
16192 $$ = (char *) mm_alloc(sizeof("0, , ") + strlen(con) + strlen($3));
16193 sprintf($$, "0, %s, %s", con, $3);
16194 }
16195 ;
16196
16197 opt_output: SQL_OUTPUT { $$ = mm_strdup("output"); }
16198 | /* EMPTY */ { $$ = EMPTY; }
16199 ;
16200
16201 /*
16202 * dynamic SQL: descriptor based access
16203 * originally written by Christof Petig <christof.petig@wtal.de>
16204 * and Peter Eisentraut <peter.eisentraut@credativ.de>
16205 */
16206
16207 /*
16208 * allocate a descriptor
16209 */
16210 ECPGAllocateDescr: SQL_ALLOCATE SQL_DESCRIPTOR quoted_ident_stringvar
16211 {
16212 add_descriptor($3,connection);
16213 $$ = $3;
16214 }
16215 ;
16216
16217
16218 /*
16219 * deallocate a descriptor
16220 */
16221 ECPGDeallocateDescr: DEALLOCATE SQL_DESCRIPTOR quoted_ident_stringvar
16222 {
16223 drop_descriptor($3,connection);
16224 $$ = $3;
16225 }
16226 ;
16227
16228 /*
16229 * manipulate a descriptor header
16230 */
16231
16232 ECPGGetDescriptorHeader: SQL_GET SQL_DESCRIPTOR quoted_ident_stringvar ECPGGetDescHeaderItems
16233 { $$ = $3; }
16234 ;
16235
16236 ECPGGetDescHeaderItems: ECPGGetDescHeaderItem
16237 | ECPGGetDescHeaderItems ',' ECPGGetDescHeaderItem
16238 ;
16239
16240 ECPGGetDescHeaderItem: cvariable '=' desc_header_item
16241 { push_assignment($1, $3); }
16242 ;
16243
16244
16245 ECPGSetDescriptorHeader: SET SQL_DESCRIPTOR quoted_ident_stringvar ECPGSetDescHeaderItems
16246 { $$ = $3; }
16247 ;
16248
16249 ECPGSetDescHeaderItems: ECPGSetDescHeaderItem
16250 | ECPGSetDescHeaderItems ',' ECPGSetDescHeaderItem
16251 ;
16252
16253 ECPGSetDescHeaderItem: desc_header_item '=' IntConstVar
16254 {
16255 push_assignment($3, $1);
16256 }
16257 ;
16258
16259 IntConstVar: Iconst
16260 {
16261 char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
16262
16263 sprintf(length, "%d", (int) strlen($1));
16264 new_variable($1, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
16265 $$ = $1;
16266 }
16267 | cvariable
16268 {
16269 $$ = $1;
16270 }
16271 ;
16272
16273 desc_header_item: SQL_COUNT { $$ = ECPGd_count; }
16274 ;
16275
16276 /*
16277 * manipulate a descriptor
16278 */
16279
16280 ECPGGetDescriptor: SQL_GET SQL_DESCRIPTOR quoted_ident_stringvar VALUE_P IntConstVar ECPGGetDescItems
16281 { $$.str = $5; $$.name = $3; }
16282 ;
16283
16284 ECPGGetDescItems: ECPGGetDescItem
16285 | ECPGGetDescItems ',' ECPGGetDescItem
16286 ;
16287
16288 ECPGGetDescItem: cvariable '=' descriptor_item { push_assignment($1, $3); };
16289
16290
16291 ECPGSetDescriptor: SET SQL_DESCRIPTOR quoted_ident_stringvar VALUE_P IntConstVar ECPGSetDescItems
16292 { $$.str = $5; $$.name = $3; }
16293 ;
16294
16295 ECPGSetDescItems: ECPGSetDescItem
16296 | ECPGSetDescItems ',' ECPGSetDescItem
16297 ;
16298
16299 ECPGSetDescItem: descriptor_item '=' AllConstVar
16300 {
16301 push_assignment($3, $1);
16302 }
16303 ;
16304
16305 AllConstVar: ecpg_fconst
16306 {
16307 char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
16308
16309 sprintf(length, "%d", (int) strlen($1));
16310 new_variable($1, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
16311 $$ = $1;
16312 }
16313
16314 | IntConstVar
16315 {
16316 $$ = $1;
16317 }
16318
16319 | '-' ecpg_fconst
16320 {
16321 char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
16322 char *var = cat2_str(mm_strdup("-"), $2);
16323
16324 sprintf(length, "%d", (int) strlen(var));
16325 new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
16326 $$ = var;
16327 }
16328
16329 | '-' Iconst
16330 {
16331 char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
16332 char *var = cat2_str(mm_strdup("-"), $2);
16333
16334 sprintf(length, "%d", (int) strlen(var));
16335 new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
16336 $$ = var;
16337 }
16338
16339 | ecpg_sconst
16340 {
16341 char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
16342 char *var = $1 + 1;
16343
16344 var[strlen(var) - 1] = '\0';
16345 sprintf(length, "%d", (int) strlen(var));
16346 new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
16347 $$ = var;
16348 }
16349 ;
16350
16351 descriptor_item: SQL_CARDINALITY { $$ = ECPGd_cardinality; }
16352 | DATA_P { $$ = ECPGd_data; }
16353 | SQL_DATETIME_INTERVAL_CODE { $$ = ECPGd_di_code; }
16354 | SQL_DATETIME_INTERVAL_PRECISION { $$ = ECPGd_di_precision; }
16355 | SQL_INDICATOR { $$ = ECPGd_indicator; }
16356 | SQL_KEY_MEMBER { $$ = ECPGd_key_member; }
16357 | SQL_LENGTH { $$ = ECPGd_length; }
16358 | NAME_P { $$ = ECPGd_name; }
16359 | SQL_NULLABLE { $$ = ECPGd_nullable; }
16360 | SQL_OCTET_LENGTH { $$ = ECPGd_octet; }
16361 | PRECISION { $$ = ECPGd_precision; }
16362 | SQL_RETURNED_LENGTH { $$ = ECPGd_length; }
16363 | SQL_RETURNED_OCTET_LENGTH { $$ = ECPGd_ret_octet; }
16364 | SQL_SCALE { $$ = ECPGd_scale; }
16365 | TYPE_P { $$ = ECPGd_type; }
16366 ;
16367
16368 /*
16369 * set/reset the automatic transaction mode, this needs a different handling
16370 * as the other set commands
16371 */
16372 ECPGSetAutocommit: SET SQL_AUTOCOMMIT '=' on_off { $$ = $4; }
16373 | SET SQL_AUTOCOMMIT TO on_off { $$ = $4; }
16374 ;
16375
16376 on_off: ON { $$ = mm_strdup("on"); }
16377 | OFF { $$ = mm_strdup("off"); }
16378 ;
16379
16380 /*
16381 * set the actual connection, this needs a different handling as the other
16382 * set commands
16383 */
16384 ECPGSetConnection: SET CONNECTION TO connection_object { $$ = $4; }
16385 | SET CONNECTION '=' connection_object { $$ = $4; }
16386 | SET CONNECTION connection_object { $$ = $3; }
16387 ;
16388
16389 /*
16390 * define a new type for embedded SQL
16391 */
16392 ECPGTypedef: TYPE_P
16393 {
16394 /* reset this variable so we see if there was */
16395 /* an initializer specified */
16396 initializer = 0;
16397 }
16398 ECPGColLabelCommon IS var_type opt_array_bounds opt_reference
16399 {
16400 add_typedef($3, $6.index1, $6.index2, $5.type_enum, $5.type_dimension, $5.type_index, initializer, *$7 ? 1 : 0);
16401
16402 if (auto_create_c == false)
16403 $$ = cat_str(7, mm_strdup("/* exec sql type"), mm_strdup($3), mm_strdup("is"), mm_strdup($5.type_str), mm_strdup($6.str), $7, mm_strdup("*/"));
16404 else
16405 $$ = cat_str(6, mm_strdup("typedef "), mm_strdup($5.type_str), *$7?mm_strdup("*"):mm_strdup(""), mm_strdup($3), mm_strdup($6.str), mm_strdup(";"));
16406 }
16407 ;
16408
16409 opt_reference: SQL_REFERENCE { $$ = mm_strdup("reference"); }
16410 | /*EMPTY*/ { $$ = EMPTY; }
16411 ;
16412
16413 /*
16414 * define the type of one variable for embedded SQL
16415 */
16416 ECPGVar: SQL_VAR
16417 {
16418 /* reset this variable so we see if there was */
16419 /* an initializer specified */
16420 initializer = 0;
16421 }
16422 ColLabel IS var_type opt_array_bounds opt_reference
16423 {
16424 struct variable *p = find_variable($3);
16425 char *dimension = $6.index1;
16426 char *length = $6.index2;
16427 struct ECPGtype * type;
16428
16429 if (($5.type_enum == ECPGt_struct ||
16430 $5.type_enum == ECPGt_union) &&
16431 initializer == 1)
16432 mmerror(PARSE_ERROR, ET_ERROR, "initializer not allowed in EXEC SQL VAR command");
16433 else
16434 {
16435 adjust_array($5.type_enum, &dimension, &length, $5.type_dimension, $5.type_index, *$7?1:0, false);
16436
16437 switch ($5.type_enum)
16438 {
16439 case ECPGt_struct:
16440 case ECPGt_union:
16441 if (atoi(dimension) < 0)
16442 type = ECPGmake_struct_type(struct_member_list[struct_level], $5.type_enum, $5.type_str, $5.type_sizeof);
16443 else
16444 type = ECPGmake_array_type(ECPGmake_struct_type(struct_member_list[struct_level], $5.type_enum, $5.type_str, $5.type_sizeof), dimension);
16445 break;
16446
16447 case ECPGt_varchar:
16448 case ECPGt_bytea:
16449 if (atoi(dimension) == -1)
16450 type = ECPGmake_simple_type($5.type_enum, length, 0);
16451 else
16452 type = ECPGmake_array_type(ECPGmake_simple_type($5.type_enum, length, 0), dimension);
16453 break;
16454
16455 case ECPGt_char:
16456 case ECPGt_unsigned_char:
16457 case ECPGt_string:
16458 if (atoi(dimension) == -1)
16459 type = ECPGmake_simple_type($5.type_enum, length, 0);
16460 else
16461 type = ECPGmake_array_type(ECPGmake_simple_type($5.type_enum, length, 0), dimension);
16462 break;
16463
16464 default:
16465 if (atoi(length) >= 0)
16466 mmerror(PARSE_ERROR, ET_ERROR, "multidimensional arrays for simple data types are not supported");
16467
16468 if (atoi(dimension) < 0)
16469 type = ECPGmake_simple_type($5.type_enum, mm_strdup("1"), 0);
16470 else
16471 type = ECPGmake_array_type(ECPGmake_simple_type($5.type_enum, mm_strdup("1"), 0), dimension);
16472 break;
16473 }
16474
16475 ECPGfree_type(p->type);
16476 p->type = type;
16477 }
16478
16479 $$ = cat_str(7, mm_strdup("/* exec sql var"), mm_strdup($3), mm_strdup("is"), mm_strdup($5.type_str), mm_strdup($6.str), $7, mm_strdup("*/"));
16480 }
16481 ;
16482
16483 /*
16484 * whenever statement: decide what to do in case of error/no data found
16485 * according to SQL standards we lack: SQLSTATE, CONSTRAINT and SQLEXCEPTION
16486 */
16487 ECPGWhenever: SQL_WHENEVER SQL_SQLERROR action
16488 {
16489 when_error.code = $<action>3.code;
16490 when_error.command = $<action>3.command;
16491 $$ = cat_str(3, mm_strdup("/* exec sql whenever sqlerror "), $3.str, mm_strdup("; */"));
16492 }
16493 | SQL_WHENEVER NOT SQL_FOUND action
16494 {
16495 when_nf.code = $<action>4.code;
16496 when_nf.command = $<action>4.command;
16497 $$ = cat_str(3, mm_strdup("/* exec sql whenever not found "), $4.str, mm_strdup("; */"));
16498 }
16499 | SQL_WHENEVER SQL_SQLWARNING action
16500 {
16501 when_warn.code = $<action>3.code;
16502 when_warn.command = $<action>3.command;
16503 $$ = cat_str(3, mm_strdup("/* exec sql whenever sql_warning "), $3.str, mm_strdup("; */"));
16504 }
16505 ;
16506
16507 action : CONTINUE_P
16508 {
16509 $<action>$.code = W_NOTHING;
16510 $<action>$.command = NULL;
16511 $<action>$.str = mm_strdup("continue");
16512 }
16513 | SQL_SQLPRINT
16514 {
16515 $<action>$.code = W_SQLPRINT;
16516 $<action>$.command = NULL;
16517 $<action>$.str = mm_strdup("sqlprint");
16518 }
16519 | SQL_STOP
16520 {
16521 $<action>$.code = W_STOP;
16522 $<action>$.command = NULL;
16523 $<action>$.str = mm_strdup("stop");
16524 }
16525 | SQL_GOTO name
16526 {
16527 $<action>$.code = W_GOTO;
16528 $<action>$.command = mm_strdup($2);
16529 $<action>$.str = cat2_str(mm_strdup("goto "), $2);
16530 }
16531 | SQL_GO TO name
16532 {
16533 $<action>$.code = W_GOTO;
16534 $<action>$.command = mm_strdup($3);
16535 $<action>$.str = cat2_str(mm_strdup("goto "), $3);
16536 }
16537 | DO name '(' c_args ')'
16538 {
16539 $<action>$.code = W_DO;
16540 $<action>$.command = cat_str(4, $2, mm_strdup("("), $4, mm_strdup(")"));
16541 $<action>$.str = cat2_str(mm_strdup("do"), mm_strdup($<action>$.command));
16542 }
16543 | DO SQL_BREAK
16544 {
16545 $<action>$.code = W_BREAK;
16546 $<action>$.command = NULL;
16547 $<action>$.str = mm_strdup("break");
16548 }
16549 | DO CONTINUE_P
16550 {
16551 $<action>$.code = W_CONTINUE;
16552 $<action>$.command = NULL;
16553 $<action>$.str = mm_strdup("continue");
16554 }
16555 | CALL name '(' c_args ')'
16556 {
16557 $<action>$.code = W_DO;
16558 $<action>$.command = cat_str(4, $2, mm_strdup("("), $4, mm_strdup(")"));
16559 $<action>$.str = cat2_str(mm_strdup("call"), mm_strdup($<action>$.command));
16560 }
16561 | CALL name
16562 {
16563 $<action>$.code = W_DO;
16564 $<action>$.command = cat2_str($2, mm_strdup("()"));
16565 $<action>$.str = cat2_str(mm_strdup("call"), mm_strdup($<action>$.command));
16566 }
16567 ;
16568
16569 /* some other stuff for ecpg */
16570
16571 /* additional unreserved keywords */
16572 ECPGKeywords: ECPGKeywords_vanames { $$ = $1; }
16573 | ECPGKeywords_rest { $$ = $1; }
16574 ;
16575
16576 ECPGKeywords_vanames: SQL_BREAK { $$ = mm_strdup("break"); }
16577 | SQL_CARDINALITY { $$ = mm_strdup("cardinality"); }
16578 | SQL_COUNT { $$ = mm_strdup("count"); }
16579 | SQL_DATETIME_INTERVAL_CODE { $$ = mm_strdup("datetime_interval_code"); }
16580 | SQL_DATETIME_INTERVAL_PRECISION { $$ = mm_strdup("datetime_interval_precision"); }
16581 | SQL_FOUND { $$ = mm_strdup("found"); }
16582 | SQL_GO { $$ = mm_strdup("go"); }
16583 | SQL_GOTO { $$ = mm_strdup("goto"); }
16584 | SQL_IDENTIFIED { $$ = mm_strdup("identified"); }
16585 | SQL_INDICATOR { $$ = mm_strdup("indicator"); }
16586 | SQL_KEY_MEMBER { $$ = mm_strdup("key_member"); }
16587 | SQL_LENGTH { $$ = mm_strdup("length"); }
16588 | SQL_NULLABLE { $$ = mm_strdup("nullable"); }
16589 | SQL_OCTET_LENGTH { $$ = mm_strdup("octet_length"); }
16590 | SQL_RETURNED_LENGTH { $$ = mm_strdup("returned_length"); }
16591 | SQL_RETURNED_OCTET_LENGTH { $$ = mm_strdup("returned_octet_length"); }
16592 | SQL_SCALE { $$ = mm_strdup("scale"); }
16593 | SQL_SECTION { $$ = mm_strdup("section"); }
16594 | SQL_SQLERROR { $$ = mm_strdup("sqlerror"); }
16595 | SQL_SQLPRINT { $$ = mm_strdup("sqlprint"); }
16596 | SQL_SQLWARNING { $$ = mm_strdup("sqlwarning"); }
16597 | SQL_STOP { $$ = mm_strdup("stop"); }
16598 ;
16599
16600 ECPGKeywords_rest: SQL_CONNECT { $$ = mm_strdup("connect"); }
16601 | SQL_DESCRIBE { $$ = mm_strdup("describe"); }
16602 | SQL_DISCONNECT { $$ = mm_strdup("disconnect"); }
16603 | SQL_OPEN { $$ = mm_strdup("open"); }
16604 | SQL_VAR { $$ = mm_strdup("var"); }
16605 | SQL_WHENEVER { $$ = mm_strdup("whenever"); }
16606 ;
16607
16608 /* additional keywords that can be SQL type names (but not ECPGColLabels) */
16609 ECPGTypeName: SQL_BOOL { $$ = mm_strdup("bool"); }
16610 | SQL_LONG { $$ = mm_strdup("long"); }
16611 | SQL_OUTPUT { $$ = mm_strdup("output"); }
16612 | SQL_SHORT { $$ = mm_strdup("short"); }
16613 | SQL_STRUCT { $$ = mm_strdup("struct"); }
16614 | SQL_SIGNED { $$ = mm_strdup("signed"); }
16615 | SQL_UNSIGNED { $$ = mm_strdup("unsigned"); }
16616 ;
16617
16618 symbol: ColLabel { $$ = $1; }
16619 ;
16620
16621 ECPGColId: ecpg_ident { $$ = $1; }
16622 | unreserved_keyword { $$ = $1; }
16623 | col_name_keyword { $$ = $1; }
16624 | ECPGunreserved_interval { $$ = $1; }
16625 | ECPGKeywords { $$ = $1; }
16626 | ECPGCKeywords { $$ = $1; }
16627 | CHAR_P { $$ = mm_strdup("char"); }
16628 | VALUES { $$ = mm_strdup("values"); }
16629 ;
16630
16631 /*
16632 * Name classification hierarchy.
16633 *
16634 * These productions should match those in the core grammar, except that
16635 * we use all_unreserved_keyword instead of unreserved_keyword, and
16636 * where possible include ECPG keywords as well as core keywords.
16637 */
16638
16639 /* Column identifier --- names that can be column, table, etc names.
16640 */
16641 ColId: ecpg_ident { $$ = $1; }
16642 | all_unreserved_keyword { $$ = $1; }
16643 | col_name_keyword { $$ = $1; }
16644 | ECPGKeywords { $$ = $1; }
16645 | ECPGCKeywords { $$ = $1; }
16646 | CHAR_P { $$ = mm_strdup("char"); }
16647 | VALUES { $$ = mm_strdup("values"); }
16648 ;
16649
16650 /* Type/function identifier --- names that can be type or function names.
16651 */
16652 type_function_name: ecpg_ident { $$ = $1; }
16653 | all_unreserved_keyword { $$ = $1; }
16654 | type_func_name_keyword { $$ = $1; }
16655 | ECPGKeywords { $$ = $1; }
16656 | ECPGCKeywords { $$ = $1; }
16657 | ECPGTypeName { $$ = $1; }
16658 ;
16659
16660 /* Column label --- allowed labels in "AS" clauses.
16661 * This presently includes *all* Postgres keywords.
16662 */
16663 ColLabel: ECPGColLabel { $$ = $1; }
16664 | ECPGTypeName { $$ = $1; }
16665 | CHAR_P { $$ = mm_strdup("char"); }
16666 | CURRENT_P { $$ = mm_strdup("current"); }
16667 | INPUT_P { $$ = mm_strdup("input"); }
16668 | INT_P { $$ = mm_strdup("int"); }
16669 | TO { $$ = mm_strdup("to"); }
16670 | UNION { $$ = mm_strdup("union"); }
16671 | VALUES { $$ = mm_strdup("values"); }
16672 | ECPGCKeywords { $$ = $1; }
16673 | ECPGunreserved_interval { $$ = $1; }
16674 ;
16675
16676 ECPGColLabel: ECPGColLabelCommon { $$ = $1; }
16677 | unreserved_keyword { $$ = $1; }
16678 | reserved_keyword { $$ = $1; }
16679 | ECPGKeywords_rest { $$ = $1; }
16680 | CONNECTION { $$ = mm_strdup("connection"); }
16681 ;
16682
16683 ECPGColLabelCommon: ecpg_ident { $$ = $1; }
16684 | col_name_keyword { $$ = $1; }
16685 | type_func_name_keyword { $$ = $1; }
16686 | ECPGKeywords_vanames { $$ = $1; }
16687 ;
16688
16689 ECPGCKeywords: S_AUTO { $$ = mm_strdup("auto"); }
16690 | S_CONST { $$ = mm_strdup("const"); }
16691 | S_EXTERN { $$ = mm_strdup("extern"); }
16692 | S_REGISTER { $$ = mm_strdup("register"); }
16693 | S_STATIC { $$ = mm_strdup("static"); }
16694 | S_TYPEDEF { $$ = mm_strdup("typedef"); }
16695 | S_VOLATILE { $$ = mm_strdup("volatile"); }
16696 ;
16697
16698 /* "Unreserved" keywords --- available for use as any kind of name.
16699 */
16700
16701 /*
16702 * The following symbols must be excluded from ECPGColLabel and directly
16703 * included into ColLabel to enable C variables to get names from ECPGColLabel:
16704 * DAY_P, HOUR_P, MINUTE_P, MONTH_P, SECOND_P, YEAR_P.
16705 *
16706 * We also have to exclude CONNECTION, CURRENT, and INPUT for various reasons.
16707 * CONNECTION can be added back in all_unreserved_keyword, but CURRENT and
16708 * INPUT are reserved for ecpg purposes.
16709 *
16710 * The mentioned exclusions are done by $replace_line settings in parse.pl.
16711 */
16712 all_unreserved_keyword: unreserved_keyword { $$ = $1; }
16713 | ECPGunreserved_interval { $$ = $1; }
16714 | CONNECTION { $$ = mm_strdup("connection"); }
16715 ;
16716
16717 ECPGunreserved_interval: DAY_P { $$ = mm_strdup("day"); }
16718 | HOUR_P { $$ = mm_strdup("hour"); }
16719 | MINUTE_P { $$ = mm_strdup("minute"); }
16720 | MONTH_P { $$ = mm_strdup("month"); }
16721 | SECOND_P { $$ = mm_strdup("second"); }
16722 | YEAR_P { $$ = mm_strdup("year"); }
16723 ;
16724
16725
16726 into_list : coutputvariable | into_list ',' coutputvariable
16727 ;
16728
16729 ecpgstart: SQL_START {
16730 reset_variables();
16731 pacounter = 1;
16732 }
16733 ;
16734
16735 c_args: /*EMPTY*/ { $$ = EMPTY; }
16736 | c_list { $$ = $1; }
16737 ;
16738
16739 coutputvariable: cvariable indicator
16740 { add_variable_to_head(&argsresult, find_variable($1), find_variable($2)); }
16741 | cvariable
16742 { add_variable_to_head(&argsresult, find_variable($1), &no_indicator); }
16743 ;
16744
16745
16746 civarind: cvariable indicator
16747 {
16748 if (find_variable($2)->type->type == ECPGt_array)
16749 mmerror(PARSE_ERROR, ET_ERROR, "arrays of indicators are not allowed on input");
16750
16751 add_variable_to_head(&argsinsert, find_variable($1), find_variable($2));
16752 $$ = create_questionmarks($1, false);
16753 }
16754 ;
16755
16756 char_civar: char_variable
16757 {
16758 char *ptr = strstr($1, ".arr");
16759
16760 if (ptr) /* varchar, we need the struct name here, not the struct element */
16761 *ptr = '\0';
16762 add_variable_to_head(&argsinsert, find_variable($1), &no_indicator);
16763 $$ = $1;
16764 }
16765 ;
16766
16767 civar: cvariable
16768 {
16769 add_variable_to_head(&argsinsert, find_variable($1), &no_indicator);
16770 $$ = create_questionmarks($1, false);
16771 }
16772 ;
16773
16774 indicator: cvariable { check_indicator((find_variable($1))->type); $$ = $1; }
16775 | SQL_INDICATOR cvariable { check_indicator((find_variable($2))->type); $$ = $2; }
16776 | SQL_INDICATOR name { check_indicator((find_variable($2))->type); $$ = $2; }
16777 ;
16778
16779 cvariable: CVARIABLE
16780 {
16781 /* As long as multidimensional arrays are not implemented we have to check for those here */
16782 char *ptr = $1;
16783 int brace_open=0, brace = false;
16784
16785 for (; *ptr; ptr++)
16786 {
16787 switch (*ptr)
16788 {
16789 case '[':
16790 if (brace)
16791 mmfatal(PARSE_ERROR, "multidimensional arrays for simple data types are not supported");
16792 brace_open++;
16793 break;
16794 case ']':
16795 brace_open--;
16796 if (brace_open == 0)
16797 brace = true;
16798 break;
16799 case '\t':
16800 case ' ':
16801 break;
16802 default:
16803 if (brace_open == 0)
16804 brace = false;
16805 break;
16806 }
16807 }
16808 $$ = $1;
16809 }
16810 ;
16811
16812 ecpg_param: PARAM { $$ = make_name(); } ;
16813
16814 ecpg_bconst: BCONST { $$ = make_name(); } ;
16815
16816 ecpg_fconst: FCONST { $$ = make_name(); } ;
16817
16818 ecpg_sconst:
16819 SCONST
16820 {
16821 /* could have been input as '' or $$ */
16822 $$ = (char *)mm_alloc(strlen($1) + 3);
16823 $$[0]='\'';
16824 strcpy($$+1, $1);
16825 $$[strlen($1)+1]='\'';
16826 $$[strlen($1)+2]='\0';
16827 free($1);
16828 }
16829 | ECONST
16830 {
16831 $$ = (char *)mm_alloc(strlen($1) + 4);
16832 $$[0]='E';
16833 $$[1]='\'';
16834 strcpy($$+2, $1);
16835 $$[strlen($1)+2]='\'';
16836 $$[strlen($1)+3]='\0';
16837 free($1);
16838 }
16839 | NCONST
16840 {
16841 $$ = (char *)mm_alloc(strlen($1) + 4);
16842 $$[0]='N';
16843 $$[1]='\'';
16844 strcpy($$+2, $1);
16845 $$[strlen($1)+2]='\'';
16846 $$[strlen($1)+3]='\0';
16847 free($1);
16848 }
16849 | UCONST { $$ = $1; }
16850 | DOLCONST { $$ = $1; }
16851 ;
16852
16853 ecpg_xconst: XCONST { $$ = make_name(); } ;
16854
16855 ecpg_ident: IDENT { $$ = make_name(); }
16856 | CSTRING { $$ = make3_str(mm_strdup("\""), $1, mm_strdup("\"")); }
16857 | UIDENT { $$ = $1; }
16858 ;
16859
16860 quoted_ident_stringvar: name
16861 { $$ = make3_str(mm_strdup("\""), $1, mm_strdup("\"")); }
16862 | char_variable
16863 { $$ = make3_str(mm_strdup("("), $1, mm_strdup(")")); }
16864 ;
16865
16866 /*
16867 * C stuff
16868 */
16869
16870 c_stuff_item: c_anything { $$ = $1; }
16871 | '(' ')' { $$ = mm_strdup("()"); }
16872 | '(' c_stuff ')'
16873 { $$ = cat_str(3, mm_strdup("("), $2, mm_strdup(")")); }
16874 ;
16875
16876 c_stuff: c_stuff_item { $$ = $1; }
16877 | c_stuff c_stuff_item
16878 { $$ = cat2_str($1, $2); }
16879 ;
16880
16881 c_list: c_term { $$ = $1; }
16882 | c_list ',' c_term { $$ = cat_str(3, $1, mm_strdup(","), $3); }
16883 ;
16884
16885 c_term: c_stuff { $$ = $1; }
16886 | '{' c_list '}' { $$ = cat_str(3, mm_strdup("{"), $2, mm_strdup("}")); }
16887 ;
16888
16889 c_thing: c_anything { $$ = $1; }
16890 | '(' { $$ = mm_strdup("("); }
16891 | ')' { $$ = mm_strdup(")"); }
16892 | ',' { $$ = mm_strdup(","); }
16893 | ';' { $$ = mm_strdup(";"); }
16894 ;
16895
16896 c_anything: ecpg_ident { $$ = $1; }
16897 | Iconst { $$ = $1; }
16898 | ecpg_fconst { $$ = $1; }
16899 | ecpg_sconst { $$ = $1; }
16900 | '*' { $$ = mm_strdup("*"); }
16901 | '+' { $$ = mm_strdup("+"); }
16902 | '-' { $$ = mm_strdup("-"); }
16903 | '/' { $$ = mm_strdup("/"); }
16904 | '%' { $$ = mm_strdup("%"); }
16905 | NULL_P { $$ = mm_strdup("NULL"); }
16906 | S_ADD { $$ = mm_strdup("+="); }
16907 | S_AND { $$ = mm_strdup("&&"); }
16908 | S_ANYTHING { $$ = make_name(); }
16909 | S_AUTO { $$ = mm_strdup("auto"); }
16910 | S_CONST { $$ = mm_strdup("const"); }
16911 | S_DEC { $$ = mm_strdup("--"); }
16912 | S_DIV { $$ = mm_strdup("/="); }
16913 | S_DOTPOINT { $$ = mm_strdup(".*"); }
16914 | S_EQUAL { $$ = mm_strdup("=="); }
16915 | S_EXTERN { $$ = mm_strdup("extern"); }
16916 | S_INC { $$ = mm_strdup("++"); }
16917 | S_LSHIFT { $$ = mm_strdup("<<"); }
16918 | S_MEMBER { $$ = mm_strdup("->"); }
16919 | S_MEMPOINT { $$ = mm_strdup("->*"); }
16920 | S_MOD { $$ = mm_strdup("%="); }
16921 | S_MUL { $$ = mm_strdup("*="); }
16922 | S_NEQUAL { $$ = mm_strdup("!="); }
16923 | S_OR { $$ = mm_strdup("||"); }
16924 | S_REGISTER { $$ = mm_strdup("register"); }
16925 | S_RSHIFT { $$ = mm_strdup(">>"); }
16926 | S_STATIC { $$ = mm_strdup("static"); }
16927 | S_SUB { $$ = mm_strdup("-="); }
16928 | S_TYPEDEF { $$ = mm_strdup("typedef"); }
16929 | S_VOLATILE { $$ = mm_strdup("volatile"); }
16930 | SQL_BOOL { $$ = mm_strdup("bool"); }
16931 | ENUM_P { $$ = mm_strdup("enum"); }
16932 | HOUR_P { $$ = mm_strdup("hour"); }
16933 | INT_P { $$ = mm_strdup("int"); }
16934 | SQL_LONG { $$ = mm_strdup("long"); }
16935 | MINUTE_P { $$ = mm_strdup("minute"); }
16936 | MONTH_P { $$ = mm_strdup("month"); }
16937 | SECOND_P { $$ = mm_strdup("second"); }
16938 | SQL_SHORT { $$ = mm_strdup("short"); }
16939 | SQL_SIGNED { $$ = mm_strdup("signed"); }
16940 | SQL_STRUCT { $$ = mm_strdup("struct"); }
16941 | SQL_UNSIGNED { $$ = mm_strdup("unsigned"); }
16942 | YEAR_P { $$ = mm_strdup("year"); }
16943 | CHAR_P { $$ = mm_strdup("char"); }
16944 | FLOAT_P { $$ = mm_strdup("float"); }
16945 | TO { $$ = mm_strdup("to"); }
16946 | UNION { $$ = mm_strdup("union"); }
16947 | VARCHAR { $$ = mm_strdup("varchar"); }
16948 | '[' { $$ = mm_strdup("["); }
16949 | ']' { $$ = mm_strdup("]"); }
16950 | '=' { $$ = mm_strdup("="); }
16951 | ':' { $$ = mm_strdup(":"); }
16952 ;
16953
16954 DeallocateStmt: DEALLOCATE prepared_name { $$ = $2; }
16955 | DEALLOCATE PREPARE prepared_name { $$ = $3; }
16956 | DEALLOCATE ALL { $$ = mm_strdup("all"); }
16957 | DEALLOCATE PREPARE ALL { $$ = mm_strdup("all"); }
16958 ;
16959
16960 Iresult: Iconst { $$ = $1; }
16961 | '(' Iresult ')' { $$ = cat_str(3, mm_strdup("("), $2, mm_strdup(")")); }
16962 | Iresult '+' Iresult { $$ = cat_str(3, $1, mm_strdup("+"), $3); }
16963 | Iresult '-' Iresult { $$ = cat_str(3, $1, mm_strdup("-"), $3); }
16964 | Iresult '*' Iresult { $$ = cat_str(3, $1, mm_strdup("*"), $3); }
16965 | Iresult '/' Iresult { $$ = cat_str(3, $1, mm_strdup("/"), $3); }
16966 | Iresult '%' Iresult { $$ = cat_str(3, $1, mm_strdup("%"), $3); }
16967 | ecpg_sconst { $$ = $1; }
16968 | ColId { $$ = $1; }
16969 | ColId '(' var_type ')' { if (pg_strcasecmp($1, "sizeof") != 0)
16970 mmerror(PARSE_ERROR, ET_ERROR, "operator not allowed in variable definition");
16971 else
16972 $$ = cat_str(4, $1, mm_strdup("("), $3.type_str, mm_strdup(")"));
16973 }
16974 ;
16975
16976 execute_rest: /* EMPTY */ { $$ = EMPTY; }
16977 | ecpg_using opt_ecpg_into { $$ = EMPTY; }
16978 | ecpg_into ecpg_using { $$ = EMPTY; }
16979 | ecpg_into { $$ = EMPTY; }
16980 ;
16981
16982 ecpg_into: INTO into_list { $$ = EMPTY; }
16983 | into_descriptor { $$ = $1; }
16984 ;
16985
16986 opt_ecpg_into: /* EMPTY */ { $$ = EMPTY; }
16987 | ecpg_into { $$ = $1; }
16988 ;
16989
16990 ecpg_fetch_into: ecpg_into { $$ = $1; }
16991 | using_descriptor
16992 {
16993 struct variable *var;
16994
16995 var = argsinsert->variable;
16996 remove_variable_from_list(&argsinsert, var);
16997 add_variable_to_head(&argsresult, var, &no_indicator);
16998 $$ = $1;
16999 }
17000 ;
17001
17002 opt_ecpg_fetch_into: /* EMPTY */ { $$ = EMPTY; }
17003 | ecpg_fetch_into { $$ = $1; }
17004 ;
17005
17006 %%
17007
17008 void base_yyerror(const char *error)
17009 {
17010 /* translator: %s is typically the translation of "syntax error" */
17011 mmerror(PARSE_ERROR, ET_ERROR, "%s at or near \"%s\"",
17012 _(error), token_start ? token_start : base_yytext);
17013 }
17014
17015 void parser_init(void)
17016 {
17017 /* This function is empty. It only exists for compatibility with the backend parser right now. */
17018 }
17019