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
vmmerror(int error_code,enum errortype type,const char * error,va_list ap)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:
98 ret_value = error_code;
99 break;
100 }
101 }
102
103 void
mmerror(int error_code,enum errortype type,const char * error,...)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 }
112
113 void
mmfatal(int error_code,const char * error,...)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 *
cat2_str(char * str1,char * str2)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 *
cat_str(int count,...)151 cat_str(int count, ...)
152 {
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 *
make2_str(char * str1,char * str2)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 *
make3_str(char * str1,char * str2,char * str3)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 *
make_name(void)198 make_name(void)
199 {
200 return mm_strdup(base_yytext);
201 }
202
203 static char *
create_questionmarks(char * name,bool array)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
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 *
adjust_outofscope_cursor_vars(struct cursor * cur)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 *
add_additional_variables(char * name,bool insert)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;
529 }
530
531 static void
add_typedef(char * name,char * dimension,char * length,enum ECPGttype type_enum,char * type_dimension,char * type_index,int initializer,int array)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 /* types */
629 %type <str> stmt
630 %type <str> CallStmt
631 %type <str> CreateRoleStmt
632 %type <str> opt_with
633 %type <str> OptRoleList
634 %type <str> AlterOptRoleList
635 %type <str> AlterOptRoleElem
636 %type <str> CreateOptRoleElem
637 %type <str> CreateUserStmt
638 %type <str> AlterRoleStmt
639 %type <str> opt_in_database
640 %type <str> AlterRoleSetStmt
641 %type <str> DropRoleStmt
642 %type <str> CreateGroupStmt
643 %type <str> AlterGroupStmt
644 %type <str> add_drop
645 %type <str> CreateSchemaStmt
646 %type <str> OptSchemaName
647 %type <str> OptSchemaEltList
648 %type <str> schema_stmt
649 %type <str> VariableSetStmt
650 %type <str> set_rest
651 %type <str> generic_set
652 %type <str> set_rest_more
653 %type <str> var_name
654 %type <str> var_list
655 %type <str> var_value
656 %type <str> iso_level
657 %type <str> opt_boolean_or_string
658 %type <str> zone_value
659 %type <str> opt_encoding
660 %type <str> NonReservedWord_or_Sconst
661 %type <str> VariableResetStmt
662 %type <str> reset_rest
663 %type <str> generic_reset
664 %type <str> SetResetClause
665 %type <str> FunctionSetResetClause
666 %type <str> VariableShowStmt
667 %type <str> ConstraintsSetStmt
668 %type <str> constraints_set_list
669 %type <str> constraints_set_mode
670 %type <str> CheckPointStmt
671 %type <str> DiscardStmt
672 %type <str> AlterTableStmt
673 %type <str> alter_table_cmds
674 %type <str> partition_cmd
675 %type <str> index_partition_cmd
676 %type <str> alter_table_cmd
677 %type <str> alter_column_default
678 %type <str> opt_drop_behavior
679 %type <str> opt_collate_clause
680 %type <str> alter_using
681 %type <str> replica_identity
682 %type <str> reloptions
683 %type <str> opt_reloptions
684 %type <str> reloption_list
685 %type <str> reloption_elem
686 %type <str> alter_identity_column_option_list
687 %type <str> alter_identity_column_option
688 %type <str> PartitionBoundSpec
689 %type <str> hash_partbound_elem
690 %type <str> hash_partbound
691 %type <str> AlterCompositeTypeStmt
692 %type <str> alter_type_cmds
693 %type <str> alter_type_cmd
694 %type <str> ClosePortalStmt
695 %type <str> CopyStmt
696 %type <str> copy_from
697 %type <str> opt_program
698 %type <str> copy_file_name
699 %type <str> copy_options
700 %type <str> copy_opt_list
701 %type <str> copy_opt_item
702 %type <str> opt_binary
703 %type <str> copy_delimiter
704 %type <str> opt_using
705 %type <str> copy_generic_opt_list
706 %type <str> copy_generic_opt_elem
707 %type <str> copy_generic_opt_arg
708 %type <str> copy_generic_opt_arg_list
709 %type <str> copy_generic_opt_arg_list_item
710 %type <str> CreateStmt
711 %type <str> OptTemp
712 %type <str> OptTableElementList
713 %type <str> OptTypedTableElementList
714 %type <str> TableElementList
715 %type <str> TypedTableElementList
716 %type <str> TableElement
717 %type <str> TypedTableElement
718 %type <str> columnDef
719 %type <str> columnOptions
720 %type <str> ColQualList
721 %type <str> ColConstraint
722 %type <str> ColConstraintElem
723 %type <str> generated_when
724 %type <str> ConstraintAttr
725 %type <str> TableLikeClause
726 %type <str> TableLikeOptionList
727 %type <str> TableLikeOption
728 %type <str> TableConstraint
729 %type <str> ConstraintElem
730 %type <str> opt_no_inherit
731 %type <str> opt_column_list
732 %type <str> columnList
733 %type <str> columnElem
734 %type <str> opt_c_include
735 %type <str> key_match
736 %type <str> ExclusionConstraintList
737 %type <str> ExclusionConstraintElem
738 %type <str> ExclusionWhereClause
739 %type <str> key_actions
740 %type <str> key_update
741 %type <str> key_delete
742 %type <str> key_action
743 %type <str> OptInherit
744 %type <str> OptPartitionSpec
745 %type <str> PartitionSpec
746 %type <str> part_params
747 %type <str> part_elem
748 %type <str> table_access_method_clause
749 %type <str> OptWith
750 %type <str> OnCommitOption
751 %type <str> OptTableSpace
752 %type <str> OptConsTableSpace
753 %type <str> ExistingIndex
754 %type <str> CreateStatsStmt
755 %type <str> AlterStatsStmt
756 %type <str> create_as_target
757 %type <str> opt_with_data
758 %type <str> CreateMatViewStmt
759 %type <str> create_mv_target
760 %type <str> OptNoLog
761 %type <str> RefreshMatViewStmt
762 %type <str> CreateSeqStmt
763 %type <str> AlterSeqStmt
764 %type <str> OptSeqOptList
765 %type <str> OptParenthesizedSeqOptList
766 %type <str> SeqOptList
767 %type <str> SeqOptElem
768 %type <str> opt_by
769 %type <str> NumericOnly
770 %type <str> NumericOnly_list
771 %type <str> CreatePLangStmt
772 %type <str> opt_trusted
773 %type <str> handler_name
774 %type <str> opt_inline_handler
775 %type <str> validator_clause
776 %type <str> opt_validator
777 %type <str> DropPLangStmt
778 %type <str> opt_procedural
779 %type <str> CreateTableSpaceStmt
780 %type <str> OptTableSpaceOwner
781 %type <str> DropTableSpaceStmt
782 %type <str> CreateExtensionStmt
783 %type <str> create_extension_opt_list
784 %type <str> create_extension_opt_item
785 %type <str> AlterExtensionStmt
786 %type <str> alter_extension_opt_list
787 %type <str> alter_extension_opt_item
788 %type <str> AlterExtensionContentsStmt
789 %type <str> CreateFdwStmt
790 %type <str> fdw_option
791 %type <str> fdw_options
792 %type <str> opt_fdw_options
793 %type <str> AlterFdwStmt
794 %type <str> create_generic_options
795 %type <str> generic_option_list
796 %type <str> alter_generic_options
797 %type <str> alter_generic_option_list
798 %type <str> alter_generic_option_elem
799 %type <str> generic_option_elem
800 %type <str> generic_option_name
801 %type <str> generic_option_arg
802 %type <str> CreateForeignServerStmt
803 %type <str> opt_type
804 %type <str> foreign_server_version
805 %type <str> opt_foreign_server_version
806 %type <str> AlterForeignServerStmt
807 %type <str> CreateForeignTableStmt
808 %type <str> AlterForeignTableStmt
809 %type <str> ImportForeignSchemaStmt
810 %type <str> import_qualification_type
811 %type <str> import_qualification
812 %type <str> CreateUserMappingStmt
813 %type <str> auth_ident
814 %type <str> DropUserMappingStmt
815 %type <str> AlterUserMappingStmt
816 %type <str> CreatePolicyStmt
817 %type <str> AlterPolicyStmt
818 %type <str> RowSecurityOptionalExpr
819 %type <str> RowSecurityOptionalWithCheck
820 %type <str> RowSecurityDefaultToRole
821 %type <str> RowSecurityOptionalToRole
822 %type <str> RowSecurityDefaultPermissive
823 %type <str> RowSecurityDefaultForCmd
824 %type <str> row_security_cmd
825 %type <str> CreateAmStmt
826 %type <str> am_type
827 %type <str> CreateTrigStmt
828 %type <str> TriggerActionTime
829 %type <str> TriggerEvents
830 %type <str> TriggerOneEvent
831 %type <str> TriggerReferencing
832 %type <str> TriggerTransitions
833 %type <str> TriggerTransition
834 %type <str> TransitionOldOrNew
835 %type <str> TransitionRowOrTable
836 %type <str> TransitionRelName
837 %type <str> TriggerForSpec
838 %type <str> TriggerForOptEach
839 %type <str> TriggerForType
840 %type <str> TriggerWhen
841 %type <str> FUNCTION_or_PROCEDURE
842 %type <str> TriggerFuncArgs
843 %type <str> TriggerFuncArg
844 %type <str> OptConstrFromTable
845 %type <str> ConstraintAttributeSpec
846 %type <str> ConstraintAttributeElem
847 %type <str> CreateEventTrigStmt
848 %type <str> event_trigger_when_list
849 %type <str> event_trigger_when_item
850 %type <str> event_trigger_value_list
851 %type <str> AlterEventTrigStmt
852 %type <str> enable_trigger
853 %type <str> CreateAssertionStmt
854 %type <str> DefineStmt
855 %type <str> definition
856 %type <str> def_list
857 %type <str> def_elem
858 %type <str> def_arg
859 %type <str> old_aggr_definition
860 %type <str> old_aggr_list
861 %type <str> old_aggr_elem
862 %type <str> opt_enum_val_list
863 %type <str> enum_val_list
864 %type <str> AlterEnumStmt
865 %type <str> opt_if_not_exists
866 %type <str> CreateOpClassStmt
867 %type <str> opclass_item_list
868 %type <str> opclass_item
869 %type <str> opt_default
870 %type <str> opt_opfamily
871 %type <str> opclass_purpose
872 %type <str> opt_recheck
873 %type <str> CreateOpFamilyStmt
874 %type <str> AlterOpFamilyStmt
875 %type <str> opclass_drop_list
876 %type <str> opclass_drop
877 %type <str> DropOpClassStmt
878 %type <str> DropOpFamilyStmt
879 %type <str> DropOwnedStmt
880 %type <str> ReassignOwnedStmt
881 %type <str> DropStmt
882 %type <str> drop_type_any_name
883 %type <str> drop_type_name
884 %type <str> drop_type_name_on_any_name
885 %type <str> any_name_list
886 %type <str> any_name
887 %type <str> attrs
888 %type <str> type_name_list
889 %type <str> TruncateStmt
890 %type <str> opt_restart_seqs
891 %type <str> CommentStmt
892 %type <str> comment_type_any_name
893 %type <str> comment_type_name
894 %type <str> comment_text
895 %type <str> SecLabelStmt
896 %type <str> opt_provider
897 %type <str> security_label_type_any_name
898 %type <str> security_label_type_name
899 %type <str> security_label
900 %type <str> FetchStmt
901 %type <str> fetch_args
902 %type <str> from_in
903 %type <str> opt_from_in
904 %type <str> GrantStmt
905 %type <str> RevokeStmt
906 %type <str> privileges
907 %type <str> privilege_list
908 %type <str> privilege
909 %type <str> privilege_target
910 %type <str> grantee_list
911 %type <str> grantee
912 %type <str> opt_grant_grant_option
913 %type <str> GrantRoleStmt
914 %type <str> RevokeRoleStmt
915 %type <str> opt_grant_admin_option
916 %type <str> opt_granted_by
917 %type <str> AlterDefaultPrivilegesStmt
918 %type <str> DefACLOptionList
919 %type <str> DefACLOption
920 %type <str> DefACLAction
921 %type <str> defacl_privilege_target
922 %type <str> IndexStmt
923 %type <str> opt_unique
924 %type <str> opt_concurrently
925 %type <str> opt_index_name
926 %type <str> access_method_clause
927 %type <str> index_params
928 %type <str> index_elem_options
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> opt_no
994 %type <str> AlterObjectSchemaStmt
995 %type <str> AlterOperatorStmt
996 %type <str> operator_def_list
997 %type <str> operator_def_elem
998 %type <str> operator_def_arg
999 %type <str> AlterTypeStmt
1000 %type <str> AlterOwnerStmt
1001 %type <str> CreatePublicationStmt
1002 %type <str> opt_publication_for_tables
1003 %type <str> publication_for_tables
1004 %type <str> AlterPublicationStmt
1005 %type <str> CreateSubscriptionStmt
1006 %type <str> publication_name_list
1007 %type <str> publication_name_item
1008 %type <str> AlterSubscriptionStmt
1009 %type <str> DropSubscriptionStmt
1010 %type <str> RuleStmt
1011 %type <str> RuleActionList
1012 %type <str> RuleActionMulti
1013 %type <str> RuleActionStmt
1014 %type <str> RuleActionStmtOrEmpty
1015 %type <str> event
1016 %type <str> opt_instead
1017 %type <str> NotifyStmt
1018 %type <str> notify_payload
1019 %type <str> ListenStmt
1020 %type <str> UnlistenStmt
1021 %type <str> TransactionStmt
1022 %type <str> opt_transaction
1023 %type <str> transaction_mode_item
1024 %type <str> transaction_mode_list
1025 %type <str> transaction_mode_list_or_empty
1026 %type <str> opt_transaction_chain
1027 %type <str> ViewStmt
1028 %type <str> opt_check_option
1029 %type <str> LoadStmt
1030 %type <str> CreatedbStmt
1031 %type <str> createdb_opt_list
1032 %type <str> createdb_opt_items
1033 %type <str> createdb_opt_item
1034 %type <str> createdb_opt_name
1035 %type <str> opt_equal
1036 %type <str> AlterDatabaseStmt
1037 %type <str> AlterDatabaseSetStmt
1038 %type <str> DropdbStmt
1039 %type <str> drop_option_list
1040 %type <str> drop_option
1041 %type <str> AlterCollationStmt
1042 %type <str> AlterSystemStmt
1043 %type <str> CreateDomainStmt
1044 %type <str> AlterDomainStmt
1045 %type <str> opt_as
1046 %type <str> AlterTSDictionaryStmt
1047 %type <str> AlterTSConfigurationStmt
1048 %type <str> any_with
1049 %type <str> CreateConversionStmt
1050 %type <str> ClusterStmt
1051 %type <str> cluster_index_specification
1052 %type <str> VacuumStmt
1053 %type <str> AnalyzeStmt
1054 %type <str> vac_analyze_option_list
1055 %type <str> analyze_keyword
1056 %type <str> vac_analyze_option_elem
1057 %type <str> vac_analyze_option_name
1058 %type <str> vac_analyze_option_arg
1059 %type <str> opt_analyze
1060 %type <str> opt_verbose
1061 %type <str> opt_full
1062 %type <str> opt_freeze
1063 %type <str> opt_name_list
1064 %type <str> vacuum_relation
1065 %type <str> vacuum_relation_list
1066 %type <str> opt_vacuum_relation_list
1067 %type <str> ExplainStmt
1068 %type <str> ExplainableStmt
1069 %type <str> explain_option_list
1070 %type <str> explain_option_elem
1071 %type <str> explain_option_name
1072 %type <str> explain_option_arg
1073 %type <prep> PrepareStmt
1074 %type <str> prep_type_clause
1075 %type <str> PreparableStmt
1076 %type <exec> ExecuteStmt
1077 %type <str> execute_param_clause
1078 %type <str> InsertStmt
1079 %type <str> insert_target
1080 %type <str> insert_rest
1081 %type <str> override_kind
1082 %type <str> insert_column_list
1083 %type <str> insert_column_item
1084 %type <str> opt_on_conflict
1085 %type <str> opt_conf_expr
1086 %type <str> returning_clause
1087 %type <str> DeleteStmt
1088 %type <str> using_clause
1089 %type <str> LockStmt
1090 %type <str> opt_lock
1091 %type <str> lock_type
1092 %type <str> opt_nowait
1093 %type <str> opt_nowait_or_skip
1094 %type <str> UpdateStmt
1095 %type <str> set_clause_list
1096 %type <str> set_clause
1097 %type <str> set_target
1098 %type <str> set_target_list
1099 %type <str> DeclareCursorStmt
1100 %type <str> cursor_name
1101 %type <str> cursor_options
1102 %type <str> opt_hold
1103 %type <str> SelectStmt
1104 %type <str> select_with_parens
1105 %type <str> select_no_parens
1106 %type <str> select_clause
1107 %type <str> simple_select
1108 %type <str> with_clause
1109 %type <str> cte_list
1110 %type <str> common_table_expr
1111 %type <str> opt_materialized
1112 %type <str> opt_with_clause
1113 %type <str> into_clause
1114 %type <str> OptTempTableName
1115 %type <str> opt_table
1116 %type <str> all_or_distinct
1117 %type <str> distinct_clause
1118 %type <str> opt_all_clause
1119 %type <str> opt_sort_clause
1120 %type <str> sort_clause
1121 %type <str> sortby_list
1122 %type <str> sortby
1123 %type <str> select_limit
1124 %type <str> opt_select_limit
1125 %type <str> limit_clause
1126 %type <str> offset_clause
1127 %type <str> select_limit_value
1128 %type <str> select_offset_value
1129 %type <str> select_fetch_first_value
1130 %type <str> I_or_F_const
1131 %type <str> row_or_rows
1132 %type <str> first_or_next
1133 %type <str> group_clause
1134 %type <str> group_by_list
1135 %type <str> group_by_item
1136 %type <str> empty_grouping_set
1137 %type <str> rollup_clause
1138 %type <str> cube_clause
1139 %type <str> grouping_sets_clause
1140 %type <str> having_clause
1141 %type <str> for_locking_clause
1142 %type <str> opt_for_locking_clause
1143 %type <str> for_locking_items
1144 %type <str> for_locking_item
1145 %type <str> for_locking_strength
1146 %type <str> locked_rels_list
1147 %type <str> values_clause
1148 %type <str> from_clause
1149 %type <str> from_list
1150 %type <str> table_ref
1151 %type <str> joined_table
1152 %type <str> alias_clause
1153 %type <str> opt_alias_clause
1154 %type <str> func_alias_clause
1155 %type <str> join_type
1156 %type <str> join_outer
1157 %type <str> join_qual
1158 %type <str> relation_expr
1159 %type <str> relation_expr_list
1160 %type <str> relation_expr_opt_alias
1161 %type <str> tablesample_clause
1162 %type <str> opt_repeatable_clause
1163 %type <str> func_table
1164 %type <str> rowsfrom_item
1165 %type <str> rowsfrom_list
1166 %type <str> opt_col_def_list
1167 %type <str> opt_ordinality
1168 %type <str> where_clause
1169 %type <str> where_or_current_clause
1170 %type <str> OptTableFuncElementList
1171 %type <str> TableFuncElementList
1172 %type <str> TableFuncElement
1173 %type <str> xmltable
1174 %type <str> xmltable_column_list
1175 %type <str> xmltable_column_el
1176 %type <str> xmltable_column_option_list
1177 %type <str> xmltable_column_option_el
1178 %type <str> xml_namespace_list
1179 %type <str> xml_namespace_el
1180 %type <str> Typename
1181 %type <index> opt_array_bounds
1182 %type <str> SimpleTypename
1183 %type <str> ConstTypename
1184 %type <str> GenericType
1185 %type <str> opt_type_modifiers
1186 %type <str> Numeric
1187 %type <str> opt_float
1188 %type <str> Bit
1189 %type <str> ConstBit
1190 %type <str> BitWithLength
1191 %type <str> BitWithoutLength
1192 %type <str> Character
1193 %type <str> ConstCharacter
1194 %type <str> CharacterWithLength
1195 %type <str> CharacterWithoutLength
1196 %type <str> character
1197 %type <str> opt_varying
1198 %type <str> ConstDatetime
1199 %type <str> ConstInterval
1200 %type <str> opt_timezone
1201 %type <str> opt_interval
1202 %type <str> interval_second
1203 %type <str> a_expr
1204 %type <str> b_expr
1205 %type <str> c_expr
1206 %type <str> func_application
1207 %type <str> func_expr
1208 %type <str> func_expr_windowless
1209 %type <str> func_expr_common_subexpr
1210 %type <str> xml_root_version
1211 %type <str> opt_xml_root_standalone
1212 %type <str> xml_attributes
1213 %type <str> xml_attribute_list
1214 %type <str> xml_attribute_el
1215 %type <str> document_or_content
1216 %type <str> xml_whitespace_option
1217 %type <str> xmlexists_argument
1218 %type <str> xml_passing_mech
1219 %type <str> within_group_clause
1220 %type <str> filter_clause
1221 %type <str> window_clause
1222 %type <str> window_definition_list
1223 %type <str> window_definition
1224 %type <str> over_clause
1225 %type <str> window_specification
1226 %type <str> opt_existing_window_name
1227 %type <str> opt_partition_clause
1228 %type <str> opt_frame_clause
1229 %type <str> frame_extent
1230 %type <str> frame_bound
1231 %type <str> opt_window_exclusion_clause
1232 %type <str> row
1233 %type <str> explicit_row
1234 %type <str> implicit_row
1235 %type <str> sub_type
1236 %type <str> all_Op
1237 %type <str> MathOp
1238 %type <str> qual_Op
1239 %type <str> qual_all_Op
1240 %type <str> subquery_Op
1241 %type <str> expr_list
1242 %type <str> func_arg_list
1243 %type <str> func_arg_expr
1244 %type <str> type_list
1245 %type <str> array_expr
1246 %type <str> array_expr_list
1247 %type <str> extract_list
1248 %type <str> extract_arg
1249 %type <str> unicode_normal_form
1250 %type <str> overlay_list
1251 %type <str> overlay_placing
1252 %type <str> position_list
1253 %type <str> substr_list
1254 %type <str> substr_from
1255 %type <str> substr_for
1256 %type <str> trim_list
1257 %type <str> in_expr
1258 %type <str> case_expr
1259 %type <str> when_clause_list
1260 %type <str> when_clause
1261 %type <str> case_default
1262 %type <str> case_arg
1263 %type <str> columnref
1264 %type <str> indirection_el
1265 %type <str> opt_slice_bound
1266 %type <str> indirection
1267 %type <str> opt_indirection
1268 %type <str> opt_asymmetric
1269 %type <str> opt_target_list
1270 %type <str> target_list
1271 %type <str> target_el
1272 %type <str> qualified_name_list
1273 %type <str> qualified_name
1274 %type <str> name_list
1275 %type <str> name
1276 %type <str> database_name
1277 %type <str> access_method
1278 %type <str> attr_name
1279 %type <str> index_name
1280 %type <str> file_name
1281 %type <str> func_name
1282 %type <str> AexprConst
1283 %type <str> Iconst
1284 %type <str> SignedIconst
1285 %type <str> RoleId
1286 %type <str> RoleSpec
1287 %type <str> role_list
1288 %type <str> NonReservedWord
1289 %type <str> unreserved_keyword
1290 %type <str> col_name_keyword
1291 %type <str> type_func_name_keyword
1292 %type <str> reserved_keyword
1293 /* ecpgtype */
1294 /* src/interfaces/ecpg/preproc/ecpg.type */
1295 %type <str> ECPGAllocateDescr
1296 %type <str> ECPGCKeywords
1297 %type <str> ECPGColId
1298 %type <str> ECPGColLabel
1299 %type <str> ECPGColLabelCommon
1300 %type <str> ECPGConnect
1301 %type <str> ECPGCursorStmt
1302 %type <str> ECPGDeallocateDescr
1303 %type <str> ECPGDeclaration
1304 %type <str> ECPGDeclare
1305 %type <str> ECPGDescribe
1306 %type <str> ECPGDisconnect
1307 %type <str> ECPGExecuteImmediateStmt
1308 %type <str> ECPGFree
1309 %type <str> ECPGGetDescHeaderItem
1310 %type <str> ECPGGetDescItem
1311 %type <str> ECPGGetDescriptorHeader
1312 %type <str> ECPGKeywords
1313 %type <str> ECPGKeywords_rest
1314 %type <str> ECPGKeywords_vanames
1315 %type <str> ECPGOpen
1316 %type <str> ECPGSetAutocommit
1317 %type <str> ECPGSetConnection
1318 %type <str> ECPGSetDescHeaderItem
1319 %type <str> ECPGSetDescItem
1320 %type <str> ECPGSetDescriptorHeader
1321 %type <str> ECPGTypeName
1322 %type <str> ECPGTypedef
1323 %type <str> ECPGVar
1324 %type <str> ECPGVarDeclaration
1325 %type <str> ECPGWhenever
1326 %type <str> ECPGunreserved_interval
1327 %type <str> UsingConst
1328 %type <str> UsingValue
1329 %type <str> all_unreserved_keyword
1330 %type <str> c_anything
1331 %type <str> c_args
1332 %type <str> c_list
1333 %type <str> c_stuff
1334 %type <str> c_stuff_item
1335 %type <str> c_term
1336 %type <str> c_thing
1337 %type <str> char_variable
1338 %type <str> char_civar
1339 %type <str> civar
1340 %type <str> civarind
1341 %type <str> ColId
1342 %type <str> ColLabel
1343 %type <str> connect_options
1344 %type <str> connection_object
1345 %type <str> connection_target
1346 %type <str> coutputvariable
1347 %type <str> cvariable
1348 %type <str> db_prefix
1349 %type <str> CreateAsStmt
1350 %type <str> DeallocateStmt
1351 %type <str> dis_name
1352 %type <str> ecpg_bconst
1353 %type <str> ecpg_fconst
1354 %type <str> ecpg_ident
1355 %type <str> ecpg_interval
1356 %type <str> ecpg_into
1357 %type <str> ecpg_fetch_into
1358 %type <str> ecpg_param
1359 %type <str> ecpg_sconst
1360 %type <str> ecpg_using
1361 %type <str> ecpg_xconst
1362 %type <str> enum_definition
1363 %type <str> enum_type
1364 %type <str> execstring
1365 %type <str> execute_rest
1366 %type <str> indicator
1367 %type <str> into_descriptor
1368 %type <str> into_sqlda
1369 %type <str> Iresult
1370 %type <str> on_off
1371 %type <str> opt_bit_field
1372 %type <str> opt_connection_name
1373 %type <str> opt_database_name
1374 %type <str> opt_ecpg_into
1375 %type <str> opt_ecpg_fetch_into
1376 %type <str> opt_ecpg_using
1377 %type <str> opt_initializer
1378 %type <str> opt_options
1379 %type <str> opt_output
1380 %type <str> opt_pointer
1381 %type <str> opt_port
1382 %type <str> opt_reference
1383 %type <str> opt_scale
1384 %type <str> opt_server
1385 %type <str> opt_user
1386 %type <str> opt_opt_value
1387 %type <str> ora_user
1388 %type <str> precision
1389 %type <str> prepared_name
1390 %type <str> quoted_ident_stringvar
1391 %type <str> s_struct_union
1392 %type <str> server
1393 %type <str> server_name
1394 %type <str> single_vt_declaration
1395 %type <str> storage_clause
1396 %type <str> storage_declaration
1397 %type <str> storage_modifier
1398 %type <str> struct_union_type
1399 %type <str> struct_union_type_with_symbol
1400 %type <str> symbol
1401 %type <str> type_declaration
1402 %type <str> type_function_name
1403 %type <str> user_name
1404 %type <str> using_descriptor
1405 %type <str> var_declaration
1406 %type <str> var_type_declarations
1407 %type <str> variable
1408 %type <str> variable_declarations
1409 %type <str> variable_list
1410 %type <str> vt_declarations
1411
1412 %type <str> Op
1413 %type <str> IntConstVar
1414 %type <str> AllConstVar
1415 %type <str> CSTRING
1416 %type <str> CPP_LINE
1417 %type <str> CVARIABLE
1418 %type <str> BCONST
1419 %type <str> SCONST
1420 %type <str> XCONST
1421 %type <str> IDENT
1422
1423 %type <struct_union> s_struct_union_symbol
1424
1425 %type <descriptor> ECPGGetDescriptor
1426 %type <descriptor> ECPGSetDescriptor
1427
1428 %type <type_enum> simple_type
1429 %type <type_enum> signed_type
1430 %type <type_enum> unsigned_type
1431
1432 %type <dtype_enum> descriptor_item
1433 %type <dtype_enum> desc_header_item
1434
1435 %type <type> var_type
1436
1437 %type <action> action
1438 /* orig_tokens */
1439 %token IDENT UIDENT FCONST SCONST USCONST BCONST XCONST Op
1440 %token ICONST PARAM
1441 %token TYPECAST DOT_DOT COLON_EQUALS EQUALS_GREATER
1442 %token LESS_EQUALS GREATER_EQUALS NOT_EQUALS
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452 %token ABORT_P ABSOLUTE_P ACCESS ACTION ADD_P ADMIN AFTER
1453 AGGREGATE ALL ALSO ALTER ALWAYS ANALYSE ANALYZE AND ANY ARRAY AS ASC
1454 ASSERTION ASSIGNMENT ASYMMETRIC AT ATTACH ATTRIBUTE AUTHORIZATION
1455
1456 BACKWARD BEFORE BEGIN_P BETWEEN BIGINT BINARY BIT
1457 BOOLEAN_P BOTH BY
1458
1459 CACHE CALL CALLED CASCADE CASCADED CASE CAST CATALOG_P CHAIN CHAR_P
1460 CHARACTER CHARACTERISTICS CHECK CHECKPOINT CLASS CLOSE
1461 CLUSTER COALESCE COLLATE COLLATION COLUMN COLUMNS COMMENT COMMENTS COMMIT
1462 COMMITTED CONCURRENTLY CONFIGURATION CONFLICT CONNECTION CONSTRAINT
1463 CONSTRAINTS CONTENT_P CONTINUE_P CONVERSION_P COPY COST CREATE
1464 CROSS CSV CUBE CURRENT_P
1465 CURRENT_CATALOG CURRENT_DATE CURRENT_ROLE CURRENT_SCHEMA
1466 CURRENT_TIME CURRENT_TIMESTAMP CURRENT_USER CURSOR CYCLE
1467
1468 DATA_P DATABASE DAY_P DEALLOCATE DEC DECIMAL_P DECLARE DEFAULT DEFAULTS
1469 DEFERRABLE DEFERRED DEFINER DELETE_P DELIMITER DELIMITERS DEPENDS DESC
1470 DETACH DICTIONARY DISABLE_P DISCARD DISTINCT DO DOCUMENT_P DOMAIN_P
1471 DOUBLE_P DROP
1472
1473 EACH ELSE ENABLE_P ENCODING ENCRYPTED END_P ENUM_P ESCAPE EVENT EXCEPT
1474 EXCLUDE EXCLUDING EXCLUSIVE EXECUTE EXISTS EXPLAIN EXPRESSION
1475 EXTENSION EXTERNAL EXTRACT
1476
1477 FALSE_P FAMILY FETCH FILTER FIRST_P FLOAT_P FOLLOWING FOR
1478 FORCE FOREIGN FORWARD FREEZE FROM FULL FUNCTION FUNCTIONS
1479
1480 GENERATED GLOBAL GRANT GRANTED GREATEST GROUP_P GROUPING GROUPS
1481
1482 HANDLER HAVING HEADER_P HOLD HOUR_P
1483
1484 IDENTITY_P IF_P ILIKE IMMEDIATE IMMUTABLE IMPLICIT_P IMPORT_P IN_P INCLUDE
1485 INCLUDING INCREMENT INDEX INDEXES INHERIT INHERITS INITIALLY INLINE_P
1486 INNER_P INOUT INPUT_P INSENSITIVE INSERT INSTEAD INT_P INTEGER
1487 INTERSECT INTERVAL INTO INVOKER IS ISNULL ISOLATION
1488
1489 JOIN
1490
1491 KEY
1492
1493 LABEL LANGUAGE LARGE_P LAST_P LATERAL_P
1494 LEADING LEAKPROOF LEAST LEFT LEVEL LIKE LIMIT LISTEN LOAD LOCAL
1495 LOCALTIME LOCALTIMESTAMP LOCATION LOCK_P LOCKED LOGGED
1496
1497 MAPPING MATCH MATERIALIZED MAXVALUE METHOD MINUTE_P MINVALUE MODE MONTH_P MOVE
1498
1499 NAME_P NAMES NATIONAL NATURAL NCHAR NEW NEXT NFC NFD NFKC NFKD NO NONE
1500 NORMALIZE NORMALIZED
1501 NOT NOTHING NOTIFY NOTNULL NOWAIT NULL_P NULLIF
1502 NULLS_P NUMERIC
1503
1504 OBJECT_P OF OFF OFFSET OIDS OLD ON ONLY OPERATOR OPTION OPTIONS OR
1505 ORDER ORDINALITY OTHERS OUT_P OUTER_P
1506 OVER OVERLAPS OVERLAY OVERRIDING OWNED OWNER
1507
1508 PARALLEL PARSER PARTIAL PARTITION PASSING PASSWORD PLACING PLANS POLICY
1509 POSITION PRECEDING PRECISION PRESERVE PREPARE PREPARED PRIMARY
1510 PRIOR PRIVILEGES PROCEDURAL PROCEDURE PROCEDURES PROGRAM PUBLICATION
1511
1512 QUOTE
1513
1514 RANGE READ REAL REASSIGN RECHECK RECURSIVE REF REFERENCES REFERENCING
1515 REFRESH REINDEX RELATIVE_P RELEASE RENAME REPEATABLE REPLACE REPLICA
1516 RESET RESTART RESTRICT RETURNING RETURNS REVOKE RIGHT ROLE ROLLBACK ROLLUP
1517 ROUTINE ROUTINES ROW ROWS RULE
1518
1519 SAVEPOINT SCHEMA SCHEMAS SCROLL SEARCH SECOND_P SECURITY SELECT SEQUENCE SEQUENCES
1520 SERIALIZABLE SERVER SESSION SESSION_USER SET SETS SETOF SHARE SHOW
1521 SIMILAR SIMPLE SKIP SMALLINT SNAPSHOT SOME SQL_P STABLE STANDALONE_P
1522 START STATEMENT STATISTICS STDIN STDOUT STORAGE STORED STRICT_P STRIP_P
1523 SUBSCRIPTION SUBSTRING SUPPORT SYMMETRIC SYSID SYSTEM_P
1524
1525 TABLE TABLES TABLESAMPLE TABLESPACE TEMP TEMPLATE TEMPORARY TEXT_P THEN
1526 TIES TIME TIMESTAMP TO TRAILING TRANSACTION TRANSFORM
1527 TREAT TRIGGER TRIM TRUE_P
1528 TRUNCATE TRUSTED TYPE_P TYPES_P
1529
1530 UESCAPE UNBOUNDED UNCOMMITTED UNENCRYPTED UNION UNIQUE UNKNOWN
1531 UNLISTEN UNLOGGED UNTIL UPDATE USER USING
1532
1533 VACUUM VALID VALIDATE VALIDATOR VALUE_P VALUES VARCHAR VARIADIC VARYING
1534 VERBOSE VERSION_P VIEW VIEWS VOLATILE
1535
1536 WHEN WHERE WHITESPACE_P WINDOW WITH WITHIN WITHOUT WORK WRAPPER WRITE
1537
1538 XML_P XMLATTRIBUTES XMLCONCAT XMLELEMENT XMLEXISTS XMLFOREST XMLNAMESPACES
1539 XMLPARSE XMLPI XMLROOT XMLSERIALIZE XMLTABLE
1540
1541 YEAR_P YES_P
1542
1543 ZONE
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555 %token NOT_LA NULLS_LA WITH_LA
1556
1557
1558
1559 %nonassoc SET
1560 %left UNION EXCEPT
1561 %left INTERSECT
1562 %left OR
1563 %left AND
1564 %right NOT
1565 %nonassoc IS ISNULL NOTNULL
1566 %nonassoc '<' '>' '=' LESS_EQUALS GREATER_EQUALS NOT_EQUALS
1567 %nonassoc BETWEEN IN_P LIKE ILIKE SIMILAR NOT_LA
1568 %nonassoc ESCAPE
1569 %left POSTFIXOP
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597 %nonassoc UNBOUNDED
1598 %nonassoc IDENT
1599 %nonassoc CSTRING GENERATED NULL_P PARTITION RANGE ROWS GROUPS PRECEDING FOLLOWING CUBE ROLLUP
1600 %left Op OPERATOR
1601 %left '+' '-'
1602 %left '*' '/' '%'
1603 %left '^'
1604
1605 %left AT
1606 %left COLLATE
1607 %right UMINUS
1608 %left '[' ']'
1609 %left '(' ')'
1610 %left TYPECAST
1611 %left '.'
1612
1613
1614
1615
1616
1617
1618
1619 %left JOIN CROSS LEFT FULL RIGHT INNER_P NATURAL
1620
1621 %right PRESERVE STRIP_P
1622
1623 %%
1624 prog: statements;
1625 /* rules */
1626 stmt:
1627 AlterEventTrigStmt
1628 { output_statement($1, 0, ECPGst_normal); }
1629 | AlterCollationStmt
1630 { output_statement($1, 0, ECPGst_normal); }
1631 | AlterDatabaseStmt
1632 { output_statement($1, 0, ECPGst_normal); }
1633 | AlterDatabaseSetStmt
1634 { output_statement($1, 0, ECPGst_normal); }
1635 | AlterDefaultPrivilegesStmt
1636 { output_statement($1, 0, ECPGst_normal); }
1637 | AlterDomainStmt
1638 { output_statement($1, 0, ECPGst_normal); }
1639 | AlterEnumStmt
1640 { output_statement($1, 0, ECPGst_normal); }
1641 | AlterExtensionStmt
1642 { output_statement($1, 0, ECPGst_normal); }
1643 | AlterExtensionContentsStmt
1644 { output_statement($1, 0, ECPGst_normal); }
1645 | AlterFdwStmt
1646 { output_statement($1, 0, ECPGst_normal); }
1647 | AlterForeignServerStmt
1648 { output_statement($1, 0, ECPGst_normal); }
1649 | AlterForeignTableStmt
1650 { output_statement($1, 0, ECPGst_normal); }
1651 | AlterFunctionStmt
1652 { output_statement($1, 0, ECPGst_normal); }
1653 | AlterGroupStmt
1654 { output_statement($1, 0, ECPGst_normal); }
1655 | AlterObjectDependsStmt
1656 { output_statement($1, 0, ECPGst_normal); }
1657 | AlterObjectSchemaStmt
1658 { output_statement($1, 0, ECPGst_normal); }
1659 | AlterOwnerStmt
1660 { output_statement($1, 0, ECPGst_normal); }
1661 | AlterOperatorStmt
1662 { output_statement($1, 0, ECPGst_normal); }
1663 | AlterTypeStmt
1664 { output_statement($1, 0, ECPGst_normal); }
1665 | AlterPolicyStmt
1666 { output_statement($1, 0, ECPGst_normal); }
1667 | AlterSeqStmt
1668 { output_statement($1, 0, ECPGst_normal); }
1669 | AlterSystemStmt
1670 { output_statement($1, 0, ECPGst_normal); }
1671 | AlterTableStmt
1672 { output_statement($1, 0, ECPGst_normal); }
1673 | AlterTblSpcStmt
1674 { output_statement($1, 0, ECPGst_normal); }
1675 | AlterCompositeTypeStmt
1676 { output_statement($1, 0, ECPGst_normal); }
1677 | AlterPublicationStmt
1678 { output_statement($1, 0, ECPGst_normal); }
1679 | AlterRoleSetStmt
1680 { output_statement($1, 0, ECPGst_normal); }
1681 | AlterRoleStmt
1682 { output_statement($1, 0, ECPGst_normal); }
1683 | AlterSubscriptionStmt
1684 { output_statement($1, 0, ECPGst_normal); }
1685 | AlterStatsStmt
1686 { output_statement($1, 0, ECPGst_normal); }
1687 | AlterTSConfigurationStmt
1688 { output_statement($1, 0, ECPGst_normal); }
1689 | AlterTSDictionaryStmt
1690 { output_statement($1, 0, ECPGst_normal); }
1691 | AlterUserMappingStmt
1692 { output_statement($1, 0, ECPGst_normal); }
1693 | AnalyzeStmt
1694 { output_statement($1, 0, ECPGst_normal); }
1695 | CallStmt
1696 { output_statement($1, 0, ECPGst_normal); }
1697 | CheckPointStmt
1698 { output_statement($1, 0, ECPGst_normal); }
1699 | ClosePortalStmt
1700 {
1701 if (INFORMIX_MODE)
1702 {
1703 if (pg_strcasecmp($1+strlen("close "), "database") == 0)
1704 {
1705 if (connection)
1706 mmerror(PARSE_ERROR, ET_ERROR, "AT option not allowed in CLOSE DATABASE statement");
1707
1708 fprintf(base_yyout, "{ ECPGdisconnect(__LINE__, \"CURRENT\");");
1709 whenever_action(2);
1710 free($1);
1711 break;
1712 }
1713 }
1714
1715 output_statement($1, 0, ECPGst_normal);
1716 }
1717 | ClusterStmt
1718 { output_statement($1, 0, ECPGst_normal); }
1719 | CommentStmt
1720 { output_statement($1, 0, ECPGst_normal); }
1721 | ConstraintsSetStmt
1722 { output_statement($1, 0, ECPGst_normal); }
1723 | CopyStmt
1724 { output_statement($1, 0, ECPGst_normal); }
1725 | CreateAmStmt
1726 { output_statement($1, 0, ECPGst_normal); }
1727 | CreateAsStmt
1728 { output_statement($1, 0, ECPGst_normal); }
1729 | CreateAssertionStmt
1730 { output_statement($1, 0, ECPGst_normal); }
1731 | CreateCastStmt
1732 { output_statement($1, 0, ECPGst_normal); }
1733 | CreateConversionStmt
1734 { output_statement($1, 0, ECPGst_normal); }
1735 | CreateDomainStmt
1736 { output_statement($1, 0, ECPGst_normal); }
1737 | CreateExtensionStmt
1738 { output_statement($1, 0, ECPGst_normal); }
1739 | CreateFdwStmt
1740 { output_statement($1, 0, ECPGst_normal); }
1741 | CreateForeignServerStmt
1742 { output_statement($1, 0, ECPGst_normal); }
1743 | CreateForeignTableStmt
1744 { output_statement($1, 0, ECPGst_normal); }
1745 | CreateFunctionStmt
1746 { output_statement($1, 0, ECPGst_normal); }
1747 | CreateGroupStmt
1748 { output_statement($1, 0, ECPGst_normal); }
1749 | CreateMatViewStmt
1750 { output_statement($1, 0, ECPGst_normal); }
1751 | CreateOpClassStmt
1752 { output_statement($1, 0, ECPGst_normal); }
1753 | CreateOpFamilyStmt
1754 { output_statement($1, 0, ECPGst_normal); }
1755 | CreatePublicationStmt
1756 { output_statement($1, 0, ECPGst_normal); }
1757 | AlterOpFamilyStmt
1758 { output_statement($1, 0, ECPGst_normal); }
1759 | CreatePolicyStmt
1760 { output_statement($1, 0, ECPGst_normal); }
1761 | CreatePLangStmt
1762 { output_statement($1, 0, ECPGst_normal); }
1763 | CreateSchemaStmt
1764 { output_statement($1, 0, ECPGst_normal); }
1765 | CreateSeqStmt
1766 { output_statement($1, 0, ECPGst_normal); }
1767 | CreateStmt
1768 { output_statement($1, 0, ECPGst_normal); }
1769 | CreateSubscriptionStmt
1770 { output_statement($1, 0, ECPGst_normal); }
1771 | CreateStatsStmt
1772 { output_statement($1, 0, ECPGst_normal); }
1773 | CreateTableSpaceStmt
1774 { output_statement($1, 0, ECPGst_normal); }
1775 | CreateTransformStmt
1776 { output_statement($1, 0, ECPGst_normal); }
1777 | CreateTrigStmt
1778 { output_statement($1, 0, ECPGst_normal); }
1779 | CreateEventTrigStmt
1780 { output_statement($1, 0, ECPGst_normal); }
1781 | CreateRoleStmt
1782 { output_statement($1, 0, ECPGst_normal); }
1783 | CreateUserStmt
1784 { output_statement($1, 0, ECPGst_normal); }
1785 | CreateUserMappingStmt
1786 { output_statement($1, 0, ECPGst_normal); }
1787 | CreatedbStmt
1788 { output_statement($1, 0, ECPGst_normal); }
1789 | DeallocateStmt
1790 {
1791 output_deallocate_prepare_statement($1);
1792 }
1793 | DeclareCursorStmt
1794 { output_simple_statement($1, (strncmp($1, "ECPGset_var", strlen("ECPGset_var")) == 0) ? 4 : 0); }
1795 | DefineStmt
1796 { output_statement($1, 0, ECPGst_normal); }
1797 | DeleteStmt
1798 { output_statement($1, 1, ECPGst_prepnormal); }
1799 | DiscardStmt
1800 { output_statement($1, 1, ECPGst_normal); }
1801 | DoStmt
1802 { output_statement($1, 0, ECPGst_normal); }
1803 | DropCastStmt
1804 { output_statement($1, 0, ECPGst_normal); }
1805 | DropOpClassStmt
1806 { output_statement($1, 0, ECPGst_normal); }
1807 | DropOpFamilyStmt
1808 { output_statement($1, 0, ECPGst_normal); }
1809 | DropOwnedStmt
1810 { output_statement($1, 0, ECPGst_normal); }
1811 | DropPLangStmt
1812 { output_statement($1, 0, ECPGst_normal); }
1813 | DropStmt
1814 { output_statement($1, 0, ECPGst_normal); }
1815 | DropSubscriptionStmt
1816 { output_statement($1, 0, ECPGst_normal); }
1817 | DropTableSpaceStmt
1818 { output_statement($1, 0, ECPGst_normal); }
1819 | DropTransformStmt
1820 { output_statement($1, 0, ECPGst_normal); }
1821 | DropRoleStmt
1822 { output_statement($1, 0, ECPGst_normal); }
1823 | DropUserMappingStmt
1824 { output_statement($1, 0, ECPGst_normal); }
1825 | DropdbStmt
1826 { output_statement($1, 0, ECPGst_normal); }
1827 | ExecuteStmt
1828 {
1829 if ($1.type == NULL || strlen($1.type) == 0)
1830 output_statement($1.name, 1, ECPGst_execute);
1831 else
1832 {
1833 if ($1.name[0] != '"')
1834 /* case of char_variable */
1835 add_variable_to_tail(&argsinsert, find_variable($1.name), &no_indicator);
1836 else
1837 {
1838 /* case of ecpg_ident or CSTRING */
1839 char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
1840 char *str = mm_strdup($1.name + 1);
1841
1842 /* It must be cut off double quotation because new_variable() double-quotes. */
1843 str[strlen(str) - 1] = '\0';
1844 sprintf(length, "%zu", strlen(str));
1845 add_variable_to_tail(&argsinsert, new_variable(str, ECPGmake_simple_type(ECPGt_const, length, 0), 0), &no_indicator);
1846 }
1847 output_statement(cat_str(3, mm_strdup("execute"), mm_strdup("$0"), $1.type), 0, ECPGst_exec_with_exprlist);
1848 }
1849 }
1850 | ExplainStmt
1851 { output_statement($1, 0, ECPGst_normal); }
1852 | FetchStmt
1853 { output_statement($1, 1, ECPGst_normal); }
1854 | GrantStmt
1855 { output_statement($1, 0, ECPGst_normal); }
1856 | GrantRoleStmt
1857 { output_statement($1, 0, ECPGst_normal); }
1858 | ImportForeignSchemaStmt
1859 { output_statement($1, 0, ECPGst_normal); }
1860 | IndexStmt
1861 { output_statement($1, 0, ECPGst_normal); }
1862 | InsertStmt
1863 { output_statement($1, 1, ECPGst_prepnormal); }
1864 | ListenStmt
1865 { output_statement($1, 0, ECPGst_normal); }
1866 | RefreshMatViewStmt
1867 { output_statement($1, 0, ECPGst_normal); }
1868 | LoadStmt
1869 { output_statement($1, 0, ECPGst_normal); }
1870 | LockStmt
1871 { output_statement($1, 0, ECPGst_normal); }
1872 | NotifyStmt
1873 { output_statement($1, 0, ECPGst_normal); }
1874 | PrepareStmt
1875 {
1876 if ($1.type == NULL)
1877 output_prepare_statement($1.name, $1.stmt);
1878 else if (strlen($1.type) == 0)
1879 {
1880 char *stmt = cat_str(3, mm_strdup("\""), $1.stmt, mm_strdup("\""));
1881 output_prepare_statement($1.name, stmt);
1882 }
1883 else
1884 {
1885 if ($1.name[0] != '"')
1886 /* case of char_variable */
1887 add_variable_to_tail(&argsinsert, find_variable($1.name), &no_indicator);
1888 else
1889 {
1890 char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
1891 char *str = mm_strdup($1.name + 1);
1892
1893 /* It must be cut off double quotation because new_variable() double-quotes. */
1894 str[strlen(str) - 1] = '\0';
1895 sprintf(length, "%zu", strlen(str));
1896 add_variable_to_tail(&argsinsert, new_variable(str, ECPGmake_simple_type(ECPGt_const, length, 0), 0), &no_indicator);
1897 }
1898 output_statement(cat_str(5, mm_strdup("prepare"), mm_strdup("$0"), $1.type, mm_strdup("as"), $1.stmt), 0, ECPGst_prepare);
1899 }
1900 }
1901 | ReassignOwnedStmt
1902 { output_statement($1, 0, ECPGst_normal); }
1903 | ReindexStmt
1904 { output_statement($1, 0, ECPGst_normal); }
1905 | RemoveAggrStmt
1906 { output_statement($1, 0, ECPGst_normal); }
1907 | RemoveFuncStmt
1908 { output_statement($1, 0, ECPGst_normal); }
1909 | RemoveOperStmt
1910 { output_statement($1, 0, ECPGst_normal); }
1911 | RenameStmt
1912 { output_statement($1, 0, ECPGst_normal); }
1913 | RevokeStmt
1914 { output_statement($1, 0, ECPGst_normal); }
1915 | RevokeRoleStmt
1916 { output_statement($1, 0, ECPGst_normal); }
1917 | RuleStmt
1918 { output_statement($1, 0, ECPGst_normal); }
1919 | SecLabelStmt
1920 { output_statement($1, 0, ECPGst_normal); }
1921 | SelectStmt
1922 { output_statement($1, 1, ECPGst_prepnormal); }
1923 | TransactionStmt
1924 {
1925 fprintf(base_yyout, "{ ECPGtrans(__LINE__, %s, \"%s\");", connection ? connection : "NULL", $1);
1926 whenever_action(2);
1927 free($1);
1928 }
1929 | TruncateStmt
1930 { output_statement($1, 0, ECPGst_normal); }
1931 | UnlistenStmt
1932 { output_statement($1, 0, ECPGst_normal); }
1933 | UpdateStmt
1934 { output_statement($1, 1, ECPGst_prepnormal); }
1935 | VacuumStmt
1936 { output_statement($1, 0, ECPGst_normal); }
1937 | VariableResetStmt
1938 { output_statement($1, 0, ECPGst_normal); }
1939 | VariableSetStmt
1940 { output_statement($1, 0, ECPGst_normal); }
1941 | VariableShowStmt
1942 { output_statement($1, 0, ECPGst_normal); }
1943 | ViewStmt
1944 { output_statement($1, 0, ECPGst_normal); }
1945 | ECPGAllocateDescr
1946 {
1947 fprintf(base_yyout,"ECPGallocate_desc(__LINE__, %s);",$1);
1948 whenever_action(0);
1949 free($1);
1950 }
1951 | ECPGConnect
1952 {
1953 if (connection)
1954 mmerror(PARSE_ERROR, ET_ERROR, "AT option not allowed in CONNECT statement");
1955
1956 fprintf(base_yyout, "{ ECPGconnect(__LINE__, %d, %s, %d); ", compat, $1, autocommit);
1957 reset_variables();
1958 whenever_action(2);
1959 free($1);
1960 }
1961 | ECPGCursorStmt
1962 {
1963 output_simple_statement($1, (strncmp($1, "ECPGset_var", strlen("ECPGset_var")) == 0) ? 4 : 0);
1964 }
1965 | ECPGDeallocateDescr
1966 {
1967 fprintf(base_yyout,"ECPGdeallocate_desc(__LINE__, %s);",$1);
1968 whenever_action(0);
1969 free($1);
1970 }
1971 | ECPGDeclare
1972 {
1973 output_simple_statement($1, 0);
1974 }
1975 | ECPGDescribe
1976 {
1977 fprintf(base_yyout, "{ ECPGdescribe(__LINE__, %d, %s,", compat, $1);
1978 dump_variables(argsresult, 1);
1979 fputs("ECPGt_EORT);", base_yyout);
1980 fprintf(base_yyout, "}");
1981 output_line_number();
1982
1983 free($1);
1984 }
1985 | ECPGDisconnect
1986 {
1987 if (connection)
1988 mmerror(PARSE_ERROR, ET_ERROR, "AT option not allowed in DISCONNECT statement");
1989
1990 fprintf(base_yyout, "{ ECPGdisconnect(__LINE__, %s);",
1991 $1 ? $1 : "\"CURRENT\"");
1992 whenever_action(2);
1993 free($1);
1994 }
1995 | ECPGExecuteImmediateStmt { output_statement($1, 0, ECPGst_exec_immediate); }
1996 | ECPGFree
1997 {
1998 const char *con = connection ? connection : "NULL";
1999
2000 if (strcmp($1, "all") == 0)
2001 fprintf(base_yyout, "{ ECPGdeallocate_all(__LINE__, %d, %s);", compat, con);
2002 else if ($1[0] == ':')
2003 fprintf(base_yyout, "{ ECPGdeallocate(__LINE__, %d, %s, %s);", compat, con, $1+1);
2004 else
2005 fprintf(base_yyout, "{ ECPGdeallocate(__LINE__, %d, %s, \"%s\");", compat, con, $1);
2006
2007 whenever_action(2);
2008 free($1);
2009 }
2010 | ECPGGetDescriptor
2011 {
2012 lookup_descriptor($1.name, connection);
2013 output_get_descr($1.name, $1.str);
2014 free($1.name);
2015 free($1.str);
2016 }
2017 | ECPGGetDescriptorHeader
2018 {
2019 lookup_descriptor($1, connection);
2020 output_get_descr_header($1);
2021 free($1);
2022 }
2023 | ECPGOpen
2024 {
2025 struct cursor *ptr;
2026
2027 if ((ptr = add_additional_variables($1, true)) != NULL)
2028 {
2029 connection = ptr->connection ? mm_strdup(ptr->connection) : NULL;
2030 output_statement(mm_strdup(ptr->command), 0, ECPGst_normal);
2031 ptr->opened = true;
2032 }
2033 }
2034 | ECPGSetAutocommit
2035 {
2036 fprintf(base_yyout, "{ ECPGsetcommit(__LINE__, \"%s\", %s);", $1, connection ? connection : "NULL");
2037 whenever_action(2);
2038 free($1);
2039 }
2040 | ECPGSetConnection
2041 {
2042 if (connection)
2043 mmerror(PARSE_ERROR, ET_ERROR, "AT option not allowed in SET CONNECTION statement");
2044
2045 fprintf(base_yyout, "{ ECPGsetconn(__LINE__, %s);", $1);
2046 whenever_action(2);
2047 free($1);
2048 }
2049 | ECPGSetDescriptor
2050 {
2051 lookup_descriptor($1.name, connection);
2052 output_set_descr($1.name, $1.str);
2053 free($1.name);
2054 free($1.str);
2055 }
2056 | ECPGSetDescriptorHeader
2057 {
2058 lookup_descriptor($1, connection);
2059 output_set_descr_header($1);
2060 free($1);
2061 }
2062 | ECPGTypedef
2063 {
2064 if (connection)
2065 mmerror(PARSE_ERROR, ET_ERROR, "AT option not allowed in TYPE statement");
2066
2067 fprintf(base_yyout, "%s", $1);
2068 free($1);
2069 output_line_number();
2070 }
2071 | ECPGVar
2072 {
2073 if (connection)
2074 mmerror(PARSE_ERROR, ET_ERROR, "AT option not allowed in VAR statement");
2075
2076 output_simple_statement($1, 0);
2077 }
2078 | ECPGWhenever
2079 {
2080 if (connection)
2081 mmerror(PARSE_ERROR, ET_ERROR, "AT option not allowed in WHENEVER statement");
2082
2083 output_simple_statement($1, 0);
2084 }
2085 |
2086 { $$ = NULL; }
2087 ;
2088
2089
2090 CallStmt:
2091 CALL func_application
2092 {
2093 $$ = cat_str(2,mm_strdup("call"),$2);
2094 }
2095 ;
2096
2097
2098 CreateRoleStmt:
2099 CREATE ROLE RoleId opt_with OptRoleList
2100 {
2101 $$ = cat_str(4,mm_strdup("create role"),$3,$4,$5);
2102 }
2103 ;
2104
2105
2106 opt_with:
2107 WITH
2108 {
2109 $$ = mm_strdup("with");
2110 }
2111 | WITH_LA
2112 {
2113 $$ = mm_strdup("with");
2114 }
2115 |
2116 {
2117 $$=EMPTY; }
2118 ;
2119
2120
2121 OptRoleList:
2122 OptRoleList CreateOptRoleElem
2123 {
2124 $$ = cat_str(2,$1,$2);
2125 }
2126 |
2127 {
2128 $$=EMPTY; }
2129 ;
2130
2131
2132 AlterOptRoleList:
2133 AlterOptRoleList AlterOptRoleElem
2134 {
2135 $$ = cat_str(2,$1,$2);
2136 }
2137 |
2138 {
2139 $$=EMPTY; }
2140 ;
2141
2142
2143 AlterOptRoleElem:
2144 PASSWORD ecpg_sconst
2145 {
2146 $$ = cat_str(2,mm_strdup("password"),$2);
2147 }
2148 | PASSWORD NULL_P
2149 {
2150 $$ = mm_strdup("password null");
2151 }
2152 | ENCRYPTED PASSWORD ecpg_sconst
2153 {
2154 $$ = cat_str(2,mm_strdup("encrypted password"),$3);
2155 }
2156 | UNENCRYPTED PASSWORD ecpg_sconst
2157 {
2158 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
2159 $$ = cat_str(2,mm_strdup("unencrypted password"),$3);
2160 }
2161 | INHERIT
2162 {
2163 $$ = mm_strdup("inherit");
2164 }
2165 | CONNECTION LIMIT SignedIconst
2166 {
2167 $$ = cat_str(2,mm_strdup("connection limit"),$3);
2168 }
2169 | VALID UNTIL ecpg_sconst
2170 {
2171 $$ = cat_str(2,mm_strdup("valid until"),$3);
2172 }
2173 | USER role_list
2174 {
2175 $$ = cat_str(2,mm_strdup("user"),$2);
2176 }
2177 | ecpg_ident
2178 {
2179 $$ = $1;
2180 }
2181 ;
2182
2183
2184 CreateOptRoleElem:
2185 AlterOptRoleElem
2186 {
2187 $$ = $1;
2188 }
2189 | SYSID Iconst
2190 {
2191 $$ = cat_str(2,mm_strdup("sysid"),$2);
2192 }
2193 | ADMIN role_list
2194 {
2195 $$ = cat_str(2,mm_strdup("admin"),$2);
2196 }
2197 | ROLE role_list
2198 {
2199 $$ = cat_str(2,mm_strdup("role"),$2);
2200 }
2201 | IN_P ROLE role_list
2202 {
2203 $$ = cat_str(2,mm_strdup("in role"),$3);
2204 }
2205 | IN_P GROUP_P role_list
2206 {
2207 $$ = cat_str(2,mm_strdup("in group"),$3);
2208 }
2209 ;
2210
2211
2212 CreateUserStmt:
2213 CREATE USER RoleId opt_with OptRoleList
2214 {
2215 $$ = cat_str(4,mm_strdup("create user"),$3,$4,$5);
2216 }
2217 ;
2218
2219
2220 AlterRoleStmt:
2221 ALTER ROLE RoleSpec opt_with AlterOptRoleList
2222 {
2223 $$ = cat_str(4,mm_strdup("alter role"),$3,$4,$5);
2224 }
2225 | ALTER USER RoleSpec opt_with AlterOptRoleList
2226 {
2227 $$ = cat_str(4,mm_strdup("alter user"),$3,$4,$5);
2228 }
2229 ;
2230
2231
2232 opt_in_database:
2233
2234 {
2235 $$=EMPTY; }
2236 | IN_P DATABASE database_name
2237 {
2238 $$ = cat_str(2,mm_strdup("in database"),$3);
2239 }
2240 ;
2241
2242
2243 AlterRoleSetStmt:
2244 ALTER ROLE RoleSpec opt_in_database SetResetClause
2245 {
2246 $$ = cat_str(4,mm_strdup("alter role"),$3,$4,$5);
2247 }
2248 | ALTER ROLE ALL opt_in_database SetResetClause
2249 {
2250 $$ = cat_str(3,mm_strdup("alter role all"),$4,$5);
2251 }
2252 | ALTER USER RoleSpec opt_in_database SetResetClause
2253 {
2254 $$ = cat_str(4,mm_strdup("alter user"),$3,$4,$5);
2255 }
2256 | ALTER USER ALL opt_in_database SetResetClause
2257 {
2258 $$ = cat_str(3,mm_strdup("alter user all"),$4,$5);
2259 }
2260 ;
2261
2262
2263 DropRoleStmt:
2264 DROP ROLE role_list
2265 {
2266 $$ = cat_str(2,mm_strdup("drop role"),$3);
2267 }
2268 | DROP ROLE IF_P EXISTS role_list
2269 {
2270 $$ = cat_str(2,mm_strdup("drop role if exists"),$5);
2271 }
2272 | DROP USER role_list
2273 {
2274 $$ = cat_str(2,mm_strdup("drop user"),$3);
2275 }
2276 | DROP USER IF_P EXISTS role_list
2277 {
2278 $$ = cat_str(2,mm_strdup("drop user if exists"),$5);
2279 }
2280 | DROP GROUP_P role_list
2281 {
2282 $$ = cat_str(2,mm_strdup("drop group"),$3);
2283 }
2284 | DROP GROUP_P IF_P EXISTS role_list
2285 {
2286 $$ = cat_str(2,mm_strdup("drop group if exists"),$5);
2287 }
2288 ;
2289
2290
2291 CreateGroupStmt:
2292 CREATE GROUP_P RoleId opt_with OptRoleList
2293 {
2294 $$ = cat_str(4,mm_strdup("create group"),$3,$4,$5);
2295 }
2296 ;
2297
2298
2299 AlterGroupStmt:
2300 ALTER GROUP_P RoleSpec add_drop USER role_list
2301 {
2302 $$ = cat_str(5,mm_strdup("alter group"),$3,$4,mm_strdup("user"),$6);
2303 }
2304 ;
2305
2306
2307 add_drop:
2308 ADD_P
2309 {
2310 $$ = mm_strdup("add");
2311 }
2312 | DROP
2313 {
2314 $$ = mm_strdup("drop");
2315 }
2316 ;
2317
2318
2319 CreateSchemaStmt:
2320 CREATE SCHEMA OptSchemaName AUTHORIZATION RoleSpec OptSchemaEltList
2321 {
2322 $$ = cat_str(5,mm_strdup("create schema"),$3,mm_strdup("authorization"),$5,$6);
2323 }
2324 | CREATE SCHEMA ColId OptSchemaEltList
2325 {
2326 $$ = cat_str(3,mm_strdup("create schema"),$3,$4);
2327 }
2328 | CREATE SCHEMA IF_P NOT EXISTS OptSchemaName AUTHORIZATION RoleSpec OptSchemaEltList
2329 {
2330 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
2331 $$ = cat_str(5,mm_strdup("create schema if not exists"),$6,mm_strdup("authorization"),$8,$9);
2332 }
2333 | CREATE SCHEMA IF_P NOT EXISTS ColId OptSchemaEltList
2334 {
2335 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
2336 $$ = cat_str(3,mm_strdup("create schema if not exists"),$6,$7);
2337 }
2338 ;
2339
2340
2341 OptSchemaName:
2342 ColId
2343 {
2344 $$ = $1;
2345 }
2346 |
2347 {
2348 $$=EMPTY; }
2349 ;
2350
2351
2352 OptSchemaEltList:
2353 OptSchemaEltList schema_stmt
2354 {
2355 $$ = cat_str(2,$1,$2);
2356 }
2357 |
2358 {
2359 $$=EMPTY; }
2360 ;
2361
2362
2363 schema_stmt:
2364 CreateStmt
2365 {
2366 $$ = $1;
2367 }
2368 | IndexStmt
2369 {
2370 $$ = $1;
2371 }
2372 | CreateSeqStmt
2373 {
2374 $$ = $1;
2375 }
2376 | CreateTrigStmt
2377 {
2378 $$ = $1;
2379 }
2380 | GrantStmt
2381 {
2382 $$ = $1;
2383 }
2384 | ViewStmt
2385 {
2386 $$ = $1;
2387 }
2388 ;
2389
2390
2391 VariableSetStmt:
2392 SET set_rest
2393 {
2394 $$ = cat_str(2,mm_strdup("set"),$2);
2395 }
2396 | SET LOCAL set_rest
2397 {
2398 $$ = cat_str(2,mm_strdup("set local"),$3);
2399 }
2400 | SET SESSION set_rest
2401 {
2402 $$ = cat_str(2,mm_strdup("set session"),$3);
2403 }
2404 ;
2405
2406
2407 set_rest:
2408 TRANSACTION transaction_mode_list
2409 {
2410 $$ = cat_str(2,mm_strdup("transaction"),$2);
2411 }
2412 | SESSION CHARACTERISTICS AS TRANSACTION transaction_mode_list
2413 {
2414 $$ = cat_str(2,mm_strdup("session characteristics as transaction"),$5);
2415 }
2416 | set_rest_more
2417 {
2418 $$ = $1;
2419 }
2420 ;
2421
2422
2423 generic_set:
2424 var_name TO var_list
2425 {
2426 $$ = cat_str(3,$1,mm_strdup("to"),$3);
2427 }
2428 | var_name '=' var_list
2429 {
2430 $$ = cat_str(3,$1,mm_strdup("="),$3);
2431 }
2432 | var_name TO DEFAULT
2433 {
2434 $$ = cat_str(2,$1,mm_strdup("to default"));
2435 }
2436 | var_name '=' DEFAULT
2437 {
2438 $$ = cat_str(2,$1,mm_strdup("= default"));
2439 }
2440 ;
2441
2442
2443 set_rest_more:
2444 generic_set
2445 {
2446 $$ = $1;
2447 }
2448 | var_name FROM CURRENT_P
2449 {
2450 $$ = cat_str(2,$1,mm_strdup("from current"));
2451 }
2452 | TIME ZONE zone_value
2453 {
2454 $$ = cat_str(2,mm_strdup("time zone"),$3);
2455 }
2456 | CATALOG_P ecpg_sconst
2457 {
2458 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
2459 $$ = cat_str(2,mm_strdup("catalog"),$2);
2460 }
2461 | SCHEMA ecpg_sconst
2462 {
2463 $$ = cat_str(2,mm_strdup("schema"),$2);
2464 }
2465 | NAMES opt_encoding
2466 {
2467 $$ = cat_str(2,mm_strdup("names"),$2);
2468 }
2469 | ROLE NonReservedWord_or_Sconst
2470 {
2471 $$ = cat_str(2,mm_strdup("role"),$2);
2472 }
2473 | SESSION AUTHORIZATION NonReservedWord_or_Sconst
2474 {
2475 $$ = cat_str(2,mm_strdup("session authorization"),$3);
2476 }
2477 | SESSION AUTHORIZATION DEFAULT
2478 {
2479 $$ = mm_strdup("session authorization default");
2480 }
2481 | XML_P OPTION document_or_content
2482 {
2483 $$ = cat_str(2,mm_strdup("xml option"),$3);
2484 }
2485 | TRANSACTION SNAPSHOT ecpg_sconst
2486 {
2487 $$ = cat_str(2,mm_strdup("transaction snapshot"),$3);
2488 }
2489 ;
2490
2491
2492 var_name:
2493 ECPGColId
2494 {
2495 $$ = $1;
2496 }
2497 | var_name '.' ColId
2498 {
2499 $$ = cat_str(3,$1,mm_strdup("."),$3);
2500 }
2501 ;
2502
2503
2504 var_list:
2505 var_value
2506 {
2507 $$ = $1;
2508 }
2509 | var_list ',' var_value
2510 {
2511 $$ = cat_str(3,$1,mm_strdup(","),$3);
2512 }
2513 ;
2514
2515
2516 var_value:
2517 opt_boolean_or_string
2518 {
2519 $$ = $1;
2520 }
2521 | NumericOnly
2522 {
2523 if ($1[0] == '$')
2524 {
2525 free($1);
2526 $1 = mm_strdup("$0");
2527 }
2528
2529 $$ = $1;
2530 }
2531 ;
2532
2533
2534 iso_level:
2535 READ UNCOMMITTED
2536 {
2537 $$ = mm_strdup("read uncommitted");
2538 }
2539 | READ COMMITTED
2540 {
2541 $$ = mm_strdup("read committed");
2542 }
2543 | REPEATABLE READ
2544 {
2545 $$ = mm_strdup("repeatable read");
2546 }
2547 | SERIALIZABLE
2548 {
2549 $$ = mm_strdup("serializable");
2550 }
2551 ;
2552
2553
2554 opt_boolean_or_string:
2555 TRUE_P
2556 {
2557 $$ = mm_strdup("true");
2558 }
2559 | FALSE_P
2560 {
2561 $$ = mm_strdup("false");
2562 }
2563 | ON
2564 {
2565 $$ = mm_strdup("on");
2566 }
2567 | NonReservedWord_or_Sconst
2568 {
2569 $$ = $1;
2570 }
2571 ;
2572
2573
2574 zone_value:
2575 ecpg_sconst
2576 {
2577 $$ = $1;
2578 }
2579 | ecpg_ident
2580 {
2581 $$ = $1;
2582 }
2583 | ConstInterval ecpg_sconst opt_interval
2584 {
2585 $$ = cat_str(3,$1,$2,$3);
2586 }
2587 | ConstInterval '(' Iconst ')' ecpg_sconst
2588 {
2589 $$ = cat_str(5,$1,mm_strdup("("),$3,mm_strdup(")"),$5);
2590 }
2591 | NumericOnly
2592 {
2593 $$ = $1;
2594 }
2595 | DEFAULT
2596 {
2597 $$ = mm_strdup("default");
2598 }
2599 | LOCAL
2600 {
2601 $$ = mm_strdup("local");
2602 }
2603 ;
2604
2605
2606 opt_encoding:
2607 ecpg_sconst
2608 {
2609 $$ = $1;
2610 }
2611 | DEFAULT
2612 {
2613 $$ = mm_strdup("default");
2614 }
2615 |
2616 {
2617 $$=EMPTY; }
2618 ;
2619
2620
2621 NonReservedWord_or_Sconst:
2622 NonReservedWord
2623 {
2624 $$ = $1;
2625 }
2626 | ecpg_sconst
2627 {
2628 $$ = $1;
2629 }
2630 ;
2631
2632
2633 VariableResetStmt:
2634 RESET reset_rest
2635 {
2636 $$ = cat_str(2,mm_strdup("reset"),$2);
2637 }
2638 ;
2639
2640
2641 reset_rest:
2642 generic_reset
2643 {
2644 $$ = $1;
2645 }
2646 | TIME ZONE
2647 {
2648 $$ = mm_strdup("time zone");
2649 }
2650 | TRANSACTION ISOLATION LEVEL
2651 {
2652 $$ = mm_strdup("transaction isolation level");
2653 }
2654 | SESSION AUTHORIZATION
2655 {
2656 $$ = mm_strdup("session authorization");
2657 }
2658 ;
2659
2660
2661 generic_reset:
2662 var_name
2663 {
2664 $$ = $1;
2665 }
2666 | ALL
2667 {
2668 $$ = mm_strdup("all");
2669 }
2670 ;
2671
2672
2673 SetResetClause:
2674 SET set_rest
2675 {
2676 $$ = cat_str(2,mm_strdup("set"),$2);
2677 }
2678 | VariableResetStmt
2679 {
2680 $$ = $1;
2681 }
2682 ;
2683
2684
2685 FunctionSetResetClause:
2686 SET set_rest_more
2687 {
2688 $$ = cat_str(2,mm_strdup("set"),$2);
2689 }
2690 | VariableResetStmt
2691 {
2692 $$ = $1;
2693 }
2694 ;
2695
2696
2697 VariableShowStmt:
2698 SHOW var_name ecpg_into
2699 {
2700 $$ = cat_str(2,mm_strdup("show"),$2);
2701 }
2702 | SHOW TIME ZONE ecpg_into
2703 {
2704 $$ = mm_strdup("show time zone");
2705 }
2706 | SHOW TRANSACTION ISOLATION LEVEL ecpg_into
2707 {
2708 $$ = mm_strdup("show transaction isolation level");
2709 }
2710 | SHOW SESSION AUTHORIZATION ecpg_into
2711 {
2712 $$ = mm_strdup("show session authorization");
2713 }
2714 | SHOW ALL
2715 {
2716 mmerror(PARSE_ERROR, ET_ERROR, "SHOW ALL is not implemented");
2717 $$ = EMPTY;
2718 }
2719 ;
2720
2721
2722 ConstraintsSetStmt:
2723 SET CONSTRAINTS constraints_set_list constraints_set_mode
2724 {
2725 $$ = cat_str(3,mm_strdup("set constraints"),$3,$4);
2726 }
2727 ;
2728
2729
2730 constraints_set_list:
2731 ALL
2732 {
2733 $$ = mm_strdup("all");
2734 }
2735 | qualified_name_list
2736 {
2737 $$ = $1;
2738 }
2739 ;
2740
2741
2742 constraints_set_mode:
2743 DEFERRED
2744 {
2745 $$ = mm_strdup("deferred");
2746 }
2747 | IMMEDIATE
2748 {
2749 $$ = mm_strdup("immediate");
2750 }
2751 ;
2752
2753
2754 CheckPointStmt:
2755 CHECKPOINT
2756 {
2757 $$ = mm_strdup("checkpoint");
2758 }
2759 ;
2760
2761
2762 DiscardStmt:
2763 DISCARD ALL
2764 {
2765 $$ = mm_strdup("discard all");
2766 }
2767 | DISCARD TEMP
2768 {
2769 $$ = mm_strdup("discard temp");
2770 }
2771 | DISCARD TEMPORARY
2772 {
2773 $$ = mm_strdup("discard temporary");
2774 }
2775 | DISCARD PLANS
2776 {
2777 $$ = mm_strdup("discard plans");
2778 }
2779 | DISCARD SEQUENCES
2780 {
2781 $$ = mm_strdup("discard sequences");
2782 }
2783 ;
2784
2785
2786 AlterTableStmt:
2787 ALTER TABLE relation_expr alter_table_cmds
2788 {
2789 $$ = cat_str(3,mm_strdup("alter table"),$3,$4);
2790 }
2791 | ALTER TABLE IF_P EXISTS relation_expr alter_table_cmds
2792 {
2793 $$ = cat_str(3,mm_strdup("alter table if exists"),$5,$6);
2794 }
2795 | ALTER TABLE relation_expr partition_cmd
2796 {
2797 $$ = cat_str(3,mm_strdup("alter table"),$3,$4);
2798 }
2799 | ALTER TABLE IF_P EXISTS relation_expr partition_cmd
2800 {
2801 $$ = cat_str(3,mm_strdup("alter table if exists"),$5,$6);
2802 }
2803 | ALTER TABLE ALL IN_P TABLESPACE name SET TABLESPACE name opt_nowait
2804 {
2805 $$ = cat_str(5,mm_strdup("alter table all in tablespace"),$6,mm_strdup("set tablespace"),$9,$10);
2806 }
2807 | ALTER TABLE ALL IN_P TABLESPACE name OWNED BY role_list SET TABLESPACE name opt_nowait
2808 {
2809 $$ = cat_str(7,mm_strdup("alter table all in tablespace"),$6,mm_strdup("owned by"),$9,mm_strdup("set tablespace"),$12,$13);
2810 }
2811 | ALTER INDEX qualified_name alter_table_cmds
2812 {
2813 $$ = cat_str(3,mm_strdup("alter index"),$3,$4);
2814 }
2815 | ALTER INDEX IF_P EXISTS qualified_name alter_table_cmds
2816 {
2817 $$ = cat_str(3,mm_strdup("alter index if exists"),$5,$6);
2818 }
2819 | ALTER INDEX qualified_name index_partition_cmd
2820 {
2821 $$ = cat_str(3,mm_strdup("alter index"),$3,$4);
2822 }
2823 | ALTER INDEX ALL IN_P TABLESPACE name SET TABLESPACE name opt_nowait
2824 {
2825 $$ = cat_str(5,mm_strdup("alter index all in tablespace"),$6,mm_strdup("set tablespace"),$9,$10);
2826 }
2827 | ALTER INDEX ALL IN_P TABLESPACE name OWNED BY role_list SET TABLESPACE name opt_nowait
2828 {
2829 $$ = cat_str(7,mm_strdup("alter index all in tablespace"),$6,mm_strdup("owned by"),$9,mm_strdup("set tablespace"),$12,$13);
2830 }
2831 | ALTER SEQUENCE qualified_name alter_table_cmds
2832 {
2833 $$ = cat_str(3,mm_strdup("alter sequence"),$3,$4);
2834 }
2835 | ALTER SEQUENCE IF_P EXISTS qualified_name alter_table_cmds
2836 {
2837 $$ = cat_str(3,mm_strdup("alter sequence if exists"),$5,$6);
2838 }
2839 | ALTER VIEW qualified_name alter_table_cmds
2840 {
2841 $$ = cat_str(3,mm_strdup("alter view"),$3,$4);
2842 }
2843 | ALTER VIEW IF_P EXISTS qualified_name alter_table_cmds
2844 {
2845 $$ = cat_str(3,mm_strdup("alter view if exists"),$5,$6);
2846 }
2847 | ALTER MATERIALIZED VIEW qualified_name alter_table_cmds
2848 {
2849 $$ = cat_str(3,mm_strdup("alter materialized view"),$4,$5);
2850 }
2851 | ALTER MATERIALIZED VIEW IF_P EXISTS qualified_name alter_table_cmds
2852 {
2853 $$ = cat_str(3,mm_strdup("alter materialized view if exists"),$6,$7);
2854 }
2855 | ALTER MATERIALIZED VIEW ALL IN_P TABLESPACE name SET TABLESPACE name opt_nowait
2856 {
2857 $$ = cat_str(5,mm_strdup("alter materialized view all in tablespace"),$7,mm_strdup("set tablespace"),$10,$11);
2858 }
2859 | ALTER MATERIALIZED VIEW ALL IN_P TABLESPACE name OWNED BY role_list SET TABLESPACE name opt_nowait
2860 {
2861 $$ = cat_str(7,mm_strdup("alter materialized view all in tablespace"),$7,mm_strdup("owned by"),$10,mm_strdup("set tablespace"),$13,$14);
2862 }
2863 ;
2864
2865
2866 alter_table_cmds:
2867 alter_table_cmd
2868 {
2869 $$ = $1;
2870 }
2871 | alter_table_cmds ',' alter_table_cmd
2872 {
2873 $$ = cat_str(3,$1,mm_strdup(","),$3);
2874 }
2875 ;
2876
2877
2878 partition_cmd:
2879 ATTACH PARTITION qualified_name PartitionBoundSpec
2880 {
2881 $$ = cat_str(3,mm_strdup("attach partition"),$3,$4);
2882 }
2883 | DETACH PARTITION qualified_name
2884 {
2885 $$ = cat_str(2,mm_strdup("detach partition"),$3);
2886 }
2887 ;
2888
2889
2890 index_partition_cmd:
2891 ATTACH PARTITION qualified_name
2892 {
2893 $$ = cat_str(2,mm_strdup("attach partition"),$3);
2894 }
2895 ;
2896
2897
2898 alter_table_cmd:
2899 ADD_P columnDef
2900 {
2901 $$ = cat_str(2,mm_strdup("add"),$2);
2902 }
2903 | ADD_P IF_P NOT EXISTS columnDef
2904 {
2905 $$ = cat_str(2,mm_strdup("add if not exists"),$5);
2906 }
2907 | ADD_P COLUMN columnDef
2908 {
2909 $$ = cat_str(2,mm_strdup("add column"),$3);
2910 }
2911 | ADD_P COLUMN IF_P NOT EXISTS columnDef
2912 {
2913 $$ = cat_str(2,mm_strdup("add column if not exists"),$6);
2914 }
2915 | ALTER opt_column ColId alter_column_default
2916 {
2917 $$ = cat_str(4,mm_strdup("alter"),$2,$3,$4);
2918 }
2919 | ALTER opt_column ColId DROP NOT NULL_P
2920 {
2921 $$ = cat_str(4,mm_strdup("alter"),$2,$3,mm_strdup("drop not null"));
2922 }
2923 | ALTER opt_column ColId SET NOT NULL_P
2924 {
2925 $$ = cat_str(4,mm_strdup("alter"),$2,$3,mm_strdup("set not null"));
2926 }
2927 | ALTER opt_column ColId DROP EXPRESSION
2928 {
2929 $$ = cat_str(4,mm_strdup("alter"),$2,$3,mm_strdup("drop expression"));
2930 }
2931 | ALTER opt_column ColId DROP EXPRESSION IF_P EXISTS
2932 {
2933 $$ = cat_str(4,mm_strdup("alter"),$2,$3,mm_strdup("drop expression if exists"));
2934 }
2935 | ALTER opt_column ColId SET STATISTICS SignedIconst
2936 {
2937 $$ = cat_str(5,mm_strdup("alter"),$2,$3,mm_strdup("set statistics"),$6);
2938 }
2939 | ALTER opt_column Iconst SET STATISTICS SignedIconst
2940 {
2941 $$ = cat_str(5,mm_strdup("alter"),$2,$3,mm_strdup("set statistics"),$6);
2942 }
2943 | ALTER opt_column ColId SET reloptions
2944 {
2945 $$ = cat_str(5,mm_strdup("alter"),$2,$3,mm_strdup("set"),$5);
2946 }
2947 | ALTER opt_column ColId RESET reloptions
2948 {
2949 $$ = cat_str(5,mm_strdup("alter"),$2,$3,mm_strdup("reset"),$5);
2950 }
2951 | ALTER opt_column ColId SET STORAGE ColId
2952 {
2953 $$ = cat_str(5,mm_strdup("alter"),$2,$3,mm_strdup("set storage"),$6);
2954 }
2955 | ALTER opt_column ColId ADD_P GENERATED generated_when AS IDENTITY_P OptParenthesizedSeqOptList
2956 {
2957 $$ = cat_str(7,mm_strdup("alter"),$2,$3,mm_strdup("add generated"),$6,mm_strdup("as identity"),$9);
2958 }
2959 | ALTER opt_column ColId alter_identity_column_option_list
2960 {
2961 $$ = cat_str(4,mm_strdup("alter"),$2,$3,$4);
2962 }
2963 | ALTER opt_column ColId DROP IDENTITY_P
2964 {
2965 $$ = cat_str(4,mm_strdup("alter"),$2,$3,mm_strdup("drop identity"));
2966 }
2967 | ALTER opt_column ColId DROP IDENTITY_P IF_P EXISTS
2968 {
2969 $$ = cat_str(4,mm_strdup("alter"),$2,$3,mm_strdup("drop identity if exists"));
2970 }
2971 | DROP opt_column IF_P EXISTS ColId opt_drop_behavior
2972 {
2973 $$ = cat_str(5,mm_strdup("drop"),$2,mm_strdup("if exists"),$5,$6);
2974 }
2975 | DROP opt_column ColId opt_drop_behavior
2976 {
2977 $$ = cat_str(4,mm_strdup("drop"),$2,$3,$4);
2978 }
2979 | ALTER opt_column ColId opt_set_data TYPE_P Typename opt_collate_clause alter_using
2980 {
2981 $$ = cat_str(8,mm_strdup("alter"),$2,$3,$4,mm_strdup("type"),$6,$7,$8);
2982 }
2983 | ALTER opt_column ColId alter_generic_options
2984 {
2985 $$ = cat_str(4,mm_strdup("alter"),$2,$3,$4);
2986 }
2987 | ADD_P TableConstraint
2988 {
2989 $$ = cat_str(2,mm_strdup("add"),$2);
2990 }
2991 | ALTER CONSTRAINT name ConstraintAttributeSpec
2992 {
2993 $$ = cat_str(3,mm_strdup("alter constraint"),$3,$4);
2994 }
2995 | VALIDATE CONSTRAINT name
2996 {
2997 $$ = cat_str(2,mm_strdup("validate constraint"),$3);
2998 }
2999 | DROP CONSTRAINT IF_P EXISTS name opt_drop_behavior
3000 {
3001 $$ = cat_str(3,mm_strdup("drop constraint if exists"),$5,$6);
3002 }
3003 | DROP CONSTRAINT name opt_drop_behavior
3004 {
3005 $$ = cat_str(3,mm_strdup("drop constraint"),$3,$4);
3006 }
3007 | SET WITHOUT OIDS
3008 {
3009 $$ = mm_strdup("set without oids");
3010 }
3011 | CLUSTER ON name
3012 {
3013 $$ = cat_str(2,mm_strdup("cluster on"),$3);
3014 }
3015 | SET WITHOUT CLUSTER
3016 {
3017 $$ = mm_strdup("set without cluster");
3018 }
3019 | SET LOGGED
3020 {
3021 $$ = mm_strdup("set logged");
3022 }
3023 | SET UNLOGGED
3024 {
3025 $$ = mm_strdup("set unlogged");
3026 }
3027 | ENABLE_P TRIGGER name
3028 {
3029 $$ = cat_str(2,mm_strdup("enable trigger"),$3);
3030 }
3031 | ENABLE_P ALWAYS TRIGGER name
3032 {
3033 $$ = cat_str(2,mm_strdup("enable always trigger"),$4);
3034 }
3035 | ENABLE_P REPLICA TRIGGER name
3036 {
3037 $$ = cat_str(2,mm_strdup("enable replica trigger"),$4);
3038 }
3039 | ENABLE_P TRIGGER ALL
3040 {
3041 $$ = mm_strdup("enable trigger all");
3042 }
3043 | ENABLE_P TRIGGER USER
3044 {
3045 $$ = mm_strdup("enable trigger user");
3046 }
3047 | DISABLE_P TRIGGER name
3048 {
3049 $$ = cat_str(2,mm_strdup("disable trigger"),$3);
3050 }
3051 | DISABLE_P TRIGGER ALL
3052 {
3053 $$ = mm_strdup("disable trigger all");
3054 }
3055 | DISABLE_P TRIGGER USER
3056 {
3057 $$ = mm_strdup("disable trigger user");
3058 }
3059 | ENABLE_P RULE name
3060 {
3061 $$ = cat_str(2,mm_strdup("enable rule"),$3);
3062 }
3063 | ENABLE_P ALWAYS RULE name
3064 {
3065 $$ = cat_str(2,mm_strdup("enable always rule"),$4);
3066 }
3067 | ENABLE_P REPLICA RULE name
3068 {
3069 $$ = cat_str(2,mm_strdup("enable replica rule"),$4);
3070 }
3071 | DISABLE_P RULE name
3072 {
3073 $$ = cat_str(2,mm_strdup("disable rule"),$3);
3074 }
3075 | INHERIT qualified_name
3076 {
3077 $$ = cat_str(2,mm_strdup("inherit"),$2);
3078 }
3079 | NO INHERIT qualified_name
3080 {
3081 $$ = cat_str(2,mm_strdup("no inherit"),$3);
3082 }
3083 | OF any_name
3084 {
3085 $$ = cat_str(2,mm_strdup("of"),$2);
3086 }
3087 | NOT OF
3088 {
3089 $$ = mm_strdup("not of");
3090 }
3091 | OWNER TO RoleSpec
3092 {
3093 $$ = cat_str(2,mm_strdup("owner to"),$3);
3094 }
3095 | SET TABLESPACE name
3096 {
3097 $$ = cat_str(2,mm_strdup("set tablespace"),$3);
3098 }
3099 | SET reloptions
3100 {
3101 $$ = cat_str(2,mm_strdup("set"),$2);
3102 }
3103 | RESET reloptions
3104 {
3105 $$ = cat_str(2,mm_strdup("reset"),$2);
3106 }
3107 | REPLICA IDENTITY_P replica_identity
3108 {
3109 $$ = cat_str(2,mm_strdup("replica identity"),$3);
3110 }
3111 | ENABLE_P ROW LEVEL SECURITY
3112 {
3113 $$ = mm_strdup("enable row level security");
3114 }
3115 | DISABLE_P ROW LEVEL SECURITY
3116 {
3117 $$ = mm_strdup("disable row level security");
3118 }
3119 | FORCE ROW LEVEL SECURITY
3120 {
3121 $$ = mm_strdup("force row level security");
3122 }
3123 | NO FORCE ROW LEVEL SECURITY
3124 {
3125 $$ = mm_strdup("no force row level security");
3126 }
3127 | alter_generic_options
3128 {
3129 $$ = $1;
3130 }
3131 ;
3132
3133
3134 alter_column_default:
3135 SET DEFAULT a_expr
3136 {
3137 $$ = cat_str(2,mm_strdup("set default"),$3);
3138 }
3139 | DROP DEFAULT
3140 {
3141 $$ = mm_strdup("drop default");
3142 }
3143 ;
3144
3145
3146 opt_drop_behavior:
3147 CASCADE
3148 {
3149 $$ = mm_strdup("cascade");
3150 }
3151 | RESTRICT
3152 {
3153 $$ = mm_strdup("restrict");
3154 }
3155 |
3156 {
3157 $$=EMPTY; }
3158 ;
3159
3160
3161 opt_collate_clause:
3162 COLLATE any_name
3163 {
3164 $$ = cat_str(2,mm_strdup("collate"),$2);
3165 }
3166 |
3167 {
3168 $$=EMPTY; }
3169 ;
3170
3171
3172 alter_using:
3173 USING a_expr
3174 {
3175 $$ = cat_str(2,mm_strdup("using"),$2);
3176 }
3177 |
3178 {
3179 $$=EMPTY; }
3180 ;
3181
3182
3183 replica_identity:
3184 NOTHING
3185 {
3186 $$ = mm_strdup("nothing");
3187 }
3188 | FULL
3189 {
3190 $$ = mm_strdup("full");
3191 }
3192 | DEFAULT
3193 {
3194 $$ = mm_strdup("default");
3195 }
3196 | USING INDEX name
3197 {
3198 $$ = cat_str(2,mm_strdup("using index"),$3);
3199 }
3200 ;
3201
3202
3203 reloptions:
3204 '(' reloption_list ')'
3205 {
3206 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
3207 }
3208 ;
3209
3210
3211 opt_reloptions:
3212 WITH reloptions
3213 {
3214 $$ = cat_str(2,mm_strdup("with"),$2);
3215 }
3216 |
3217 {
3218 $$=EMPTY; }
3219 ;
3220
3221
3222 reloption_list:
3223 reloption_elem
3224 {
3225 $$ = $1;
3226 }
3227 | reloption_list ',' reloption_elem
3228 {
3229 $$ = cat_str(3,$1,mm_strdup(","),$3);
3230 }
3231 ;
3232
3233
3234 reloption_elem:
3235 ColLabel '=' def_arg
3236 {
3237 $$ = cat_str(3,$1,mm_strdup("="),$3);
3238 }
3239 | ColLabel
3240 {
3241 $$ = $1;
3242 }
3243 | ColLabel '.' ColLabel '=' def_arg
3244 {
3245 $$ = cat_str(5,$1,mm_strdup("."),$3,mm_strdup("="),$5);
3246 }
3247 | ColLabel '.' ColLabel
3248 {
3249 $$ = cat_str(3,$1,mm_strdup("."),$3);
3250 }
3251 ;
3252
3253
3254 alter_identity_column_option_list:
3255 alter_identity_column_option
3256 {
3257 $$ = $1;
3258 }
3259 | alter_identity_column_option_list alter_identity_column_option
3260 {
3261 $$ = cat_str(2,$1,$2);
3262 }
3263 ;
3264
3265
3266 alter_identity_column_option:
3267 RESTART
3268 {
3269 $$ = mm_strdup("restart");
3270 }
3271 | RESTART opt_with NumericOnly
3272 {
3273 $$ = cat_str(3,mm_strdup("restart"),$2,$3);
3274 }
3275 | SET SeqOptElem
3276 {
3277 $$ = cat_str(2,mm_strdup("set"),$2);
3278 }
3279 | SET GENERATED generated_when
3280 {
3281 $$ = cat_str(2,mm_strdup("set generated"),$3);
3282 }
3283 ;
3284
3285
3286 PartitionBoundSpec:
3287 FOR VALUES WITH '(' hash_partbound ')'
3288 {
3289 $$ = cat_str(3,mm_strdup("for values with ("),$5,mm_strdup(")"));
3290 }
3291 | FOR VALUES IN_P '(' expr_list ')'
3292 {
3293 $$ = cat_str(3,mm_strdup("for values in ("),$5,mm_strdup(")"));
3294 }
3295 | FOR VALUES FROM '(' expr_list ')' TO '(' expr_list ')'
3296 {
3297 $$ = cat_str(5,mm_strdup("for values from ("),$5,mm_strdup(") to ("),$9,mm_strdup(")"));
3298 }
3299 | DEFAULT
3300 {
3301 $$ = mm_strdup("default");
3302 }
3303 ;
3304
3305
3306 hash_partbound_elem:
3307 NonReservedWord Iconst
3308 {
3309 $$ = cat_str(2,$1,$2);
3310 }
3311 ;
3312
3313
3314 hash_partbound:
3315 hash_partbound_elem
3316 {
3317 $$ = $1;
3318 }
3319 | hash_partbound ',' hash_partbound_elem
3320 {
3321 $$ = cat_str(3,$1,mm_strdup(","),$3);
3322 }
3323 ;
3324
3325
3326 AlterCompositeTypeStmt:
3327 ALTER TYPE_P any_name alter_type_cmds
3328 {
3329 $$ = cat_str(3,mm_strdup("alter type"),$3,$4);
3330 }
3331 ;
3332
3333
3334 alter_type_cmds:
3335 alter_type_cmd
3336 {
3337 $$ = $1;
3338 }
3339 | alter_type_cmds ',' alter_type_cmd
3340 {
3341 $$ = cat_str(3,$1,mm_strdup(","),$3);
3342 }
3343 ;
3344
3345
3346 alter_type_cmd:
3347 ADD_P ATTRIBUTE TableFuncElement opt_drop_behavior
3348 {
3349 $$ = cat_str(3,mm_strdup("add attribute"),$3,$4);
3350 }
3351 | DROP ATTRIBUTE IF_P EXISTS ColId opt_drop_behavior
3352 {
3353 $$ = cat_str(3,mm_strdup("drop attribute if exists"),$5,$6);
3354 }
3355 | DROP ATTRIBUTE ColId opt_drop_behavior
3356 {
3357 $$ = cat_str(3,mm_strdup("drop attribute"),$3,$4);
3358 }
3359 | ALTER ATTRIBUTE ColId opt_set_data TYPE_P Typename opt_collate_clause opt_drop_behavior
3360 {
3361 $$ = cat_str(7,mm_strdup("alter attribute"),$3,$4,mm_strdup("type"),$6,$7,$8);
3362 }
3363 ;
3364
3365
3366 ClosePortalStmt:
3367 CLOSE cursor_name
3368 {
3369 char *cursor_marker = $2[0] == ':' ? mm_strdup("$0") : $2;
3370 $$ = cat2_str(mm_strdup("close"), cursor_marker);
3371 }
3372 | CLOSE ALL
3373 {
3374 $$ = mm_strdup("close all");
3375 }
3376 ;
3377
3378
3379 CopyStmt:
3380 COPY opt_binary qualified_name opt_column_list copy_from opt_program copy_file_name copy_delimiter opt_with copy_options where_clause
3381 {
3382 if (strcmp($6, "from") == 0 &&
3383 (strcmp($7, "stdin") == 0 || strcmp($7, "stdout") == 0))
3384 mmerror(PARSE_ERROR, ET_WARNING, "COPY FROM STDIN is not implemented");
3385
3386 $$ = cat_str(11,mm_strdup("copy"),$2,$3,$4,$5,$6,$7,$8,$9,$10,$11);
3387 }
3388 | COPY '(' PreparableStmt ')' TO opt_program copy_file_name opt_with copy_options
3389 {
3390 $$ = cat_str(7,mm_strdup("copy ("),$3,mm_strdup(") to"),$6,$7,$8,$9);
3391 }
3392 ;
3393
3394
3395 copy_from:
3396 FROM
3397 {
3398 $$ = mm_strdup("from");
3399 }
3400 | TO
3401 {
3402 $$ = mm_strdup("to");
3403 }
3404 ;
3405
3406
3407 opt_program:
3408 PROGRAM
3409 {
3410 $$ = mm_strdup("program");
3411 }
3412 |
3413 {
3414 $$=EMPTY; }
3415 ;
3416
3417
3418 copy_file_name:
3419 ecpg_sconst
3420 {
3421 $$ = $1;
3422 }
3423 | STDIN
3424 {
3425 $$ = mm_strdup("stdin");
3426 }
3427 | STDOUT
3428 {
3429 $$ = mm_strdup("stdout");
3430 }
3431 ;
3432
3433
3434 copy_options:
3435 copy_opt_list
3436 {
3437 $$ = $1;
3438 }
3439 | '(' copy_generic_opt_list ')'
3440 {
3441 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
3442 }
3443 ;
3444
3445
3446 copy_opt_list:
3447 copy_opt_list copy_opt_item
3448 {
3449 $$ = cat_str(2,$1,$2);
3450 }
3451 |
3452 {
3453 $$=EMPTY; }
3454 ;
3455
3456
3457 copy_opt_item:
3458 BINARY
3459 {
3460 $$ = mm_strdup("binary");
3461 }
3462 | FREEZE
3463 {
3464 $$ = mm_strdup("freeze");
3465 }
3466 | DELIMITER opt_as ecpg_sconst
3467 {
3468 $$ = cat_str(3,mm_strdup("delimiter"),$2,$3);
3469 }
3470 | NULL_P opt_as ecpg_sconst
3471 {
3472 $$ = cat_str(3,mm_strdup("null"),$2,$3);
3473 }
3474 | CSV
3475 {
3476 $$ = mm_strdup("csv");
3477 }
3478 | HEADER_P
3479 {
3480 $$ = mm_strdup("header");
3481 }
3482 | QUOTE opt_as ecpg_sconst
3483 {
3484 $$ = cat_str(3,mm_strdup("quote"),$2,$3);
3485 }
3486 | ESCAPE opt_as ecpg_sconst
3487 {
3488 $$ = cat_str(3,mm_strdup("escape"),$2,$3);
3489 }
3490 | FORCE QUOTE columnList
3491 {
3492 $$ = cat_str(2,mm_strdup("force quote"),$3);
3493 }
3494 | FORCE QUOTE '*'
3495 {
3496 $$ = mm_strdup("force quote *");
3497 }
3498 | FORCE NOT NULL_P columnList
3499 {
3500 $$ = cat_str(2,mm_strdup("force not null"),$4);
3501 }
3502 | FORCE NULL_P columnList
3503 {
3504 $$ = cat_str(2,mm_strdup("force null"),$3);
3505 }
3506 | ENCODING ecpg_sconst
3507 {
3508 $$ = cat_str(2,mm_strdup("encoding"),$2);
3509 }
3510 ;
3511
3512
3513 opt_binary:
3514 BINARY
3515 {
3516 $$ = mm_strdup("binary");
3517 }
3518 |
3519 {
3520 $$=EMPTY; }
3521 ;
3522
3523
3524 copy_delimiter:
3525 opt_using DELIMITERS ecpg_sconst
3526 {
3527 $$ = cat_str(3,$1,mm_strdup("delimiters"),$3);
3528 }
3529 |
3530 {
3531 $$=EMPTY; }
3532 ;
3533
3534
3535 opt_using:
3536 USING
3537 {
3538 $$ = mm_strdup("using");
3539 }
3540 |
3541 {
3542 $$=EMPTY; }
3543 ;
3544
3545
3546 copy_generic_opt_list:
3547 copy_generic_opt_elem
3548 {
3549 $$ = $1;
3550 }
3551 | copy_generic_opt_list ',' copy_generic_opt_elem
3552 {
3553 $$ = cat_str(3,$1,mm_strdup(","),$3);
3554 }
3555 ;
3556
3557
3558 copy_generic_opt_elem:
3559 ColLabel copy_generic_opt_arg
3560 {
3561 $$ = cat_str(2,$1,$2);
3562 }
3563 ;
3564
3565
3566 copy_generic_opt_arg:
3567 opt_boolean_or_string
3568 {
3569 $$ = $1;
3570 }
3571 | NumericOnly
3572 {
3573 $$ = $1;
3574 }
3575 | '*'
3576 {
3577 $$ = mm_strdup("*");
3578 }
3579 | '(' copy_generic_opt_arg_list ')'
3580 {
3581 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
3582 }
3583 |
3584 {
3585 $$=EMPTY; }
3586 ;
3587
3588
3589 copy_generic_opt_arg_list:
3590 copy_generic_opt_arg_list_item
3591 {
3592 $$ = $1;
3593 }
3594 | copy_generic_opt_arg_list ',' copy_generic_opt_arg_list_item
3595 {
3596 $$ = cat_str(3,$1,mm_strdup(","),$3);
3597 }
3598 ;
3599
3600
3601 copy_generic_opt_arg_list_item:
3602 opt_boolean_or_string
3603 {
3604 $$ = $1;
3605 }
3606 ;
3607
3608
3609 CreateStmt:
3610 CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')' OptInherit OptPartitionSpec table_access_method_clause OptWith OnCommitOption OptTableSpace
3611 {
3612 $$ = cat_str(13,mm_strdup("create"),$2,mm_strdup("table"),$4,mm_strdup("("),$6,mm_strdup(")"),$8,$9,$10,$11,$12,$13);
3613 }
3614 | CREATE OptTemp TABLE IF_P NOT EXISTS qualified_name '(' OptTableElementList ')' OptInherit OptPartitionSpec table_access_method_clause OptWith OnCommitOption OptTableSpace
3615 {
3616 $$ = 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);
3617 }
3618 | CREATE OptTemp TABLE qualified_name OF any_name OptTypedTableElementList OptPartitionSpec table_access_method_clause OptWith OnCommitOption OptTableSpace
3619 {
3620 $$ = cat_str(12,mm_strdup("create"),$2,mm_strdup("table"),$4,mm_strdup("of"),$6,$7,$8,$9,$10,$11,$12);
3621 }
3622 | CREATE OptTemp TABLE IF_P NOT EXISTS qualified_name OF any_name OptTypedTableElementList OptPartitionSpec table_access_method_clause OptWith OnCommitOption OptTableSpace
3623 {
3624 $$ = cat_str(12,mm_strdup("create"),$2,mm_strdup("table if not exists"),$7,mm_strdup("of"),$9,$10,$11,$12,$13,$14,$15);
3625 }
3626 | CREATE OptTemp TABLE qualified_name PARTITION OF qualified_name OptTypedTableElementList PartitionBoundSpec OptPartitionSpec table_access_method_clause OptWith OnCommitOption OptTableSpace
3627 {
3628 $$ = cat_str(13,mm_strdup("create"),$2,mm_strdup("table"),$4,mm_strdup("partition of"),$7,$8,$9,$10,$11,$12,$13,$14);
3629 }
3630 | CREATE OptTemp TABLE IF_P NOT EXISTS qualified_name PARTITION OF qualified_name OptTypedTableElementList PartitionBoundSpec OptPartitionSpec table_access_method_clause OptWith OnCommitOption OptTableSpace
3631 {
3632 $$ = 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);
3633 }
3634 ;
3635
3636
3637 OptTemp:
3638 TEMPORARY
3639 {
3640 $$ = mm_strdup("temporary");
3641 }
3642 | TEMP
3643 {
3644 $$ = mm_strdup("temp");
3645 }
3646 | LOCAL TEMPORARY
3647 {
3648 $$ = mm_strdup("local temporary");
3649 }
3650 | LOCAL TEMP
3651 {
3652 $$ = mm_strdup("local temp");
3653 }
3654 | GLOBAL TEMPORARY
3655 {
3656 $$ = mm_strdup("global temporary");
3657 }
3658 | GLOBAL TEMP
3659 {
3660 $$ = mm_strdup("global temp");
3661 }
3662 | UNLOGGED
3663 {
3664 $$ = mm_strdup("unlogged");
3665 }
3666 |
3667 {
3668 $$=EMPTY; }
3669 ;
3670
3671
3672 OptTableElementList:
3673 TableElementList
3674 {
3675 $$ = $1;
3676 }
3677 |
3678 {
3679 $$=EMPTY; }
3680 ;
3681
3682
3683 OptTypedTableElementList:
3684 '(' TypedTableElementList ')'
3685 {
3686 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
3687 }
3688 |
3689 {
3690 $$=EMPTY; }
3691 ;
3692
3693
3694 TableElementList:
3695 TableElement
3696 {
3697 $$ = $1;
3698 }
3699 | TableElementList ',' TableElement
3700 {
3701 $$ = cat_str(3,$1,mm_strdup(","),$3);
3702 }
3703 ;
3704
3705
3706 TypedTableElementList:
3707 TypedTableElement
3708 {
3709 $$ = $1;
3710 }
3711 | TypedTableElementList ',' TypedTableElement
3712 {
3713 $$ = cat_str(3,$1,mm_strdup(","),$3);
3714 }
3715 ;
3716
3717
3718 TableElement:
3719 columnDef
3720 {
3721 $$ = $1;
3722 }
3723 | TableLikeClause
3724 {
3725 $$ = $1;
3726 }
3727 | TableConstraint
3728 {
3729 $$ = $1;
3730 }
3731 ;
3732
3733
3734 TypedTableElement:
3735 columnOptions
3736 {
3737 $$ = $1;
3738 }
3739 | TableConstraint
3740 {
3741 $$ = $1;
3742 }
3743 ;
3744
3745
3746 columnDef:
3747 ColId Typename create_generic_options ColQualList
3748 {
3749 $$ = cat_str(4,$1,$2,$3,$4);
3750 }
3751 ;
3752
3753
3754 columnOptions:
3755 ColId ColQualList
3756 {
3757 $$ = cat_str(2,$1,$2);
3758 }
3759 | ColId WITH OPTIONS ColQualList
3760 {
3761 $$ = cat_str(3,$1,mm_strdup("with options"),$4);
3762 }
3763 ;
3764
3765
3766 ColQualList:
3767 ColQualList ColConstraint
3768 {
3769 $$ = cat_str(2,$1,$2);
3770 }
3771 |
3772 {
3773 $$=EMPTY; }
3774 ;
3775
3776
3777 ColConstraint:
3778 CONSTRAINT name ColConstraintElem
3779 {
3780 $$ = cat_str(3,mm_strdup("constraint"),$2,$3);
3781 }
3782 | ColConstraintElem
3783 {
3784 $$ = $1;
3785 }
3786 | ConstraintAttr
3787 {
3788 $$ = $1;
3789 }
3790 | COLLATE any_name
3791 {
3792 $$ = cat_str(2,mm_strdup("collate"),$2);
3793 }
3794 ;
3795
3796
3797 ColConstraintElem:
3798 NOT NULL_P
3799 {
3800 $$ = mm_strdup("not null");
3801 }
3802 | NULL_P
3803 {
3804 $$ = mm_strdup("null");
3805 }
3806 | UNIQUE opt_definition OptConsTableSpace
3807 {
3808 $$ = cat_str(3,mm_strdup("unique"),$2,$3);
3809 }
3810 | PRIMARY KEY opt_definition OptConsTableSpace
3811 {
3812 $$ = cat_str(3,mm_strdup("primary key"),$3,$4);
3813 }
3814 | CHECK '(' a_expr ')' opt_no_inherit
3815 {
3816 $$ = cat_str(4,mm_strdup("check ("),$3,mm_strdup(")"),$5);
3817 }
3818 | DEFAULT b_expr
3819 {
3820 $$ = cat_str(2,mm_strdup("default"),$2);
3821 }
3822 | GENERATED generated_when AS IDENTITY_P OptParenthesizedSeqOptList
3823 {
3824 $$ = cat_str(4,mm_strdup("generated"),$2,mm_strdup("as identity"),$5);
3825 }
3826 | GENERATED generated_when AS '(' a_expr ')' STORED
3827 {
3828 $$ = cat_str(5,mm_strdup("generated"),$2,mm_strdup("as ("),$5,mm_strdup(") stored"));
3829 }
3830 | REFERENCES qualified_name opt_column_list key_match key_actions
3831 {
3832 $$ = cat_str(5,mm_strdup("references"),$2,$3,$4,$5);
3833 }
3834 ;
3835
3836
3837 generated_when:
3838 ALWAYS
3839 {
3840 $$ = mm_strdup("always");
3841 }
3842 | BY DEFAULT
3843 {
3844 $$ = mm_strdup("by default");
3845 }
3846 ;
3847
3848
3849 ConstraintAttr:
3850 DEFERRABLE
3851 {
3852 $$ = mm_strdup("deferrable");
3853 }
3854 | NOT DEFERRABLE
3855 {
3856 $$ = mm_strdup("not deferrable");
3857 }
3858 | INITIALLY DEFERRED
3859 {
3860 $$ = mm_strdup("initially deferred");
3861 }
3862 | INITIALLY IMMEDIATE
3863 {
3864 $$ = mm_strdup("initially immediate");
3865 }
3866 ;
3867
3868
3869 TableLikeClause:
3870 LIKE qualified_name TableLikeOptionList
3871 {
3872 $$ = cat_str(3,mm_strdup("like"),$2,$3);
3873 }
3874 ;
3875
3876
3877 TableLikeOptionList:
3878 TableLikeOptionList INCLUDING TableLikeOption
3879 {
3880 $$ = cat_str(3,$1,mm_strdup("including"),$3);
3881 }
3882 | TableLikeOptionList EXCLUDING TableLikeOption
3883 {
3884 $$ = cat_str(3,$1,mm_strdup("excluding"),$3);
3885 }
3886 |
3887 {
3888 $$=EMPTY; }
3889 ;
3890
3891
3892 TableLikeOption:
3893 COMMENTS
3894 {
3895 $$ = mm_strdup("comments");
3896 }
3897 | CONSTRAINTS
3898 {
3899 $$ = mm_strdup("constraints");
3900 }
3901 | DEFAULTS
3902 {
3903 $$ = mm_strdup("defaults");
3904 }
3905 | IDENTITY_P
3906 {
3907 $$ = mm_strdup("identity");
3908 }
3909 | GENERATED
3910 {
3911 $$ = mm_strdup("generated");
3912 }
3913 | INDEXES
3914 {
3915 $$ = mm_strdup("indexes");
3916 }
3917 | STATISTICS
3918 {
3919 $$ = mm_strdup("statistics");
3920 }
3921 | STORAGE
3922 {
3923 $$ = mm_strdup("storage");
3924 }
3925 | ALL
3926 {
3927 $$ = mm_strdup("all");
3928 }
3929 ;
3930
3931
3932 TableConstraint:
3933 CONSTRAINT name ConstraintElem
3934 {
3935 $$ = cat_str(3,mm_strdup("constraint"),$2,$3);
3936 }
3937 | ConstraintElem
3938 {
3939 $$ = $1;
3940 }
3941 ;
3942
3943
3944 ConstraintElem:
3945 CHECK '(' a_expr ')' ConstraintAttributeSpec
3946 {
3947 $$ = cat_str(4,mm_strdup("check ("),$3,mm_strdup(")"),$5);
3948 }
3949 | UNIQUE '(' columnList ')' opt_c_include opt_definition OptConsTableSpace ConstraintAttributeSpec
3950 {
3951 $$ = cat_str(7,mm_strdup("unique ("),$3,mm_strdup(")"),$5,$6,$7,$8);
3952 }
3953 | UNIQUE ExistingIndex ConstraintAttributeSpec
3954 {
3955 $$ = cat_str(3,mm_strdup("unique"),$2,$3);
3956 }
3957 | PRIMARY KEY '(' columnList ')' opt_c_include opt_definition OptConsTableSpace ConstraintAttributeSpec
3958 {
3959 $$ = cat_str(7,mm_strdup("primary key ("),$4,mm_strdup(")"),$6,$7,$8,$9);
3960 }
3961 | PRIMARY KEY ExistingIndex ConstraintAttributeSpec
3962 {
3963 $$ = cat_str(3,mm_strdup("primary key"),$3,$4);
3964 }
3965 | EXCLUDE access_method_clause '(' ExclusionConstraintList ')' opt_c_include opt_definition OptConsTableSpace ExclusionWhereClause ConstraintAttributeSpec
3966 {
3967 $$ = cat_str(10,mm_strdup("exclude"),$2,mm_strdup("("),$4,mm_strdup(")"),$6,$7,$8,$9,$10);
3968 }
3969 | FOREIGN KEY '(' columnList ')' REFERENCES qualified_name opt_column_list key_match key_actions ConstraintAttributeSpec
3970 {
3971 $$ = cat_str(8,mm_strdup("foreign key ("),$4,mm_strdup(") references"),$7,$8,$9,$10,$11);
3972 }
3973 ;
3974
3975
3976 opt_no_inherit:
3977 NO INHERIT
3978 {
3979 $$ = mm_strdup("no inherit");
3980 }
3981 |
3982 {
3983 $$=EMPTY; }
3984 ;
3985
3986
3987 opt_column_list:
3988 '(' columnList ')'
3989 {
3990 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
3991 }
3992 |
3993 {
3994 $$=EMPTY; }
3995 ;
3996
3997
3998 columnList:
3999 columnElem
4000 {
4001 $$ = $1;
4002 }
4003 | columnList ',' columnElem
4004 {
4005 $$ = cat_str(3,$1,mm_strdup(","),$3);
4006 }
4007 ;
4008
4009
4010 columnElem:
4011 ColId
4012 {
4013 $$ = $1;
4014 }
4015 ;
4016
4017
4018 opt_c_include:
4019 INCLUDE '(' columnList ')'
4020 {
4021 $$ = cat_str(3,mm_strdup("include ("),$3,mm_strdup(")"));
4022 }
4023 |
4024 {
4025 $$=EMPTY; }
4026 ;
4027
4028
4029 key_match:
4030 MATCH FULL
4031 {
4032 $$ = mm_strdup("match full");
4033 }
4034 | MATCH PARTIAL
4035 {
4036 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
4037 $$ = mm_strdup("match partial");
4038 }
4039 | MATCH SIMPLE
4040 {
4041 $$ = mm_strdup("match simple");
4042 }
4043 |
4044 {
4045 $$=EMPTY; }
4046 ;
4047
4048
4049 ExclusionConstraintList:
4050 ExclusionConstraintElem
4051 {
4052 $$ = $1;
4053 }
4054 | ExclusionConstraintList ',' ExclusionConstraintElem
4055 {
4056 $$ = cat_str(3,$1,mm_strdup(","),$3);
4057 }
4058 ;
4059
4060
4061 ExclusionConstraintElem:
4062 index_elem WITH any_operator
4063 {
4064 $$ = cat_str(3,$1,mm_strdup("with"),$3);
4065 }
4066 | index_elem WITH OPERATOR '(' any_operator ')'
4067 {
4068 $$ = cat_str(4,$1,mm_strdup("with operator ("),$5,mm_strdup(")"));
4069 }
4070 ;
4071
4072
4073 ExclusionWhereClause:
4074 WHERE '(' a_expr ')'
4075 {
4076 $$ = cat_str(3,mm_strdup("where ("),$3,mm_strdup(")"));
4077 }
4078 |
4079 {
4080 $$=EMPTY; }
4081 ;
4082
4083
4084 key_actions:
4085 key_update
4086 {
4087 $$ = $1;
4088 }
4089 | key_delete
4090 {
4091 $$ = $1;
4092 }
4093 | key_update key_delete
4094 {
4095 $$ = cat_str(2,$1,$2);
4096 }
4097 | key_delete key_update
4098 {
4099 $$ = cat_str(2,$1,$2);
4100 }
4101 |
4102 {
4103 $$=EMPTY; }
4104 ;
4105
4106
4107 key_update:
4108 ON UPDATE key_action
4109 {
4110 $$ = cat_str(2,mm_strdup("on update"),$3);
4111 }
4112 ;
4113
4114
4115 key_delete:
4116 ON DELETE_P key_action
4117 {
4118 $$ = cat_str(2,mm_strdup("on delete"),$3);
4119 }
4120 ;
4121
4122
4123 key_action:
4124 NO ACTION
4125 {
4126 $$ = mm_strdup("no action");
4127 }
4128 | RESTRICT
4129 {
4130 $$ = mm_strdup("restrict");
4131 }
4132 | CASCADE
4133 {
4134 $$ = mm_strdup("cascade");
4135 }
4136 | SET NULL_P
4137 {
4138 $$ = mm_strdup("set null");
4139 }
4140 | SET DEFAULT
4141 {
4142 $$ = mm_strdup("set default");
4143 }
4144 ;
4145
4146
4147 OptInherit:
4148 INHERITS '(' qualified_name_list ')'
4149 {
4150 $$ = cat_str(3,mm_strdup("inherits ("),$3,mm_strdup(")"));
4151 }
4152 |
4153 {
4154 $$=EMPTY; }
4155 ;
4156
4157
4158 OptPartitionSpec:
4159 PartitionSpec
4160 {
4161 $$ = $1;
4162 }
4163 |
4164 {
4165 $$=EMPTY; }
4166 ;
4167
4168
4169 PartitionSpec:
4170 PARTITION BY ColId '(' part_params ')'
4171 {
4172 $$ = cat_str(5,mm_strdup("partition by"),$3,mm_strdup("("),$5,mm_strdup(")"));
4173 }
4174 ;
4175
4176
4177 part_params:
4178 part_elem
4179 {
4180 $$ = $1;
4181 }
4182 | part_params ',' part_elem
4183 {
4184 $$ = cat_str(3,$1,mm_strdup(","),$3);
4185 }
4186 ;
4187
4188
4189 part_elem:
4190 ColId opt_collate opt_class
4191 {
4192 $$ = cat_str(3,$1,$2,$3);
4193 }
4194 | func_expr_windowless opt_collate opt_class
4195 {
4196 $$ = cat_str(3,$1,$2,$3);
4197 }
4198 | '(' a_expr ')' opt_collate opt_class
4199 {
4200 $$ = cat_str(5,mm_strdup("("),$2,mm_strdup(")"),$4,$5);
4201 }
4202 ;
4203
4204
4205 table_access_method_clause:
4206 USING access_method
4207 {
4208 $$ = cat_str(2,mm_strdup("using"),$2);
4209 }
4210 |
4211 {
4212 $$=EMPTY; }
4213 ;
4214
4215
4216 OptWith:
4217 WITH reloptions
4218 {
4219 $$ = cat_str(2,mm_strdup("with"),$2);
4220 }
4221 | WITHOUT OIDS
4222 {
4223 $$ = mm_strdup("without oids");
4224 }
4225 |
4226 {
4227 $$=EMPTY; }
4228 ;
4229
4230
4231 OnCommitOption:
4232 ON COMMIT DROP
4233 {
4234 $$ = mm_strdup("on commit drop");
4235 }
4236 | ON COMMIT DELETE_P ROWS
4237 {
4238 $$ = mm_strdup("on commit delete rows");
4239 }
4240 | ON COMMIT PRESERVE ROWS
4241 {
4242 $$ = mm_strdup("on commit preserve rows");
4243 }
4244 |
4245 {
4246 $$=EMPTY; }
4247 ;
4248
4249
4250 OptTableSpace:
4251 TABLESPACE name
4252 {
4253 $$ = cat_str(2,mm_strdup("tablespace"),$2);
4254 }
4255 |
4256 {
4257 $$=EMPTY; }
4258 ;
4259
4260
4261 OptConsTableSpace:
4262 USING INDEX TABLESPACE name
4263 {
4264 $$ = cat_str(2,mm_strdup("using index tablespace"),$4);
4265 }
4266 |
4267 {
4268 $$=EMPTY; }
4269 ;
4270
4271
4272 ExistingIndex:
4273 USING INDEX index_name
4274 {
4275 $$ = cat_str(2,mm_strdup("using index"),$3);
4276 }
4277 ;
4278
4279
4280 CreateStatsStmt:
4281 CREATE STATISTICS any_name opt_name_list ON expr_list FROM from_list
4282 {
4283 $$ = cat_str(7,mm_strdup("create statistics"),$3,$4,mm_strdup("on"),$6,mm_strdup("from"),$8);
4284 }
4285 | CREATE STATISTICS IF_P NOT EXISTS any_name opt_name_list ON expr_list FROM from_list
4286 {
4287 $$ = cat_str(7,mm_strdup("create statistics if not exists"),$6,$7,mm_strdup("on"),$9,mm_strdup("from"),$11);
4288 }
4289 ;
4290
4291
4292 AlterStatsStmt:
4293 ALTER STATISTICS any_name SET STATISTICS SignedIconst
4294 {
4295 $$ = cat_str(4,mm_strdup("alter statistics"),$3,mm_strdup("set statistics"),$6);
4296 }
4297 | ALTER STATISTICS IF_P EXISTS any_name SET STATISTICS SignedIconst
4298 {
4299 $$ = cat_str(4,mm_strdup("alter statistics if exists"),$5,mm_strdup("set statistics"),$8);
4300 }
4301 ;
4302
4303
4304 create_as_target:
4305 qualified_name opt_column_list table_access_method_clause OptWith OnCommitOption OptTableSpace
4306 {
4307 $$ = cat_str(6,$1,$2,$3,$4,$5,$6);
4308 }
4309 ;
4310
4311
4312 opt_with_data:
4313 WITH DATA_P
4314 {
4315 $$ = mm_strdup("with data");
4316 }
4317 | WITH NO DATA_P
4318 {
4319 $$ = mm_strdup("with no data");
4320 }
4321 |
4322 {
4323 $$=EMPTY; }
4324 ;
4325
4326
4327 CreateMatViewStmt:
4328 CREATE OptNoLog MATERIALIZED VIEW create_mv_target AS SelectStmt opt_with_data
4329 {
4330 $$ = cat_str(7,mm_strdup("create"),$2,mm_strdup("materialized view"),$5,mm_strdup("as"),$7,$8);
4331 }
4332 | CREATE OptNoLog MATERIALIZED VIEW IF_P NOT EXISTS create_mv_target AS SelectStmt opt_with_data
4333 {
4334 $$ = cat_str(7,mm_strdup("create"),$2,mm_strdup("materialized view if not exists"),$8,mm_strdup("as"),$10,$11);
4335 }
4336 ;
4337
4338
4339 create_mv_target:
4340 qualified_name opt_column_list table_access_method_clause opt_reloptions OptTableSpace
4341 {
4342 $$ = cat_str(5,$1,$2,$3,$4,$5);
4343 }
4344 ;
4345
4346
4347 OptNoLog:
4348 UNLOGGED
4349 {
4350 $$ = mm_strdup("unlogged");
4351 }
4352 |
4353 {
4354 $$=EMPTY; }
4355 ;
4356
4357
4358 RefreshMatViewStmt:
4359 REFRESH MATERIALIZED VIEW opt_concurrently qualified_name opt_with_data
4360 {
4361 $$ = cat_str(4,mm_strdup("refresh materialized view"),$4,$5,$6);
4362 }
4363 ;
4364
4365
4366 CreateSeqStmt:
4367 CREATE OptTemp SEQUENCE qualified_name OptSeqOptList
4368 {
4369 $$ = cat_str(5,mm_strdup("create"),$2,mm_strdup("sequence"),$4,$5);
4370 }
4371 | CREATE OptTemp SEQUENCE IF_P NOT EXISTS qualified_name OptSeqOptList
4372 {
4373 $$ = cat_str(5,mm_strdup("create"),$2,mm_strdup("sequence if not exists"),$7,$8);
4374 }
4375 ;
4376
4377
4378 AlterSeqStmt:
4379 ALTER SEQUENCE qualified_name SeqOptList
4380 {
4381 $$ = cat_str(3,mm_strdup("alter sequence"),$3,$4);
4382 }
4383 | ALTER SEQUENCE IF_P EXISTS qualified_name SeqOptList
4384 {
4385 $$ = cat_str(3,mm_strdup("alter sequence if exists"),$5,$6);
4386 }
4387 ;
4388
4389
4390 OptSeqOptList:
4391 SeqOptList
4392 {
4393 $$ = $1;
4394 }
4395 |
4396 {
4397 $$=EMPTY; }
4398 ;
4399
4400
4401 OptParenthesizedSeqOptList:
4402 '(' SeqOptList ')'
4403 {
4404 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
4405 }
4406 |
4407 {
4408 $$=EMPTY; }
4409 ;
4410
4411
4412 SeqOptList:
4413 SeqOptElem
4414 {
4415 $$ = $1;
4416 }
4417 | SeqOptList SeqOptElem
4418 {
4419 $$ = cat_str(2,$1,$2);
4420 }
4421 ;
4422
4423
4424 SeqOptElem:
4425 AS SimpleTypename
4426 {
4427 $$ = cat_str(2,mm_strdup("as"),$2);
4428 }
4429 | CACHE NumericOnly
4430 {
4431 $$ = cat_str(2,mm_strdup("cache"),$2);
4432 }
4433 | CYCLE
4434 {
4435 $$ = mm_strdup("cycle");
4436 }
4437 | NO CYCLE
4438 {
4439 $$ = mm_strdup("no cycle");
4440 }
4441 | INCREMENT opt_by NumericOnly
4442 {
4443 $$ = cat_str(3,mm_strdup("increment"),$2,$3);
4444 }
4445 | MAXVALUE NumericOnly
4446 {
4447 $$ = cat_str(2,mm_strdup("maxvalue"),$2);
4448 }
4449 | MINVALUE NumericOnly
4450 {
4451 $$ = cat_str(2,mm_strdup("minvalue"),$2);
4452 }
4453 | NO MAXVALUE
4454 {
4455 $$ = mm_strdup("no maxvalue");
4456 }
4457 | NO MINVALUE
4458 {
4459 $$ = mm_strdup("no minvalue");
4460 }
4461 | OWNED BY any_name
4462 {
4463 $$ = cat_str(2,mm_strdup("owned by"),$3);
4464 }
4465 | SEQUENCE NAME_P any_name
4466 {
4467 $$ = cat_str(2,mm_strdup("sequence name"),$3);
4468 }
4469 | START opt_with NumericOnly
4470 {
4471 $$ = cat_str(3,mm_strdup("start"),$2,$3);
4472 }
4473 | RESTART
4474 {
4475 $$ = mm_strdup("restart");
4476 }
4477 | RESTART opt_with NumericOnly
4478 {
4479 $$ = cat_str(3,mm_strdup("restart"),$2,$3);
4480 }
4481 ;
4482
4483
4484 opt_by:
4485 BY
4486 {
4487 $$ = mm_strdup("by");
4488 }
4489 |
4490 {
4491 $$=EMPTY; }
4492 ;
4493
4494
4495 NumericOnly:
4496 ecpg_fconst
4497 {
4498 $$ = $1;
4499 }
4500 | '+' ecpg_fconst
4501 {
4502 $$ = cat_str(2,mm_strdup("+"),$2);
4503 }
4504 | '-' ecpg_fconst
4505 {
4506 $$ = cat_str(2,mm_strdup("-"),$2);
4507 }
4508 | SignedIconst
4509 {
4510 $$ = $1;
4511 }
4512 ;
4513
4514
4515 NumericOnly_list:
4516 NumericOnly
4517 {
4518 $$ = $1;
4519 }
4520 | NumericOnly_list ',' NumericOnly
4521 {
4522 $$ = cat_str(3,$1,mm_strdup(","),$3);
4523 }
4524 ;
4525
4526
4527 CreatePLangStmt:
4528 CREATE opt_or_replace opt_trusted opt_procedural LANGUAGE NonReservedWord_or_Sconst
4529 {
4530 $$ = cat_str(6,mm_strdup("create"),$2,$3,$4,mm_strdup("language"),$6);
4531 }
4532 | CREATE opt_or_replace opt_trusted opt_procedural LANGUAGE NonReservedWord_or_Sconst HANDLER handler_name opt_inline_handler opt_validator
4533 {
4534 $$ = cat_str(10,mm_strdup("create"),$2,$3,$4,mm_strdup("language"),$6,mm_strdup("handler"),$8,$9,$10);
4535 }
4536 ;
4537
4538
4539 opt_trusted:
4540 TRUSTED
4541 {
4542 $$ = mm_strdup("trusted");
4543 }
4544 |
4545 {
4546 $$=EMPTY; }
4547 ;
4548
4549
4550 handler_name:
4551 name
4552 {
4553 $$ = $1;
4554 }
4555 | name attrs
4556 {
4557 $$ = cat_str(2,$1,$2);
4558 }
4559 ;
4560
4561
4562 opt_inline_handler:
4563 INLINE_P handler_name
4564 {
4565 $$ = cat_str(2,mm_strdup("inline"),$2);
4566 }
4567 |
4568 {
4569 $$=EMPTY; }
4570 ;
4571
4572
4573 validator_clause:
4574 VALIDATOR handler_name
4575 {
4576 $$ = cat_str(2,mm_strdup("validator"),$2);
4577 }
4578 | NO VALIDATOR
4579 {
4580 $$ = mm_strdup("no validator");
4581 }
4582 ;
4583
4584
4585 opt_validator:
4586 validator_clause
4587 {
4588 $$ = $1;
4589 }
4590 |
4591 {
4592 $$=EMPTY; }
4593 ;
4594
4595
4596 DropPLangStmt:
4597 DROP opt_procedural LANGUAGE NonReservedWord_or_Sconst opt_drop_behavior
4598 {
4599 $$ = cat_str(5,mm_strdup("drop"),$2,mm_strdup("language"),$4,$5);
4600 }
4601 | DROP opt_procedural LANGUAGE IF_P EXISTS NonReservedWord_or_Sconst opt_drop_behavior
4602 {
4603 $$ = cat_str(5,mm_strdup("drop"),$2,mm_strdup("language if exists"),$6,$7);
4604 }
4605 ;
4606
4607
4608 opt_procedural:
4609 PROCEDURAL
4610 {
4611 $$ = mm_strdup("procedural");
4612 }
4613 |
4614 {
4615 $$=EMPTY; }
4616 ;
4617
4618
4619 CreateTableSpaceStmt:
4620 CREATE TABLESPACE name OptTableSpaceOwner LOCATION ecpg_sconst opt_reloptions
4621 {
4622 $$ = cat_str(6,mm_strdup("create tablespace"),$3,$4,mm_strdup("location"),$6,$7);
4623 }
4624 ;
4625
4626
4627 OptTableSpaceOwner:
4628 OWNER RoleSpec
4629 {
4630 $$ = cat_str(2,mm_strdup("owner"),$2);
4631 }
4632 |
4633 {
4634 $$=EMPTY; }
4635 ;
4636
4637
4638 DropTableSpaceStmt:
4639 DROP TABLESPACE name
4640 {
4641 $$ = cat_str(2,mm_strdup("drop tablespace"),$3);
4642 }
4643 | DROP TABLESPACE IF_P EXISTS name
4644 {
4645 $$ = cat_str(2,mm_strdup("drop tablespace if exists"),$5);
4646 }
4647 ;
4648
4649
4650 CreateExtensionStmt:
4651 CREATE EXTENSION name opt_with create_extension_opt_list
4652 {
4653 $$ = cat_str(4,mm_strdup("create extension"),$3,$4,$5);
4654 }
4655 | CREATE EXTENSION IF_P NOT EXISTS name opt_with create_extension_opt_list
4656 {
4657 $$ = cat_str(4,mm_strdup("create extension if not exists"),$6,$7,$8);
4658 }
4659 ;
4660
4661
4662 create_extension_opt_list:
4663 create_extension_opt_list create_extension_opt_item
4664 {
4665 $$ = cat_str(2,$1,$2);
4666 }
4667 |
4668 {
4669 $$=EMPTY; }
4670 ;
4671
4672
4673 create_extension_opt_item:
4674 SCHEMA name
4675 {
4676 $$ = cat_str(2,mm_strdup("schema"),$2);
4677 }
4678 | VERSION_P NonReservedWord_or_Sconst
4679 {
4680 $$ = cat_str(2,mm_strdup("version"),$2);
4681 }
4682 | FROM NonReservedWord_or_Sconst
4683 {
4684 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
4685 $$ = cat_str(2,mm_strdup("from"),$2);
4686 }
4687 | CASCADE
4688 {
4689 $$ = mm_strdup("cascade");
4690 }
4691 ;
4692
4693
4694 AlterExtensionStmt:
4695 ALTER EXTENSION name UPDATE alter_extension_opt_list
4696 {
4697 $$ = cat_str(4,mm_strdup("alter extension"),$3,mm_strdup("update"),$5);
4698 }
4699 ;
4700
4701
4702 alter_extension_opt_list:
4703 alter_extension_opt_list alter_extension_opt_item
4704 {
4705 $$ = cat_str(2,$1,$2);
4706 }
4707 |
4708 {
4709 $$=EMPTY; }
4710 ;
4711
4712
4713 alter_extension_opt_item:
4714 TO NonReservedWord_or_Sconst
4715 {
4716 $$ = cat_str(2,mm_strdup("to"),$2);
4717 }
4718 ;
4719
4720
4721 AlterExtensionContentsStmt:
4722 ALTER EXTENSION name add_drop ACCESS METHOD name
4723 {
4724 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("access method"),$7);
4725 }
4726 | ALTER EXTENSION name add_drop AGGREGATE aggregate_with_argtypes
4727 {
4728 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("aggregate"),$6);
4729 }
4730 | ALTER EXTENSION name add_drop CAST '(' Typename AS Typename ')'
4731 {
4732 $$ = cat_str(8,mm_strdup("alter extension"),$3,$4,mm_strdup("cast ("),$7,mm_strdup("as"),$9,mm_strdup(")"));
4733 }
4734 | ALTER EXTENSION name add_drop COLLATION any_name
4735 {
4736 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("collation"),$6);
4737 }
4738 | ALTER EXTENSION name add_drop CONVERSION_P any_name
4739 {
4740 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("conversion"),$6);
4741 }
4742 | ALTER EXTENSION name add_drop DOMAIN_P Typename
4743 {
4744 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("domain"),$6);
4745 }
4746 | ALTER EXTENSION name add_drop FUNCTION function_with_argtypes
4747 {
4748 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("function"),$6);
4749 }
4750 | ALTER EXTENSION name add_drop opt_procedural LANGUAGE name
4751 {
4752 $$ = cat_str(6,mm_strdup("alter extension"),$3,$4,$5,mm_strdup("language"),$7);
4753 }
4754 | ALTER EXTENSION name add_drop OPERATOR operator_with_argtypes
4755 {
4756 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("operator"),$6);
4757 }
4758 | ALTER EXTENSION name add_drop OPERATOR CLASS any_name USING access_method
4759 {
4760 $$ = cat_str(7,mm_strdup("alter extension"),$3,$4,mm_strdup("operator class"),$7,mm_strdup("using"),$9);
4761 }
4762 | ALTER EXTENSION name add_drop OPERATOR FAMILY any_name USING access_method
4763 {
4764 $$ = cat_str(7,mm_strdup("alter extension"),$3,$4,mm_strdup("operator family"),$7,mm_strdup("using"),$9);
4765 }
4766 | ALTER EXTENSION name add_drop PROCEDURE function_with_argtypes
4767 {
4768 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("procedure"),$6);
4769 }
4770 | ALTER EXTENSION name add_drop ROUTINE function_with_argtypes
4771 {
4772 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("routine"),$6);
4773 }
4774 | ALTER EXTENSION name add_drop SCHEMA name
4775 {
4776 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("schema"),$6);
4777 }
4778 | ALTER EXTENSION name add_drop EVENT TRIGGER name
4779 {
4780 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("event trigger"),$7);
4781 }
4782 | ALTER EXTENSION name add_drop TABLE any_name
4783 {
4784 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("table"),$6);
4785 }
4786 | ALTER EXTENSION name add_drop TEXT_P SEARCH PARSER any_name
4787 {
4788 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("text search parser"),$8);
4789 }
4790 | ALTER EXTENSION name add_drop TEXT_P SEARCH DICTIONARY any_name
4791 {
4792 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("text search dictionary"),$8);
4793 }
4794 | ALTER EXTENSION name add_drop TEXT_P SEARCH TEMPLATE any_name
4795 {
4796 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("text search template"),$8);
4797 }
4798 | ALTER EXTENSION name add_drop TEXT_P SEARCH CONFIGURATION any_name
4799 {
4800 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("text search configuration"),$8);
4801 }
4802 | ALTER EXTENSION name add_drop SEQUENCE any_name
4803 {
4804 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("sequence"),$6);
4805 }
4806 | ALTER EXTENSION name add_drop VIEW any_name
4807 {
4808 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("view"),$6);
4809 }
4810 | ALTER EXTENSION name add_drop MATERIALIZED VIEW any_name
4811 {
4812 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("materialized view"),$7);
4813 }
4814 | ALTER EXTENSION name add_drop FOREIGN TABLE any_name
4815 {
4816 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("foreign table"),$7);
4817 }
4818 | ALTER EXTENSION name add_drop FOREIGN DATA_P WRAPPER name
4819 {
4820 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("foreign data wrapper"),$8);
4821 }
4822 | ALTER EXTENSION name add_drop SERVER name
4823 {
4824 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("server"),$6);
4825 }
4826 | ALTER EXTENSION name add_drop TRANSFORM FOR Typename LANGUAGE name
4827 {
4828 $$ = cat_str(7,mm_strdup("alter extension"),$3,$4,mm_strdup("transform for"),$7,mm_strdup("language"),$9);
4829 }
4830 | ALTER EXTENSION name add_drop TYPE_P Typename
4831 {
4832 $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("type"),$6);
4833 }
4834 ;
4835
4836
4837 CreateFdwStmt:
4838 CREATE FOREIGN DATA_P WRAPPER name opt_fdw_options create_generic_options
4839 {
4840 $$ = cat_str(4,mm_strdup("create foreign data wrapper"),$5,$6,$7);
4841 }
4842 ;
4843
4844
4845 fdw_option:
4846 HANDLER handler_name
4847 {
4848 $$ = cat_str(2,mm_strdup("handler"),$2);
4849 }
4850 | NO HANDLER
4851 {
4852 $$ = mm_strdup("no handler");
4853 }
4854 | VALIDATOR handler_name
4855 {
4856 $$ = cat_str(2,mm_strdup("validator"),$2);
4857 }
4858 | NO VALIDATOR
4859 {
4860 $$ = mm_strdup("no validator");
4861 }
4862 ;
4863
4864
4865 fdw_options:
4866 fdw_option
4867 {
4868 $$ = $1;
4869 }
4870 | fdw_options fdw_option
4871 {
4872 $$ = cat_str(2,$1,$2);
4873 }
4874 ;
4875
4876
4877 opt_fdw_options:
4878 fdw_options
4879 {
4880 $$ = $1;
4881 }
4882 |
4883 {
4884 $$=EMPTY; }
4885 ;
4886
4887
4888 AlterFdwStmt:
4889 ALTER FOREIGN DATA_P WRAPPER name opt_fdw_options alter_generic_options
4890 {
4891 $$ = cat_str(4,mm_strdup("alter foreign data wrapper"),$5,$6,$7);
4892 }
4893 | ALTER FOREIGN DATA_P WRAPPER name fdw_options
4894 {
4895 $$ = cat_str(3,mm_strdup("alter foreign data wrapper"),$5,$6);
4896 }
4897 ;
4898
4899
4900 create_generic_options:
4901 OPTIONS '(' generic_option_list ')'
4902 {
4903 $$ = cat_str(3,mm_strdup("options ("),$3,mm_strdup(")"));
4904 }
4905 |
4906 {
4907 $$=EMPTY; }
4908 ;
4909
4910
4911 generic_option_list:
4912 generic_option_elem
4913 {
4914 $$ = $1;
4915 }
4916 | generic_option_list ',' generic_option_elem
4917 {
4918 $$ = cat_str(3,$1,mm_strdup(","),$3);
4919 }
4920 ;
4921
4922
4923 alter_generic_options:
4924 OPTIONS '(' alter_generic_option_list ')'
4925 {
4926 $$ = cat_str(3,mm_strdup("options ("),$3,mm_strdup(")"));
4927 }
4928 ;
4929
4930
4931 alter_generic_option_list:
4932 alter_generic_option_elem
4933 {
4934 $$ = $1;
4935 }
4936 | alter_generic_option_list ',' alter_generic_option_elem
4937 {
4938 $$ = cat_str(3,$1,mm_strdup(","),$3);
4939 }
4940 ;
4941
4942
4943 alter_generic_option_elem:
4944 generic_option_elem
4945 {
4946 $$ = $1;
4947 }
4948 | SET generic_option_elem
4949 {
4950 $$ = cat_str(2,mm_strdup("set"),$2);
4951 }
4952 | ADD_P generic_option_elem
4953 {
4954 $$ = cat_str(2,mm_strdup("add"),$2);
4955 }
4956 | DROP generic_option_name
4957 {
4958 $$ = cat_str(2,mm_strdup("drop"),$2);
4959 }
4960 ;
4961
4962
4963 generic_option_elem:
4964 generic_option_name generic_option_arg
4965 {
4966 $$ = cat_str(2,$1,$2);
4967 }
4968 ;
4969
4970
4971 generic_option_name:
4972 ColLabel
4973 {
4974 $$ = $1;
4975 }
4976 ;
4977
4978
4979 generic_option_arg:
4980 ecpg_sconst
4981 {
4982 $$ = $1;
4983 }
4984 ;
4985
4986
4987 CreateForeignServerStmt:
4988 CREATE SERVER name opt_type opt_foreign_server_version FOREIGN DATA_P WRAPPER name create_generic_options
4989 {
4990 $$ = cat_str(7,mm_strdup("create server"),$3,$4,$5,mm_strdup("foreign data wrapper"),$9,$10);
4991 }
4992 | CREATE SERVER IF_P NOT EXISTS name opt_type opt_foreign_server_version FOREIGN DATA_P WRAPPER name create_generic_options
4993 {
4994 $$ = cat_str(7,mm_strdup("create server if not exists"),$6,$7,$8,mm_strdup("foreign data wrapper"),$12,$13);
4995 }
4996 ;
4997
4998
4999 opt_type:
5000 TYPE_P ecpg_sconst
5001 {
5002 $$ = cat_str(2,mm_strdup("type"),$2);
5003 }
5004 |
5005 {
5006 $$=EMPTY; }
5007 ;
5008
5009
5010 foreign_server_version:
5011 VERSION_P ecpg_sconst
5012 {
5013 $$ = cat_str(2,mm_strdup("version"),$2);
5014 }
5015 | VERSION_P NULL_P
5016 {
5017 $$ = mm_strdup("version null");
5018 }
5019 ;
5020
5021
5022 opt_foreign_server_version:
5023 foreign_server_version
5024 {
5025 $$ = $1;
5026 }
5027 |
5028 {
5029 $$=EMPTY; }
5030 ;
5031
5032
5033 AlterForeignServerStmt:
5034 ALTER SERVER name foreign_server_version alter_generic_options
5035 {
5036 $$ = cat_str(4,mm_strdup("alter server"),$3,$4,$5);
5037 }
5038 | ALTER SERVER name foreign_server_version
5039 {
5040 $$ = cat_str(3,mm_strdup("alter server"),$3,$4);
5041 }
5042 | ALTER SERVER name alter_generic_options
5043 {
5044 $$ = cat_str(3,mm_strdup("alter server"),$3,$4);
5045 }
5046 ;
5047
5048
5049 CreateForeignTableStmt:
5050 CREATE FOREIGN TABLE qualified_name '(' OptTableElementList ')' OptInherit SERVER name create_generic_options
5051 {
5052 $$ = cat_str(9,mm_strdup("create foreign table"),$4,mm_strdup("("),$6,mm_strdup(")"),$8,mm_strdup("server"),$10,$11);
5053 }
5054 | CREATE FOREIGN TABLE IF_P NOT EXISTS qualified_name '(' OptTableElementList ')' OptInherit SERVER name create_generic_options
5055 {
5056 $$ = cat_str(9,mm_strdup("create foreign table if not exists"),$7,mm_strdup("("),$9,mm_strdup(")"),$11,mm_strdup("server"),$13,$14);
5057 }
5058 | CREATE FOREIGN TABLE qualified_name PARTITION OF qualified_name OptTypedTableElementList PartitionBoundSpec SERVER name create_generic_options
5059 {
5060 $$ = cat_str(9,mm_strdup("create foreign table"),$4,mm_strdup("partition of"),$7,$8,$9,mm_strdup("server"),$11,$12);
5061 }
5062 | CREATE FOREIGN TABLE IF_P NOT EXISTS qualified_name PARTITION OF qualified_name OptTypedTableElementList PartitionBoundSpec SERVER name create_generic_options
5063 {
5064 $$ = cat_str(9,mm_strdup("create foreign table if not exists"),$7,mm_strdup("partition of"),$10,$11,$12,mm_strdup("server"),$14,$15);
5065 }
5066 ;
5067
5068
5069 AlterForeignTableStmt:
5070 ALTER FOREIGN TABLE relation_expr alter_table_cmds
5071 {
5072 $$ = cat_str(3,mm_strdup("alter foreign table"),$4,$5);
5073 }
5074 | ALTER FOREIGN TABLE IF_P EXISTS relation_expr alter_table_cmds
5075 {
5076 $$ = cat_str(3,mm_strdup("alter foreign table if exists"),$6,$7);
5077 }
5078 ;
5079
5080
5081 ImportForeignSchemaStmt:
5082 IMPORT_P FOREIGN SCHEMA name import_qualification FROM SERVER name INTO name create_generic_options
5083 {
5084 $$ = cat_str(8,mm_strdup("import foreign schema"),$4,$5,mm_strdup("from server"),$8,mm_strdup("into"),$10,$11);
5085 }
5086 ;
5087
5088
5089 import_qualification_type:
5090 LIMIT TO
5091 {
5092 $$ = mm_strdup("limit to");
5093 }
5094 | EXCEPT
5095 {
5096 $$ = mm_strdup("except");
5097 }
5098 ;
5099
5100
5101 import_qualification:
5102 import_qualification_type '(' relation_expr_list ')'
5103 {
5104 $$ = cat_str(4,$1,mm_strdup("("),$3,mm_strdup(")"));
5105 }
5106 |
5107 {
5108 $$=EMPTY; }
5109 ;
5110
5111
5112 CreateUserMappingStmt:
5113 CREATE USER MAPPING FOR auth_ident SERVER name create_generic_options
5114 {
5115 $$ = cat_str(5,mm_strdup("create user mapping for"),$5,mm_strdup("server"),$7,$8);
5116 }
5117 | CREATE USER MAPPING IF_P NOT EXISTS FOR auth_ident SERVER name create_generic_options
5118 {
5119 $$ = cat_str(5,mm_strdup("create user mapping if not exists for"),$8,mm_strdup("server"),$10,$11);
5120 }
5121 ;
5122
5123
5124 auth_ident:
5125 RoleSpec
5126 {
5127 $$ = $1;
5128 }
5129 | USER
5130 {
5131 $$ = mm_strdup("user");
5132 }
5133 ;
5134
5135
5136 DropUserMappingStmt:
5137 DROP USER MAPPING FOR auth_ident SERVER name
5138 {
5139 $$ = cat_str(4,mm_strdup("drop user mapping for"),$5,mm_strdup("server"),$7);
5140 }
5141 | DROP USER MAPPING IF_P EXISTS FOR auth_ident SERVER name
5142 {
5143 $$ = cat_str(4,mm_strdup("drop user mapping if exists for"),$7,mm_strdup("server"),$9);
5144 }
5145 ;
5146
5147
5148 AlterUserMappingStmt:
5149 ALTER USER MAPPING FOR auth_ident SERVER name alter_generic_options
5150 {
5151 $$ = cat_str(5,mm_strdup("alter user mapping for"),$5,mm_strdup("server"),$7,$8);
5152 }
5153 ;
5154
5155
5156 CreatePolicyStmt:
5157 CREATE POLICY name ON qualified_name RowSecurityDefaultPermissive RowSecurityDefaultForCmd RowSecurityDefaultToRole RowSecurityOptionalExpr RowSecurityOptionalWithCheck
5158 {
5159 $$ = cat_str(9,mm_strdup("create policy"),$3,mm_strdup("on"),$5,$6,$7,$8,$9,$10);
5160 }
5161 ;
5162
5163
5164 AlterPolicyStmt:
5165 ALTER POLICY name ON qualified_name RowSecurityOptionalToRole RowSecurityOptionalExpr RowSecurityOptionalWithCheck
5166 {
5167 $$ = cat_str(7,mm_strdup("alter policy"),$3,mm_strdup("on"),$5,$6,$7,$8);
5168 }
5169 ;
5170
5171
5172 RowSecurityOptionalExpr:
5173 USING '(' a_expr ')'
5174 {
5175 $$ = cat_str(3,mm_strdup("using ("),$3,mm_strdup(")"));
5176 }
5177 |
5178 {
5179 $$=EMPTY; }
5180 ;
5181
5182
5183 RowSecurityOptionalWithCheck:
5184 WITH CHECK '(' a_expr ')'
5185 {
5186 $$ = cat_str(3,mm_strdup("with check ("),$4,mm_strdup(")"));
5187 }
5188 |
5189 {
5190 $$=EMPTY; }
5191 ;
5192
5193
5194 RowSecurityDefaultToRole:
5195 TO role_list
5196 {
5197 $$ = cat_str(2,mm_strdup("to"),$2);
5198 }
5199 |
5200 {
5201 $$=EMPTY; }
5202 ;
5203
5204
5205 RowSecurityOptionalToRole:
5206 TO role_list
5207 {
5208 $$ = cat_str(2,mm_strdup("to"),$2);
5209 }
5210 |
5211 {
5212 $$=EMPTY; }
5213 ;
5214
5215
5216 RowSecurityDefaultPermissive:
5217 AS ecpg_ident
5218 {
5219 $$ = cat_str(2,mm_strdup("as"),$2);
5220 }
5221 |
5222 {
5223 $$=EMPTY; }
5224 ;
5225
5226
5227 RowSecurityDefaultForCmd:
5228 FOR row_security_cmd
5229 {
5230 $$ = cat_str(2,mm_strdup("for"),$2);
5231 }
5232 |
5233 {
5234 $$=EMPTY; }
5235 ;
5236
5237
5238 row_security_cmd:
5239 ALL
5240 {
5241 $$ = mm_strdup("all");
5242 }
5243 | SELECT
5244 {
5245 $$ = mm_strdup("select");
5246 }
5247 | INSERT
5248 {
5249 $$ = mm_strdup("insert");
5250 }
5251 | UPDATE
5252 {
5253 $$ = mm_strdup("update");
5254 }
5255 | DELETE_P
5256 {
5257 $$ = mm_strdup("delete");
5258 }
5259 ;
5260
5261
5262 CreateAmStmt:
5263 CREATE ACCESS METHOD name TYPE_P am_type HANDLER handler_name
5264 {
5265 $$ = cat_str(6,mm_strdup("create access method"),$4,mm_strdup("type"),$6,mm_strdup("handler"),$8);
5266 }
5267 ;
5268
5269
5270 am_type:
5271 INDEX
5272 {
5273 $$ = mm_strdup("index");
5274 }
5275 | TABLE
5276 {
5277 $$ = mm_strdup("table");
5278 }
5279 ;
5280
5281
5282 CreateTrigStmt:
5283 CREATE TRIGGER name TriggerActionTime TriggerEvents ON qualified_name TriggerReferencing TriggerForSpec TriggerWhen EXECUTE FUNCTION_or_PROCEDURE func_name '(' TriggerFuncArgs ')'
5284 {
5285 $$ = 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(")"));
5286 }
5287 | CREATE CONSTRAINT TRIGGER name AFTER TriggerEvents ON qualified_name OptConstrFromTable ConstraintAttributeSpec FOR EACH ROW TriggerWhen EXECUTE FUNCTION_or_PROCEDURE func_name '(' TriggerFuncArgs ')'
5288 {
5289 $$ = 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(")"));
5290 }
5291 ;
5292
5293
5294 TriggerActionTime:
5295 BEFORE
5296 {
5297 $$ = mm_strdup("before");
5298 }
5299 | AFTER
5300 {
5301 $$ = mm_strdup("after");
5302 }
5303 | INSTEAD OF
5304 {
5305 $$ = mm_strdup("instead of");
5306 }
5307 ;
5308
5309
5310 TriggerEvents:
5311 TriggerOneEvent
5312 {
5313 $$ = $1;
5314 }
5315 | TriggerEvents OR TriggerOneEvent
5316 {
5317 $$ = cat_str(3,$1,mm_strdup("or"),$3);
5318 }
5319 ;
5320
5321
5322 TriggerOneEvent:
5323 INSERT
5324 {
5325 $$ = mm_strdup("insert");
5326 }
5327 | DELETE_P
5328 {
5329 $$ = mm_strdup("delete");
5330 }
5331 | UPDATE
5332 {
5333 $$ = mm_strdup("update");
5334 }
5335 | UPDATE OF columnList
5336 {
5337 $$ = cat_str(2,mm_strdup("update of"),$3);
5338 }
5339 | TRUNCATE
5340 {
5341 $$ = mm_strdup("truncate");
5342 }
5343 ;
5344
5345
5346 TriggerReferencing:
5347 REFERENCING TriggerTransitions
5348 {
5349 $$ = cat_str(2,mm_strdup("referencing"),$2);
5350 }
5351 |
5352 {
5353 $$=EMPTY; }
5354 ;
5355
5356
5357 TriggerTransitions:
5358 TriggerTransition
5359 {
5360 $$ = $1;
5361 }
5362 | TriggerTransitions TriggerTransition
5363 {
5364 $$ = cat_str(2,$1,$2);
5365 }
5366 ;
5367
5368
5369 TriggerTransition:
5370 TransitionOldOrNew TransitionRowOrTable opt_as TransitionRelName
5371 {
5372 $$ = cat_str(4,$1,$2,$3,$4);
5373 }
5374 ;
5375
5376
5377 TransitionOldOrNew:
5378 NEW
5379 {
5380 $$ = mm_strdup("new");
5381 }
5382 | OLD
5383 {
5384 $$ = mm_strdup("old");
5385 }
5386 ;
5387
5388
5389 TransitionRowOrTable:
5390 TABLE
5391 {
5392 $$ = mm_strdup("table");
5393 }
5394 | ROW
5395 {
5396 $$ = mm_strdup("row");
5397 }
5398 ;
5399
5400
5401 TransitionRelName:
5402 ColId
5403 {
5404 $$ = $1;
5405 }
5406 ;
5407
5408
5409 TriggerForSpec:
5410 FOR TriggerForOptEach TriggerForType
5411 {
5412 $$ = cat_str(3,mm_strdup("for"),$2,$3);
5413 }
5414 |
5415 {
5416 $$=EMPTY; }
5417 ;
5418
5419
5420 TriggerForOptEach:
5421 EACH
5422 {
5423 $$ = mm_strdup("each");
5424 }
5425 |
5426 {
5427 $$=EMPTY; }
5428 ;
5429
5430
5431 TriggerForType:
5432 ROW
5433 {
5434 $$ = mm_strdup("row");
5435 }
5436 | STATEMENT
5437 {
5438 $$ = mm_strdup("statement");
5439 }
5440 ;
5441
5442
5443 TriggerWhen:
5444 WHEN '(' a_expr ')'
5445 {
5446 $$ = cat_str(3,mm_strdup("when ("),$3,mm_strdup(")"));
5447 }
5448 |
5449 {
5450 $$=EMPTY; }
5451 ;
5452
5453
5454 FUNCTION_or_PROCEDURE:
5455 FUNCTION
5456 {
5457 $$ = mm_strdup("function");
5458 }
5459 | PROCEDURE
5460 {
5461 $$ = mm_strdup("procedure");
5462 }
5463 ;
5464
5465
5466 TriggerFuncArgs:
5467 TriggerFuncArg
5468 {
5469 $$ = $1;
5470 }
5471 | TriggerFuncArgs ',' TriggerFuncArg
5472 {
5473 $$ = cat_str(3,$1,mm_strdup(","),$3);
5474 }
5475 |
5476 {
5477 $$=EMPTY; }
5478 ;
5479
5480
5481 TriggerFuncArg:
5482 Iconst
5483 {
5484 $$ = $1;
5485 }
5486 | ecpg_fconst
5487 {
5488 $$ = $1;
5489 }
5490 | ecpg_sconst
5491 {
5492 $$ = $1;
5493 }
5494 | ColLabel
5495 {
5496 $$ = $1;
5497 }
5498 ;
5499
5500
5501 OptConstrFromTable:
5502 FROM qualified_name
5503 {
5504 $$ = cat_str(2,mm_strdup("from"),$2);
5505 }
5506 |
5507 {
5508 $$=EMPTY; }
5509 ;
5510
5511
5512 ConstraintAttributeSpec:
5513
5514 {
5515 $$=EMPTY; }
5516 | ConstraintAttributeSpec ConstraintAttributeElem
5517 {
5518 $$ = cat_str(2,$1,$2);
5519 }
5520 ;
5521
5522
5523 ConstraintAttributeElem:
5524 NOT DEFERRABLE
5525 {
5526 $$ = mm_strdup("not deferrable");
5527 }
5528 | DEFERRABLE
5529 {
5530 $$ = mm_strdup("deferrable");
5531 }
5532 | INITIALLY IMMEDIATE
5533 {
5534 $$ = mm_strdup("initially immediate");
5535 }
5536 | INITIALLY DEFERRED
5537 {
5538 $$ = mm_strdup("initially deferred");
5539 }
5540 | NOT VALID
5541 {
5542 $$ = mm_strdup("not valid");
5543 }
5544 | NO INHERIT
5545 {
5546 $$ = mm_strdup("no inherit");
5547 }
5548 ;
5549
5550
5551 CreateEventTrigStmt:
5552 CREATE EVENT TRIGGER name ON ColLabel EXECUTE FUNCTION_or_PROCEDURE func_name '(' ')'
5553 {
5554 $$ = cat_str(8,mm_strdup("create event trigger"),$4,mm_strdup("on"),$6,mm_strdup("execute"),$8,$9,mm_strdup("( )"));
5555 }
5556 | CREATE EVENT TRIGGER name ON ColLabel WHEN event_trigger_when_list EXECUTE FUNCTION_or_PROCEDURE func_name '(' ')'
5557 {
5558 $$ = cat_str(10,mm_strdup("create event trigger"),$4,mm_strdup("on"),$6,mm_strdup("when"),$8,mm_strdup("execute"),$10,$11,mm_strdup("( )"));
5559 }
5560 ;
5561
5562
5563 event_trigger_when_list:
5564 event_trigger_when_item
5565 {
5566 $$ = $1;
5567 }
5568 | event_trigger_when_list AND event_trigger_when_item
5569 {
5570 $$ = cat_str(3,$1,mm_strdup("and"),$3);
5571 }
5572 ;
5573
5574
5575 event_trigger_when_item:
5576 ColId IN_P '(' event_trigger_value_list ')'
5577 {
5578 $$ = cat_str(4,$1,mm_strdup("in ("),$4,mm_strdup(")"));
5579 }
5580 ;
5581
5582
5583 event_trigger_value_list:
5584 SCONST
5585 {
5586 $$ = mm_strdup("sconst");
5587 }
5588 | event_trigger_value_list ',' SCONST
5589 {
5590 $$ = cat_str(2,$1,mm_strdup(", sconst"));
5591 }
5592 ;
5593
5594
5595 AlterEventTrigStmt:
5596 ALTER EVENT TRIGGER name enable_trigger
5597 {
5598 $$ = cat_str(3,mm_strdup("alter event trigger"),$4,$5);
5599 }
5600 ;
5601
5602
5603 enable_trigger:
5604 ENABLE_P
5605 {
5606 $$ = mm_strdup("enable");
5607 }
5608 | ENABLE_P REPLICA
5609 {
5610 $$ = mm_strdup("enable replica");
5611 }
5612 | ENABLE_P ALWAYS
5613 {
5614 $$ = mm_strdup("enable always");
5615 }
5616 | DISABLE_P
5617 {
5618 $$ = mm_strdup("disable");
5619 }
5620 ;
5621
5622
5623 CreateAssertionStmt:
5624 CREATE ASSERTION any_name CHECK '(' a_expr ')' ConstraintAttributeSpec
5625 {
5626 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
5627 $$ = cat_str(6,mm_strdup("create assertion"),$3,mm_strdup("check ("),$6,mm_strdup(")"),$8);
5628 }
5629 ;
5630
5631
5632 DefineStmt:
5633 CREATE opt_or_replace AGGREGATE func_name aggr_args definition
5634 {
5635 $$ = cat_str(6,mm_strdup("create"),$2,mm_strdup("aggregate"),$4,$5,$6);
5636 }
5637 | CREATE opt_or_replace AGGREGATE func_name old_aggr_definition
5638 {
5639 $$ = cat_str(5,mm_strdup("create"),$2,mm_strdup("aggregate"),$4,$5);
5640 }
5641 | CREATE OPERATOR any_operator definition
5642 {
5643 $$ = cat_str(3,mm_strdup("create operator"),$3,$4);
5644 }
5645 | CREATE TYPE_P any_name definition
5646 {
5647 $$ = cat_str(3,mm_strdup("create type"),$3,$4);
5648 }
5649 | CREATE TYPE_P any_name
5650 {
5651 $$ = cat_str(2,mm_strdup("create type"),$3);
5652 }
5653 | CREATE TYPE_P any_name AS '(' OptTableFuncElementList ')'
5654 {
5655 $$ = cat_str(5,mm_strdup("create type"),$3,mm_strdup("as ("),$6,mm_strdup(")"));
5656 }
5657 | CREATE TYPE_P any_name AS ENUM_P '(' opt_enum_val_list ')'
5658 {
5659 $$ = cat_str(5,mm_strdup("create type"),$3,mm_strdup("as enum ("),$7,mm_strdup(")"));
5660 }
5661 | CREATE TYPE_P any_name AS RANGE definition
5662 {
5663 $$ = cat_str(4,mm_strdup("create type"),$3,mm_strdup("as range"),$6);
5664 }
5665 | CREATE TEXT_P SEARCH PARSER any_name definition
5666 {
5667 $$ = cat_str(3,mm_strdup("create text search parser"),$5,$6);
5668 }
5669 | CREATE TEXT_P SEARCH DICTIONARY any_name definition
5670 {
5671 $$ = cat_str(3,mm_strdup("create text search dictionary"),$5,$6);
5672 }
5673 | CREATE TEXT_P SEARCH TEMPLATE any_name definition
5674 {
5675 $$ = cat_str(3,mm_strdup("create text search template"),$5,$6);
5676 }
5677 | CREATE TEXT_P SEARCH CONFIGURATION any_name definition
5678 {
5679 $$ = cat_str(3,mm_strdup("create text search configuration"),$5,$6);
5680 }
5681 | CREATE COLLATION any_name definition
5682 {
5683 $$ = cat_str(3,mm_strdup("create collation"),$3,$4);
5684 }
5685 | CREATE COLLATION IF_P NOT EXISTS any_name definition
5686 {
5687 $$ = cat_str(3,mm_strdup("create collation if not exists"),$6,$7);
5688 }
5689 | CREATE COLLATION any_name FROM any_name
5690 {
5691 $$ = cat_str(4,mm_strdup("create collation"),$3,mm_strdup("from"),$5);
5692 }
5693 | CREATE COLLATION IF_P NOT EXISTS any_name FROM any_name
5694 {
5695 $$ = cat_str(4,mm_strdup("create collation if not exists"),$6,mm_strdup("from"),$8);
5696 }
5697 ;
5698
5699
5700 definition:
5701 '(' def_list ')'
5702 {
5703 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
5704 }
5705 ;
5706
5707
5708 def_list:
5709 def_elem
5710 {
5711 $$ = $1;
5712 }
5713 | def_list ',' def_elem
5714 {
5715 $$ = cat_str(3,$1,mm_strdup(","),$3);
5716 }
5717 ;
5718
5719
5720 def_elem:
5721 ColLabel '=' def_arg
5722 {
5723 $$ = cat_str(3,$1,mm_strdup("="),$3);
5724 }
5725 | ColLabel
5726 {
5727 $$ = $1;
5728 }
5729 ;
5730
5731
5732 def_arg:
5733 func_type
5734 {
5735 $$ = $1;
5736 }
5737 | reserved_keyword
5738 {
5739 $$ = $1;
5740 }
5741 | qual_all_Op
5742 {
5743 $$ = $1;
5744 }
5745 | NumericOnly
5746 {
5747 $$ = $1;
5748 }
5749 | ecpg_sconst
5750 {
5751 $$ = $1;
5752 }
5753 | NONE
5754 {
5755 $$ = mm_strdup("none");
5756 }
5757 ;
5758
5759
5760 old_aggr_definition:
5761 '(' old_aggr_list ')'
5762 {
5763 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
5764 }
5765 ;
5766
5767
5768 old_aggr_list:
5769 old_aggr_elem
5770 {
5771 $$ = $1;
5772 }
5773 | old_aggr_list ',' old_aggr_elem
5774 {
5775 $$ = cat_str(3,$1,mm_strdup(","),$3);
5776 }
5777 ;
5778
5779
5780 old_aggr_elem:
5781 ecpg_ident '=' def_arg
5782 {
5783 $$ = cat_str(3,$1,mm_strdup("="),$3);
5784 }
5785 ;
5786
5787
5788 opt_enum_val_list:
5789 enum_val_list
5790 {
5791 $$ = $1;
5792 }
5793 |
5794 {
5795 $$=EMPTY; }
5796 ;
5797
5798
5799 enum_val_list:
5800 ecpg_sconst
5801 {
5802 $$ = $1;
5803 }
5804 | enum_val_list ',' ecpg_sconst
5805 {
5806 $$ = cat_str(3,$1,mm_strdup(","),$3);
5807 }
5808 ;
5809
5810
5811 AlterEnumStmt:
5812 ALTER TYPE_P any_name ADD_P VALUE_P opt_if_not_exists ecpg_sconst
5813 {
5814 $$ = cat_str(5,mm_strdup("alter type"),$3,mm_strdup("add value"),$6,$7);
5815 }
5816 | ALTER TYPE_P any_name ADD_P VALUE_P opt_if_not_exists ecpg_sconst BEFORE ecpg_sconst
5817 {
5818 $$ = cat_str(7,mm_strdup("alter type"),$3,mm_strdup("add value"),$6,$7,mm_strdup("before"),$9);
5819 }
5820 | ALTER TYPE_P any_name ADD_P VALUE_P opt_if_not_exists ecpg_sconst AFTER ecpg_sconst
5821 {
5822 $$ = cat_str(7,mm_strdup("alter type"),$3,mm_strdup("add value"),$6,$7,mm_strdup("after"),$9);
5823 }
5824 | ALTER TYPE_P any_name RENAME VALUE_P ecpg_sconst TO ecpg_sconst
5825 {
5826 $$ = cat_str(6,mm_strdup("alter type"),$3,mm_strdup("rename value"),$6,mm_strdup("to"),$8);
5827 }
5828 ;
5829
5830
5831 opt_if_not_exists:
5832 IF_P NOT EXISTS
5833 {
5834 $$ = mm_strdup("if not exists");
5835 }
5836 |
5837 {
5838 $$=EMPTY; }
5839 ;
5840
5841
5842 CreateOpClassStmt:
5843 CREATE OPERATOR CLASS any_name opt_default FOR TYPE_P Typename USING access_method opt_opfamily AS opclass_item_list
5844 {
5845 $$ = cat_str(10,mm_strdup("create operator class"),$4,$5,mm_strdup("for type"),$8,mm_strdup("using"),$10,$11,mm_strdup("as"),$13);
5846 }
5847 ;
5848
5849
5850 opclass_item_list:
5851 opclass_item
5852 {
5853 $$ = $1;
5854 }
5855 | opclass_item_list ',' opclass_item
5856 {
5857 $$ = cat_str(3,$1,mm_strdup(","),$3);
5858 }
5859 ;
5860
5861
5862 opclass_item:
5863 OPERATOR Iconst any_operator opclass_purpose opt_recheck
5864 {
5865 $$ = cat_str(5,mm_strdup("operator"),$2,$3,$4,$5);
5866 }
5867 | OPERATOR Iconst operator_with_argtypes opclass_purpose opt_recheck
5868 {
5869 $$ = cat_str(5,mm_strdup("operator"),$2,$3,$4,$5);
5870 }
5871 | FUNCTION Iconst function_with_argtypes
5872 {
5873 $$ = cat_str(3,mm_strdup("function"),$2,$3);
5874 }
5875 | FUNCTION Iconst '(' type_list ')' function_with_argtypes
5876 {
5877 $$ = cat_str(6,mm_strdup("function"),$2,mm_strdup("("),$4,mm_strdup(")"),$6);
5878 }
5879 | STORAGE Typename
5880 {
5881 $$ = cat_str(2,mm_strdup("storage"),$2);
5882 }
5883 ;
5884
5885
5886 opt_default:
5887 DEFAULT
5888 {
5889 $$ = mm_strdup("default");
5890 }
5891 |
5892 {
5893 $$=EMPTY; }
5894 ;
5895
5896
5897 opt_opfamily:
5898 FAMILY any_name
5899 {
5900 $$ = cat_str(2,mm_strdup("family"),$2);
5901 }
5902 |
5903 {
5904 $$=EMPTY; }
5905 ;
5906
5907
5908 opclass_purpose:
5909 FOR SEARCH
5910 {
5911 $$ = mm_strdup("for search");
5912 }
5913 | FOR ORDER BY any_name
5914 {
5915 $$ = cat_str(2,mm_strdup("for order by"),$4);
5916 }
5917 |
5918 {
5919 $$=EMPTY; }
5920 ;
5921
5922
5923 opt_recheck:
5924 RECHECK
5925 {
5926 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
5927 $$ = mm_strdup("recheck");
5928 }
5929 |
5930 {
5931 $$=EMPTY; }
5932 ;
5933
5934
5935 CreateOpFamilyStmt:
5936 CREATE OPERATOR FAMILY any_name USING access_method
5937 {
5938 $$ = cat_str(4,mm_strdup("create operator family"),$4,mm_strdup("using"),$6);
5939 }
5940 ;
5941
5942
5943 AlterOpFamilyStmt:
5944 ALTER OPERATOR FAMILY any_name USING access_method ADD_P opclass_item_list
5945 {
5946 $$ = cat_str(6,mm_strdup("alter operator family"),$4,mm_strdup("using"),$6,mm_strdup("add"),$8);
5947 }
5948 | ALTER OPERATOR FAMILY any_name USING access_method DROP opclass_drop_list
5949 {
5950 $$ = cat_str(6,mm_strdup("alter operator family"),$4,mm_strdup("using"),$6,mm_strdup("drop"),$8);
5951 }
5952 ;
5953
5954
5955 opclass_drop_list:
5956 opclass_drop
5957 {
5958 $$ = $1;
5959 }
5960 | opclass_drop_list ',' opclass_drop
5961 {
5962 $$ = cat_str(3,$1,mm_strdup(","),$3);
5963 }
5964 ;
5965
5966
5967 opclass_drop:
5968 OPERATOR Iconst '(' type_list ')'
5969 {
5970 $$ = cat_str(5,mm_strdup("operator"),$2,mm_strdup("("),$4,mm_strdup(")"));
5971 }
5972 | FUNCTION Iconst '(' type_list ')'
5973 {
5974 $$ = cat_str(5,mm_strdup("function"),$2,mm_strdup("("),$4,mm_strdup(")"));
5975 }
5976 ;
5977
5978
5979 DropOpClassStmt:
5980 DROP OPERATOR CLASS any_name USING access_method opt_drop_behavior
5981 {
5982 $$ = cat_str(5,mm_strdup("drop operator class"),$4,mm_strdup("using"),$6,$7);
5983 }
5984 | DROP OPERATOR CLASS IF_P EXISTS any_name USING access_method opt_drop_behavior
5985 {
5986 $$ = cat_str(5,mm_strdup("drop operator class if exists"),$6,mm_strdup("using"),$8,$9);
5987 }
5988 ;
5989
5990
5991 DropOpFamilyStmt:
5992 DROP OPERATOR FAMILY any_name USING access_method opt_drop_behavior
5993 {
5994 $$ = cat_str(5,mm_strdup("drop operator family"),$4,mm_strdup("using"),$6,$7);
5995 }
5996 | DROP OPERATOR FAMILY IF_P EXISTS any_name USING access_method opt_drop_behavior
5997 {
5998 $$ = cat_str(5,mm_strdup("drop operator family if exists"),$6,mm_strdup("using"),$8,$9);
5999 }
6000 ;
6001
6002
6003 DropOwnedStmt:
6004 DROP OWNED BY role_list opt_drop_behavior
6005 {
6006 $$ = cat_str(3,mm_strdup("drop owned by"),$4,$5);
6007 }
6008 ;
6009
6010
6011 ReassignOwnedStmt:
6012 REASSIGN OWNED BY role_list TO RoleSpec
6013 {
6014 $$ = cat_str(4,mm_strdup("reassign owned by"),$4,mm_strdup("to"),$6);
6015 }
6016 ;
6017
6018
6019 DropStmt:
6020 DROP drop_type_any_name IF_P EXISTS any_name_list opt_drop_behavior
6021 {
6022 $$ = cat_str(5,mm_strdup("drop"),$2,mm_strdup("if exists"),$5,$6);
6023 }
6024 | DROP drop_type_any_name any_name_list opt_drop_behavior
6025 {
6026 $$ = cat_str(4,mm_strdup("drop"),$2,$3,$4);
6027 }
6028 | DROP drop_type_name IF_P EXISTS name_list opt_drop_behavior
6029 {
6030 $$ = cat_str(5,mm_strdup("drop"),$2,mm_strdup("if exists"),$5,$6);
6031 }
6032 | DROP drop_type_name name_list opt_drop_behavior
6033 {
6034 $$ = cat_str(4,mm_strdup("drop"),$2,$3,$4);
6035 }
6036 | DROP drop_type_name_on_any_name name ON any_name opt_drop_behavior
6037 {
6038 $$ = cat_str(6,mm_strdup("drop"),$2,$3,mm_strdup("on"),$5,$6);
6039 }
6040 | DROP drop_type_name_on_any_name IF_P EXISTS name ON any_name opt_drop_behavior
6041 {
6042 $$ = cat_str(7,mm_strdup("drop"),$2,mm_strdup("if exists"),$5,mm_strdup("on"),$7,$8);
6043 }
6044 | DROP TYPE_P type_name_list opt_drop_behavior
6045 {
6046 $$ = cat_str(3,mm_strdup("drop type"),$3,$4);
6047 }
6048 | DROP TYPE_P IF_P EXISTS type_name_list opt_drop_behavior
6049 {
6050 $$ = cat_str(3,mm_strdup("drop type if exists"),$5,$6);
6051 }
6052 | DROP DOMAIN_P type_name_list opt_drop_behavior
6053 {
6054 $$ = cat_str(3,mm_strdup("drop domain"),$3,$4);
6055 }
6056 | DROP DOMAIN_P IF_P EXISTS type_name_list opt_drop_behavior
6057 {
6058 $$ = cat_str(3,mm_strdup("drop domain if exists"),$5,$6);
6059 }
6060 | DROP INDEX CONCURRENTLY any_name_list opt_drop_behavior
6061 {
6062 $$ = cat_str(3,mm_strdup("drop index concurrently"),$4,$5);
6063 }
6064 | DROP INDEX CONCURRENTLY IF_P EXISTS any_name_list opt_drop_behavior
6065 {
6066 $$ = cat_str(3,mm_strdup("drop index concurrently if exists"),$6,$7);
6067 }
6068 ;
6069
6070
6071 drop_type_any_name:
6072 TABLE
6073 {
6074 $$ = mm_strdup("table");
6075 }
6076 | SEQUENCE
6077 {
6078 $$ = mm_strdup("sequence");
6079 }
6080 | VIEW
6081 {
6082 $$ = mm_strdup("view");
6083 }
6084 | MATERIALIZED VIEW
6085 {
6086 $$ = mm_strdup("materialized view");
6087 }
6088 | INDEX
6089 {
6090 $$ = mm_strdup("index");
6091 }
6092 | FOREIGN TABLE
6093 {
6094 $$ = mm_strdup("foreign table");
6095 }
6096 | COLLATION
6097 {
6098 $$ = mm_strdup("collation");
6099 }
6100 | CONVERSION_P
6101 {
6102 $$ = mm_strdup("conversion");
6103 }
6104 | STATISTICS
6105 {
6106 $$ = mm_strdup("statistics");
6107 }
6108 | TEXT_P SEARCH PARSER
6109 {
6110 $$ = mm_strdup("text search parser");
6111 }
6112 | TEXT_P SEARCH DICTIONARY
6113 {
6114 $$ = mm_strdup("text search dictionary");
6115 }
6116 | TEXT_P SEARCH TEMPLATE
6117 {
6118 $$ = mm_strdup("text search template");
6119 }
6120 | TEXT_P SEARCH CONFIGURATION
6121 {
6122 $$ = mm_strdup("text search configuration");
6123 }
6124 ;
6125
6126
6127 drop_type_name:
6128 ACCESS METHOD
6129 {
6130 $$ = mm_strdup("access method");
6131 }
6132 | EVENT TRIGGER
6133 {
6134 $$ = mm_strdup("event trigger");
6135 }
6136 | EXTENSION
6137 {
6138 $$ = mm_strdup("extension");
6139 }
6140 | FOREIGN DATA_P WRAPPER
6141 {
6142 $$ = mm_strdup("foreign data wrapper");
6143 }
6144 | PUBLICATION
6145 {
6146 $$ = mm_strdup("publication");
6147 }
6148 | SCHEMA
6149 {
6150 $$ = mm_strdup("schema");
6151 }
6152 | SERVER
6153 {
6154 $$ = mm_strdup("server");
6155 }
6156 ;
6157
6158
6159 drop_type_name_on_any_name:
6160 POLICY
6161 {
6162 $$ = mm_strdup("policy");
6163 }
6164 | RULE
6165 {
6166 $$ = mm_strdup("rule");
6167 }
6168 | TRIGGER
6169 {
6170 $$ = mm_strdup("trigger");
6171 }
6172 ;
6173
6174
6175 any_name_list:
6176 any_name
6177 {
6178 $$ = $1;
6179 }
6180 | any_name_list ',' any_name
6181 {
6182 $$ = cat_str(3,$1,mm_strdup(","),$3);
6183 }
6184 ;
6185
6186
6187 any_name:
6188 ColId
6189 {
6190 $$ = $1;
6191 }
6192 | ColId attrs
6193 {
6194 $$ = cat_str(2,$1,$2);
6195 }
6196 ;
6197
6198
6199 attrs:
6200 '.' attr_name
6201 {
6202 $$ = cat_str(2,mm_strdup("."),$2);
6203 }
6204 | attrs '.' attr_name
6205 {
6206 $$ = cat_str(3,$1,mm_strdup("."),$3);
6207 }
6208 ;
6209
6210
6211 type_name_list:
6212 Typename
6213 {
6214 $$ = $1;
6215 }
6216 | type_name_list ',' Typename
6217 {
6218 $$ = cat_str(3,$1,mm_strdup(","),$3);
6219 }
6220 ;
6221
6222
6223 TruncateStmt:
6224 TRUNCATE opt_table relation_expr_list opt_restart_seqs opt_drop_behavior
6225 {
6226 $$ = cat_str(5,mm_strdup("truncate"),$2,$3,$4,$5);
6227 }
6228 ;
6229
6230
6231 opt_restart_seqs:
6232 CONTINUE_P IDENTITY_P
6233 {
6234 $$ = mm_strdup("continue identity");
6235 }
6236 | RESTART IDENTITY_P
6237 {
6238 $$ = mm_strdup("restart identity");
6239 }
6240 |
6241 {
6242 $$=EMPTY; }
6243 ;
6244
6245
6246 CommentStmt:
6247 COMMENT ON comment_type_any_name any_name IS comment_text
6248 {
6249 $$ = cat_str(5,mm_strdup("comment on"),$3,$4,mm_strdup("is"),$6);
6250 }
6251 | COMMENT ON comment_type_name name IS comment_text
6252 {
6253 $$ = cat_str(5,mm_strdup("comment on"),$3,$4,mm_strdup("is"),$6);
6254 }
6255 | COMMENT ON TYPE_P Typename IS comment_text
6256 {
6257 $$ = cat_str(4,mm_strdup("comment on type"),$4,mm_strdup("is"),$6);
6258 }
6259 | COMMENT ON DOMAIN_P Typename IS comment_text
6260 {
6261 $$ = cat_str(4,mm_strdup("comment on domain"),$4,mm_strdup("is"),$6);
6262 }
6263 | COMMENT ON AGGREGATE aggregate_with_argtypes IS comment_text
6264 {
6265 $$ = cat_str(4,mm_strdup("comment on aggregate"),$4,mm_strdup("is"),$6);
6266 }
6267 | COMMENT ON FUNCTION function_with_argtypes IS comment_text
6268 {
6269 $$ = cat_str(4,mm_strdup("comment on function"),$4,mm_strdup("is"),$6);
6270 }
6271 | COMMENT ON OPERATOR operator_with_argtypes IS comment_text
6272 {
6273 $$ = cat_str(4,mm_strdup("comment on operator"),$4,mm_strdup("is"),$6);
6274 }
6275 | COMMENT ON CONSTRAINT name ON any_name IS comment_text
6276 {
6277 $$ = cat_str(6,mm_strdup("comment on constraint"),$4,mm_strdup("on"),$6,mm_strdup("is"),$8);
6278 }
6279 | COMMENT ON CONSTRAINT name ON DOMAIN_P any_name IS comment_text
6280 {
6281 $$ = cat_str(6,mm_strdup("comment on constraint"),$4,mm_strdup("on domain"),$7,mm_strdup("is"),$9);
6282 }
6283 | COMMENT ON POLICY name ON any_name IS comment_text
6284 {
6285 $$ = cat_str(6,mm_strdup("comment on policy"),$4,mm_strdup("on"),$6,mm_strdup("is"),$8);
6286 }
6287 | COMMENT ON PROCEDURE function_with_argtypes IS comment_text
6288 {
6289 $$ = cat_str(4,mm_strdup("comment on procedure"),$4,mm_strdup("is"),$6);
6290 }
6291 | COMMENT ON ROUTINE function_with_argtypes IS comment_text
6292 {
6293 $$ = cat_str(4,mm_strdup("comment on routine"),$4,mm_strdup("is"),$6);
6294 }
6295 | COMMENT ON RULE name ON any_name IS comment_text
6296 {
6297 $$ = cat_str(6,mm_strdup("comment on rule"),$4,mm_strdup("on"),$6,mm_strdup("is"),$8);
6298 }
6299 | COMMENT ON TRANSFORM FOR Typename LANGUAGE name IS comment_text
6300 {
6301 $$ = cat_str(6,mm_strdup("comment on transform for"),$5,mm_strdup("language"),$7,mm_strdup("is"),$9);
6302 }
6303 | COMMENT ON TRIGGER name ON any_name IS comment_text
6304 {
6305 $$ = cat_str(6,mm_strdup("comment on trigger"),$4,mm_strdup("on"),$6,mm_strdup("is"),$8);
6306 }
6307 | COMMENT ON OPERATOR CLASS any_name USING access_method IS comment_text
6308 {
6309 $$ = cat_str(6,mm_strdup("comment on operator class"),$5,mm_strdup("using"),$7,mm_strdup("is"),$9);
6310 }
6311 | COMMENT ON OPERATOR FAMILY any_name USING access_method IS comment_text
6312 {
6313 $$ = cat_str(6,mm_strdup("comment on operator family"),$5,mm_strdup("using"),$7,mm_strdup("is"),$9);
6314 }
6315 | COMMENT ON LARGE_P OBJECT_P NumericOnly IS comment_text
6316 {
6317 $$ = cat_str(4,mm_strdup("comment on large object"),$5,mm_strdup("is"),$7);
6318 }
6319 | COMMENT ON CAST '(' Typename AS Typename ')' IS comment_text
6320 {
6321 $$ = cat_str(6,mm_strdup("comment on cast ("),$5,mm_strdup("as"),$7,mm_strdup(") is"),$10);
6322 }
6323 ;
6324
6325
6326 comment_type_any_name:
6327 COLUMN
6328 {
6329 $$ = mm_strdup("column");
6330 }
6331 | INDEX
6332 {
6333 $$ = mm_strdup("index");
6334 }
6335 | SEQUENCE
6336 {
6337 $$ = mm_strdup("sequence");
6338 }
6339 | STATISTICS
6340 {
6341 $$ = mm_strdup("statistics");
6342 }
6343 | TABLE
6344 {
6345 $$ = mm_strdup("table");
6346 }
6347 | VIEW
6348 {
6349 $$ = mm_strdup("view");
6350 }
6351 | MATERIALIZED VIEW
6352 {
6353 $$ = mm_strdup("materialized view");
6354 }
6355 | COLLATION
6356 {
6357 $$ = mm_strdup("collation");
6358 }
6359 | CONVERSION_P
6360 {
6361 $$ = mm_strdup("conversion");
6362 }
6363 | FOREIGN TABLE
6364 {
6365 $$ = mm_strdup("foreign table");
6366 }
6367 | TEXT_P SEARCH CONFIGURATION
6368 {
6369 $$ = mm_strdup("text search configuration");
6370 }
6371 | TEXT_P SEARCH DICTIONARY
6372 {
6373 $$ = mm_strdup("text search dictionary");
6374 }
6375 | TEXT_P SEARCH PARSER
6376 {
6377 $$ = mm_strdup("text search parser");
6378 }
6379 | TEXT_P SEARCH TEMPLATE
6380 {
6381 $$ = mm_strdup("text search template");
6382 }
6383 ;
6384
6385
6386 comment_type_name:
6387 ACCESS METHOD
6388 {
6389 $$ = mm_strdup("access method");
6390 }
6391 | DATABASE
6392 {
6393 $$ = mm_strdup("database");
6394 }
6395 | EVENT TRIGGER
6396 {
6397 $$ = mm_strdup("event trigger");
6398 }
6399 | EXTENSION
6400 {
6401 $$ = mm_strdup("extension");
6402 }
6403 | FOREIGN DATA_P WRAPPER
6404 {
6405 $$ = mm_strdup("foreign data wrapper");
6406 }
6407 | opt_procedural LANGUAGE
6408 {
6409 $$ = cat_str(2,$1,mm_strdup("language"));
6410 }
6411 | PUBLICATION
6412 {
6413 $$ = mm_strdup("publication");
6414 }
6415 | ROLE
6416 {
6417 $$ = mm_strdup("role");
6418 }
6419 | SCHEMA
6420 {
6421 $$ = mm_strdup("schema");
6422 }
6423 | SERVER
6424 {
6425 $$ = mm_strdup("server");
6426 }
6427 | SUBSCRIPTION
6428 {
6429 $$ = mm_strdup("subscription");
6430 }
6431 | TABLESPACE
6432 {
6433 $$ = mm_strdup("tablespace");
6434 }
6435 ;
6436
6437
6438 comment_text:
6439 ecpg_sconst
6440 {
6441 $$ = $1;
6442 }
6443 | NULL_P
6444 {
6445 $$ = mm_strdup("null");
6446 }
6447 ;
6448
6449
6450 SecLabelStmt:
6451 SECURITY LABEL opt_provider ON security_label_type_any_name any_name IS security_label
6452 {
6453 $$ = cat_str(7,mm_strdup("security label"),$3,mm_strdup("on"),$5,$6,mm_strdup("is"),$8);
6454 }
6455 | SECURITY LABEL opt_provider ON security_label_type_name name IS security_label
6456 {
6457 $$ = cat_str(7,mm_strdup("security label"),$3,mm_strdup("on"),$5,$6,mm_strdup("is"),$8);
6458 }
6459 | SECURITY LABEL opt_provider ON TYPE_P Typename IS security_label
6460 {
6461 $$ = cat_str(6,mm_strdup("security label"),$3,mm_strdup("on type"),$6,mm_strdup("is"),$8);
6462 }
6463 | SECURITY LABEL opt_provider ON DOMAIN_P Typename IS security_label
6464 {
6465 $$ = cat_str(6,mm_strdup("security label"),$3,mm_strdup("on domain"),$6,mm_strdup("is"),$8);
6466 }
6467 | SECURITY LABEL opt_provider ON AGGREGATE aggregate_with_argtypes IS security_label
6468 {
6469 $$ = cat_str(6,mm_strdup("security label"),$3,mm_strdup("on aggregate"),$6,mm_strdup("is"),$8);
6470 }
6471 | SECURITY LABEL opt_provider ON FUNCTION function_with_argtypes IS security_label
6472 {
6473 $$ = cat_str(6,mm_strdup("security label"),$3,mm_strdup("on function"),$6,mm_strdup("is"),$8);
6474 }
6475 | SECURITY LABEL opt_provider ON LARGE_P OBJECT_P NumericOnly IS security_label
6476 {
6477 $$ = cat_str(6,mm_strdup("security label"),$3,mm_strdup("on large object"),$7,mm_strdup("is"),$9);
6478 }
6479 | SECURITY LABEL opt_provider ON PROCEDURE function_with_argtypes IS security_label
6480 {
6481 $$ = cat_str(6,mm_strdup("security label"),$3,mm_strdup("on procedure"),$6,mm_strdup("is"),$8);
6482 }
6483 | SECURITY LABEL opt_provider ON ROUTINE function_with_argtypes IS security_label
6484 {
6485 $$ = cat_str(6,mm_strdup("security label"),$3,mm_strdup("on routine"),$6,mm_strdup("is"),$8);
6486 }
6487 ;
6488
6489
6490 opt_provider:
6491 FOR NonReservedWord_or_Sconst
6492 {
6493 $$ = cat_str(2,mm_strdup("for"),$2);
6494 }
6495 |
6496 {
6497 $$=EMPTY; }
6498 ;
6499
6500
6501 security_label_type_any_name:
6502 COLUMN
6503 {
6504 $$ = mm_strdup("column");
6505 }
6506 | FOREIGN TABLE
6507 {
6508 $$ = mm_strdup("foreign table");
6509 }
6510 | SEQUENCE
6511 {
6512 $$ = mm_strdup("sequence");
6513 }
6514 | TABLE
6515 {
6516 $$ = mm_strdup("table");
6517 }
6518 | VIEW
6519 {
6520 $$ = mm_strdup("view");
6521 }
6522 | MATERIALIZED VIEW
6523 {
6524 $$ = mm_strdup("materialized view");
6525 }
6526 ;
6527
6528
6529 security_label_type_name:
6530 DATABASE
6531 {
6532 $$ = mm_strdup("database");
6533 }
6534 | EVENT TRIGGER
6535 {
6536 $$ = mm_strdup("event trigger");
6537 }
6538 | opt_procedural LANGUAGE
6539 {
6540 $$ = cat_str(2,$1,mm_strdup("language"));
6541 }
6542 | PUBLICATION
6543 {
6544 $$ = mm_strdup("publication");
6545 }
6546 | ROLE
6547 {
6548 $$ = mm_strdup("role");
6549 }
6550 | SCHEMA
6551 {
6552 $$ = mm_strdup("schema");
6553 }
6554 | SUBSCRIPTION
6555 {
6556 $$ = mm_strdup("subscription");
6557 }
6558 | TABLESPACE
6559 {
6560 $$ = mm_strdup("tablespace");
6561 }
6562 ;
6563
6564
6565 security_label:
6566 ecpg_sconst
6567 {
6568 $$ = $1;
6569 }
6570 | NULL_P
6571 {
6572 $$ = mm_strdup("null");
6573 }
6574 ;
6575
6576
6577 FetchStmt:
6578 FETCH fetch_args
6579 {
6580 $$ = cat_str(2,mm_strdup("fetch"),$2);
6581 }
6582 | MOVE fetch_args
6583 {
6584 $$ = cat_str(2,mm_strdup("move"),$2);
6585 }
6586 | FETCH fetch_args ecpg_fetch_into
6587 {
6588 $$ = cat2_str(mm_strdup("fetch"), $2);
6589 }
6590 | FETCH FORWARD cursor_name opt_ecpg_fetch_into
6591 {
6592 char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
6593 add_additional_variables($3, false);
6594 $$ = cat_str(2, mm_strdup("fetch forward"), cursor_marker);
6595 }
6596 | FETCH FORWARD from_in cursor_name opt_ecpg_fetch_into
6597 {
6598 char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
6599 add_additional_variables($4, false);
6600 $$ = cat_str(2, mm_strdup("fetch forward from"), cursor_marker);
6601 }
6602 | FETCH BACKWARD cursor_name opt_ecpg_fetch_into
6603 {
6604 char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
6605 add_additional_variables($3, false);
6606 $$ = cat_str(2, mm_strdup("fetch backward"), cursor_marker);
6607 }
6608 | FETCH BACKWARD from_in cursor_name opt_ecpg_fetch_into
6609 {
6610 char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
6611 add_additional_variables($4, false);
6612 $$ = cat_str(2, mm_strdup("fetch backward from"), cursor_marker);
6613 }
6614 | MOVE FORWARD cursor_name
6615 {
6616 char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
6617 add_additional_variables($3, false);
6618 $$ = cat_str(2, mm_strdup("move forward"), cursor_marker);
6619 }
6620 | MOVE FORWARD from_in cursor_name
6621 {
6622 char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
6623 add_additional_variables($4, false);
6624 $$ = cat_str(2, mm_strdup("move forward from"), cursor_marker);
6625 }
6626 | MOVE BACKWARD cursor_name
6627 {
6628 char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
6629 add_additional_variables($3, false);
6630 $$ = cat_str(2, mm_strdup("move backward"), cursor_marker);
6631 }
6632 | MOVE BACKWARD from_in cursor_name
6633 {
6634 char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
6635 add_additional_variables($4, false);
6636 $$ = cat_str(2, mm_strdup("move backward from"), cursor_marker);
6637 }
6638 ;
6639
6640
6641 fetch_args:
6642 cursor_name
6643 {
6644 add_additional_variables($1, false);
6645 if ($1[0] == ':')
6646 {
6647 free($1);
6648 $1 = mm_strdup("$0");
6649 }
6650
6651 $$ = $1;
6652 }
6653 | from_in cursor_name
6654 {
6655 add_additional_variables($2, false);
6656 if ($2[0] == ':')
6657 {
6658 free($2);
6659 $2 = mm_strdup("$0");
6660 }
6661
6662 $$ = cat_str(2,$1,$2);
6663 }
6664 | NEXT opt_from_in cursor_name
6665 {
6666 add_additional_variables($3, false);
6667 if ($3[0] == ':')
6668 {
6669 free($3);
6670 $3 = mm_strdup("$0");
6671 }
6672
6673 $$ = cat_str(3,mm_strdup("next"),$2,$3);
6674 }
6675 | PRIOR opt_from_in cursor_name
6676 {
6677 add_additional_variables($3, false);
6678 if ($3[0] == ':')
6679 {
6680 free($3);
6681 $3 = mm_strdup("$0");
6682 }
6683
6684 $$ = cat_str(3,mm_strdup("prior"),$2,$3);
6685 }
6686 | FIRST_P opt_from_in cursor_name
6687 {
6688 add_additional_variables($3, false);
6689 if ($3[0] == ':')
6690 {
6691 free($3);
6692 $3 = mm_strdup("$0");
6693 }
6694
6695 $$ = cat_str(3,mm_strdup("first"),$2,$3);
6696 }
6697 | LAST_P opt_from_in cursor_name
6698 {
6699 add_additional_variables($3, false);
6700 if ($3[0] == ':')
6701 {
6702 free($3);
6703 $3 = mm_strdup("$0");
6704 }
6705
6706 $$ = cat_str(3,mm_strdup("last"),$2,$3);
6707 }
6708 | ABSOLUTE_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("absolute"),$2,$3,$4);
6723 }
6724 | RELATIVE_P SignedIconst opt_from_in cursor_name
6725 {
6726 add_additional_variables($4, false);
6727 if ($4[0] == ':')
6728 {
6729 free($4);
6730 $4 = mm_strdup("$0");
6731 }
6732 if ($2[0] == '$')
6733 {
6734 free($2);
6735 $2 = mm_strdup("$0");
6736 }
6737
6738 $$ = cat_str(4,mm_strdup("relative"),$2,$3,$4);
6739 }
6740 | SignedIconst 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 if ($1[0] == '$')
6749 {
6750 free($1);
6751 $1 = mm_strdup("$0");
6752 }
6753
6754 $$ = cat_str(3,$1,$2,$3);
6755 }
6756 | ALL opt_from_in cursor_name
6757 {
6758 add_additional_variables($3, false);
6759 if ($3[0] == ':')
6760 {
6761 free($3);
6762 $3 = mm_strdup("$0");
6763 }
6764
6765 $$ = cat_str(3,mm_strdup("all"),$2,$3);
6766 }
6767 | FORWARD SignedIconst 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 if ($2[0] == '$')
6776 {
6777 free($2);
6778 $2 = mm_strdup("$0");
6779 }
6780
6781 $$ = cat_str(4,mm_strdup("forward"),$2,$3,$4);
6782 }
6783 | FORWARD ALL opt_from_in cursor_name
6784 {
6785 add_additional_variables($4, false);
6786 if ($4[0] == ':')
6787 {
6788 free($4);
6789 $4 = mm_strdup("$0");
6790 }
6791
6792 $$ = cat_str(3,mm_strdup("forward all"),$3,$4);
6793 }
6794 | BACKWARD SignedIconst 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 if ($2[0] == '$')
6803 {
6804 free($2);
6805 $2 = mm_strdup("$0");
6806 }
6807
6808 $$ = cat_str(4,mm_strdup("backward"),$2,$3,$4);
6809 }
6810 | BACKWARD ALL opt_from_in cursor_name
6811 {
6812 add_additional_variables($4, false);
6813 if ($4[0] == ':')
6814 {
6815 free($4);
6816 $4 = mm_strdup("$0");
6817 }
6818
6819 $$ = cat_str(3,mm_strdup("backward all"),$3,$4);
6820 }
6821 ;
6822
6823
6824 from_in:
6825 FROM
6826 {
6827 $$ = mm_strdup("from");
6828 }
6829 | IN_P
6830 {
6831 $$ = mm_strdup("in");
6832 }
6833 ;
6834
6835
6836 opt_from_in:
6837 from_in
6838 {
6839 $$ = $1;
6840 }
6841 |
6842 {
6843 $$=EMPTY; }
6844 ;
6845
6846
6847 GrantStmt:
6848 GRANT privileges ON privilege_target TO grantee_list opt_grant_grant_option
6849 {
6850 $$ = cat_str(7,mm_strdup("grant"),$2,mm_strdup("on"),$4,mm_strdup("to"),$6,$7);
6851 }
6852 ;
6853
6854
6855 RevokeStmt:
6856 REVOKE privileges ON privilege_target FROM grantee_list opt_drop_behavior
6857 {
6858 $$ = cat_str(7,mm_strdup("revoke"),$2,mm_strdup("on"),$4,mm_strdup("from"),$6,$7);
6859 }
6860 | REVOKE GRANT OPTION FOR privileges ON privilege_target FROM grantee_list opt_drop_behavior
6861 {
6862 $$ = cat_str(7,mm_strdup("revoke grant option for"),$5,mm_strdup("on"),$7,mm_strdup("from"),$9,$10);
6863 }
6864 ;
6865
6866
6867 privileges:
6868 privilege_list
6869 {
6870 $$ = $1;
6871 }
6872 | ALL
6873 {
6874 $$ = mm_strdup("all");
6875 }
6876 | ALL PRIVILEGES
6877 {
6878 $$ = mm_strdup("all privileges");
6879 }
6880 | ALL '(' columnList ')'
6881 {
6882 $$ = cat_str(3,mm_strdup("all ("),$3,mm_strdup(")"));
6883 }
6884 | ALL PRIVILEGES '(' columnList ')'
6885 {
6886 $$ = cat_str(3,mm_strdup("all privileges ("),$4,mm_strdup(")"));
6887 }
6888 ;
6889
6890
6891 privilege_list:
6892 privilege
6893 {
6894 $$ = $1;
6895 }
6896 | privilege_list ',' privilege
6897 {
6898 $$ = cat_str(3,$1,mm_strdup(","),$3);
6899 }
6900 ;
6901
6902
6903 privilege:
6904 SELECT opt_column_list
6905 {
6906 $$ = cat_str(2,mm_strdup("select"),$2);
6907 }
6908 | REFERENCES opt_column_list
6909 {
6910 $$ = cat_str(2,mm_strdup("references"),$2);
6911 }
6912 | CREATE opt_column_list
6913 {
6914 $$ = cat_str(2,mm_strdup("create"),$2);
6915 }
6916 | ColId opt_column_list
6917 {
6918 $$ = cat_str(2,$1,$2);
6919 }
6920 ;
6921
6922
6923 privilege_target:
6924 qualified_name_list
6925 {
6926 $$ = $1;
6927 }
6928 | TABLE qualified_name_list
6929 {
6930 $$ = cat_str(2,mm_strdup("table"),$2);
6931 }
6932 | SEQUENCE qualified_name_list
6933 {
6934 $$ = cat_str(2,mm_strdup("sequence"),$2);
6935 }
6936 | FOREIGN DATA_P WRAPPER name_list
6937 {
6938 $$ = cat_str(2,mm_strdup("foreign data wrapper"),$4);
6939 }
6940 | FOREIGN SERVER name_list
6941 {
6942 $$ = cat_str(2,mm_strdup("foreign server"),$3);
6943 }
6944 | FUNCTION function_with_argtypes_list
6945 {
6946 $$ = cat_str(2,mm_strdup("function"),$2);
6947 }
6948 | PROCEDURE function_with_argtypes_list
6949 {
6950 $$ = cat_str(2,mm_strdup("procedure"),$2);
6951 }
6952 | ROUTINE function_with_argtypes_list
6953 {
6954 $$ = cat_str(2,mm_strdup("routine"),$2);
6955 }
6956 | DATABASE name_list
6957 {
6958 $$ = cat_str(2,mm_strdup("database"),$2);
6959 }
6960 | DOMAIN_P any_name_list
6961 {
6962 $$ = cat_str(2,mm_strdup("domain"),$2);
6963 }
6964 | LANGUAGE name_list
6965 {
6966 $$ = cat_str(2,mm_strdup("language"),$2);
6967 }
6968 | LARGE_P OBJECT_P NumericOnly_list
6969 {
6970 $$ = cat_str(2,mm_strdup("large object"),$3);
6971 }
6972 | SCHEMA name_list
6973 {
6974 $$ = cat_str(2,mm_strdup("schema"),$2);
6975 }
6976 | TABLESPACE name_list
6977 {
6978 $$ = cat_str(2,mm_strdup("tablespace"),$2);
6979 }
6980 | TYPE_P any_name_list
6981 {
6982 $$ = cat_str(2,mm_strdup("type"),$2);
6983 }
6984 | ALL TABLES IN_P SCHEMA name_list
6985 {
6986 $$ = cat_str(2,mm_strdup("all tables in schema"),$5);
6987 }
6988 | ALL SEQUENCES IN_P SCHEMA name_list
6989 {
6990 $$ = cat_str(2,mm_strdup("all sequences in schema"),$5);
6991 }
6992 | ALL FUNCTIONS IN_P SCHEMA name_list
6993 {
6994 $$ = cat_str(2,mm_strdup("all functions in schema"),$5);
6995 }
6996 | ALL PROCEDURES IN_P SCHEMA name_list
6997 {
6998 $$ = cat_str(2,mm_strdup("all procedures in schema"),$5);
6999 }
7000 | ALL ROUTINES IN_P SCHEMA name_list
7001 {
7002 $$ = cat_str(2,mm_strdup("all routines in schema"),$5);
7003 }
7004 ;
7005
7006
7007 grantee_list:
7008 grantee
7009 {
7010 $$ = $1;
7011 }
7012 | grantee_list ',' grantee
7013 {
7014 $$ = cat_str(3,$1,mm_strdup(","),$3);
7015 }
7016 ;
7017
7018
7019 grantee:
7020 RoleSpec
7021 {
7022 $$ = $1;
7023 }
7024 | GROUP_P RoleSpec
7025 {
7026 $$ = cat_str(2,mm_strdup("group"),$2);
7027 }
7028 ;
7029
7030
7031 opt_grant_grant_option:
7032 WITH GRANT OPTION
7033 {
7034 $$ = mm_strdup("with grant option");
7035 }
7036 |
7037 {
7038 $$=EMPTY; }
7039 ;
7040
7041
7042 GrantRoleStmt:
7043 GRANT privilege_list TO role_list opt_grant_admin_option opt_granted_by
7044 {
7045 $$ = cat_str(6,mm_strdup("grant"),$2,mm_strdup("to"),$4,$5,$6);
7046 }
7047 ;
7048
7049
7050 RevokeRoleStmt:
7051 REVOKE privilege_list FROM role_list opt_granted_by opt_drop_behavior
7052 {
7053 $$ = cat_str(6,mm_strdup("revoke"),$2,mm_strdup("from"),$4,$5,$6);
7054 }
7055 | REVOKE ADMIN OPTION FOR privilege_list FROM role_list opt_granted_by opt_drop_behavior
7056 {
7057 $$ = cat_str(6,mm_strdup("revoke admin option for"),$5,mm_strdup("from"),$7,$8,$9);
7058 }
7059 ;
7060
7061
7062 opt_grant_admin_option:
7063 WITH ADMIN OPTION
7064 {
7065 $$ = mm_strdup("with admin option");
7066 }
7067 |
7068 {
7069 $$=EMPTY; }
7070 ;
7071
7072
7073 opt_granted_by:
7074 GRANTED BY RoleSpec
7075 {
7076 $$ = cat_str(2,mm_strdup("granted by"),$3);
7077 }
7078 |
7079 {
7080 $$=EMPTY; }
7081 ;
7082
7083
7084 AlterDefaultPrivilegesStmt:
7085 ALTER DEFAULT PRIVILEGES DefACLOptionList DefACLAction
7086 {
7087 $$ = cat_str(3,mm_strdup("alter default privileges"),$4,$5);
7088 }
7089 ;
7090
7091
7092 DefACLOptionList:
7093 DefACLOptionList DefACLOption
7094 {
7095 $$ = cat_str(2,$1,$2);
7096 }
7097 |
7098 {
7099 $$=EMPTY; }
7100 ;
7101
7102
7103 DefACLOption:
7104 IN_P SCHEMA name_list
7105 {
7106 $$ = cat_str(2,mm_strdup("in schema"),$3);
7107 }
7108 | FOR ROLE role_list
7109 {
7110 $$ = cat_str(2,mm_strdup("for role"),$3);
7111 }
7112 | FOR USER role_list
7113 {
7114 $$ = cat_str(2,mm_strdup("for user"),$3);
7115 }
7116 ;
7117
7118
7119 DefACLAction:
7120 GRANT privileges ON defacl_privilege_target TO grantee_list opt_grant_grant_option
7121 {
7122 $$ = cat_str(7,mm_strdup("grant"),$2,mm_strdup("on"),$4,mm_strdup("to"),$6,$7);
7123 }
7124 | REVOKE privileges ON defacl_privilege_target FROM grantee_list opt_drop_behavior
7125 {
7126 $$ = cat_str(7,mm_strdup("revoke"),$2,mm_strdup("on"),$4,mm_strdup("from"),$6,$7);
7127 }
7128 | REVOKE GRANT OPTION FOR privileges ON defacl_privilege_target FROM grantee_list opt_drop_behavior
7129 {
7130 $$ = cat_str(7,mm_strdup("revoke grant option for"),$5,mm_strdup("on"),$7,mm_strdup("from"),$9,$10);
7131 }
7132 ;
7133
7134
7135 defacl_privilege_target:
7136 TABLES
7137 {
7138 $$ = mm_strdup("tables");
7139 }
7140 | FUNCTIONS
7141 {
7142 $$ = mm_strdup("functions");
7143 }
7144 | ROUTINES
7145 {
7146 $$ = mm_strdup("routines");
7147 }
7148 | SEQUENCES
7149 {
7150 $$ = mm_strdup("sequences");
7151 }
7152 | TYPES_P
7153 {
7154 $$ = mm_strdup("types");
7155 }
7156 | SCHEMAS
7157 {
7158 $$ = mm_strdup("schemas");
7159 }
7160 ;
7161
7162
7163 IndexStmt:
7164 CREATE opt_unique INDEX opt_concurrently opt_index_name ON relation_expr access_method_clause '(' index_params ')' opt_include opt_reloptions OptTableSpace where_clause
7165 {
7166 $$ = 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);
7167 }
7168 | 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
7169 {
7170 $$ = 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);
7171 }
7172 ;
7173
7174
7175 opt_unique:
7176 UNIQUE
7177 {
7178 $$ = mm_strdup("unique");
7179 }
7180 |
7181 {
7182 $$=EMPTY; }
7183 ;
7184
7185
7186 opt_concurrently:
7187 CONCURRENTLY
7188 {
7189 $$ = mm_strdup("concurrently");
7190 }
7191 |
7192 {
7193 $$=EMPTY; }
7194 ;
7195
7196
7197 opt_index_name:
7198 index_name
7199 {
7200 $$ = $1;
7201 }
7202 |
7203 {
7204 $$=EMPTY; }
7205 ;
7206
7207
7208 access_method_clause:
7209 USING access_method
7210 {
7211 $$ = cat_str(2,mm_strdup("using"),$2);
7212 }
7213 |
7214 {
7215 $$=EMPTY; }
7216 ;
7217
7218
7219 index_params:
7220 index_elem
7221 {
7222 $$ = $1;
7223 }
7224 | index_params ',' index_elem
7225 {
7226 $$ = cat_str(3,$1,mm_strdup(","),$3);
7227 }
7228 ;
7229
7230
7231 index_elem_options:
7232 opt_collate opt_class opt_asc_desc opt_nulls_order
7233 {
7234 $$ = cat_str(4,$1,$2,$3,$4);
7235 }
7236 | opt_collate any_name reloptions opt_asc_desc opt_nulls_order
7237 {
7238 $$ = cat_str(5,$1,$2,$3,$4,$5);
7239 }
7240 ;
7241
7242
7243 index_elem:
7244 ColId index_elem_options
7245 {
7246 $$ = cat_str(2,$1,$2);
7247 }
7248 | func_expr_windowless index_elem_options
7249 {
7250 $$ = cat_str(2,$1,$2);
7251 }
7252 | '(' a_expr ')' index_elem_options
7253 {
7254 $$ = cat_str(4,mm_strdup("("),$2,mm_strdup(")"),$4);
7255 }
7256 ;
7257
7258
7259 opt_include:
7260 INCLUDE '(' index_including_params ')'
7261 {
7262 $$ = cat_str(3,mm_strdup("include ("),$3,mm_strdup(")"));
7263 }
7264 |
7265 {
7266 $$=EMPTY; }
7267 ;
7268
7269
7270 index_including_params:
7271 index_elem
7272 {
7273 $$ = $1;
7274 }
7275 | index_including_params ',' index_elem
7276 {
7277 $$ = cat_str(3,$1,mm_strdup(","),$3);
7278 }
7279 ;
7280
7281
7282 opt_collate:
7283 COLLATE any_name
7284 {
7285 $$ = cat_str(2,mm_strdup("collate"),$2);
7286 }
7287 |
7288 {
7289 $$=EMPTY; }
7290 ;
7291
7292
7293 opt_class:
7294 any_name
7295 {
7296 $$ = $1;
7297 }
7298 |
7299 {
7300 $$=EMPTY; }
7301 ;
7302
7303
7304 opt_asc_desc:
7305 ASC
7306 {
7307 $$ = mm_strdup("asc");
7308 }
7309 | DESC
7310 {
7311 $$ = mm_strdup("desc");
7312 }
7313 |
7314 {
7315 $$=EMPTY; }
7316 ;
7317
7318
7319 opt_nulls_order:
7320 NULLS_LA FIRST_P
7321 {
7322 $$ = mm_strdup("nulls first");
7323 }
7324 | NULLS_LA LAST_P
7325 {
7326 $$ = mm_strdup("nulls last");
7327 }
7328 |
7329 {
7330 $$=EMPTY; }
7331 ;
7332
7333
7334 CreateFunctionStmt:
7335 CREATE opt_or_replace FUNCTION func_name func_args_with_defaults RETURNS func_return createfunc_opt_list
7336 {
7337 $$ = cat_str(8,mm_strdup("create"),$2,mm_strdup("function"),$4,$5,mm_strdup("returns"),$7,$8);
7338 }
7339 | CREATE opt_or_replace FUNCTION func_name func_args_with_defaults RETURNS TABLE '(' table_func_column_list ')' createfunc_opt_list
7340 {
7341 $$ = cat_str(9,mm_strdup("create"),$2,mm_strdup("function"),$4,$5,mm_strdup("returns table ("),$9,mm_strdup(")"),$11);
7342 }
7343 | CREATE opt_or_replace FUNCTION func_name func_args_with_defaults createfunc_opt_list
7344 {
7345 $$ = cat_str(6,mm_strdup("create"),$2,mm_strdup("function"),$4,$5,$6);
7346 }
7347 | CREATE opt_or_replace PROCEDURE func_name func_args_with_defaults createfunc_opt_list
7348 {
7349 $$ = cat_str(6,mm_strdup("create"),$2,mm_strdup("procedure"),$4,$5,$6);
7350 }
7351 ;
7352
7353
7354 opt_or_replace:
7355 OR REPLACE
7356 {
7357 $$ = mm_strdup("or replace");
7358 }
7359 |
7360 {
7361 $$=EMPTY; }
7362 ;
7363
7364
7365 func_args:
7366 '(' func_args_list ')'
7367 {
7368 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
7369 }
7370 | '(' ')'
7371 {
7372 $$ = mm_strdup("( )");
7373 }
7374 ;
7375
7376
7377 func_args_list:
7378 func_arg
7379 {
7380 $$ = $1;
7381 }
7382 | func_args_list ',' func_arg
7383 {
7384 $$ = cat_str(3,$1,mm_strdup(","),$3);
7385 }
7386 ;
7387
7388
7389 function_with_argtypes_list:
7390 function_with_argtypes
7391 {
7392 $$ = $1;
7393 }
7394 | function_with_argtypes_list ',' function_with_argtypes
7395 {
7396 $$ = cat_str(3,$1,mm_strdup(","),$3);
7397 }
7398 ;
7399
7400
7401 function_with_argtypes:
7402 func_name func_args
7403 {
7404 $$ = cat_str(2,$1,$2);
7405 }
7406 | type_func_name_keyword
7407 {
7408 $$ = $1;
7409 }
7410 | ColId
7411 {
7412 $$ = $1;
7413 }
7414 | ColId indirection
7415 {
7416 $$ = cat_str(2,$1,$2);
7417 }
7418 ;
7419
7420
7421 func_args_with_defaults:
7422 '(' func_args_with_defaults_list ')'
7423 {
7424 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
7425 }
7426 | '(' ')'
7427 {
7428 $$ = mm_strdup("( )");
7429 }
7430 ;
7431
7432
7433 func_args_with_defaults_list:
7434 func_arg_with_default
7435 {
7436 $$ = $1;
7437 }
7438 | func_args_with_defaults_list ',' func_arg_with_default
7439 {
7440 $$ = cat_str(3,$1,mm_strdup(","),$3);
7441 }
7442 ;
7443
7444
7445 func_arg:
7446 arg_class param_name func_type
7447 {
7448 $$ = cat_str(3,$1,$2,$3);
7449 }
7450 | param_name arg_class func_type
7451 {
7452 $$ = cat_str(3,$1,$2,$3);
7453 }
7454 | param_name func_type
7455 {
7456 $$ = cat_str(2,$1,$2);
7457 }
7458 | arg_class func_type
7459 {
7460 $$ = cat_str(2,$1,$2);
7461 }
7462 | func_type
7463 {
7464 $$ = $1;
7465 }
7466 ;
7467
7468
7469 arg_class:
7470 IN_P
7471 {
7472 $$ = mm_strdup("in");
7473 }
7474 | OUT_P
7475 {
7476 $$ = mm_strdup("out");
7477 }
7478 | INOUT
7479 {
7480 $$ = mm_strdup("inout");
7481 }
7482 | IN_P OUT_P
7483 {
7484 $$ = mm_strdup("in out");
7485 }
7486 | VARIADIC
7487 {
7488 $$ = mm_strdup("variadic");
7489 }
7490 ;
7491
7492
7493 param_name:
7494 type_function_name
7495 {
7496 $$ = $1;
7497 }
7498 ;
7499
7500
7501 func_return:
7502 func_type
7503 {
7504 $$ = $1;
7505 }
7506 ;
7507
7508
7509 func_type:
7510 Typename
7511 {
7512 $$ = $1;
7513 }
7514 | type_function_name attrs '%' TYPE_P
7515 {
7516 $$ = cat_str(3,$1,$2,mm_strdup("% type"));
7517 }
7518 | SETOF type_function_name attrs '%' TYPE_P
7519 {
7520 $$ = cat_str(4,mm_strdup("setof"),$2,$3,mm_strdup("% type"));
7521 }
7522 ;
7523
7524
7525 func_arg_with_default:
7526 func_arg
7527 {
7528 $$ = $1;
7529 }
7530 | func_arg DEFAULT a_expr
7531 {
7532 $$ = cat_str(3,$1,mm_strdup("default"),$3);
7533 }
7534 | func_arg '=' a_expr
7535 {
7536 $$ = cat_str(3,$1,mm_strdup("="),$3);
7537 }
7538 ;
7539
7540
7541 aggr_arg:
7542 func_arg
7543 {
7544 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
7545 $$ = $1;
7546 }
7547 ;
7548
7549
7550 aggr_args:
7551 '(' '*' ')'
7552 {
7553 $$ = mm_strdup("( * )");
7554 }
7555 | '(' aggr_args_list ')'
7556 {
7557 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
7558 }
7559 | '(' ORDER BY aggr_args_list ')'
7560 {
7561 $$ = cat_str(3,mm_strdup("( order by"),$4,mm_strdup(")"));
7562 }
7563 | '(' aggr_args_list ORDER BY aggr_args_list ')'
7564 {
7565 $$ = cat_str(5,mm_strdup("("),$2,mm_strdup("order by"),$5,mm_strdup(")"));
7566 }
7567 ;
7568
7569
7570 aggr_args_list:
7571 aggr_arg
7572 {
7573 $$ = $1;
7574 }
7575 | aggr_args_list ',' aggr_arg
7576 {
7577 $$ = cat_str(3,$1,mm_strdup(","),$3);
7578 }
7579 ;
7580
7581
7582 aggregate_with_argtypes:
7583 func_name aggr_args
7584 {
7585 $$ = cat_str(2,$1,$2);
7586 }
7587 ;
7588
7589
7590 aggregate_with_argtypes_list:
7591 aggregate_with_argtypes
7592 {
7593 $$ = $1;
7594 }
7595 | aggregate_with_argtypes_list ',' aggregate_with_argtypes
7596 {
7597 $$ = cat_str(3,$1,mm_strdup(","),$3);
7598 }
7599 ;
7600
7601
7602 createfunc_opt_list:
7603 createfunc_opt_item
7604 {
7605 $$ = $1;
7606 }
7607 | createfunc_opt_list createfunc_opt_item
7608 {
7609 $$ = cat_str(2,$1,$2);
7610 }
7611 ;
7612
7613
7614 common_func_opt_item:
7615 CALLED ON NULL_P INPUT_P
7616 {
7617 $$ = mm_strdup("called on null input");
7618 }
7619 | RETURNS NULL_P ON NULL_P INPUT_P
7620 {
7621 $$ = mm_strdup("returns null on null input");
7622 }
7623 | STRICT_P
7624 {
7625 $$ = mm_strdup("strict");
7626 }
7627 | IMMUTABLE
7628 {
7629 $$ = mm_strdup("immutable");
7630 }
7631 | STABLE
7632 {
7633 $$ = mm_strdup("stable");
7634 }
7635 | VOLATILE
7636 {
7637 $$ = mm_strdup("volatile");
7638 }
7639 | EXTERNAL SECURITY DEFINER
7640 {
7641 $$ = mm_strdup("external security definer");
7642 }
7643 | EXTERNAL SECURITY INVOKER
7644 {
7645 $$ = mm_strdup("external security invoker");
7646 }
7647 | SECURITY DEFINER
7648 {
7649 $$ = mm_strdup("security definer");
7650 }
7651 | SECURITY INVOKER
7652 {
7653 $$ = mm_strdup("security invoker");
7654 }
7655 | LEAKPROOF
7656 {
7657 $$ = mm_strdup("leakproof");
7658 }
7659 | NOT LEAKPROOF
7660 {
7661 $$ = mm_strdup("not leakproof");
7662 }
7663 | COST NumericOnly
7664 {
7665 $$ = cat_str(2,mm_strdup("cost"),$2);
7666 }
7667 | ROWS NumericOnly
7668 {
7669 $$ = cat_str(2,mm_strdup("rows"),$2);
7670 }
7671 | SUPPORT any_name
7672 {
7673 $$ = cat_str(2,mm_strdup("support"),$2);
7674 }
7675 | FunctionSetResetClause
7676 {
7677 $$ = $1;
7678 }
7679 | PARALLEL ColId
7680 {
7681 $$ = cat_str(2,mm_strdup("parallel"),$2);
7682 }
7683 ;
7684
7685
7686 createfunc_opt_item:
7687 AS func_as
7688 {
7689 $$ = cat_str(2,mm_strdup("as"),$2);
7690 }
7691 | LANGUAGE NonReservedWord_or_Sconst
7692 {
7693 $$ = cat_str(2,mm_strdup("language"),$2);
7694 }
7695 | TRANSFORM transform_type_list
7696 {
7697 $$ = cat_str(2,mm_strdup("transform"),$2);
7698 }
7699 | WINDOW
7700 {
7701 $$ = mm_strdup("window");
7702 }
7703 | common_func_opt_item
7704 {
7705 $$ = $1;
7706 }
7707 ;
7708
7709
7710 func_as:
7711 ecpg_sconst
7712 {
7713 $$ = $1;
7714 }
7715 | ecpg_sconst ',' ecpg_sconst
7716 {
7717 $$ = cat_str(3,$1,mm_strdup(","),$3);
7718 }
7719 ;
7720
7721
7722 transform_type_list:
7723 FOR TYPE_P Typename
7724 {
7725 $$ = cat_str(2,mm_strdup("for type"),$3);
7726 }
7727 | transform_type_list ',' FOR TYPE_P Typename
7728 {
7729 $$ = cat_str(3,$1,mm_strdup(", for type"),$5);
7730 }
7731 ;
7732
7733
7734 opt_definition:
7735 WITH definition
7736 {
7737 $$ = cat_str(2,mm_strdup("with"),$2);
7738 }
7739 |
7740 {
7741 $$=EMPTY; }
7742 ;
7743
7744
7745 table_func_column:
7746 param_name func_type
7747 {
7748 $$ = cat_str(2,$1,$2);
7749 }
7750 ;
7751
7752
7753 table_func_column_list:
7754 table_func_column
7755 {
7756 $$ = $1;
7757 }
7758 | table_func_column_list ',' table_func_column
7759 {
7760 $$ = cat_str(3,$1,mm_strdup(","),$3);
7761 }
7762 ;
7763
7764
7765 AlterFunctionStmt:
7766 ALTER FUNCTION function_with_argtypes alterfunc_opt_list opt_restrict
7767 {
7768 $$ = cat_str(4,mm_strdup("alter function"),$3,$4,$5);
7769 }
7770 | ALTER PROCEDURE function_with_argtypes alterfunc_opt_list opt_restrict
7771 {
7772 $$ = cat_str(4,mm_strdup("alter procedure"),$3,$4,$5);
7773 }
7774 | ALTER ROUTINE function_with_argtypes alterfunc_opt_list opt_restrict
7775 {
7776 $$ = cat_str(4,mm_strdup("alter routine"),$3,$4,$5);
7777 }
7778 ;
7779
7780
7781 alterfunc_opt_list:
7782 common_func_opt_item
7783 {
7784 $$ = $1;
7785 }
7786 | alterfunc_opt_list common_func_opt_item
7787 {
7788 $$ = cat_str(2,$1,$2);
7789 }
7790 ;
7791
7792
7793 opt_restrict:
7794 RESTRICT
7795 {
7796 $$ = mm_strdup("restrict");
7797 }
7798 |
7799 {
7800 $$=EMPTY; }
7801 ;
7802
7803
7804 RemoveFuncStmt:
7805 DROP FUNCTION function_with_argtypes_list opt_drop_behavior
7806 {
7807 $$ = cat_str(3,mm_strdup("drop function"),$3,$4);
7808 }
7809 | DROP FUNCTION IF_P EXISTS function_with_argtypes_list opt_drop_behavior
7810 {
7811 $$ = cat_str(3,mm_strdup("drop function if exists"),$5,$6);
7812 }
7813 | DROP PROCEDURE function_with_argtypes_list opt_drop_behavior
7814 {
7815 $$ = cat_str(3,mm_strdup("drop procedure"),$3,$4);
7816 }
7817 | DROP PROCEDURE IF_P EXISTS function_with_argtypes_list opt_drop_behavior
7818 {
7819 $$ = cat_str(3,mm_strdup("drop procedure if exists"),$5,$6);
7820 }
7821 | DROP ROUTINE function_with_argtypes_list opt_drop_behavior
7822 {
7823 $$ = cat_str(3,mm_strdup("drop routine"),$3,$4);
7824 }
7825 | DROP ROUTINE IF_P EXISTS function_with_argtypes_list opt_drop_behavior
7826 {
7827 $$ = cat_str(3,mm_strdup("drop routine if exists"),$5,$6);
7828 }
7829 ;
7830
7831
7832 RemoveAggrStmt:
7833 DROP AGGREGATE aggregate_with_argtypes_list opt_drop_behavior
7834 {
7835 $$ = cat_str(3,mm_strdup("drop aggregate"),$3,$4);
7836 }
7837 | DROP AGGREGATE IF_P EXISTS aggregate_with_argtypes_list opt_drop_behavior
7838 {
7839 $$ = cat_str(3,mm_strdup("drop aggregate if exists"),$5,$6);
7840 }
7841 ;
7842
7843
7844 RemoveOperStmt:
7845 DROP OPERATOR operator_with_argtypes_list opt_drop_behavior
7846 {
7847 $$ = cat_str(3,mm_strdup("drop operator"),$3,$4);
7848 }
7849 | DROP OPERATOR IF_P EXISTS operator_with_argtypes_list opt_drop_behavior
7850 {
7851 $$ = cat_str(3,mm_strdup("drop operator if exists"),$5,$6);
7852 }
7853 ;
7854
7855
7856 oper_argtypes:
7857 '(' Typename ')'
7858 {
7859 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
7860 }
7861 | '(' Typename ',' Typename ')'
7862 {
7863 $$ = cat_str(5,mm_strdup("("),$2,mm_strdup(","),$4,mm_strdup(")"));
7864 }
7865 | '(' NONE ',' Typename ')'
7866 {
7867 $$ = cat_str(3,mm_strdup("( none ,"),$4,mm_strdup(")"));
7868 }
7869 | '(' Typename ',' NONE ')'
7870 {
7871 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(", none )"));
7872 }
7873 ;
7874
7875
7876 any_operator:
7877 all_Op
7878 {
7879 $$ = $1;
7880 }
7881 | ColId '.' any_operator
7882 {
7883 $$ = cat_str(3,$1,mm_strdup("."),$3);
7884 }
7885 ;
7886
7887
7888 operator_with_argtypes_list:
7889 operator_with_argtypes
7890 {
7891 $$ = $1;
7892 }
7893 | operator_with_argtypes_list ',' operator_with_argtypes
7894 {
7895 $$ = cat_str(3,$1,mm_strdup(","),$3);
7896 }
7897 ;
7898
7899
7900 operator_with_argtypes:
7901 any_operator oper_argtypes
7902 {
7903 $$ = cat_str(2,$1,$2);
7904 }
7905 ;
7906
7907
7908 DoStmt:
7909 DO dostmt_opt_list
7910 {
7911 $$ = cat_str(2,mm_strdup("do"),$2);
7912 }
7913 ;
7914
7915
7916 dostmt_opt_list:
7917 dostmt_opt_item
7918 {
7919 $$ = $1;
7920 }
7921 | dostmt_opt_list dostmt_opt_item
7922 {
7923 $$ = cat_str(2,$1,$2);
7924 }
7925 ;
7926
7927
7928 dostmt_opt_item:
7929 ecpg_sconst
7930 {
7931 $$ = $1;
7932 }
7933 | LANGUAGE NonReservedWord_or_Sconst
7934 {
7935 $$ = cat_str(2,mm_strdup("language"),$2);
7936 }
7937 ;
7938
7939
7940 CreateCastStmt:
7941 CREATE CAST '(' Typename AS Typename ')' WITH FUNCTION function_with_argtypes cast_context
7942 {
7943 $$ = cat_str(7,mm_strdup("create cast ("),$4,mm_strdup("as"),$6,mm_strdup(") with function"),$10,$11);
7944 }
7945 | CREATE CAST '(' Typename AS Typename ')' WITHOUT FUNCTION cast_context
7946 {
7947 $$ = cat_str(6,mm_strdup("create cast ("),$4,mm_strdup("as"),$6,mm_strdup(") without function"),$10);
7948 }
7949 | CREATE CAST '(' Typename AS Typename ')' WITH INOUT cast_context
7950 {
7951 $$ = cat_str(6,mm_strdup("create cast ("),$4,mm_strdup("as"),$6,mm_strdup(") with inout"),$10);
7952 }
7953 ;
7954
7955
7956 cast_context:
7957 AS IMPLICIT_P
7958 {
7959 $$ = mm_strdup("as implicit");
7960 }
7961 | AS ASSIGNMENT
7962 {
7963 $$ = mm_strdup("as assignment");
7964 }
7965 |
7966 {
7967 $$=EMPTY; }
7968 ;
7969
7970
7971 DropCastStmt:
7972 DROP CAST opt_if_exists '(' Typename AS Typename ')' opt_drop_behavior
7973 {
7974 $$ = cat_str(8,mm_strdup("drop cast"),$3,mm_strdup("("),$5,mm_strdup("as"),$7,mm_strdup(")"),$9);
7975 }
7976 ;
7977
7978
7979 opt_if_exists:
7980 IF_P EXISTS
7981 {
7982 $$ = mm_strdup("if exists");
7983 }
7984 |
7985 {
7986 $$=EMPTY; }
7987 ;
7988
7989
7990 CreateTransformStmt:
7991 CREATE opt_or_replace TRANSFORM FOR Typename LANGUAGE name '(' transform_element_list ')'
7992 {
7993 $$ = cat_str(9,mm_strdup("create"),$2,mm_strdup("transform for"),$5,mm_strdup("language"),$7,mm_strdup("("),$9,mm_strdup(")"));
7994 }
7995 ;
7996
7997
7998 transform_element_list:
7999 FROM SQL_P WITH FUNCTION function_with_argtypes ',' TO SQL_P WITH FUNCTION function_with_argtypes
8000 {
8001 $$ = cat_str(4,mm_strdup("from sql with function"),$5,mm_strdup(", to sql with function"),$11);
8002 }
8003 | TO SQL_P WITH FUNCTION function_with_argtypes ',' FROM SQL_P WITH FUNCTION function_with_argtypes
8004 {
8005 $$ = cat_str(4,mm_strdup("to sql with function"),$5,mm_strdup(", from sql with function"),$11);
8006 }
8007 | FROM SQL_P WITH FUNCTION function_with_argtypes
8008 {
8009 $$ = cat_str(2,mm_strdup("from sql with function"),$5);
8010 }
8011 | TO SQL_P WITH FUNCTION function_with_argtypes
8012 {
8013 $$ = cat_str(2,mm_strdup("to sql with function"),$5);
8014 }
8015 ;
8016
8017
8018 DropTransformStmt:
8019 DROP TRANSFORM opt_if_exists FOR Typename LANGUAGE name opt_drop_behavior
8020 {
8021 $$ = cat_str(7,mm_strdup("drop transform"),$3,mm_strdup("for"),$5,mm_strdup("language"),$7,$8);
8022 }
8023 ;
8024
8025
8026 ReindexStmt:
8027 REINDEX reindex_target_type opt_concurrently qualified_name
8028 {
8029 $$ = cat_str(4,mm_strdup("reindex"),$2,$3,$4);
8030 }
8031 | REINDEX reindex_target_multitable opt_concurrently name
8032 {
8033 $$ = cat_str(4,mm_strdup("reindex"),$2,$3,$4);
8034 }
8035 | REINDEX '(' reindex_option_list ')' reindex_target_type opt_concurrently qualified_name
8036 {
8037 $$ = cat_str(6,mm_strdup("reindex ("),$3,mm_strdup(")"),$5,$6,$7);
8038 }
8039 | REINDEX '(' reindex_option_list ')' reindex_target_multitable opt_concurrently name
8040 {
8041 $$ = cat_str(6,mm_strdup("reindex ("),$3,mm_strdup(")"),$5,$6,$7);
8042 }
8043 ;
8044
8045
8046 reindex_target_type:
8047 INDEX
8048 {
8049 $$ = mm_strdup("index");
8050 }
8051 | TABLE
8052 {
8053 $$ = mm_strdup("table");
8054 }
8055 ;
8056
8057
8058 reindex_target_multitable:
8059 SCHEMA
8060 {
8061 $$ = mm_strdup("schema");
8062 }
8063 | SYSTEM_P
8064 {
8065 $$ = mm_strdup("system");
8066 }
8067 | DATABASE
8068 {
8069 $$ = mm_strdup("database");
8070 }
8071 ;
8072
8073
8074 reindex_option_list:
8075 reindex_option_elem
8076 {
8077 $$ = $1;
8078 }
8079 | reindex_option_list ',' reindex_option_elem
8080 {
8081 $$ = cat_str(3,$1,mm_strdup(","),$3);
8082 }
8083 ;
8084
8085
8086 reindex_option_elem:
8087 VERBOSE
8088 {
8089 $$ = mm_strdup("verbose");
8090 }
8091 ;
8092
8093
8094 AlterTblSpcStmt:
8095 ALTER TABLESPACE name SET reloptions
8096 {
8097 $$ = cat_str(4,mm_strdup("alter tablespace"),$3,mm_strdup("set"),$5);
8098 }
8099 | ALTER TABLESPACE name RESET reloptions
8100 {
8101 $$ = cat_str(4,mm_strdup("alter tablespace"),$3,mm_strdup("reset"),$5);
8102 }
8103 ;
8104
8105
8106 RenameStmt:
8107 ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
8108 {
8109 $$ = cat_str(4,mm_strdup("alter aggregate"),$3,mm_strdup("rename to"),$6);
8110 }
8111 | ALTER COLLATION any_name RENAME TO name
8112 {
8113 $$ = cat_str(4,mm_strdup("alter collation"),$3,mm_strdup("rename to"),$6);
8114 }
8115 | ALTER CONVERSION_P any_name RENAME TO name
8116 {
8117 $$ = cat_str(4,mm_strdup("alter conversion"),$3,mm_strdup("rename to"),$6);
8118 }
8119 | ALTER DATABASE database_name RENAME TO database_name
8120 {
8121 $$ = cat_str(4,mm_strdup("alter database"),$3,mm_strdup("rename to"),$6);
8122 }
8123 | ALTER DOMAIN_P any_name RENAME TO name
8124 {
8125 $$ = cat_str(4,mm_strdup("alter domain"),$3,mm_strdup("rename to"),$6);
8126 }
8127 | ALTER DOMAIN_P any_name RENAME CONSTRAINT name TO name
8128 {
8129 $$ = cat_str(6,mm_strdup("alter domain"),$3,mm_strdup("rename constraint"),$6,mm_strdup("to"),$8);
8130 }
8131 | ALTER FOREIGN DATA_P WRAPPER name RENAME TO name
8132 {
8133 $$ = cat_str(4,mm_strdup("alter foreign data wrapper"),$5,mm_strdup("rename to"),$8);
8134 }
8135 | ALTER FUNCTION function_with_argtypes RENAME TO name
8136 {
8137 $$ = cat_str(4,mm_strdup("alter function"),$3,mm_strdup("rename to"),$6);
8138 }
8139 | ALTER GROUP_P RoleId RENAME TO RoleId
8140 {
8141 $$ = cat_str(4,mm_strdup("alter group"),$3,mm_strdup("rename to"),$6);
8142 }
8143 | ALTER opt_procedural LANGUAGE name RENAME TO name
8144 {
8145 $$ = cat_str(6,mm_strdup("alter"),$2,mm_strdup("language"),$4,mm_strdup("rename to"),$7);
8146 }
8147 | ALTER OPERATOR CLASS any_name USING access_method RENAME TO name
8148 {
8149 $$ = cat_str(6,mm_strdup("alter operator class"),$4,mm_strdup("using"),$6,mm_strdup("rename to"),$9);
8150 }
8151 | ALTER OPERATOR FAMILY any_name USING access_method RENAME TO name
8152 {
8153 $$ = cat_str(6,mm_strdup("alter operator family"),$4,mm_strdup("using"),$6,mm_strdup("rename to"),$9);
8154 }
8155 | ALTER POLICY name ON qualified_name RENAME TO name
8156 {
8157 $$ = cat_str(6,mm_strdup("alter policy"),$3,mm_strdup("on"),$5,mm_strdup("rename to"),$8);
8158 }
8159 | ALTER POLICY IF_P EXISTS name ON qualified_name RENAME TO name
8160 {
8161 $$ = cat_str(6,mm_strdup("alter policy if exists"),$5,mm_strdup("on"),$7,mm_strdup("rename to"),$10);
8162 }
8163 | ALTER PROCEDURE function_with_argtypes RENAME TO name
8164 {
8165 $$ = cat_str(4,mm_strdup("alter procedure"),$3,mm_strdup("rename to"),$6);
8166 }
8167 | ALTER PUBLICATION name RENAME TO name
8168 {
8169 $$ = cat_str(4,mm_strdup("alter publication"),$3,mm_strdup("rename to"),$6);
8170 }
8171 | ALTER ROUTINE function_with_argtypes RENAME TO name
8172 {
8173 $$ = cat_str(4,mm_strdup("alter routine"),$3,mm_strdup("rename to"),$6);
8174 }
8175 | ALTER SCHEMA name RENAME TO name
8176 {
8177 $$ = cat_str(4,mm_strdup("alter schema"),$3,mm_strdup("rename to"),$6);
8178 }
8179 | ALTER SERVER name RENAME TO name
8180 {
8181 $$ = cat_str(4,mm_strdup("alter server"),$3,mm_strdup("rename to"),$6);
8182 }
8183 | ALTER SUBSCRIPTION name RENAME TO name
8184 {
8185 $$ = cat_str(4,mm_strdup("alter subscription"),$3,mm_strdup("rename to"),$6);
8186 }
8187 | ALTER TABLE relation_expr RENAME TO name
8188 {
8189 $$ = cat_str(4,mm_strdup("alter table"),$3,mm_strdup("rename to"),$6);
8190 }
8191 | ALTER TABLE IF_P EXISTS relation_expr RENAME TO name
8192 {
8193 $$ = cat_str(4,mm_strdup("alter table if exists"),$5,mm_strdup("rename to"),$8);
8194 }
8195 | ALTER SEQUENCE qualified_name RENAME TO name
8196 {
8197 $$ = cat_str(4,mm_strdup("alter sequence"),$3,mm_strdup("rename to"),$6);
8198 }
8199 | ALTER SEQUENCE IF_P EXISTS qualified_name RENAME TO name
8200 {
8201 $$ = cat_str(4,mm_strdup("alter sequence if exists"),$5,mm_strdup("rename to"),$8);
8202 }
8203 | ALTER VIEW qualified_name RENAME TO name
8204 {
8205 $$ = cat_str(4,mm_strdup("alter view"),$3,mm_strdup("rename to"),$6);
8206 }
8207 | ALTER VIEW IF_P EXISTS qualified_name RENAME TO name
8208 {
8209 $$ = cat_str(4,mm_strdup("alter view if exists"),$5,mm_strdup("rename to"),$8);
8210 }
8211 | ALTER MATERIALIZED VIEW qualified_name RENAME TO name
8212 {
8213 $$ = cat_str(4,mm_strdup("alter materialized view"),$4,mm_strdup("rename to"),$7);
8214 }
8215 | ALTER MATERIALIZED VIEW IF_P EXISTS qualified_name RENAME TO name
8216 {
8217 $$ = cat_str(4,mm_strdup("alter materialized view if exists"),$6,mm_strdup("rename to"),$9);
8218 }
8219 | ALTER INDEX qualified_name RENAME TO name
8220 {
8221 $$ = cat_str(4,mm_strdup("alter index"),$3,mm_strdup("rename to"),$6);
8222 }
8223 | ALTER INDEX IF_P EXISTS qualified_name RENAME TO name
8224 {
8225 $$ = cat_str(4,mm_strdup("alter index if exists"),$5,mm_strdup("rename to"),$8);
8226 }
8227 | ALTER FOREIGN TABLE relation_expr RENAME TO name
8228 {
8229 $$ = cat_str(4,mm_strdup("alter foreign table"),$4,mm_strdup("rename to"),$7);
8230 }
8231 | ALTER FOREIGN TABLE IF_P EXISTS relation_expr RENAME TO name
8232 {
8233 $$ = cat_str(4,mm_strdup("alter foreign table if exists"),$6,mm_strdup("rename to"),$9);
8234 }
8235 | ALTER TABLE relation_expr RENAME opt_column name TO name
8236 {
8237 $$ = cat_str(7,mm_strdup("alter table"),$3,mm_strdup("rename"),$5,$6,mm_strdup("to"),$8);
8238 }
8239 | ALTER TABLE IF_P EXISTS relation_expr RENAME opt_column name TO name
8240 {
8241 $$ = cat_str(7,mm_strdup("alter table if exists"),$5,mm_strdup("rename"),$7,$8,mm_strdup("to"),$10);
8242 }
8243 | ALTER VIEW qualified_name RENAME opt_column name TO name
8244 {
8245 $$ = cat_str(7,mm_strdup("alter view"),$3,mm_strdup("rename"),$5,$6,mm_strdup("to"),$8);
8246 }
8247 | ALTER VIEW IF_P EXISTS qualified_name RENAME opt_column name TO name
8248 {
8249 $$ = cat_str(7,mm_strdup("alter view if exists"),$5,mm_strdup("rename"),$7,$8,mm_strdup("to"),$10);
8250 }
8251 | ALTER MATERIALIZED VIEW qualified_name RENAME opt_column name TO name
8252 {
8253 $$ = cat_str(7,mm_strdup("alter materialized view"),$4,mm_strdup("rename"),$6,$7,mm_strdup("to"),$9);
8254 }
8255 | ALTER MATERIALIZED VIEW IF_P EXISTS qualified_name RENAME opt_column name TO name
8256 {
8257 $$ = cat_str(7,mm_strdup("alter materialized view if exists"),$6,mm_strdup("rename"),$8,$9,mm_strdup("to"),$11);
8258 }
8259 | ALTER TABLE relation_expr RENAME CONSTRAINT name TO name
8260 {
8261 $$ = cat_str(6,mm_strdup("alter table"),$3,mm_strdup("rename constraint"),$6,mm_strdup("to"),$8);
8262 }
8263 | ALTER TABLE IF_P EXISTS relation_expr RENAME CONSTRAINT name TO name
8264 {
8265 $$ = cat_str(6,mm_strdup("alter table if exists"),$5,mm_strdup("rename constraint"),$8,mm_strdup("to"),$10);
8266 }
8267 | ALTER FOREIGN TABLE relation_expr RENAME opt_column name TO name
8268 {
8269 $$ = cat_str(7,mm_strdup("alter foreign table"),$4,mm_strdup("rename"),$6,$7,mm_strdup("to"),$9);
8270 }
8271 | ALTER FOREIGN TABLE IF_P EXISTS relation_expr RENAME opt_column name TO name
8272 {
8273 $$ = cat_str(7,mm_strdup("alter foreign table if exists"),$6,mm_strdup("rename"),$8,$9,mm_strdup("to"),$11);
8274 }
8275 | ALTER RULE name ON qualified_name RENAME TO name
8276 {
8277 $$ = cat_str(6,mm_strdup("alter rule"),$3,mm_strdup("on"),$5,mm_strdup("rename to"),$8);
8278 }
8279 | ALTER TRIGGER name ON qualified_name RENAME TO name
8280 {
8281 $$ = cat_str(6,mm_strdup("alter trigger"),$3,mm_strdup("on"),$5,mm_strdup("rename to"),$8);
8282 }
8283 | ALTER EVENT TRIGGER name RENAME TO name
8284 {
8285 $$ = cat_str(4,mm_strdup("alter event trigger"),$4,mm_strdup("rename to"),$7);
8286 }
8287 | ALTER ROLE RoleId RENAME TO RoleId
8288 {
8289 $$ = cat_str(4,mm_strdup("alter role"),$3,mm_strdup("rename to"),$6);
8290 }
8291 | ALTER USER RoleId RENAME TO RoleId
8292 {
8293 $$ = cat_str(4,mm_strdup("alter user"),$3,mm_strdup("rename to"),$6);
8294 }
8295 | ALTER TABLESPACE name RENAME TO name
8296 {
8297 $$ = cat_str(4,mm_strdup("alter tablespace"),$3,mm_strdup("rename to"),$6);
8298 }
8299 | ALTER STATISTICS any_name RENAME TO name
8300 {
8301 $$ = cat_str(4,mm_strdup("alter statistics"),$3,mm_strdup("rename to"),$6);
8302 }
8303 | ALTER TEXT_P SEARCH PARSER any_name RENAME TO name
8304 {
8305 $$ = cat_str(4,mm_strdup("alter text search parser"),$5,mm_strdup("rename to"),$8);
8306 }
8307 | ALTER TEXT_P SEARCH DICTIONARY any_name RENAME TO name
8308 {
8309 $$ = cat_str(4,mm_strdup("alter text search dictionary"),$5,mm_strdup("rename to"),$8);
8310 }
8311 | ALTER TEXT_P SEARCH TEMPLATE any_name RENAME TO name
8312 {
8313 $$ = cat_str(4,mm_strdup("alter text search template"),$5,mm_strdup("rename to"),$8);
8314 }
8315 | ALTER TEXT_P SEARCH CONFIGURATION any_name RENAME TO name
8316 {
8317 $$ = cat_str(4,mm_strdup("alter text search configuration"),$5,mm_strdup("rename to"),$8);
8318 }
8319 | ALTER TYPE_P any_name RENAME TO name
8320 {
8321 $$ = cat_str(4,mm_strdup("alter type"),$3,mm_strdup("rename to"),$6);
8322 }
8323 | ALTER TYPE_P any_name RENAME ATTRIBUTE name TO name opt_drop_behavior
8324 {
8325 $$ = cat_str(7,mm_strdup("alter type"),$3,mm_strdup("rename attribute"),$6,mm_strdup("to"),$8,$9);
8326 }
8327 ;
8328
8329
8330 opt_column:
8331 COLUMN
8332 {
8333 $$ = mm_strdup("column");
8334 }
8335 |
8336 {
8337 $$=EMPTY; }
8338 ;
8339
8340
8341 opt_set_data:
8342 SET DATA_P
8343 {
8344 $$ = mm_strdup("set data");
8345 }
8346 |
8347 {
8348 $$=EMPTY; }
8349 ;
8350
8351
8352 AlterObjectDependsStmt:
8353 ALTER FUNCTION function_with_argtypes opt_no DEPENDS ON EXTENSION name
8354 {
8355 $$ = cat_str(5,mm_strdup("alter function"),$3,$4,mm_strdup("depends on extension"),$8);
8356 }
8357 | ALTER PROCEDURE function_with_argtypes opt_no DEPENDS ON EXTENSION name
8358 {
8359 $$ = cat_str(5,mm_strdup("alter procedure"),$3,$4,mm_strdup("depends on extension"),$8);
8360 }
8361 | ALTER ROUTINE function_with_argtypes opt_no DEPENDS ON EXTENSION name
8362 {
8363 $$ = cat_str(5,mm_strdup("alter routine"),$3,$4,mm_strdup("depends on extension"),$8);
8364 }
8365 | ALTER TRIGGER name ON qualified_name opt_no DEPENDS ON EXTENSION name
8366 {
8367 $$ = cat_str(7,mm_strdup("alter trigger"),$3,mm_strdup("on"),$5,$6,mm_strdup("depends on extension"),$10);
8368 }
8369 | ALTER MATERIALIZED VIEW qualified_name opt_no DEPENDS ON EXTENSION name
8370 {
8371 $$ = cat_str(5,mm_strdup("alter materialized view"),$4,$5,mm_strdup("depends on extension"),$9);
8372 }
8373 | ALTER INDEX qualified_name opt_no DEPENDS ON EXTENSION name
8374 {
8375 $$ = cat_str(5,mm_strdup("alter index"),$3,$4,mm_strdup("depends on extension"),$8);
8376 }
8377 ;
8378
8379
8380 opt_no:
8381 NO
8382 {
8383 $$ = mm_strdup("no");
8384 }
8385 |
8386 {
8387 $$=EMPTY; }
8388 ;
8389
8390
8391 AlterObjectSchemaStmt:
8392 ALTER AGGREGATE aggregate_with_argtypes SET SCHEMA name
8393 {
8394 $$ = cat_str(4,mm_strdup("alter aggregate"),$3,mm_strdup("set schema"),$6);
8395 }
8396 | ALTER COLLATION any_name SET SCHEMA name
8397 {
8398 $$ = cat_str(4,mm_strdup("alter collation"),$3,mm_strdup("set schema"),$6);
8399 }
8400 | ALTER CONVERSION_P any_name SET SCHEMA name
8401 {
8402 $$ = cat_str(4,mm_strdup("alter conversion"),$3,mm_strdup("set schema"),$6);
8403 }
8404 | ALTER DOMAIN_P any_name SET SCHEMA name
8405 {
8406 $$ = cat_str(4,mm_strdup("alter domain"),$3,mm_strdup("set schema"),$6);
8407 }
8408 | ALTER EXTENSION name SET SCHEMA name
8409 {
8410 $$ = cat_str(4,mm_strdup("alter extension"),$3,mm_strdup("set schema"),$6);
8411 }
8412 | ALTER FUNCTION function_with_argtypes SET SCHEMA name
8413 {
8414 $$ = cat_str(4,mm_strdup("alter function"),$3,mm_strdup("set schema"),$6);
8415 }
8416 | ALTER OPERATOR operator_with_argtypes SET SCHEMA name
8417 {
8418 $$ = cat_str(4,mm_strdup("alter operator"),$3,mm_strdup("set schema"),$6);
8419 }
8420 | ALTER OPERATOR CLASS any_name USING access_method SET SCHEMA name
8421 {
8422 $$ = cat_str(6,mm_strdup("alter operator class"),$4,mm_strdup("using"),$6,mm_strdup("set schema"),$9);
8423 }
8424 | ALTER OPERATOR FAMILY any_name USING access_method SET SCHEMA name
8425 {
8426 $$ = cat_str(6,mm_strdup("alter operator family"),$4,mm_strdup("using"),$6,mm_strdup("set schema"),$9);
8427 }
8428 | ALTER PROCEDURE function_with_argtypes SET SCHEMA name
8429 {
8430 $$ = cat_str(4,mm_strdup("alter procedure"),$3,mm_strdup("set schema"),$6);
8431 }
8432 | ALTER ROUTINE function_with_argtypes SET SCHEMA name
8433 {
8434 $$ = cat_str(4,mm_strdup("alter routine"),$3,mm_strdup("set schema"),$6);
8435 }
8436 | ALTER TABLE relation_expr SET SCHEMA name
8437 {
8438 $$ = cat_str(4,mm_strdup("alter table"),$3,mm_strdup("set schema"),$6);
8439 }
8440 | ALTER TABLE IF_P EXISTS relation_expr SET SCHEMA name
8441 {
8442 $$ = cat_str(4,mm_strdup("alter table if exists"),$5,mm_strdup("set schema"),$8);
8443 }
8444 | ALTER STATISTICS any_name SET SCHEMA name
8445 {
8446 $$ = cat_str(4,mm_strdup("alter statistics"),$3,mm_strdup("set schema"),$6);
8447 }
8448 | ALTER TEXT_P SEARCH PARSER any_name SET SCHEMA name
8449 {
8450 $$ = cat_str(4,mm_strdup("alter text search parser"),$5,mm_strdup("set schema"),$8);
8451 }
8452 | ALTER TEXT_P SEARCH DICTIONARY any_name SET SCHEMA name
8453 {
8454 $$ = cat_str(4,mm_strdup("alter text search dictionary"),$5,mm_strdup("set schema"),$8);
8455 }
8456 | ALTER TEXT_P SEARCH TEMPLATE any_name SET SCHEMA name
8457 {
8458 $$ = cat_str(4,mm_strdup("alter text search template"),$5,mm_strdup("set schema"),$8);
8459 }
8460 | ALTER TEXT_P SEARCH CONFIGURATION any_name SET SCHEMA name
8461 {
8462 $$ = cat_str(4,mm_strdup("alter text search configuration"),$5,mm_strdup("set schema"),$8);
8463 }
8464 | ALTER SEQUENCE qualified_name SET SCHEMA name
8465 {
8466 $$ = cat_str(4,mm_strdup("alter sequence"),$3,mm_strdup("set schema"),$6);
8467 }
8468 | ALTER SEQUENCE IF_P EXISTS qualified_name SET SCHEMA name
8469 {
8470 $$ = cat_str(4,mm_strdup("alter sequence if exists"),$5,mm_strdup("set schema"),$8);
8471 }
8472 | ALTER VIEW qualified_name SET SCHEMA name
8473 {
8474 $$ = cat_str(4,mm_strdup("alter view"),$3,mm_strdup("set schema"),$6);
8475 }
8476 | ALTER VIEW IF_P EXISTS qualified_name SET SCHEMA name
8477 {
8478 $$ = cat_str(4,mm_strdup("alter view if exists"),$5,mm_strdup("set schema"),$8);
8479 }
8480 | ALTER MATERIALIZED VIEW qualified_name SET SCHEMA name
8481 {
8482 $$ = cat_str(4,mm_strdup("alter materialized view"),$4,mm_strdup("set schema"),$7);
8483 }
8484 | ALTER MATERIALIZED VIEW IF_P EXISTS qualified_name SET SCHEMA name
8485 {
8486 $$ = cat_str(4,mm_strdup("alter materialized view if exists"),$6,mm_strdup("set schema"),$9);
8487 }
8488 | ALTER FOREIGN TABLE relation_expr SET SCHEMA name
8489 {
8490 $$ = cat_str(4,mm_strdup("alter foreign table"),$4,mm_strdup("set schema"),$7);
8491 }
8492 | ALTER FOREIGN TABLE IF_P EXISTS relation_expr SET SCHEMA name
8493 {
8494 $$ = cat_str(4,mm_strdup("alter foreign table if exists"),$6,mm_strdup("set schema"),$9);
8495 }
8496 | ALTER TYPE_P any_name SET SCHEMA name
8497 {
8498 $$ = cat_str(4,mm_strdup("alter type"),$3,mm_strdup("set schema"),$6);
8499 }
8500 ;
8501
8502
8503 AlterOperatorStmt:
8504 ALTER OPERATOR operator_with_argtypes SET '(' operator_def_list ')'
8505 {
8506 $$ = cat_str(5,mm_strdup("alter operator"),$3,mm_strdup("set ("),$6,mm_strdup(")"));
8507 }
8508 ;
8509
8510
8511 operator_def_list:
8512 operator_def_elem
8513 {
8514 $$ = $1;
8515 }
8516 | operator_def_list ',' operator_def_elem
8517 {
8518 $$ = cat_str(3,$1,mm_strdup(","),$3);
8519 }
8520 ;
8521
8522
8523 operator_def_elem:
8524 ColLabel '=' NONE
8525 {
8526 $$ = cat_str(2,$1,mm_strdup("= none"));
8527 }
8528 | ColLabel '=' operator_def_arg
8529 {
8530 $$ = cat_str(3,$1,mm_strdup("="),$3);
8531 }
8532 ;
8533
8534
8535 operator_def_arg:
8536 func_type
8537 {
8538 $$ = $1;
8539 }
8540 | reserved_keyword
8541 {
8542 $$ = $1;
8543 }
8544 | qual_all_Op
8545 {
8546 $$ = $1;
8547 }
8548 | NumericOnly
8549 {
8550 $$ = $1;
8551 }
8552 | ecpg_sconst
8553 {
8554 $$ = $1;
8555 }
8556 ;
8557
8558
8559 AlterTypeStmt:
8560 ALTER TYPE_P any_name SET '(' operator_def_list ')'
8561 {
8562 $$ = cat_str(5,mm_strdup("alter type"),$3,mm_strdup("set ("),$6,mm_strdup(")"));
8563 }
8564 ;
8565
8566
8567 AlterOwnerStmt:
8568 ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
8569 {
8570 $$ = cat_str(4,mm_strdup("alter aggregate"),$3,mm_strdup("owner to"),$6);
8571 }
8572 | ALTER COLLATION any_name OWNER TO RoleSpec
8573 {
8574 $$ = cat_str(4,mm_strdup("alter collation"),$3,mm_strdup("owner to"),$6);
8575 }
8576 | ALTER CONVERSION_P any_name OWNER TO RoleSpec
8577 {
8578 $$ = cat_str(4,mm_strdup("alter conversion"),$3,mm_strdup("owner to"),$6);
8579 }
8580 | ALTER DATABASE database_name OWNER TO RoleSpec
8581 {
8582 $$ = cat_str(4,mm_strdup("alter database"),$3,mm_strdup("owner to"),$6);
8583 }
8584 | ALTER DOMAIN_P any_name OWNER TO RoleSpec
8585 {
8586 $$ = cat_str(4,mm_strdup("alter domain"),$3,mm_strdup("owner to"),$6);
8587 }
8588 | ALTER FUNCTION function_with_argtypes OWNER TO RoleSpec
8589 {
8590 $$ = cat_str(4,mm_strdup("alter function"),$3,mm_strdup("owner to"),$6);
8591 }
8592 | ALTER opt_procedural LANGUAGE name OWNER TO RoleSpec
8593 {
8594 $$ = cat_str(6,mm_strdup("alter"),$2,mm_strdup("language"),$4,mm_strdup("owner to"),$7);
8595 }
8596 | ALTER LARGE_P OBJECT_P NumericOnly OWNER TO RoleSpec
8597 {
8598 $$ = cat_str(4,mm_strdup("alter large object"),$4,mm_strdup("owner to"),$7);
8599 }
8600 | ALTER OPERATOR operator_with_argtypes OWNER TO RoleSpec
8601 {
8602 $$ = cat_str(4,mm_strdup("alter operator"),$3,mm_strdup("owner to"),$6);
8603 }
8604 | ALTER OPERATOR CLASS any_name USING access_method OWNER TO RoleSpec
8605 {
8606 $$ = cat_str(6,mm_strdup("alter operator class"),$4,mm_strdup("using"),$6,mm_strdup("owner to"),$9);
8607 }
8608 | ALTER OPERATOR FAMILY any_name USING access_method OWNER TO RoleSpec
8609 {
8610 $$ = cat_str(6,mm_strdup("alter operator family"),$4,mm_strdup("using"),$6,mm_strdup("owner to"),$9);
8611 }
8612 | ALTER PROCEDURE function_with_argtypes OWNER TO RoleSpec
8613 {
8614 $$ = cat_str(4,mm_strdup("alter procedure"),$3,mm_strdup("owner to"),$6);
8615 }
8616 | ALTER ROUTINE function_with_argtypes OWNER TO RoleSpec
8617 {
8618 $$ = cat_str(4,mm_strdup("alter routine"),$3,mm_strdup("owner to"),$6);
8619 }
8620 | ALTER SCHEMA name OWNER TO RoleSpec
8621 {
8622 $$ = cat_str(4,mm_strdup("alter schema"),$3,mm_strdup("owner to"),$6);
8623 }
8624 | ALTER TYPE_P any_name OWNER TO RoleSpec
8625 {
8626 $$ = cat_str(4,mm_strdup("alter type"),$3,mm_strdup("owner to"),$6);
8627 }
8628 | ALTER TABLESPACE name OWNER TO RoleSpec
8629 {
8630 $$ = cat_str(4,mm_strdup("alter tablespace"),$3,mm_strdup("owner to"),$6);
8631 }
8632 | ALTER STATISTICS any_name OWNER TO RoleSpec
8633 {
8634 $$ = cat_str(4,mm_strdup("alter statistics"),$3,mm_strdup("owner to"),$6);
8635 }
8636 | ALTER TEXT_P SEARCH DICTIONARY any_name OWNER TO RoleSpec
8637 {
8638 $$ = cat_str(4,mm_strdup("alter text search dictionary"),$5,mm_strdup("owner to"),$8);
8639 }
8640 | ALTER TEXT_P SEARCH CONFIGURATION any_name OWNER TO RoleSpec
8641 {
8642 $$ = cat_str(4,mm_strdup("alter text search configuration"),$5,mm_strdup("owner to"),$8);
8643 }
8644 | ALTER FOREIGN DATA_P WRAPPER name OWNER TO RoleSpec
8645 {
8646 $$ = cat_str(4,mm_strdup("alter foreign data wrapper"),$5,mm_strdup("owner to"),$8);
8647 }
8648 | ALTER SERVER name OWNER TO RoleSpec
8649 {
8650 $$ = cat_str(4,mm_strdup("alter server"),$3,mm_strdup("owner to"),$6);
8651 }
8652 | ALTER EVENT TRIGGER name OWNER TO RoleSpec
8653 {
8654 $$ = cat_str(4,mm_strdup("alter event trigger"),$4,mm_strdup("owner to"),$7);
8655 }
8656 | ALTER PUBLICATION name OWNER TO RoleSpec
8657 {
8658 $$ = cat_str(4,mm_strdup("alter publication"),$3,mm_strdup("owner to"),$6);
8659 }
8660 | ALTER SUBSCRIPTION name OWNER TO RoleSpec
8661 {
8662 $$ = cat_str(4,mm_strdup("alter subscription"),$3,mm_strdup("owner to"),$6);
8663 }
8664 ;
8665
8666
8667 CreatePublicationStmt:
8668 CREATE PUBLICATION name opt_publication_for_tables opt_definition
8669 {
8670 $$ = cat_str(4,mm_strdup("create publication"),$3,$4,$5);
8671 }
8672 ;
8673
8674
8675 opt_publication_for_tables:
8676 publication_for_tables
8677 {
8678 $$ = $1;
8679 }
8680 |
8681 {
8682 $$=EMPTY; }
8683 ;
8684
8685
8686 publication_for_tables:
8687 FOR TABLE relation_expr_list
8688 {
8689 $$ = cat_str(2,mm_strdup("for table"),$3);
8690 }
8691 | FOR ALL TABLES
8692 {
8693 $$ = mm_strdup("for all tables");
8694 }
8695 ;
8696
8697
8698 AlterPublicationStmt:
8699 ALTER PUBLICATION name SET definition
8700 {
8701 $$ = cat_str(4,mm_strdup("alter publication"),$3,mm_strdup("set"),$5);
8702 }
8703 | ALTER PUBLICATION name ADD_P TABLE relation_expr_list
8704 {
8705 $$ = cat_str(4,mm_strdup("alter publication"),$3,mm_strdup("add table"),$6);
8706 }
8707 | ALTER PUBLICATION name SET TABLE relation_expr_list
8708 {
8709 $$ = cat_str(4,mm_strdup("alter publication"),$3,mm_strdup("set table"),$6);
8710 }
8711 | ALTER PUBLICATION name DROP TABLE relation_expr_list
8712 {
8713 $$ = cat_str(4,mm_strdup("alter publication"),$3,mm_strdup("drop table"),$6);
8714 }
8715 ;
8716
8717
8718 CreateSubscriptionStmt:
8719 CREATE SUBSCRIPTION name CONNECTION ecpg_sconst PUBLICATION publication_name_list opt_definition
8720 {
8721 $$ = cat_str(7,mm_strdup("create subscription"),$3,mm_strdup("connection"),$5,mm_strdup("publication"),$7,$8);
8722 }
8723 ;
8724
8725
8726 publication_name_list:
8727 publication_name_item
8728 {
8729 $$ = $1;
8730 }
8731 | publication_name_list ',' publication_name_item
8732 {
8733 $$ = cat_str(3,$1,mm_strdup(","),$3);
8734 }
8735 ;
8736
8737
8738 publication_name_item:
8739 ColLabel
8740 {
8741 $$ = $1;
8742 }
8743 ;
8744
8745
8746 AlterSubscriptionStmt:
8747 ALTER SUBSCRIPTION name SET definition
8748 {
8749 $$ = cat_str(4,mm_strdup("alter subscription"),$3,mm_strdup("set"),$5);
8750 }
8751 | ALTER SUBSCRIPTION name CONNECTION ecpg_sconst
8752 {
8753 $$ = cat_str(4,mm_strdup("alter subscription"),$3,mm_strdup("connection"),$5);
8754 }
8755 | ALTER SUBSCRIPTION name REFRESH PUBLICATION opt_definition
8756 {
8757 $$ = cat_str(4,mm_strdup("alter subscription"),$3,mm_strdup("refresh publication"),$6);
8758 }
8759 | ALTER SUBSCRIPTION name SET PUBLICATION publication_name_list opt_definition
8760 {
8761 $$ = cat_str(5,mm_strdup("alter subscription"),$3,mm_strdup("set publication"),$6,$7);
8762 }
8763 | ALTER SUBSCRIPTION name ENABLE_P
8764 {
8765 $$ = cat_str(3,mm_strdup("alter subscription"),$3,mm_strdup("enable"));
8766 }
8767 | ALTER SUBSCRIPTION name DISABLE_P
8768 {
8769 $$ = cat_str(3,mm_strdup("alter subscription"),$3,mm_strdup("disable"));
8770 }
8771 ;
8772
8773
8774 DropSubscriptionStmt:
8775 DROP SUBSCRIPTION name opt_drop_behavior
8776 {
8777 $$ = cat_str(3,mm_strdup("drop subscription"),$3,$4);
8778 }
8779 | DROP SUBSCRIPTION IF_P EXISTS name opt_drop_behavior
8780 {
8781 $$ = cat_str(3,mm_strdup("drop subscription if exists"),$5,$6);
8782 }
8783 ;
8784
8785
8786 RuleStmt:
8787 CREATE opt_or_replace RULE name AS ON event TO qualified_name where_clause DO opt_instead RuleActionList
8788 {
8789 $$ = 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);
8790 }
8791 ;
8792
8793
8794 RuleActionList:
8795 NOTHING
8796 {
8797 $$ = mm_strdup("nothing");
8798 }
8799 | RuleActionStmt
8800 {
8801 $$ = $1;
8802 }
8803 | '(' RuleActionMulti ')'
8804 {
8805 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
8806 }
8807 ;
8808
8809
8810 RuleActionMulti:
8811 RuleActionMulti ';' RuleActionStmtOrEmpty
8812 {
8813 $$ = cat_str(3,$1,mm_strdup(";"),$3);
8814 }
8815 | RuleActionStmtOrEmpty
8816 {
8817 $$ = $1;
8818 }
8819 ;
8820
8821
8822 RuleActionStmt:
8823 SelectStmt
8824 {
8825 $$ = $1;
8826 }
8827 | InsertStmt
8828 {
8829 $$ = $1;
8830 }
8831 | UpdateStmt
8832 {
8833 $$ = $1;
8834 }
8835 | DeleteStmt
8836 {
8837 $$ = $1;
8838 }
8839 | NotifyStmt
8840 {
8841 $$ = $1;
8842 }
8843 ;
8844
8845
8846 RuleActionStmtOrEmpty:
8847 RuleActionStmt
8848 {
8849 $$ = $1;
8850 }
8851 |
8852 {
8853 $$=EMPTY; }
8854 ;
8855
8856
8857 event:
8858 SELECT
8859 {
8860 $$ = mm_strdup("select");
8861 }
8862 | UPDATE
8863 {
8864 $$ = mm_strdup("update");
8865 }
8866 | DELETE_P
8867 {
8868 $$ = mm_strdup("delete");
8869 }
8870 | INSERT
8871 {
8872 $$ = mm_strdup("insert");
8873 }
8874 ;
8875
8876
8877 opt_instead:
8878 INSTEAD
8879 {
8880 $$ = mm_strdup("instead");
8881 }
8882 | ALSO
8883 {
8884 $$ = mm_strdup("also");
8885 }
8886 |
8887 {
8888 $$=EMPTY; }
8889 ;
8890
8891
8892 NotifyStmt:
8893 NOTIFY ColId notify_payload
8894 {
8895 $$ = cat_str(3,mm_strdup("notify"),$2,$3);
8896 }
8897 ;
8898
8899
8900 notify_payload:
8901 ',' ecpg_sconst
8902 {
8903 $$ = cat_str(2,mm_strdup(","),$2);
8904 }
8905 |
8906 {
8907 $$=EMPTY; }
8908 ;
8909
8910
8911 ListenStmt:
8912 LISTEN ColId
8913 {
8914 $$ = cat_str(2,mm_strdup("listen"),$2);
8915 }
8916 ;
8917
8918
8919 UnlistenStmt:
8920 UNLISTEN ColId
8921 {
8922 $$ = cat_str(2,mm_strdup("unlisten"),$2);
8923 }
8924 | UNLISTEN '*'
8925 {
8926 $$ = mm_strdup("unlisten *");
8927 }
8928 ;
8929
8930
8931 TransactionStmt:
8932 ABORT_P opt_transaction opt_transaction_chain
8933 {
8934 $$ = cat_str(3,mm_strdup("abort"),$2,$3);
8935 }
8936 | BEGIN_P opt_transaction transaction_mode_list_or_empty
8937 {
8938 $$ = cat_str(3,mm_strdup("begin"),$2,$3);
8939 }
8940 | START TRANSACTION transaction_mode_list_or_empty
8941 {
8942 $$ = cat_str(2,mm_strdup("start transaction"),$3);
8943 }
8944 | COMMIT opt_transaction opt_transaction_chain
8945 {
8946 $$ = cat_str(3,mm_strdup("commit"),$2,$3);
8947 }
8948 | END_P opt_transaction opt_transaction_chain
8949 {
8950 $$ = cat_str(3,mm_strdup("end"),$2,$3);
8951 }
8952 | ROLLBACK opt_transaction opt_transaction_chain
8953 {
8954 $$ = cat_str(3,mm_strdup("rollback"),$2,$3);
8955 }
8956 | SAVEPOINT ColId
8957 {
8958 $$ = cat_str(2,mm_strdup("savepoint"),$2);
8959 }
8960 | RELEASE SAVEPOINT ColId
8961 {
8962 $$ = cat_str(2,mm_strdup("release savepoint"),$3);
8963 }
8964 | RELEASE ColId
8965 {
8966 $$ = cat_str(2,mm_strdup("release"),$2);
8967 }
8968 | ROLLBACK opt_transaction TO SAVEPOINT ColId
8969 {
8970 $$ = cat_str(4,mm_strdup("rollback"),$2,mm_strdup("to savepoint"),$5);
8971 }
8972 | ROLLBACK opt_transaction TO ColId
8973 {
8974 $$ = cat_str(4,mm_strdup("rollback"),$2,mm_strdup("to"),$4);
8975 }
8976 | PREPARE TRANSACTION ecpg_sconst
8977 {
8978 $$ = cat_str(2,mm_strdup("prepare transaction"),$3);
8979 }
8980 | COMMIT PREPARED ecpg_sconst
8981 {
8982 $$ = cat_str(2,mm_strdup("commit prepared"),$3);
8983 }
8984 | ROLLBACK PREPARED ecpg_sconst
8985 {
8986 $$ = cat_str(2,mm_strdup("rollback prepared"),$3);
8987 }
8988 ;
8989
8990
8991 opt_transaction:
8992 WORK
8993 {
8994 $$ = mm_strdup("work");
8995 }
8996 | TRANSACTION
8997 {
8998 $$ = mm_strdup("transaction");
8999 }
9000 |
9001 {
9002 $$=EMPTY; }
9003 ;
9004
9005
9006 transaction_mode_item:
9007 ISOLATION LEVEL iso_level
9008 {
9009 $$ = cat_str(2,mm_strdup("isolation level"),$3);
9010 }
9011 | READ ONLY
9012 {
9013 $$ = mm_strdup("read only");
9014 }
9015 | READ WRITE
9016 {
9017 $$ = mm_strdup("read write");
9018 }
9019 | DEFERRABLE
9020 {
9021 $$ = mm_strdup("deferrable");
9022 }
9023 | NOT DEFERRABLE
9024 {
9025 $$ = mm_strdup("not deferrable");
9026 }
9027 ;
9028
9029
9030 transaction_mode_list:
9031 transaction_mode_item
9032 {
9033 $$ = $1;
9034 }
9035 | transaction_mode_list ',' transaction_mode_item
9036 {
9037 $$ = cat_str(3,$1,mm_strdup(","),$3);
9038 }
9039 | transaction_mode_list transaction_mode_item
9040 {
9041 $$ = cat_str(2,$1,$2);
9042 }
9043 ;
9044
9045
9046 transaction_mode_list_or_empty:
9047 transaction_mode_list
9048 {
9049 $$ = $1;
9050 }
9051 |
9052 {
9053 $$=EMPTY; }
9054 ;
9055
9056
9057 opt_transaction_chain:
9058 AND CHAIN
9059 {
9060 $$ = mm_strdup("and chain");
9061 }
9062 | AND NO CHAIN
9063 {
9064 $$ = mm_strdup("and no chain");
9065 }
9066 |
9067 {
9068 $$=EMPTY; }
9069 ;
9070
9071
9072 ViewStmt:
9073 CREATE OptTemp VIEW qualified_name opt_column_list opt_reloptions AS SelectStmt opt_check_option
9074 {
9075 $$ = cat_str(9,mm_strdup("create"),$2,mm_strdup("view"),$4,$5,$6,mm_strdup("as"),$8,$9);
9076 }
9077 | CREATE OR REPLACE OptTemp VIEW qualified_name opt_column_list opt_reloptions AS SelectStmt opt_check_option
9078 {
9079 $$ = cat_str(9,mm_strdup("create or replace"),$4,mm_strdup("view"),$6,$7,$8,mm_strdup("as"),$10,$11);
9080 }
9081 | CREATE OptTemp RECURSIVE VIEW qualified_name '(' columnList ')' opt_reloptions AS SelectStmt opt_check_option
9082 {
9083 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
9084 $$ = cat_str(11,mm_strdup("create"),$2,mm_strdup("recursive view"),$5,mm_strdup("("),$7,mm_strdup(")"),$9,mm_strdup("as"),$11,$12);
9085 }
9086 | CREATE OR REPLACE OptTemp RECURSIVE VIEW qualified_name '(' columnList ')' opt_reloptions AS SelectStmt opt_check_option
9087 {
9088 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
9089 $$ = 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);
9090 }
9091 ;
9092
9093
9094 opt_check_option:
9095 WITH CHECK OPTION
9096 {
9097 $$ = mm_strdup("with check option");
9098 }
9099 | WITH CASCADED CHECK OPTION
9100 {
9101 $$ = mm_strdup("with cascaded check option");
9102 }
9103 | WITH LOCAL CHECK OPTION
9104 {
9105 $$ = mm_strdup("with local check option");
9106 }
9107 |
9108 {
9109 $$=EMPTY; }
9110 ;
9111
9112
9113 LoadStmt:
9114 LOAD file_name
9115 {
9116 $$ = cat_str(2,mm_strdup("load"),$2);
9117 }
9118 ;
9119
9120
9121 CreatedbStmt:
9122 CREATE DATABASE database_name opt_with createdb_opt_list
9123 {
9124 $$ = cat_str(4,mm_strdup("create database"),$3,$4,$5);
9125 }
9126 ;
9127
9128
9129 createdb_opt_list:
9130 createdb_opt_items
9131 {
9132 $$ = $1;
9133 }
9134 |
9135 {
9136 $$=EMPTY; }
9137 ;
9138
9139
9140 createdb_opt_items:
9141 createdb_opt_item
9142 {
9143 $$ = $1;
9144 }
9145 | createdb_opt_items createdb_opt_item
9146 {
9147 $$ = cat_str(2,$1,$2);
9148 }
9149 ;
9150
9151
9152 createdb_opt_item:
9153 createdb_opt_name opt_equal SignedIconst
9154 {
9155 $$ = cat_str(3,$1,$2,$3);
9156 }
9157 | createdb_opt_name opt_equal opt_boolean_or_string
9158 {
9159 $$ = cat_str(3,$1,$2,$3);
9160 }
9161 | createdb_opt_name opt_equal DEFAULT
9162 {
9163 $$ = cat_str(3,$1,$2,mm_strdup("default"));
9164 }
9165 ;
9166
9167
9168 createdb_opt_name:
9169 ecpg_ident
9170 {
9171 $$ = $1;
9172 }
9173 | CONNECTION LIMIT
9174 {
9175 $$ = mm_strdup("connection limit");
9176 }
9177 | ENCODING
9178 {
9179 $$ = mm_strdup("encoding");
9180 }
9181 | LOCATION
9182 {
9183 $$ = mm_strdup("location");
9184 }
9185 | OWNER
9186 {
9187 $$ = mm_strdup("owner");
9188 }
9189 | TABLESPACE
9190 {
9191 $$ = mm_strdup("tablespace");
9192 }
9193 | TEMPLATE
9194 {
9195 $$ = mm_strdup("template");
9196 }
9197 ;
9198
9199
9200 opt_equal:
9201 '='
9202 {
9203 $$ = mm_strdup("=");
9204 }
9205 |
9206 {
9207 $$=EMPTY; }
9208 ;
9209
9210
9211 AlterDatabaseStmt:
9212 ALTER DATABASE database_name WITH createdb_opt_list
9213 {
9214 $$ = cat_str(4,mm_strdup("alter database"),$3,mm_strdup("with"),$5);
9215 }
9216 | ALTER DATABASE database_name createdb_opt_list
9217 {
9218 $$ = cat_str(3,mm_strdup("alter database"),$3,$4);
9219 }
9220 | ALTER DATABASE database_name SET TABLESPACE name
9221 {
9222 $$ = cat_str(4,mm_strdup("alter database"),$3,mm_strdup("set tablespace"),$6);
9223 }
9224 ;
9225
9226
9227 AlterDatabaseSetStmt:
9228 ALTER DATABASE database_name SetResetClause
9229 {
9230 $$ = cat_str(3,mm_strdup("alter database"),$3,$4);
9231 }
9232 ;
9233
9234
9235 DropdbStmt:
9236 DROP DATABASE database_name
9237 {
9238 $$ = cat_str(2,mm_strdup("drop database"),$3);
9239 }
9240 | DROP DATABASE IF_P EXISTS database_name
9241 {
9242 $$ = cat_str(2,mm_strdup("drop database if exists"),$5);
9243 }
9244 | DROP DATABASE database_name opt_with '(' drop_option_list ')'
9245 {
9246 $$ = cat_str(6,mm_strdup("drop database"),$3,$4,mm_strdup("("),$6,mm_strdup(")"));
9247 }
9248 | DROP DATABASE IF_P EXISTS database_name opt_with '(' drop_option_list ')'
9249 {
9250 $$ = cat_str(6,mm_strdup("drop database if exists"),$5,$6,mm_strdup("("),$8,mm_strdup(")"));
9251 }
9252 ;
9253
9254
9255 drop_option_list:
9256 drop_option
9257 {
9258 $$ = $1;
9259 }
9260 | drop_option_list ',' drop_option
9261 {
9262 $$ = cat_str(3,$1,mm_strdup(","),$3);
9263 }
9264 ;
9265
9266
9267 drop_option:
9268 FORCE
9269 {
9270 $$ = mm_strdup("force");
9271 }
9272 ;
9273
9274
9275 AlterCollationStmt:
9276 ALTER COLLATION any_name REFRESH VERSION_P
9277 {
9278 $$ = cat_str(3,mm_strdup("alter collation"),$3,mm_strdup("refresh version"));
9279 }
9280 ;
9281
9282
9283 AlterSystemStmt:
9284 ALTER SYSTEM_P SET generic_set
9285 {
9286 $$ = cat_str(2,mm_strdup("alter system set"),$4);
9287 }
9288 | ALTER SYSTEM_P RESET generic_reset
9289 {
9290 $$ = cat_str(2,mm_strdup("alter system reset"),$4);
9291 }
9292 ;
9293
9294
9295 CreateDomainStmt:
9296 CREATE DOMAIN_P any_name opt_as Typename ColQualList
9297 {
9298 $$ = cat_str(5,mm_strdup("create domain"),$3,$4,$5,$6);
9299 }
9300 ;
9301
9302
9303 AlterDomainStmt:
9304 ALTER DOMAIN_P any_name alter_column_default
9305 {
9306 $$ = cat_str(3,mm_strdup("alter domain"),$3,$4);
9307 }
9308 | ALTER DOMAIN_P any_name DROP NOT NULL_P
9309 {
9310 $$ = cat_str(3,mm_strdup("alter domain"),$3,mm_strdup("drop not null"));
9311 }
9312 | ALTER DOMAIN_P any_name SET NOT NULL_P
9313 {
9314 $$ = cat_str(3,mm_strdup("alter domain"),$3,mm_strdup("set not null"));
9315 }
9316 | ALTER DOMAIN_P any_name ADD_P TableConstraint
9317 {
9318 $$ = cat_str(4,mm_strdup("alter domain"),$3,mm_strdup("add"),$5);
9319 }
9320 | ALTER DOMAIN_P any_name DROP CONSTRAINT name opt_drop_behavior
9321 {
9322 $$ = cat_str(5,mm_strdup("alter domain"),$3,mm_strdup("drop constraint"),$6,$7);
9323 }
9324 | ALTER DOMAIN_P any_name DROP CONSTRAINT IF_P EXISTS name opt_drop_behavior
9325 {
9326 $$ = cat_str(5,mm_strdup("alter domain"),$3,mm_strdup("drop constraint if exists"),$8,$9);
9327 }
9328 | ALTER DOMAIN_P any_name VALIDATE CONSTRAINT name
9329 {
9330 $$ = cat_str(4,mm_strdup("alter domain"),$3,mm_strdup("validate constraint"),$6);
9331 }
9332 ;
9333
9334
9335 opt_as:
9336 AS
9337 {
9338 $$ = mm_strdup("as");
9339 }
9340 |
9341 {
9342 $$=EMPTY; }
9343 ;
9344
9345
9346 AlterTSDictionaryStmt:
9347 ALTER TEXT_P SEARCH DICTIONARY any_name definition
9348 {
9349 $$ = cat_str(3,mm_strdup("alter text search dictionary"),$5,$6);
9350 }
9351 ;
9352
9353
9354 AlterTSConfigurationStmt:
9355 ALTER TEXT_P SEARCH CONFIGURATION any_name ADD_P MAPPING FOR name_list any_with any_name_list
9356 {
9357 $$ = cat_str(6,mm_strdup("alter text search configuration"),$5,mm_strdup("add mapping for"),$9,$10,$11);
9358 }
9359 | ALTER TEXT_P SEARCH CONFIGURATION any_name ALTER MAPPING FOR name_list any_with any_name_list
9360 {
9361 $$ = cat_str(6,mm_strdup("alter text search configuration"),$5,mm_strdup("alter mapping for"),$9,$10,$11);
9362 }
9363 | ALTER TEXT_P SEARCH CONFIGURATION any_name ALTER MAPPING REPLACE any_name any_with any_name
9364 {
9365 $$ = cat_str(6,mm_strdup("alter text search configuration"),$5,mm_strdup("alter mapping replace"),$9,$10,$11);
9366 }
9367 | ALTER TEXT_P SEARCH CONFIGURATION any_name ALTER MAPPING FOR name_list REPLACE any_name any_with any_name
9368 {
9369 $$ = cat_str(8,mm_strdup("alter text search configuration"),$5,mm_strdup("alter mapping for"),$9,mm_strdup("replace"),$11,$12,$13);
9370 }
9371 | ALTER TEXT_P SEARCH CONFIGURATION any_name DROP MAPPING FOR name_list
9372 {
9373 $$ = cat_str(4,mm_strdup("alter text search configuration"),$5,mm_strdup("drop mapping for"),$9);
9374 }
9375 | ALTER TEXT_P SEARCH CONFIGURATION any_name DROP MAPPING IF_P EXISTS FOR name_list
9376 {
9377 $$ = cat_str(4,mm_strdup("alter text search configuration"),$5,mm_strdup("drop mapping if exists for"),$11);
9378 }
9379 ;
9380
9381
9382 any_with:
9383 WITH
9384 {
9385 $$ = mm_strdup("with");
9386 }
9387 | WITH_LA
9388 {
9389 $$ = mm_strdup("with");
9390 }
9391 ;
9392
9393
9394 CreateConversionStmt:
9395 CREATE opt_default CONVERSION_P any_name FOR ecpg_sconst TO ecpg_sconst FROM any_name
9396 {
9397 $$ = cat_str(10,mm_strdup("create"),$2,mm_strdup("conversion"),$4,mm_strdup("for"),$6,mm_strdup("to"),$8,mm_strdup("from"),$10);
9398 }
9399 ;
9400
9401
9402 ClusterStmt:
9403 CLUSTER opt_verbose qualified_name cluster_index_specification
9404 {
9405 $$ = cat_str(4,mm_strdup("cluster"),$2,$3,$4);
9406 }
9407 | CLUSTER opt_verbose
9408 {
9409 $$ = cat_str(2,mm_strdup("cluster"),$2);
9410 }
9411 | CLUSTER opt_verbose index_name ON qualified_name
9412 {
9413 $$ = cat_str(5,mm_strdup("cluster"),$2,$3,mm_strdup("on"),$5);
9414 }
9415 ;
9416
9417
9418 cluster_index_specification:
9419 USING index_name
9420 {
9421 $$ = cat_str(2,mm_strdup("using"),$2);
9422 }
9423 |
9424 {
9425 $$=EMPTY; }
9426 ;
9427
9428
9429 VacuumStmt:
9430 VACUUM opt_full opt_freeze opt_verbose opt_analyze opt_vacuum_relation_list
9431 {
9432 $$ = cat_str(6,mm_strdup("vacuum"),$2,$3,$4,$5,$6);
9433 }
9434 | VACUUM '(' vac_analyze_option_list ')' opt_vacuum_relation_list
9435 {
9436 $$ = cat_str(4,mm_strdup("vacuum ("),$3,mm_strdup(")"),$5);
9437 }
9438 ;
9439
9440
9441 AnalyzeStmt:
9442 analyze_keyword opt_verbose opt_vacuum_relation_list
9443 {
9444 $$ = cat_str(3,$1,$2,$3);
9445 }
9446 | analyze_keyword '(' vac_analyze_option_list ')' opt_vacuum_relation_list
9447 {
9448 $$ = cat_str(5,$1,mm_strdup("("),$3,mm_strdup(")"),$5);
9449 }
9450 ;
9451
9452
9453 vac_analyze_option_list:
9454 vac_analyze_option_elem
9455 {
9456 $$ = $1;
9457 }
9458 | vac_analyze_option_list ',' vac_analyze_option_elem
9459 {
9460 $$ = cat_str(3,$1,mm_strdup(","),$3);
9461 }
9462 ;
9463
9464
9465 analyze_keyword:
9466 ANALYZE
9467 {
9468 $$ = mm_strdup("analyze");
9469 }
9470 | ANALYSE
9471 {
9472 $$ = mm_strdup("analyse");
9473 }
9474 ;
9475
9476
9477 vac_analyze_option_elem:
9478 vac_analyze_option_name vac_analyze_option_arg
9479 {
9480 $$ = cat_str(2,$1,$2);
9481 }
9482 ;
9483
9484
9485 vac_analyze_option_name:
9486 NonReservedWord
9487 {
9488 $$ = $1;
9489 }
9490 | analyze_keyword
9491 {
9492 $$ = $1;
9493 }
9494 ;
9495
9496
9497 vac_analyze_option_arg:
9498 opt_boolean_or_string
9499 {
9500 $$ = $1;
9501 }
9502 | NumericOnly
9503 {
9504 $$ = $1;
9505 }
9506 |
9507 {
9508 $$=EMPTY; }
9509 ;
9510
9511
9512 opt_analyze:
9513 analyze_keyword
9514 {
9515 $$ = $1;
9516 }
9517 |
9518 {
9519 $$=EMPTY; }
9520 ;
9521
9522
9523 opt_verbose:
9524 VERBOSE
9525 {
9526 $$ = mm_strdup("verbose");
9527 }
9528 |
9529 {
9530 $$=EMPTY; }
9531 ;
9532
9533
9534 opt_full:
9535 FULL
9536 {
9537 $$ = mm_strdup("full");
9538 }
9539 |
9540 {
9541 $$=EMPTY; }
9542 ;
9543
9544
9545 opt_freeze:
9546 FREEZE
9547 {
9548 $$ = mm_strdup("freeze");
9549 }
9550 |
9551 {
9552 $$=EMPTY; }
9553 ;
9554
9555
9556 opt_name_list:
9557 '(' name_list ')'
9558 {
9559 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
9560 }
9561 |
9562 {
9563 $$=EMPTY; }
9564 ;
9565
9566
9567 vacuum_relation:
9568 qualified_name opt_name_list
9569 {
9570 $$ = cat_str(2,$1,$2);
9571 }
9572 ;
9573
9574
9575 vacuum_relation_list:
9576 vacuum_relation
9577 {
9578 $$ = $1;
9579 }
9580 | vacuum_relation_list ',' vacuum_relation
9581 {
9582 $$ = cat_str(3,$1,mm_strdup(","),$3);
9583 }
9584 ;
9585
9586
9587 opt_vacuum_relation_list:
9588 vacuum_relation_list
9589 {
9590 $$ = $1;
9591 }
9592 |
9593 {
9594 $$=EMPTY; }
9595 ;
9596
9597
9598 ExplainStmt:
9599 EXPLAIN ExplainableStmt
9600 {
9601 $$ = cat_str(2,mm_strdup("explain"),$2);
9602 }
9603 | EXPLAIN analyze_keyword opt_verbose ExplainableStmt
9604 {
9605 $$ = cat_str(4,mm_strdup("explain"),$2,$3,$4);
9606 }
9607 | EXPLAIN VERBOSE ExplainableStmt
9608 {
9609 $$ = cat_str(2,mm_strdup("explain verbose"),$3);
9610 }
9611 | EXPLAIN '(' explain_option_list ')' ExplainableStmt
9612 {
9613 $$ = cat_str(4,mm_strdup("explain ("),$3,mm_strdup(")"),$5);
9614 }
9615 ;
9616
9617
9618 ExplainableStmt:
9619 SelectStmt
9620 {
9621 $$ = $1;
9622 }
9623 | InsertStmt
9624 {
9625 $$ = $1;
9626 }
9627 | UpdateStmt
9628 {
9629 $$ = $1;
9630 }
9631 | DeleteStmt
9632 {
9633 $$ = $1;
9634 }
9635 | DeclareCursorStmt
9636 {
9637 $$ = $1;
9638 }
9639 | CreateAsStmt
9640 {
9641 $$ = $1;
9642 }
9643 | CreateMatViewStmt
9644 {
9645 $$ = $1;
9646 }
9647 | RefreshMatViewStmt
9648 {
9649 $$ = $1;
9650 }
9651 | ExecuteStmt
9652 {
9653 $$ = $1.name;
9654 }
9655 ;
9656
9657
9658 explain_option_list:
9659 explain_option_elem
9660 {
9661 $$ = $1;
9662 }
9663 | explain_option_list ',' explain_option_elem
9664 {
9665 $$ = cat_str(3,$1,mm_strdup(","),$3);
9666 }
9667 ;
9668
9669
9670 explain_option_elem:
9671 explain_option_name explain_option_arg
9672 {
9673 $$ = cat_str(2,$1,$2);
9674 }
9675 ;
9676
9677
9678 explain_option_name:
9679 NonReservedWord
9680 {
9681 $$ = $1;
9682 }
9683 | analyze_keyword
9684 {
9685 $$ = $1;
9686 }
9687 ;
9688
9689
9690 explain_option_arg:
9691 opt_boolean_or_string
9692 {
9693 $$ = $1;
9694 }
9695 | NumericOnly
9696 {
9697 $$ = $1;
9698 }
9699 |
9700 {
9701 $$=EMPTY; }
9702 ;
9703
9704
9705 PrepareStmt:
9706 PREPARE prepared_name prep_type_clause AS PreparableStmt
9707 {
9708 $$.name = $2;
9709 $$.type = $3;
9710 $$.stmt = $5;
9711 }
9712 | PREPARE prepared_name FROM execstring
9713 {
9714 $$.name = $2;
9715 $$.type = NULL;
9716 $$.stmt = $4;
9717 }
9718 ;
9719
9720
9721 prep_type_clause:
9722 '(' type_list ')'
9723 {
9724 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
9725 }
9726 |
9727 {
9728 $$=EMPTY; }
9729 ;
9730
9731
9732 PreparableStmt:
9733 SelectStmt
9734 {
9735 $$ = $1;
9736 }
9737 | InsertStmt
9738 {
9739 $$ = $1;
9740 }
9741 | UpdateStmt
9742 {
9743 $$ = $1;
9744 }
9745 | DeleteStmt
9746 {
9747 $$ = $1;
9748 }
9749 ;
9750
9751
9752 ExecuteStmt:
9753 EXECUTE prepared_name execute_param_clause execute_rest
9754 {
9755 $$.name = $2;
9756 $$.type = $3;
9757 }
9758 | CREATE OptTemp TABLE create_as_target AS EXECUTE prepared_name execute_param_clause opt_with_data execute_rest
9759 {
9760 $$.name = cat_str(8,mm_strdup("create"),$2,mm_strdup("table"),$4,mm_strdup("as execute"),$7,$8,$9);
9761 }
9762 | CREATE OptTemp TABLE IF_P NOT EXISTS create_as_target AS EXECUTE prepared_name execute_param_clause opt_with_data execute_rest
9763 {
9764 $$.name = cat_str(8,mm_strdup("create"),$2,mm_strdup("table if not exists"),$7,mm_strdup("as execute"),$10,$11,$12);
9765 }
9766 ;
9767
9768
9769 execute_param_clause:
9770 '(' expr_list ')'
9771 {
9772 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
9773 }
9774 |
9775 {
9776 $$=EMPTY; }
9777 ;
9778
9779
9780 InsertStmt:
9781 opt_with_clause INSERT INTO insert_target insert_rest opt_on_conflict returning_clause
9782 {
9783 $$ = cat_str(6,$1,mm_strdup("insert into"),$4,$5,$6,$7);
9784 }
9785 ;
9786
9787
9788 insert_target:
9789 qualified_name
9790 {
9791 $$ = $1;
9792 }
9793 | qualified_name AS ColId
9794 {
9795 $$ = cat_str(3,$1,mm_strdup("as"),$3);
9796 }
9797 ;
9798
9799
9800 insert_rest:
9801 SelectStmt
9802 {
9803 $$ = $1;
9804 }
9805 | OVERRIDING override_kind VALUE_P SelectStmt
9806 {
9807 $$ = cat_str(4,mm_strdup("overriding"),$2,mm_strdup("value"),$4);
9808 }
9809 | '(' insert_column_list ')' SelectStmt
9810 {
9811 $$ = cat_str(4,mm_strdup("("),$2,mm_strdup(")"),$4);
9812 }
9813 | '(' insert_column_list ')' OVERRIDING override_kind VALUE_P SelectStmt
9814 {
9815 $$ = cat_str(6,mm_strdup("("),$2,mm_strdup(") overriding"),$5,mm_strdup("value"),$7);
9816 }
9817 | DEFAULT VALUES
9818 {
9819 $$ = mm_strdup("default values");
9820 }
9821 ;
9822
9823
9824 override_kind:
9825 USER
9826 {
9827 $$ = mm_strdup("user");
9828 }
9829 | SYSTEM_P
9830 {
9831 $$ = mm_strdup("system");
9832 }
9833 ;
9834
9835
9836 insert_column_list:
9837 insert_column_item
9838 {
9839 $$ = $1;
9840 }
9841 | insert_column_list ',' insert_column_item
9842 {
9843 $$ = cat_str(3,$1,mm_strdup(","),$3);
9844 }
9845 ;
9846
9847
9848 insert_column_item:
9849 ColId opt_indirection
9850 {
9851 $$ = cat_str(2,$1,$2);
9852 }
9853 ;
9854
9855
9856 opt_on_conflict:
9857 ON CONFLICT opt_conf_expr DO UPDATE SET set_clause_list where_clause
9858 {
9859 $$ = cat_str(5,mm_strdup("on conflict"),$3,mm_strdup("do update set"),$7,$8);
9860 }
9861 | ON CONFLICT opt_conf_expr DO NOTHING
9862 {
9863 $$ = cat_str(3,mm_strdup("on conflict"),$3,mm_strdup("do nothing"));
9864 }
9865 |
9866 {
9867 $$=EMPTY; }
9868 ;
9869
9870
9871 opt_conf_expr:
9872 '(' index_params ')' where_clause
9873 {
9874 $$ = cat_str(4,mm_strdup("("),$2,mm_strdup(")"),$4);
9875 }
9876 | ON CONSTRAINT name
9877 {
9878 $$ = cat_str(2,mm_strdup("on constraint"),$3);
9879 }
9880 |
9881 {
9882 $$=EMPTY; }
9883 ;
9884
9885
9886 returning_clause:
9887 RETURNING target_list opt_ecpg_into
9888 {
9889 $$ = cat_str(2,mm_strdup("returning"),$2);
9890 }
9891 |
9892 {
9893 $$=EMPTY; }
9894 ;
9895
9896
9897 DeleteStmt:
9898 opt_with_clause DELETE_P FROM relation_expr_opt_alias using_clause where_or_current_clause returning_clause
9899 {
9900 $$ = cat_str(6,$1,mm_strdup("delete from"),$4,$5,$6,$7);
9901 }
9902 ;
9903
9904
9905 using_clause:
9906 USING from_list
9907 {
9908 $$ = cat_str(2,mm_strdup("using"),$2);
9909 }
9910 |
9911 {
9912 $$=EMPTY; }
9913 ;
9914
9915
9916 LockStmt:
9917 LOCK_P opt_table relation_expr_list opt_lock opt_nowait
9918 {
9919 $$ = cat_str(5,mm_strdup("lock"),$2,$3,$4,$5);
9920 }
9921 ;
9922
9923
9924 opt_lock:
9925 IN_P lock_type MODE
9926 {
9927 $$ = cat_str(3,mm_strdup("in"),$2,mm_strdup("mode"));
9928 }
9929 |
9930 {
9931 $$=EMPTY; }
9932 ;
9933
9934
9935 lock_type:
9936 ACCESS SHARE
9937 {
9938 $$ = mm_strdup("access share");
9939 }
9940 | ROW SHARE
9941 {
9942 $$ = mm_strdup("row share");
9943 }
9944 | ROW EXCLUSIVE
9945 {
9946 $$ = mm_strdup("row exclusive");
9947 }
9948 | SHARE UPDATE EXCLUSIVE
9949 {
9950 $$ = mm_strdup("share update exclusive");
9951 }
9952 | SHARE
9953 {
9954 $$ = mm_strdup("share");
9955 }
9956 | SHARE ROW EXCLUSIVE
9957 {
9958 $$ = mm_strdup("share row exclusive");
9959 }
9960 | EXCLUSIVE
9961 {
9962 $$ = mm_strdup("exclusive");
9963 }
9964 | ACCESS EXCLUSIVE
9965 {
9966 $$ = mm_strdup("access exclusive");
9967 }
9968 ;
9969
9970
9971 opt_nowait:
9972 NOWAIT
9973 {
9974 $$ = mm_strdup("nowait");
9975 }
9976 |
9977 {
9978 $$=EMPTY; }
9979 ;
9980
9981
9982 opt_nowait_or_skip:
9983 NOWAIT
9984 {
9985 $$ = mm_strdup("nowait");
9986 }
9987 | SKIP LOCKED
9988 {
9989 $$ = mm_strdup("skip locked");
9990 }
9991 |
9992 {
9993 $$=EMPTY; }
9994 ;
9995
9996
9997 UpdateStmt:
9998 opt_with_clause UPDATE relation_expr_opt_alias SET set_clause_list from_clause where_or_current_clause returning_clause
9999 {
10000 $$ = cat_str(8,$1,mm_strdup("update"),$3,mm_strdup("set"),$5,$6,$7,$8);
10001 }
10002 ;
10003
10004
10005 set_clause_list:
10006 set_clause
10007 {
10008 $$ = $1;
10009 }
10010 | set_clause_list ',' set_clause
10011 {
10012 $$ = cat_str(3,$1,mm_strdup(","),$3);
10013 }
10014 ;
10015
10016
10017 set_clause:
10018 set_target '=' a_expr
10019 {
10020 $$ = cat_str(3,$1,mm_strdup("="),$3);
10021 }
10022 | '(' set_target_list ')' '=' a_expr
10023 {
10024 $$ = cat_str(4,mm_strdup("("),$2,mm_strdup(") ="),$5);
10025 }
10026 ;
10027
10028
10029 set_target:
10030 ColId opt_indirection
10031 {
10032 $$ = cat_str(2,$1,$2);
10033 }
10034 ;
10035
10036
10037 set_target_list:
10038 set_target
10039 {
10040 $$ = $1;
10041 }
10042 | set_target_list ',' set_target
10043 {
10044 $$ = cat_str(3,$1,mm_strdup(","),$3);
10045 }
10046 ;
10047
10048
10049 DeclareCursorStmt:
10050 DECLARE cursor_name cursor_options CURSOR opt_hold FOR SelectStmt
10051 {
10052 struct cursor *ptr, *this;
10053 char *cursor_marker = $2[0] == ':' ? mm_strdup("$0") : mm_strdup($2);
10054 char *comment, *c1, *c2;
10055 int (* strcmp_fn)(const char *, const char *) = (($2[0] == ':' || $2[0] == '"') ? strcmp : pg_strcasecmp);
10056
10057 for (ptr = cur; ptr != NULL; ptr = ptr->next)
10058 {
10059 if (strcmp_fn($2, ptr->name) == 0)
10060 {
10061 if ($2[0] == ':')
10062 mmerror(PARSE_ERROR, ET_ERROR, "using variable \"%s\" in different declare statements is not supported", $2+1);
10063 else
10064 mmerror(PARSE_ERROR, ET_ERROR, "cursor \"%s\" is already defined", $2);
10065 }
10066 }
10067
10068 this = (struct cursor *) mm_alloc(sizeof(struct cursor));
10069
10070 this->next = cur;
10071 this->name = $2;
10072 this->function = (current_function ? mm_strdup(current_function) : NULL);
10073 this->connection = connection;
10074 this->opened = false;
10075 this->command = cat_str(7, mm_strdup("declare"), cursor_marker, $3, mm_strdup("cursor"), $5, mm_strdup("for"), $7);
10076 this->argsinsert = argsinsert;
10077 this->argsinsert_oos = NULL;
10078 this->argsresult = argsresult;
10079 this->argsresult_oos = NULL;
10080 argsinsert = argsresult = NULL;
10081 cur = this;
10082
10083 c1 = mm_strdup(this->command);
10084 if ((c2 = strstr(c1, "*/")) != NULL)
10085 {
10086 /* We put this text into a comment, so we better remove [*][/]. */
10087 c2[0] = '.';
10088 c2[1] = '.';
10089 }
10090 comment = cat_str(3, mm_strdup("/*"), c1, mm_strdup("*/"));
10091
10092 $$ = cat2_str(adjust_outofscope_cursor_vars(this), comment);
10093 }
10094 ;
10095
10096
10097 cursor_name:
10098 name
10099 {
10100 $$ = $1;
10101 }
10102 | char_civar
10103 {
10104 char *curname = mm_alloc(strlen($1) + 2);
10105 sprintf(curname, ":%s", $1);
10106 free($1);
10107 $1 = curname;
10108 $$ = $1;
10109 }
10110 ;
10111
10112
10113 cursor_options:
10114
10115 {
10116 $$=EMPTY; }
10117 | cursor_options NO SCROLL
10118 {
10119 $$ = cat_str(2,$1,mm_strdup("no scroll"));
10120 }
10121 | cursor_options SCROLL
10122 {
10123 $$ = cat_str(2,$1,mm_strdup("scroll"));
10124 }
10125 | cursor_options BINARY
10126 {
10127 $$ = cat_str(2,$1,mm_strdup("binary"));
10128 }
10129 | cursor_options INSENSITIVE
10130 {
10131 $$ = cat_str(2,$1,mm_strdup("insensitive"));
10132 }
10133 ;
10134
10135
10136 opt_hold:
10137
10138 {
10139 if (compat == ECPG_COMPAT_INFORMIX_SE && autocommit)
10140 $$ = mm_strdup("with hold");
10141 else
10142 $$ = EMPTY;
10143 }
10144 | WITH HOLD
10145 {
10146 $$ = mm_strdup("with hold");
10147 }
10148 | WITHOUT HOLD
10149 {
10150 $$ = mm_strdup("without hold");
10151 }
10152 ;
10153
10154
10155 SelectStmt:
10156 select_no_parens %prec UMINUS
10157 {
10158 $$ = $1;
10159 }
10160 | select_with_parens %prec UMINUS
10161 {
10162 $$ = $1;
10163 }
10164 ;
10165
10166
10167 select_with_parens:
10168 '(' select_no_parens ')'
10169 {
10170 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
10171 }
10172 | '(' select_with_parens ')'
10173 {
10174 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
10175 }
10176 ;
10177
10178
10179 select_no_parens:
10180 simple_select
10181 {
10182 $$ = $1;
10183 }
10184 | select_clause sort_clause
10185 {
10186 $$ = cat_str(2,$1,$2);
10187 }
10188 | select_clause opt_sort_clause for_locking_clause opt_select_limit
10189 {
10190 $$ = cat_str(4,$1,$2,$3,$4);
10191 }
10192 | select_clause opt_sort_clause select_limit opt_for_locking_clause
10193 {
10194 $$ = cat_str(4,$1,$2,$3,$4);
10195 }
10196 | with_clause select_clause
10197 {
10198 $$ = cat_str(2,$1,$2);
10199 }
10200 | with_clause select_clause sort_clause
10201 {
10202 $$ = cat_str(3,$1,$2,$3);
10203 }
10204 | with_clause select_clause opt_sort_clause for_locking_clause opt_select_limit
10205 {
10206 $$ = cat_str(5,$1,$2,$3,$4,$5);
10207 }
10208 | with_clause select_clause opt_sort_clause select_limit opt_for_locking_clause
10209 {
10210 $$ = cat_str(5,$1,$2,$3,$4,$5);
10211 }
10212 ;
10213
10214
10215 select_clause:
10216 simple_select
10217 {
10218 $$ = $1;
10219 }
10220 | select_with_parens
10221 {
10222 $$ = $1;
10223 }
10224 ;
10225
10226
10227 simple_select:
10228 SELECT opt_all_clause opt_target_list into_clause from_clause where_clause group_clause having_clause window_clause
10229 {
10230 $$ = cat_str(9,mm_strdup("select"),$2,$3,$4,$5,$6,$7,$8,$9);
10231 }
10232 | SELECT distinct_clause target_list into_clause from_clause where_clause group_clause having_clause window_clause
10233 {
10234 $$ = cat_str(9,mm_strdup("select"),$2,$3,$4,$5,$6,$7,$8,$9);
10235 }
10236 | values_clause
10237 {
10238 $$ = $1;
10239 }
10240 | TABLE relation_expr
10241 {
10242 $$ = cat_str(2,mm_strdup("table"),$2);
10243 }
10244 | select_clause UNION all_or_distinct select_clause
10245 {
10246 $$ = cat_str(4,$1,mm_strdup("union"),$3,$4);
10247 }
10248 | select_clause INTERSECT all_or_distinct select_clause
10249 {
10250 $$ = cat_str(4,$1,mm_strdup("intersect"),$3,$4);
10251 }
10252 | select_clause EXCEPT all_or_distinct select_clause
10253 {
10254 $$ = cat_str(4,$1,mm_strdup("except"),$3,$4);
10255 }
10256 ;
10257
10258
10259 with_clause:
10260 WITH cte_list
10261 {
10262 $$ = cat_str(2,mm_strdup("with"),$2);
10263 }
10264 | WITH_LA cte_list
10265 {
10266 $$ = cat_str(2,mm_strdup("with"),$2);
10267 }
10268 | WITH RECURSIVE cte_list
10269 {
10270 $$ = cat_str(2,mm_strdup("with recursive"),$3);
10271 }
10272 ;
10273
10274
10275 cte_list:
10276 common_table_expr
10277 {
10278 $$ = $1;
10279 }
10280 | cte_list ',' common_table_expr
10281 {
10282 $$ = cat_str(3,$1,mm_strdup(","),$3);
10283 }
10284 ;
10285
10286
10287 common_table_expr:
10288 name opt_name_list AS opt_materialized '(' PreparableStmt ')'
10289 {
10290 $$ = cat_str(7,$1,$2,mm_strdup("as"),$4,mm_strdup("("),$6,mm_strdup(")"));
10291 }
10292 ;
10293
10294
10295 opt_materialized:
10296 MATERIALIZED
10297 {
10298 $$ = mm_strdup("materialized");
10299 }
10300 | NOT MATERIALIZED
10301 {
10302 $$ = mm_strdup("not materialized");
10303 }
10304 |
10305 {
10306 $$=EMPTY; }
10307 ;
10308
10309
10310 opt_with_clause:
10311 with_clause
10312 {
10313 $$ = $1;
10314 }
10315 |
10316 {
10317 $$=EMPTY; }
10318 ;
10319
10320
10321 into_clause:
10322 INTO OptTempTableName
10323 {
10324 FoundInto = 1;
10325 $$= cat2_str(mm_strdup("into"), $2);
10326 }
10327 | ecpg_into { $$ = EMPTY; }
10328 |
10329 {
10330 $$=EMPTY; }
10331 ;
10332
10333
10334 OptTempTableName:
10335 TEMPORARY opt_table qualified_name
10336 {
10337 $$ = cat_str(3,mm_strdup("temporary"),$2,$3);
10338 }
10339 | TEMP opt_table qualified_name
10340 {
10341 $$ = cat_str(3,mm_strdup("temp"),$2,$3);
10342 }
10343 | LOCAL TEMPORARY opt_table qualified_name
10344 {
10345 $$ = cat_str(3,mm_strdup("local temporary"),$3,$4);
10346 }
10347 | LOCAL TEMP opt_table qualified_name
10348 {
10349 $$ = cat_str(3,mm_strdup("local temp"),$3,$4);
10350 }
10351 | GLOBAL TEMPORARY opt_table qualified_name
10352 {
10353 $$ = cat_str(3,mm_strdup("global temporary"),$3,$4);
10354 }
10355 | GLOBAL TEMP opt_table qualified_name
10356 {
10357 $$ = cat_str(3,mm_strdup("global temp"),$3,$4);
10358 }
10359 | UNLOGGED opt_table qualified_name
10360 {
10361 $$ = cat_str(3,mm_strdup("unlogged"),$2,$3);
10362 }
10363 | TABLE qualified_name
10364 {
10365 $$ = cat_str(2,mm_strdup("table"),$2);
10366 }
10367 | qualified_name
10368 {
10369 $$ = $1;
10370 }
10371 ;
10372
10373
10374 opt_table:
10375 TABLE
10376 {
10377 $$ = mm_strdup("table");
10378 }
10379 |
10380 {
10381 $$=EMPTY; }
10382 ;
10383
10384
10385 all_or_distinct:
10386 ALL
10387 {
10388 $$ = mm_strdup("all");
10389 }
10390 | DISTINCT
10391 {
10392 $$ = mm_strdup("distinct");
10393 }
10394 |
10395 {
10396 $$=EMPTY; }
10397 ;
10398
10399
10400 distinct_clause:
10401 DISTINCT
10402 {
10403 $$ = mm_strdup("distinct");
10404 }
10405 | DISTINCT ON '(' expr_list ')'
10406 {
10407 $$ = cat_str(3,mm_strdup("distinct on ("),$4,mm_strdup(")"));
10408 }
10409 ;
10410
10411
10412 opt_all_clause:
10413 ALL
10414 {
10415 $$ = mm_strdup("all");
10416 }
10417 |
10418 {
10419 $$=EMPTY; }
10420 ;
10421
10422
10423 opt_sort_clause:
10424 sort_clause
10425 {
10426 $$ = $1;
10427 }
10428 |
10429 {
10430 $$=EMPTY; }
10431 ;
10432
10433
10434 sort_clause:
10435 ORDER BY sortby_list
10436 {
10437 $$ = cat_str(2,mm_strdup("order by"),$3);
10438 }
10439 ;
10440
10441
10442 sortby_list:
10443 sortby
10444 {
10445 $$ = $1;
10446 }
10447 | sortby_list ',' sortby
10448 {
10449 $$ = cat_str(3,$1,mm_strdup(","),$3);
10450 }
10451 ;
10452
10453
10454 sortby:
10455 a_expr USING qual_all_Op opt_nulls_order
10456 {
10457 $$ = cat_str(4,$1,mm_strdup("using"),$3,$4);
10458 }
10459 | a_expr opt_asc_desc opt_nulls_order
10460 {
10461 $$ = cat_str(3,$1,$2,$3);
10462 }
10463 ;
10464
10465
10466 select_limit:
10467 limit_clause offset_clause
10468 {
10469 $$ = cat_str(2,$1,$2);
10470 }
10471 | offset_clause limit_clause
10472 {
10473 $$ = cat_str(2,$1,$2);
10474 }
10475 | limit_clause
10476 {
10477 $$ = $1;
10478 }
10479 | offset_clause
10480 {
10481 $$ = $1;
10482 }
10483 ;
10484
10485
10486 opt_select_limit:
10487 select_limit
10488 {
10489 $$ = $1;
10490 }
10491 |
10492 {
10493 $$=EMPTY; }
10494 ;
10495
10496
10497 limit_clause:
10498 LIMIT select_limit_value
10499 {
10500 $$ = cat_str(2,mm_strdup("limit"),$2);
10501 }
10502 | LIMIT select_limit_value ',' select_offset_value
10503 {
10504 mmerror(PARSE_ERROR, ET_WARNING, "no longer supported LIMIT #,# syntax passed to server");
10505 $$ = cat_str(4, mm_strdup("limit"), $2, mm_strdup(","), $4);
10506 }
10507 | FETCH first_or_next select_fetch_first_value row_or_rows ONLY
10508 {
10509 $$ = cat_str(5,mm_strdup("fetch"),$2,$3,$4,mm_strdup("only"));
10510 }
10511 | FETCH first_or_next select_fetch_first_value row_or_rows WITH TIES
10512 {
10513 $$ = cat_str(5,mm_strdup("fetch"),$2,$3,$4,mm_strdup("with ties"));
10514 }
10515 | FETCH first_or_next row_or_rows ONLY
10516 {
10517 $$ = cat_str(4,mm_strdup("fetch"),$2,$3,mm_strdup("only"));
10518 }
10519 | FETCH first_or_next row_or_rows WITH TIES
10520 {
10521 $$ = cat_str(4,mm_strdup("fetch"),$2,$3,mm_strdup("with ties"));
10522 }
10523 ;
10524
10525
10526 offset_clause:
10527 OFFSET select_offset_value
10528 {
10529 $$ = cat_str(2,mm_strdup("offset"),$2);
10530 }
10531 | OFFSET select_fetch_first_value row_or_rows
10532 {
10533 $$ = cat_str(3,mm_strdup("offset"),$2,$3);
10534 }
10535 ;
10536
10537
10538 select_limit_value:
10539 a_expr
10540 {
10541 $$ = $1;
10542 }
10543 | ALL
10544 {
10545 $$ = mm_strdup("all");
10546 }
10547 ;
10548
10549
10550 select_offset_value:
10551 a_expr
10552 {
10553 $$ = $1;
10554 }
10555 ;
10556
10557
10558 select_fetch_first_value:
10559 c_expr
10560 {
10561 $$ = $1;
10562 }
10563 | '+' I_or_F_const
10564 {
10565 $$ = cat_str(2,mm_strdup("+"),$2);
10566 }
10567 | '-' I_or_F_const
10568 {
10569 $$ = cat_str(2,mm_strdup("-"),$2);
10570 }
10571 ;
10572
10573
10574 I_or_F_const:
10575 Iconst
10576 {
10577 $$ = $1;
10578 }
10579 | ecpg_fconst
10580 {
10581 $$ = $1;
10582 }
10583 ;
10584
10585
10586 row_or_rows:
10587 ROW
10588 {
10589 $$ = mm_strdup("row");
10590 }
10591 | ROWS
10592 {
10593 $$ = mm_strdup("rows");
10594 }
10595 ;
10596
10597
10598 first_or_next:
10599 FIRST_P
10600 {
10601 $$ = mm_strdup("first");
10602 }
10603 | NEXT
10604 {
10605 $$ = mm_strdup("next");
10606 }
10607 ;
10608
10609
10610 group_clause:
10611 GROUP_P BY group_by_list
10612 {
10613 $$ = cat_str(2,mm_strdup("group by"),$3);
10614 }
10615 |
10616 {
10617 $$=EMPTY; }
10618 ;
10619
10620
10621 group_by_list:
10622 group_by_item
10623 {
10624 $$ = $1;
10625 }
10626 | group_by_list ',' group_by_item
10627 {
10628 $$ = cat_str(3,$1,mm_strdup(","),$3);
10629 }
10630 ;
10631
10632
10633 group_by_item:
10634 a_expr
10635 {
10636 $$ = $1;
10637 }
10638 | empty_grouping_set
10639 {
10640 $$ = $1;
10641 }
10642 | cube_clause
10643 {
10644 $$ = $1;
10645 }
10646 | rollup_clause
10647 {
10648 $$ = $1;
10649 }
10650 | grouping_sets_clause
10651 {
10652 $$ = $1;
10653 }
10654 ;
10655
10656
10657 empty_grouping_set:
10658 '(' ')'
10659 {
10660 $$ = mm_strdup("( )");
10661 }
10662 ;
10663
10664
10665 rollup_clause:
10666 ROLLUP '(' expr_list ')'
10667 {
10668 $$ = cat_str(3,mm_strdup("rollup ("),$3,mm_strdup(")"));
10669 }
10670 ;
10671
10672
10673 cube_clause:
10674 CUBE '(' expr_list ')'
10675 {
10676 $$ = cat_str(3,mm_strdup("cube ("),$3,mm_strdup(")"));
10677 }
10678 ;
10679
10680
10681 grouping_sets_clause:
10682 GROUPING SETS '(' group_by_list ')'
10683 {
10684 $$ = cat_str(3,mm_strdup("grouping sets ("),$4,mm_strdup(")"));
10685 }
10686 ;
10687
10688
10689 having_clause:
10690 HAVING a_expr
10691 {
10692 $$ = cat_str(2,mm_strdup("having"),$2);
10693 }
10694 |
10695 {
10696 $$=EMPTY; }
10697 ;
10698
10699
10700 for_locking_clause:
10701 for_locking_items
10702 {
10703 $$ = $1;
10704 }
10705 | FOR READ ONLY
10706 {
10707 $$ = mm_strdup("for read only");
10708 }
10709 ;
10710
10711
10712 opt_for_locking_clause:
10713 for_locking_clause
10714 {
10715 $$ = $1;
10716 }
10717 |
10718 {
10719 $$=EMPTY; }
10720 ;
10721
10722
10723 for_locking_items:
10724 for_locking_item
10725 {
10726 $$ = $1;
10727 }
10728 | for_locking_items for_locking_item
10729 {
10730 $$ = cat_str(2,$1,$2);
10731 }
10732 ;
10733
10734
10735 for_locking_item:
10736 for_locking_strength locked_rels_list opt_nowait_or_skip
10737 {
10738 $$ = cat_str(3,$1,$2,$3);
10739 }
10740 ;
10741
10742
10743 for_locking_strength:
10744 FOR UPDATE
10745 {
10746 $$ = mm_strdup("for update");
10747 }
10748 | FOR NO KEY UPDATE
10749 {
10750 $$ = mm_strdup("for no key update");
10751 }
10752 | FOR SHARE
10753 {
10754 $$ = mm_strdup("for share");
10755 }
10756 | FOR KEY SHARE
10757 {
10758 $$ = mm_strdup("for key share");
10759 }
10760 ;
10761
10762
10763 locked_rels_list:
10764 OF qualified_name_list
10765 {
10766 $$ = cat_str(2,mm_strdup("of"),$2);
10767 }
10768 |
10769 {
10770 $$=EMPTY; }
10771 ;
10772
10773
10774 values_clause:
10775 VALUES '(' expr_list ')'
10776 {
10777 $$ = cat_str(3,mm_strdup("values ("),$3,mm_strdup(")"));
10778 }
10779 | values_clause ',' '(' expr_list ')'
10780 {
10781 $$ = cat_str(4,$1,mm_strdup(", ("),$4,mm_strdup(")"));
10782 }
10783 ;
10784
10785
10786 from_clause:
10787 FROM from_list
10788 {
10789 $$ = cat_str(2,mm_strdup("from"),$2);
10790 }
10791 |
10792 {
10793 $$=EMPTY; }
10794 ;
10795
10796
10797 from_list:
10798 table_ref
10799 {
10800 $$ = $1;
10801 }
10802 | from_list ',' table_ref
10803 {
10804 $$ = cat_str(3,$1,mm_strdup(","),$3);
10805 }
10806 ;
10807
10808
10809 table_ref:
10810 relation_expr opt_alias_clause
10811 {
10812 $$ = cat_str(2,$1,$2);
10813 }
10814 | relation_expr opt_alias_clause tablesample_clause
10815 {
10816 $$ = cat_str(3,$1,$2,$3);
10817 }
10818 | func_table func_alias_clause
10819 {
10820 $$ = cat_str(2,$1,$2);
10821 }
10822 | LATERAL_P func_table func_alias_clause
10823 {
10824 $$ = cat_str(3,mm_strdup("lateral"),$2,$3);
10825 }
10826 | xmltable opt_alias_clause
10827 {
10828 $$ = cat_str(2,$1,$2);
10829 }
10830 | LATERAL_P xmltable opt_alias_clause
10831 {
10832 $$ = cat_str(3,mm_strdup("lateral"),$2,$3);
10833 }
10834 | select_with_parens opt_alias_clause
10835 {
10836 if ($2 == NULL)
10837 mmerror(PARSE_ERROR, ET_ERROR, "subquery in FROM must have an alias");
10838
10839 $$ = cat_str(2,$1,$2);
10840 }
10841 | LATERAL_P select_with_parens opt_alias_clause
10842 {
10843 if ($3 == NULL)
10844 mmerror(PARSE_ERROR, ET_ERROR, "subquery in FROM must have an alias");
10845
10846 $$ = cat_str(3,mm_strdup("lateral"),$2,$3);
10847 }
10848 | joined_table
10849 {
10850 $$ = $1;
10851 }
10852 | '(' joined_table ')' alias_clause
10853 {
10854 $$ = cat_str(4,mm_strdup("("),$2,mm_strdup(")"),$4);
10855 }
10856 ;
10857
10858
10859 joined_table:
10860 '(' joined_table ')'
10861 {
10862 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
10863 }
10864 | table_ref CROSS JOIN table_ref
10865 {
10866 $$ = cat_str(3,$1,mm_strdup("cross join"),$4);
10867 }
10868 | table_ref join_type JOIN table_ref join_qual
10869 {
10870 $$ = cat_str(5,$1,$2,mm_strdup("join"),$4,$5);
10871 }
10872 | table_ref JOIN table_ref join_qual
10873 {
10874 $$ = cat_str(4,$1,mm_strdup("join"),$3,$4);
10875 }
10876 | table_ref NATURAL join_type JOIN table_ref
10877 {
10878 $$ = cat_str(5,$1,mm_strdup("natural"),$3,mm_strdup("join"),$5);
10879 }
10880 | table_ref NATURAL JOIN table_ref
10881 {
10882 $$ = cat_str(3,$1,mm_strdup("natural join"),$4);
10883 }
10884 ;
10885
10886
10887 alias_clause:
10888 AS ColId '(' name_list ')'
10889 {
10890 $$ = cat_str(5,mm_strdup("as"),$2,mm_strdup("("),$4,mm_strdup(")"));
10891 }
10892 | AS ColId
10893 {
10894 $$ = cat_str(2,mm_strdup("as"),$2);
10895 }
10896 | ColId '(' name_list ')'
10897 {
10898 $$ = cat_str(4,$1,mm_strdup("("),$3,mm_strdup(")"));
10899 }
10900 | ColId
10901 {
10902 $$ = $1;
10903 }
10904 ;
10905
10906
10907 opt_alias_clause:
10908 alias_clause
10909 {
10910 $$ = $1;
10911 }
10912 |
10913 {
10914 $$=EMPTY; }
10915 ;
10916
10917
10918 func_alias_clause:
10919 alias_clause
10920 {
10921 $$ = $1;
10922 }
10923 | AS '(' TableFuncElementList ')'
10924 {
10925 $$ = cat_str(3,mm_strdup("as ("),$3,mm_strdup(")"));
10926 }
10927 | AS ColId '(' TableFuncElementList ')'
10928 {
10929 $$ = cat_str(5,mm_strdup("as"),$2,mm_strdup("("),$4,mm_strdup(")"));
10930 }
10931 | ColId '(' TableFuncElementList ')'
10932 {
10933 $$ = cat_str(4,$1,mm_strdup("("),$3,mm_strdup(")"));
10934 }
10935 |
10936 {
10937 $$=EMPTY; }
10938 ;
10939
10940
10941 join_type:
10942 FULL join_outer
10943 {
10944 $$ = cat_str(2,mm_strdup("full"),$2);
10945 }
10946 | LEFT join_outer
10947 {
10948 $$ = cat_str(2,mm_strdup("left"),$2);
10949 }
10950 | RIGHT join_outer
10951 {
10952 $$ = cat_str(2,mm_strdup("right"),$2);
10953 }
10954 | INNER_P
10955 {
10956 $$ = mm_strdup("inner");
10957 }
10958 ;
10959
10960
10961 join_outer:
10962 OUTER_P
10963 {
10964 $$ = mm_strdup("outer");
10965 }
10966 |
10967 {
10968 $$=EMPTY; }
10969 ;
10970
10971
10972 join_qual:
10973 USING '(' name_list ')'
10974 {
10975 $$ = cat_str(3,mm_strdup("using ("),$3,mm_strdup(")"));
10976 }
10977 | ON a_expr
10978 {
10979 $$ = cat_str(2,mm_strdup("on"),$2);
10980 }
10981 ;
10982
10983
10984 relation_expr:
10985 qualified_name
10986 {
10987 $$ = $1;
10988 }
10989 | qualified_name '*'
10990 {
10991 $$ = cat_str(2,$1,mm_strdup("*"));
10992 }
10993 | ONLY qualified_name
10994 {
10995 $$ = cat_str(2,mm_strdup("only"),$2);
10996 }
10997 | ONLY '(' qualified_name ')'
10998 {
10999 $$ = cat_str(3,mm_strdup("only ("),$3,mm_strdup(")"));
11000 }
11001 ;
11002
11003
11004 relation_expr_list:
11005 relation_expr
11006 {
11007 $$ = $1;
11008 }
11009 | relation_expr_list ',' relation_expr
11010 {
11011 $$ = cat_str(3,$1,mm_strdup(","),$3);
11012 }
11013 ;
11014
11015
11016 relation_expr_opt_alias:
11017 relation_expr %prec UMINUS
11018 {
11019 $$ = $1;
11020 }
11021 | relation_expr ColId
11022 {
11023 $$ = cat_str(2,$1,$2);
11024 }
11025 | relation_expr AS ColId
11026 {
11027 $$ = cat_str(3,$1,mm_strdup("as"),$3);
11028 }
11029 ;
11030
11031
11032 tablesample_clause:
11033 TABLESAMPLE func_name '(' expr_list ')' opt_repeatable_clause
11034 {
11035 $$ = cat_str(6,mm_strdup("tablesample"),$2,mm_strdup("("),$4,mm_strdup(")"),$6);
11036 }
11037 ;
11038
11039
11040 opt_repeatable_clause:
11041 REPEATABLE '(' a_expr ')'
11042 {
11043 $$ = cat_str(3,mm_strdup("repeatable ("),$3,mm_strdup(")"));
11044 }
11045 |
11046 {
11047 $$=EMPTY; }
11048 ;
11049
11050
11051 func_table:
11052 func_expr_windowless opt_ordinality
11053 {
11054 $$ = cat_str(2,$1,$2);
11055 }
11056 | ROWS FROM '(' rowsfrom_list ')' opt_ordinality
11057 {
11058 $$ = cat_str(4,mm_strdup("rows from ("),$4,mm_strdup(")"),$6);
11059 }
11060 ;
11061
11062
11063 rowsfrom_item:
11064 func_expr_windowless opt_col_def_list
11065 {
11066 $$ = cat_str(2,$1,$2);
11067 }
11068 ;
11069
11070
11071 rowsfrom_list:
11072 rowsfrom_item
11073 {
11074 $$ = $1;
11075 }
11076 | rowsfrom_list ',' rowsfrom_item
11077 {
11078 $$ = cat_str(3,$1,mm_strdup(","),$3);
11079 }
11080 ;
11081
11082
11083 opt_col_def_list:
11084 AS '(' TableFuncElementList ')'
11085 {
11086 $$ = cat_str(3,mm_strdup("as ("),$3,mm_strdup(")"));
11087 }
11088 |
11089 {
11090 $$=EMPTY; }
11091 ;
11092
11093
11094 opt_ordinality:
11095 WITH_LA ORDINALITY
11096 {
11097 $$ = mm_strdup("with ordinality");
11098 }
11099 |
11100 {
11101 $$=EMPTY; }
11102 ;
11103
11104
11105 where_clause:
11106 WHERE a_expr
11107 {
11108 $$ = cat_str(2,mm_strdup("where"),$2);
11109 }
11110 |
11111 {
11112 $$=EMPTY; }
11113 ;
11114
11115
11116 where_or_current_clause:
11117 WHERE a_expr
11118 {
11119 $$ = cat_str(2,mm_strdup("where"),$2);
11120 }
11121 | WHERE CURRENT_P OF cursor_name
11122 {
11123 char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
11124 $$ = cat_str(2,mm_strdup("where current of"), cursor_marker);
11125 }
11126 |
11127 {
11128 $$=EMPTY; }
11129 ;
11130
11131
11132 OptTableFuncElementList:
11133 TableFuncElementList
11134 {
11135 $$ = $1;
11136 }
11137 |
11138 {
11139 $$=EMPTY; }
11140 ;
11141
11142
11143 TableFuncElementList:
11144 TableFuncElement
11145 {
11146 $$ = $1;
11147 }
11148 | TableFuncElementList ',' TableFuncElement
11149 {
11150 $$ = cat_str(3,$1,mm_strdup(","),$3);
11151 }
11152 ;
11153
11154
11155 TableFuncElement:
11156 ColId Typename opt_collate_clause
11157 {
11158 $$ = cat_str(3,$1,$2,$3);
11159 }
11160 ;
11161
11162
11163 xmltable:
11164 XMLTABLE '(' c_expr xmlexists_argument COLUMNS xmltable_column_list ')'
11165 {
11166 $$ = cat_str(6,mm_strdup("xmltable ("),$3,$4,mm_strdup("columns"),$6,mm_strdup(")"));
11167 }
11168 | XMLTABLE '(' XMLNAMESPACES '(' xml_namespace_list ')' ',' c_expr xmlexists_argument COLUMNS xmltable_column_list ')'
11169 {
11170 $$ = cat_str(8,mm_strdup("xmltable ( xmlnamespaces ("),$5,mm_strdup(") ,"),$8,$9,mm_strdup("columns"),$11,mm_strdup(")"));
11171 }
11172 ;
11173
11174
11175 xmltable_column_list:
11176 xmltable_column_el
11177 {
11178 $$ = $1;
11179 }
11180 | xmltable_column_list ',' xmltable_column_el
11181 {
11182 $$ = cat_str(3,$1,mm_strdup(","),$3);
11183 }
11184 ;
11185
11186
11187 xmltable_column_el:
11188 ColId Typename
11189 {
11190 $$ = cat_str(2,$1,$2);
11191 }
11192 | ColId Typename xmltable_column_option_list
11193 {
11194 $$ = cat_str(3,$1,$2,$3);
11195 }
11196 | ColId FOR ORDINALITY
11197 {
11198 $$ = cat_str(2,$1,mm_strdup("for ordinality"));
11199 }
11200 ;
11201
11202
11203 xmltable_column_option_list:
11204 xmltable_column_option_el
11205 {
11206 $$ = $1;
11207 }
11208 | xmltable_column_option_list xmltable_column_option_el
11209 {
11210 $$ = cat_str(2,$1,$2);
11211 }
11212 ;
11213
11214
11215 xmltable_column_option_el:
11216 ecpg_ident b_expr
11217 {
11218 $$ = cat_str(2,$1,$2);
11219 }
11220 | DEFAULT b_expr
11221 {
11222 $$ = cat_str(2,mm_strdup("default"),$2);
11223 }
11224 | NOT NULL_P
11225 {
11226 $$ = mm_strdup("not null");
11227 }
11228 | NULL_P
11229 {
11230 $$ = mm_strdup("null");
11231 }
11232 ;
11233
11234
11235 xml_namespace_list:
11236 xml_namespace_el
11237 {
11238 $$ = $1;
11239 }
11240 | xml_namespace_list ',' xml_namespace_el
11241 {
11242 $$ = cat_str(3,$1,mm_strdup(","),$3);
11243 }
11244 ;
11245
11246
11247 xml_namespace_el:
11248 b_expr AS ColLabel
11249 {
11250 $$ = cat_str(3,$1,mm_strdup("as"),$3);
11251 }
11252 | DEFAULT b_expr
11253 {
11254 $$ = cat_str(2,mm_strdup("default"),$2);
11255 }
11256 ;
11257
11258
11259 Typename:
11260 SimpleTypename opt_array_bounds
11261 { $$ = cat2_str($1, $2.str); }
11262 | SETOF SimpleTypename opt_array_bounds
11263 { $$ = cat_str(3, mm_strdup("setof"), $2, $3.str); }
11264 | SimpleTypename ARRAY '[' Iconst ']'
11265 {
11266 $$ = cat_str(4,$1,mm_strdup("array ["),$4,mm_strdup("]"));
11267 }
11268 | SETOF SimpleTypename ARRAY '[' Iconst ']'
11269 {
11270 $$ = cat_str(5,mm_strdup("setof"),$2,mm_strdup("array ["),$5,mm_strdup("]"));
11271 }
11272 | SimpleTypename ARRAY
11273 {
11274 $$ = cat_str(2,$1,mm_strdup("array"));
11275 }
11276 | SETOF SimpleTypename ARRAY
11277 {
11278 $$ = cat_str(3,mm_strdup("setof"),$2,mm_strdup("array"));
11279 }
11280 ;
11281
11282
11283 opt_array_bounds:
11284 opt_array_bounds '[' ']'
11285 {
11286 $$.index1 = $1.index1;
11287 $$.index2 = $1.index2;
11288 if (strcmp($$.index1, "-1") == 0)
11289 $$.index1 = mm_strdup("0");
11290 else if (strcmp($1.index2, "-1") == 0)
11291 $$.index2 = mm_strdup("0");
11292 $$.str = cat_str(2, $1.str, mm_strdup("[]"));
11293 }
11294 | opt_array_bounds '[' Iresult ']'
11295 {
11296 $$.index1 = $1.index1;
11297 $$.index2 = $1.index2;
11298 if (strcmp($1.index1, "-1") == 0)
11299 $$.index1 = mm_strdup($3);
11300 else if (strcmp($1.index2, "-1") == 0)
11301 $$.index2 = mm_strdup($3);
11302 $$.str = cat_str(4, $1.str, mm_strdup("["), $3, mm_strdup("]"));
11303 }
11304 |
11305 {
11306 $$.index1 = mm_strdup("-1");
11307 $$.index2 = mm_strdup("-1");
11308 $$.str= EMPTY;
11309 }
11310 ;
11311
11312
11313 SimpleTypename:
11314 GenericType
11315 {
11316 $$ = $1;
11317 }
11318 | Numeric
11319 {
11320 $$ = $1;
11321 }
11322 | Bit
11323 {
11324 $$ = $1;
11325 }
11326 | Character
11327 {
11328 $$ = $1;
11329 }
11330 | ConstDatetime
11331 {
11332 $$ = $1;
11333 }
11334 | ConstInterval opt_interval
11335 {
11336 $$ = cat_str(2,$1,$2);
11337 }
11338 | ConstInterval '(' Iconst ')'
11339 {
11340 $$ = cat_str(4,$1,mm_strdup("("),$3,mm_strdup(")"));
11341 }
11342 ;
11343
11344
11345 ConstTypename:
11346 Numeric
11347 {
11348 $$ = $1;
11349 }
11350 | ConstBit
11351 {
11352 $$ = $1;
11353 }
11354 | ConstCharacter
11355 {
11356 $$ = $1;
11357 }
11358 | ConstDatetime
11359 {
11360 $$ = $1;
11361 }
11362 ;
11363
11364
11365 GenericType:
11366 type_function_name opt_type_modifiers
11367 {
11368 $$ = cat_str(2,$1,$2);
11369 }
11370 | type_function_name attrs opt_type_modifiers
11371 {
11372 $$ = cat_str(3,$1,$2,$3);
11373 }
11374 ;
11375
11376
11377 opt_type_modifiers:
11378 '(' expr_list ')'
11379 {
11380 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
11381 }
11382 |
11383 {
11384 $$=EMPTY; }
11385 ;
11386
11387
11388 Numeric:
11389 INT_P
11390 {
11391 $$ = mm_strdup("int");
11392 }
11393 | INTEGER
11394 {
11395 $$ = mm_strdup("integer");
11396 }
11397 | SMALLINT
11398 {
11399 $$ = mm_strdup("smallint");
11400 }
11401 | BIGINT
11402 {
11403 $$ = mm_strdup("bigint");
11404 }
11405 | REAL
11406 {
11407 $$ = mm_strdup("real");
11408 }
11409 | FLOAT_P opt_float
11410 {
11411 $$ = cat_str(2,mm_strdup("float"),$2);
11412 }
11413 | DOUBLE_P PRECISION
11414 {
11415 $$ = mm_strdup("double precision");
11416 }
11417 | DECIMAL_P opt_type_modifiers
11418 {
11419 $$ = cat_str(2,mm_strdup("decimal"),$2);
11420 }
11421 | DEC opt_type_modifiers
11422 {
11423 $$ = cat_str(2,mm_strdup("dec"),$2);
11424 }
11425 | NUMERIC opt_type_modifiers
11426 {
11427 $$ = cat_str(2,mm_strdup("numeric"),$2);
11428 }
11429 | BOOLEAN_P
11430 {
11431 $$ = mm_strdup("boolean");
11432 }
11433 ;
11434
11435
11436 opt_float:
11437 '(' Iconst ')'
11438 {
11439 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
11440 }
11441 |
11442 {
11443 $$=EMPTY; }
11444 ;
11445
11446
11447 Bit:
11448 BitWithLength
11449 {
11450 $$ = $1;
11451 }
11452 | BitWithoutLength
11453 {
11454 $$ = $1;
11455 }
11456 ;
11457
11458
11459 ConstBit:
11460 BitWithLength
11461 {
11462 $$ = $1;
11463 }
11464 | BitWithoutLength
11465 {
11466 $$ = $1;
11467 }
11468 ;
11469
11470
11471 BitWithLength:
11472 BIT opt_varying '(' expr_list ')'
11473 {
11474 $$ = cat_str(5,mm_strdup("bit"),$2,mm_strdup("("),$4,mm_strdup(")"));
11475 }
11476 ;
11477
11478
11479 BitWithoutLength:
11480 BIT opt_varying
11481 {
11482 $$ = cat_str(2,mm_strdup("bit"),$2);
11483 }
11484 ;
11485
11486
11487 Character:
11488 CharacterWithLength
11489 {
11490 $$ = $1;
11491 }
11492 | CharacterWithoutLength
11493 {
11494 $$ = $1;
11495 }
11496 ;
11497
11498
11499 ConstCharacter:
11500 CharacterWithLength
11501 {
11502 $$ = $1;
11503 }
11504 | CharacterWithoutLength
11505 {
11506 $$ = $1;
11507 }
11508 ;
11509
11510
11511 CharacterWithLength:
11512 character '(' Iconst ')'
11513 {
11514 $$ = cat_str(4,$1,mm_strdup("("),$3,mm_strdup(")"));
11515 }
11516 ;
11517
11518
11519 CharacterWithoutLength:
11520 character
11521 {
11522 $$ = $1;
11523 }
11524 ;
11525
11526
11527 character:
11528 CHARACTER opt_varying
11529 {
11530 $$ = cat_str(2,mm_strdup("character"),$2);
11531 }
11532 | CHAR_P opt_varying
11533 {
11534 $$ = cat_str(2,mm_strdup("char"),$2);
11535 }
11536 | VARCHAR
11537 {
11538 $$ = mm_strdup("varchar");
11539 }
11540 | NATIONAL CHARACTER opt_varying
11541 {
11542 $$ = cat_str(2,mm_strdup("national character"),$3);
11543 }
11544 | NATIONAL CHAR_P opt_varying
11545 {
11546 $$ = cat_str(2,mm_strdup("national char"),$3);
11547 }
11548 | NCHAR opt_varying
11549 {
11550 $$ = cat_str(2,mm_strdup("nchar"),$2);
11551 }
11552 ;
11553
11554
11555 opt_varying:
11556 VARYING
11557 {
11558 $$ = mm_strdup("varying");
11559 }
11560 |
11561 {
11562 $$=EMPTY; }
11563 ;
11564
11565
11566 ConstDatetime:
11567 TIMESTAMP '(' Iconst ')' opt_timezone
11568 {
11569 $$ = cat_str(4,mm_strdup("timestamp ("),$3,mm_strdup(")"),$5);
11570 }
11571 | TIMESTAMP opt_timezone
11572 {
11573 $$ = cat_str(2,mm_strdup("timestamp"),$2);
11574 }
11575 | TIME '(' Iconst ')' opt_timezone
11576 {
11577 $$ = cat_str(4,mm_strdup("time ("),$3,mm_strdup(")"),$5);
11578 }
11579 | TIME opt_timezone
11580 {
11581 $$ = cat_str(2,mm_strdup("time"),$2);
11582 }
11583 ;
11584
11585
11586 ConstInterval:
11587 INTERVAL
11588 {
11589 $$ = mm_strdup("interval");
11590 }
11591 ;
11592
11593
11594 opt_timezone:
11595 WITH_LA TIME ZONE
11596 {
11597 $$ = mm_strdup("with time zone");
11598 }
11599 | WITHOUT TIME ZONE
11600 {
11601 $$ = mm_strdup("without time zone");
11602 }
11603 |
11604 {
11605 $$=EMPTY; }
11606 ;
11607
11608
11609 opt_interval:
11610 YEAR_P
11611 {
11612 $$ = mm_strdup("year");
11613 }
11614 | MONTH_P
11615 {
11616 $$ = mm_strdup("month");
11617 }
11618 | DAY_P
11619 {
11620 $$ = mm_strdup("day");
11621 }
11622 | HOUR_P
11623 {
11624 $$ = mm_strdup("hour");
11625 }
11626 | MINUTE_P
11627 {
11628 $$ = mm_strdup("minute");
11629 }
11630 | interval_second
11631 {
11632 $$ = $1;
11633 }
11634 | YEAR_P TO MONTH_P
11635 {
11636 $$ = mm_strdup("year to month");
11637 }
11638 | DAY_P TO HOUR_P
11639 {
11640 $$ = mm_strdup("day to hour");
11641 }
11642 | DAY_P TO MINUTE_P
11643 {
11644 $$ = mm_strdup("day to minute");
11645 }
11646 | DAY_P TO interval_second
11647 {
11648 $$ = cat_str(2,mm_strdup("day to"),$3);
11649 }
11650 | HOUR_P TO MINUTE_P
11651 {
11652 $$ = mm_strdup("hour to minute");
11653 }
11654 | HOUR_P TO interval_second
11655 {
11656 $$ = cat_str(2,mm_strdup("hour to"),$3);
11657 }
11658 | MINUTE_P TO interval_second
11659 {
11660 $$ = cat_str(2,mm_strdup("minute to"),$3);
11661 }
11662 |
11663 {
11664 $$=EMPTY; }
11665 ;
11666
11667
11668 interval_second:
11669 SECOND_P
11670 {
11671 $$ = mm_strdup("second");
11672 }
11673 | SECOND_P '(' Iconst ')'
11674 {
11675 $$ = cat_str(3,mm_strdup("second ("),$3,mm_strdup(")"));
11676 }
11677 ;
11678
11679
11680 a_expr:
11681 c_expr
11682 {
11683 $$ = $1;
11684 }
11685 | a_expr TYPECAST Typename
11686 {
11687 $$ = cat_str(3,$1,mm_strdup("::"),$3);
11688 }
11689 | a_expr COLLATE any_name
11690 {
11691 $$ = cat_str(3,$1,mm_strdup("collate"),$3);
11692 }
11693 | a_expr AT TIME ZONE a_expr %prec AT
11694 {
11695 $$ = cat_str(3,$1,mm_strdup("at time zone"),$5);
11696 }
11697 | '+' a_expr %prec UMINUS
11698 {
11699 $$ = cat_str(2,mm_strdup("+"),$2);
11700 }
11701 | '-' a_expr %prec UMINUS
11702 {
11703 $$ = cat_str(2,mm_strdup("-"),$2);
11704 }
11705 | a_expr '+' a_expr
11706 {
11707 $$ = cat_str(3,$1,mm_strdup("+"),$3);
11708 }
11709 | a_expr '-' a_expr
11710 {
11711 $$ = cat_str(3,$1,mm_strdup("-"),$3);
11712 }
11713 | a_expr '*' a_expr
11714 {
11715 $$ = cat_str(3,$1,mm_strdup("*"),$3);
11716 }
11717 | a_expr '/' a_expr
11718 {
11719 $$ = cat_str(3,$1,mm_strdup("/"),$3);
11720 }
11721 | a_expr '%' a_expr
11722 {
11723 $$ = cat_str(3,$1,mm_strdup("%"),$3);
11724 }
11725 | a_expr '^' a_expr
11726 {
11727 $$ = cat_str(3,$1,mm_strdup("^"),$3);
11728 }
11729 | a_expr '<' a_expr
11730 {
11731 $$ = cat_str(3,$1,mm_strdup("<"),$3);
11732 }
11733 | a_expr '>' a_expr
11734 {
11735 $$ = cat_str(3,$1,mm_strdup(">"),$3);
11736 }
11737 | a_expr '=' a_expr
11738 {
11739 $$ = cat_str(3,$1,mm_strdup("="),$3);
11740 }
11741 | a_expr LESS_EQUALS a_expr
11742 {
11743 $$ = cat_str(3,$1,mm_strdup("<="),$3);
11744 }
11745 | a_expr GREATER_EQUALS a_expr
11746 {
11747 $$ = cat_str(3,$1,mm_strdup(">="),$3);
11748 }
11749 | a_expr NOT_EQUALS a_expr
11750 {
11751 $$ = cat_str(3,$1,mm_strdup("<>"),$3);
11752 }
11753 | a_expr qual_Op a_expr %prec Op
11754 {
11755 $$ = cat_str(3,$1,$2,$3);
11756 }
11757 | qual_Op a_expr %prec Op
11758 {
11759 $$ = cat_str(2,$1,$2);
11760 }
11761 | a_expr qual_Op %prec POSTFIXOP
11762 {
11763 $$ = cat_str(2,$1,$2);
11764 }
11765 | a_expr AND a_expr
11766 {
11767 $$ = cat_str(3,$1,mm_strdup("and"),$3);
11768 }
11769 | a_expr OR a_expr
11770 {
11771 $$ = cat_str(3,$1,mm_strdup("or"),$3);
11772 }
11773 | NOT a_expr
11774 {
11775 $$ = cat_str(2,mm_strdup("not"),$2);
11776 }
11777 | NOT_LA a_expr %prec NOT
11778 {
11779 $$ = cat_str(2,mm_strdup("not"),$2);
11780 }
11781 | a_expr LIKE a_expr
11782 {
11783 $$ = cat_str(3,$1,mm_strdup("like"),$3);
11784 }
11785 | a_expr LIKE a_expr ESCAPE a_expr %prec LIKE
11786 {
11787 $$ = cat_str(5,$1,mm_strdup("like"),$3,mm_strdup("escape"),$5);
11788 }
11789 | a_expr NOT_LA LIKE a_expr %prec NOT_LA
11790 {
11791 $$ = cat_str(3,$1,mm_strdup("not like"),$4);
11792 }
11793 | a_expr NOT_LA LIKE a_expr ESCAPE a_expr %prec NOT_LA
11794 {
11795 $$ = cat_str(5,$1,mm_strdup("not like"),$4,mm_strdup("escape"),$6);
11796 }
11797 | a_expr ILIKE a_expr
11798 {
11799 $$ = cat_str(3,$1,mm_strdup("ilike"),$3);
11800 }
11801 | a_expr ILIKE a_expr ESCAPE a_expr %prec ILIKE
11802 {
11803 $$ = cat_str(5,$1,mm_strdup("ilike"),$3,mm_strdup("escape"),$5);
11804 }
11805 | a_expr NOT_LA ILIKE a_expr %prec NOT_LA
11806 {
11807 $$ = cat_str(3,$1,mm_strdup("not ilike"),$4);
11808 }
11809 | a_expr NOT_LA ILIKE a_expr ESCAPE a_expr %prec NOT_LA
11810 {
11811 $$ = cat_str(5,$1,mm_strdup("not ilike"),$4,mm_strdup("escape"),$6);
11812 }
11813 | a_expr SIMILAR TO a_expr %prec SIMILAR
11814 {
11815 $$ = cat_str(3,$1,mm_strdup("similar to"),$4);
11816 }
11817 | a_expr SIMILAR TO a_expr ESCAPE a_expr %prec SIMILAR
11818 {
11819 $$ = cat_str(5,$1,mm_strdup("similar to"),$4,mm_strdup("escape"),$6);
11820 }
11821 | a_expr NOT_LA SIMILAR TO a_expr %prec NOT_LA
11822 {
11823 $$ = cat_str(3,$1,mm_strdup("not similar to"),$5);
11824 }
11825 | a_expr NOT_LA SIMILAR TO a_expr ESCAPE a_expr %prec NOT_LA
11826 {
11827 $$ = cat_str(5,$1,mm_strdup("not similar to"),$5,mm_strdup("escape"),$7);
11828 }
11829 | a_expr IS NULL_P %prec IS
11830 {
11831 $$ = cat_str(2,$1,mm_strdup("is null"));
11832 }
11833 | a_expr ISNULL
11834 {
11835 $$ = cat_str(2,$1,mm_strdup("isnull"));
11836 }
11837 | a_expr IS NOT NULL_P %prec IS
11838 {
11839 $$ = cat_str(2,$1,mm_strdup("is not null"));
11840 }
11841 | a_expr NOTNULL
11842 {
11843 $$ = cat_str(2,$1,mm_strdup("notnull"));
11844 }
11845 | row OVERLAPS row
11846 {
11847 $$ = cat_str(3,$1,mm_strdup("overlaps"),$3);
11848 }
11849 | a_expr IS TRUE_P %prec IS
11850 {
11851 $$ = cat_str(2,$1,mm_strdup("is true"));
11852 }
11853 | a_expr IS NOT TRUE_P %prec IS
11854 {
11855 $$ = cat_str(2,$1,mm_strdup("is not true"));
11856 }
11857 | a_expr IS FALSE_P %prec IS
11858 {
11859 $$ = cat_str(2,$1,mm_strdup("is false"));
11860 }
11861 | a_expr IS NOT FALSE_P %prec IS
11862 {
11863 $$ = cat_str(2,$1,mm_strdup("is not false"));
11864 }
11865 | a_expr IS UNKNOWN %prec IS
11866 {
11867 $$ = cat_str(2,$1,mm_strdup("is unknown"));
11868 }
11869 | a_expr IS NOT UNKNOWN %prec IS
11870 {
11871 $$ = cat_str(2,$1,mm_strdup("is not unknown"));
11872 }
11873 | a_expr IS DISTINCT FROM a_expr %prec IS
11874 {
11875 $$ = cat_str(3,$1,mm_strdup("is distinct from"),$5);
11876 }
11877 | a_expr IS NOT DISTINCT FROM a_expr %prec IS
11878 {
11879 $$ = cat_str(3,$1,mm_strdup("is not distinct from"),$6);
11880 }
11881 | a_expr IS OF '(' type_list ')' %prec IS
11882 {
11883 $$ = cat_str(4,$1,mm_strdup("is of ("),$5,mm_strdup(")"));
11884 }
11885 | a_expr IS NOT OF '(' type_list ')' %prec IS
11886 {
11887 $$ = cat_str(4,$1,mm_strdup("is not of ("),$6,mm_strdup(")"));
11888 }
11889 | a_expr BETWEEN opt_asymmetric b_expr AND a_expr %prec BETWEEN
11890 {
11891 $$ = cat_str(6,$1,mm_strdup("between"),$3,$4,mm_strdup("and"),$6);
11892 }
11893 | a_expr NOT_LA BETWEEN opt_asymmetric b_expr AND a_expr %prec NOT_LA
11894 {
11895 $$ = cat_str(6,$1,mm_strdup("not between"),$4,$5,mm_strdup("and"),$7);
11896 }
11897 | a_expr BETWEEN SYMMETRIC b_expr AND a_expr %prec BETWEEN
11898 {
11899 $$ = cat_str(5,$1,mm_strdup("between symmetric"),$4,mm_strdup("and"),$6);
11900 }
11901 | a_expr NOT_LA BETWEEN SYMMETRIC b_expr AND a_expr %prec NOT_LA
11902 {
11903 $$ = cat_str(5,$1,mm_strdup("not between symmetric"),$5,mm_strdup("and"),$7);
11904 }
11905 | a_expr IN_P in_expr
11906 {
11907 $$ = cat_str(3,$1,mm_strdup("in"),$3);
11908 }
11909 | a_expr NOT_LA IN_P in_expr %prec NOT_LA
11910 {
11911 $$ = cat_str(3,$1,mm_strdup("not in"),$4);
11912 }
11913 | a_expr subquery_Op sub_type select_with_parens %prec Op
11914 {
11915 $$ = cat_str(4,$1,$2,$3,$4);
11916 }
11917 | a_expr subquery_Op sub_type '(' a_expr ')' %prec Op
11918 {
11919 $$ = cat_str(6,$1,$2,$3,mm_strdup("("),$5,mm_strdup(")"));
11920 }
11921 | UNIQUE select_with_parens
11922 {
11923 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
11924 $$ = cat_str(2,mm_strdup("unique"),$2);
11925 }
11926 | a_expr IS DOCUMENT_P %prec IS
11927 {
11928 $$ = cat_str(2,$1,mm_strdup("is document"));
11929 }
11930 | a_expr IS NOT DOCUMENT_P %prec IS
11931 {
11932 $$ = cat_str(2,$1,mm_strdup("is not document"));
11933 }
11934 | a_expr IS NORMALIZED %prec IS
11935 {
11936 $$ = cat_str(2,$1,mm_strdup("is normalized"));
11937 }
11938 | a_expr IS unicode_normal_form NORMALIZED %prec IS
11939 {
11940 $$ = cat_str(4,$1,mm_strdup("is"),$3,mm_strdup("normalized"));
11941 }
11942 | a_expr IS NOT NORMALIZED %prec IS
11943 {
11944 $$ = cat_str(2,$1,mm_strdup("is not normalized"));
11945 }
11946 | a_expr IS NOT unicode_normal_form NORMALIZED %prec IS
11947 {
11948 $$ = cat_str(4,$1,mm_strdup("is not"),$4,mm_strdup("normalized"));
11949 }
11950 | DEFAULT
11951 {
11952 $$ = mm_strdup("default");
11953 }
11954 ;
11955
11956
11957 b_expr:
11958 c_expr
11959 {
11960 $$ = $1;
11961 }
11962 | b_expr TYPECAST Typename
11963 {
11964 $$ = cat_str(3,$1,mm_strdup("::"),$3);
11965 }
11966 | '+' b_expr %prec UMINUS
11967 {
11968 $$ = cat_str(2,mm_strdup("+"),$2);
11969 }
11970 | '-' b_expr %prec UMINUS
11971 {
11972 $$ = cat_str(2,mm_strdup("-"),$2);
11973 }
11974 | b_expr '+' b_expr
11975 {
11976 $$ = cat_str(3,$1,mm_strdup("+"),$3);
11977 }
11978 | b_expr '-' b_expr
11979 {
11980 $$ = cat_str(3,$1,mm_strdup("-"),$3);
11981 }
11982 | b_expr '*' b_expr
11983 {
11984 $$ = cat_str(3,$1,mm_strdup("*"),$3);
11985 }
11986 | b_expr '/' b_expr
11987 {
11988 $$ = cat_str(3,$1,mm_strdup("/"),$3);
11989 }
11990 | b_expr '%' b_expr
11991 {
11992 $$ = cat_str(3,$1,mm_strdup("%"),$3);
11993 }
11994 | b_expr '^' b_expr
11995 {
11996 $$ = cat_str(3,$1,mm_strdup("^"),$3);
11997 }
11998 | b_expr '<' b_expr
11999 {
12000 $$ = cat_str(3,$1,mm_strdup("<"),$3);
12001 }
12002 | b_expr '>' b_expr
12003 {
12004 $$ = cat_str(3,$1,mm_strdup(">"),$3);
12005 }
12006 | b_expr '=' b_expr
12007 {
12008 $$ = cat_str(3,$1,mm_strdup("="),$3);
12009 }
12010 | b_expr LESS_EQUALS b_expr
12011 {
12012 $$ = cat_str(3,$1,mm_strdup("<="),$3);
12013 }
12014 | b_expr GREATER_EQUALS b_expr
12015 {
12016 $$ = cat_str(3,$1,mm_strdup(">="),$3);
12017 }
12018 | b_expr NOT_EQUALS b_expr
12019 {
12020 $$ = cat_str(3,$1,mm_strdup("<>"),$3);
12021 }
12022 | b_expr qual_Op b_expr %prec Op
12023 {
12024 $$ = cat_str(3,$1,$2,$3);
12025 }
12026 | qual_Op b_expr %prec Op
12027 {
12028 $$ = cat_str(2,$1,$2);
12029 }
12030 | b_expr qual_Op %prec POSTFIXOP
12031 {
12032 $$ = cat_str(2,$1,$2);
12033 }
12034 | b_expr IS DISTINCT FROM b_expr %prec IS
12035 {
12036 $$ = cat_str(3,$1,mm_strdup("is distinct from"),$5);
12037 }
12038 | b_expr IS NOT DISTINCT FROM b_expr %prec IS
12039 {
12040 $$ = cat_str(3,$1,mm_strdup("is not distinct from"),$6);
12041 }
12042 | b_expr IS OF '(' type_list ')' %prec IS
12043 {
12044 $$ = cat_str(4,$1,mm_strdup("is of ("),$5,mm_strdup(")"));
12045 }
12046 | b_expr IS NOT OF '(' type_list ')' %prec IS
12047 {
12048 $$ = cat_str(4,$1,mm_strdup("is not of ("),$6,mm_strdup(")"));
12049 }
12050 | b_expr IS DOCUMENT_P %prec IS
12051 {
12052 $$ = cat_str(2,$1,mm_strdup("is document"));
12053 }
12054 | b_expr IS NOT DOCUMENT_P %prec IS
12055 {
12056 $$ = cat_str(2,$1,mm_strdup("is not document"));
12057 }
12058 ;
12059
12060
12061 c_expr:
12062 columnref
12063 {
12064 $$ = $1;
12065 }
12066 | AexprConst
12067 {
12068 $$ = $1;
12069 }
12070 | ecpg_param opt_indirection
12071 {
12072 $$ = cat_str(2,$1,$2);
12073 }
12074 | '(' a_expr ')' opt_indirection
12075 {
12076 $$ = cat_str(4,mm_strdup("("),$2,mm_strdup(")"),$4);
12077 }
12078 | case_expr
12079 {
12080 $$ = $1;
12081 }
12082 | func_expr
12083 {
12084 $$ = $1;
12085 }
12086 | select_with_parens %prec UMINUS
12087 {
12088 $$ = $1;
12089 }
12090 | select_with_parens indirection
12091 {
12092 $$ = cat_str(2,$1,$2);
12093 }
12094 | EXISTS select_with_parens
12095 {
12096 $$ = cat_str(2,mm_strdup("exists"),$2);
12097 }
12098 | ARRAY select_with_parens
12099 {
12100 $$ = cat_str(2,mm_strdup("array"),$2);
12101 }
12102 | ARRAY array_expr
12103 {
12104 $$ = cat_str(2,mm_strdup("array"),$2);
12105 }
12106 | explicit_row
12107 {
12108 $$ = $1;
12109 }
12110 | implicit_row
12111 {
12112 $$ = $1;
12113 }
12114 | GROUPING '(' expr_list ')'
12115 {
12116 $$ = cat_str(3,mm_strdup("grouping ("),$3,mm_strdup(")"));
12117 }
12118 ;
12119
12120
12121 func_application:
12122 func_name '(' ')'
12123 {
12124 $$ = cat_str(2,$1,mm_strdup("( )"));
12125 }
12126 | func_name '(' func_arg_list opt_sort_clause ')'
12127 {
12128 $$ = cat_str(5,$1,mm_strdup("("),$3,$4,mm_strdup(")"));
12129 }
12130 | func_name '(' VARIADIC func_arg_expr opt_sort_clause ')'
12131 {
12132 $$ = cat_str(5,$1,mm_strdup("( variadic"),$4,$5,mm_strdup(")"));
12133 }
12134 | func_name '(' func_arg_list ',' VARIADIC func_arg_expr opt_sort_clause ')'
12135 {
12136 $$ = cat_str(7,$1,mm_strdup("("),$3,mm_strdup(", variadic"),$6,$7,mm_strdup(")"));
12137 }
12138 | func_name '(' ALL func_arg_list opt_sort_clause ')'
12139 {
12140 $$ = cat_str(5,$1,mm_strdup("( all"),$4,$5,mm_strdup(")"));
12141 }
12142 | func_name '(' DISTINCT func_arg_list opt_sort_clause ')'
12143 {
12144 $$ = cat_str(5,$1,mm_strdup("( distinct"),$4,$5,mm_strdup(")"));
12145 }
12146 | func_name '(' '*' ')'
12147 {
12148 $$ = cat_str(2,$1,mm_strdup("( * )"));
12149 }
12150 ;
12151
12152
12153 func_expr:
12154 func_application within_group_clause filter_clause over_clause
12155 {
12156 $$ = cat_str(4,$1,$2,$3,$4);
12157 }
12158 | func_expr_common_subexpr
12159 {
12160 $$ = $1;
12161 }
12162 ;
12163
12164
12165 func_expr_windowless:
12166 func_application
12167 {
12168 $$ = $1;
12169 }
12170 | func_expr_common_subexpr
12171 {
12172 $$ = $1;
12173 }
12174 ;
12175
12176
12177 func_expr_common_subexpr:
12178 COLLATION FOR '(' a_expr ')'
12179 {
12180 $$ = cat_str(3,mm_strdup("collation for ("),$4,mm_strdup(")"));
12181 }
12182 | CURRENT_DATE
12183 {
12184 $$ = mm_strdup("current_date");
12185 }
12186 | CURRENT_TIME
12187 {
12188 $$ = mm_strdup("current_time");
12189 }
12190 | CURRENT_TIME '(' Iconst ')'
12191 {
12192 $$ = cat_str(3,mm_strdup("current_time ("),$3,mm_strdup(")"));
12193 }
12194 | CURRENT_TIMESTAMP
12195 {
12196 $$ = mm_strdup("current_timestamp");
12197 }
12198 | CURRENT_TIMESTAMP '(' Iconst ')'
12199 {
12200 $$ = cat_str(3,mm_strdup("current_timestamp ("),$3,mm_strdup(")"));
12201 }
12202 | LOCALTIME
12203 {
12204 $$ = mm_strdup("localtime");
12205 }
12206 | LOCALTIME '(' Iconst ')'
12207 {
12208 $$ = cat_str(3,mm_strdup("localtime ("),$3,mm_strdup(")"));
12209 }
12210 | LOCALTIMESTAMP
12211 {
12212 $$ = mm_strdup("localtimestamp");
12213 }
12214 | LOCALTIMESTAMP '(' Iconst ')'
12215 {
12216 $$ = cat_str(3,mm_strdup("localtimestamp ("),$3,mm_strdup(")"));
12217 }
12218 | CURRENT_ROLE
12219 {
12220 $$ = mm_strdup("current_role");
12221 }
12222 | CURRENT_USER
12223 {
12224 $$ = mm_strdup("current_user");
12225 }
12226 | SESSION_USER
12227 {
12228 $$ = mm_strdup("session_user");
12229 }
12230 | USER
12231 {
12232 $$ = mm_strdup("user");
12233 }
12234 | CURRENT_CATALOG
12235 {
12236 $$ = mm_strdup("current_catalog");
12237 }
12238 | CURRENT_SCHEMA
12239 {
12240 $$ = mm_strdup("current_schema");
12241 }
12242 | CAST '(' a_expr AS Typename ')'
12243 {
12244 $$ = cat_str(5,mm_strdup("cast ("),$3,mm_strdup("as"),$5,mm_strdup(")"));
12245 }
12246 | EXTRACT '(' extract_list ')'
12247 {
12248 $$ = cat_str(3,mm_strdup("extract ("),$3,mm_strdup(")"));
12249 }
12250 | NORMALIZE '(' a_expr ')'
12251 {
12252 $$ = cat_str(3,mm_strdup("normalize ("),$3,mm_strdup(")"));
12253 }
12254 | NORMALIZE '(' a_expr ',' unicode_normal_form ')'
12255 {
12256 $$ = cat_str(5,mm_strdup("normalize ("),$3,mm_strdup(","),$5,mm_strdup(")"));
12257 }
12258 | OVERLAY '(' overlay_list ')'
12259 {
12260 $$ = cat_str(3,mm_strdup("overlay ("),$3,mm_strdup(")"));
12261 }
12262 | POSITION '(' position_list ')'
12263 {
12264 $$ = cat_str(3,mm_strdup("position ("),$3,mm_strdup(")"));
12265 }
12266 | SUBSTRING '(' substr_list ')'
12267 {
12268 $$ = cat_str(3,mm_strdup("substring ("),$3,mm_strdup(")"));
12269 }
12270 | TREAT '(' a_expr AS Typename ')'
12271 {
12272 $$ = cat_str(5,mm_strdup("treat ("),$3,mm_strdup("as"),$5,mm_strdup(")"));
12273 }
12274 | TRIM '(' BOTH trim_list ')'
12275 {
12276 $$ = cat_str(3,mm_strdup("trim ( both"),$4,mm_strdup(")"));
12277 }
12278 | TRIM '(' LEADING trim_list ')'
12279 {
12280 $$ = cat_str(3,mm_strdup("trim ( leading"),$4,mm_strdup(")"));
12281 }
12282 | TRIM '(' TRAILING trim_list ')'
12283 {
12284 $$ = cat_str(3,mm_strdup("trim ( trailing"),$4,mm_strdup(")"));
12285 }
12286 | TRIM '(' trim_list ')'
12287 {
12288 $$ = cat_str(3,mm_strdup("trim ("),$3,mm_strdup(")"));
12289 }
12290 | NULLIF '(' a_expr ',' a_expr ')'
12291 {
12292 $$ = cat_str(5,mm_strdup("nullif ("),$3,mm_strdup(","),$5,mm_strdup(")"));
12293 }
12294 | COALESCE '(' expr_list ')'
12295 {
12296 $$ = cat_str(3,mm_strdup("coalesce ("),$3,mm_strdup(")"));
12297 }
12298 | GREATEST '(' expr_list ')'
12299 {
12300 $$ = cat_str(3,mm_strdup("greatest ("),$3,mm_strdup(")"));
12301 }
12302 | LEAST '(' expr_list ')'
12303 {
12304 $$ = cat_str(3,mm_strdup("least ("),$3,mm_strdup(")"));
12305 }
12306 | XMLCONCAT '(' expr_list ')'
12307 {
12308 $$ = cat_str(3,mm_strdup("xmlconcat ("),$3,mm_strdup(")"));
12309 }
12310 | XMLELEMENT '(' NAME_P ColLabel ')'
12311 {
12312 $$ = cat_str(3,mm_strdup("xmlelement ( name"),$4,mm_strdup(")"));
12313 }
12314 | XMLELEMENT '(' NAME_P ColLabel ',' xml_attributes ')'
12315 {
12316 $$ = cat_str(5,mm_strdup("xmlelement ( name"),$4,mm_strdup(","),$6,mm_strdup(")"));
12317 }
12318 | XMLELEMENT '(' NAME_P ColLabel ',' expr_list ')'
12319 {
12320 $$ = cat_str(5,mm_strdup("xmlelement ( name"),$4,mm_strdup(","),$6,mm_strdup(")"));
12321 }
12322 | XMLELEMENT '(' NAME_P ColLabel ',' xml_attributes ',' expr_list ')'
12323 {
12324 $$ = cat_str(7,mm_strdup("xmlelement ( name"),$4,mm_strdup(","),$6,mm_strdup(","),$8,mm_strdup(")"));
12325 }
12326 | XMLEXISTS '(' c_expr xmlexists_argument ')'
12327 {
12328 $$ = cat_str(4,mm_strdup("xmlexists ("),$3,$4,mm_strdup(")"));
12329 }
12330 | XMLFOREST '(' xml_attribute_list ')'
12331 {
12332 $$ = cat_str(3,mm_strdup("xmlforest ("),$3,mm_strdup(")"));
12333 }
12334 | XMLPARSE '(' document_or_content a_expr xml_whitespace_option ')'
12335 {
12336 $$ = cat_str(5,mm_strdup("xmlparse ("),$3,$4,$5,mm_strdup(")"));
12337 }
12338 | XMLPI '(' NAME_P ColLabel ')'
12339 {
12340 $$ = cat_str(3,mm_strdup("xmlpi ( name"),$4,mm_strdup(")"));
12341 }
12342 | XMLPI '(' NAME_P ColLabel ',' a_expr ')'
12343 {
12344 $$ = cat_str(5,mm_strdup("xmlpi ( name"),$4,mm_strdup(","),$6,mm_strdup(")"));
12345 }
12346 | XMLROOT '(' a_expr ',' xml_root_version opt_xml_root_standalone ')'
12347 {
12348 $$ = cat_str(6,mm_strdup("xmlroot ("),$3,mm_strdup(","),$5,$6,mm_strdup(")"));
12349 }
12350 | XMLSERIALIZE '(' document_or_content a_expr AS SimpleTypename ')'
12351 {
12352 $$ = cat_str(6,mm_strdup("xmlserialize ("),$3,$4,mm_strdup("as"),$6,mm_strdup(")"));
12353 }
12354 ;
12355
12356
12357 xml_root_version:
12358 VERSION_P a_expr
12359 {
12360 $$ = cat_str(2,mm_strdup("version"),$2);
12361 }
12362 | VERSION_P NO VALUE_P
12363 {
12364 $$ = mm_strdup("version no value");
12365 }
12366 ;
12367
12368
12369 opt_xml_root_standalone:
12370 ',' STANDALONE_P YES_P
12371 {
12372 $$ = mm_strdup(", standalone yes");
12373 }
12374 | ',' STANDALONE_P NO
12375 {
12376 $$ = mm_strdup(", standalone no");
12377 }
12378 | ',' STANDALONE_P NO VALUE_P
12379 {
12380 $$ = mm_strdup(", standalone no value");
12381 }
12382 |
12383 {
12384 $$=EMPTY; }
12385 ;
12386
12387
12388 xml_attributes:
12389 XMLATTRIBUTES '(' xml_attribute_list ')'
12390 {
12391 $$ = cat_str(3,mm_strdup("xmlattributes ("),$3,mm_strdup(")"));
12392 }
12393 ;
12394
12395
12396 xml_attribute_list:
12397 xml_attribute_el
12398 {
12399 $$ = $1;
12400 }
12401 | xml_attribute_list ',' xml_attribute_el
12402 {
12403 $$ = cat_str(3,$1,mm_strdup(","),$3);
12404 }
12405 ;
12406
12407
12408 xml_attribute_el:
12409 a_expr AS ColLabel
12410 {
12411 $$ = cat_str(3,$1,mm_strdup("as"),$3);
12412 }
12413 | a_expr
12414 {
12415 $$ = $1;
12416 }
12417 ;
12418
12419
12420 document_or_content:
12421 DOCUMENT_P
12422 {
12423 $$ = mm_strdup("document");
12424 }
12425 | CONTENT_P
12426 {
12427 $$ = mm_strdup("content");
12428 }
12429 ;
12430
12431
12432 xml_whitespace_option:
12433 PRESERVE WHITESPACE_P
12434 {
12435 $$ = mm_strdup("preserve whitespace");
12436 }
12437 | STRIP_P WHITESPACE_P
12438 {
12439 $$ = mm_strdup("strip whitespace");
12440 }
12441 |
12442 {
12443 $$=EMPTY; }
12444 ;
12445
12446
12447 xmlexists_argument:
12448 PASSING c_expr
12449 {
12450 $$ = cat_str(2,mm_strdup("passing"),$2);
12451 }
12452 | PASSING c_expr xml_passing_mech
12453 {
12454 $$ = cat_str(3,mm_strdup("passing"),$2,$3);
12455 }
12456 | PASSING xml_passing_mech c_expr
12457 {
12458 $$ = cat_str(3,mm_strdup("passing"),$2,$3);
12459 }
12460 | PASSING xml_passing_mech c_expr xml_passing_mech
12461 {
12462 $$ = cat_str(4,mm_strdup("passing"),$2,$3,$4);
12463 }
12464 ;
12465
12466
12467 xml_passing_mech:
12468 BY REF
12469 {
12470 $$ = mm_strdup("by ref");
12471 }
12472 | BY VALUE_P
12473 {
12474 $$ = mm_strdup("by value");
12475 }
12476 ;
12477
12478
12479 within_group_clause:
12480 WITHIN GROUP_P '(' sort_clause ')'
12481 {
12482 $$ = cat_str(3,mm_strdup("within group ("),$4,mm_strdup(")"));
12483 }
12484 |
12485 {
12486 $$=EMPTY; }
12487 ;
12488
12489
12490 filter_clause:
12491 FILTER '(' WHERE a_expr ')'
12492 {
12493 $$ = cat_str(3,mm_strdup("filter ( where"),$4,mm_strdup(")"));
12494 }
12495 |
12496 {
12497 $$=EMPTY; }
12498 ;
12499
12500
12501 window_clause:
12502 WINDOW window_definition_list
12503 {
12504 $$ = cat_str(2,mm_strdup("window"),$2);
12505 }
12506 |
12507 {
12508 $$=EMPTY; }
12509 ;
12510
12511
12512 window_definition_list:
12513 window_definition
12514 {
12515 $$ = $1;
12516 }
12517 | window_definition_list ',' window_definition
12518 {
12519 $$ = cat_str(3,$1,mm_strdup(","),$3);
12520 }
12521 ;
12522
12523
12524 window_definition:
12525 ColId AS window_specification
12526 {
12527 $$ = cat_str(3,$1,mm_strdup("as"),$3);
12528 }
12529 ;
12530
12531
12532 over_clause:
12533 OVER window_specification
12534 {
12535 $$ = cat_str(2,mm_strdup("over"),$2);
12536 }
12537 | OVER ColId
12538 {
12539 $$ = cat_str(2,mm_strdup("over"),$2);
12540 }
12541 |
12542 {
12543 $$=EMPTY; }
12544 ;
12545
12546
12547 window_specification:
12548 '(' opt_existing_window_name opt_partition_clause opt_sort_clause opt_frame_clause ')'
12549 {
12550 $$ = cat_str(6,mm_strdup("("),$2,$3,$4,$5,mm_strdup(")"));
12551 }
12552 ;
12553
12554
12555 opt_existing_window_name:
12556 ColId
12557 {
12558 $$ = $1;
12559 }
12560 | %prec Op
12561 {
12562 $$=EMPTY; }
12563 ;
12564
12565
12566 opt_partition_clause:
12567 PARTITION BY expr_list
12568 {
12569 $$ = cat_str(2,mm_strdup("partition by"),$3);
12570 }
12571 |
12572 {
12573 $$=EMPTY; }
12574 ;
12575
12576
12577 opt_frame_clause:
12578 RANGE frame_extent opt_window_exclusion_clause
12579 {
12580 $$ = cat_str(3,mm_strdup("range"),$2,$3);
12581 }
12582 | ROWS frame_extent opt_window_exclusion_clause
12583 {
12584 $$ = cat_str(3,mm_strdup("rows"),$2,$3);
12585 }
12586 | GROUPS frame_extent opt_window_exclusion_clause
12587 {
12588 $$ = cat_str(3,mm_strdup("groups"),$2,$3);
12589 }
12590 |
12591 {
12592 $$=EMPTY; }
12593 ;
12594
12595
12596 frame_extent:
12597 frame_bound
12598 {
12599 $$ = $1;
12600 }
12601 | BETWEEN frame_bound AND frame_bound
12602 {
12603 $$ = cat_str(4,mm_strdup("between"),$2,mm_strdup("and"),$4);
12604 }
12605 ;
12606
12607
12608 frame_bound:
12609 UNBOUNDED PRECEDING
12610 {
12611 $$ = mm_strdup("unbounded preceding");
12612 }
12613 | UNBOUNDED FOLLOWING
12614 {
12615 $$ = mm_strdup("unbounded following");
12616 }
12617 | CURRENT_P ROW
12618 {
12619 $$ = mm_strdup("current row");
12620 }
12621 | a_expr PRECEDING
12622 {
12623 $$ = cat_str(2,$1,mm_strdup("preceding"));
12624 }
12625 | a_expr FOLLOWING
12626 {
12627 $$ = cat_str(2,$1,mm_strdup("following"));
12628 }
12629 ;
12630
12631
12632 opt_window_exclusion_clause:
12633 EXCLUDE CURRENT_P ROW
12634 {
12635 $$ = mm_strdup("exclude current row");
12636 }
12637 | EXCLUDE GROUP_P
12638 {
12639 $$ = mm_strdup("exclude group");
12640 }
12641 | EXCLUDE TIES
12642 {
12643 $$ = mm_strdup("exclude ties");
12644 }
12645 | EXCLUDE NO OTHERS
12646 {
12647 $$ = mm_strdup("exclude no others");
12648 }
12649 |
12650 {
12651 $$=EMPTY; }
12652 ;
12653
12654
12655 row:
12656 ROW '(' expr_list ')'
12657 {
12658 $$ = cat_str(3,mm_strdup("row ("),$3,mm_strdup(")"));
12659 }
12660 | ROW '(' ')'
12661 {
12662 $$ = mm_strdup("row ( )");
12663 }
12664 | '(' expr_list ',' a_expr ')'
12665 {
12666 $$ = cat_str(5,mm_strdup("("),$2,mm_strdup(","),$4,mm_strdup(")"));
12667 }
12668 ;
12669
12670
12671 explicit_row:
12672 ROW '(' expr_list ')'
12673 {
12674 $$ = cat_str(3,mm_strdup("row ("),$3,mm_strdup(")"));
12675 }
12676 | ROW '(' ')'
12677 {
12678 $$ = mm_strdup("row ( )");
12679 }
12680 ;
12681
12682
12683 implicit_row:
12684 '(' expr_list ',' a_expr ')'
12685 {
12686 $$ = cat_str(5,mm_strdup("("),$2,mm_strdup(","),$4,mm_strdup(")"));
12687 }
12688 ;
12689
12690
12691 sub_type:
12692 ANY
12693 {
12694 $$ = mm_strdup("any");
12695 }
12696 | SOME
12697 {
12698 $$ = mm_strdup("some");
12699 }
12700 | ALL
12701 {
12702 $$ = mm_strdup("all");
12703 }
12704 ;
12705
12706
12707 all_Op:
12708 Op
12709 {
12710 $$ = $1;
12711 }
12712 | MathOp
12713 {
12714 $$ = $1;
12715 }
12716 ;
12717
12718
12719 MathOp:
12720 '+'
12721 {
12722 $$ = mm_strdup("+");
12723 }
12724 | '-'
12725 {
12726 $$ = mm_strdup("-");
12727 }
12728 | '*'
12729 {
12730 $$ = mm_strdup("*");
12731 }
12732 | '/'
12733 {
12734 $$ = mm_strdup("/");
12735 }
12736 | '%'
12737 {
12738 $$ = mm_strdup("%");
12739 }
12740 | '^'
12741 {
12742 $$ = mm_strdup("^");
12743 }
12744 | '<'
12745 {
12746 $$ = mm_strdup("<");
12747 }
12748 | '>'
12749 {
12750 $$ = mm_strdup(">");
12751 }
12752 | '='
12753 {
12754 $$ = mm_strdup("=");
12755 }
12756 | LESS_EQUALS
12757 {
12758 $$ = mm_strdup("<=");
12759 }
12760 | GREATER_EQUALS
12761 {
12762 $$ = mm_strdup(">=");
12763 }
12764 | NOT_EQUALS
12765 {
12766 $$ = mm_strdup("<>");
12767 }
12768 ;
12769
12770
12771 qual_Op:
12772 Op
12773 {
12774 $$ = $1;
12775 }
12776 | OPERATOR '(' any_operator ')'
12777 {
12778 $$ = cat_str(3,mm_strdup("operator ("),$3,mm_strdup(")"));
12779 }
12780 ;
12781
12782
12783 qual_all_Op:
12784 all_Op
12785 {
12786 $$ = $1;
12787 }
12788 | OPERATOR '(' any_operator ')'
12789 {
12790 $$ = cat_str(3,mm_strdup("operator ("),$3,mm_strdup(")"));
12791 }
12792 ;
12793
12794
12795 subquery_Op:
12796 all_Op
12797 {
12798 $$ = $1;
12799 }
12800 | OPERATOR '(' any_operator ')'
12801 {
12802 $$ = cat_str(3,mm_strdup("operator ("),$3,mm_strdup(")"));
12803 }
12804 | LIKE
12805 {
12806 $$ = mm_strdup("like");
12807 }
12808 | NOT_LA LIKE
12809 {
12810 $$ = mm_strdup("not like");
12811 }
12812 | ILIKE
12813 {
12814 $$ = mm_strdup("ilike");
12815 }
12816 | NOT_LA ILIKE
12817 {
12818 $$ = mm_strdup("not ilike");
12819 }
12820 ;
12821
12822
12823 expr_list:
12824 a_expr
12825 {
12826 $$ = $1;
12827 }
12828 | expr_list ',' a_expr
12829 {
12830 $$ = cat_str(3,$1,mm_strdup(","),$3);
12831 }
12832 ;
12833
12834
12835 func_arg_list:
12836 func_arg_expr
12837 {
12838 $$ = $1;
12839 }
12840 | func_arg_list ',' func_arg_expr
12841 {
12842 $$ = cat_str(3,$1,mm_strdup(","),$3);
12843 }
12844 ;
12845
12846
12847 func_arg_expr:
12848 a_expr
12849 {
12850 $$ = $1;
12851 }
12852 | param_name COLON_EQUALS a_expr
12853 {
12854 $$ = cat_str(3,$1,mm_strdup(":="),$3);
12855 }
12856 | param_name EQUALS_GREATER a_expr
12857 {
12858 $$ = cat_str(3,$1,mm_strdup("=>"),$3);
12859 }
12860 ;
12861
12862
12863 type_list:
12864 Typename
12865 {
12866 $$ = $1;
12867 }
12868 | type_list ',' Typename
12869 {
12870 $$ = cat_str(3,$1,mm_strdup(","),$3);
12871 }
12872 ;
12873
12874
12875 array_expr:
12876 '[' expr_list ']'
12877 {
12878 $$ = cat_str(3,mm_strdup("["),$2,mm_strdup("]"));
12879 }
12880 | '[' array_expr_list ']'
12881 {
12882 $$ = cat_str(3,mm_strdup("["),$2,mm_strdup("]"));
12883 }
12884 | '[' ']'
12885 {
12886 $$ = mm_strdup("[ ]");
12887 }
12888 ;
12889
12890
12891 array_expr_list:
12892 array_expr
12893 {
12894 $$ = $1;
12895 }
12896 | array_expr_list ',' array_expr
12897 {
12898 $$ = cat_str(3,$1,mm_strdup(","),$3);
12899 }
12900 ;
12901
12902
12903 extract_list:
12904 extract_arg FROM a_expr
12905 {
12906 $$ = cat_str(3,$1,mm_strdup("from"),$3);
12907 }
12908 |
12909 {
12910 $$=EMPTY; }
12911 ;
12912
12913
12914 extract_arg:
12915 ecpg_ident
12916 {
12917 $$ = $1;
12918 }
12919 | YEAR_P
12920 {
12921 $$ = mm_strdup("year");
12922 }
12923 | MONTH_P
12924 {
12925 $$ = mm_strdup("month");
12926 }
12927 | DAY_P
12928 {
12929 $$ = mm_strdup("day");
12930 }
12931 | HOUR_P
12932 {
12933 $$ = mm_strdup("hour");
12934 }
12935 | MINUTE_P
12936 {
12937 $$ = mm_strdup("minute");
12938 }
12939 | SECOND_P
12940 {
12941 $$ = mm_strdup("second");
12942 }
12943 | ecpg_sconst
12944 {
12945 $$ = $1;
12946 }
12947 ;
12948
12949
12950 unicode_normal_form:
12951 NFC
12952 {
12953 $$ = mm_strdup("nfc");
12954 }
12955 | NFD
12956 {
12957 $$ = mm_strdup("nfd");
12958 }
12959 | NFKC
12960 {
12961 $$ = mm_strdup("nfkc");
12962 }
12963 | NFKD
12964 {
12965 $$ = mm_strdup("nfkd");
12966 }
12967 ;
12968
12969
12970 overlay_list:
12971 a_expr overlay_placing substr_from substr_for
12972 {
12973 $$ = cat_str(4,$1,$2,$3,$4);
12974 }
12975 | a_expr overlay_placing substr_from
12976 {
12977 $$ = cat_str(3,$1,$2,$3);
12978 }
12979 ;
12980
12981
12982 overlay_placing:
12983 PLACING a_expr
12984 {
12985 $$ = cat_str(2,mm_strdup("placing"),$2);
12986 }
12987 ;
12988
12989
12990 position_list:
12991 b_expr IN_P b_expr
12992 {
12993 $$ = cat_str(3,$1,mm_strdup("in"),$3);
12994 }
12995 |
12996 {
12997 $$=EMPTY; }
12998 ;
12999
13000
13001 substr_list:
13002 a_expr substr_from substr_for
13003 {
13004 $$ = cat_str(3,$1,$2,$3);
13005 }
13006 | a_expr substr_for substr_from
13007 {
13008 $$ = cat_str(3,$1,$2,$3);
13009 }
13010 | a_expr substr_from
13011 {
13012 $$ = cat_str(2,$1,$2);
13013 }
13014 | a_expr substr_for
13015 {
13016 $$ = cat_str(2,$1,$2);
13017 }
13018 | expr_list
13019 {
13020 $$ = $1;
13021 }
13022 |
13023 {
13024 $$=EMPTY; }
13025 ;
13026
13027
13028 substr_from:
13029 FROM a_expr
13030 {
13031 $$ = cat_str(2,mm_strdup("from"),$2);
13032 }
13033 ;
13034
13035
13036 substr_for:
13037 FOR a_expr
13038 {
13039 $$ = cat_str(2,mm_strdup("for"),$2);
13040 }
13041 ;
13042
13043
13044 trim_list:
13045 a_expr FROM expr_list
13046 {
13047 $$ = cat_str(3,$1,mm_strdup("from"),$3);
13048 }
13049 | FROM expr_list
13050 {
13051 $$ = cat_str(2,mm_strdup("from"),$2);
13052 }
13053 | expr_list
13054 {
13055 $$ = $1;
13056 }
13057 ;
13058
13059
13060 in_expr:
13061 select_with_parens
13062 {
13063 $$ = $1;
13064 }
13065 | '(' expr_list ')'
13066 {
13067 $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
13068 }
13069 ;
13070
13071
13072 case_expr:
13073 CASE case_arg when_clause_list case_default END_P
13074 {
13075 $$ = cat_str(5,mm_strdup("case"),$2,$3,$4,mm_strdup("end"));
13076 }
13077 ;
13078
13079
13080 when_clause_list:
13081 when_clause
13082 {
13083 $$ = $1;
13084 }
13085 | when_clause_list when_clause
13086 {
13087 $$ = cat_str(2,$1,$2);
13088 }
13089 ;
13090
13091
13092 when_clause:
13093 WHEN a_expr THEN a_expr
13094 {
13095 $$ = cat_str(4,mm_strdup("when"),$2,mm_strdup("then"),$4);
13096 }
13097 ;
13098
13099
13100 case_default:
13101 ELSE a_expr
13102 {
13103 $$ = cat_str(2,mm_strdup("else"),$2);
13104 }
13105 |
13106 {
13107 $$=EMPTY; }
13108 ;
13109
13110
13111 case_arg:
13112 a_expr
13113 {
13114 $$ = $1;
13115 }
13116 |
13117 {
13118 $$=EMPTY; }
13119 ;
13120
13121
13122 columnref:
13123 ColId
13124 {
13125 $$ = $1;
13126 }
13127 | ColId indirection
13128 {
13129 $$ = cat_str(2,$1,$2);
13130 }
13131 ;
13132
13133
13134 indirection_el:
13135 '.' attr_name
13136 {
13137 $$ = cat_str(2,mm_strdup("."),$2);
13138 }
13139 | '.' '*'
13140 {
13141 $$ = mm_strdup(". *");
13142 }
13143 | '[' a_expr ']'
13144 {
13145 $$ = cat_str(3,mm_strdup("["),$2,mm_strdup("]"));
13146 }
13147 | '[' opt_slice_bound ':' opt_slice_bound ']'
13148 {
13149 $$ = cat_str(5,mm_strdup("["),$2,mm_strdup(":"),$4,mm_strdup("]"));
13150 }
13151 ;
13152
13153
13154 opt_slice_bound:
13155 a_expr
13156 {
13157 $$ = $1;
13158 }
13159 |
13160 {
13161 $$=EMPTY; }
13162 ;
13163
13164
13165 indirection:
13166 indirection_el
13167 {
13168 $$ = $1;
13169 }
13170 | indirection indirection_el
13171 {
13172 $$ = cat_str(2,$1,$2);
13173 }
13174 ;
13175
13176
13177 opt_indirection:
13178
13179 {
13180 $$=EMPTY; }
13181 | opt_indirection indirection_el
13182 {
13183 $$ = cat_str(2,$1,$2);
13184 }
13185 ;
13186
13187
13188 opt_asymmetric:
13189 ASYMMETRIC
13190 {
13191 $$ = mm_strdup("asymmetric");
13192 }
13193 |
13194 {
13195 $$=EMPTY; }
13196 ;
13197
13198
13199 opt_target_list:
13200 target_list
13201 {
13202 $$ = $1;
13203 }
13204 |
13205 {
13206 $$=EMPTY; }
13207 ;
13208
13209
13210 target_list:
13211 target_el
13212 {
13213 $$ = $1;
13214 }
13215 | target_list ',' target_el
13216 {
13217 $$ = cat_str(3,$1,mm_strdup(","),$3);
13218 }
13219 ;
13220
13221
13222 target_el:
13223 a_expr AS ColLabel
13224 {
13225 $$ = cat_str(3,$1,mm_strdup("as"),$3);
13226 }
13227 | a_expr ecpg_ident
13228 {
13229 $$ = cat_str(2,$1,$2);
13230 }
13231 | a_expr
13232 {
13233 $$ = $1;
13234 }
13235 | '*'
13236 {
13237 $$ = mm_strdup("*");
13238 }
13239 ;
13240
13241
13242 qualified_name_list:
13243 qualified_name
13244 {
13245 $$ = $1;
13246 }
13247 | qualified_name_list ',' qualified_name
13248 {
13249 $$ = cat_str(3,$1,mm_strdup(","),$3);
13250 }
13251 ;
13252
13253
13254 qualified_name:
13255 ColId
13256 {
13257 $$ = $1;
13258 }
13259 | ColId indirection
13260 {
13261 $$ = cat_str(2,$1,$2);
13262 }
13263 ;
13264
13265
13266 name_list:
13267 name
13268 {
13269 $$ = $1;
13270 }
13271 | name_list ',' name
13272 {
13273 $$ = cat_str(3,$1,mm_strdup(","),$3);
13274 }
13275 ;
13276
13277
13278 name:
13279 ColId
13280 {
13281 $$ = $1;
13282 }
13283 ;
13284
13285
13286 database_name:
13287 ColId
13288 {
13289 $$ = $1;
13290 }
13291 ;
13292
13293
13294 access_method:
13295 ColId
13296 {
13297 $$ = $1;
13298 }
13299 ;
13300
13301
13302 attr_name:
13303 ColLabel
13304 {
13305 $$ = $1;
13306 }
13307 ;
13308
13309
13310 index_name:
13311 ColId
13312 {
13313 $$ = $1;
13314 }
13315 ;
13316
13317
13318 file_name:
13319 ecpg_sconst
13320 {
13321 $$ = $1;
13322 }
13323 ;
13324
13325
13326 func_name:
13327 type_function_name
13328 {
13329 $$ = $1;
13330 }
13331 | ColId indirection
13332 {
13333 $$ = cat_str(2,$1,$2);
13334 }
13335 ;
13336
13337
13338 AexprConst:
13339 Iconst
13340 {
13341 $$ = $1;
13342 }
13343 | ecpg_fconst
13344 {
13345 $$ = $1;
13346 }
13347 | ecpg_sconst
13348 {
13349 $$ = $1;
13350 }
13351 | ecpg_bconst
13352 {
13353 $$ = $1;
13354 }
13355 | ecpg_xconst
13356 {
13357 $$ = $1;
13358 }
13359 | func_name ecpg_sconst
13360 {
13361 $$ = cat_str(2,$1,$2);
13362 }
13363 | func_name '(' func_arg_list opt_sort_clause ')' ecpg_sconst
13364 {
13365 $$ = cat_str(6,$1,mm_strdup("("),$3,$4,mm_strdup(")"),$6);
13366 }
13367 | ConstTypename ecpg_sconst
13368 {
13369 $$ = cat_str(2,$1,$2);
13370 }
13371 | ConstInterval ecpg_sconst opt_interval
13372 {
13373 $$ = cat_str(3,$1,$2,$3);
13374 }
13375 | ConstInterval '(' Iconst ')' ecpg_sconst
13376 {
13377 $$ = cat_str(5,$1,mm_strdup("("),$3,mm_strdup(")"),$5);
13378 }
13379 | TRUE_P
13380 {
13381 $$ = mm_strdup("true");
13382 }
13383 | FALSE_P
13384 {
13385 $$ = mm_strdup("false");
13386 }
13387 | NULL_P
13388 {
13389 $$ = mm_strdup("null");
13390 }
13391 | civar { $$ = $1; }
13392 | civarind { $$ = $1; }
13393 ;
13394
13395
13396 Iconst:
13397 ICONST
13398 { $$ = make_name(); }
13399 ;
13400
13401
13402 SignedIconst:
13403 Iconst
13404 {
13405 $$ = $1;
13406 }
13407 | civar { $$ = $1; }
13408 | '+' Iconst
13409 {
13410 $$ = cat_str(2,mm_strdup("+"),$2);
13411 }
13412 | '-' Iconst
13413 {
13414 $$ = cat_str(2,mm_strdup("-"),$2);
13415 }
13416 ;
13417
13418
13419 RoleId:
13420 RoleSpec
13421 {
13422 $$ = $1;
13423 }
13424 ;
13425
13426
13427 RoleSpec:
13428 NonReservedWord
13429 {
13430 $$ = $1;
13431 }
13432 | CURRENT_USER
13433 {
13434 $$ = mm_strdup("current_user");
13435 }
13436 | SESSION_USER
13437 {
13438 $$ = mm_strdup("session_user");
13439 }
13440 ;
13441
13442
13443 role_list:
13444 RoleSpec
13445 {
13446 $$ = $1;
13447 }
13448 | role_list ',' RoleSpec
13449 {
13450 $$ = cat_str(3,$1,mm_strdup(","),$3);
13451 }
13452 ;
13453
13454
13455 NonReservedWord:
13456 ecpg_ident
13457 {
13458 $$ = $1;
13459 }
13460 | unreserved_keyword
13461 {
13462 $$ = $1;
13463 }
13464 | col_name_keyword
13465 {
13466 $$ = $1;
13467 }
13468 | type_func_name_keyword
13469 {
13470 $$ = $1;
13471 }
13472 ;
13473
13474
13475 unreserved_keyword:
13476 ABORT_P
13477 {
13478 $$ = mm_strdup("abort");
13479 }
13480 | ABSOLUTE_P
13481 {
13482 $$ = mm_strdup("absolute");
13483 }
13484 | ACCESS
13485 {
13486 $$ = mm_strdup("access");
13487 }
13488 | ACTION
13489 {
13490 $$ = mm_strdup("action");
13491 }
13492 | ADD_P
13493 {
13494 $$ = mm_strdup("add");
13495 }
13496 | ADMIN
13497 {
13498 $$ = mm_strdup("admin");
13499 }
13500 | AFTER
13501 {
13502 $$ = mm_strdup("after");
13503 }
13504 | AGGREGATE
13505 {
13506 $$ = mm_strdup("aggregate");
13507 }
13508 | ALSO
13509 {
13510 $$ = mm_strdup("also");
13511 }
13512 | ALTER
13513 {
13514 $$ = mm_strdup("alter");
13515 }
13516 | ALWAYS
13517 {
13518 $$ = mm_strdup("always");
13519 }
13520 | ASSERTION
13521 {
13522 $$ = mm_strdup("assertion");
13523 }
13524 | ASSIGNMENT
13525 {
13526 $$ = mm_strdup("assignment");
13527 }
13528 | AT
13529 {
13530 $$ = mm_strdup("at");
13531 }
13532 | ATTACH
13533 {
13534 $$ = mm_strdup("attach");
13535 }
13536 | ATTRIBUTE
13537 {
13538 $$ = mm_strdup("attribute");
13539 }
13540 | BACKWARD
13541 {
13542 $$ = mm_strdup("backward");
13543 }
13544 | BEFORE
13545 {
13546 $$ = mm_strdup("before");
13547 }
13548 | BEGIN_P
13549 {
13550 $$ = mm_strdup("begin");
13551 }
13552 | BY
13553 {
13554 $$ = mm_strdup("by");
13555 }
13556 | CACHE
13557 {
13558 $$ = mm_strdup("cache");
13559 }
13560 | CALL
13561 {
13562 $$ = mm_strdup("call");
13563 }
13564 | CALLED
13565 {
13566 $$ = mm_strdup("called");
13567 }
13568 | CASCADE
13569 {
13570 $$ = mm_strdup("cascade");
13571 }
13572 | CASCADED
13573 {
13574 $$ = mm_strdup("cascaded");
13575 }
13576 | CATALOG_P
13577 {
13578 $$ = mm_strdup("catalog");
13579 }
13580 | CHAIN
13581 {
13582 $$ = mm_strdup("chain");
13583 }
13584 | CHARACTERISTICS
13585 {
13586 $$ = mm_strdup("characteristics");
13587 }
13588 | CHECKPOINT
13589 {
13590 $$ = mm_strdup("checkpoint");
13591 }
13592 | CLASS
13593 {
13594 $$ = mm_strdup("class");
13595 }
13596 | CLOSE
13597 {
13598 $$ = mm_strdup("close");
13599 }
13600 | CLUSTER
13601 {
13602 $$ = mm_strdup("cluster");
13603 }
13604 | COLUMNS
13605 {
13606 $$ = mm_strdup("columns");
13607 }
13608 | COMMENT
13609 {
13610 $$ = mm_strdup("comment");
13611 }
13612 | COMMENTS
13613 {
13614 $$ = mm_strdup("comments");
13615 }
13616 | COMMIT
13617 {
13618 $$ = mm_strdup("commit");
13619 }
13620 | COMMITTED
13621 {
13622 $$ = mm_strdup("committed");
13623 }
13624 | CONFIGURATION
13625 {
13626 $$ = mm_strdup("configuration");
13627 }
13628 | CONFLICT
13629 {
13630 $$ = mm_strdup("conflict");
13631 }
13632 | CONSTRAINTS
13633 {
13634 $$ = mm_strdup("constraints");
13635 }
13636 | CONTENT_P
13637 {
13638 $$ = mm_strdup("content");
13639 }
13640 | CONTINUE_P
13641 {
13642 $$ = mm_strdup("continue");
13643 }
13644 | CONVERSION_P
13645 {
13646 $$ = mm_strdup("conversion");
13647 }
13648 | COPY
13649 {
13650 $$ = mm_strdup("copy");
13651 }
13652 | COST
13653 {
13654 $$ = mm_strdup("cost");
13655 }
13656 | CSV
13657 {
13658 $$ = mm_strdup("csv");
13659 }
13660 | CUBE
13661 {
13662 $$ = mm_strdup("cube");
13663 }
13664 | CURSOR
13665 {
13666 $$ = mm_strdup("cursor");
13667 }
13668 | CYCLE
13669 {
13670 $$ = mm_strdup("cycle");
13671 }
13672 | DATA_P
13673 {
13674 $$ = mm_strdup("data");
13675 }
13676 | DATABASE
13677 {
13678 $$ = mm_strdup("database");
13679 }
13680 | DEALLOCATE
13681 {
13682 $$ = mm_strdup("deallocate");
13683 }
13684 | DECLARE
13685 {
13686 $$ = mm_strdup("declare");
13687 }
13688 | DEFAULTS
13689 {
13690 $$ = mm_strdup("defaults");
13691 }
13692 | DEFERRED
13693 {
13694 $$ = mm_strdup("deferred");
13695 }
13696 | DEFINER
13697 {
13698 $$ = mm_strdup("definer");
13699 }
13700 | DELETE_P
13701 {
13702 $$ = mm_strdup("delete");
13703 }
13704 | DELIMITER
13705 {
13706 $$ = mm_strdup("delimiter");
13707 }
13708 | DELIMITERS
13709 {
13710 $$ = mm_strdup("delimiters");
13711 }
13712 | DEPENDS
13713 {
13714 $$ = mm_strdup("depends");
13715 }
13716 | DETACH
13717 {
13718 $$ = mm_strdup("detach");
13719 }
13720 | DICTIONARY
13721 {
13722 $$ = mm_strdup("dictionary");
13723 }
13724 | DISABLE_P
13725 {
13726 $$ = mm_strdup("disable");
13727 }
13728 | DISCARD
13729 {
13730 $$ = mm_strdup("discard");
13731 }
13732 | DOCUMENT_P
13733 {
13734 $$ = mm_strdup("document");
13735 }
13736 | DOMAIN_P
13737 {
13738 $$ = mm_strdup("domain");
13739 }
13740 | DOUBLE_P
13741 {
13742 $$ = mm_strdup("double");
13743 }
13744 | DROP
13745 {
13746 $$ = mm_strdup("drop");
13747 }
13748 | EACH
13749 {
13750 $$ = mm_strdup("each");
13751 }
13752 | ENABLE_P
13753 {
13754 $$ = mm_strdup("enable");
13755 }
13756 | ENCODING
13757 {
13758 $$ = mm_strdup("encoding");
13759 }
13760 | ENCRYPTED
13761 {
13762 $$ = mm_strdup("encrypted");
13763 }
13764 | ENUM_P
13765 {
13766 $$ = mm_strdup("enum");
13767 }
13768 | ESCAPE
13769 {
13770 $$ = mm_strdup("escape");
13771 }
13772 | EVENT
13773 {
13774 $$ = mm_strdup("event");
13775 }
13776 | EXCLUDE
13777 {
13778 $$ = mm_strdup("exclude");
13779 }
13780 | EXCLUDING
13781 {
13782 $$ = mm_strdup("excluding");
13783 }
13784 | EXCLUSIVE
13785 {
13786 $$ = mm_strdup("exclusive");
13787 }
13788 | EXECUTE
13789 {
13790 $$ = mm_strdup("execute");
13791 }
13792 | EXPLAIN
13793 {
13794 $$ = mm_strdup("explain");
13795 }
13796 | EXPRESSION
13797 {
13798 $$ = mm_strdup("expression");
13799 }
13800 | EXTENSION
13801 {
13802 $$ = mm_strdup("extension");
13803 }
13804 | EXTERNAL
13805 {
13806 $$ = mm_strdup("external");
13807 }
13808 | FAMILY
13809 {
13810 $$ = mm_strdup("family");
13811 }
13812 | FILTER
13813 {
13814 $$ = mm_strdup("filter");
13815 }
13816 | FIRST_P
13817 {
13818 $$ = mm_strdup("first");
13819 }
13820 | FOLLOWING
13821 {
13822 $$ = mm_strdup("following");
13823 }
13824 | FORCE
13825 {
13826 $$ = mm_strdup("force");
13827 }
13828 | FORWARD
13829 {
13830 $$ = mm_strdup("forward");
13831 }
13832 | FUNCTION
13833 {
13834 $$ = mm_strdup("function");
13835 }
13836 | FUNCTIONS
13837 {
13838 $$ = mm_strdup("functions");
13839 }
13840 | GENERATED
13841 {
13842 $$ = mm_strdup("generated");
13843 }
13844 | GLOBAL
13845 {
13846 $$ = mm_strdup("global");
13847 }
13848 | GRANTED
13849 {
13850 $$ = mm_strdup("granted");
13851 }
13852 | GROUPS
13853 {
13854 $$ = mm_strdup("groups");
13855 }
13856 | HANDLER
13857 {
13858 $$ = mm_strdup("handler");
13859 }
13860 | HEADER_P
13861 {
13862 $$ = mm_strdup("header");
13863 }
13864 | HOLD
13865 {
13866 $$ = mm_strdup("hold");
13867 }
13868 | IDENTITY_P
13869 {
13870 $$ = mm_strdup("identity");
13871 }
13872 | IF_P
13873 {
13874 $$ = mm_strdup("if");
13875 }
13876 | IMMEDIATE
13877 {
13878 $$ = mm_strdup("immediate");
13879 }
13880 | IMMUTABLE
13881 {
13882 $$ = mm_strdup("immutable");
13883 }
13884 | IMPLICIT_P
13885 {
13886 $$ = mm_strdup("implicit");
13887 }
13888 | IMPORT_P
13889 {
13890 $$ = mm_strdup("import");
13891 }
13892 | INCLUDE
13893 {
13894 $$ = mm_strdup("include");
13895 }
13896 | INCLUDING
13897 {
13898 $$ = mm_strdup("including");
13899 }
13900 | INCREMENT
13901 {
13902 $$ = mm_strdup("increment");
13903 }
13904 | INDEX
13905 {
13906 $$ = mm_strdup("index");
13907 }
13908 | INDEXES
13909 {
13910 $$ = mm_strdup("indexes");
13911 }
13912 | INHERIT
13913 {
13914 $$ = mm_strdup("inherit");
13915 }
13916 | INHERITS
13917 {
13918 $$ = mm_strdup("inherits");
13919 }
13920 | INLINE_P
13921 {
13922 $$ = mm_strdup("inline");
13923 }
13924 | INSENSITIVE
13925 {
13926 $$ = mm_strdup("insensitive");
13927 }
13928 | INSERT
13929 {
13930 $$ = mm_strdup("insert");
13931 }
13932 | INSTEAD
13933 {
13934 $$ = mm_strdup("instead");
13935 }
13936 | INVOKER
13937 {
13938 $$ = mm_strdup("invoker");
13939 }
13940 | ISOLATION
13941 {
13942 $$ = mm_strdup("isolation");
13943 }
13944 | KEY
13945 {
13946 $$ = mm_strdup("key");
13947 }
13948 | LABEL
13949 {
13950 $$ = mm_strdup("label");
13951 }
13952 | LANGUAGE
13953 {
13954 $$ = mm_strdup("language");
13955 }
13956 | LARGE_P
13957 {
13958 $$ = mm_strdup("large");
13959 }
13960 | LAST_P
13961 {
13962 $$ = mm_strdup("last");
13963 }
13964 | LEAKPROOF
13965 {
13966 $$ = mm_strdup("leakproof");
13967 }
13968 | LEVEL
13969 {
13970 $$ = mm_strdup("level");
13971 }
13972 | LISTEN
13973 {
13974 $$ = mm_strdup("listen");
13975 }
13976 | LOAD
13977 {
13978 $$ = mm_strdup("load");
13979 }
13980 | LOCAL
13981 {
13982 $$ = mm_strdup("local");
13983 }
13984 | LOCATION
13985 {
13986 $$ = mm_strdup("location");
13987 }
13988 | LOCK_P
13989 {
13990 $$ = mm_strdup("lock");
13991 }
13992 | LOCKED
13993 {
13994 $$ = mm_strdup("locked");
13995 }
13996 | LOGGED
13997 {
13998 $$ = mm_strdup("logged");
13999 }
14000 | MAPPING
14001 {
14002 $$ = mm_strdup("mapping");
14003 }
14004 | MATCH
14005 {
14006 $$ = mm_strdup("match");
14007 }
14008 | MATERIALIZED
14009 {
14010 $$ = mm_strdup("materialized");
14011 }
14012 | MAXVALUE
14013 {
14014 $$ = mm_strdup("maxvalue");
14015 }
14016 | METHOD
14017 {
14018 $$ = mm_strdup("method");
14019 }
14020 | MINVALUE
14021 {
14022 $$ = mm_strdup("minvalue");
14023 }
14024 | MODE
14025 {
14026 $$ = mm_strdup("mode");
14027 }
14028 | MOVE
14029 {
14030 $$ = mm_strdup("move");
14031 }
14032 | NAME_P
14033 {
14034 $$ = mm_strdup("name");
14035 }
14036 | NAMES
14037 {
14038 $$ = mm_strdup("names");
14039 }
14040 | NEW
14041 {
14042 $$ = mm_strdup("new");
14043 }
14044 | NEXT
14045 {
14046 $$ = mm_strdup("next");
14047 }
14048 | NFC
14049 {
14050 $$ = mm_strdup("nfc");
14051 }
14052 | NFD
14053 {
14054 $$ = mm_strdup("nfd");
14055 }
14056 | NFKC
14057 {
14058 $$ = mm_strdup("nfkc");
14059 }
14060 | NFKD
14061 {
14062 $$ = mm_strdup("nfkd");
14063 }
14064 | NO
14065 {
14066 $$ = mm_strdup("no");
14067 }
14068 | NORMALIZED
14069 {
14070 $$ = mm_strdup("normalized");
14071 }
14072 | NOTHING
14073 {
14074 $$ = mm_strdup("nothing");
14075 }
14076 | NOTIFY
14077 {
14078 $$ = mm_strdup("notify");
14079 }
14080 | NOWAIT
14081 {
14082 $$ = mm_strdup("nowait");
14083 }
14084 | NULLS_P
14085 {
14086 $$ = mm_strdup("nulls");
14087 }
14088 | OBJECT_P
14089 {
14090 $$ = mm_strdup("object");
14091 }
14092 | OF
14093 {
14094 $$ = mm_strdup("of");
14095 }
14096 | OFF
14097 {
14098 $$ = mm_strdup("off");
14099 }
14100 | OIDS
14101 {
14102 $$ = mm_strdup("oids");
14103 }
14104 | OLD
14105 {
14106 $$ = mm_strdup("old");
14107 }
14108 | OPERATOR
14109 {
14110 $$ = mm_strdup("operator");
14111 }
14112 | OPTION
14113 {
14114 $$ = mm_strdup("option");
14115 }
14116 | OPTIONS
14117 {
14118 $$ = mm_strdup("options");
14119 }
14120 | ORDINALITY
14121 {
14122 $$ = mm_strdup("ordinality");
14123 }
14124 | OTHERS
14125 {
14126 $$ = mm_strdup("others");
14127 }
14128 | OVER
14129 {
14130 $$ = mm_strdup("over");
14131 }
14132 | OVERRIDING
14133 {
14134 $$ = mm_strdup("overriding");
14135 }
14136 | OWNED
14137 {
14138 $$ = mm_strdup("owned");
14139 }
14140 | OWNER
14141 {
14142 $$ = mm_strdup("owner");
14143 }
14144 | PARALLEL
14145 {
14146 $$ = mm_strdup("parallel");
14147 }
14148 | PARSER
14149 {
14150 $$ = mm_strdup("parser");
14151 }
14152 | PARTIAL
14153 {
14154 $$ = mm_strdup("partial");
14155 }
14156 | PARTITION
14157 {
14158 $$ = mm_strdup("partition");
14159 }
14160 | PASSING
14161 {
14162 $$ = mm_strdup("passing");
14163 }
14164 | PASSWORD
14165 {
14166 $$ = mm_strdup("password");
14167 }
14168 | PLANS
14169 {
14170 $$ = mm_strdup("plans");
14171 }
14172 | POLICY
14173 {
14174 $$ = mm_strdup("policy");
14175 }
14176 | PRECEDING
14177 {
14178 $$ = mm_strdup("preceding");
14179 }
14180 | PREPARE
14181 {
14182 $$ = mm_strdup("prepare");
14183 }
14184 | PREPARED
14185 {
14186 $$ = mm_strdup("prepared");
14187 }
14188 | PRESERVE
14189 {
14190 $$ = mm_strdup("preserve");
14191 }
14192 | PRIOR
14193 {
14194 $$ = mm_strdup("prior");
14195 }
14196 | PRIVILEGES
14197 {
14198 $$ = mm_strdup("privileges");
14199 }
14200 | PROCEDURAL
14201 {
14202 $$ = mm_strdup("procedural");
14203 }
14204 | PROCEDURE
14205 {
14206 $$ = mm_strdup("procedure");
14207 }
14208 | PROCEDURES
14209 {
14210 $$ = mm_strdup("procedures");
14211 }
14212 | PROGRAM
14213 {
14214 $$ = mm_strdup("program");
14215 }
14216 | PUBLICATION
14217 {
14218 $$ = mm_strdup("publication");
14219 }
14220 | QUOTE
14221 {
14222 $$ = mm_strdup("quote");
14223 }
14224 | RANGE
14225 {
14226 $$ = mm_strdup("range");
14227 }
14228 | READ
14229 {
14230 $$ = mm_strdup("read");
14231 }
14232 | REASSIGN
14233 {
14234 $$ = mm_strdup("reassign");
14235 }
14236 | RECHECK
14237 {
14238 $$ = mm_strdup("recheck");
14239 }
14240 | RECURSIVE
14241 {
14242 $$ = mm_strdup("recursive");
14243 }
14244 | REF
14245 {
14246 $$ = mm_strdup("ref");
14247 }
14248 | REFERENCING
14249 {
14250 $$ = mm_strdup("referencing");
14251 }
14252 | REFRESH
14253 {
14254 $$ = mm_strdup("refresh");
14255 }
14256 | REINDEX
14257 {
14258 $$ = mm_strdup("reindex");
14259 }
14260 | RELATIVE_P
14261 {
14262 $$ = mm_strdup("relative");
14263 }
14264 | RELEASE
14265 {
14266 $$ = mm_strdup("release");
14267 }
14268 | RENAME
14269 {
14270 $$ = mm_strdup("rename");
14271 }
14272 | REPEATABLE
14273 {
14274 $$ = mm_strdup("repeatable");
14275 }
14276 | REPLACE
14277 {
14278 $$ = mm_strdup("replace");
14279 }
14280 | REPLICA
14281 {
14282 $$ = mm_strdup("replica");
14283 }
14284 | RESET
14285 {
14286 $$ = mm_strdup("reset");
14287 }
14288 | RESTART
14289 {
14290 $$ = mm_strdup("restart");
14291 }
14292 | RESTRICT
14293 {
14294 $$ = mm_strdup("restrict");
14295 }
14296 | RETURNS
14297 {
14298 $$ = mm_strdup("returns");
14299 }
14300 | REVOKE
14301 {
14302 $$ = mm_strdup("revoke");
14303 }
14304 | ROLE
14305 {
14306 $$ = mm_strdup("role");
14307 }
14308 | ROLLBACK
14309 {
14310 $$ = mm_strdup("rollback");
14311 }
14312 | ROLLUP
14313 {
14314 $$ = mm_strdup("rollup");
14315 }
14316 | ROUTINE
14317 {
14318 $$ = mm_strdup("routine");
14319 }
14320 | ROUTINES
14321 {
14322 $$ = mm_strdup("routines");
14323 }
14324 | ROWS
14325 {
14326 $$ = mm_strdup("rows");
14327 }
14328 | RULE
14329 {
14330 $$ = mm_strdup("rule");
14331 }
14332 | SAVEPOINT
14333 {
14334 $$ = mm_strdup("savepoint");
14335 }
14336 | SCHEMA
14337 {
14338 $$ = mm_strdup("schema");
14339 }
14340 | SCHEMAS
14341 {
14342 $$ = mm_strdup("schemas");
14343 }
14344 | SCROLL
14345 {
14346 $$ = mm_strdup("scroll");
14347 }
14348 | SEARCH
14349 {
14350 $$ = mm_strdup("search");
14351 }
14352 | SECURITY
14353 {
14354 $$ = mm_strdup("security");
14355 }
14356 | SEQUENCE
14357 {
14358 $$ = mm_strdup("sequence");
14359 }
14360 | SEQUENCES
14361 {
14362 $$ = mm_strdup("sequences");
14363 }
14364 | SERIALIZABLE
14365 {
14366 $$ = mm_strdup("serializable");
14367 }
14368 | SERVER
14369 {
14370 $$ = mm_strdup("server");
14371 }
14372 | SESSION
14373 {
14374 $$ = mm_strdup("session");
14375 }
14376 | SET
14377 {
14378 $$ = mm_strdup("set");
14379 }
14380 | SETS
14381 {
14382 $$ = mm_strdup("sets");
14383 }
14384 | SHARE
14385 {
14386 $$ = mm_strdup("share");
14387 }
14388 | SHOW
14389 {
14390 $$ = mm_strdup("show");
14391 }
14392 | SIMPLE
14393 {
14394 $$ = mm_strdup("simple");
14395 }
14396 | SKIP
14397 {
14398 $$ = mm_strdup("skip");
14399 }
14400 | SNAPSHOT
14401 {
14402 $$ = mm_strdup("snapshot");
14403 }
14404 | SQL_P
14405 {
14406 $$ = mm_strdup("sql");
14407 }
14408 | STABLE
14409 {
14410 $$ = mm_strdup("stable");
14411 }
14412 | STANDALONE_P
14413 {
14414 $$ = mm_strdup("standalone");
14415 }
14416 | START
14417 {
14418 $$ = mm_strdup("start");
14419 }
14420 | STATEMENT
14421 {
14422 $$ = mm_strdup("statement");
14423 }
14424 | STATISTICS
14425 {
14426 $$ = mm_strdup("statistics");
14427 }
14428 | STDIN
14429 {
14430 $$ = mm_strdup("stdin");
14431 }
14432 | STDOUT
14433 {
14434 $$ = mm_strdup("stdout");
14435 }
14436 | STORAGE
14437 {
14438 $$ = mm_strdup("storage");
14439 }
14440 | STORED
14441 {
14442 $$ = mm_strdup("stored");
14443 }
14444 | STRICT_P
14445 {
14446 $$ = mm_strdup("strict");
14447 }
14448 | STRIP_P
14449 {
14450 $$ = mm_strdup("strip");
14451 }
14452 | SUBSCRIPTION
14453 {
14454 $$ = mm_strdup("subscription");
14455 }
14456 | SUPPORT
14457 {
14458 $$ = mm_strdup("support");
14459 }
14460 | SYSID
14461 {
14462 $$ = mm_strdup("sysid");
14463 }
14464 | SYSTEM_P
14465 {
14466 $$ = mm_strdup("system");
14467 }
14468 | TABLES
14469 {
14470 $$ = mm_strdup("tables");
14471 }
14472 | TABLESPACE
14473 {
14474 $$ = mm_strdup("tablespace");
14475 }
14476 | TEMP
14477 {
14478 $$ = mm_strdup("temp");
14479 }
14480 | TEMPLATE
14481 {
14482 $$ = mm_strdup("template");
14483 }
14484 | TEMPORARY
14485 {
14486 $$ = mm_strdup("temporary");
14487 }
14488 | TEXT_P
14489 {
14490 $$ = mm_strdup("text");
14491 }
14492 | TIES
14493 {
14494 $$ = mm_strdup("ties");
14495 }
14496 | TRANSACTION
14497 {
14498 $$ = mm_strdup("transaction");
14499 }
14500 | TRANSFORM
14501 {
14502 $$ = mm_strdup("transform");
14503 }
14504 | TRIGGER
14505 {
14506 $$ = mm_strdup("trigger");
14507 }
14508 | TRUNCATE
14509 {
14510 $$ = mm_strdup("truncate");
14511 }
14512 | TRUSTED
14513 {
14514 $$ = mm_strdup("trusted");
14515 }
14516 | TYPE_P
14517 {
14518 $$ = mm_strdup("type");
14519 }
14520 | TYPES_P
14521 {
14522 $$ = mm_strdup("types");
14523 }
14524 | UESCAPE
14525 {
14526 $$ = mm_strdup("uescape");
14527 }
14528 | UNBOUNDED
14529 {
14530 $$ = mm_strdup("unbounded");
14531 }
14532 | UNCOMMITTED
14533 {
14534 $$ = mm_strdup("uncommitted");
14535 }
14536 | UNENCRYPTED
14537 {
14538 $$ = mm_strdup("unencrypted");
14539 }
14540 | UNKNOWN
14541 {
14542 $$ = mm_strdup("unknown");
14543 }
14544 | UNLISTEN
14545 {
14546 $$ = mm_strdup("unlisten");
14547 }
14548 | UNLOGGED
14549 {
14550 $$ = mm_strdup("unlogged");
14551 }
14552 | UNTIL
14553 {
14554 $$ = mm_strdup("until");
14555 }
14556 | UPDATE
14557 {
14558 $$ = mm_strdup("update");
14559 }
14560 | VACUUM
14561 {
14562 $$ = mm_strdup("vacuum");
14563 }
14564 | VALID
14565 {
14566 $$ = mm_strdup("valid");
14567 }
14568 | VALIDATE
14569 {
14570 $$ = mm_strdup("validate");
14571 }
14572 | VALIDATOR
14573 {
14574 $$ = mm_strdup("validator");
14575 }
14576 | VALUE_P
14577 {
14578 $$ = mm_strdup("value");
14579 }
14580 | VARYING
14581 {
14582 $$ = mm_strdup("varying");
14583 }
14584 | VERSION_P
14585 {
14586 $$ = mm_strdup("version");
14587 }
14588 | VIEW
14589 {
14590 $$ = mm_strdup("view");
14591 }
14592 | VIEWS
14593 {
14594 $$ = mm_strdup("views");
14595 }
14596 | VOLATILE
14597 {
14598 $$ = mm_strdup("volatile");
14599 }
14600 | WHITESPACE_P
14601 {
14602 $$ = mm_strdup("whitespace");
14603 }
14604 | WITHIN
14605 {
14606 $$ = mm_strdup("within");
14607 }
14608 | WITHOUT
14609 {
14610 $$ = mm_strdup("without");
14611 }
14612 | WORK
14613 {
14614 $$ = mm_strdup("work");
14615 }
14616 | WRAPPER
14617 {
14618 $$ = mm_strdup("wrapper");
14619 }
14620 | WRITE
14621 {
14622 $$ = mm_strdup("write");
14623 }
14624 | XML_P
14625 {
14626 $$ = mm_strdup("xml");
14627 }
14628 | YES_P
14629 {
14630 $$ = mm_strdup("yes");
14631 }
14632 | ZONE
14633 {
14634 $$ = mm_strdup("zone");
14635 }
14636 ;
14637
14638
14639 col_name_keyword:
14640 BETWEEN
14641 {
14642 $$ = mm_strdup("between");
14643 }
14644 | BIGINT
14645 {
14646 $$ = mm_strdup("bigint");
14647 }
14648 | BIT
14649 {
14650 $$ = mm_strdup("bit");
14651 }
14652 | BOOLEAN_P
14653 {
14654 $$ = mm_strdup("boolean");
14655 }
14656 | CHARACTER
14657 {
14658 $$ = mm_strdup("character");
14659 }
14660 | COALESCE
14661 {
14662 $$ = mm_strdup("coalesce");
14663 }
14664 | DEC
14665 {
14666 $$ = mm_strdup("dec");
14667 }
14668 | DECIMAL_P
14669 {
14670 $$ = mm_strdup("decimal");
14671 }
14672 | EXISTS
14673 {
14674 $$ = mm_strdup("exists");
14675 }
14676 | EXTRACT
14677 {
14678 $$ = mm_strdup("extract");
14679 }
14680 | FLOAT_P
14681 {
14682 $$ = mm_strdup("float");
14683 }
14684 | GREATEST
14685 {
14686 $$ = mm_strdup("greatest");
14687 }
14688 | GROUPING
14689 {
14690 $$ = mm_strdup("grouping");
14691 }
14692 | INOUT
14693 {
14694 $$ = mm_strdup("inout");
14695 }
14696 | INTEGER
14697 {
14698 $$ = mm_strdup("integer");
14699 }
14700 | INTERVAL
14701 {
14702 $$ = mm_strdup("interval");
14703 }
14704 | LEAST
14705 {
14706 $$ = mm_strdup("least");
14707 }
14708 | NATIONAL
14709 {
14710 $$ = mm_strdup("national");
14711 }
14712 | NCHAR
14713 {
14714 $$ = mm_strdup("nchar");
14715 }
14716 | NONE
14717 {
14718 $$ = mm_strdup("none");
14719 }
14720 | NORMALIZE
14721 {
14722 $$ = mm_strdup("normalize");
14723 }
14724 | NULLIF
14725 {
14726 $$ = mm_strdup("nullif");
14727 }
14728 | NUMERIC
14729 {
14730 $$ = mm_strdup("numeric");
14731 }
14732 | OUT_P
14733 {
14734 $$ = mm_strdup("out");
14735 }
14736 | OVERLAY
14737 {
14738 $$ = mm_strdup("overlay");
14739 }
14740 | POSITION
14741 {
14742 $$ = mm_strdup("position");
14743 }
14744 | PRECISION
14745 {
14746 $$ = mm_strdup("precision");
14747 }
14748 | REAL
14749 {
14750 $$ = mm_strdup("real");
14751 }
14752 | ROW
14753 {
14754 $$ = mm_strdup("row");
14755 }
14756 | SETOF
14757 {
14758 $$ = mm_strdup("setof");
14759 }
14760 | SMALLINT
14761 {
14762 $$ = mm_strdup("smallint");
14763 }
14764 | SUBSTRING
14765 {
14766 $$ = mm_strdup("substring");
14767 }
14768 | TIME
14769 {
14770 $$ = mm_strdup("time");
14771 }
14772 | TIMESTAMP
14773 {
14774 $$ = mm_strdup("timestamp");
14775 }
14776 | TREAT
14777 {
14778 $$ = mm_strdup("treat");
14779 }
14780 | TRIM
14781 {
14782 $$ = mm_strdup("trim");
14783 }
14784 | VARCHAR
14785 {
14786 $$ = mm_strdup("varchar");
14787 }
14788 | XMLATTRIBUTES
14789 {
14790 $$ = mm_strdup("xmlattributes");
14791 }
14792 | XMLCONCAT
14793 {
14794 $$ = mm_strdup("xmlconcat");
14795 }
14796 | XMLELEMENT
14797 {
14798 $$ = mm_strdup("xmlelement");
14799 }
14800 | XMLEXISTS
14801 {
14802 $$ = mm_strdup("xmlexists");
14803 }
14804 | XMLFOREST
14805 {
14806 $$ = mm_strdup("xmlforest");
14807 }
14808 | XMLNAMESPACES
14809 {
14810 $$ = mm_strdup("xmlnamespaces");
14811 }
14812 | XMLPARSE
14813 {
14814 $$ = mm_strdup("xmlparse");
14815 }
14816 | XMLPI
14817 {
14818 $$ = mm_strdup("xmlpi");
14819 }
14820 | XMLROOT
14821 {
14822 $$ = mm_strdup("xmlroot");
14823 }
14824 | XMLSERIALIZE
14825 {
14826 $$ = mm_strdup("xmlserialize");
14827 }
14828 | XMLTABLE
14829 {
14830 $$ = mm_strdup("xmltable");
14831 }
14832 ;
14833
14834
14835 type_func_name_keyword:
14836 AUTHORIZATION
14837 {
14838 $$ = mm_strdup("authorization");
14839 }
14840 | BINARY
14841 {
14842 $$ = mm_strdup("binary");
14843 }
14844 | COLLATION
14845 {
14846 $$ = mm_strdup("collation");
14847 }
14848 | CONCURRENTLY
14849 {
14850 $$ = mm_strdup("concurrently");
14851 }
14852 | CROSS
14853 {
14854 $$ = mm_strdup("cross");
14855 }
14856 | CURRENT_SCHEMA
14857 {
14858 $$ = mm_strdup("current_schema");
14859 }
14860 | FREEZE
14861 {
14862 $$ = mm_strdup("freeze");
14863 }
14864 | FULL
14865 {
14866 $$ = mm_strdup("full");
14867 }
14868 | ILIKE
14869 {
14870 $$ = mm_strdup("ilike");
14871 }
14872 | INNER_P
14873 {
14874 $$ = mm_strdup("inner");
14875 }
14876 | IS
14877 {
14878 $$ = mm_strdup("is");
14879 }
14880 | ISNULL
14881 {
14882 $$ = mm_strdup("isnull");
14883 }
14884 | JOIN
14885 {
14886 $$ = mm_strdup("join");
14887 }
14888 | LEFT
14889 {
14890 $$ = mm_strdup("left");
14891 }
14892 | LIKE
14893 {
14894 $$ = mm_strdup("like");
14895 }
14896 | NATURAL
14897 {
14898 $$ = mm_strdup("natural");
14899 }
14900 | NOTNULL
14901 {
14902 $$ = mm_strdup("notnull");
14903 }
14904 | OUTER_P
14905 {
14906 $$ = mm_strdup("outer");
14907 }
14908 | OVERLAPS
14909 {
14910 $$ = mm_strdup("overlaps");
14911 }
14912 | RIGHT
14913 {
14914 $$ = mm_strdup("right");
14915 }
14916 | SIMILAR
14917 {
14918 $$ = mm_strdup("similar");
14919 }
14920 | TABLESAMPLE
14921 {
14922 $$ = mm_strdup("tablesample");
14923 }
14924 | VERBOSE
14925 {
14926 $$ = mm_strdup("verbose");
14927 }
14928 ;
14929
14930
14931 reserved_keyword:
14932 ALL
14933 {
14934 $$ = mm_strdup("all");
14935 }
14936 | ANALYSE
14937 {
14938 $$ = mm_strdup("analyse");
14939 }
14940 | ANALYZE
14941 {
14942 $$ = mm_strdup("analyze");
14943 }
14944 | AND
14945 {
14946 $$ = mm_strdup("and");
14947 }
14948 | ANY
14949 {
14950 $$ = mm_strdup("any");
14951 }
14952 | ARRAY
14953 {
14954 $$ = mm_strdup("array");
14955 }
14956 | AS
14957 {
14958 $$ = mm_strdup("as");
14959 }
14960 | ASC
14961 {
14962 $$ = mm_strdup("asc");
14963 }
14964 | ASYMMETRIC
14965 {
14966 $$ = mm_strdup("asymmetric");
14967 }
14968 | BOTH
14969 {
14970 $$ = mm_strdup("both");
14971 }
14972 | CASE
14973 {
14974 $$ = mm_strdup("case");
14975 }
14976 | CAST
14977 {
14978 $$ = mm_strdup("cast");
14979 }
14980 | CHECK
14981 {
14982 $$ = mm_strdup("check");
14983 }
14984 | COLLATE
14985 {
14986 $$ = mm_strdup("collate");
14987 }
14988 | COLUMN
14989 {
14990 $$ = mm_strdup("column");
14991 }
14992 | CONSTRAINT
14993 {
14994 $$ = mm_strdup("constraint");
14995 }
14996 | CREATE
14997 {
14998 $$ = mm_strdup("create");
14999 }
15000 | CURRENT_CATALOG
15001 {
15002 $$ = mm_strdup("current_catalog");
15003 }
15004 | CURRENT_DATE
15005 {
15006 $$ = mm_strdup("current_date");
15007 }
15008 | CURRENT_ROLE
15009 {
15010 $$ = mm_strdup("current_role");
15011 }
15012 | CURRENT_TIME
15013 {
15014 $$ = mm_strdup("current_time");
15015 }
15016 | CURRENT_TIMESTAMP
15017 {
15018 $$ = mm_strdup("current_timestamp");
15019 }
15020 | CURRENT_USER
15021 {
15022 $$ = mm_strdup("current_user");
15023 }
15024 | DEFAULT
15025 {
15026 $$ = mm_strdup("default");
15027 }
15028 | DEFERRABLE
15029 {
15030 $$ = mm_strdup("deferrable");
15031 }
15032 | DESC
15033 {
15034 $$ = mm_strdup("desc");
15035 }
15036 | DISTINCT
15037 {
15038 $$ = mm_strdup("distinct");
15039 }
15040 | DO
15041 {
15042 $$ = mm_strdup("do");
15043 }
15044 | ELSE
15045 {
15046 $$ = mm_strdup("else");
15047 }
15048 | END_P
15049 {
15050 $$ = mm_strdup("end");
15051 }
15052 | EXCEPT
15053 {
15054 $$ = mm_strdup("except");
15055 }
15056 | FALSE_P
15057 {
15058 $$ = mm_strdup("false");
15059 }
15060 | FETCH
15061 {
15062 $$ = mm_strdup("fetch");
15063 }
15064 | FOR
15065 {
15066 $$ = mm_strdup("for");
15067 }
15068 | FOREIGN
15069 {
15070 $$ = mm_strdup("foreign");
15071 }
15072 | FROM
15073 {
15074 $$ = mm_strdup("from");
15075 }
15076 | GRANT
15077 {
15078 $$ = mm_strdup("grant");
15079 }
15080 | GROUP_P
15081 {
15082 $$ = mm_strdup("group");
15083 }
15084 | HAVING
15085 {
15086 $$ = mm_strdup("having");
15087 }
15088 | IN_P
15089 {
15090 $$ = mm_strdup("in");
15091 }
15092 | INITIALLY
15093 {
15094 $$ = mm_strdup("initially");
15095 }
15096 | INTERSECT
15097 {
15098 $$ = mm_strdup("intersect");
15099 }
15100 | INTO
15101 {
15102 $$ = mm_strdup("into");
15103 }
15104 | LATERAL_P
15105 {
15106 $$ = mm_strdup("lateral");
15107 }
15108 | LEADING
15109 {
15110 $$ = mm_strdup("leading");
15111 }
15112 | LIMIT
15113 {
15114 $$ = mm_strdup("limit");
15115 }
15116 | LOCALTIME
15117 {
15118 $$ = mm_strdup("localtime");
15119 }
15120 | LOCALTIMESTAMP
15121 {
15122 $$ = mm_strdup("localtimestamp");
15123 }
15124 | NOT
15125 {
15126 $$ = mm_strdup("not");
15127 }
15128 | NULL_P
15129 {
15130 $$ = mm_strdup("null");
15131 }
15132 | OFFSET
15133 {
15134 $$ = mm_strdup("offset");
15135 }
15136 | ON
15137 {
15138 $$ = mm_strdup("on");
15139 }
15140 | ONLY
15141 {
15142 $$ = mm_strdup("only");
15143 }
15144 | OR
15145 {
15146 $$ = mm_strdup("or");
15147 }
15148 | ORDER
15149 {
15150 $$ = mm_strdup("order");
15151 }
15152 | PLACING
15153 {
15154 $$ = mm_strdup("placing");
15155 }
15156 | PRIMARY
15157 {
15158 $$ = mm_strdup("primary");
15159 }
15160 | REFERENCES
15161 {
15162 $$ = mm_strdup("references");
15163 }
15164 | RETURNING
15165 {
15166 $$ = mm_strdup("returning");
15167 }
15168 | SELECT
15169 {
15170 $$ = mm_strdup("select");
15171 }
15172 | SESSION_USER
15173 {
15174 $$ = mm_strdup("session_user");
15175 }
15176 | SOME
15177 {
15178 $$ = mm_strdup("some");
15179 }
15180 | SYMMETRIC
15181 {
15182 $$ = mm_strdup("symmetric");
15183 }
15184 | TABLE
15185 {
15186 $$ = mm_strdup("table");
15187 }
15188 | THEN
15189 {
15190 $$ = mm_strdup("then");
15191 }
15192 | TRAILING
15193 {
15194 $$ = mm_strdup("trailing");
15195 }
15196 | TRUE_P
15197 {
15198 $$ = mm_strdup("true");
15199 }
15200 | UNIQUE
15201 {
15202 $$ = mm_strdup("unique");
15203 }
15204 | USER
15205 {
15206 $$ = mm_strdup("user");
15207 }
15208 | USING
15209 {
15210 $$ = mm_strdup("using");
15211 }
15212 | VARIADIC
15213 {
15214 $$ = mm_strdup("variadic");
15215 }
15216 | WHEN
15217 {
15218 $$ = mm_strdup("when");
15219 }
15220 | WHERE
15221 {
15222 $$ = mm_strdup("where");
15223 }
15224 | WINDOW
15225 {
15226 $$ = mm_strdup("window");
15227 }
15228 | WITH
15229 {
15230 $$ = mm_strdup("with");
15231 }
15232 ;
15233
15234
15235 /* trailer */
15236 /* src/interfaces/ecpg/preproc/ecpg.trailer */
15237
15238 statements: /*EMPTY*/
15239 | statements statement
15240 ;
15241
15242 statement: ecpgstart at stmt ';' { connection = NULL; }
15243 | ecpgstart stmt ';'
15244 | ecpgstart ECPGVarDeclaration
15245 {
15246 fprintf(base_yyout, "%s", $2);
15247 free($2);
15248 output_line_number();
15249 }
15250 | ECPGDeclaration
15251 | c_thing { fprintf(base_yyout, "%s", $1); free($1); }
15252 | CPP_LINE { fprintf(base_yyout, "%s", $1); free($1); }
15253 | '{' { braces_open++; fputs("{", base_yyout); }
15254 | '}'
15255 {
15256 remove_typedefs(braces_open);
15257 remove_variables(braces_open--);
15258 if (braces_open == 0)
15259 {
15260 free(current_function);
15261 current_function = NULL;
15262 }
15263 fputs("}", base_yyout);
15264 }
15265 ;
15266
15267 CreateAsStmt: CREATE OptTemp TABLE create_as_target AS {FoundInto = 0;} SelectStmt opt_with_data
15268 {
15269 if (FoundInto == 1)
15270 mmerror(PARSE_ERROR, ET_ERROR, "CREATE TABLE AS cannot specify INTO");
15271
15272 $$ = cat_str(7, mm_strdup("create"), $2, mm_strdup("table"), $4, mm_strdup("as"), $7, $8);
15273 }
15274 | CREATE OptTemp TABLE IF_P NOT EXISTS create_as_target AS {FoundInto = 0;} SelectStmt opt_with_data
15275 {
15276 if (FoundInto == 1)
15277 mmerror(PARSE_ERROR, ET_ERROR, "CREATE TABLE AS cannot specify INTO");
15278
15279 $$ = cat_str(7, mm_strdup("create"), $2, mm_strdup("table if not exists"), $7, mm_strdup("as"), $10, $11);
15280 }
15281 ;
15282
15283 at: AT connection_object
15284 {
15285 connection = $2;
15286 /*
15287 * Do we have a variable as connection target? Remove the variable
15288 * from the variable list or else it will be used twice.
15289 */
15290 if (argsinsert != NULL)
15291 argsinsert = NULL;
15292 }
15293 ;
15294
15295 /*
15296 * the exec sql connect statement: connect to the given database
15297 */
15298 ECPGConnect: SQL_CONNECT TO connection_target opt_connection_name opt_user
15299 { $$ = cat_str(5, $3, mm_strdup(","), $5, mm_strdup(","), $4); }
15300 | SQL_CONNECT TO DEFAULT
15301 { $$ = mm_strdup("NULL, NULL, NULL, \"DEFAULT\""); }
15302 /* also allow ORACLE syntax */
15303 | SQL_CONNECT ora_user
15304 { $$ = cat_str(3, mm_strdup("NULL,"), $2, mm_strdup(", NULL")); }
15305 | DATABASE connection_target
15306 { $$ = cat2_str($2, mm_strdup(", NULL, NULL, NULL")); }
15307 ;
15308
15309 connection_target: opt_database_name opt_server opt_port
15310 {
15311 /* old style: dbname[@server][:port] */
15312 if (strlen($2) > 0 && *($2) != '@')
15313 mmerror(PARSE_ERROR, ET_ERROR, "expected \"@\", found \"%s\"", $2);
15314
15315 /* C strings need to be handled differently */
15316 if ($1[0] == '\"')
15317 $$ = $1;
15318 else
15319 $$ = make3_str(mm_strdup("\""), make3_str($1, $2, $3), mm_strdup("\""));
15320 }
15321 | db_prefix ':' server opt_port '/' opt_database_name opt_options
15322 {
15323 /* new style: <tcp|unix>:postgresql://server[:port][/dbname] */
15324 if (strncmp($1, "unix:postgresql", strlen("unix:postgresql")) != 0 && strncmp($1, "tcp:postgresql", strlen("tcp:postgresql")) != 0)
15325 mmerror(PARSE_ERROR, ET_ERROR, "only protocols \"tcp\" and \"unix\" and database type \"postgresql\" are supported");
15326
15327 if (strncmp($3, "//", strlen("//")) != 0)
15328 mmerror(PARSE_ERROR, ET_ERROR, "expected \"://\", found \"%s\"", $3);
15329
15330 if (strncmp($1, "unix", strlen("unix")) == 0 &&
15331 strncmp($3 + strlen("//"), "localhost", strlen("localhost")) != 0 &&
15332 strncmp($3 + strlen("//"), "127.0.0.1", strlen("127.0.0.1")) != 0)
15333 mmerror(PARSE_ERROR, ET_ERROR, "Unix-domain sockets only work on \"localhost\" but not on \"%s\"", $3 + strlen("//"));
15334
15335 $$ = make3_str(make3_str(mm_strdup("\""), $1, mm_strdup(":")), $3, make3_str(make3_str($4, mm_strdup("/"), $6), $7, mm_strdup("\"")));
15336 }
15337 | char_variable
15338 {
15339 $$ = $1;
15340 }
15341 | ecpg_sconst
15342 {
15343 /* We can only process double quoted strings not single quotes ones,
15344 * so we change the quotes.
15345 * Note, that the rule for ecpg_sconst adds these single quotes. */
15346 $1[0] = '\"';
15347 $1[strlen($1)-1] = '\"';
15348 $$ = $1;
15349 }
15350 ;
15351
15352 opt_database_name: database_name { $$ = $1; }
15353 | /*EMPTY*/ { $$ = EMPTY; }
15354 ;
15355
15356 db_prefix: ecpg_ident cvariable
15357 {
15358 if (strcmp($2, "postgresql") != 0 && strcmp($2, "postgres") != 0)
15359 mmerror(PARSE_ERROR, ET_ERROR, "expected \"postgresql\", found \"%s\"", $2);
15360
15361 if (strcmp($1, "tcp") != 0 && strcmp($1, "unix") != 0)
15362 mmerror(PARSE_ERROR, ET_ERROR, "invalid connection type: %s", $1);
15363
15364 $$ = make3_str($1, mm_strdup(":"), $2);
15365 }
15366 ;
15367
15368 server: Op server_name
15369 {
15370 if (strcmp($1, "@") != 0 && strcmp($1, "//") != 0)
15371 mmerror(PARSE_ERROR, ET_ERROR, "expected \"@\" or \"://\", found \"%s\"", $1);
15372
15373 $$ = make2_str($1, $2);
15374 }
15375 ;
15376
15377 opt_server: server { $$ = $1; }
15378 | /*EMPTY*/ { $$ = EMPTY; }
15379 ;
15380
15381 server_name: ColId { $$ = $1; }
15382 | ColId '.' server_name { $$ = make3_str($1, mm_strdup("."), $3); }
15383 | IP { $$ = make_name(); }
15384 ;
15385
15386 opt_port: ':' Iconst { $$ = make2_str(mm_strdup(":"), $2); }
15387 | /*EMPTY*/ { $$ = EMPTY; }
15388 ;
15389
15390 opt_connection_name: AS connection_object { $$ = $2; }
15391 | /*EMPTY*/ { $$ = mm_strdup("NULL"); }
15392 ;
15393
15394 opt_user: USER ora_user { $$ = $2; }
15395 | /*EMPTY*/ { $$ = mm_strdup("NULL, NULL"); }
15396 ;
15397
15398 ora_user: user_name
15399 { $$ = cat2_str($1, mm_strdup(", NULL")); }
15400 | user_name '/' user_name
15401 { $$ = cat_str(3, $1, mm_strdup(","), $3); }
15402 | user_name SQL_IDENTIFIED BY user_name
15403 { $$ = cat_str(3, $1, mm_strdup(","), $4); }
15404 | user_name USING user_name
15405 { $$ = cat_str(3, $1, mm_strdup(","), $3); }
15406 ;
15407
15408 user_name: RoleId
15409 {
15410 if ($1[0] == '\"')
15411 $$ = $1;
15412 else
15413 $$ = make3_str(mm_strdup("\""), $1, mm_strdup("\""));
15414 }
15415 | ecpg_sconst
15416 {
15417 if ($1[0] == '\"')
15418 $$ = $1;
15419 else
15420 $$ = make3_str(mm_strdup("\""), $1, mm_strdup("\""));
15421 }
15422 | civar
15423 {
15424 enum ECPGttype type = argsinsert->variable->type->type;
15425
15426 /* if array see what's inside */
15427 if (type == ECPGt_array)
15428 type = argsinsert->variable->type->u.element->type;
15429
15430 /* handle varchars */
15431 if (type == ECPGt_varchar)
15432 $$ = make2_str(mm_strdup(argsinsert->variable->name), mm_strdup(".arr"));
15433 else
15434 $$ = mm_strdup(argsinsert->variable->name);
15435 }
15436 ;
15437
15438 char_variable: cvariable
15439 {
15440 /* check if we have a string variable */
15441 struct variable *p = find_variable($1);
15442 enum ECPGttype type = p->type->type;
15443
15444 /* If we have just one character this is not a string */
15445 if (atol(p->type->size) == 1)
15446 mmerror(PARSE_ERROR, ET_ERROR, "invalid data type");
15447 else
15448 {
15449 /* if array see what's inside */
15450 if (type == ECPGt_array)
15451 type = p->type->u.element->type;
15452
15453 switch (type)
15454 {
15455 case ECPGt_char:
15456 case ECPGt_unsigned_char:
15457 case ECPGt_string:
15458 $$ = $1;
15459 break;
15460 case ECPGt_varchar:
15461 $$ = make2_str($1, mm_strdup(".arr"));
15462 break;
15463 default:
15464 mmerror(PARSE_ERROR, ET_ERROR, "invalid data type");
15465 $$ = $1;
15466 break;
15467 }
15468 }
15469 }
15470 ;
15471
15472 opt_options: Op connect_options
15473 {
15474 if (strlen($1) == 0)
15475 mmerror(PARSE_ERROR, ET_ERROR, "incomplete statement");
15476
15477 if (strcmp($1, "?") != 0)
15478 mmerror(PARSE_ERROR, ET_ERROR, "unrecognized token \"%s\"", $1);
15479
15480 $$ = make2_str(mm_strdup("?"), $2);
15481 }
15482 | /*EMPTY*/ { $$ = EMPTY; }
15483 ;
15484
15485 connect_options: ColId opt_opt_value
15486 {
15487 $$ = make2_str($1, $2);
15488 }
15489 | ColId opt_opt_value Op connect_options
15490 {
15491 if (strlen($3) == 0)
15492 mmerror(PARSE_ERROR, ET_ERROR, "incomplete statement");
15493
15494 if (strcmp($3, "&") != 0)
15495 mmerror(PARSE_ERROR, ET_ERROR, "unrecognized token \"%s\"", $3);
15496
15497 $$ = cat_str(3, make2_str($1, $2), $3, $4);
15498 }
15499 ;
15500
15501 opt_opt_value: /*EMPTY*/
15502 { $$ = EMPTY; }
15503 | '=' Iconst
15504 { $$ = make2_str(mm_strdup("="), $2); }
15505 | '=' ecpg_ident
15506 { $$ = make2_str(mm_strdup("="), $2); }
15507 | '=' civar
15508 { $$ = make2_str(mm_strdup("="), $2); }
15509 ;
15510
15511 prepared_name: name
15512 {
15513 if ($1[0] == '\"' && $1[strlen($1)-1] == '\"') /* already quoted? */
15514 $$ = $1;
15515 else /* not quoted => convert to lowercase */
15516 {
15517 size_t i;
15518
15519 for (i = 0; i< strlen($1); i++)
15520 $1[i] = tolower((unsigned char) $1[i]);
15521
15522 $$ = make3_str(mm_strdup("\""), $1, mm_strdup("\""));
15523 }
15524 }
15525 | char_variable { $$ = $1; }
15526 ;
15527
15528 /*
15529 * Declare a prepared cursor. The syntax is different from the standard
15530 * declare statement, so we create a new rule.
15531 */
15532 ECPGCursorStmt: DECLARE cursor_name cursor_options CURSOR opt_hold FOR prepared_name
15533 {
15534 struct cursor *ptr, *this;
15535 char *cursor_marker = $2[0] == ':' ? mm_strdup("$0") : mm_strdup($2);
15536 int (* strcmp_fn)(const char *, const char *) = (($2[0] == ':' || $2[0] == '"') ? strcmp : pg_strcasecmp);
15537 struct variable *thisquery = (struct variable *)mm_alloc(sizeof(struct variable));
15538 const char *con = connection ? connection : "NULL";
15539 char *comment;
15540
15541 for (ptr = cur; ptr != NULL; ptr = ptr->next)
15542 {
15543 if (strcmp_fn($2, ptr->name) == 0)
15544 {
15545 /* re-definition is a bug */
15546 if ($2[0] == ':')
15547 mmerror(PARSE_ERROR, ET_ERROR, "using variable \"%s\" in different declare statements is not supported", $2+1);
15548 else
15549 mmerror(PARSE_ERROR, ET_ERROR, "cursor \"%s\" is already defined", $2);
15550 }
15551 }
15552
15553 this = (struct cursor *) mm_alloc(sizeof(struct cursor));
15554
15555 /* initial definition */
15556 this->next = cur;
15557 this->name = $2;
15558 this->function = (current_function ? mm_strdup(current_function) : NULL);
15559 this->connection = connection;
15560 this->command = cat_str(6, mm_strdup("declare"), cursor_marker, $3, mm_strdup("cursor"), $5, mm_strdup("for $1"));
15561 this->argsresult = NULL;
15562 this->argsresult_oos = NULL;
15563
15564 thisquery->type = &ecpg_query;
15565 thisquery->brace_level = 0;
15566 thisquery->next = NULL;
15567 thisquery->name = (char *) mm_alloc(sizeof("ECPGprepared_statement(, , __LINE__)") + strlen(con) + strlen($7));
15568 sprintf(thisquery->name, "ECPGprepared_statement(%s, %s, __LINE__)", con, $7);
15569
15570 this->argsinsert = NULL;
15571 this->argsinsert_oos = NULL;
15572 if ($2[0] == ':')
15573 {
15574 struct variable *var = find_variable($2 + 1);
15575 remove_variable_from_list(&argsinsert, var);
15576 add_variable_to_head(&(this->argsinsert), var, &no_indicator);
15577 }
15578 add_variable_to_head(&(this->argsinsert), thisquery, &no_indicator);
15579
15580 cur = this;
15581
15582 comment = cat_str(3, mm_strdup("/*"), mm_strdup(this->command), mm_strdup("*/"));
15583
15584 $$ = cat_str(2, adjust_outofscope_cursor_vars(this),
15585 comment);
15586 }
15587 ;
15588
15589 ECPGExecuteImmediateStmt: EXECUTE IMMEDIATE execstring
15590 {
15591 /* execute immediate means prepare the statement and
15592 * immediately execute it */
15593 $$ = $3;
15594 };
15595 /*
15596 * variable declaration outside exec sql declare block
15597 */
15598 ECPGVarDeclaration: single_vt_declaration;
15599
15600 single_vt_declaration: type_declaration { $$ = $1; }
15601 | var_declaration { $$ = $1; }
15602 ;
15603
15604 precision: NumericOnly { $$ = $1; };
15605
15606 opt_scale: ',' NumericOnly { $$ = $2; }
15607 | /* EMPTY */ { $$ = EMPTY; }
15608 ;
15609
15610 ecpg_interval: opt_interval { $$ = $1; }
15611 | YEAR_P TO MINUTE_P { $$ = mm_strdup("year to minute"); }
15612 | YEAR_P TO SECOND_P { $$ = mm_strdup("year to second"); }
15613 | DAY_P TO DAY_P { $$ = mm_strdup("day to day"); }
15614 | MONTH_P TO MONTH_P { $$ = mm_strdup("month to month"); }
15615 ;
15616
15617 /*
15618 * variable declaration inside exec sql declare block
15619 */
15620 ECPGDeclaration: sql_startdeclare
15621 { fputs("/* exec sql begin declare section */", base_yyout); }
15622 var_type_declarations sql_enddeclare
15623 {
15624 fprintf(base_yyout, "%s/* exec sql end declare section */", $3);
15625 free($3);
15626 output_line_number();
15627 }
15628 ;
15629
15630 sql_startdeclare: ecpgstart BEGIN_P DECLARE SQL_SECTION ';' {};
15631
15632 sql_enddeclare: ecpgstart END_P DECLARE SQL_SECTION ';' {};
15633
15634 var_type_declarations: /*EMPTY*/ { $$ = EMPTY; }
15635 | vt_declarations { $$ = $1; }
15636 ;
15637
15638 vt_declarations: single_vt_declaration { $$ = $1; }
15639 | CPP_LINE { $$ = $1; }
15640 | vt_declarations single_vt_declaration { $$ = cat2_str($1, $2); }
15641 | vt_declarations CPP_LINE { $$ = cat2_str($1, $2); }
15642 ;
15643
15644 variable_declarations: var_declaration { $$ = $1; }
15645 | variable_declarations var_declaration { $$ = cat2_str($1, $2); }
15646 ;
15647
15648 type_declaration: S_TYPEDEF
15649 {
15650 /* reset this variable so we see if there was */
15651 /* an initializer specified */
15652 initializer = 0;
15653 }
15654 var_type opt_pointer ECPGColLabelCommon opt_array_bounds ';'
15655 {
15656 add_typedef($5, $6.index1, $6.index2, $3.type_enum, $3.type_dimension, $3.type_index, initializer, *$4 ? 1 : 0);
15657
15658 fprintf(base_yyout, "typedef %s %s %s %s;\n", $3.type_str, *$4 ? "*" : "", $5, $6.str);
15659 output_line_number();
15660 $$ = mm_strdup("");
15661 };
15662
15663 var_declaration: storage_declaration
15664 var_type
15665 {
15666 actual_type[struct_level].type_enum = $2.type_enum;
15667 actual_type[struct_level].type_str = $2.type_str;
15668 actual_type[struct_level].type_dimension = $2.type_dimension;
15669 actual_type[struct_level].type_index = $2.type_index;
15670 actual_type[struct_level].type_sizeof = $2.type_sizeof;
15671
15672 actual_startline[struct_level] = hashline_number();
15673 }
15674 variable_list ';'
15675 {
15676 $$ = cat_str(5, actual_startline[struct_level], $1, $2.type_str, $4, mm_strdup(";\n"));
15677 }
15678 | var_type
15679 {
15680 actual_type[struct_level].type_enum = $1.type_enum;
15681 actual_type[struct_level].type_str = $1.type_str;
15682 actual_type[struct_level].type_dimension = $1.type_dimension;
15683 actual_type[struct_level].type_index = $1.type_index;
15684 actual_type[struct_level].type_sizeof = $1.type_sizeof;
15685
15686 actual_startline[struct_level] = hashline_number();
15687 }
15688 variable_list ';'
15689 {
15690 $$ = cat_str(4, actual_startline[struct_level], $1.type_str, $3, mm_strdup(";\n"));
15691 }
15692 | struct_union_type_with_symbol ';'
15693 {
15694 $$ = cat2_str($1, mm_strdup(";"));
15695 }
15696 ;
15697
15698 opt_bit_field: ':' Iconst { $$ =cat2_str(mm_strdup(":"), $2); }
15699 | /* EMPTY */ { $$ = EMPTY; }
15700 ;
15701
15702 storage_declaration: storage_clause storage_modifier
15703 {$$ = cat2_str ($1, $2); }
15704 | storage_clause {$$ = $1; }
15705 | storage_modifier {$$ = $1; }
15706 ;
15707
15708 storage_clause : S_EXTERN { $$ = mm_strdup("extern"); }
15709 | S_STATIC { $$ = mm_strdup("static"); }
15710 | S_REGISTER { $$ = mm_strdup("register"); }
15711 | S_AUTO { $$ = mm_strdup("auto"); }
15712 ;
15713
15714 storage_modifier : S_CONST { $$ = mm_strdup("const"); }
15715 | S_VOLATILE { $$ = mm_strdup("volatile"); }
15716 ;
15717
15718 var_type: simple_type
15719 {
15720 $$.type_enum = $1;
15721 $$.type_str = mm_strdup(ecpg_type_name($1));
15722 $$.type_dimension = mm_strdup("-1");
15723 $$.type_index = mm_strdup("-1");
15724 $$.type_sizeof = NULL;
15725 }
15726 | struct_union_type
15727 {
15728 $$.type_str = $1;
15729 $$.type_dimension = mm_strdup("-1");
15730 $$.type_index = mm_strdup("-1");
15731
15732 if (strncmp($1, "struct", sizeof("struct")-1) == 0)
15733 {
15734 $$.type_enum = ECPGt_struct;
15735 $$.type_sizeof = ECPGstruct_sizeof;
15736 }
15737 else
15738 {
15739 $$.type_enum = ECPGt_union;
15740 $$.type_sizeof = NULL;
15741 }
15742 }
15743 | enum_type
15744 {
15745 $$.type_str = $1;
15746 $$.type_enum = ECPGt_int;
15747 $$.type_dimension = mm_strdup("-1");
15748 $$.type_index = mm_strdup("-1");
15749 $$.type_sizeof = NULL;
15750 }
15751 | ECPGColLabelCommon '(' precision opt_scale ')'
15752 {
15753 if (strcmp($1, "numeric") == 0)
15754 {
15755 $$.type_enum = ECPGt_numeric;
15756 $$.type_str = mm_strdup("numeric");
15757 }
15758 else if (strcmp($1, "decimal") == 0)
15759 {
15760 $$.type_enum = ECPGt_decimal;
15761 $$.type_str = mm_strdup("decimal");
15762 }
15763 else
15764 {
15765 mmerror(PARSE_ERROR, ET_ERROR, "only data types numeric and decimal have precision/scale argument");
15766 $$.type_enum = ECPGt_numeric;
15767 $$.type_str = mm_strdup("numeric");
15768 }
15769
15770 $$.type_dimension = mm_strdup("-1");
15771 $$.type_index = mm_strdup("-1");
15772 $$.type_sizeof = NULL;
15773 }
15774 | ECPGColLabelCommon ecpg_interval
15775 {
15776 if (strlen($2) != 0 && strcmp ($1, "datetime") != 0 && strcmp ($1, "interval") != 0)
15777 mmerror (PARSE_ERROR, ET_ERROR, "interval specification not allowed here");
15778
15779 /*
15780 * Check for type names that the SQL grammar treats as
15781 * unreserved keywords
15782 */
15783 if (strcmp($1, "varchar") == 0)
15784 {
15785 $$.type_enum = ECPGt_varchar;
15786 $$.type_str = EMPTY; /*mm_strdup("varchar");*/
15787 $$.type_dimension = mm_strdup("-1");
15788 $$.type_index = mm_strdup("-1");
15789 $$.type_sizeof = NULL;
15790 }
15791 else if (strcmp($1, "bytea") == 0)
15792 {
15793 $$.type_enum = ECPGt_bytea;
15794 $$.type_str = EMPTY;
15795 $$.type_dimension = mm_strdup("-1");
15796 $$.type_index = mm_strdup("-1");
15797 $$.type_sizeof = NULL;
15798 }
15799 else if (strcmp($1, "float") == 0)
15800 {
15801 $$.type_enum = ECPGt_float;
15802 $$.type_str = mm_strdup("float");
15803 $$.type_dimension = mm_strdup("-1");
15804 $$.type_index = mm_strdup("-1");
15805 $$.type_sizeof = NULL;
15806 }
15807 else if (strcmp($1, "double") == 0)
15808 {
15809 $$.type_enum = ECPGt_double;
15810 $$.type_str = mm_strdup("double");
15811 $$.type_dimension = mm_strdup("-1");
15812 $$.type_index = mm_strdup("-1");
15813 $$.type_sizeof = NULL;
15814 }
15815 else if (strcmp($1, "numeric") == 0)
15816 {
15817 $$.type_enum = ECPGt_numeric;
15818 $$.type_str = mm_strdup("numeric");
15819 $$.type_dimension = mm_strdup("-1");
15820 $$.type_index = mm_strdup("-1");
15821 $$.type_sizeof = NULL;
15822 }
15823 else if (strcmp($1, "decimal") == 0)
15824 {
15825 $$.type_enum = ECPGt_decimal;
15826 $$.type_str = mm_strdup("decimal");
15827 $$.type_dimension = mm_strdup("-1");
15828 $$.type_index = mm_strdup("-1");
15829 $$.type_sizeof = NULL;
15830 }
15831 else if (strcmp($1, "date") == 0)
15832 {
15833 $$.type_enum = ECPGt_date;
15834 $$.type_str = mm_strdup("date");
15835 $$.type_dimension = mm_strdup("-1");
15836 $$.type_index = mm_strdup("-1");
15837 $$.type_sizeof = NULL;
15838 }
15839 else if (strcmp($1, "timestamp") == 0)
15840 {
15841 $$.type_enum = ECPGt_timestamp;
15842 $$.type_str = mm_strdup("timestamp");
15843 $$.type_dimension = mm_strdup("-1");
15844 $$.type_index = mm_strdup("-1");
15845 $$.type_sizeof = NULL;
15846 }
15847 else if (strcmp($1, "interval") == 0)
15848 {
15849 $$.type_enum = ECPGt_interval;
15850 $$.type_str = mm_strdup("interval");
15851 $$.type_dimension = mm_strdup("-1");
15852 $$.type_index = mm_strdup("-1");
15853 $$.type_sizeof = NULL;
15854 }
15855 else if (strcmp($1, "datetime") == 0)
15856 {
15857 $$.type_enum = ECPGt_timestamp;
15858 $$.type_str = mm_strdup("timestamp");
15859 $$.type_dimension = mm_strdup("-1");
15860 $$.type_index = mm_strdup("-1");
15861 $$.type_sizeof = NULL;
15862 }
15863 else if ((strcmp($1, "string") == 0) && INFORMIX_MODE)
15864 {
15865 $$.type_enum = ECPGt_string;
15866 $$.type_str = mm_strdup("char");
15867 $$.type_dimension = mm_strdup("-1");
15868 $$.type_index = mm_strdup("-1");
15869 $$.type_sizeof = NULL;
15870 }
15871 else
15872 {
15873 /* this is for typedef'ed types */
15874 struct typedefs *this = get_typedef($1);
15875
15876 $$.type_str = (this->type->type_enum == ECPGt_varchar || this->type->type_enum == ECPGt_bytea) ? EMPTY : mm_strdup(this->name);
15877 $$.type_enum = this->type->type_enum;
15878 $$.type_dimension = this->type->type_dimension;
15879 $$.type_index = this->type->type_index;
15880 if (this->type->type_sizeof && strlen(this->type->type_sizeof) != 0)
15881 $$.type_sizeof = this->type->type_sizeof;
15882 else
15883 $$.type_sizeof = cat_str(3, mm_strdup("sizeof("), mm_strdup(this->name), mm_strdup(")"));
15884
15885 struct_member_list[struct_level] = ECPGstruct_member_dup(this->struct_member_list);
15886 }
15887 }
15888 | s_struct_union_symbol
15889 {
15890 /* this is for named structs/unions */
15891 char *name;
15892 struct typedefs *this;
15893 bool forward = (forward_name != NULL && strcmp($1.symbol, forward_name) == 0 && strcmp($1.su, "struct") == 0);
15894
15895 name = cat2_str($1.su, $1.symbol);
15896 /* Do we have a forward definition? */
15897 if (!forward)
15898 {
15899 /* No */
15900
15901 this = get_typedef(name);
15902 $$.type_str = mm_strdup(this->name);
15903 $$.type_enum = this->type->type_enum;
15904 $$.type_dimension = this->type->type_dimension;
15905 $$.type_index = this->type->type_index;
15906 $$.type_sizeof = this->type->type_sizeof;
15907 struct_member_list[struct_level] = ECPGstruct_member_dup(this->struct_member_list);
15908 free(name);
15909 }
15910 else
15911 {
15912 $$.type_str = name;
15913 $$.type_enum = ECPGt_long;
15914 $$.type_dimension = mm_strdup("-1");
15915 $$.type_index = mm_strdup("-1");
15916 $$.type_sizeof = mm_strdup("");
15917 struct_member_list[struct_level] = NULL;
15918 }
15919 }
15920 ;
15921
15922 enum_type: ENUM_P symbol enum_definition
15923 { $$ = cat_str(3, mm_strdup("enum"), $2, $3); }
15924 | ENUM_P enum_definition
15925 { $$ = cat2_str(mm_strdup("enum"), $2); }
15926 | ENUM_P symbol
15927 { $$ = cat2_str(mm_strdup("enum"), $2); }
15928 ;
15929
15930 enum_definition: '{' c_list '}'
15931 { $$ = cat_str(3, mm_strdup("{"), $2, mm_strdup("}")); };
15932
15933 struct_union_type_with_symbol: s_struct_union_symbol
15934 {
15935 struct_member_list[struct_level++] = NULL;
15936 if (struct_level >= STRUCT_DEPTH)
15937 mmerror(PARSE_ERROR, ET_ERROR, "too many levels in nested structure/union definition");
15938 forward_name = mm_strdup($1.symbol);
15939 }
15940 '{' variable_declarations '}'
15941 {
15942 struct typedefs *ptr, *this;
15943 struct this_type su_type;
15944
15945 ECPGfree_struct_member(struct_member_list[struct_level]);
15946 struct_member_list[struct_level] = NULL;
15947 struct_level--;
15948 if (strncmp($1.su, "struct", sizeof("struct")-1) == 0)
15949 su_type.type_enum = ECPGt_struct;
15950 else
15951 su_type.type_enum = ECPGt_union;
15952 su_type.type_str = cat2_str($1.su, $1.symbol);
15953 free(forward_name);
15954 forward_name = NULL;
15955
15956 /* This is essentially a typedef but needs the keyword struct/union as well.
15957 * So we create the typedef for each struct definition with symbol */
15958 for (ptr = types; ptr != NULL; ptr = ptr->next)
15959 {
15960 if (strcmp(su_type.type_str, ptr->name) == 0)
15961 /* re-definition is a bug */
15962 mmerror(PARSE_ERROR, ET_ERROR, "type \"%s\" is already defined", su_type.type_str);
15963 }
15964
15965 this = (struct typedefs *) mm_alloc(sizeof(struct typedefs));
15966
15967 /* initial definition */
15968 this->next = types;
15969 this->name = mm_strdup(su_type.type_str);
15970 this->brace_level = braces_open;
15971 this->type = (struct this_type *) mm_alloc(sizeof(struct this_type));
15972 this->type->type_enum = su_type.type_enum;
15973 this->type->type_str = mm_strdup(su_type.type_str);
15974 this->type->type_dimension = mm_strdup("-1"); /* dimension of array */
15975 this->type->type_index = mm_strdup("-1"); /* length of string */
15976 this->type->type_sizeof = ECPGstruct_sizeof;
15977 this->struct_member_list = struct_member_list[struct_level];
15978
15979 types = this;
15980 $$ = cat_str(4, su_type.type_str, mm_strdup("{"), $4, mm_strdup("}"));
15981 }
15982 ;
15983
15984 struct_union_type: struct_union_type_with_symbol { $$ = $1; }
15985 | s_struct_union
15986 {
15987 struct_member_list[struct_level++] = NULL;
15988 if (struct_level >= STRUCT_DEPTH)
15989 mmerror(PARSE_ERROR, ET_ERROR, "too many levels in nested structure/union definition");
15990 }
15991 '{' variable_declarations '}'
15992 {
15993 ECPGfree_struct_member(struct_member_list[struct_level]);
15994 struct_member_list[struct_level] = NULL;
15995 struct_level--;
15996 $$ = cat_str(4, $1, mm_strdup("{"), $4, mm_strdup("}"));
15997 }
15998 ;
15999
16000 s_struct_union_symbol: SQL_STRUCT symbol
16001 {
16002 $$.su = mm_strdup("struct");
16003 $$.symbol = $2;
16004 ECPGstruct_sizeof = cat_str(3, mm_strdup("sizeof("), cat2_str(mm_strdup($$.su), mm_strdup($$.symbol)), mm_strdup(")"));
16005 }
16006 | UNION symbol
16007 {
16008 $$.su = mm_strdup("union");
16009 $$.symbol = $2;
16010 }
16011 ;
16012
16013 s_struct_union: SQL_STRUCT
16014 {
16015 ECPGstruct_sizeof = mm_strdup(""); /* This must not be NULL to distinguish from simple types. */
16016 $$ = mm_strdup("struct");
16017 }
16018 | UNION
16019 {
16020 $$ = mm_strdup("union");
16021 }
16022 ;
16023
16024 simple_type: unsigned_type { $$=$1; }
16025 | opt_signed signed_type { $$=$2; }
16026 ;
16027
16028 unsigned_type: SQL_UNSIGNED SQL_SHORT { $$ = ECPGt_unsigned_short; }
16029 | SQL_UNSIGNED SQL_SHORT INT_P { $$ = ECPGt_unsigned_short; }
16030 | SQL_UNSIGNED { $$ = ECPGt_unsigned_int; }
16031 | SQL_UNSIGNED INT_P { $$ = ECPGt_unsigned_int; }
16032 | SQL_UNSIGNED SQL_LONG { $$ = ECPGt_unsigned_long; }
16033 | SQL_UNSIGNED SQL_LONG INT_P { $$ = ECPGt_unsigned_long; }
16034 | SQL_UNSIGNED SQL_LONG SQL_LONG { $$ = ECPGt_unsigned_long_long; }
16035 | SQL_UNSIGNED SQL_LONG SQL_LONG INT_P { $$ = ECPGt_unsigned_long_long; }
16036 | SQL_UNSIGNED CHAR_P { $$ = ECPGt_unsigned_char; }
16037 ;
16038
16039 signed_type: SQL_SHORT { $$ = ECPGt_short; }
16040 | SQL_SHORT INT_P { $$ = ECPGt_short; }
16041 | INT_P { $$ = ECPGt_int; }
16042 | SQL_LONG { $$ = ECPGt_long; }
16043 | SQL_LONG INT_P { $$ = ECPGt_long; }
16044 | SQL_LONG SQL_LONG { $$ = ECPGt_long_long; }
16045 | SQL_LONG SQL_LONG INT_P { $$ = ECPGt_long_long; }
16046 | SQL_BOOL { $$ = ECPGt_bool; }
16047 | CHAR_P { $$ = ECPGt_char; }
16048 | DOUBLE_P { $$ = ECPGt_double; }
16049 ;
16050
16051 opt_signed: SQL_SIGNED
16052 | /* EMPTY */
16053 ;
16054
16055 variable_list: variable
16056 { $$ = $1; }
16057 | variable_list ',' variable
16058 {
16059 if (actual_type[struct_level].type_enum == ECPGt_varchar || actual_type[struct_level].type_enum == ECPGt_bytea)
16060 $$ = cat_str(3, $1, mm_strdup(";"), $3);
16061 else
16062 $$ = cat_str(3, $1, mm_strdup(","), $3);
16063 }
16064 ;
16065
16066 variable: opt_pointer ECPGColLabel opt_array_bounds opt_bit_field opt_initializer
16067 {
16068 struct ECPGtype * type;
16069 char *dimension = $3.index1; /* dimension of array */
16070 char *length = $3.index2; /* length of string */
16071 char *dim_str;
16072 char *vcn;
16073 int *varlen_type_counter;
16074 char *struct_name;
16075
16076 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);
16077 switch (actual_type[struct_level].type_enum)
16078 {
16079 case ECPGt_struct:
16080 case ECPGt_union:
16081 if (atoi(dimension) < 0)
16082 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);
16083 else
16084 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);
16085
16086 $$ = cat_str(5, $1, mm_strdup($2), $3.str, $4, $5);
16087 break;
16088
16089 case ECPGt_varchar:
16090 case ECPGt_bytea:
16091 if (actual_type[struct_level].type_enum == ECPGt_varchar)
16092 {
16093 varlen_type_counter = &varchar_counter;
16094 struct_name = " struct varchar_";
16095 }
16096 else
16097 {
16098 varlen_type_counter = &bytea_counter;
16099 struct_name = " struct bytea_";
16100 }
16101 if (atoi(dimension) < 0)
16102 type = ECPGmake_simple_type(actual_type[struct_level].type_enum, length, *varlen_type_counter);
16103 else
16104 type = ECPGmake_array_type(ECPGmake_simple_type(actual_type[struct_level].type_enum, length, *varlen_type_counter), dimension);
16105
16106 if (strcmp(dimension, "0") == 0 || abs(atoi(dimension)) == 1)
16107 dim_str=mm_strdup("");
16108 else
16109 dim_str=cat_str(3, mm_strdup("["), mm_strdup(dimension), mm_strdup("]"));
16110 /* cannot check for atoi <= 0 because a defined constant will yield 0 here as well */
16111 if (atoi(length) < 0 || strcmp(length, "0") == 0)
16112 mmerror(PARSE_ERROR, ET_ERROR, "pointers to varchar are not implemented");
16113
16114 /* make sure varchar struct name is unique by adding a unique counter to its definition */
16115 vcn = (char *) mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
16116 sprintf(vcn, "%d", *varlen_type_counter);
16117 if (strcmp(dimension, "0") == 0)
16118 $$ = 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);
16119 else
16120 $$ = 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);
16121 (*varlen_type_counter)++;
16122 break;
16123
16124 case ECPGt_char:
16125 case ECPGt_unsigned_char:
16126 case ECPGt_string:
16127 if (atoi(dimension) == -1)
16128 {
16129 int i = strlen($5);
16130
16131 if (atoi(length) == -1 && i > 0) /* char <var>[] = "string" */
16132 {
16133 /* if we have an initializer but no string size set, let's use the initializer's length */
16134 free(length);
16135 length = mm_alloc(i+sizeof("sizeof()"));
16136 sprintf(length, "sizeof(%s)", $5+2);
16137 }
16138 type = ECPGmake_simple_type(actual_type[struct_level].type_enum, length, 0);
16139 }
16140 else
16141 type = ECPGmake_array_type(ECPGmake_simple_type(actual_type[struct_level].type_enum, length, 0), dimension);
16142
16143 $$ = cat_str(5, $1, mm_strdup($2), $3.str, $4, $5);
16144 break;
16145
16146 default:
16147 if (atoi(dimension) < 0)
16148 type = ECPGmake_simple_type(actual_type[struct_level].type_enum, mm_strdup("1"), 0);
16149 else
16150 type = ECPGmake_array_type(ECPGmake_simple_type(actual_type[struct_level].type_enum, mm_strdup("1"), 0), dimension);
16151
16152 $$ = cat_str(5, $1, mm_strdup($2), $3.str, $4, $5);
16153 break;
16154 }
16155
16156 if (struct_level == 0)
16157 new_variable($2, type, braces_open);
16158 else
16159 ECPGmake_struct_member($2, type, &(struct_member_list[struct_level - 1]));
16160
16161 free($2);
16162 }
16163 ;
16164
16165 opt_initializer: /*EMPTY*/
16166 { $$ = EMPTY; }
16167 | '=' c_term
16168 {
16169 initializer = 1;
16170 $$ = cat2_str(mm_strdup("="), $2);
16171 }
16172 ;
16173
16174 opt_pointer: /*EMPTY*/ { $$ = EMPTY; }
16175 | '*' { $$ = mm_strdup("*"); }
16176 | '*' '*' { $$ = mm_strdup("**"); }
16177 ;
16178
16179 /*
16180 * We try to simulate the correct DECLARE syntax here so we get dynamic SQL
16181 */
16182 ECPGDeclare: DECLARE STATEMENT ecpg_ident
16183 {
16184 /* this is only supported for compatibility */
16185 $$ = cat_str(3, mm_strdup("/* declare statement"), $3, mm_strdup("*/"));
16186 }
16187 ;
16188 /*
16189 * the exec sql disconnect statement: disconnect from the given database
16190 */
16191 ECPGDisconnect: SQL_DISCONNECT dis_name { $$ = $2; }
16192 ;
16193
16194 dis_name: connection_object { $$ = $1; }
16195 | CURRENT_P { $$ = mm_strdup("\"CURRENT\""); }
16196 | ALL { $$ = mm_strdup("\"ALL\""); }
16197 | /* EMPTY */ { $$ = mm_strdup("\"CURRENT\""); }
16198 ;
16199
16200 connection_object: database_name { $$ = make3_str(mm_strdup("\""), $1, mm_strdup("\"")); }
16201 | DEFAULT { $$ = mm_strdup("\"DEFAULT\""); }
16202 | char_variable { $$ = $1; }
16203 ;
16204
16205 execstring: char_variable
16206 { $$ = $1; }
16207 | CSTRING
16208 { $$ = make3_str(mm_strdup("\""), $1, mm_strdup("\"")); }
16209 ;
16210
16211 /*
16212 * the exec sql free command to deallocate a previously
16213 * prepared statement
16214 */
16215 ECPGFree: SQL_FREE cursor_name { $$ = $2; }
16216 | SQL_FREE ALL { $$ = mm_strdup("all"); }
16217 ;
16218
16219 /*
16220 * open is an open cursor, at the moment this has to be removed
16221 */
16222 ECPGOpen: SQL_OPEN cursor_name opt_ecpg_using
16223 {
16224 if ($2[0] == ':')
16225 remove_variable_from_list(&argsinsert, find_variable($2 + 1));
16226 $$ = $2;
16227 }
16228 ;
16229
16230 opt_ecpg_using: /*EMPTY*/ { $$ = EMPTY; }
16231 | ecpg_using { $$ = $1; }
16232 ;
16233
16234 ecpg_using: USING using_list { $$ = EMPTY; }
16235 | using_descriptor { $$ = $1; }
16236 ;
16237
16238 using_descriptor: USING SQL_P SQL_DESCRIPTOR quoted_ident_stringvar
16239 {
16240 add_variable_to_head(&argsinsert, descriptor_variable($4,0), &no_indicator);
16241 $$ = EMPTY;
16242 }
16243 | USING SQL_DESCRIPTOR name
16244 {
16245 add_variable_to_head(&argsinsert, sqlda_variable($3), &no_indicator);
16246 $$ = EMPTY;
16247 }
16248 ;
16249
16250 into_descriptor: INTO SQL_P SQL_DESCRIPTOR quoted_ident_stringvar
16251 {
16252 add_variable_to_head(&argsresult, descriptor_variable($4,1), &no_indicator);
16253 $$ = EMPTY;
16254 }
16255 | INTO SQL_DESCRIPTOR name
16256 {
16257 add_variable_to_head(&argsresult, sqlda_variable($3), &no_indicator);
16258 $$ = EMPTY;
16259 }
16260 ;
16261
16262 into_sqlda: INTO name
16263 {
16264 add_variable_to_head(&argsresult, sqlda_variable($2), &no_indicator);
16265 $$ = EMPTY;
16266 }
16267 ;
16268
16269 using_list: UsingValue | UsingValue ',' using_list;
16270
16271 UsingValue: UsingConst
16272 {
16273 char *length = mm_alloc(32);
16274
16275 sprintf(length, "%zu", strlen($1));
16276 add_variable_to_head(&argsinsert, new_variable($1, ECPGmake_simple_type(ECPGt_const, length, 0), 0), &no_indicator);
16277 }
16278 | civar { $$ = EMPTY; }
16279 | civarind { $$ = EMPTY; }
16280 ;
16281
16282 UsingConst: Iconst { $$ = $1; }
16283 | '+' Iconst { $$ = cat_str(2, mm_strdup("+"), $2); }
16284 | '-' Iconst { $$ = cat_str(2, mm_strdup("-"), $2); }
16285 | ecpg_fconst { $$ = $1; }
16286 | '+' ecpg_fconst { $$ = cat_str(2, mm_strdup("+"), $2); }
16287 | '-' ecpg_fconst { $$ = cat_str(2, mm_strdup("-"), $2); }
16288 | ecpg_sconst { $$ = $1; }
16289 | ecpg_bconst { $$ = $1; }
16290 | ecpg_xconst { $$ = $1; }
16291 ;
16292
16293 /*
16294 * We accept DESCRIBE [OUTPUT] but do nothing with DESCRIBE INPUT so far.
16295 */
16296 ECPGDescribe: SQL_DESCRIBE INPUT_P prepared_name using_descriptor
16297 {
16298 const char *con = connection ? connection : "NULL";
16299 mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
16300 $$ = (char *) mm_alloc(sizeof("1, , ") + strlen(con) + strlen($3));
16301 sprintf($$, "1, %s, %s", con, $3);
16302 }
16303 | SQL_DESCRIBE opt_output prepared_name using_descriptor
16304 {
16305 const char *con = connection ? connection : "NULL";
16306 struct variable *var;
16307
16308 var = argsinsert->variable;
16309 remove_variable_from_list(&argsinsert, var);
16310 add_variable_to_head(&argsresult, var, &no_indicator);
16311
16312 $$ = (char *) mm_alloc(sizeof("0, , ") + strlen(con) + strlen($3));
16313 sprintf($$, "0, %s, %s", con, $3);
16314 }
16315 | SQL_DESCRIBE opt_output prepared_name into_descriptor
16316 {
16317 const char *con = connection ? connection : "NULL";
16318 $$ = (char *) mm_alloc(sizeof("0, , ") + strlen(con) + strlen($3));
16319 sprintf($$, "0, %s, %s", con, $3);
16320 }
16321 | SQL_DESCRIBE INPUT_P prepared_name into_sqlda
16322 {
16323 const char *con = connection ? connection : "NULL";
16324 mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
16325 $$ = (char *) mm_alloc(sizeof("1, , ") + strlen(con) + strlen($3));
16326 sprintf($$, "1, %s, %s", con, $3);
16327 }
16328 | SQL_DESCRIBE opt_output prepared_name into_sqlda
16329 {
16330 const char *con = connection ? connection : "NULL";
16331 $$ = (char *) mm_alloc(sizeof("0, , ") + strlen(con) + strlen($3));
16332 sprintf($$, "0, %s, %s", con, $3);
16333 }
16334 ;
16335
16336 opt_output: SQL_OUTPUT { $$ = mm_strdup("output"); }
16337 | /* EMPTY */ { $$ = EMPTY; }
16338 ;
16339
16340 /*
16341 * dynamic SQL: descriptor based access
16342 * originally written by Christof Petig <christof.petig@wtal.de>
16343 * and Peter Eisentraut <peter.eisentraut@credativ.de>
16344 */
16345
16346 /*
16347 * allocate a descriptor
16348 */
16349 ECPGAllocateDescr: SQL_ALLOCATE SQL_DESCRIPTOR quoted_ident_stringvar
16350 {
16351 add_descriptor($3,connection);
16352 $$ = $3;
16353 }
16354 ;
16355
16356
16357 /*
16358 * deallocate a descriptor
16359 */
16360 ECPGDeallocateDescr: DEALLOCATE SQL_DESCRIPTOR quoted_ident_stringvar
16361 {
16362 drop_descriptor($3,connection);
16363 $$ = $3;
16364 }
16365 ;
16366
16367 /*
16368 * manipulate a descriptor header
16369 */
16370
16371 ECPGGetDescriptorHeader: SQL_GET SQL_DESCRIPTOR quoted_ident_stringvar ECPGGetDescHeaderItems
16372 { $$ = $3; }
16373 ;
16374
16375 ECPGGetDescHeaderItems: ECPGGetDescHeaderItem
16376 | ECPGGetDescHeaderItems ',' ECPGGetDescHeaderItem
16377 ;
16378
16379 ECPGGetDescHeaderItem: cvariable '=' desc_header_item
16380 { push_assignment($1, $3); }
16381 ;
16382
16383
16384 ECPGSetDescriptorHeader: SET SQL_DESCRIPTOR quoted_ident_stringvar ECPGSetDescHeaderItems
16385 { $$ = $3; }
16386 ;
16387
16388 ECPGSetDescHeaderItems: ECPGSetDescHeaderItem
16389 | ECPGSetDescHeaderItems ',' ECPGSetDescHeaderItem
16390 ;
16391
16392 ECPGSetDescHeaderItem: desc_header_item '=' IntConstVar
16393 {
16394 push_assignment($3, $1);
16395 }
16396 ;
16397
16398 IntConstVar: Iconst
16399 {
16400 char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
16401
16402 sprintf(length, "%zu", strlen($1));
16403 new_variable($1, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
16404 $$ = $1;
16405 }
16406 | cvariable
16407 {
16408 $$ = $1;
16409 }
16410 ;
16411
16412 desc_header_item: SQL_COUNT { $$ = ECPGd_count; }
16413 ;
16414
16415 /*
16416 * manipulate a descriptor
16417 */
16418
16419 ECPGGetDescriptor: SQL_GET SQL_DESCRIPTOR quoted_ident_stringvar VALUE_P IntConstVar ECPGGetDescItems
16420 { $$.str = $5; $$.name = $3; }
16421 ;
16422
16423 ECPGGetDescItems: ECPGGetDescItem
16424 | ECPGGetDescItems ',' ECPGGetDescItem
16425 ;
16426
16427 ECPGGetDescItem: cvariable '=' descriptor_item { push_assignment($1, $3); };
16428
16429
16430 ECPGSetDescriptor: SET SQL_DESCRIPTOR quoted_ident_stringvar VALUE_P IntConstVar ECPGSetDescItems
16431 { $$.str = $5; $$.name = $3; }
16432 ;
16433
16434 ECPGSetDescItems: ECPGSetDescItem
16435 | ECPGSetDescItems ',' ECPGSetDescItem
16436 ;
16437
16438 ECPGSetDescItem: descriptor_item '=' AllConstVar
16439 {
16440 push_assignment($3, $1);
16441 }
16442 ;
16443
16444 AllConstVar: ecpg_fconst
16445 {
16446 char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
16447
16448 sprintf(length, "%zu", strlen($1));
16449 new_variable($1, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
16450 $$ = $1;
16451 }
16452
16453 | IntConstVar
16454 {
16455 $$ = $1;
16456 }
16457
16458 | '-' ecpg_fconst
16459 {
16460 char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
16461 char *var = cat2_str(mm_strdup("-"), $2);
16462
16463 sprintf(length, "%zu", strlen(var));
16464 new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
16465 $$ = var;
16466 }
16467
16468 | '-' Iconst
16469 {
16470 char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
16471 char *var = cat2_str(mm_strdup("-"), $2);
16472
16473 sprintf(length, "%zu", strlen(var));
16474 new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
16475 $$ = var;
16476 }
16477
16478 | ecpg_sconst
16479 {
16480 char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
16481 char *var = $1 + 1;
16482
16483 var[strlen(var) - 1] = '\0';
16484 sprintf(length, "%zu", strlen(var));
16485 new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
16486 $$ = var;
16487 }
16488 ;
16489
16490 descriptor_item: SQL_CARDINALITY { $$ = ECPGd_cardinality; }
16491 | DATA_P { $$ = ECPGd_data; }
16492 | SQL_DATETIME_INTERVAL_CODE { $$ = ECPGd_di_code; }
16493 | SQL_DATETIME_INTERVAL_PRECISION { $$ = ECPGd_di_precision; }
16494 | SQL_INDICATOR { $$ = ECPGd_indicator; }
16495 | SQL_KEY_MEMBER { $$ = ECPGd_key_member; }
16496 | SQL_LENGTH { $$ = ECPGd_length; }
16497 | NAME_P { $$ = ECPGd_name; }
16498 | SQL_NULLABLE { $$ = ECPGd_nullable; }
16499 | SQL_OCTET_LENGTH { $$ = ECPGd_octet; }
16500 | PRECISION { $$ = ECPGd_precision; }
16501 | SQL_RETURNED_LENGTH { $$ = ECPGd_length; }
16502 | SQL_RETURNED_OCTET_LENGTH { $$ = ECPGd_ret_octet; }
16503 | SQL_SCALE { $$ = ECPGd_scale; }
16504 | TYPE_P { $$ = ECPGd_type; }
16505 ;
16506
16507 /*
16508 * set/reset the automatic transaction mode, this needs a different handling
16509 * as the other set commands
16510 */
16511 ECPGSetAutocommit: SET SQL_AUTOCOMMIT '=' on_off { $$ = $4; }
16512 | SET SQL_AUTOCOMMIT TO on_off { $$ = $4; }
16513 ;
16514
16515 on_off: ON { $$ = mm_strdup("on"); }
16516 | OFF { $$ = mm_strdup("off"); }
16517 ;
16518
16519 /*
16520 * set the actual connection, this needs a different handling as the other
16521 * set commands
16522 */
16523 ECPGSetConnection: SET CONNECTION TO connection_object { $$ = $4; }
16524 | SET CONNECTION '=' connection_object { $$ = $4; }
16525 | SET CONNECTION connection_object { $$ = $3; }
16526 ;
16527
16528 /*
16529 * define a new type for embedded SQL
16530 */
16531 ECPGTypedef: TYPE_P
16532 {
16533 /* reset this variable so we see if there was */
16534 /* an initializer specified */
16535 initializer = 0;
16536 }
16537 ECPGColLabelCommon IS var_type opt_array_bounds opt_reference
16538 {
16539 add_typedef($3, $6.index1, $6.index2, $5.type_enum, $5.type_dimension, $5.type_index, initializer, *$7 ? 1 : 0);
16540
16541 if (auto_create_c == false)
16542 $$ = 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("*/"));
16543 else
16544 $$ = 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(";"));
16545 }
16546 ;
16547
16548 opt_reference: SQL_REFERENCE { $$ = mm_strdup("reference"); }
16549 | /*EMPTY*/ { $$ = EMPTY; }
16550 ;
16551
16552 /*
16553 * define the type of one variable for embedded SQL
16554 */
16555 ECPGVar: SQL_VAR
16556 {
16557 /* reset this variable so we see if there was */
16558 /* an initializer specified */
16559 initializer = 0;
16560 }
16561 ColLabel IS var_type opt_array_bounds opt_reference
16562 {
16563 struct variable *p = find_variable($3);
16564 char *dimension = $6.index1;
16565 char *length = $6.index2;
16566 struct ECPGtype * type;
16567
16568 if (($5.type_enum == ECPGt_struct ||
16569 $5.type_enum == ECPGt_union) &&
16570 initializer == 1)
16571 mmerror(PARSE_ERROR, ET_ERROR, "initializer not allowed in EXEC SQL VAR command");
16572 else
16573 {
16574 adjust_array($5.type_enum, &dimension, &length, $5.type_dimension, $5.type_index, *$7?1:0, false);
16575
16576 switch ($5.type_enum)
16577 {
16578 case ECPGt_struct:
16579 case ECPGt_union:
16580 if (atoi(dimension) < 0)
16581 type = ECPGmake_struct_type(struct_member_list[struct_level], $5.type_enum, $5.type_str, $5.type_sizeof);
16582 else
16583 type = ECPGmake_array_type(ECPGmake_struct_type(struct_member_list[struct_level], $5.type_enum, $5.type_str, $5.type_sizeof), dimension);
16584 break;
16585
16586 case ECPGt_varchar:
16587 case ECPGt_bytea:
16588 if (atoi(dimension) == -1)
16589 type = ECPGmake_simple_type($5.type_enum, length, 0);
16590 else
16591 type = ECPGmake_array_type(ECPGmake_simple_type($5.type_enum, length, 0), dimension);
16592 break;
16593
16594 case ECPGt_char:
16595 case ECPGt_unsigned_char:
16596 case ECPGt_string:
16597 if (atoi(dimension) == -1)
16598 type = ECPGmake_simple_type($5.type_enum, length, 0);
16599 else
16600 type = ECPGmake_array_type(ECPGmake_simple_type($5.type_enum, length, 0), dimension);
16601 break;
16602
16603 default:
16604 if (atoi(length) >= 0)
16605 mmerror(PARSE_ERROR, ET_ERROR, "multidimensional arrays for simple data types are not supported");
16606
16607 if (atoi(dimension) < 0)
16608 type = ECPGmake_simple_type($5.type_enum, mm_strdup("1"), 0);
16609 else
16610 type = ECPGmake_array_type(ECPGmake_simple_type($5.type_enum, mm_strdup("1"), 0), dimension);
16611 break;
16612 }
16613
16614 ECPGfree_type(p->type);
16615 p->type = type;
16616 }
16617
16618 $$ = 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("*/"));
16619 }
16620 ;
16621
16622 /*
16623 * whenever statement: decide what to do in case of error/no data found
16624 * according to SQL standards we lack: SQLSTATE, CONSTRAINT and SQLEXCEPTION
16625 */
16626 ECPGWhenever: SQL_WHENEVER SQL_SQLERROR action
16627 {
16628 when_error.code = $<action>3.code;
16629 when_error.command = $<action>3.command;
16630 $$ = cat_str(3, mm_strdup("/* exec sql whenever sqlerror "), $3.str, mm_strdup("; */"));
16631 }
16632 | SQL_WHENEVER NOT SQL_FOUND action
16633 {
16634 when_nf.code = $<action>4.code;
16635 when_nf.command = $<action>4.command;
16636 $$ = cat_str(3, mm_strdup("/* exec sql whenever not found "), $4.str, mm_strdup("; */"));
16637 }
16638 | SQL_WHENEVER SQL_SQLWARNING action
16639 {
16640 when_warn.code = $<action>3.code;
16641 when_warn.command = $<action>3.command;
16642 $$ = cat_str(3, mm_strdup("/* exec sql whenever sql_warning "), $3.str, mm_strdup("; */"));
16643 }
16644 ;
16645
16646 action : CONTINUE_P
16647 {
16648 $<action>$.code = W_NOTHING;
16649 $<action>$.command = NULL;
16650 $<action>$.str = mm_strdup("continue");
16651 }
16652 | SQL_SQLPRINT
16653 {
16654 $<action>$.code = W_SQLPRINT;
16655 $<action>$.command = NULL;
16656 $<action>$.str = mm_strdup("sqlprint");
16657 }
16658 | SQL_STOP
16659 {
16660 $<action>$.code = W_STOP;
16661 $<action>$.command = NULL;
16662 $<action>$.str = mm_strdup("stop");
16663 }
16664 | SQL_GOTO name
16665 {
16666 $<action>$.code = W_GOTO;
16667 $<action>$.command = mm_strdup($2);
16668 $<action>$.str = cat2_str(mm_strdup("goto "), $2);
16669 }
16670 | SQL_GO TO name
16671 {
16672 $<action>$.code = W_GOTO;
16673 $<action>$.command = mm_strdup($3);
16674 $<action>$.str = cat2_str(mm_strdup("goto "), $3);
16675 }
16676 | DO name '(' c_args ')'
16677 {
16678 $<action>$.code = W_DO;
16679 $<action>$.command = cat_str(4, $2, mm_strdup("("), $4, mm_strdup(")"));
16680 $<action>$.str = cat2_str(mm_strdup("do"), mm_strdup($<action>$.command));
16681 }
16682 | DO SQL_BREAK
16683 {
16684 $<action>$.code = W_BREAK;
16685 $<action>$.command = NULL;
16686 $<action>$.str = mm_strdup("break");
16687 }
16688 | DO CONTINUE_P
16689 {
16690 $<action>$.code = W_CONTINUE;
16691 $<action>$.command = NULL;
16692 $<action>$.str = mm_strdup("continue");
16693 }
16694 | CALL name '(' c_args ')'
16695 {
16696 $<action>$.code = W_DO;
16697 $<action>$.command = cat_str(4, $2, mm_strdup("("), $4, mm_strdup(")"));
16698 $<action>$.str = cat2_str(mm_strdup("call"), mm_strdup($<action>$.command));
16699 }
16700 | CALL name
16701 {
16702 $<action>$.code = W_DO;
16703 $<action>$.command = cat2_str($2, mm_strdup("()"));
16704 $<action>$.str = cat2_str(mm_strdup("call"), mm_strdup($<action>$.command));
16705 }
16706 ;
16707
16708 /* some other stuff for ecpg */
16709
16710 /* additional unreserved keywords */
16711 ECPGKeywords: ECPGKeywords_vanames { $$ = $1; }
16712 | ECPGKeywords_rest { $$ = $1; }
16713 ;
16714
16715 ECPGKeywords_vanames: SQL_BREAK { $$ = mm_strdup("break"); }
16716 | SQL_CARDINALITY { $$ = mm_strdup("cardinality"); }
16717 | SQL_COUNT { $$ = mm_strdup("count"); }
16718 | SQL_DATETIME_INTERVAL_CODE { $$ = mm_strdup("datetime_interval_code"); }
16719 | SQL_DATETIME_INTERVAL_PRECISION { $$ = mm_strdup("datetime_interval_precision"); }
16720 | SQL_FOUND { $$ = mm_strdup("found"); }
16721 | SQL_GO { $$ = mm_strdup("go"); }
16722 | SQL_GOTO { $$ = mm_strdup("goto"); }
16723 | SQL_IDENTIFIED { $$ = mm_strdup("identified"); }
16724 | SQL_INDICATOR { $$ = mm_strdup("indicator"); }
16725 | SQL_KEY_MEMBER { $$ = mm_strdup("key_member"); }
16726 | SQL_LENGTH { $$ = mm_strdup("length"); }
16727 | SQL_NULLABLE { $$ = mm_strdup("nullable"); }
16728 | SQL_OCTET_LENGTH { $$ = mm_strdup("octet_length"); }
16729 | SQL_RETURNED_LENGTH { $$ = mm_strdup("returned_length"); }
16730 | SQL_RETURNED_OCTET_LENGTH { $$ = mm_strdup("returned_octet_length"); }
16731 | SQL_SCALE { $$ = mm_strdup("scale"); }
16732 | SQL_SECTION { $$ = mm_strdup("section"); }
16733 | SQL_SQLERROR { $$ = mm_strdup("sqlerror"); }
16734 | SQL_SQLPRINT { $$ = mm_strdup("sqlprint"); }
16735 | SQL_SQLWARNING { $$ = mm_strdup("sqlwarning"); }
16736 | SQL_STOP { $$ = mm_strdup("stop"); }
16737 ;
16738
16739 ECPGKeywords_rest: SQL_CONNECT { $$ = mm_strdup("connect"); }
16740 | SQL_DESCRIBE { $$ = mm_strdup("describe"); }
16741 | SQL_DISCONNECT { $$ = mm_strdup("disconnect"); }
16742 | SQL_OPEN { $$ = mm_strdup("open"); }
16743 | SQL_VAR { $$ = mm_strdup("var"); }
16744 | SQL_WHENEVER { $$ = mm_strdup("whenever"); }
16745 ;
16746
16747 /* additional keywords that can be SQL type names (but not ECPGColLabels) */
16748 ECPGTypeName: SQL_BOOL { $$ = mm_strdup("bool"); }
16749 | SQL_LONG { $$ = mm_strdup("long"); }
16750 | SQL_OUTPUT { $$ = mm_strdup("output"); }
16751 | SQL_SHORT { $$ = mm_strdup("short"); }
16752 | SQL_STRUCT { $$ = mm_strdup("struct"); }
16753 | SQL_SIGNED { $$ = mm_strdup("signed"); }
16754 | SQL_UNSIGNED { $$ = mm_strdup("unsigned"); }
16755 ;
16756
16757 symbol: ColLabel { $$ = $1; }
16758 ;
16759
16760 ECPGColId: ecpg_ident { $$ = $1; }
16761 | unreserved_keyword { $$ = $1; }
16762 | col_name_keyword { $$ = $1; }
16763 | ECPGunreserved_interval { $$ = $1; }
16764 | ECPGKeywords { $$ = $1; }
16765 | ECPGCKeywords { $$ = $1; }
16766 | CHAR_P { $$ = mm_strdup("char"); }
16767 | VALUES { $$ = mm_strdup("values"); }
16768 ;
16769
16770 /*
16771 * Name classification hierarchy.
16772 *
16773 * These productions should match those in the core grammar, except that
16774 * we use all_unreserved_keyword instead of unreserved_keyword, and
16775 * where possible include ECPG keywords as well as core keywords.
16776 */
16777
16778 /* Column identifier --- names that can be column, table, etc names.
16779 */
16780 ColId: ecpg_ident { $$ = $1; }
16781 | all_unreserved_keyword { $$ = $1; }
16782 | col_name_keyword { $$ = $1; }
16783 | ECPGKeywords { $$ = $1; }
16784 | ECPGCKeywords { $$ = $1; }
16785 | CHAR_P { $$ = mm_strdup("char"); }
16786 | VALUES { $$ = mm_strdup("values"); }
16787 ;
16788
16789 /* Type/function identifier --- names that can be type or function names.
16790 */
16791 type_function_name: ecpg_ident { $$ = $1; }
16792 | all_unreserved_keyword { $$ = $1; }
16793 | type_func_name_keyword { $$ = $1; }
16794 | ECPGKeywords { $$ = $1; }
16795 | ECPGCKeywords { $$ = $1; }
16796 | ECPGTypeName { $$ = $1; }
16797 ;
16798
16799 /* Column label --- allowed labels in "AS" clauses.
16800 * This presently includes *all* Postgres keywords.
16801 */
16802 ColLabel: ECPGColLabel { $$ = $1; }
16803 | ECPGTypeName { $$ = $1; }
16804 | CHAR_P { $$ = mm_strdup("char"); }
16805 | CURRENT_P { $$ = mm_strdup("current"); }
16806 | INPUT_P { $$ = mm_strdup("input"); }
16807 | INT_P { $$ = mm_strdup("int"); }
16808 | TO { $$ = mm_strdup("to"); }
16809 | UNION { $$ = mm_strdup("union"); }
16810 | VALUES { $$ = mm_strdup("values"); }
16811 | ECPGCKeywords { $$ = $1; }
16812 | ECPGunreserved_interval { $$ = $1; }
16813 ;
16814
16815 ECPGColLabel: ECPGColLabelCommon { $$ = $1; }
16816 | unreserved_keyword { $$ = $1; }
16817 | reserved_keyword { $$ = $1; }
16818 | ECPGKeywords_rest { $$ = $1; }
16819 | CONNECTION { $$ = mm_strdup("connection"); }
16820 ;
16821
16822 ECPGColLabelCommon: ecpg_ident { $$ = $1; }
16823 | col_name_keyword { $$ = $1; }
16824 | type_func_name_keyword { $$ = $1; }
16825 | ECPGKeywords_vanames { $$ = $1; }
16826 ;
16827
16828 ECPGCKeywords: S_AUTO { $$ = mm_strdup("auto"); }
16829 | S_CONST { $$ = mm_strdup("const"); }
16830 | S_EXTERN { $$ = mm_strdup("extern"); }
16831 | S_REGISTER { $$ = mm_strdup("register"); }
16832 | S_STATIC { $$ = mm_strdup("static"); }
16833 | S_TYPEDEF { $$ = mm_strdup("typedef"); }
16834 | S_VOLATILE { $$ = mm_strdup("volatile"); }
16835 ;
16836
16837 /* "Unreserved" keywords --- available for use as any kind of name.
16838 */
16839
16840 /*
16841 * The following symbols must be excluded from ECPGColLabel and directly
16842 * included into ColLabel to enable C variables to get names from ECPGColLabel:
16843 * DAY_P, HOUR_P, MINUTE_P, MONTH_P, SECOND_P, YEAR_P.
16844 *
16845 * We also have to exclude CONNECTION, CURRENT, and INPUT for various reasons.
16846 * CONNECTION can be added back in all_unreserved_keyword, but CURRENT and
16847 * INPUT are reserved for ecpg purposes.
16848 *
16849 * The mentioned exclusions are done by $replace_line settings in parse.pl.
16850 */
16851 all_unreserved_keyword: unreserved_keyword { $$ = $1; }
16852 | ECPGunreserved_interval { $$ = $1; }
16853 | CONNECTION { $$ = mm_strdup("connection"); }
16854 ;
16855
16856 ECPGunreserved_interval: DAY_P { $$ = mm_strdup("day"); }
16857 | HOUR_P { $$ = mm_strdup("hour"); }
16858 | MINUTE_P { $$ = mm_strdup("minute"); }
16859 | MONTH_P { $$ = mm_strdup("month"); }
16860 | SECOND_P { $$ = mm_strdup("second"); }
16861 | YEAR_P { $$ = mm_strdup("year"); }
16862 ;
16863
16864
16865 into_list : coutputvariable | into_list ',' coutputvariable
16866 ;
16867
16868 ecpgstart: SQL_START {
16869 reset_variables();
16870 pacounter = 1;
16871 }
16872 ;
16873
16874 c_args: /*EMPTY*/ { $$ = EMPTY; }
16875 | c_list { $$ = $1; }
16876 ;
16877
16878 coutputvariable: cvariable indicator
16879 { add_variable_to_head(&argsresult, find_variable($1), find_variable($2)); }
16880 | cvariable
16881 { add_variable_to_head(&argsresult, find_variable($1), &no_indicator); }
16882 ;
16883
16884
16885 civarind: cvariable indicator
16886 {
16887 if (find_variable($2)->type->type == ECPGt_array)
16888 mmerror(PARSE_ERROR, ET_ERROR, "arrays of indicators are not allowed on input");
16889
16890 add_variable_to_head(&argsinsert, find_variable($1), find_variable($2));
16891 $$ = create_questionmarks($1, false);
16892 }
16893 ;
16894
16895 char_civar: char_variable
16896 {
16897 char *ptr = strstr($1, ".arr");
16898
16899 if (ptr) /* varchar, we need the struct name here, not the struct element */
16900 *ptr = '\0';
16901 add_variable_to_head(&argsinsert, find_variable($1), &no_indicator);
16902 $$ = $1;
16903 }
16904 ;
16905
16906 civar: cvariable
16907 {
16908 add_variable_to_head(&argsinsert, find_variable($1), &no_indicator);
16909 $$ = create_questionmarks($1, false);
16910 }
16911 ;
16912
16913 indicator: cvariable { check_indicator((find_variable($1))->type); $$ = $1; }
16914 | SQL_INDICATOR cvariable { check_indicator((find_variable($2))->type); $$ = $2; }
16915 | SQL_INDICATOR name { check_indicator((find_variable($2))->type); $$ = $2; }
16916 ;
16917
16918 cvariable: CVARIABLE
16919 {
16920 /* As long as multidimensional arrays are not implemented we have to check for those here */
16921 char *ptr = $1;
16922 int brace_open=0, brace = false;
16923
16924 for (; *ptr; ptr++)
16925 {
16926 switch (*ptr)
16927 {
16928 case '[':
16929 if (brace)
16930 mmfatal(PARSE_ERROR, "multidimensional arrays for simple data types are not supported");
16931 brace_open++;
16932 break;
16933 case ']':
16934 brace_open--;
16935 if (brace_open == 0)
16936 brace = true;
16937 break;
16938 case '\t':
16939 case ' ':
16940 break;
16941 default:
16942 if (brace_open == 0)
16943 brace = false;
16944 break;
16945 }
16946 }
16947 $$ = $1;
16948 }
16949 ;
16950
16951 ecpg_param: PARAM { $$ = make_name(); } ;
16952
16953 ecpg_bconst: BCONST { $$ = $1; } ;
16954
16955 ecpg_fconst: FCONST { $$ = make_name(); } ;
16956
16957 ecpg_sconst: SCONST { $$ = $1; } ;
16958
16959 ecpg_xconst: XCONST { $$ = $1; } ;
16960
16961 ecpg_ident: IDENT { $$ = $1; }
16962 | CSTRING { $$ = make3_str(mm_strdup("\""), $1, mm_strdup("\"")); }
16963 ;
16964
16965 quoted_ident_stringvar: name
16966 { $$ = make3_str(mm_strdup("\""), $1, mm_strdup("\"")); }
16967 | char_variable
16968 { $$ = make3_str(mm_strdup("("), $1, mm_strdup(")")); }
16969 ;
16970
16971 /*
16972 * C stuff
16973 */
16974
16975 c_stuff_item: c_anything { $$ = $1; }
16976 | '(' ')' { $$ = mm_strdup("()"); }
16977 | '(' c_stuff ')'
16978 { $$ = cat_str(3, mm_strdup("("), $2, mm_strdup(")")); }
16979 ;
16980
16981 c_stuff: c_stuff_item { $$ = $1; }
16982 | c_stuff c_stuff_item
16983 { $$ = cat2_str($1, $2); }
16984 ;
16985
16986 c_list: c_term { $$ = $1; }
16987 | c_list ',' c_term { $$ = cat_str(3, $1, mm_strdup(","), $3); }
16988 ;
16989
16990 c_term: c_stuff { $$ = $1; }
16991 | '{' c_list '}' { $$ = cat_str(3, mm_strdup("{"), $2, mm_strdup("}")); }
16992 ;
16993
16994 c_thing: c_anything { $$ = $1; }
16995 | '(' { $$ = mm_strdup("("); }
16996 | ')' { $$ = mm_strdup(")"); }
16997 | ',' { $$ = mm_strdup(","); }
16998 | ';' { $$ = mm_strdup(";"); }
16999 ;
17000
17001 c_anything: ecpg_ident { $$ = $1; }
17002 | Iconst { $$ = $1; }
17003 | ecpg_fconst { $$ = $1; }
17004 | ecpg_sconst { $$ = $1; }
17005 | '*' { $$ = mm_strdup("*"); }
17006 | '+' { $$ = mm_strdup("+"); }
17007 | '-' { $$ = mm_strdup("-"); }
17008 | '/' { $$ = mm_strdup("/"); }
17009 | '%' { $$ = mm_strdup("%"); }
17010 | NULL_P { $$ = mm_strdup("NULL"); }
17011 | S_ADD { $$ = mm_strdup("+="); }
17012 | S_AND { $$ = mm_strdup("&&"); }
17013 | S_ANYTHING { $$ = make_name(); }
17014 | S_AUTO { $$ = mm_strdup("auto"); }
17015 | S_CONST { $$ = mm_strdup("const"); }
17016 | S_DEC { $$ = mm_strdup("--"); }
17017 | S_DIV { $$ = mm_strdup("/="); }
17018 | S_DOTPOINT { $$ = mm_strdup(".*"); }
17019 | S_EQUAL { $$ = mm_strdup("=="); }
17020 | S_EXTERN { $$ = mm_strdup("extern"); }
17021 | S_INC { $$ = mm_strdup("++"); }
17022 | S_LSHIFT { $$ = mm_strdup("<<"); }
17023 | S_MEMBER { $$ = mm_strdup("->"); }
17024 | S_MEMPOINT { $$ = mm_strdup("->*"); }
17025 | S_MOD { $$ = mm_strdup("%="); }
17026 | S_MUL { $$ = mm_strdup("*="); }
17027 | S_NEQUAL { $$ = mm_strdup("!="); }
17028 | S_OR { $$ = mm_strdup("||"); }
17029 | S_REGISTER { $$ = mm_strdup("register"); }
17030 | S_RSHIFT { $$ = mm_strdup(">>"); }
17031 | S_STATIC { $$ = mm_strdup("static"); }
17032 | S_SUB { $$ = mm_strdup("-="); }
17033 | S_TYPEDEF { $$ = mm_strdup("typedef"); }
17034 | S_VOLATILE { $$ = mm_strdup("volatile"); }
17035 | SQL_BOOL { $$ = mm_strdup("bool"); }
17036 | ENUM_P { $$ = mm_strdup("enum"); }
17037 | HOUR_P { $$ = mm_strdup("hour"); }
17038 | INT_P { $$ = mm_strdup("int"); }
17039 | SQL_LONG { $$ = mm_strdup("long"); }
17040 | MINUTE_P { $$ = mm_strdup("minute"); }
17041 | MONTH_P { $$ = mm_strdup("month"); }
17042 | SECOND_P { $$ = mm_strdup("second"); }
17043 | SQL_SHORT { $$ = mm_strdup("short"); }
17044 | SQL_SIGNED { $$ = mm_strdup("signed"); }
17045 | SQL_STRUCT { $$ = mm_strdup("struct"); }
17046 | SQL_UNSIGNED { $$ = mm_strdup("unsigned"); }
17047 | YEAR_P { $$ = mm_strdup("year"); }
17048 | CHAR_P { $$ = mm_strdup("char"); }
17049 | FLOAT_P { $$ = mm_strdup("float"); }
17050 | TO { $$ = mm_strdup("to"); }
17051 | UNION { $$ = mm_strdup("union"); }
17052 | VARCHAR { $$ = mm_strdup("varchar"); }
17053 | '[' { $$ = mm_strdup("["); }
17054 | ']' { $$ = mm_strdup("]"); }
17055 | '=' { $$ = mm_strdup("="); }
17056 | ':' { $$ = mm_strdup(":"); }
17057 ;
17058
17059 DeallocateStmt: DEALLOCATE prepared_name { $$ = $2; }
17060 | DEALLOCATE PREPARE prepared_name { $$ = $3; }
17061 | DEALLOCATE ALL { $$ = mm_strdup("all"); }
17062 | DEALLOCATE PREPARE ALL { $$ = mm_strdup("all"); }
17063 ;
17064
17065 Iresult: Iconst { $$ = $1; }
17066 | '(' Iresult ')' { $$ = cat_str(3, mm_strdup("("), $2, mm_strdup(")")); }
17067 | Iresult '+' Iresult { $$ = cat_str(3, $1, mm_strdup("+"), $3); }
17068 | Iresult '-' Iresult { $$ = cat_str(3, $1, mm_strdup("-"), $3); }
17069 | Iresult '*' Iresult { $$ = cat_str(3, $1, mm_strdup("*"), $3); }
17070 | Iresult '/' Iresult { $$ = cat_str(3, $1, mm_strdup("/"), $3); }
17071 | Iresult '%' Iresult { $$ = cat_str(3, $1, mm_strdup("%"), $3); }
17072 | ecpg_sconst { $$ = $1; }
17073 | ColId { $$ = $1; }
17074 | ColId '(' var_type ')' { if (pg_strcasecmp($1, "sizeof") != 0)
17075 mmerror(PARSE_ERROR, ET_ERROR, "operator not allowed in variable definition");
17076 else
17077 $$ = cat_str(4, $1, mm_strdup("("), $3.type_str, mm_strdup(")"));
17078 }
17079 ;
17080
17081 execute_rest: /* EMPTY */ { $$ = EMPTY; }
17082 | ecpg_using opt_ecpg_into { $$ = EMPTY; }
17083 | ecpg_into ecpg_using { $$ = EMPTY; }
17084 | ecpg_into { $$ = EMPTY; }
17085 ;
17086
17087 ecpg_into: INTO into_list { $$ = EMPTY; }
17088 | into_descriptor { $$ = $1; }
17089 ;
17090
17091 opt_ecpg_into: /* EMPTY */ { $$ = EMPTY; }
17092 | ecpg_into { $$ = $1; }
17093 ;
17094
17095 ecpg_fetch_into: ecpg_into { $$ = $1; }
17096 | using_descriptor
17097 {
17098 struct variable *var;
17099
17100 var = argsinsert->variable;
17101 remove_variable_from_list(&argsinsert, var);
17102 add_variable_to_head(&argsresult, var, &no_indicator);
17103 $$ = $1;
17104 }
17105 ;
17106
17107 opt_ecpg_fetch_into: /* EMPTY */ { $$ = EMPTY; }
17108 | ecpg_fetch_into { $$ = $1; }
17109 ;
17110
17111 %%
17112
17113 void base_yyerror(const char *error)
17114 {
17115 /* translator: %s is typically the translation of "syntax error" */
17116 mmerror(PARSE_ERROR, ET_ERROR, "%s at or near \"%s\"",
17117 _(error), token_start ? token_start : base_yytext);
17118 }
17119
parser_init(void)17120 void parser_init(void)
17121 {
17122 /* This function is empty. It only exists for compatibility with the backend parser right now. */
17123 }
17124