1 /* header */
2 /* src/interfaces/ecpg/preproc/ecpg.header */
3 
4 /* Copyright comment */
5 %{
6 #include "postgres_fe.h"
7 
8 #include "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 
51 /* temporarily store struct members while creating the data structure */
52 struct ECPGstruct_member *struct_member_list[STRUCT_DEPTH] = { NULL };
53 
54 /* also store struct type so we can do a sizeof() later */
55 static char *ECPGstruct_sizeof = NULL;
56 
57 /* for forward declarations we have to store some data as well */
58 static char *forward_name = NULL;
59 
60 struct ECPGtype ecpg_no_indicator = {ECPGt_NO_INDICATOR, NULL, NULL, NULL, {NULL}, 0};
61 struct variable no_indicator = {"no_indicator", &ecpg_no_indicator, 0, NULL};
62 
63 static struct ECPGtype ecpg_query = {ECPGt_char_variable, NULL, NULL, NULL, {NULL}, 0};
64 
65 static void vmmerror(int error_code, enum errortype type, const char *error, va_list ap) pg_attribute_printf(3, 0);
66 
67 /*
68  * Handle parsing errors and warnings
69  */
70 static void
vmmerror(int error_code,enum errortype type,const char * error,va_list ap)71 vmmerror(int error_code, enum errortype type, const char *error, va_list ap)
72 {
73 	/* localize the error message string */
74 	error = _(error);
75 
76 	fprintf(stderr, "%s:%d: ", input_filename, base_yylineno);
77 
78 	switch(type)
79 	{
80 		case ET_WARNING:
81 			fprintf(stderr, _("WARNING: "));
82 			break;
83 		case ET_ERROR:
84 			fprintf(stderr, _("ERROR: "));
85 			break;
86 	}
87 
88 	vfprintf(stderr, error, ap);
89 
90 	fprintf(stderr, "\n");
91 
92 	switch(type)
93 	{
94 		case ET_WARNING:
95 			break;
96 		case ET_ERROR:
97 			ret_value = error_code;
98 			break;
99 	}
100 }
101 
102 void
mmerror(int error_code,enum errortype type,const char * error,...)103 mmerror(int error_code, enum errortype type, const char *error, ...)
104 {
105 	va_list		ap;
106 
107 	va_start(ap, error);
108 	vmmerror(error_code, type, error, ap);
109 	va_end(ap);
110 }
111 
112 void
mmfatal(int error_code,const char * error,...)113 mmfatal(int error_code, const char *error, ...)
114 {
115 	va_list		ap;
116 
117 	va_start(ap, error);
118 	vmmerror(error_code, ET_ERROR, error, ap);
119 	va_end(ap);
120 
121 	if (base_yyin)
122 		fclose(base_yyin);
123 	if (base_yyout)
124 		fclose(base_yyout);
125 
126 	if (strcmp(output_filename, "-") != 0 && unlink(output_filename) != 0)
127 		fprintf(stderr, _("could not remove output file \"%s\"\n"), output_filename);
128 	exit(error_code);
129 }
130 
131 /*
132  * string concatenation
133  */
134 
135 static char *
cat2_str(char * str1,char * str2)136 cat2_str(char *str1, char *str2)
137 {
138 	char * res_str	= (char *)mm_alloc(strlen(str1) + strlen(str2) + 2);
139 
140 	strcpy(res_str, str1);
141 	if (strlen(str1) != 0 && strlen(str2) != 0)
142 		strcat(res_str, " ");
143 	strcat(res_str, str2);
144 	free(str1);
145 	free(str2);
146 	return res_str;
147 }
148 
149 static char *
cat_str(int count,...)150 cat_str(int count, ...)
151 {
152 	va_list		args;
153 	int			i;
154 	char		*res_str;
155 
156 	va_start(args, count);
157 
158 	res_str = va_arg(args, char *);
159 
160 	/* now add all other strings */
161 	for (i = 1; i < count; i++)
162 		res_str = cat2_str(res_str, va_arg(args, char *));
163 
164 	va_end(args);
165 
166 	return res_str;
167 }
168 
169 static char *
make2_str(char * str1,char * str2)170 make2_str(char *str1, char *str2)
171 {
172 	char * res_str	= (char *)mm_alloc(strlen(str1) + strlen(str2) + 1);
173 
174 	strcpy(res_str, str1);
175 	strcat(res_str, str2);
176 	free(str1);
177 	free(str2);
178 	return res_str;
179 }
180 
181 static char *
make3_str(char * str1,char * str2,char * str3)182 make3_str(char *str1, char *str2, char *str3)
183 {
184 	char * res_str	= (char *)mm_alloc(strlen(str1) + strlen(str2) +strlen(str3) + 1);
185 
186 	strcpy(res_str, str1);
187 	strcat(res_str, str2);
188 	strcat(res_str, str3);
189 	free(str1);
190 	free(str2);
191 	free(str3);
192 	return res_str;
193 }
194 
195 /* and the rest */
196 static char *
make_name(void)197 make_name(void)
198 {
199 	return mm_strdup(base_yytext);
200 }
201 
202 static char *
create_questionmarks(char * name,bool array)203 create_questionmarks(char *name, bool array)
204 {
205 	struct variable *p = find_variable(name);
206 	int count;
207 	char *result = EMPTY;
208 
209 	/* In case we have a struct, we have to print as many "?" as there are attributes in the struct
210 	 * An array is only allowed together with an element argument
211 	 * This is essentially only used for inserts, but using a struct as input parameter is an error anywhere else
212 	 * so we don't have to worry here. */
213 
214 	if (p->type->type == ECPGt_struct || (array && p->type->type == ECPGt_array && p->type->u.element->type == ECPGt_struct))
215 	{
216 		struct ECPGstruct_member *m;
217 
218 		if (p->type->type == ECPGt_struct)
219 			m = p->type->u.members;
220 		else
221 			m = p->type->u.element->u.members;
222 
223 		for (count = 0; m != NULL; m=m->next, count++);
224 	}
225 	else
226 		count = 1;
227 
228 	for (; count > 0; count --)
229 	{
230 		sprintf(pacounter_buffer, "$%d", pacounter++);
231 		result = cat_str(3, result, mm_strdup(pacounter_buffer), mm_strdup(" , "));
232 	}
233 
234 	/* removed the trailing " ," */
235 
236 	result[strlen(result)-3] = '\0';
237 	return result;
238 }
239 
240 static char *
adjust_outofscope_cursor_vars(struct cursor * cur)241 adjust_outofscope_cursor_vars(struct cursor *cur)
242 {
243 	/* Informix accepts DECLARE with variables that are out of scope when OPEN is called.
244 	 * For instance you can DECLARE a cursor in one function, and OPEN/FETCH/CLOSE
245 	 * it in another functions. This is very useful for e.g. event-driver programming,
246 	 * but may also lead to dangerous programming. The limitation when this is allowed
247 	 * and doesn't cause problems have to be documented, like the allocated variables
248 	 * must not be realloc()'ed.
249 	 *
250 	 * We have to change the variables to our own struct and just store the pointer
251 	 * instead of the variable. Do it only for local variables, not for globals.
252 	 */
253 
254 	char *result = EMPTY;
255 	int insert;
256 
257 	for (insert = 1; insert >= 0; insert--)
258 	{
259 		struct arguments *list;
260 		struct arguments *ptr;
261 		struct arguments *newlist = NULL;
262 		struct variable *newvar, *newind;
263 
264 		list = (insert ? cur->argsinsert : cur->argsresult);
265 
266 		for (ptr = list; ptr != NULL; ptr = ptr->next)
267 		{
268 			char var_text[20];
269 			char *original_var;
270 			bool skip_set_var = false;
271 			bool var_ptr = false;
272 
273 			/* change variable name to "ECPGget_var(<counter>)" */
274 			original_var = ptr->variable->name;
275 			sprintf(var_text, "%d))", ecpg_internal_var);
276 
277 			/* Don't emit ECPGset_var() calls for global variables */
278 			if (ptr->variable->brace_level == 0)
279 			{
280 				newvar = ptr->variable;
281 				skip_set_var = true;
282 			}
283 			else if ((ptr->variable->type->type == ECPGt_char_variable)
284 					 && (strncmp(ptr->variable->name, "ECPGprepared_statement", strlen("ECPGprepared_statement")) == 0))
285 			{
286 				newvar = ptr->variable;
287 				skip_set_var = true;
288 			}
289 			else if ((ptr->variable->type->type != ECPGt_varchar
290 					  && ptr->variable->type->type != ECPGt_char
291 					  && ptr->variable->type->type != ECPGt_unsigned_char
292 					  && ptr->variable->type->type != ECPGt_string)
293 					 && atoi(ptr->variable->type->size) > 1)
294 			{
295 				newvar = new_variable(cat_str(4, mm_strdup("("),
296 											  mm_strdup(ecpg_type_name(ptr->variable->type->u.element->type)),
297 											  mm_strdup(" *)(ECPGget_var("),
298 											  mm_strdup(var_text)),
299 									  ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type,
300 																			   mm_strdup("1"),
301 																			   ptr->variable->type->u.element->counter),
302 														  ptr->variable->type->size),
303 									  0);
304 			}
305 			else if ((ptr->variable->type->type == ECPGt_varchar
306 					  || ptr->variable->type->type == ECPGt_char
307 					  || ptr->variable->type->type == ECPGt_unsigned_char
308 					  || ptr->variable->type->type == ECPGt_string)
309 					 && atoi(ptr->variable->type->size) > 1)
310 			{
311 				newvar = new_variable(cat_str(4, mm_strdup("("),
312 											  mm_strdup(ecpg_type_name(ptr->variable->type->type)),
313 											  mm_strdup(" *)(ECPGget_var("),
314 											  mm_strdup(var_text)),
315 									  ECPGmake_simple_type(ptr->variable->type->type,
316 														   ptr->variable->type->size,
317 														   ptr->variable->type->counter),
318 									  0);
319 				if (ptr->variable->type->type == ECPGt_varchar)
320 					var_ptr = true;
321 			}
322 			else if (ptr->variable->type->type == ECPGt_struct
323 					 || ptr->variable->type->type == ECPGt_union)
324 			{
325 				newvar = new_variable(cat_str(5, mm_strdup("(*("),
326 											  mm_strdup(ptr->variable->type->type_name),
327 											  mm_strdup(" *)(ECPGget_var("),
328 											  mm_strdup(var_text),
329 											  mm_strdup(")")),
330 									  ECPGmake_struct_type(ptr->variable->type->u.members,
331 														   ptr->variable->type->type,
332 														   ptr->variable->type->type_name,
333 														   ptr->variable->type->struct_sizeof),
334 									  0);
335 				var_ptr = true;
336 			}
337 			else if (ptr->variable->type->type == ECPGt_array)
338 			{
339 				if (ptr->variable->type->u.element->type == ECPGt_struct
340 					|| ptr->variable->type->u.element->type == ECPGt_union)
341 				{
342 					newvar = new_variable(cat_str(5, mm_strdup("(*("),
343 											  mm_strdup(ptr->variable->type->u.element->type_name),
344 											  mm_strdup(" *)(ECPGget_var("),
345 											  mm_strdup(var_text),
346 											  mm_strdup(")")),
347 										  ECPGmake_struct_type(ptr->variable->type->u.element->u.members,
348 															   ptr->variable->type->u.element->type,
349 															   ptr->variable->type->u.element->type_name,
350 															   ptr->variable->type->u.element->struct_sizeof),
351 										  0);
352 				}
353 				else
354 				{
355 					newvar = new_variable(cat_str(4, mm_strdup("("),
356 												  mm_strdup(ecpg_type_name(ptr->variable->type->u.element->type)),
357 												  mm_strdup(" *)(ECPGget_var("),
358 												  mm_strdup(var_text)),
359 										  ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type,
360 																				   ptr->variable->type->u.element->size,
361 																				   ptr->variable->type->u.element->counter),
362 															  ptr->variable->type->size),
363 										  0);
364 					var_ptr = true;
365 				}
366 			}
367 			else
368 			{
369 				newvar = new_variable(cat_str(4, mm_strdup("*("),
370 											  mm_strdup(ecpg_type_name(ptr->variable->type->type)),
371 											  mm_strdup(" *)(ECPGget_var("),
372 											  mm_strdup(var_text)),
373 									  ECPGmake_simple_type(ptr->variable->type->type,
374 														   ptr->variable->type->size,
375 														   ptr->variable->type->counter),
376 									  0);
377 				var_ptr = true;
378 			}
379 
380 			/* create call to "ECPGset_var(<counter>, <connection>, <pointer>. <line number>)" */
381 			if (!skip_set_var)
382 			{
383 				sprintf(var_text, "%d, %s", ecpg_internal_var++, var_ptr ? "&(" : "(");
384 				result = cat_str(5, result, mm_strdup("ECPGset_var("),
385 								 mm_strdup(var_text), mm_strdup(original_var),
386 								 mm_strdup("), __LINE__);\n"));
387 			}
388 
389 			/* now the indicator if there is one and it's not a global variable */
390 			if ((ptr->indicator->type->type == ECPGt_NO_INDICATOR) || (ptr->indicator->brace_level == 0))
391 			{
392 				newind = ptr->indicator;
393 			}
394 			else
395 			{
396 				/* change variable name to "ECPGget_var(<counter>)" */
397 				original_var = ptr->indicator->name;
398 				sprintf(var_text, "%d))", ecpg_internal_var);
399 				var_ptr = false;
400 
401 				if (ptr->indicator->type->type == ECPGt_struct
402 					|| ptr->indicator->type->type == ECPGt_union)
403 				{
404 					newind = new_variable(cat_str(5, mm_strdup("(*("),
405 											  mm_strdup(ptr->indicator->type->type_name),
406 											  mm_strdup(" *)(ECPGget_var("),
407 											  mm_strdup(var_text),
408 											  mm_strdup(")")),
409 										  ECPGmake_struct_type(ptr->indicator->type->u.members,
410 															   ptr->indicator->type->type,
411 															   ptr->indicator->type->type_name,
412 															   ptr->indicator->type->struct_sizeof),
413 										  0);
414 					var_ptr = true;
415 				}
416 				else if (ptr->indicator->type->type == ECPGt_array)
417 				{
418 					if (ptr->indicator->type->u.element->type == ECPGt_struct
419 						|| ptr->indicator->type->u.element->type == ECPGt_union)
420 					{
421 						newind = new_variable(cat_str(5, mm_strdup("(*("),
422 											  mm_strdup(ptr->indicator->type->u.element->type_name),
423 											  mm_strdup(" *)(ECPGget_var("),
424 											  mm_strdup(var_text),
425 											  mm_strdup(")")),
426 											  ECPGmake_struct_type(ptr->indicator->type->u.element->u.members,
427 																   ptr->indicator->type->u.element->type,
428 																   ptr->indicator->type->u.element->type_name,
429 																   ptr->indicator->type->u.element->struct_sizeof),
430 											  0);
431 					}
432 					else
433 					{
434 						newind = new_variable(cat_str(4, mm_strdup("("),
435 													  mm_strdup(ecpg_type_name(ptr->indicator->type->u.element->type)),
436 													  mm_strdup(" *)(ECPGget_var("), mm_strdup(var_text)),
437 											  ECPGmake_array_type(ECPGmake_simple_type(ptr->indicator->type->u.element->type,
438 																					   ptr->indicator->type->u.element->size,
439 																					   ptr->indicator->type->u.element->counter),
440 																  ptr->indicator->type->size),
441 											  0);
442 						var_ptr = true;
443 					}
444 				}
445 				else if (atoi(ptr->indicator->type->size) > 1)
446 				{
447 					newind = new_variable(cat_str(4, mm_strdup("("),
448 												  mm_strdup(ecpg_type_name(ptr->indicator->type->type)),
449 												  mm_strdup(" *)(ECPGget_var("),
450 												  mm_strdup(var_text)),
451 										  ECPGmake_simple_type(ptr->indicator->type->type,
452 															   ptr->indicator->type->size,
453 															   ptr->variable->type->counter),
454 										  0);
455 				}
456 				else
457 				{
458 					newind = new_variable(cat_str(4, mm_strdup("*("),
459 												  mm_strdup(ecpg_type_name(ptr->indicator->type->type)),
460 												  mm_strdup(" *)(ECPGget_var("),
461 												  mm_strdup(var_text)),
462 										  ECPGmake_simple_type(ptr->indicator->type->type,
463 															   ptr->indicator->type->size,
464 															   ptr->variable->type->counter),
465 										  0);
466 					var_ptr = true;
467 				}
468 
469 				/* create call to "ECPGset_var(<counter>, <pointer>. <line number>)" */
470 				sprintf(var_text, "%d, %s", ecpg_internal_var++, var_ptr ? "&(" : "(");
471 				result = cat_str(5, result, mm_strdup("ECPGset_var("),
472 								 mm_strdup(var_text), mm_strdup(original_var),
473 								 mm_strdup("), __LINE__);\n"));
474 			}
475 
476 			add_variable_to_tail(&newlist, newvar, newind);
477 		}
478 
479 		if (insert)
480 			cur->argsinsert_oos = newlist;
481 		else
482 			cur->argsresult_oos = newlist;
483 	}
484 
485 	return result;
486 }
487 
488 /* This tests whether the cursor was declared and opened in the same function. */
489 #define SAMEFUNC(cur)	\
490 	((cur->function == NULL) ||		\
491 	 (cur->function != NULL && strcmp(cur->function, current_function) == 0))
492 
493 static struct cursor *
add_additional_variables(char * name,bool insert)494 add_additional_variables(char *name, bool insert)
495 {
496 	struct cursor *ptr;
497 	struct arguments *p;
498 	int (* strcmp_fn)(const char *, const char *) = ((name[0] == ':' || name[0] == '"') ? strcmp : pg_strcasecmp);
499 
500 	for (ptr = cur; ptr != NULL; ptr=ptr->next)
501 	{
502 		if (strcmp_fn(ptr->name, name) == 0)
503 			break;
504 	}
505 
506 	if (ptr == NULL)
507 	{
508 		mmerror(PARSE_ERROR, ET_ERROR, "cursor \"%s\" does not exist", name);
509 		return NULL;
510 	}
511 
512 	if (insert)
513 	{
514 		/* add all those input variables that were given earlier
515 		 * note that we have to append here but have to keep the existing order */
516 		for (p = (SAMEFUNC(ptr) ? ptr->argsinsert : ptr->argsinsert_oos); p; p = p->next)
517 			add_variable_to_tail(&argsinsert, p->variable, p->indicator);
518 	}
519 
520 	/* add all those output variables that were given earlier */
521 	for (p = (SAMEFUNC(ptr) ? ptr->argsresult : ptr->argsresult_oos); p; p = p->next)
522 		add_variable_to_tail(&argsresult, p->variable, p->indicator);
523 
524 	return ptr;
525 }
526 
527 static void
add_typedef(char * name,char * dimension,char * length,enum ECPGttype type_enum,char * type_dimension,char * type_index,int initializer,int array)528 add_typedef(char *name, char *dimension, char *length, enum ECPGttype type_enum,
529 			char *type_dimension, char *type_index, int initializer, int array)
530 {
531 	/* add entry to list */
532 	struct typedefs *ptr, *this;
533 
534 	if ((type_enum == ECPGt_struct ||
535 		 type_enum == ECPGt_union) &&
536 		initializer == 1)
537 		mmerror(PARSE_ERROR, ET_ERROR, "initializer not allowed in type definition");
538 	else if (INFORMIX_MODE && strcmp(name, "string") == 0)
539 		mmerror(PARSE_ERROR, ET_ERROR, "type name \"string\" is reserved in Informix mode");
540 	else
541 	{
542 		for (ptr = types; ptr != NULL; ptr = ptr->next)
543 		{
544 			if (strcmp(name, ptr->name) == 0)
545 				/* re-definition is a bug */
546 				mmerror(PARSE_ERROR, ET_ERROR, "type \"%s\" is already defined", name);
547 		}
548 		adjust_array(type_enum, &dimension, &length, type_dimension, type_index, array, true);
549 
550 		this = (struct typedefs *) mm_alloc(sizeof(struct typedefs));
551 
552 		/* initial definition */
553 		this->next = types;
554 		this->name = name;
555 		this->brace_level = braces_open;
556 		this->type = (struct this_type *) mm_alloc(sizeof(struct this_type));
557 		this->type->type_enum = type_enum;
558 		this->type->type_str = mm_strdup(name);
559 		this->type->type_dimension = dimension; /* dimension of array */
560 		this->type->type_index = length;	/* length of string */
561 		this->type->type_sizeof = ECPGstruct_sizeof;
562 		this->struct_member_list = (type_enum == ECPGt_struct || type_enum == ECPGt_union) ?
563 		ECPGstruct_member_dup(struct_member_list[struct_level]) : NULL;
564 
565 		if (type_enum != ECPGt_varchar &&
566 			type_enum != ECPGt_char &&
567 			type_enum != ECPGt_unsigned_char &&
568 			type_enum != ECPGt_string &&
569 			atoi(this->type->type_index) >= 0)
570 			mmerror(PARSE_ERROR, ET_ERROR, "multidimensional arrays for simple data types are not supported");
571 
572 		types = this;
573 	}
574 }
575 %}
576 
577 %expect 0
578 %name-prefix="base_yy"
579 %locations
580 
581 %union {
582 	double	dval;
583 	char	*str;
584 	int		ival;
585 	struct	when		action;
586 	struct	index		index;
587 	int		tagname;
588 	struct	this_type	type;
589 	enum	ECPGttype	type_enum;
590 	enum	ECPGdtype	dtype_enum;
591 	struct	fetch_desc	descriptor;
592 	struct  su_symbol	struct_union;
593 	struct	prep		prep;
594 }
595 /* tokens */
596 /* src/interfaces/ecpg/preproc/ecpg.tokens */
597 
598 /* special embedded SQL tokens */
599 %token  SQL_ALLOCATE SQL_AUTOCOMMIT SQL_BOOL SQL_BREAK
600                 SQL_CARDINALITY SQL_CONNECT
601                 SQL_COUNT
602                 SQL_DATETIME_INTERVAL_CODE
603                 SQL_DATETIME_INTERVAL_PRECISION SQL_DESCRIBE
604                 SQL_DESCRIPTOR SQL_DISCONNECT SQL_FOUND
605                 SQL_FREE SQL_GET SQL_GO SQL_GOTO SQL_IDENTIFIED
606                 SQL_INDICATOR SQL_KEY_MEMBER SQL_LENGTH
607                 SQL_LONG SQL_NULLABLE SQL_OCTET_LENGTH
608                 SQL_OPEN SQL_OUTPUT SQL_REFERENCE
609                 SQL_RETURNED_LENGTH SQL_RETURNED_OCTET_LENGTH SQL_SCALE
610                 SQL_SECTION SQL_SHORT SQL_SIGNED SQL_SQLERROR
611                 SQL_SQLPRINT SQL_SQLWARNING SQL_START SQL_STOP
612                 SQL_STRUCT SQL_UNSIGNED SQL_VAR SQL_WHENEVER
613 
614 /* C tokens */
615 %token  S_ADD S_AND S_ANYTHING S_AUTO S_CONST S_DEC S_DIV
616                 S_DOTPOINT S_EQUAL S_EXTERN S_INC S_LSHIFT S_MEMPOINT
617                 S_MEMBER S_MOD S_MUL S_NEQUAL S_OR S_REGISTER S_RSHIFT
618                 S_STATIC S_SUB S_VOLATILE
619                 S_TYPEDEF
620 
621 %token CSTRING CVARIABLE CPP_LINE IP
622 %token DOLCONST ECONST NCONST UCONST UIDENT
623 /* types */
624 %type <str> stmt
625 %type <str> CallStmt
626 %type <str> CreateRoleStmt
627 %type <str> opt_with
628 %type <str> OptRoleList
629 %type <str> AlterOptRoleList
630 %type <str> AlterOptRoleElem
631 %type <str> CreateOptRoleElem
632 %type <str> CreateUserStmt
633 %type <str> AlterRoleStmt
634 %type <str> opt_in_database
635 %type <str> AlterRoleSetStmt
636 %type <str> DropRoleStmt
637 %type <str> CreateGroupStmt
638 %type <str> AlterGroupStmt
639 %type <str> add_drop
640 %type <str> CreateSchemaStmt
641 %type <str> OptSchemaName
642 %type <str> OptSchemaEltList
643 %type <str> schema_stmt
644 %type <str> VariableSetStmt
645 %type <str> set_rest
646 %type <str> generic_set
647 %type <str> set_rest_more
648 %type <str> var_name
649 %type <str> var_list
650 %type <str> var_value
651 %type <str> iso_level
652 %type <str> opt_boolean_or_string
653 %type <str> zone_value
654 %type <str> opt_encoding
655 %type <str> NonReservedWord_or_Sconst
656 %type <str> VariableResetStmt
657 %type <str> reset_rest
658 %type <str> generic_reset
659 %type <str> SetResetClause
660 %type <str> FunctionSetResetClause
661 %type <str> VariableShowStmt
662 %type <str> ConstraintsSetStmt
663 %type <str> constraints_set_list
664 %type <str> constraints_set_mode
665 %type <str> CheckPointStmt
666 %type <str> DiscardStmt
667 %type <str> AlterTableStmt
668 %type <str> alter_table_cmds
669 %type <str> partition_cmd
670 %type <str> index_partition_cmd
671 %type <str> alter_table_cmd
672 %type <str> alter_column_default
673 %type <str> opt_drop_behavior
674 %type <str> opt_collate_clause
675 %type <str> alter_using
676 %type <str> replica_identity
677 %type <str> reloptions
678 %type <str> opt_reloptions
679 %type <str> reloption_list
680 %type <str> reloption_elem
681 %type <str> alter_identity_column_option_list
682 %type <str> alter_identity_column_option
683 %type <str> PartitionBoundSpec
684 %type <str> hash_partbound_elem
685 %type <str> hash_partbound
686 %type <str> partbound_datum
687 %type <str> partbound_datum_list
688 %type <str> range_datum_list
689 %type <str> PartitionRangeDatum
690 %type <str> AlterCompositeTypeStmt
691 %type <str> alter_type_cmds
692 %type <str> alter_type_cmd
693 %type <str> ClosePortalStmt
694 %type <str> CopyStmt
695 %type <str> copy_from
696 %type <str> opt_program
697 %type <str> copy_file_name
698 %type <str> copy_options
699 %type <str> copy_opt_list
700 %type <str> copy_opt_item
701 %type <str> opt_binary
702 %type <str> opt_oids
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_strategy
747 %type <str> part_params
748 %type <str> part_elem
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> create_as_target
756 %type <str> opt_with_data
757 %type <str> CreateMatViewStmt
758 %type <str> create_mv_target
759 %type <str> OptNoLog
760 %type <str> RefreshMatViewStmt
761 %type <str> CreateSeqStmt
762 %type <str> AlterSeqStmt
763 %type <str> OptSeqOptList
764 %type <str> OptParenthesizedSeqOptList
765 %type <str> SeqOptList
766 %type <str> SeqOptElem
767 %type <str> opt_by
768 %type <str> NumericOnly
769 %type <str> NumericOnly_list
770 %type <str> CreatePLangStmt
771 %type <str> opt_trusted
772 %type <str> handler_name
773 %type <str> opt_inline_handler
774 %type <str> validator_clause
775 %type <str> opt_validator
776 %type <str> DropPLangStmt
777 %type <str> opt_procedural
778 %type <str> CreateTableSpaceStmt
779 %type <str> OptTableSpaceOwner
780 %type <str> DropTableSpaceStmt
781 %type <str> CreateExtensionStmt
782 %type <str> create_extension_opt_list
783 %type <str> create_extension_opt_item
784 %type <str> AlterExtensionStmt
785 %type <str> alter_extension_opt_list
786 %type <str> alter_extension_opt_item
787 %type <str> AlterExtensionContentsStmt
788 %type <str> CreateFdwStmt
789 %type <str> fdw_option
790 %type <str> fdw_options
791 %type <str> opt_fdw_options
792 %type <str> AlterFdwStmt
793 %type <str> create_generic_options
794 %type <str> generic_option_list
795 %type <str> alter_generic_options
796 %type <str> alter_generic_option_list
797 %type <str> alter_generic_option_elem
798 %type <str> generic_option_elem
799 %type <str> generic_option_name
800 %type <str> generic_option_arg
801 %type <str> CreateForeignServerStmt
802 %type <str> opt_type
803 %type <str> foreign_server_version
804 %type <str> opt_foreign_server_version
805 %type <str> AlterForeignServerStmt
806 %type <str> CreateForeignTableStmt
807 %type <str> AlterForeignTableStmt
808 %type <str> ImportForeignSchemaStmt
809 %type <str> import_qualification_type
810 %type <str> import_qualification
811 %type <str> CreateUserMappingStmt
812 %type <str> auth_ident
813 %type <str> DropUserMappingStmt
814 %type <str> AlterUserMappingStmt
815 %type <str> CreatePolicyStmt
816 %type <str> AlterPolicyStmt
817 %type <str> RowSecurityOptionalExpr
818 %type <str> RowSecurityOptionalWithCheck
819 %type <str> RowSecurityDefaultToRole
820 %type <str> RowSecurityOptionalToRole
821 %type <str> RowSecurityDefaultPermissive
822 %type <str> RowSecurityDefaultForCmd
823 %type <str> row_security_cmd
824 %type <str> CreateAmStmt
825 %type <str> CreateTrigStmt
826 %type <str> TriggerActionTime
827 %type <str> TriggerEvents
828 %type <str> TriggerOneEvent
829 %type <str> TriggerReferencing
830 %type <str> TriggerTransitions
831 %type <str> TriggerTransition
832 %type <str> TransitionOldOrNew
833 %type <str> TransitionRowOrTable
834 %type <str> TransitionRelName
835 %type <str> TriggerForSpec
836 %type <str> TriggerForOptEach
837 %type <str> TriggerForType
838 %type <str> TriggerWhen
839 %type <str> FUNCTION_or_PROCEDURE
840 %type <str> TriggerFuncArgs
841 %type <str> TriggerFuncArg
842 %type <str> OptConstrFromTable
843 %type <str> ConstraintAttributeSpec
844 %type <str> ConstraintAttributeElem
845 %type <str> CreateEventTrigStmt
846 %type <str> event_trigger_when_list
847 %type <str> event_trigger_when_item
848 %type <str> event_trigger_value_list
849 %type <str> AlterEventTrigStmt
850 %type <str> enable_trigger
851 %type <str> CreateAssertStmt
852 %type <str> DropAssertStmt
853 %type <str> DefineStmt
854 %type <str> definition
855 %type <str> def_list
856 %type <str> def_elem
857 %type <str> def_arg
858 %type <str> old_aggr_definition
859 %type <str> old_aggr_list
860 %type <str> old_aggr_elem
861 %type <str> opt_enum_val_list
862 %type <str> enum_val_list
863 %type <str> AlterEnumStmt
864 %type <str> opt_if_not_exists
865 %type <str> CreateOpClassStmt
866 %type <str> opclass_item_list
867 %type <str> opclass_item
868 %type <str> opt_default
869 %type <str> opt_opfamily
870 %type <str> opclass_purpose
871 %type <str> opt_recheck
872 %type <str> CreateOpFamilyStmt
873 %type <str> AlterOpFamilyStmt
874 %type <str> opclass_drop_list
875 %type <str> opclass_drop
876 %type <str> DropOpClassStmt
877 %type <str> DropOpFamilyStmt
878 %type <str> DropOwnedStmt
879 %type <str> ReassignOwnedStmt
880 %type <str> DropStmt
881 %type <str> drop_type_any_name
882 %type <str> drop_type_name
883 %type <str> drop_type_name_on_any_name
884 %type <str> any_name_list
885 %type <str> any_name
886 %type <str> attrs
887 %type <str> type_name_list
888 %type <str> TruncateStmt
889 %type <str> opt_restart_seqs
890 %type <str> CommentStmt
891 %type <str> comment_type_any_name
892 %type <str> comment_type_name
893 %type <str> comment_text
894 %type <str> SecLabelStmt
895 %type <str> opt_provider
896 %type <str> security_label_type_any_name
897 %type <str> security_label_type_name
898 %type <str> security_label
899 %type <str> FetchStmt
900 %type <str> fetch_args
901 %type <str> from_in
902 %type <str> opt_from_in
903 %type <str> GrantStmt
904 %type <str> RevokeStmt
905 %type <str> privileges
906 %type <str> privilege_list
907 %type <str> privilege
908 %type <str> privilege_target
909 %type <str> grantee_list
910 %type <str> grantee
911 %type <str> opt_grant_grant_option
912 %type <str> GrantRoleStmt
913 %type <str> RevokeRoleStmt
914 %type <str> opt_grant_admin_option
915 %type <str> opt_granted_by
916 %type <str> AlterDefaultPrivilegesStmt
917 %type <str> DefACLOptionList
918 %type <str> DefACLOption
919 %type <str> DefACLAction
920 %type <str> defacl_privilege_target
921 %type <str> IndexStmt
922 %type <str> opt_unique
923 %type <str> opt_concurrently
924 %type <str> opt_index_name
925 %type <str> access_method_clause
926 %type <str> index_params
927 %type <str> index_elem
928 %type <str> opt_include
929 %type <str> index_including_params
930 %type <str> opt_collate
931 %type <str> opt_class
932 %type <str> opt_asc_desc
933 %type <str> opt_nulls_order
934 %type <str> CreateFunctionStmt
935 %type <str> opt_or_replace
936 %type <str> func_args
937 %type <str> func_args_list
938 %type <str> function_with_argtypes_list
939 %type <str> function_with_argtypes
940 %type <str> func_args_with_defaults
941 %type <str> func_args_with_defaults_list
942 %type <str> func_arg
943 %type <str> arg_class
944 %type <str> param_name
945 %type <str> func_return
946 %type <str> func_type
947 %type <str> func_arg_with_default
948 %type <str> aggr_arg
949 %type <str> aggr_args
950 %type <str> aggr_args_list
951 %type <str> aggregate_with_argtypes
952 %type <str> aggregate_with_argtypes_list
953 %type <str> createfunc_opt_list
954 %type <str> common_func_opt_item
955 %type <str> createfunc_opt_item
956 %type <str> func_as
957 %type <str> transform_type_list
958 %type <str> opt_definition
959 %type <str> table_func_column
960 %type <str> table_func_column_list
961 %type <str> AlterFunctionStmt
962 %type <str> alterfunc_opt_list
963 %type <str> opt_restrict
964 %type <str> RemoveFuncStmt
965 %type <str> RemoveAggrStmt
966 %type <str> RemoveOperStmt
967 %type <str> oper_argtypes
968 %type <str> any_operator
969 %type <str> operator_with_argtypes_list
970 %type <str> operator_with_argtypes
971 %type <str> DoStmt
972 %type <str> dostmt_opt_list
973 %type <str> dostmt_opt_item
974 %type <str> CreateCastStmt
975 %type <str> cast_context
976 %type <str> DropCastStmt
977 %type <str> opt_if_exists
978 %type <str> CreateTransformStmt
979 %type <str> transform_element_list
980 %type <str> DropTransformStmt
981 %type <str> ReindexStmt
982 %type <str> reindex_target_type
983 %type <str> reindex_target_multitable
984 %type <str> reindex_option_list
985 %type <str> reindex_option_elem
986 %type <str> AlterTblSpcStmt
987 %type <str> RenameStmt
988 %type <str> opt_column
989 %type <str> opt_set_data
990 %type <str> AlterObjectDependsStmt
991 %type <str> AlterObjectSchemaStmt
992 %type <str> AlterOperatorStmt
993 %type <str> operator_def_list
994 %type <str> operator_def_elem
995 %type <str> operator_def_arg
996 %type <str> AlterOwnerStmt
997 %type <str> CreatePublicationStmt
998 %type <str> opt_publication_for_tables
999 %type <str> publication_for_tables
1000 %type <str> AlterPublicationStmt
1001 %type <str> CreateSubscriptionStmt
1002 %type <str> publication_name_list
1003 %type <str> publication_name_item
1004 %type <str> AlterSubscriptionStmt
1005 %type <str> DropSubscriptionStmt
1006 %type <str> RuleStmt
1007 %type <str> RuleActionList
1008 %type <str> RuleActionMulti
1009 %type <str> RuleActionStmt
1010 %type <str> RuleActionStmtOrEmpty
1011 %type <str> event
1012 %type <str> opt_instead
1013 %type <str> NotifyStmt
1014 %type <str> notify_payload
1015 %type <str> ListenStmt
1016 %type <str> UnlistenStmt
1017 %type <str> TransactionStmt
1018 %type <str> opt_transaction
1019 %type <str> transaction_mode_item
1020 %type <str> transaction_mode_list
1021 %type <str> transaction_mode_list_or_empty
1022 %type <str> ViewStmt
1023 %type <str> opt_check_option
1024 %type <str> LoadStmt
1025 %type <str> CreatedbStmt
1026 %type <str> createdb_opt_list
1027 %type <str> createdb_opt_items
1028 %type <str> createdb_opt_item
1029 %type <str> createdb_opt_name
1030 %type <str> opt_equal
1031 %type <str> AlterDatabaseStmt
1032 %type <str> AlterDatabaseSetStmt
1033 %type <str> DropdbStmt
1034 %type <str> AlterCollationStmt
1035 %type <str> AlterSystemStmt
1036 %type <str> CreateDomainStmt
1037 %type <str> AlterDomainStmt
1038 %type <str> opt_as
1039 %type <str> AlterTSDictionaryStmt
1040 %type <str> AlterTSConfigurationStmt
1041 %type <str> any_with
1042 %type <str> CreateConversionStmt
1043 %type <str> ClusterStmt
1044 %type <str> cluster_index_specification
1045 %type <str> VacuumStmt
1046 %type <str> vacuum_option_list
1047 %type <str> vacuum_option_elem
1048 %type <str> AnalyzeStmt
1049 %type <str> analyze_option_list
1050 %type <str> analyze_option_elem
1051 %type <str> analyze_keyword
1052 %type <str> opt_analyze
1053 %type <str> opt_verbose
1054 %type <str> opt_full
1055 %type <str> opt_freeze
1056 %type <str> opt_name_list
1057 %type <str> vacuum_relation
1058 %type <str> vacuum_relation_list
1059 %type <str> opt_vacuum_relation_list
1060 %type <str> ExplainStmt
1061 %type <str> ExplainableStmt
1062 %type <str> explain_option_list
1063 %type <str> explain_option_elem
1064 %type <str> explain_option_name
1065 %type <str> explain_option_arg
1066 %type <prep> PrepareStmt
1067 %type <str> prep_type_clause
1068 %type <str> PreparableStmt
1069 %type <str> ExecuteStmt
1070 %type <str> execute_param_clause
1071 %type <str> InsertStmt
1072 %type <str> insert_target
1073 %type <str> insert_rest
1074 %type <str> override_kind
1075 %type <str> insert_column_list
1076 %type <str> insert_column_item
1077 %type <str> opt_on_conflict
1078 %type <str> opt_conf_expr
1079 %type <str> returning_clause
1080 %type <str> DeleteStmt
1081 %type <str> using_clause
1082 %type <str> LockStmt
1083 %type <str> opt_lock
1084 %type <str> lock_type
1085 %type <str> opt_nowait
1086 %type <str> opt_nowait_or_skip
1087 %type <str> UpdateStmt
1088 %type <str> set_clause_list
1089 %type <str> set_clause
1090 %type <str> set_target
1091 %type <str> set_target_list
1092 %type <str> DeclareCursorStmt
1093 %type <str> cursor_name
1094 %type <str> cursor_options
1095 %type <str> opt_hold
1096 %type <str> SelectStmt
1097 %type <str> select_with_parens
1098 %type <str> select_no_parens
1099 %type <str> select_clause
1100 %type <str> simple_select
1101 %type <str> with_clause
1102 %type <str> cte_list
1103 %type <str> common_table_expr
1104 %type <str> opt_with_clause
1105 %type <str> into_clause
1106 %type <str> OptTempTableName
1107 %type <str> opt_table
1108 %type <str> all_or_distinct
1109 %type <str> distinct_clause
1110 %type <str> opt_all_clause
1111 %type <str> opt_sort_clause
1112 %type <str> sort_clause
1113 %type <str> sortby_list
1114 %type <str> sortby
1115 %type <str> select_limit
1116 %type <str> opt_select_limit
1117 %type <str> limit_clause
1118 %type <str> offset_clause
1119 %type <str> select_limit_value
1120 %type <str> select_offset_value
1121 %type <str> select_fetch_first_value
1122 %type <str> I_or_F_const
1123 %type <str> row_or_rows
1124 %type <str> first_or_next
1125 %type <str> group_clause
1126 %type <str> group_by_list
1127 %type <str> group_by_item
1128 %type <str> empty_grouping_set
1129 %type <str> rollup_clause
1130 %type <str> cube_clause
1131 %type <str> grouping_sets_clause
1132 %type <str> having_clause
1133 %type <str> for_locking_clause
1134 %type <str> opt_for_locking_clause
1135 %type <str> for_locking_items
1136 %type <str> for_locking_item
1137 %type <str> for_locking_strength
1138 %type <str> locked_rels_list
1139 %type <str> values_clause
1140 %type <str> from_clause
1141 %type <str> from_list
1142 %type <str> table_ref
1143 %type <str> joined_table
1144 %type <str> alias_clause
1145 %type <str> opt_alias_clause
1146 %type <str> func_alias_clause
1147 %type <str> join_type
1148 %type <str> join_outer
1149 %type <str> join_qual
1150 %type <str> relation_expr
1151 %type <str> relation_expr_list
1152 %type <str> relation_expr_opt_alias
1153 %type <str> tablesample_clause
1154 %type <str> opt_repeatable_clause
1155 %type <str> func_table
1156 %type <str> rowsfrom_item
1157 %type <str> rowsfrom_list
1158 %type <str> opt_col_def_list
1159 %type <str> opt_ordinality
1160 %type <str> where_clause
1161 %type <str> where_or_current_clause
1162 %type <str> OptTableFuncElementList
1163 %type <str> TableFuncElementList
1164 %type <str> TableFuncElement
1165 %type <str> xmltable
1166 %type <str> xmltable_column_list
1167 %type <str> xmltable_column_el
1168 %type <str> xmltable_column_option_list
1169 %type <str> xmltable_column_option_el
1170 %type <str> xml_namespace_list
1171 %type <str> xml_namespace_el
1172 %type <str> Typename
1173 %type <index> opt_array_bounds
1174 %type <str> SimpleTypename
1175 %type <str> ConstTypename
1176 %type <str> GenericType
1177 %type <str> opt_type_modifiers
1178 %type <str> Numeric
1179 %type <str> opt_float
1180 %type <str> Bit
1181 %type <str> ConstBit
1182 %type <str> BitWithLength
1183 %type <str> BitWithoutLength
1184 %type <str> Character
1185 %type <str> ConstCharacter
1186 %type <str> CharacterWithLength
1187 %type <str> CharacterWithoutLength
1188 %type <str> character
1189 %type <str> opt_varying
1190 %type <str> ConstDatetime
1191 %type <str> ConstInterval
1192 %type <str> opt_timezone
1193 %type <str> opt_interval
1194 %type <str> interval_second
1195 %type <str> a_expr
1196 %type <str> b_expr
1197 %type <str> c_expr
1198 %type <str> func_application
1199 %type <str> func_expr
1200 %type <str> func_expr_windowless
1201 %type <str> func_expr_common_subexpr
1202 %type <str> xml_root_version
1203 %type <str> opt_xml_root_standalone
1204 %type <str> xml_attributes
1205 %type <str> xml_attribute_list
1206 %type <str> xml_attribute_el
1207 %type <str> document_or_content
1208 %type <str> xml_whitespace_option
1209 %type <str> xmlexists_argument
1210 %type <str> within_group_clause
1211 %type <str> filter_clause
1212 %type <str> window_clause
1213 %type <str> window_definition_list
1214 %type <str> window_definition
1215 %type <str> over_clause
1216 %type <str> window_specification
1217 %type <str> opt_existing_window_name
1218 %type <str> opt_partition_clause
1219 %type <str> opt_frame_clause
1220 %type <str> frame_extent
1221 %type <str> frame_bound
1222 %type <str> opt_window_exclusion_clause
1223 %type <str> row
1224 %type <str> explicit_row
1225 %type <str> implicit_row
1226 %type <str> sub_type
1227 %type <str> all_Op
1228 %type <str> MathOp
1229 %type <str> qual_Op
1230 %type <str> qual_all_Op
1231 %type <str> subquery_Op
1232 %type <str> expr_list
1233 %type <str> func_arg_list
1234 %type <str> func_arg_expr
1235 %type <str> type_list
1236 %type <str> array_expr
1237 %type <str> array_expr_list
1238 %type <str> extract_list
1239 %type <str> extract_arg
1240 %type <str> overlay_list
1241 %type <str> overlay_placing
1242 %type <str> position_list
1243 %type <str> substr_list
1244 %type <str> substr_from
1245 %type <str> substr_for
1246 %type <str> trim_list
1247 %type <str> in_expr
1248 %type <str> case_expr
1249 %type <str> when_clause_list
1250 %type <str> when_clause
1251 %type <str> case_default
1252 %type <str> case_arg
1253 %type <str> columnref
1254 %type <str> indirection_el
1255 %type <str> opt_slice_bound
1256 %type <str> indirection
1257 %type <str> opt_indirection
1258 %type <str> opt_asymmetric
1259 %type <str> opt_target_list
1260 %type <str> target_list
1261 %type <str> target_el
1262 %type <str> qualified_name_list
1263 %type <str> qualified_name
1264 %type <str> name_list
1265 %type <str> name
1266 %type <str> database_name
1267 %type <str> access_method
1268 %type <str> attr_name
1269 %type <str> index_name
1270 %type <str> file_name
1271 %type <str> func_name
1272 %type <str> AexprConst
1273 %type <str> Iconst
1274 %type <str> SignedIconst
1275 %type <str> RoleId
1276 %type <str> RoleSpec
1277 %type <str> role_list
1278 %type <str> NonReservedWord
1279 %type <str> unreserved_keyword
1280 %type <str> col_name_keyword
1281 %type <str> type_func_name_keyword
1282 %type <str> reserved_keyword
1283 /* ecpgtype */
1284 /* src/interfaces/ecpg/preproc/ecpg.type */
1285 %type <str> ECPGAllocateDescr
1286 %type <str> ECPGCKeywords
1287 %type <str> ECPGColId
1288 %type <str> ECPGColLabel
1289 %type <str> ECPGColLabelCommon
1290 %type <str> ECPGConnect
1291 %type <str> ECPGCursorStmt
1292 %type <str> ECPGDeallocateDescr
1293 %type <str> ECPGDeclaration
1294 %type <str> ECPGDeclare
1295 %type <str> ECPGDescribe
1296 %type <str> ECPGDisconnect
1297 %type <str> ECPGExecuteImmediateStmt
1298 %type <str> ECPGFree
1299 %type <str> ECPGGetDescHeaderItem
1300 %type <str> ECPGGetDescItem
1301 %type <str> ECPGGetDescriptorHeader
1302 %type <str> ECPGKeywords
1303 %type <str> ECPGKeywords_rest
1304 %type <str> ECPGKeywords_vanames
1305 %type <str> ECPGOpen
1306 %type <str> ECPGSetAutocommit
1307 %type <str> ECPGSetConnection
1308 %type <str> ECPGSetDescHeaderItem
1309 %type <str> ECPGSetDescItem
1310 %type <str> ECPGSetDescriptorHeader
1311 %type <str> ECPGTypeName
1312 %type <str> ECPGTypedef
1313 %type <str> ECPGVar
1314 %type <str> ECPGVarDeclaration
1315 %type <str> ECPGWhenever
1316 %type <str> ECPGunreserved_interval
1317 %type <str> UsingConst
1318 %type <str> UsingValue
1319 %type <str> all_unreserved_keyword
1320 %type <str> c_anything
1321 %type <str> c_args
1322 %type <str> c_list
1323 %type <str> c_stuff
1324 %type <str> c_stuff_item
1325 %type <str> c_term
1326 %type <str> c_thing
1327 %type <str> char_variable
1328 %type <str> char_civar
1329 %type <str> civar
1330 %type <str> civarind
1331 %type <str> ColId
1332 %type <str> ColLabel
1333 %type <str> connect_options
1334 %type <str> connection_object
1335 %type <str> connection_target
1336 %type <str> coutputvariable
1337 %type <str> cvariable
1338 %type <str> db_prefix
1339 %type <str> CreateAsStmt
1340 %type <str> DeallocateStmt
1341 %type <str> dis_name
1342 %type <str> ecpg_bconst
1343 %type <str> ecpg_fconst
1344 %type <str> ecpg_ident
1345 %type <str> ecpg_interval
1346 %type <str> ecpg_into
1347 %type <str> ecpg_fetch_into
1348 %type <str> ecpg_param
1349 %type <str> ecpg_sconst
1350 %type <str> ecpg_using
1351 %type <str> ecpg_xconst
1352 %type <str> enum_definition
1353 %type <str> enum_type
1354 %type <str> execstring
1355 %type <str> execute_rest
1356 %type <str> indicator
1357 %type <str> into_descriptor
1358 %type <str> into_sqlda
1359 %type <str> Iresult
1360 %type <str> on_off
1361 %type <str> opt_bit_field
1362 %type <str> opt_connection_name
1363 %type <str> opt_database_name
1364 %type <str> opt_ecpg_into
1365 %type <str> opt_ecpg_fetch_into
1366 %type <str> opt_ecpg_using
1367 %type <str> opt_initializer
1368 %type <str> opt_options
1369 %type <str> opt_output
1370 %type <str> opt_pointer
1371 %type <str> opt_port
1372 %type <str> opt_reference
1373 %type <str> opt_scale
1374 %type <str> opt_server
1375 %type <str> opt_user
1376 %type <str> opt_opt_value
1377 %type <str> ora_user
1378 %type <str> precision
1379 %type <str> prepared_name
1380 %type <str> quoted_ident_stringvar
1381 %type <str> s_struct_union
1382 %type <str> server
1383 %type <str> server_name
1384 %type <str> single_vt_declaration
1385 %type <str> storage_clause
1386 %type <str> storage_declaration
1387 %type <str> storage_modifier
1388 %type <str> struct_union_type
1389 %type <str> struct_union_type_with_symbol
1390 %type <str> symbol
1391 %type <str> type_declaration
1392 %type <str> type_function_name
1393 %type <str> user_name
1394 %type <str> using_descriptor
1395 %type <str> var_declaration
1396 %type <str> var_type_declarations
1397 %type <str> variable
1398 %type <str> variable_declarations
1399 %type <str> variable_list
1400 %type <str> vt_declarations
1401 
1402 %type <str> Op
1403 %type <str> IntConstVar
1404 %type <str> AllConstVar
1405 %type <str> CSTRING
1406 %type <str> CPP_LINE
1407 %type <str> CVARIABLE
1408 %type <str> DOLCONST
1409 %type <str> ECONST
1410 %type <str> NCONST
1411 %type <str> SCONST
1412 %type <str> UCONST
1413 %type <str> UIDENT
1414 
1415 %type  <struct_union> s_struct_union_symbol
1416 
1417 %type  <descriptor> ECPGGetDescriptor
1418 %type  <descriptor> ECPGSetDescriptor
1419 
1420 %type  <type_enum> simple_type
1421 %type  <type_enum> signed_type
1422 %type  <type_enum> unsigned_type
1423 
1424 %type  <dtype_enum> descriptor_item
1425 %type  <dtype_enum> desc_header_item
1426 
1427 %type  <type>   var_type
1428 
1429 %type  <action> action
1430 /* orig_tokens */
1431  %token IDENT FCONST SCONST BCONST XCONST Op
1432  %token ICONST PARAM
1433  %token TYPECAST DOT_DOT COLON_EQUALS EQUALS_GREATER
1434  %token LESS_EQUALS GREATER_EQUALS NOT_EQUALS
1435 
1436 
1437 
1438 
1439 
1440 
1441 
1442 
1443 
1444  %token ABORT_P ABSOLUTE_P ACCESS ACTION ADD_P ADMIN AFTER
1445  AGGREGATE ALL ALSO ALTER ALWAYS ANALYSE ANALYZE AND ANY ARRAY AS ASC
1446  ASSERTION ASSIGNMENT ASYMMETRIC AT ATTACH ATTRIBUTE AUTHORIZATION
1447 
1448  BACKWARD BEFORE BEGIN_P BETWEEN BIGINT BINARY BIT
1449  BOOLEAN_P BOTH BY
1450 
1451  CACHE CALL CALLED CASCADE CASCADED CASE CAST CATALOG_P CHAIN CHAR_P
1452  CHARACTER CHARACTERISTICS CHECK CHECKPOINT CLASS CLOSE
1453  CLUSTER COALESCE COLLATE COLLATION COLUMN COLUMNS COMMENT COMMENTS COMMIT
1454  COMMITTED CONCURRENTLY CONFIGURATION CONFLICT CONNECTION CONSTRAINT
1455  CONSTRAINTS CONTENT_P CONTINUE_P CONVERSION_P COPY COST CREATE
1456  CROSS CSV CUBE CURRENT_P
1457  CURRENT_CATALOG CURRENT_DATE CURRENT_ROLE CURRENT_SCHEMA
1458  CURRENT_TIME CURRENT_TIMESTAMP CURRENT_USER CURSOR CYCLE
1459 
1460  DATA_P DATABASE DAY_P DEALLOCATE DEC DECIMAL_P DECLARE DEFAULT DEFAULTS
1461  DEFERRABLE DEFERRED DEFINER DELETE_P DELIMITER DELIMITERS DEPENDS DESC
1462  DETACH DICTIONARY DISABLE_P DISCARD DISTINCT DO DOCUMENT_P DOMAIN_P
1463  DOUBLE_P DROP
1464 
1465  EACH ELSE ENABLE_P ENCODING ENCRYPTED END_P ENUM_P ESCAPE EVENT EXCEPT
1466  EXCLUDE EXCLUDING EXCLUSIVE EXECUTE EXISTS EXPLAIN
1467  EXTENSION EXTERNAL EXTRACT
1468 
1469  FALSE_P FAMILY FETCH FILTER FIRST_P FLOAT_P FOLLOWING FOR
1470  FORCE FOREIGN FORWARD FREEZE FROM FULL FUNCTION FUNCTIONS
1471 
1472  GENERATED GLOBAL GRANT GRANTED GREATEST GROUP_P GROUPING GROUPS
1473 
1474  HANDLER HAVING HEADER_P HOLD HOUR_P
1475 
1476  IDENTITY_P IF_P ILIKE IMMEDIATE IMMUTABLE IMPLICIT_P IMPORT_P IN_P INCLUDE
1477  INCLUDING INCREMENT INDEX INDEXES INHERIT INHERITS INITIALLY INLINE_P
1478  INNER_P INOUT INPUT_P INSENSITIVE INSERT INSTEAD INT_P INTEGER
1479  INTERSECT INTERVAL INTO INVOKER IS ISNULL ISOLATION
1480 
1481  JOIN
1482 
1483  KEY
1484 
1485  LABEL LANGUAGE LARGE_P LAST_P LATERAL_P
1486  LEADING LEAKPROOF LEAST LEFT LEVEL LIKE LIMIT LISTEN LOAD LOCAL
1487  LOCALTIME LOCALTIMESTAMP LOCATION LOCK_P LOCKED LOGGED
1488 
1489  MAPPING MATCH MATERIALIZED MAXVALUE METHOD MINUTE_P MINVALUE MODE MONTH_P MOVE
1490 
1491  NAME_P NAMES NATIONAL NATURAL NCHAR NEW NEXT NO NONE
1492  NOT NOTHING NOTIFY NOTNULL NOWAIT NULL_P NULLIF
1493  NULLS_P NUMERIC
1494 
1495  OBJECT_P OF OFF OFFSET OIDS OLD ON ONLY OPERATOR OPTION OPTIONS OR
1496  ORDER ORDINALITY OTHERS OUT_P OUTER_P
1497  OVER OVERLAPS OVERLAY OVERRIDING OWNED OWNER
1498 
1499  PARALLEL PARSER PARTIAL PARTITION PASSING PASSWORD PLACING PLANS POLICY
1500  POSITION PRECEDING PRECISION PRESERVE PREPARE PREPARED PRIMARY
1501  PRIOR PRIVILEGES PROCEDURAL PROCEDURE PROCEDURES PROGRAM PUBLICATION
1502 
1503  QUOTE
1504 
1505  RANGE READ REAL REASSIGN RECHECK RECURSIVE REF REFERENCES REFERENCING
1506  REFRESH REINDEX RELATIVE_P RELEASE RENAME REPEATABLE REPLACE REPLICA
1507  RESET RESTART RESTRICT RETURNING RETURNS REVOKE RIGHT ROLE ROLLBACK ROLLUP
1508  ROUTINE ROUTINES ROW ROWS RULE
1509 
1510  SAVEPOINT SCHEMA SCHEMAS SCROLL SEARCH SECOND_P SECURITY SELECT SEQUENCE SEQUENCES
1511  SERIALIZABLE SERVER SESSION SESSION_USER SET SETS SETOF SHARE SHOW
1512  SIMILAR SIMPLE SKIP SMALLINT SNAPSHOT SOME SQL_P STABLE STANDALONE_P
1513  START STATEMENT STATISTICS STDIN STDOUT STORAGE STRICT_P STRIP_P
1514  SUBSCRIPTION SUBSTRING SYMMETRIC SYSID SYSTEM_P
1515 
1516  TABLE TABLES TABLESAMPLE TABLESPACE TEMP TEMPLATE TEMPORARY TEXT_P THEN
1517  TIES TIME TIMESTAMP TO TRAILING TRANSACTION TRANSFORM
1518  TREAT TRIGGER TRIM TRUE_P
1519  TRUNCATE TRUSTED TYPE_P TYPES_P
1520 
1521  UNBOUNDED UNCOMMITTED UNENCRYPTED UNION UNIQUE UNKNOWN UNLISTEN UNLOGGED
1522  UNTIL UPDATE USER USING
1523 
1524  VACUUM VALID VALIDATE VALIDATOR VALUE_P VALUES VARCHAR VARIADIC VARYING
1525  VERBOSE VERSION_P VIEW VIEWS VOLATILE
1526 
1527  WHEN WHERE WHITESPACE_P WINDOW WITH WITHIN WITHOUT WORK WRAPPER WRITE
1528 
1529  XML_P XMLATTRIBUTES XMLCONCAT XMLELEMENT XMLEXISTS XMLFOREST XMLNAMESPACES
1530  XMLPARSE XMLPI XMLROOT XMLSERIALIZE XMLTABLE
1531 
1532  YEAR_P YES_P
1533 
1534  ZONE
1535 
1536 
1537 
1538 
1539 
1540 
1541 
1542 
1543 
1544 
1545 
1546  %token NOT_LA NULLS_LA WITH_LA
1547 
1548 
1549 
1550  %nonassoc SET
1551  %left UNION EXCEPT
1552  %left INTERSECT
1553  %left OR
1554  %left AND
1555  %right NOT
1556  %nonassoc IS ISNULL NOTNULL
1557  %nonassoc '<' '>' '=' LESS_EQUALS GREATER_EQUALS NOT_EQUALS
1558  %nonassoc BETWEEN IN_P LIKE ILIKE SIMILAR NOT_LA
1559  %nonassoc ESCAPE
1560  %left POSTFIXOP
1561 
1562 
1563 
1564 
1565 
1566 
1567 
1568 
1569 
1570 
1571 
1572 
1573 
1574 
1575 
1576 
1577 
1578 
1579 
1580 
1581 
1582 
1583 
1584 
1585 
1586 
1587 
1588  %nonassoc UNBOUNDED
1589  %nonassoc IDENT
1590 %nonassoc CSTRING
1591 %nonassoc UIDENT GENERATED NULL_P PARTITION RANGE ROWS GROUPS PRECEDING FOLLOWING CUBE ROLLUP
1592  %left Op OPERATOR
1593  %left '+' '-'
1594  %left '*' '/' '%'
1595  %left '^'
1596 
1597  %left AT
1598  %left COLLATE
1599  %right UMINUS
1600  %left '[' ']'
1601  %left '(' ')'
1602  %left TYPECAST
1603  %left '.'
1604 
1605 
1606 
1607 
1608 
1609 
1610 
1611  %left JOIN CROSS LEFT FULL RIGHT INNER_P NATURAL
1612 
1613  %right PRESERVE STRIP_P
1614 
1615 %%
1616 prog: statements;
1617 /* rules */
1618  stmt:
1619  AlterEventTrigStmt
1620  { output_statement($1, 0, ECPGst_normal); }
1621 |  AlterCollationStmt
1622  { output_statement($1, 0, ECPGst_normal); }
1623 |  AlterDatabaseStmt
1624  { output_statement($1, 0, ECPGst_normal); }
1625 |  AlterDatabaseSetStmt
1626  { output_statement($1, 0, ECPGst_normal); }
1627 |  AlterDefaultPrivilegesStmt
1628  { output_statement($1, 0, ECPGst_normal); }
1629 |  AlterDomainStmt
1630  { output_statement($1, 0, ECPGst_normal); }
1631 |  AlterEnumStmt
1632  { output_statement($1, 0, ECPGst_normal); }
1633 |  AlterExtensionStmt
1634  { output_statement($1, 0, ECPGst_normal); }
1635 |  AlterExtensionContentsStmt
1636  { output_statement($1, 0, ECPGst_normal); }
1637 |  AlterFdwStmt
1638  { output_statement($1, 0, ECPGst_normal); }
1639 |  AlterForeignServerStmt
1640  { output_statement($1, 0, ECPGst_normal); }
1641 |  AlterForeignTableStmt
1642  { output_statement($1, 0, ECPGst_normal); }
1643 |  AlterFunctionStmt
1644  { output_statement($1, 0, ECPGst_normal); }
1645 |  AlterGroupStmt
1646  { output_statement($1, 0, ECPGst_normal); }
1647 |  AlterObjectDependsStmt
1648  { output_statement($1, 0, ECPGst_normal); }
1649 |  AlterObjectSchemaStmt
1650  { output_statement($1, 0, ECPGst_normal); }
1651 |  AlterOwnerStmt
1652  { output_statement($1, 0, ECPGst_normal); }
1653 |  AlterOperatorStmt
1654  { output_statement($1, 0, ECPGst_normal); }
1655 |  AlterPolicyStmt
1656  { output_statement($1, 0, ECPGst_normal); }
1657 |  AlterSeqStmt
1658  { output_statement($1, 0, ECPGst_normal); }
1659 |  AlterSystemStmt
1660  { output_statement($1, 0, ECPGst_normal); }
1661 |  AlterTableStmt
1662  { output_statement($1, 0, ECPGst_normal); }
1663 |  AlterTblSpcStmt
1664  { output_statement($1, 0, ECPGst_normal); }
1665 |  AlterCompositeTypeStmt
1666  { output_statement($1, 0, ECPGst_normal); }
1667 |  AlterPublicationStmt
1668  { output_statement($1, 0, ECPGst_normal); }
1669 |  AlterRoleSetStmt
1670  { output_statement($1, 0, ECPGst_normal); }
1671 |  AlterRoleStmt
1672  { output_statement($1, 0, ECPGst_normal); }
1673 |  AlterSubscriptionStmt
1674  { output_statement($1, 0, ECPGst_normal); }
1675 |  AlterTSConfigurationStmt
1676  { output_statement($1, 0, ECPGst_normal); }
1677 |  AlterTSDictionaryStmt
1678  { output_statement($1, 0, ECPGst_normal); }
1679 |  AlterUserMappingStmt
1680  { output_statement($1, 0, ECPGst_normal); }
1681 |  AnalyzeStmt
1682  { output_statement($1, 0, ECPGst_normal); }
1683 |  CallStmt
1684  { output_statement($1, 0, ECPGst_normal); }
1685 |  CheckPointStmt
1686  { output_statement($1, 0, ECPGst_normal); }
1687 |  ClosePortalStmt
1688 	{
1689 		if (INFORMIX_MODE)
1690 		{
1691 			if (pg_strcasecmp($1+strlen("close "), "database") == 0)
1692 			{
1693 				if (connection)
1694 					mmerror(PARSE_ERROR, ET_ERROR, "AT option not allowed in CLOSE DATABASE statement");
1695 
1696 				fprintf(base_yyout, "{ ECPGdisconnect(__LINE__, \"CURRENT\");");
1697 				whenever_action(2);
1698 				free($1);
1699 				break;
1700 			}
1701 		}
1702 
1703 		output_statement($1, 0, ECPGst_normal);
1704 	}
1705 |  ClusterStmt
1706  { output_statement($1, 0, ECPGst_normal); }
1707 |  CommentStmt
1708  { output_statement($1, 0, ECPGst_normal); }
1709 |  ConstraintsSetStmt
1710  { output_statement($1, 0, ECPGst_normal); }
1711 |  CopyStmt
1712  { output_statement($1, 0, ECPGst_normal); }
1713 |  CreateAmStmt
1714  { output_statement($1, 0, ECPGst_normal); }
1715 |  CreateAsStmt
1716  { output_statement($1, 0, ECPGst_normal); }
1717 |  CreateAssertStmt
1718  { output_statement($1, 0, ECPGst_normal); }
1719 |  CreateCastStmt
1720  { output_statement($1, 0, ECPGst_normal); }
1721 |  CreateConversionStmt
1722  { output_statement($1, 0, ECPGst_normal); }
1723 |  CreateDomainStmt
1724  { output_statement($1, 0, ECPGst_normal); }
1725 |  CreateExtensionStmt
1726  { output_statement($1, 0, ECPGst_normal); }
1727 |  CreateFdwStmt
1728  { output_statement($1, 0, ECPGst_normal); }
1729 |  CreateForeignServerStmt
1730  { output_statement($1, 0, ECPGst_normal); }
1731 |  CreateForeignTableStmt
1732  { output_statement($1, 0, ECPGst_normal); }
1733 |  CreateFunctionStmt
1734  { output_statement($1, 0, ECPGst_normal); }
1735 |  CreateGroupStmt
1736  { output_statement($1, 0, ECPGst_normal); }
1737 |  CreateMatViewStmt
1738  { output_statement($1, 0, ECPGst_normal); }
1739 |  CreateOpClassStmt
1740  { output_statement($1, 0, ECPGst_normal); }
1741 |  CreateOpFamilyStmt
1742  { output_statement($1, 0, ECPGst_normal); }
1743 |  CreatePublicationStmt
1744  { output_statement($1, 0, ECPGst_normal); }
1745 |  AlterOpFamilyStmt
1746  { output_statement($1, 0, ECPGst_normal); }
1747 |  CreatePolicyStmt
1748  { output_statement($1, 0, ECPGst_normal); }
1749 |  CreatePLangStmt
1750  { output_statement($1, 0, ECPGst_normal); }
1751 |  CreateSchemaStmt
1752  { output_statement($1, 0, ECPGst_normal); }
1753 |  CreateSeqStmt
1754  { output_statement($1, 0, ECPGst_normal); }
1755 |  CreateStmt
1756  { output_statement($1, 0, ECPGst_normal); }
1757 |  CreateSubscriptionStmt
1758  { output_statement($1, 0, ECPGst_normal); }
1759 |  CreateStatsStmt
1760  { output_statement($1, 0, ECPGst_normal); }
1761 |  CreateTableSpaceStmt
1762  { output_statement($1, 0, ECPGst_normal); }
1763 |  CreateTransformStmt
1764  { output_statement($1, 0, ECPGst_normal); }
1765 |  CreateTrigStmt
1766  { output_statement($1, 0, ECPGst_normal); }
1767 |  CreateEventTrigStmt
1768  { output_statement($1, 0, ECPGst_normal); }
1769 |  CreateRoleStmt
1770  { output_statement($1, 0, ECPGst_normal); }
1771 |  CreateUserStmt
1772  { output_statement($1, 0, ECPGst_normal); }
1773 |  CreateUserMappingStmt
1774  { output_statement($1, 0, ECPGst_normal); }
1775 |  CreatedbStmt
1776  { output_statement($1, 0, ECPGst_normal); }
1777 |  DeallocateStmt
1778 	{
1779 		output_deallocate_prepare_statement($1);
1780 	}
1781 |  DeclareCursorStmt
1782 	{ output_simple_statement($1); }
1783 |  DefineStmt
1784  { output_statement($1, 0, ECPGst_normal); }
1785 |  DeleteStmt
1786 	{ output_statement($1, 1, ECPGst_prepnormal); }
1787 |  DiscardStmt
1788 	{ output_statement($1, 1, ECPGst_normal); }
1789 |  DoStmt
1790  { output_statement($1, 0, ECPGst_normal); }
1791 |  DropAssertStmt
1792  { output_statement($1, 0, ECPGst_normal); }
1793 |  DropCastStmt
1794  { output_statement($1, 0, ECPGst_normal); }
1795 |  DropOpClassStmt
1796  { output_statement($1, 0, ECPGst_normal); }
1797 |  DropOpFamilyStmt
1798  { output_statement($1, 0, ECPGst_normal); }
1799 |  DropOwnedStmt
1800  { output_statement($1, 0, ECPGst_normal); }
1801 |  DropPLangStmt
1802  { output_statement($1, 0, ECPGst_normal); }
1803 |  DropStmt
1804  { output_statement($1, 0, ECPGst_normal); }
1805 |  DropSubscriptionStmt
1806  { output_statement($1, 0, ECPGst_normal); }
1807 |  DropTableSpaceStmt
1808  { output_statement($1, 0, ECPGst_normal); }
1809 |  DropTransformStmt
1810  { output_statement($1, 0, ECPGst_normal); }
1811 |  DropRoleStmt
1812  { output_statement($1, 0, ECPGst_normal); }
1813 |  DropUserMappingStmt
1814  { output_statement($1, 0, ECPGst_normal); }
1815 |  DropdbStmt
1816  { output_statement($1, 0, ECPGst_normal); }
1817 |  ExecuteStmt
1818 	{ output_statement($1, 1, ECPGst_execute); }
1819 |  ExplainStmt
1820  { output_statement($1, 0, ECPGst_normal); }
1821 |  FetchStmt
1822 	{ output_statement($1, 1, ECPGst_normal); }
1823 |  GrantStmt
1824  { output_statement($1, 0, ECPGst_normal); }
1825 |  GrantRoleStmt
1826  { output_statement($1, 0, ECPGst_normal); }
1827 |  ImportForeignSchemaStmt
1828  { output_statement($1, 0, ECPGst_normal); }
1829 |  IndexStmt
1830  { output_statement($1, 0, ECPGst_normal); }
1831 |  InsertStmt
1832 	{ output_statement($1, 1, ECPGst_prepnormal); }
1833 |  ListenStmt
1834  { output_statement($1, 0, ECPGst_normal); }
1835 |  RefreshMatViewStmt
1836  { output_statement($1, 0, ECPGst_normal); }
1837 |  LoadStmt
1838  { output_statement($1, 0, ECPGst_normal); }
1839 |  LockStmt
1840  { output_statement($1, 0, ECPGst_normal); }
1841 |  NotifyStmt
1842  { output_statement($1, 0, ECPGst_normal); }
1843 |  PrepareStmt
1844 	{
1845 		if ($1.type == NULL || strlen($1.type) == 0)
1846 			output_prepare_statement($1.name, $1.stmt);
1847 		else
1848 			output_statement(cat_str(5, mm_strdup("prepare"), $1.name, $1.type, mm_strdup("as"), $1.stmt), 0, ECPGst_normal);
1849 	}
1850 |  ReassignOwnedStmt
1851  { output_statement($1, 0, ECPGst_normal); }
1852 |  ReindexStmt
1853  { output_statement($1, 0, ECPGst_normal); }
1854 |  RemoveAggrStmt
1855  { output_statement($1, 0, ECPGst_normal); }
1856 |  RemoveFuncStmt
1857  { output_statement($1, 0, ECPGst_normal); }
1858 |  RemoveOperStmt
1859  { output_statement($1, 0, ECPGst_normal); }
1860 |  RenameStmt
1861  { output_statement($1, 0, ECPGst_normal); }
1862 |  RevokeStmt
1863  { output_statement($1, 0, ECPGst_normal); }
1864 |  RevokeRoleStmt
1865  { output_statement($1, 0, ECPGst_normal); }
1866 |  RuleStmt
1867  { output_statement($1, 0, ECPGst_normal); }
1868 |  SecLabelStmt
1869  { output_statement($1, 0, ECPGst_normal); }
1870 |  SelectStmt
1871 	{ output_statement($1, 1, ECPGst_prepnormal); }
1872 |  TransactionStmt
1873 	{
1874 		fprintf(base_yyout, "{ ECPGtrans(__LINE__, %s, \"%s\");", connection ? connection : "NULL", $1);
1875 		whenever_action(2);
1876 		free($1);
1877 	}
1878 |  TruncateStmt
1879  { output_statement($1, 0, ECPGst_normal); }
1880 |  UnlistenStmt
1881  { output_statement($1, 0, ECPGst_normal); }
1882 |  UpdateStmt
1883 	{ output_statement($1, 1, ECPGst_prepnormal); }
1884 |  VacuumStmt
1885  { output_statement($1, 0, ECPGst_normal); }
1886 |  VariableResetStmt
1887  { output_statement($1, 0, ECPGst_normal); }
1888 |  VariableSetStmt
1889  { output_statement($1, 0, ECPGst_normal); }
1890 |  VariableShowStmt
1891  { output_statement($1, 0, ECPGst_normal); }
1892 |  ViewStmt
1893  { output_statement($1, 0, ECPGst_normal); }
1894 	| ECPGAllocateDescr
1895 	{
1896 		fprintf(base_yyout,"ECPGallocate_desc(__LINE__, %s);",$1);
1897 		whenever_action(0);
1898 		free($1);
1899 	}
1900 	| ECPGConnect
1901 	{
1902 		if (connection)
1903 			mmerror(PARSE_ERROR, ET_ERROR, "AT option not allowed in CONNECT statement");
1904 
1905 		fprintf(base_yyout, "{ ECPGconnect(__LINE__, %d, %s, %d); ", compat, $1, autocommit);
1906 		reset_variables();
1907 		whenever_action(2);
1908 		free($1);
1909 	}
1910 	| ECPGCursorStmt
1911 	{
1912 		output_simple_statement($1);
1913 	}
1914 	| ECPGDeallocateDescr
1915 	{
1916 		fprintf(base_yyout,"ECPGdeallocate_desc(__LINE__, %s);",$1);
1917 		whenever_action(0);
1918 		free($1);
1919 	}
1920 	| ECPGDeclare
1921 	{
1922 		output_simple_statement($1);
1923 	}
1924 	| ECPGDescribe
1925 	{
1926 		fprintf(base_yyout, "{ ECPGdescribe(__LINE__, %d, %s,", compat, $1);
1927 		dump_variables(argsresult, 1);
1928 		fputs("ECPGt_EORT);", base_yyout);
1929 		fprintf(base_yyout, "}");
1930 		output_line_number();
1931 
1932 		free($1);
1933 	}
1934 	| ECPGDisconnect
1935 	{
1936 		if (connection)
1937 			mmerror(PARSE_ERROR, ET_ERROR, "AT option not allowed in DISCONNECT statement");
1938 
1939 		fprintf(base_yyout, "{ ECPGdisconnect(__LINE__, %s);",
1940 				$1 ? $1 : "\"CURRENT\"");
1941 		whenever_action(2);
1942 		free($1);
1943 	}
1944 	| ECPGExecuteImmediateStmt	{ output_statement($1, 0, ECPGst_exec_immediate); }
1945 	| ECPGFree
1946 	{
1947 		const char *con = connection ? connection : "NULL";
1948 
1949 		if (strcmp($1, "all") == 0)
1950 			fprintf(base_yyout, "{ ECPGdeallocate_all(__LINE__, %d, %s);", compat, con);
1951 		else if ($1[0] == ':')
1952 			fprintf(base_yyout, "{ ECPGdeallocate(__LINE__, %d, %s, %s);", compat, con, $1+1);
1953 		else
1954 			fprintf(base_yyout, "{ ECPGdeallocate(__LINE__, %d, %s, \"%s\");", compat, con, $1);
1955 
1956 		whenever_action(2);
1957 		free($1);
1958 	}
1959 	| ECPGGetDescriptor
1960 	{
1961 		lookup_descriptor($1.name, connection);
1962 		output_get_descr($1.name, $1.str);
1963 		free($1.name);
1964 		free($1.str);
1965 	}
1966 	| ECPGGetDescriptorHeader
1967 	{
1968 		lookup_descriptor($1, connection);
1969 		output_get_descr_header($1);
1970 		free($1);
1971 	}
1972 	| ECPGOpen
1973 	{
1974 		struct cursor *ptr;
1975 
1976 		if ((ptr = add_additional_variables($1, true)) != NULL)
1977 		{
1978 			connection = ptr->connection ? mm_strdup(ptr->connection) : NULL;
1979 			output_statement(mm_strdup(ptr->command), 0, ECPGst_normal);
1980 			ptr->opened = true;
1981 		}
1982 	}
1983 	| ECPGSetAutocommit
1984 	{
1985 		fprintf(base_yyout, "{ ECPGsetcommit(__LINE__, \"%s\", %s);", $1, connection ? connection : "NULL");
1986 		whenever_action(2);
1987 		free($1);
1988 	}
1989 	| ECPGSetConnection
1990 	{
1991 		if (connection)
1992 			mmerror(PARSE_ERROR, ET_ERROR, "AT option not allowed in SET CONNECTION statement");
1993 
1994 		fprintf(base_yyout, "{ ECPGsetconn(__LINE__, %s);", $1);
1995 		whenever_action(2);
1996 		free($1);
1997 	}
1998 	| ECPGSetDescriptor
1999 	{
2000 		lookup_descriptor($1.name, connection);
2001 		output_set_descr($1.name, $1.str);
2002 		free($1.name);
2003 		free($1.str);
2004 	}
2005 	| ECPGSetDescriptorHeader
2006 	{
2007 		lookup_descriptor($1, connection);
2008 		output_set_descr_header($1);
2009 		free($1);
2010 	}
2011 	| ECPGTypedef
2012 	{
2013 		if (connection)
2014 			mmerror(PARSE_ERROR, ET_ERROR, "AT option not allowed in TYPE statement");
2015 
2016 		fprintf(base_yyout, "%s", $1);
2017 		free($1);
2018 		output_line_number();
2019 	}
2020 	| ECPGVar
2021 	{
2022 		if (connection)
2023 			mmerror(PARSE_ERROR, ET_ERROR, "AT option not allowed in VAR statement");
2024 
2025 		output_simple_statement($1);
2026 	}
2027 	| ECPGWhenever
2028 	{
2029 		if (connection)
2030 			mmerror(PARSE_ERROR, ET_ERROR, "AT option not allowed in WHENEVER statement");
2031 
2032 		output_simple_statement($1);
2033 	}
2034 |
2035  { $$ = NULL; }
2036 ;
2037 
2038 
2039  CallStmt:
2040  CALL func_application
2041  {
2042  $$ = cat_str(2,mm_strdup("call"),$2);
2043 }
2044 ;
2045 
2046 
2047  CreateRoleStmt:
2048  CREATE ROLE RoleId opt_with OptRoleList
2049  {
2050  $$ = cat_str(4,mm_strdup("create role"),$3,$4,$5);
2051 }
2052 ;
2053 
2054 
2055  opt_with:
2056  WITH
2057  {
2058  $$ = mm_strdup("with");
2059 }
2060 |  WITH_LA
2061  {
2062  $$ = mm_strdup("with");
2063 }
2064 |
2065  {
2066  $$=EMPTY; }
2067 ;
2068 
2069 
2070  OptRoleList:
2071  OptRoleList CreateOptRoleElem
2072  {
2073  $$ = cat_str(2,$1,$2);
2074 }
2075 |
2076  {
2077  $$=EMPTY; }
2078 ;
2079 
2080 
2081  AlterOptRoleList:
2082  AlterOptRoleList AlterOptRoleElem
2083  {
2084  $$ = cat_str(2,$1,$2);
2085 }
2086 |
2087  {
2088  $$=EMPTY; }
2089 ;
2090 
2091 
2092  AlterOptRoleElem:
2093  PASSWORD ecpg_sconst
2094  {
2095  $$ = cat_str(2,mm_strdup("password"),$2);
2096 }
2097 |  PASSWORD NULL_P
2098  {
2099  $$ = mm_strdup("password null");
2100 }
2101 |  ENCRYPTED PASSWORD ecpg_sconst
2102  {
2103  $$ = cat_str(2,mm_strdup("encrypted password"),$3);
2104 }
2105 |  UNENCRYPTED PASSWORD ecpg_sconst
2106  {
2107 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
2108  $$ = cat_str(2,mm_strdup("unencrypted password"),$3);
2109 }
2110 |  INHERIT
2111  {
2112  $$ = mm_strdup("inherit");
2113 }
2114 |  CONNECTION LIMIT SignedIconst
2115  {
2116  $$ = cat_str(2,mm_strdup("connection limit"),$3);
2117 }
2118 |  VALID UNTIL ecpg_sconst
2119  {
2120  $$ = cat_str(2,mm_strdup("valid until"),$3);
2121 }
2122 |  USER role_list
2123  {
2124  $$ = cat_str(2,mm_strdup("user"),$2);
2125 }
2126 |  ecpg_ident
2127  {
2128  $$ = $1;
2129 }
2130 ;
2131 
2132 
2133  CreateOptRoleElem:
2134  AlterOptRoleElem
2135  {
2136  $$ = $1;
2137 }
2138 |  SYSID Iconst
2139  {
2140  $$ = cat_str(2,mm_strdup("sysid"),$2);
2141 }
2142 |  ADMIN role_list
2143  {
2144  $$ = cat_str(2,mm_strdup("admin"),$2);
2145 }
2146 |  ROLE role_list
2147  {
2148  $$ = cat_str(2,mm_strdup("role"),$2);
2149 }
2150 |  IN_P ROLE role_list
2151  {
2152  $$ = cat_str(2,mm_strdup("in role"),$3);
2153 }
2154 |  IN_P GROUP_P role_list
2155  {
2156  $$ = cat_str(2,mm_strdup("in group"),$3);
2157 }
2158 ;
2159 
2160 
2161  CreateUserStmt:
2162  CREATE USER RoleId opt_with OptRoleList
2163  {
2164  $$ = cat_str(4,mm_strdup("create user"),$3,$4,$5);
2165 }
2166 ;
2167 
2168 
2169  AlterRoleStmt:
2170  ALTER ROLE RoleSpec opt_with AlterOptRoleList
2171  {
2172  $$ = cat_str(4,mm_strdup("alter role"),$3,$4,$5);
2173 }
2174 |  ALTER USER RoleSpec opt_with AlterOptRoleList
2175  {
2176  $$ = cat_str(4,mm_strdup("alter user"),$3,$4,$5);
2177 }
2178 ;
2179 
2180 
2181  opt_in_database:
2182 
2183  {
2184  $$=EMPTY; }
2185 |  IN_P DATABASE database_name
2186  {
2187  $$ = cat_str(2,mm_strdup("in database"),$3);
2188 }
2189 ;
2190 
2191 
2192  AlterRoleSetStmt:
2193  ALTER ROLE RoleSpec opt_in_database SetResetClause
2194  {
2195  $$ = cat_str(4,mm_strdup("alter role"),$3,$4,$5);
2196 }
2197 |  ALTER ROLE ALL opt_in_database SetResetClause
2198  {
2199  $$ = cat_str(3,mm_strdup("alter role all"),$4,$5);
2200 }
2201 |  ALTER USER RoleSpec opt_in_database SetResetClause
2202  {
2203  $$ = cat_str(4,mm_strdup("alter user"),$3,$4,$5);
2204 }
2205 |  ALTER USER ALL opt_in_database SetResetClause
2206  {
2207  $$ = cat_str(3,mm_strdup("alter user all"),$4,$5);
2208 }
2209 ;
2210 
2211 
2212  DropRoleStmt:
2213  DROP ROLE role_list
2214  {
2215  $$ = cat_str(2,mm_strdup("drop role"),$3);
2216 }
2217 |  DROP ROLE IF_P EXISTS role_list
2218  {
2219  $$ = cat_str(2,mm_strdup("drop role if exists"),$5);
2220 }
2221 |  DROP USER role_list
2222  {
2223  $$ = cat_str(2,mm_strdup("drop user"),$3);
2224 }
2225 |  DROP USER IF_P EXISTS role_list
2226  {
2227  $$ = cat_str(2,mm_strdup("drop user if exists"),$5);
2228 }
2229 |  DROP GROUP_P role_list
2230  {
2231  $$ = cat_str(2,mm_strdup("drop group"),$3);
2232 }
2233 |  DROP GROUP_P IF_P EXISTS role_list
2234  {
2235  $$ = cat_str(2,mm_strdup("drop group if exists"),$5);
2236 }
2237 ;
2238 
2239 
2240  CreateGroupStmt:
2241  CREATE GROUP_P RoleId opt_with OptRoleList
2242  {
2243  $$ = cat_str(4,mm_strdup("create group"),$3,$4,$5);
2244 }
2245 ;
2246 
2247 
2248  AlterGroupStmt:
2249  ALTER GROUP_P RoleSpec add_drop USER role_list
2250  {
2251  $$ = cat_str(5,mm_strdup("alter group"),$3,$4,mm_strdup("user"),$6);
2252 }
2253 ;
2254 
2255 
2256  add_drop:
2257  ADD_P
2258  {
2259  $$ = mm_strdup("add");
2260 }
2261 |  DROP
2262  {
2263  $$ = mm_strdup("drop");
2264 }
2265 ;
2266 
2267 
2268  CreateSchemaStmt:
2269  CREATE SCHEMA OptSchemaName AUTHORIZATION RoleSpec OptSchemaEltList
2270  {
2271  $$ = cat_str(5,mm_strdup("create schema"),$3,mm_strdup("authorization"),$5,$6);
2272 }
2273 |  CREATE SCHEMA ColId OptSchemaEltList
2274  {
2275  $$ = cat_str(3,mm_strdup("create schema"),$3,$4);
2276 }
2277 |  CREATE SCHEMA IF_P NOT EXISTS OptSchemaName AUTHORIZATION RoleSpec OptSchemaEltList
2278  {
2279 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
2280  $$ = cat_str(5,mm_strdup("create schema if not exists"),$6,mm_strdup("authorization"),$8,$9);
2281 }
2282 |  CREATE SCHEMA IF_P NOT EXISTS ColId OptSchemaEltList
2283  {
2284 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
2285  $$ = cat_str(3,mm_strdup("create schema if not exists"),$6,$7);
2286 }
2287 ;
2288 
2289 
2290  OptSchemaName:
2291  ColId
2292  {
2293  $$ = $1;
2294 }
2295 |
2296  {
2297  $$=EMPTY; }
2298 ;
2299 
2300 
2301  OptSchemaEltList:
2302  OptSchemaEltList schema_stmt
2303  {
2304  $$ = cat_str(2,$1,$2);
2305 }
2306 |
2307  {
2308  $$=EMPTY; }
2309 ;
2310 
2311 
2312  schema_stmt:
2313  CreateStmt
2314  {
2315  $$ = $1;
2316 }
2317 |  IndexStmt
2318  {
2319  $$ = $1;
2320 }
2321 |  CreateSeqStmt
2322  {
2323  $$ = $1;
2324 }
2325 |  CreateTrigStmt
2326  {
2327  $$ = $1;
2328 }
2329 |  GrantStmt
2330  {
2331  $$ = $1;
2332 }
2333 |  ViewStmt
2334  {
2335  $$ = $1;
2336 }
2337 ;
2338 
2339 
2340  VariableSetStmt:
2341  SET set_rest
2342  {
2343  $$ = cat_str(2,mm_strdup("set"),$2);
2344 }
2345 |  SET LOCAL set_rest
2346  {
2347  $$ = cat_str(2,mm_strdup("set local"),$3);
2348 }
2349 |  SET SESSION set_rest
2350  {
2351  $$ = cat_str(2,mm_strdup("set session"),$3);
2352 }
2353 ;
2354 
2355 
2356  set_rest:
2357  TRANSACTION transaction_mode_list
2358  {
2359  $$ = cat_str(2,mm_strdup("transaction"),$2);
2360 }
2361 |  SESSION CHARACTERISTICS AS TRANSACTION transaction_mode_list
2362  {
2363  $$ = cat_str(2,mm_strdup("session characteristics as transaction"),$5);
2364 }
2365 |  set_rest_more
2366  {
2367  $$ = $1;
2368 }
2369 ;
2370 
2371 
2372  generic_set:
2373  var_name TO var_list
2374  {
2375  $$ = cat_str(3,$1,mm_strdup("to"),$3);
2376 }
2377 |  var_name '=' var_list
2378  {
2379  $$ = cat_str(3,$1,mm_strdup("="),$3);
2380 }
2381 |  var_name TO DEFAULT
2382  {
2383  $$ = cat_str(2,$1,mm_strdup("to default"));
2384 }
2385 |  var_name '=' DEFAULT
2386  {
2387  $$ = cat_str(2,$1,mm_strdup("= default"));
2388 }
2389 ;
2390 
2391 
2392  set_rest_more:
2393  generic_set
2394  {
2395  $$ = $1;
2396 }
2397 |  var_name FROM CURRENT_P
2398  {
2399  $$ = cat_str(2,$1,mm_strdup("from current"));
2400 }
2401 |  TIME ZONE zone_value
2402  {
2403  $$ = cat_str(2,mm_strdup("time zone"),$3);
2404 }
2405 |  CATALOG_P ecpg_sconst
2406  {
2407 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
2408  $$ = cat_str(2,mm_strdup("catalog"),$2);
2409 }
2410 |  SCHEMA ecpg_sconst
2411  {
2412  $$ = cat_str(2,mm_strdup("schema"),$2);
2413 }
2414 |  NAMES opt_encoding
2415  {
2416  $$ = cat_str(2,mm_strdup("names"),$2);
2417 }
2418 |  ROLE NonReservedWord_or_Sconst
2419  {
2420  $$ = cat_str(2,mm_strdup("role"),$2);
2421 }
2422 |  SESSION AUTHORIZATION NonReservedWord_or_Sconst
2423  {
2424  $$ = cat_str(2,mm_strdup("session authorization"),$3);
2425 }
2426 |  SESSION AUTHORIZATION DEFAULT
2427  {
2428  $$ = mm_strdup("session authorization default");
2429 }
2430 |  XML_P OPTION document_or_content
2431  {
2432  $$ = cat_str(2,mm_strdup("xml option"),$3);
2433 }
2434 |  TRANSACTION SNAPSHOT ecpg_sconst
2435  {
2436  $$ = cat_str(2,mm_strdup("transaction snapshot"),$3);
2437 }
2438 ;
2439 
2440 
2441  var_name:
2442 ECPGColId
2443  {
2444  $$ = $1;
2445 }
2446 |  var_name '.' ColId
2447  {
2448  $$ = cat_str(3,$1,mm_strdup("."),$3);
2449 }
2450 ;
2451 
2452 
2453  var_list:
2454  var_value
2455  {
2456  $$ = $1;
2457 }
2458 |  var_list ',' var_value
2459  {
2460  $$ = cat_str(3,$1,mm_strdup(","),$3);
2461 }
2462 ;
2463 
2464 
2465  var_value:
2466  opt_boolean_or_string
2467  {
2468  $$ = $1;
2469 }
2470 |  NumericOnly
2471  {
2472 		if ($1[0] == '$')
2473 		{
2474 			free($1);
2475 			$1 = mm_strdup("$0");
2476 		}
2477 
2478  $$ = $1;
2479 }
2480 ;
2481 
2482 
2483  iso_level:
2484  READ UNCOMMITTED
2485  {
2486  $$ = mm_strdup("read uncommitted");
2487 }
2488 |  READ COMMITTED
2489  {
2490  $$ = mm_strdup("read committed");
2491 }
2492 |  REPEATABLE READ
2493  {
2494  $$ = mm_strdup("repeatable read");
2495 }
2496 |  SERIALIZABLE
2497  {
2498  $$ = mm_strdup("serializable");
2499 }
2500 ;
2501 
2502 
2503  opt_boolean_or_string:
2504  TRUE_P
2505  {
2506  $$ = mm_strdup("true");
2507 }
2508 |  FALSE_P
2509  {
2510  $$ = mm_strdup("false");
2511 }
2512 |  ON
2513  {
2514  $$ = mm_strdup("on");
2515 }
2516 |  NonReservedWord_or_Sconst
2517  {
2518  $$ = $1;
2519 }
2520 ;
2521 
2522 
2523  zone_value:
2524  ecpg_sconst
2525  {
2526  $$ = $1;
2527 }
2528 |  ecpg_ident
2529  {
2530  $$ = $1;
2531 }
2532 |  ConstInterval ecpg_sconst opt_interval
2533  {
2534  $$ = cat_str(3,$1,$2,$3);
2535 }
2536 |  ConstInterval '(' Iconst ')' ecpg_sconst
2537  {
2538  $$ = cat_str(5,$1,mm_strdup("("),$3,mm_strdup(")"),$5);
2539 }
2540 |  NumericOnly
2541  {
2542  $$ = $1;
2543 }
2544 |  DEFAULT
2545  {
2546  $$ = mm_strdup("default");
2547 }
2548 |  LOCAL
2549  {
2550  $$ = mm_strdup("local");
2551 }
2552 ;
2553 
2554 
2555  opt_encoding:
2556  ecpg_sconst
2557  {
2558  $$ = $1;
2559 }
2560 |  DEFAULT
2561  {
2562  $$ = mm_strdup("default");
2563 }
2564 |
2565  {
2566  $$=EMPTY; }
2567 ;
2568 
2569 
2570  NonReservedWord_or_Sconst:
2571  NonReservedWord
2572  {
2573  $$ = $1;
2574 }
2575 |  ecpg_sconst
2576  {
2577  $$ = $1;
2578 }
2579 ;
2580 
2581 
2582  VariableResetStmt:
2583  RESET reset_rest
2584  {
2585  $$ = cat_str(2,mm_strdup("reset"),$2);
2586 }
2587 ;
2588 
2589 
2590  reset_rest:
2591  generic_reset
2592  {
2593  $$ = $1;
2594 }
2595 |  TIME ZONE
2596  {
2597  $$ = mm_strdup("time zone");
2598 }
2599 |  TRANSACTION ISOLATION LEVEL
2600  {
2601  $$ = mm_strdup("transaction isolation level");
2602 }
2603 |  SESSION AUTHORIZATION
2604  {
2605  $$ = mm_strdup("session authorization");
2606 }
2607 ;
2608 
2609 
2610  generic_reset:
2611  var_name
2612  {
2613  $$ = $1;
2614 }
2615 |  ALL
2616  {
2617  $$ = mm_strdup("all");
2618 }
2619 ;
2620 
2621 
2622  SetResetClause:
2623  SET set_rest
2624  {
2625  $$ = cat_str(2,mm_strdup("set"),$2);
2626 }
2627 |  VariableResetStmt
2628  {
2629  $$ = $1;
2630 }
2631 ;
2632 
2633 
2634  FunctionSetResetClause:
2635  SET set_rest_more
2636  {
2637  $$ = cat_str(2,mm_strdup("set"),$2);
2638 }
2639 |  VariableResetStmt
2640  {
2641  $$ = $1;
2642 }
2643 ;
2644 
2645 
2646  VariableShowStmt:
2647 SHOW var_name ecpg_into
2648  {
2649  $$ = cat_str(2,mm_strdup("show"),$2);
2650 }
2651 | SHOW TIME ZONE ecpg_into
2652  {
2653  $$ = mm_strdup("show time zone");
2654 }
2655 | SHOW TRANSACTION ISOLATION LEVEL ecpg_into
2656  {
2657  $$ = mm_strdup("show transaction isolation level");
2658 }
2659 | SHOW SESSION AUTHORIZATION ecpg_into
2660  {
2661  $$ = mm_strdup("show session authorization");
2662 }
2663 |  SHOW ALL
2664 	{
2665 		mmerror(PARSE_ERROR, ET_ERROR, "SHOW ALL is not implemented");
2666 		$$ = EMPTY;
2667 	}
2668 ;
2669 
2670 
2671  ConstraintsSetStmt:
2672  SET CONSTRAINTS constraints_set_list constraints_set_mode
2673  {
2674  $$ = cat_str(3,mm_strdup("set constraints"),$3,$4);
2675 }
2676 ;
2677 
2678 
2679  constraints_set_list:
2680  ALL
2681  {
2682  $$ = mm_strdup("all");
2683 }
2684 |  qualified_name_list
2685  {
2686  $$ = $1;
2687 }
2688 ;
2689 
2690 
2691  constraints_set_mode:
2692  DEFERRED
2693  {
2694  $$ = mm_strdup("deferred");
2695 }
2696 |  IMMEDIATE
2697  {
2698  $$ = mm_strdup("immediate");
2699 }
2700 ;
2701 
2702 
2703  CheckPointStmt:
2704  CHECKPOINT
2705  {
2706  $$ = mm_strdup("checkpoint");
2707 }
2708 ;
2709 
2710 
2711  DiscardStmt:
2712  DISCARD ALL
2713  {
2714  $$ = mm_strdup("discard all");
2715 }
2716 |  DISCARD TEMP
2717  {
2718  $$ = mm_strdup("discard temp");
2719 }
2720 |  DISCARD TEMPORARY
2721  {
2722  $$ = mm_strdup("discard temporary");
2723 }
2724 |  DISCARD PLANS
2725  {
2726  $$ = mm_strdup("discard plans");
2727 }
2728 |  DISCARD SEQUENCES
2729  {
2730  $$ = mm_strdup("discard sequences");
2731 }
2732 ;
2733 
2734 
2735  AlterTableStmt:
2736  ALTER TABLE relation_expr alter_table_cmds
2737  {
2738  $$ = cat_str(3,mm_strdup("alter table"),$3,$4);
2739 }
2740 |  ALTER TABLE IF_P EXISTS relation_expr alter_table_cmds
2741  {
2742  $$ = cat_str(3,mm_strdup("alter table if exists"),$5,$6);
2743 }
2744 |  ALTER TABLE relation_expr partition_cmd
2745  {
2746  $$ = cat_str(3,mm_strdup("alter table"),$3,$4);
2747 }
2748 |  ALTER TABLE IF_P EXISTS relation_expr partition_cmd
2749  {
2750  $$ = cat_str(3,mm_strdup("alter table if exists"),$5,$6);
2751 }
2752 |  ALTER TABLE ALL IN_P TABLESPACE name SET TABLESPACE name opt_nowait
2753  {
2754  $$ = cat_str(5,mm_strdup("alter table all in tablespace"),$6,mm_strdup("set tablespace"),$9,$10);
2755 }
2756 |  ALTER TABLE ALL IN_P TABLESPACE name OWNED BY role_list SET TABLESPACE name opt_nowait
2757  {
2758  $$ = cat_str(7,mm_strdup("alter table all in tablespace"),$6,mm_strdup("owned by"),$9,mm_strdup("set tablespace"),$12,$13);
2759 }
2760 |  ALTER INDEX qualified_name alter_table_cmds
2761  {
2762  $$ = cat_str(3,mm_strdup("alter index"),$3,$4);
2763 }
2764 |  ALTER INDEX IF_P EXISTS qualified_name alter_table_cmds
2765  {
2766  $$ = cat_str(3,mm_strdup("alter index if exists"),$5,$6);
2767 }
2768 |  ALTER INDEX qualified_name index_partition_cmd
2769  {
2770  $$ = cat_str(3,mm_strdup("alter index"),$3,$4);
2771 }
2772 |  ALTER INDEX ALL IN_P TABLESPACE name SET TABLESPACE name opt_nowait
2773  {
2774  $$ = cat_str(5,mm_strdup("alter index all in tablespace"),$6,mm_strdup("set tablespace"),$9,$10);
2775 }
2776 |  ALTER INDEX ALL IN_P TABLESPACE name OWNED BY role_list SET TABLESPACE name opt_nowait
2777  {
2778  $$ = cat_str(7,mm_strdup("alter index all in tablespace"),$6,mm_strdup("owned by"),$9,mm_strdup("set tablespace"),$12,$13);
2779 }
2780 |  ALTER SEQUENCE qualified_name alter_table_cmds
2781  {
2782  $$ = cat_str(3,mm_strdup("alter sequence"),$3,$4);
2783 }
2784 |  ALTER SEQUENCE IF_P EXISTS qualified_name alter_table_cmds
2785  {
2786  $$ = cat_str(3,mm_strdup("alter sequence if exists"),$5,$6);
2787 }
2788 |  ALTER VIEW qualified_name alter_table_cmds
2789  {
2790  $$ = cat_str(3,mm_strdup("alter view"),$3,$4);
2791 }
2792 |  ALTER VIEW IF_P EXISTS qualified_name alter_table_cmds
2793  {
2794  $$ = cat_str(3,mm_strdup("alter view if exists"),$5,$6);
2795 }
2796 |  ALTER MATERIALIZED VIEW qualified_name alter_table_cmds
2797  {
2798  $$ = cat_str(3,mm_strdup("alter materialized view"),$4,$5);
2799 }
2800 |  ALTER MATERIALIZED VIEW IF_P EXISTS qualified_name alter_table_cmds
2801  {
2802  $$ = cat_str(3,mm_strdup("alter materialized view if exists"),$6,$7);
2803 }
2804 |  ALTER MATERIALIZED VIEW ALL IN_P TABLESPACE name SET TABLESPACE name opt_nowait
2805  {
2806  $$ = cat_str(5,mm_strdup("alter materialized view all in tablespace"),$7,mm_strdup("set tablespace"),$10,$11);
2807 }
2808 |  ALTER MATERIALIZED VIEW ALL IN_P TABLESPACE name OWNED BY role_list SET TABLESPACE name opt_nowait
2809  {
2810  $$ = cat_str(7,mm_strdup("alter materialized view all in tablespace"),$7,mm_strdup("owned by"),$10,mm_strdup("set tablespace"),$13,$14);
2811 }
2812 ;
2813 
2814 
2815  alter_table_cmds:
2816  alter_table_cmd
2817  {
2818  $$ = $1;
2819 }
2820 |  alter_table_cmds ',' alter_table_cmd
2821  {
2822  $$ = cat_str(3,$1,mm_strdup(","),$3);
2823 }
2824 ;
2825 
2826 
2827  partition_cmd:
2828  ATTACH PARTITION qualified_name PartitionBoundSpec
2829  {
2830  $$ = cat_str(3,mm_strdup("attach partition"),$3,$4);
2831 }
2832 |  DETACH PARTITION qualified_name
2833  {
2834  $$ = cat_str(2,mm_strdup("detach partition"),$3);
2835 }
2836 ;
2837 
2838 
2839  index_partition_cmd:
2840  ATTACH PARTITION qualified_name
2841  {
2842  $$ = cat_str(2,mm_strdup("attach partition"),$3);
2843 }
2844 ;
2845 
2846 
2847  alter_table_cmd:
2848  ADD_P columnDef
2849  {
2850  $$ = cat_str(2,mm_strdup("add"),$2);
2851 }
2852 |  ADD_P IF_P NOT EXISTS columnDef
2853  {
2854  $$ = cat_str(2,mm_strdup("add if not exists"),$5);
2855 }
2856 |  ADD_P COLUMN columnDef
2857  {
2858  $$ = cat_str(2,mm_strdup("add column"),$3);
2859 }
2860 |  ADD_P COLUMN IF_P NOT EXISTS columnDef
2861  {
2862  $$ = cat_str(2,mm_strdup("add column if not exists"),$6);
2863 }
2864 |  ALTER opt_column ColId alter_column_default
2865  {
2866  $$ = cat_str(4,mm_strdup("alter"),$2,$3,$4);
2867 }
2868 |  ALTER opt_column ColId DROP NOT NULL_P
2869  {
2870  $$ = cat_str(4,mm_strdup("alter"),$2,$3,mm_strdup("drop not null"));
2871 }
2872 |  ALTER opt_column ColId SET NOT NULL_P
2873  {
2874  $$ = cat_str(4,mm_strdup("alter"),$2,$3,mm_strdup("set not null"));
2875 }
2876 |  ALTER opt_column ColId SET STATISTICS SignedIconst
2877  {
2878  $$ = cat_str(5,mm_strdup("alter"),$2,$3,mm_strdup("set statistics"),$6);
2879 }
2880 |  ALTER opt_column Iconst SET STATISTICS SignedIconst
2881  {
2882  $$ = cat_str(5,mm_strdup("alter"),$2,$3,mm_strdup("set statistics"),$6);
2883 }
2884 |  ALTER opt_column ColId SET reloptions
2885  {
2886  $$ = cat_str(5,mm_strdup("alter"),$2,$3,mm_strdup("set"),$5);
2887 }
2888 |  ALTER opt_column ColId RESET reloptions
2889  {
2890  $$ = cat_str(5,mm_strdup("alter"),$2,$3,mm_strdup("reset"),$5);
2891 }
2892 |  ALTER opt_column ColId SET STORAGE ColId
2893  {
2894  $$ = cat_str(5,mm_strdup("alter"),$2,$3,mm_strdup("set storage"),$6);
2895 }
2896 |  ALTER opt_column ColId ADD_P GENERATED generated_when AS IDENTITY_P OptParenthesizedSeqOptList
2897  {
2898  $$ = cat_str(7,mm_strdup("alter"),$2,$3,mm_strdup("add generated"),$6,mm_strdup("as identity"),$9);
2899 }
2900 |  ALTER opt_column ColId alter_identity_column_option_list
2901  {
2902  $$ = cat_str(4,mm_strdup("alter"),$2,$3,$4);
2903 }
2904 |  ALTER opt_column ColId DROP IDENTITY_P
2905  {
2906  $$ = cat_str(4,mm_strdup("alter"),$2,$3,mm_strdup("drop identity"));
2907 }
2908 |  ALTER opt_column ColId DROP IDENTITY_P IF_P EXISTS
2909  {
2910  $$ = cat_str(4,mm_strdup("alter"),$2,$3,mm_strdup("drop identity if exists"));
2911 }
2912 |  DROP opt_column IF_P EXISTS ColId opt_drop_behavior
2913  {
2914  $$ = cat_str(5,mm_strdup("drop"),$2,mm_strdup("if exists"),$5,$6);
2915 }
2916 |  DROP opt_column ColId opt_drop_behavior
2917  {
2918  $$ = cat_str(4,mm_strdup("drop"),$2,$3,$4);
2919 }
2920 |  ALTER opt_column ColId opt_set_data TYPE_P Typename opt_collate_clause alter_using
2921  {
2922  $$ = cat_str(8,mm_strdup("alter"),$2,$3,$4,mm_strdup("type"),$6,$7,$8);
2923 }
2924 |  ALTER opt_column ColId alter_generic_options
2925  {
2926  $$ = cat_str(4,mm_strdup("alter"),$2,$3,$4);
2927 }
2928 |  ADD_P TableConstraint
2929  {
2930  $$ = cat_str(2,mm_strdup("add"),$2);
2931 }
2932 |  ALTER CONSTRAINT name ConstraintAttributeSpec
2933  {
2934  $$ = cat_str(3,mm_strdup("alter constraint"),$3,$4);
2935 }
2936 |  VALIDATE CONSTRAINT name
2937  {
2938  $$ = cat_str(2,mm_strdup("validate constraint"),$3);
2939 }
2940 |  DROP CONSTRAINT IF_P EXISTS name opt_drop_behavior
2941  {
2942  $$ = cat_str(3,mm_strdup("drop constraint if exists"),$5,$6);
2943 }
2944 |  DROP CONSTRAINT name opt_drop_behavior
2945  {
2946  $$ = cat_str(3,mm_strdup("drop constraint"),$3,$4);
2947 }
2948 |  SET WITH OIDS
2949  {
2950  $$ = mm_strdup("set with oids");
2951 }
2952 |  SET WITHOUT OIDS
2953  {
2954  $$ = mm_strdup("set without oids");
2955 }
2956 |  CLUSTER ON name
2957  {
2958  $$ = cat_str(2,mm_strdup("cluster on"),$3);
2959 }
2960 |  SET WITHOUT CLUSTER
2961  {
2962  $$ = mm_strdup("set without cluster");
2963 }
2964 |  SET LOGGED
2965  {
2966  $$ = mm_strdup("set logged");
2967 }
2968 |  SET UNLOGGED
2969  {
2970  $$ = mm_strdup("set unlogged");
2971 }
2972 |  ENABLE_P TRIGGER name
2973  {
2974  $$ = cat_str(2,mm_strdup("enable trigger"),$3);
2975 }
2976 |  ENABLE_P ALWAYS TRIGGER name
2977  {
2978  $$ = cat_str(2,mm_strdup("enable always trigger"),$4);
2979 }
2980 |  ENABLE_P REPLICA TRIGGER name
2981  {
2982  $$ = cat_str(2,mm_strdup("enable replica trigger"),$4);
2983 }
2984 |  ENABLE_P TRIGGER ALL
2985  {
2986  $$ = mm_strdup("enable trigger all");
2987 }
2988 |  ENABLE_P TRIGGER USER
2989  {
2990  $$ = mm_strdup("enable trigger user");
2991 }
2992 |  DISABLE_P TRIGGER name
2993  {
2994  $$ = cat_str(2,mm_strdup("disable trigger"),$3);
2995 }
2996 |  DISABLE_P TRIGGER ALL
2997  {
2998  $$ = mm_strdup("disable trigger all");
2999 }
3000 |  DISABLE_P TRIGGER USER
3001  {
3002  $$ = mm_strdup("disable trigger user");
3003 }
3004 |  ENABLE_P RULE name
3005  {
3006  $$ = cat_str(2,mm_strdup("enable rule"),$3);
3007 }
3008 |  ENABLE_P ALWAYS RULE name
3009  {
3010  $$ = cat_str(2,mm_strdup("enable always rule"),$4);
3011 }
3012 |  ENABLE_P REPLICA RULE name
3013  {
3014  $$ = cat_str(2,mm_strdup("enable replica rule"),$4);
3015 }
3016 |  DISABLE_P RULE name
3017  {
3018  $$ = cat_str(2,mm_strdup("disable rule"),$3);
3019 }
3020 |  INHERIT qualified_name
3021  {
3022  $$ = cat_str(2,mm_strdup("inherit"),$2);
3023 }
3024 |  NO INHERIT qualified_name
3025  {
3026  $$ = cat_str(2,mm_strdup("no inherit"),$3);
3027 }
3028 |  OF any_name
3029  {
3030  $$ = cat_str(2,mm_strdup("of"),$2);
3031 }
3032 |  NOT OF
3033  {
3034  $$ = mm_strdup("not of");
3035 }
3036 |  OWNER TO RoleSpec
3037  {
3038  $$ = cat_str(2,mm_strdup("owner to"),$3);
3039 }
3040 |  SET TABLESPACE name
3041  {
3042  $$ = cat_str(2,mm_strdup("set tablespace"),$3);
3043 }
3044 |  SET reloptions
3045  {
3046  $$ = cat_str(2,mm_strdup("set"),$2);
3047 }
3048 |  RESET reloptions
3049  {
3050  $$ = cat_str(2,mm_strdup("reset"),$2);
3051 }
3052 |  REPLICA IDENTITY_P replica_identity
3053  {
3054  $$ = cat_str(2,mm_strdup("replica identity"),$3);
3055 }
3056 |  ENABLE_P ROW LEVEL SECURITY
3057  {
3058  $$ = mm_strdup("enable row level security");
3059 }
3060 |  DISABLE_P ROW LEVEL SECURITY
3061  {
3062  $$ = mm_strdup("disable row level security");
3063 }
3064 |  FORCE ROW LEVEL SECURITY
3065  {
3066  $$ = mm_strdup("force row level security");
3067 }
3068 |  NO FORCE ROW LEVEL SECURITY
3069  {
3070  $$ = mm_strdup("no force row level security");
3071 }
3072 |  alter_generic_options
3073  {
3074  $$ = $1;
3075 }
3076 ;
3077 
3078 
3079  alter_column_default:
3080  SET DEFAULT a_expr
3081  {
3082  $$ = cat_str(2,mm_strdup("set default"),$3);
3083 }
3084 |  DROP DEFAULT
3085  {
3086  $$ = mm_strdup("drop default");
3087 }
3088 ;
3089 
3090 
3091  opt_drop_behavior:
3092  CASCADE
3093  {
3094  $$ = mm_strdup("cascade");
3095 }
3096 |  RESTRICT
3097  {
3098  $$ = mm_strdup("restrict");
3099 }
3100 |
3101  {
3102  $$=EMPTY; }
3103 ;
3104 
3105 
3106  opt_collate_clause:
3107  COLLATE any_name
3108  {
3109  $$ = cat_str(2,mm_strdup("collate"),$2);
3110 }
3111 |
3112  {
3113  $$=EMPTY; }
3114 ;
3115 
3116 
3117  alter_using:
3118  USING a_expr
3119  {
3120  $$ = cat_str(2,mm_strdup("using"),$2);
3121 }
3122 |
3123  {
3124  $$=EMPTY; }
3125 ;
3126 
3127 
3128  replica_identity:
3129  NOTHING
3130  {
3131  $$ = mm_strdup("nothing");
3132 }
3133 |  FULL
3134  {
3135  $$ = mm_strdup("full");
3136 }
3137 |  DEFAULT
3138  {
3139  $$ = mm_strdup("default");
3140 }
3141 |  USING INDEX name
3142  {
3143  $$ = cat_str(2,mm_strdup("using index"),$3);
3144 }
3145 ;
3146 
3147 
3148  reloptions:
3149  '(' reloption_list ')'
3150  {
3151  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
3152 }
3153 ;
3154 
3155 
3156  opt_reloptions:
3157  WITH reloptions
3158  {
3159  $$ = cat_str(2,mm_strdup("with"),$2);
3160 }
3161 |
3162  {
3163  $$=EMPTY; }
3164 ;
3165 
3166 
3167  reloption_list:
3168  reloption_elem
3169  {
3170  $$ = $1;
3171 }
3172 |  reloption_list ',' reloption_elem
3173  {
3174  $$ = cat_str(3,$1,mm_strdup(","),$3);
3175 }
3176 ;
3177 
3178 
3179  reloption_elem:
3180  ColLabel '=' def_arg
3181  {
3182  $$ = cat_str(3,$1,mm_strdup("="),$3);
3183 }
3184 |  ColLabel
3185  {
3186  $$ = $1;
3187 }
3188 |  ColLabel '.' ColLabel '=' def_arg
3189  {
3190  $$ = cat_str(5,$1,mm_strdup("."),$3,mm_strdup("="),$5);
3191 }
3192 |  ColLabel '.' ColLabel
3193  {
3194  $$ = cat_str(3,$1,mm_strdup("."),$3);
3195 }
3196 ;
3197 
3198 
3199  alter_identity_column_option_list:
3200  alter_identity_column_option
3201  {
3202  $$ = $1;
3203 }
3204 |  alter_identity_column_option_list alter_identity_column_option
3205  {
3206  $$ = cat_str(2,$1,$2);
3207 }
3208 ;
3209 
3210 
3211  alter_identity_column_option:
3212  RESTART
3213  {
3214  $$ = mm_strdup("restart");
3215 }
3216 |  RESTART opt_with NumericOnly
3217  {
3218  $$ = cat_str(3,mm_strdup("restart"),$2,$3);
3219 }
3220 |  SET SeqOptElem
3221  {
3222  $$ = cat_str(2,mm_strdup("set"),$2);
3223 }
3224 |  SET GENERATED generated_when
3225  {
3226  $$ = cat_str(2,mm_strdup("set generated"),$3);
3227 }
3228 ;
3229 
3230 
3231  PartitionBoundSpec:
3232  FOR VALUES WITH '(' hash_partbound ')'
3233  {
3234  $$ = cat_str(3,mm_strdup("for values with ("),$5,mm_strdup(")"));
3235 }
3236 |  FOR VALUES IN_P '(' partbound_datum_list ')'
3237  {
3238  $$ = cat_str(3,mm_strdup("for values in ("),$5,mm_strdup(")"));
3239 }
3240 |  FOR VALUES FROM '(' range_datum_list ')' TO '(' range_datum_list ')'
3241  {
3242  $$ = cat_str(5,mm_strdup("for values from ("),$5,mm_strdup(") to ("),$9,mm_strdup(")"));
3243 }
3244 |  DEFAULT
3245  {
3246  $$ = mm_strdup("default");
3247 }
3248 ;
3249 
3250 
3251  hash_partbound_elem:
3252  NonReservedWord Iconst
3253  {
3254  $$ = cat_str(2,$1,$2);
3255 }
3256 ;
3257 
3258 
3259  hash_partbound:
3260  hash_partbound_elem
3261  {
3262  $$ = $1;
3263 }
3264 |  hash_partbound ',' hash_partbound_elem
3265  {
3266  $$ = cat_str(3,$1,mm_strdup(","),$3);
3267 }
3268 ;
3269 
3270 
3271  partbound_datum:
3272  ecpg_sconst
3273  {
3274  $$ = $1;
3275 }
3276 |  NumericOnly
3277  {
3278  $$ = $1;
3279 }
3280 |  TRUE_P
3281  {
3282  $$ = mm_strdup("true");
3283 }
3284 |  FALSE_P
3285  {
3286  $$ = mm_strdup("false");
3287 }
3288 |  NULL_P
3289  {
3290  $$ = mm_strdup("null");
3291 }
3292 ;
3293 
3294 
3295  partbound_datum_list:
3296  partbound_datum
3297  {
3298  $$ = $1;
3299 }
3300 |  partbound_datum_list ',' partbound_datum
3301  {
3302  $$ = cat_str(3,$1,mm_strdup(","),$3);
3303 }
3304 ;
3305 
3306 
3307  range_datum_list:
3308  PartitionRangeDatum
3309  {
3310  $$ = $1;
3311 }
3312 |  range_datum_list ',' PartitionRangeDatum
3313  {
3314  $$ = cat_str(3,$1,mm_strdup(","),$3);
3315 }
3316 ;
3317 
3318 
3319  PartitionRangeDatum:
3320  MINVALUE
3321  {
3322  $$ = mm_strdup("minvalue");
3323 }
3324 |  MAXVALUE
3325  {
3326  $$ = mm_strdup("maxvalue");
3327 }
3328 |  partbound_datum
3329  {
3330  $$ = $1;
3331 }
3332 ;
3333 
3334 
3335  AlterCompositeTypeStmt:
3336  ALTER TYPE_P any_name alter_type_cmds
3337  {
3338  $$ = cat_str(3,mm_strdup("alter type"),$3,$4);
3339 }
3340 ;
3341 
3342 
3343  alter_type_cmds:
3344  alter_type_cmd
3345  {
3346  $$ = $1;
3347 }
3348 |  alter_type_cmds ',' alter_type_cmd
3349  {
3350  $$ = cat_str(3,$1,mm_strdup(","),$3);
3351 }
3352 ;
3353 
3354 
3355  alter_type_cmd:
3356  ADD_P ATTRIBUTE TableFuncElement opt_drop_behavior
3357  {
3358  $$ = cat_str(3,mm_strdup("add attribute"),$3,$4);
3359 }
3360 |  DROP ATTRIBUTE IF_P EXISTS ColId opt_drop_behavior
3361  {
3362  $$ = cat_str(3,mm_strdup("drop attribute if exists"),$5,$6);
3363 }
3364 |  DROP ATTRIBUTE ColId opt_drop_behavior
3365  {
3366  $$ = cat_str(3,mm_strdup("drop attribute"),$3,$4);
3367 }
3368 |  ALTER ATTRIBUTE ColId opt_set_data TYPE_P Typename opt_collate_clause opt_drop_behavior
3369  {
3370  $$ = cat_str(7,mm_strdup("alter attribute"),$3,$4,mm_strdup("type"),$6,$7,$8);
3371 }
3372 ;
3373 
3374 
3375  ClosePortalStmt:
3376  CLOSE cursor_name
3377 	{
3378 		char *cursor_marker = $2[0] == ':' ? mm_strdup("$0") : $2;
3379 		$$ = cat2_str(mm_strdup("close"), cursor_marker);
3380 	}
3381 |  CLOSE ALL
3382  {
3383  $$ = mm_strdup("close all");
3384 }
3385 ;
3386 
3387 
3388  CopyStmt:
3389  COPY opt_binary qualified_name opt_column_list opt_oids copy_from opt_program copy_file_name copy_delimiter opt_with copy_options
3390  {
3391 			if (strcmp($6, "from") == 0 &&
3392 			   (strcmp($7, "stdin") == 0 || strcmp($7, "stdout") == 0))
3393 				mmerror(PARSE_ERROR, ET_WARNING, "COPY FROM STDIN is not implemented");
3394 
3395  $$ = cat_str(11,mm_strdup("copy"),$2,$3,$4,$5,$6,$7,$8,$9,$10,$11);
3396 }
3397 |  COPY '(' PreparableStmt ')' TO opt_program copy_file_name opt_with copy_options
3398  {
3399  $$ = cat_str(7,mm_strdup("copy ("),$3,mm_strdup(") to"),$6,$7,$8,$9);
3400 }
3401 ;
3402 
3403 
3404  copy_from:
3405  FROM
3406  {
3407  $$ = mm_strdup("from");
3408 }
3409 |  TO
3410  {
3411  $$ = mm_strdup("to");
3412 }
3413 ;
3414 
3415 
3416  opt_program:
3417  PROGRAM
3418  {
3419  $$ = mm_strdup("program");
3420 }
3421 |
3422  {
3423  $$=EMPTY; }
3424 ;
3425 
3426 
3427  copy_file_name:
3428  ecpg_sconst
3429  {
3430  $$ = $1;
3431 }
3432 |  STDIN
3433  {
3434  $$ = mm_strdup("stdin");
3435 }
3436 |  STDOUT
3437  {
3438  $$ = mm_strdup("stdout");
3439 }
3440 ;
3441 
3442 
3443  copy_options:
3444  copy_opt_list
3445  {
3446  $$ = $1;
3447 }
3448 |  '(' copy_generic_opt_list ')'
3449  {
3450  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
3451 }
3452 ;
3453 
3454 
3455  copy_opt_list:
3456  copy_opt_list copy_opt_item
3457  {
3458  $$ = cat_str(2,$1,$2);
3459 }
3460 |
3461  {
3462  $$=EMPTY; }
3463 ;
3464 
3465 
3466  copy_opt_item:
3467  BINARY
3468  {
3469  $$ = mm_strdup("binary");
3470 }
3471 |  OIDS
3472  {
3473  $$ = mm_strdup("oids");
3474 }
3475 |  FREEZE
3476  {
3477  $$ = mm_strdup("freeze");
3478 }
3479 |  DELIMITER opt_as ecpg_sconst
3480  {
3481  $$ = cat_str(3,mm_strdup("delimiter"),$2,$3);
3482 }
3483 |  NULL_P opt_as ecpg_sconst
3484  {
3485  $$ = cat_str(3,mm_strdup("null"),$2,$3);
3486 }
3487 |  CSV
3488  {
3489  $$ = mm_strdup("csv");
3490 }
3491 |  HEADER_P
3492  {
3493  $$ = mm_strdup("header");
3494 }
3495 |  QUOTE opt_as ecpg_sconst
3496  {
3497  $$ = cat_str(3,mm_strdup("quote"),$2,$3);
3498 }
3499 |  ESCAPE opt_as ecpg_sconst
3500  {
3501  $$ = cat_str(3,mm_strdup("escape"),$2,$3);
3502 }
3503 |  FORCE QUOTE columnList
3504  {
3505  $$ = cat_str(2,mm_strdup("force quote"),$3);
3506 }
3507 |  FORCE QUOTE '*'
3508  {
3509  $$ = mm_strdup("force quote *");
3510 }
3511 |  FORCE NOT NULL_P columnList
3512  {
3513  $$ = cat_str(2,mm_strdup("force not null"),$4);
3514 }
3515 |  FORCE NULL_P columnList
3516  {
3517  $$ = cat_str(2,mm_strdup("force null"),$3);
3518 }
3519 |  ENCODING ecpg_sconst
3520  {
3521  $$ = cat_str(2,mm_strdup("encoding"),$2);
3522 }
3523 ;
3524 
3525 
3526  opt_binary:
3527  BINARY
3528  {
3529  $$ = mm_strdup("binary");
3530 }
3531 |
3532  {
3533  $$=EMPTY; }
3534 ;
3535 
3536 
3537  opt_oids:
3538  WITH OIDS
3539  {
3540  $$ = mm_strdup("with oids");
3541 }
3542 |
3543  {
3544  $$=EMPTY; }
3545 ;
3546 
3547 
3548  copy_delimiter:
3549  opt_using DELIMITERS ecpg_sconst
3550  {
3551  $$ = cat_str(3,$1,mm_strdup("delimiters"),$3);
3552 }
3553 |
3554  {
3555  $$=EMPTY; }
3556 ;
3557 
3558 
3559  opt_using:
3560  USING
3561  {
3562  $$ = mm_strdup("using");
3563 }
3564 |
3565  {
3566  $$=EMPTY; }
3567 ;
3568 
3569 
3570  copy_generic_opt_list:
3571  copy_generic_opt_elem
3572  {
3573  $$ = $1;
3574 }
3575 |  copy_generic_opt_list ',' copy_generic_opt_elem
3576  {
3577  $$ = cat_str(3,$1,mm_strdup(","),$3);
3578 }
3579 ;
3580 
3581 
3582  copy_generic_opt_elem:
3583  ColLabel copy_generic_opt_arg
3584  {
3585  $$ = cat_str(2,$1,$2);
3586 }
3587 ;
3588 
3589 
3590  copy_generic_opt_arg:
3591  opt_boolean_or_string
3592  {
3593  $$ = $1;
3594 }
3595 |  NumericOnly
3596  {
3597  $$ = $1;
3598 }
3599 |  '*'
3600  {
3601  $$ = mm_strdup("*");
3602 }
3603 |  '(' copy_generic_opt_arg_list ')'
3604  {
3605  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
3606 }
3607 |
3608  {
3609  $$=EMPTY; }
3610 ;
3611 
3612 
3613  copy_generic_opt_arg_list:
3614  copy_generic_opt_arg_list_item
3615  {
3616  $$ = $1;
3617 }
3618 |  copy_generic_opt_arg_list ',' copy_generic_opt_arg_list_item
3619  {
3620  $$ = cat_str(3,$1,mm_strdup(","),$3);
3621 }
3622 ;
3623 
3624 
3625  copy_generic_opt_arg_list_item:
3626  opt_boolean_or_string
3627  {
3628  $$ = $1;
3629 }
3630 ;
3631 
3632 
3633  CreateStmt:
3634  CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')' OptInherit OptPartitionSpec OptWith OnCommitOption OptTableSpace
3635  {
3636  $$ = cat_str(12,mm_strdup("create"),$2,mm_strdup("table"),$4,mm_strdup("("),$6,mm_strdup(")"),$8,$9,$10,$11,$12);
3637 }
3638 |  CREATE OptTemp TABLE IF_P NOT EXISTS qualified_name '(' OptTableElementList ')' OptInherit OptPartitionSpec OptWith OnCommitOption OptTableSpace
3639  {
3640  $$ = cat_str(12,mm_strdup("create"),$2,mm_strdup("table if not exists"),$7,mm_strdup("("),$9,mm_strdup(")"),$11,$12,$13,$14,$15);
3641 }
3642 |  CREATE OptTemp TABLE qualified_name OF any_name OptTypedTableElementList OptPartitionSpec OptWith OnCommitOption OptTableSpace
3643  {
3644  $$ = cat_str(11,mm_strdup("create"),$2,mm_strdup("table"),$4,mm_strdup("of"),$6,$7,$8,$9,$10,$11);
3645 }
3646 |  CREATE OptTemp TABLE IF_P NOT EXISTS qualified_name OF any_name OptTypedTableElementList OptPartitionSpec OptWith OnCommitOption OptTableSpace
3647  {
3648  $$ = cat_str(11,mm_strdup("create"),$2,mm_strdup("table if not exists"),$7,mm_strdup("of"),$9,$10,$11,$12,$13,$14);
3649 }
3650 |  CREATE OptTemp TABLE qualified_name PARTITION OF qualified_name OptTypedTableElementList PartitionBoundSpec OptPartitionSpec OptWith OnCommitOption OptTableSpace
3651  {
3652  $$ = cat_str(12,mm_strdup("create"),$2,mm_strdup("table"),$4,mm_strdup("partition of"),$7,$8,$9,$10,$11,$12,$13);
3653 }
3654 |  CREATE OptTemp TABLE IF_P NOT EXISTS qualified_name PARTITION OF qualified_name OptTypedTableElementList PartitionBoundSpec OptPartitionSpec OptWith OnCommitOption OptTableSpace
3655  {
3656  $$ = cat_str(12,mm_strdup("create"),$2,mm_strdup("table if not exists"),$7,mm_strdup("partition of"),$10,$11,$12,$13,$14,$15,$16);
3657 }
3658 ;
3659 
3660 
3661  OptTemp:
3662  TEMPORARY
3663  {
3664  $$ = mm_strdup("temporary");
3665 }
3666 |  TEMP
3667  {
3668  $$ = mm_strdup("temp");
3669 }
3670 |  LOCAL TEMPORARY
3671  {
3672  $$ = mm_strdup("local temporary");
3673 }
3674 |  LOCAL TEMP
3675  {
3676  $$ = mm_strdup("local temp");
3677 }
3678 |  GLOBAL TEMPORARY
3679  {
3680  $$ = mm_strdup("global temporary");
3681 }
3682 |  GLOBAL TEMP
3683  {
3684  $$ = mm_strdup("global temp");
3685 }
3686 |  UNLOGGED
3687  {
3688  $$ = mm_strdup("unlogged");
3689 }
3690 |
3691  {
3692  $$=EMPTY; }
3693 ;
3694 
3695 
3696  OptTableElementList:
3697  TableElementList
3698  {
3699  $$ = $1;
3700 }
3701 |
3702  {
3703  $$=EMPTY; }
3704 ;
3705 
3706 
3707  OptTypedTableElementList:
3708  '(' TypedTableElementList ')'
3709  {
3710  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
3711 }
3712 |
3713  {
3714  $$=EMPTY; }
3715 ;
3716 
3717 
3718  TableElementList:
3719  TableElement
3720  {
3721  $$ = $1;
3722 }
3723 |  TableElementList ',' TableElement
3724  {
3725  $$ = cat_str(3,$1,mm_strdup(","),$3);
3726 }
3727 ;
3728 
3729 
3730  TypedTableElementList:
3731  TypedTableElement
3732  {
3733  $$ = $1;
3734 }
3735 |  TypedTableElementList ',' TypedTableElement
3736  {
3737  $$ = cat_str(3,$1,mm_strdup(","),$3);
3738 }
3739 ;
3740 
3741 
3742  TableElement:
3743  columnDef
3744  {
3745  $$ = $1;
3746 }
3747 |  TableLikeClause
3748  {
3749  $$ = $1;
3750 }
3751 |  TableConstraint
3752  {
3753  $$ = $1;
3754 }
3755 ;
3756 
3757 
3758  TypedTableElement:
3759  columnOptions
3760  {
3761  $$ = $1;
3762 }
3763 |  TableConstraint
3764  {
3765  $$ = $1;
3766 }
3767 ;
3768 
3769 
3770  columnDef:
3771  ColId Typename create_generic_options ColQualList
3772  {
3773  $$ = cat_str(4,$1,$2,$3,$4);
3774 }
3775 ;
3776 
3777 
3778  columnOptions:
3779  ColId ColQualList
3780  {
3781  $$ = cat_str(2,$1,$2);
3782 }
3783 |  ColId WITH OPTIONS ColQualList
3784  {
3785  $$ = cat_str(3,$1,mm_strdup("with options"),$4);
3786 }
3787 ;
3788 
3789 
3790  ColQualList:
3791  ColQualList ColConstraint
3792  {
3793  $$ = cat_str(2,$1,$2);
3794 }
3795 |
3796  {
3797  $$=EMPTY; }
3798 ;
3799 
3800 
3801  ColConstraint:
3802  CONSTRAINT name ColConstraintElem
3803  {
3804  $$ = cat_str(3,mm_strdup("constraint"),$2,$3);
3805 }
3806 |  ColConstraintElem
3807  {
3808  $$ = $1;
3809 }
3810 |  ConstraintAttr
3811  {
3812  $$ = $1;
3813 }
3814 |  COLLATE any_name
3815  {
3816  $$ = cat_str(2,mm_strdup("collate"),$2);
3817 }
3818 ;
3819 
3820 
3821  ColConstraintElem:
3822  NOT NULL_P
3823  {
3824  $$ = mm_strdup("not null");
3825 }
3826 |  NULL_P
3827  {
3828  $$ = mm_strdup("null");
3829 }
3830 |  UNIQUE opt_definition OptConsTableSpace
3831  {
3832  $$ = cat_str(3,mm_strdup("unique"),$2,$3);
3833 }
3834 |  PRIMARY KEY opt_definition OptConsTableSpace
3835  {
3836  $$ = cat_str(3,mm_strdup("primary key"),$3,$4);
3837 }
3838 |  CHECK '(' a_expr ')' opt_no_inherit
3839  {
3840  $$ = cat_str(4,mm_strdup("check ("),$3,mm_strdup(")"),$5);
3841 }
3842 |  DEFAULT b_expr
3843  {
3844  $$ = cat_str(2,mm_strdup("default"),$2);
3845 }
3846 |  GENERATED generated_when AS IDENTITY_P OptParenthesizedSeqOptList
3847  {
3848  $$ = cat_str(4,mm_strdup("generated"),$2,mm_strdup("as identity"),$5);
3849 }
3850 |  REFERENCES qualified_name opt_column_list key_match key_actions
3851  {
3852  $$ = cat_str(5,mm_strdup("references"),$2,$3,$4,$5);
3853 }
3854 ;
3855 
3856 
3857  generated_when:
3858  ALWAYS
3859  {
3860  $$ = mm_strdup("always");
3861 }
3862 |  BY DEFAULT
3863  {
3864  $$ = mm_strdup("by default");
3865 }
3866 ;
3867 
3868 
3869  ConstraintAttr:
3870  DEFERRABLE
3871  {
3872  $$ = mm_strdup("deferrable");
3873 }
3874 |  NOT DEFERRABLE
3875  {
3876  $$ = mm_strdup("not deferrable");
3877 }
3878 |  INITIALLY DEFERRED
3879  {
3880  $$ = mm_strdup("initially deferred");
3881 }
3882 |  INITIALLY IMMEDIATE
3883  {
3884  $$ = mm_strdup("initially immediate");
3885 }
3886 ;
3887 
3888 
3889  TableLikeClause:
3890  LIKE qualified_name TableLikeOptionList
3891  {
3892  $$ = cat_str(3,mm_strdup("like"),$2,$3);
3893 }
3894 ;
3895 
3896 
3897  TableLikeOptionList:
3898  TableLikeOptionList INCLUDING TableLikeOption
3899  {
3900  $$ = cat_str(3,$1,mm_strdup("including"),$3);
3901 }
3902 |  TableLikeOptionList EXCLUDING TableLikeOption
3903  {
3904  $$ = cat_str(3,$1,mm_strdup("excluding"),$3);
3905 }
3906 |
3907  {
3908  $$=EMPTY; }
3909 ;
3910 
3911 
3912  TableLikeOption:
3913  COMMENTS
3914  {
3915  $$ = mm_strdup("comments");
3916 }
3917 |  CONSTRAINTS
3918  {
3919  $$ = mm_strdup("constraints");
3920 }
3921 |  DEFAULTS
3922  {
3923  $$ = mm_strdup("defaults");
3924 }
3925 |  IDENTITY_P
3926  {
3927  $$ = mm_strdup("identity");
3928 }
3929 |  INDEXES
3930  {
3931  $$ = mm_strdup("indexes");
3932 }
3933 |  STATISTICS
3934  {
3935  $$ = mm_strdup("statistics");
3936 }
3937 |  STORAGE
3938  {
3939  $$ = mm_strdup("storage");
3940 }
3941 |  ALL
3942  {
3943  $$ = mm_strdup("all");
3944 }
3945 ;
3946 
3947 
3948  TableConstraint:
3949  CONSTRAINT name ConstraintElem
3950  {
3951  $$ = cat_str(3,mm_strdup("constraint"),$2,$3);
3952 }
3953 |  ConstraintElem
3954  {
3955  $$ = $1;
3956 }
3957 ;
3958 
3959 
3960  ConstraintElem:
3961  CHECK '(' a_expr ')' ConstraintAttributeSpec
3962  {
3963  $$ = cat_str(4,mm_strdup("check ("),$3,mm_strdup(")"),$5);
3964 }
3965 |  UNIQUE '(' columnList ')' opt_c_include opt_definition OptConsTableSpace ConstraintAttributeSpec
3966  {
3967  $$ = cat_str(7,mm_strdup("unique ("),$3,mm_strdup(")"),$5,$6,$7,$8);
3968 }
3969 |  UNIQUE ExistingIndex ConstraintAttributeSpec
3970  {
3971  $$ = cat_str(3,mm_strdup("unique"),$2,$3);
3972 }
3973 |  PRIMARY KEY '(' columnList ')' opt_c_include opt_definition OptConsTableSpace ConstraintAttributeSpec
3974  {
3975  $$ = cat_str(7,mm_strdup("primary key ("),$4,mm_strdup(")"),$6,$7,$8,$9);
3976 }
3977 |  PRIMARY KEY ExistingIndex ConstraintAttributeSpec
3978  {
3979  $$ = cat_str(3,mm_strdup("primary key"),$3,$4);
3980 }
3981 |  EXCLUDE access_method_clause '(' ExclusionConstraintList ')' opt_c_include opt_definition OptConsTableSpace ExclusionWhereClause ConstraintAttributeSpec
3982  {
3983  $$ = cat_str(10,mm_strdup("exclude"),$2,mm_strdup("("),$4,mm_strdup(")"),$6,$7,$8,$9,$10);
3984 }
3985 |  FOREIGN KEY '(' columnList ')' REFERENCES qualified_name opt_column_list key_match key_actions ConstraintAttributeSpec
3986  {
3987  $$ = cat_str(8,mm_strdup("foreign key ("),$4,mm_strdup(") references"),$7,$8,$9,$10,$11);
3988 }
3989 ;
3990 
3991 
3992  opt_no_inherit:
3993  NO INHERIT
3994  {
3995  $$ = mm_strdup("no inherit");
3996 }
3997 |
3998  {
3999  $$=EMPTY; }
4000 ;
4001 
4002 
4003  opt_column_list:
4004  '(' columnList ')'
4005  {
4006  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
4007 }
4008 |
4009  {
4010  $$=EMPTY; }
4011 ;
4012 
4013 
4014  columnList:
4015  columnElem
4016  {
4017  $$ = $1;
4018 }
4019 |  columnList ',' columnElem
4020  {
4021  $$ = cat_str(3,$1,mm_strdup(","),$3);
4022 }
4023 ;
4024 
4025 
4026  columnElem:
4027  ColId
4028  {
4029  $$ = $1;
4030 }
4031 ;
4032 
4033 
4034  opt_c_include:
4035  INCLUDE '(' columnList ')'
4036  {
4037  $$ = cat_str(3,mm_strdup("include ("),$3,mm_strdup(")"));
4038 }
4039 |
4040  {
4041  $$=EMPTY; }
4042 ;
4043 
4044 
4045  key_match:
4046  MATCH FULL
4047  {
4048  $$ = mm_strdup("match full");
4049 }
4050 |  MATCH PARTIAL
4051  {
4052 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
4053  $$ = mm_strdup("match partial");
4054 }
4055 |  MATCH SIMPLE
4056  {
4057  $$ = mm_strdup("match simple");
4058 }
4059 |
4060  {
4061  $$=EMPTY; }
4062 ;
4063 
4064 
4065  ExclusionConstraintList:
4066  ExclusionConstraintElem
4067  {
4068  $$ = $1;
4069 }
4070 |  ExclusionConstraintList ',' ExclusionConstraintElem
4071  {
4072  $$ = cat_str(3,$1,mm_strdup(","),$3);
4073 }
4074 ;
4075 
4076 
4077  ExclusionConstraintElem:
4078  index_elem WITH any_operator
4079  {
4080  $$ = cat_str(3,$1,mm_strdup("with"),$3);
4081 }
4082 |  index_elem WITH OPERATOR '(' any_operator ')'
4083  {
4084  $$ = cat_str(4,$1,mm_strdup("with operator ("),$5,mm_strdup(")"));
4085 }
4086 ;
4087 
4088 
4089  ExclusionWhereClause:
4090  WHERE '(' a_expr ')'
4091  {
4092  $$ = cat_str(3,mm_strdup("where ("),$3,mm_strdup(")"));
4093 }
4094 |
4095  {
4096  $$=EMPTY; }
4097 ;
4098 
4099 
4100  key_actions:
4101  key_update
4102  {
4103  $$ = $1;
4104 }
4105 |  key_delete
4106  {
4107  $$ = $1;
4108 }
4109 |  key_update key_delete
4110  {
4111  $$ = cat_str(2,$1,$2);
4112 }
4113 |  key_delete key_update
4114  {
4115  $$ = cat_str(2,$1,$2);
4116 }
4117 |
4118  {
4119  $$=EMPTY; }
4120 ;
4121 
4122 
4123  key_update:
4124  ON UPDATE key_action
4125  {
4126  $$ = cat_str(2,mm_strdup("on update"),$3);
4127 }
4128 ;
4129 
4130 
4131  key_delete:
4132  ON DELETE_P key_action
4133  {
4134  $$ = cat_str(2,mm_strdup("on delete"),$3);
4135 }
4136 ;
4137 
4138 
4139  key_action:
4140  NO ACTION
4141  {
4142  $$ = mm_strdup("no action");
4143 }
4144 |  RESTRICT
4145  {
4146  $$ = mm_strdup("restrict");
4147 }
4148 |  CASCADE
4149  {
4150  $$ = mm_strdup("cascade");
4151 }
4152 |  SET NULL_P
4153  {
4154  $$ = mm_strdup("set null");
4155 }
4156 |  SET DEFAULT
4157  {
4158  $$ = mm_strdup("set default");
4159 }
4160 ;
4161 
4162 
4163  OptInherit:
4164  INHERITS '(' qualified_name_list ')'
4165  {
4166  $$ = cat_str(3,mm_strdup("inherits ("),$3,mm_strdup(")"));
4167 }
4168 |
4169  {
4170  $$=EMPTY; }
4171 ;
4172 
4173 
4174  OptPartitionSpec:
4175  PartitionSpec
4176  {
4177  $$ = $1;
4178 }
4179 |
4180  {
4181  $$=EMPTY; }
4182 ;
4183 
4184 
4185  PartitionSpec:
4186  PARTITION BY part_strategy '(' part_params ')'
4187  {
4188  $$ = cat_str(5,mm_strdup("partition by"),$3,mm_strdup("("),$5,mm_strdup(")"));
4189 }
4190 ;
4191 
4192 
4193  part_strategy:
4194  ecpg_ident
4195  {
4196  $$ = $1;
4197 }
4198 |  unreserved_keyword
4199  {
4200  $$ = $1;
4201 }
4202 ;
4203 
4204 
4205  part_params:
4206  part_elem
4207  {
4208  $$ = $1;
4209 }
4210 |  part_params ',' part_elem
4211  {
4212  $$ = cat_str(3,$1,mm_strdup(","),$3);
4213 }
4214 ;
4215 
4216 
4217  part_elem:
4218  ColId opt_collate opt_class
4219  {
4220  $$ = cat_str(3,$1,$2,$3);
4221 }
4222 |  func_expr_windowless opt_collate opt_class
4223  {
4224  $$ = cat_str(3,$1,$2,$3);
4225 }
4226 |  '(' a_expr ')' opt_collate opt_class
4227  {
4228  $$ = cat_str(5,mm_strdup("("),$2,mm_strdup(")"),$4,$5);
4229 }
4230 ;
4231 
4232 
4233  OptWith:
4234  WITH reloptions
4235  {
4236  $$ = cat_str(2,mm_strdup("with"),$2);
4237 }
4238 |  WITH OIDS
4239  {
4240  $$ = mm_strdup("with oids");
4241 }
4242 |  WITHOUT OIDS
4243  {
4244  $$ = mm_strdup("without oids");
4245 }
4246 |
4247  {
4248  $$=EMPTY; }
4249 ;
4250 
4251 
4252  OnCommitOption:
4253  ON COMMIT DROP
4254  {
4255  $$ = mm_strdup("on commit drop");
4256 }
4257 |  ON COMMIT DELETE_P ROWS
4258  {
4259  $$ = mm_strdup("on commit delete rows");
4260 }
4261 |  ON COMMIT PRESERVE ROWS
4262  {
4263  $$ = mm_strdup("on commit preserve rows");
4264 }
4265 |
4266  {
4267  $$=EMPTY; }
4268 ;
4269 
4270 
4271  OptTableSpace:
4272  TABLESPACE name
4273  {
4274  $$ = cat_str(2,mm_strdup("tablespace"),$2);
4275 }
4276 |
4277  {
4278  $$=EMPTY; }
4279 ;
4280 
4281 
4282  OptConsTableSpace:
4283  USING INDEX TABLESPACE name
4284  {
4285  $$ = cat_str(2,mm_strdup("using index tablespace"),$4);
4286 }
4287 |
4288  {
4289  $$=EMPTY; }
4290 ;
4291 
4292 
4293  ExistingIndex:
4294  USING INDEX index_name
4295  {
4296  $$ = cat_str(2,mm_strdup("using index"),$3);
4297 }
4298 ;
4299 
4300 
4301  CreateStatsStmt:
4302  CREATE STATISTICS any_name opt_name_list ON expr_list FROM from_list
4303  {
4304  $$ = cat_str(7,mm_strdup("create statistics"),$3,$4,mm_strdup("on"),$6,mm_strdup("from"),$8);
4305 }
4306 |  CREATE STATISTICS IF_P NOT EXISTS any_name opt_name_list ON expr_list FROM from_list
4307  {
4308  $$ = cat_str(7,mm_strdup("create statistics if not exists"),$6,$7,mm_strdup("on"),$9,mm_strdup("from"),$11);
4309 }
4310 ;
4311 
4312 
4313  create_as_target:
4314  qualified_name opt_column_list OptWith OnCommitOption OptTableSpace
4315  {
4316  $$ = cat_str(5,$1,$2,$3,$4,$5);
4317 }
4318 ;
4319 
4320 
4321  opt_with_data:
4322  WITH DATA_P
4323  {
4324  $$ = mm_strdup("with data");
4325 }
4326 |  WITH NO DATA_P
4327  {
4328  $$ = mm_strdup("with no data");
4329 }
4330 |
4331  {
4332  $$=EMPTY; }
4333 ;
4334 
4335 
4336  CreateMatViewStmt:
4337  CREATE OptNoLog MATERIALIZED VIEW create_mv_target AS SelectStmt opt_with_data
4338  {
4339  $$ = cat_str(7,mm_strdup("create"),$2,mm_strdup("materialized view"),$5,mm_strdup("as"),$7,$8);
4340 }
4341 |  CREATE OptNoLog MATERIALIZED VIEW IF_P NOT EXISTS create_mv_target AS SelectStmt opt_with_data
4342  {
4343  $$ = cat_str(7,mm_strdup("create"),$2,mm_strdup("materialized view if not exists"),$8,mm_strdup("as"),$10,$11);
4344 }
4345 ;
4346 
4347 
4348  create_mv_target:
4349  qualified_name opt_column_list opt_reloptions OptTableSpace
4350  {
4351  $$ = cat_str(4,$1,$2,$3,$4);
4352 }
4353 ;
4354 
4355 
4356  OptNoLog:
4357  UNLOGGED
4358  {
4359  $$ = mm_strdup("unlogged");
4360 }
4361 |
4362  {
4363  $$=EMPTY; }
4364 ;
4365 
4366 
4367  RefreshMatViewStmt:
4368  REFRESH MATERIALIZED VIEW opt_concurrently qualified_name opt_with_data
4369  {
4370  $$ = cat_str(4,mm_strdup("refresh materialized view"),$4,$5,$6);
4371 }
4372 ;
4373 
4374 
4375  CreateSeqStmt:
4376  CREATE OptTemp SEQUENCE qualified_name OptSeqOptList
4377  {
4378  $$ = cat_str(5,mm_strdup("create"),$2,mm_strdup("sequence"),$4,$5);
4379 }
4380 |  CREATE OptTemp SEQUENCE IF_P NOT EXISTS qualified_name OptSeqOptList
4381  {
4382  $$ = cat_str(5,mm_strdup("create"),$2,mm_strdup("sequence if not exists"),$7,$8);
4383 }
4384 ;
4385 
4386 
4387  AlterSeqStmt:
4388  ALTER SEQUENCE qualified_name SeqOptList
4389  {
4390  $$ = cat_str(3,mm_strdup("alter sequence"),$3,$4);
4391 }
4392 |  ALTER SEQUENCE IF_P EXISTS qualified_name SeqOptList
4393  {
4394  $$ = cat_str(3,mm_strdup("alter sequence if exists"),$5,$6);
4395 }
4396 ;
4397 
4398 
4399  OptSeqOptList:
4400  SeqOptList
4401  {
4402  $$ = $1;
4403 }
4404 |
4405  {
4406  $$=EMPTY; }
4407 ;
4408 
4409 
4410  OptParenthesizedSeqOptList:
4411  '(' SeqOptList ')'
4412  {
4413  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
4414 }
4415 |
4416  {
4417  $$=EMPTY; }
4418 ;
4419 
4420 
4421  SeqOptList:
4422  SeqOptElem
4423  {
4424  $$ = $1;
4425 }
4426 |  SeqOptList SeqOptElem
4427  {
4428  $$ = cat_str(2,$1,$2);
4429 }
4430 ;
4431 
4432 
4433  SeqOptElem:
4434  AS SimpleTypename
4435  {
4436  $$ = cat_str(2,mm_strdup("as"),$2);
4437 }
4438 |  CACHE NumericOnly
4439  {
4440  $$ = cat_str(2,mm_strdup("cache"),$2);
4441 }
4442 |  CYCLE
4443  {
4444  $$ = mm_strdup("cycle");
4445 }
4446 |  NO CYCLE
4447  {
4448  $$ = mm_strdup("no cycle");
4449 }
4450 |  INCREMENT opt_by NumericOnly
4451  {
4452  $$ = cat_str(3,mm_strdup("increment"),$2,$3);
4453 }
4454 |  MAXVALUE NumericOnly
4455  {
4456  $$ = cat_str(2,mm_strdup("maxvalue"),$2);
4457 }
4458 |  MINVALUE NumericOnly
4459  {
4460  $$ = cat_str(2,mm_strdup("minvalue"),$2);
4461 }
4462 |  NO MAXVALUE
4463  {
4464  $$ = mm_strdup("no maxvalue");
4465 }
4466 |  NO MINVALUE
4467  {
4468  $$ = mm_strdup("no minvalue");
4469 }
4470 |  OWNED BY any_name
4471  {
4472  $$ = cat_str(2,mm_strdup("owned by"),$3);
4473 }
4474 |  SEQUENCE NAME_P any_name
4475  {
4476  $$ = cat_str(2,mm_strdup("sequence name"),$3);
4477 }
4478 |  START opt_with NumericOnly
4479  {
4480  $$ = cat_str(3,mm_strdup("start"),$2,$3);
4481 }
4482 |  RESTART
4483  {
4484  $$ = mm_strdup("restart");
4485 }
4486 |  RESTART opt_with NumericOnly
4487  {
4488  $$ = cat_str(3,mm_strdup("restart"),$2,$3);
4489 }
4490 ;
4491 
4492 
4493  opt_by:
4494  BY
4495  {
4496  $$ = mm_strdup("by");
4497 }
4498 |
4499  {
4500  $$=EMPTY; }
4501 ;
4502 
4503 
4504  NumericOnly:
4505  ecpg_fconst
4506  {
4507  $$ = $1;
4508 }
4509 |  '+' ecpg_fconst
4510  {
4511  $$ = cat_str(2,mm_strdup("+"),$2);
4512 }
4513 |  '-' ecpg_fconst
4514  {
4515  $$ = cat_str(2,mm_strdup("-"),$2);
4516 }
4517 |  SignedIconst
4518  {
4519  $$ = $1;
4520 }
4521 ;
4522 
4523 
4524  NumericOnly_list:
4525  NumericOnly
4526  {
4527  $$ = $1;
4528 }
4529 |  NumericOnly_list ',' NumericOnly
4530  {
4531  $$ = cat_str(3,$1,mm_strdup(","),$3);
4532 }
4533 ;
4534 
4535 
4536  CreatePLangStmt:
4537  CREATE opt_or_replace opt_trusted opt_procedural LANGUAGE NonReservedWord_or_Sconst
4538  {
4539  $$ = cat_str(6,mm_strdup("create"),$2,$3,$4,mm_strdup("language"),$6);
4540 }
4541 |  CREATE opt_or_replace opt_trusted opt_procedural LANGUAGE NonReservedWord_or_Sconst HANDLER handler_name opt_inline_handler opt_validator
4542  {
4543  $$ = cat_str(10,mm_strdup("create"),$2,$3,$4,mm_strdup("language"),$6,mm_strdup("handler"),$8,$9,$10);
4544 }
4545 ;
4546 
4547 
4548  opt_trusted:
4549  TRUSTED
4550  {
4551  $$ = mm_strdup("trusted");
4552 }
4553 |
4554  {
4555  $$=EMPTY; }
4556 ;
4557 
4558 
4559  handler_name:
4560  name
4561  {
4562  $$ = $1;
4563 }
4564 |  name attrs
4565  {
4566  $$ = cat_str(2,$1,$2);
4567 }
4568 ;
4569 
4570 
4571  opt_inline_handler:
4572  INLINE_P handler_name
4573  {
4574  $$ = cat_str(2,mm_strdup("inline"),$2);
4575 }
4576 |
4577  {
4578  $$=EMPTY; }
4579 ;
4580 
4581 
4582  validator_clause:
4583  VALIDATOR handler_name
4584  {
4585  $$ = cat_str(2,mm_strdup("validator"),$2);
4586 }
4587 |  NO VALIDATOR
4588  {
4589  $$ = mm_strdup("no validator");
4590 }
4591 ;
4592 
4593 
4594  opt_validator:
4595  validator_clause
4596  {
4597  $$ = $1;
4598 }
4599 |
4600  {
4601  $$=EMPTY; }
4602 ;
4603 
4604 
4605  DropPLangStmt:
4606  DROP opt_procedural LANGUAGE NonReservedWord_or_Sconst opt_drop_behavior
4607  {
4608  $$ = cat_str(5,mm_strdup("drop"),$2,mm_strdup("language"),$4,$5);
4609 }
4610 |  DROP opt_procedural LANGUAGE IF_P EXISTS NonReservedWord_or_Sconst opt_drop_behavior
4611  {
4612  $$ = cat_str(5,mm_strdup("drop"),$2,mm_strdup("language if exists"),$6,$7);
4613 }
4614 ;
4615 
4616 
4617  opt_procedural:
4618  PROCEDURAL
4619  {
4620  $$ = mm_strdup("procedural");
4621 }
4622 |
4623  {
4624  $$=EMPTY; }
4625 ;
4626 
4627 
4628  CreateTableSpaceStmt:
4629  CREATE TABLESPACE name OptTableSpaceOwner LOCATION ecpg_sconst opt_reloptions
4630  {
4631  $$ = cat_str(6,mm_strdup("create tablespace"),$3,$4,mm_strdup("location"),$6,$7);
4632 }
4633 ;
4634 
4635 
4636  OptTableSpaceOwner:
4637  OWNER RoleSpec
4638  {
4639  $$ = cat_str(2,mm_strdup("owner"),$2);
4640 }
4641 |
4642  {
4643  $$=EMPTY; }
4644 ;
4645 
4646 
4647  DropTableSpaceStmt:
4648  DROP TABLESPACE name
4649  {
4650  $$ = cat_str(2,mm_strdup("drop tablespace"),$3);
4651 }
4652 |  DROP TABLESPACE IF_P EXISTS name
4653  {
4654  $$ = cat_str(2,mm_strdup("drop tablespace if exists"),$5);
4655 }
4656 ;
4657 
4658 
4659  CreateExtensionStmt:
4660  CREATE EXTENSION name opt_with create_extension_opt_list
4661  {
4662  $$ = cat_str(4,mm_strdup("create extension"),$3,$4,$5);
4663 }
4664 |  CREATE EXTENSION IF_P NOT EXISTS name opt_with create_extension_opt_list
4665  {
4666  $$ = cat_str(4,mm_strdup("create extension if not exists"),$6,$7,$8);
4667 }
4668 ;
4669 
4670 
4671  create_extension_opt_list:
4672  create_extension_opt_list create_extension_opt_item
4673  {
4674  $$ = cat_str(2,$1,$2);
4675 }
4676 |
4677  {
4678  $$=EMPTY; }
4679 ;
4680 
4681 
4682  create_extension_opt_item:
4683  SCHEMA name
4684  {
4685  $$ = cat_str(2,mm_strdup("schema"),$2);
4686 }
4687 |  VERSION_P NonReservedWord_or_Sconst
4688  {
4689  $$ = cat_str(2,mm_strdup("version"),$2);
4690 }
4691 |  FROM NonReservedWord_or_Sconst
4692  {
4693  $$ = cat_str(2,mm_strdup("from"),$2);
4694 }
4695 |  CASCADE
4696  {
4697  $$ = mm_strdup("cascade");
4698 }
4699 ;
4700 
4701 
4702  AlterExtensionStmt:
4703  ALTER EXTENSION name UPDATE alter_extension_opt_list
4704  {
4705  $$ = cat_str(4,mm_strdup("alter extension"),$3,mm_strdup("update"),$5);
4706 }
4707 ;
4708 
4709 
4710  alter_extension_opt_list:
4711  alter_extension_opt_list alter_extension_opt_item
4712  {
4713  $$ = cat_str(2,$1,$2);
4714 }
4715 |
4716  {
4717  $$=EMPTY; }
4718 ;
4719 
4720 
4721  alter_extension_opt_item:
4722  TO NonReservedWord_or_Sconst
4723  {
4724  $$ = cat_str(2,mm_strdup("to"),$2);
4725 }
4726 ;
4727 
4728 
4729  AlterExtensionContentsStmt:
4730  ALTER EXTENSION name add_drop ACCESS METHOD name
4731  {
4732  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("access method"),$7);
4733 }
4734 |  ALTER EXTENSION name add_drop AGGREGATE aggregate_with_argtypes
4735  {
4736  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("aggregate"),$6);
4737 }
4738 |  ALTER EXTENSION name add_drop CAST '(' Typename AS Typename ')'
4739  {
4740  $$ = cat_str(8,mm_strdup("alter extension"),$3,$4,mm_strdup("cast ("),$7,mm_strdup("as"),$9,mm_strdup(")"));
4741 }
4742 |  ALTER EXTENSION name add_drop COLLATION any_name
4743  {
4744  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("collation"),$6);
4745 }
4746 |  ALTER EXTENSION name add_drop CONVERSION_P any_name
4747  {
4748  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("conversion"),$6);
4749 }
4750 |  ALTER EXTENSION name add_drop DOMAIN_P Typename
4751  {
4752  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("domain"),$6);
4753 }
4754 |  ALTER EXTENSION name add_drop FUNCTION function_with_argtypes
4755  {
4756  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("function"),$6);
4757 }
4758 |  ALTER EXTENSION name add_drop opt_procedural LANGUAGE name
4759  {
4760  $$ = cat_str(6,mm_strdup("alter extension"),$3,$4,$5,mm_strdup("language"),$7);
4761 }
4762 |  ALTER EXTENSION name add_drop OPERATOR operator_with_argtypes
4763  {
4764  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("operator"),$6);
4765 }
4766 |  ALTER EXTENSION name add_drop OPERATOR CLASS any_name USING access_method
4767  {
4768  $$ = cat_str(7,mm_strdup("alter extension"),$3,$4,mm_strdup("operator class"),$7,mm_strdup("using"),$9);
4769 }
4770 |  ALTER EXTENSION name add_drop OPERATOR FAMILY any_name USING access_method
4771  {
4772  $$ = cat_str(7,mm_strdup("alter extension"),$3,$4,mm_strdup("operator family"),$7,mm_strdup("using"),$9);
4773 }
4774 |  ALTER EXTENSION name add_drop PROCEDURE function_with_argtypes
4775  {
4776  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("procedure"),$6);
4777 }
4778 |  ALTER EXTENSION name add_drop ROUTINE function_with_argtypes
4779  {
4780  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("routine"),$6);
4781 }
4782 |  ALTER EXTENSION name add_drop SCHEMA name
4783  {
4784  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("schema"),$6);
4785 }
4786 |  ALTER EXTENSION name add_drop EVENT TRIGGER name
4787  {
4788  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("event trigger"),$7);
4789 }
4790 |  ALTER EXTENSION name add_drop TABLE any_name
4791  {
4792  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("table"),$6);
4793 }
4794 |  ALTER EXTENSION name add_drop TEXT_P SEARCH PARSER any_name
4795  {
4796  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("text search parser"),$8);
4797 }
4798 |  ALTER EXTENSION name add_drop TEXT_P SEARCH DICTIONARY any_name
4799  {
4800  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("text search dictionary"),$8);
4801 }
4802 |  ALTER EXTENSION name add_drop TEXT_P SEARCH TEMPLATE any_name
4803  {
4804  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("text search template"),$8);
4805 }
4806 |  ALTER EXTENSION name add_drop TEXT_P SEARCH CONFIGURATION any_name
4807  {
4808  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("text search configuration"),$8);
4809 }
4810 |  ALTER EXTENSION name add_drop SEQUENCE any_name
4811  {
4812  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("sequence"),$6);
4813 }
4814 |  ALTER EXTENSION name add_drop VIEW any_name
4815  {
4816  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("view"),$6);
4817 }
4818 |  ALTER EXTENSION name add_drop MATERIALIZED VIEW any_name
4819  {
4820  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("materialized view"),$7);
4821 }
4822 |  ALTER EXTENSION name add_drop FOREIGN TABLE any_name
4823  {
4824  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("foreign table"),$7);
4825 }
4826 |  ALTER EXTENSION name add_drop FOREIGN DATA_P WRAPPER name
4827  {
4828  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("foreign data wrapper"),$8);
4829 }
4830 |  ALTER EXTENSION name add_drop SERVER name
4831  {
4832  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("server"),$6);
4833 }
4834 |  ALTER EXTENSION name add_drop TRANSFORM FOR Typename LANGUAGE name
4835  {
4836  $$ = cat_str(7,mm_strdup("alter extension"),$3,$4,mm_strdup("transform for"),$7,mm_strdup("language"),$9);
4837 }
4838 |  ALTER EXTENSION name add_drop TYPE_P Typename
4839  {
4840  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("type"),$6);
4841 }
4842 ;
4843 
4844 
4845  CreateFdwStmt:
4846  CREATE FOREIGN DATA_P WRAPPER name opt_fdw_options create_generic_options
4847  {
4848  $$ = cat_str(4,mm_strdup("create foreign data wrapper"),$5,$6,$7);
4849 }
4850 ;
4851 
4852 
4853  fdw_option:
4854  HANDLER handler_name
4855  {
4856  $$ = cat_str(2,mm_strdup("handler"),$2);
4857 }
4858 |  NO HANDLER
4859  {
4860  $$ = mm_strdup("no handler");
4861 }
4862 |  VALIDATOR handler_name
4863  {
4864  $$ = cat_str(2,mm_strdup("validator"),$2);
4865 }
4866 |  NO VALIDATOR
4867  {
4868  $$ = mm_strdup("no validator");
4869 }
4870 ;
4871 
4872 
4873  fdw_options:
4874  fdw_option
4875  {
4876  $$ = $1;
4877 }
4878 |  fdw_options fdw_option
4879  {
4880  $$ = cat_str(2,$1,$2);
4881 }
4882 ;
4883 
4884 
4885  opt_fdw_options:
4886  fdw_options
4887  {
4888  $$ = $1;
4889 }
4890 |
4891  {
4892  $$=EMPTY; }
4893 ;
4894 
4895 
4896  AlterFdwStmt:
4897  ALTER FOREIGN DATA_P WRAPPER name opt_fdw_options alter_generic_options
4898  {
4899  $$ = cat_str(4,mm_strdup("alter foreign data wrapper"),$5,$6,$7);
4900 }
4901 |  ALTER FOREIGN DATA_P WRAPPER name fdw_options
4902  {
4903  $$ = cat_str(3,mm_strdup("alter foreign data wrapper"),$5,$6);
4904 }
4905 ;
4906 
4907 
4908  create_generic_options:
4909  OPTIONS '(' generic_option_list ')'
4910  {
4911  $$ = cat_str(3,mm_strdup("options ("),$3,mm_strdup(")"));
4912 }
4913 |
4914  {
4915  $$=EMPTY; }
4916 ;
4917 
4918 
4919  generic_option_list:
4920  generic_option_elem
4921  {
4922  $$ = $1;
4923 }
4924 |  generic_option_list ',' generic_option_elem
4925  {
4926  $$ = cat_str(3,$1,mm_strdup(","),$3);
4927 }
4928 ;
4929 
4930 
4931  alter_generic_options:
4932  OPTIONS '(' alter_generic_option_list ')'
4933  {
4934  $$ = cat_str(3,mm_strdup("options ("),$3,mm_strdup(")"));
4935 }
4936 ;
4937 
4938 
4939  alter_generic_option_list:
4940  alter_generic_option_elem
4941  {
4942  $$ = $1;
4943 }
4944 |  alter_generic_option_list ',' alter_generic_option_elem
4945  {
4946  $$ = cat_str(3,$1,mm_strdup(","),$3);
4947 }
4948 ;
4949 
4950 
4951  alter_generic_option_elem:
4952  generic_option_elem
4953  {
4954  $$ = $1;
4955 }
4956 |  SET generic_option_elem
4957  {
4958  $$ = cat_str(2,mm_strdup("set"),$2);
4959 }
4960 |  ADD_P generic_option_elem
4961  {
4962  $$ = cat_str(2,mm_strdup("add"),$2);
4963 }
4964 |  DROP generic_option_name
4965  {
4966  $$ = cat_str(2,mm_strdup("drop"),$2);
4967 }
4968 ;
4969 
4970 
4971  generic_option_elem:
4972  generic_option_name generic_option_arg
4973  {
4974  $$ = cat_str(2,$1,$2);
4975 }
4976 ;
4977 
4978 
4979  generic_option_name:
4980  ColLabel
4981  {
4982  $$ = $1;
4983 }
4984 ;
4985 
4986 
4987  generic_option_arg:
4988  ecpg_sconst
4989  {
4990  $$ = $1;
4991 }
4992 ;
4993 
4994 
4995  CreateForeignServerStmt:
4996  CREATE SERVER name opt_type opt_foreign_server_version FOREIGN DATA_P WRAPPER name create_generic_options
4997  {
4998  $$ = cat_str(7,mm_strdup("create server"),$3,$4,$5,mm_strdup("foreign data wrapper"),$9,$10);
4999 }
5000 |  CREATE SERVER IF_P NOT EXISTS name opt_type opt_foreign_server_version FOREIGN DATA_P WRAPPER name create_generic_options
5001  {
5002  $$ = cat_str(7,mm_strdup("create server if not exists"),$6,$7,$8,mm_strdup("foreign data wrapper"),$12,$13);
5003 }
5004 ;
5005 
5006 
5007  opt_type:
5008  TYPE_P ecpg_sconst
5009  {
5010  $$ = cat_str(2,mm_strdup("type"),$2);
5011 }
5012 |
5013  {
5014  $$=EMPTY; }
5015 ;
5016 
5017 
5018  foreign_server_version:
5019  VERSION_P ecpg_sconst
5020  {
5021  $$ = cat_str(2,mm_strdup("version"),$2);
5022 }
5023 |  VERSION_P NULL_P
5024  {
5025  $$ = mm_strdup("version null");
5026 }
5027 ;
5028 
5029 
5030  opt_foreign_server_version:
5031  foreign_server_version
5032  {
5033  $$ = $1;
5034 }
5035 |
5036  {
5037  $$=EMPTY; }
5038 ;
5039 
5040 
5041  AlterForeignServerStmt:
5042  ALTER SERVER name foreign_server_version alter_generic_options
5043  {
5044  $$ = cat_str(4,mm_strdup("alter server"),$3,$4,$5);
5045 }
5046 |  ALTER SERVER name foreign_server_version
5047  {
5048  $$ = cat_str(3,mm_strdup("alter server"),$3,$4);
5049 }
5050 |  ALTER SERVER name alter_generic_options
5051  {
5052  $$ = cat_str(3,mm_strdup("alter server"),$3,$4);
5053 }
5054 ;
5055 
5056 
5057  CreateForeignTableStmt:
5058  CREATE FOREIGN TABLE qualified_name '(' OptTableElementList ')' OptInherit SERVER name create_generic_options
5059  {
5060  $$ = cat_str(9,mm_strdup("create foreign table"),$4,mm_strdup("("),$6,mm_strdup(")"),$8,mm_strdup("server"),$10,$11);
5061 }
5062 |  CREATE FOREIGN TABLE IF_P NOT EXISTS qualified_name '(' OptTableElementList ')' OptInherit SERVER name create_generic_options
5063  {
5064  $$ = cat_str(9,mm_strdup("create foreign table if not exists"),$7,mm_strdup("("),$9,mm_strdup(")"),$11,mm_strdup("server"),$13,$14);
5065 }
5066 |  CREATE FOREIGN TABLE qualified_name PARTITION OF qualified_name OptTypedTableElementList PartitionBoundSpec SERVER name create_generic_options
5067  {
5068  $$ = cat_str(9,mm_strdup("create foreign table"),$4,mm_strdup("partition of"),$7,$8,$9,mm_strdup("server"),$11,$12);
5069 }
5070 |  CREATE FOREIGN TABLE IF_P NOT EXISTS qualified_name PARTITION OF qualified_name OptTypedTableElementList PartitionBoundSpec SERVER name create_generic_options
5071  {
5072  $$ = cat_str(9,mm_strdup("create foreign table if not exists"),$7,mm_strdup("partition of"),$10,$11,$12,mm_strdup("server"),$14,$15);
5073 }
5074 ;
5075 
5076 
5077  AlterForeignTableStmt:
5078  ALTER FOREIGN TABLE relation_expr alter_table_cmds
5079  {
5080  $$ = cat_str(3,mm_strdup("alter foreign table"),$4,$5);
5081 }
5082 |  ALTER FOREIGN TABLE IF_P EXISTS relation_expr alter_table_cmds
5083  {
5084  $$ = cat_str(3,mm_strdup("alter foreign table if exists"),$6,$7);
5085 }
5086 ;
5087 
5088 
5089  ImportForeignSchemaStmt:
5090  IMPORT_P FOREIGN SCHEMA name import_qualification FROM SERVER name INTO name create_generic_options
5091  {
5092  $$ = cat_str(8,mm_strdup("import foreign schema"),$4,$5,mm_strdup("from server"),$8,mm_strdup("into"),$10,$11);
5093 }
5094 ;
5095 
5096 
5097  import_qualification_type:
5098  LIMIT TO
5099  {
5100  $$ = mm_strdup("limit to");
5101 }
5102 |  EXCEPT
5103  {
5104  $$ = mm_strdup("except");
5105 }
5106 ;
5107 
5108 
5109  import_qualification:
5110  import_qualification_type '(' relation_expr_list ')'
5111  {
5112  $$ = cat_str(4,$1,mm_strdup("("),$3,mm_strdup(")"));
5113 }
5114 |
5115  {
5116  $$=EMPTY; }
5117 ;
5118 
5119 
5120  CreateUserMappingStmt:
5121  CREATE USER MAPPING FOR auth_ident SERVER name create_generic_options
5122  {
5123  $$ = cat_str(5,mm_strdup("create user mapping for"),$5,mm_strdup("server"),$7,$8);
5124 }
5125 |  CREATE USER MAPPING IF_P NOT EXISTS FOR auth_ident SERVER name create_generic_options
5126  {
5127  $$ = cat_str(5,mm_strdup("create user mapping if not exists for"),$8,mm_strdup("server"),$10,$11);
5128 }
5129 ;
5130 
5131 
5132  auth_ident:
5133  RoleSpec
5134  {
5135  $$ = $1;
5136 }
5137 |  USER
5138  {
5139  $$ = mm_strdup("user");
5140 }
5141 ;
5142 
5143 
5144  DropUserMappingStmt:
5145  DROP USER MAPPING FOR auth_ident SERVER name
5146  {
5147  $$ = cat_str(4,mm_strdup("drop user mapping for"),$5,mm_strdup("server"),$7);
5148 }
5149 |  DROP USER MAPPING IF_P EXISTS FOR auth_ident SERVER name
5150  {
5151  $$ = cat_str(4,mm_strdup("drop user mapping if exists for"),$7,mm_strdup("server"),$9);
5152 }
5153 ;
5154 
5155 
5156  AlterUserMappingStmt:
5157  ALTER USER MAPPING FOR auth_ident SERVER name alter_generic_options
5158  {
5159  $$ = cat_str(5,mm_strdup("alter user mapping for"),$5,mm_strdup("server"),$7,$8);
5160 }
5161 ;
5162 
5163 
5164  CreatePolicyStmt:
5165  CREATE POLICY name ON qualified_name RowSecurityDefaultPermissive RowSecurityDefaultForCmd RowSecurityDefaultToRole RowSecurityOptionalExpr RowSecurityOptionalWithCheck
5166  {
5167  $$ = cat_str(9,mm_strdup("create policy"),$3,mm_strdup("on"),$5,$6,$7,$8,$9,$10);
5168 }
5169 ;
5170 
5171 
5172  AlterPolicyStmt:
5173  ALTER POLICY name ON qualified_name RowSecurityOptionalToRole RowSecurityOptionalExpr RowSecurityOptionalWithCheck
5174  {
5175  $$ = cat_str(7,mm_strdup("alter policy"),$3,mm_strdup("on"),$5,$6,$7,$8);
5176 }
5177 ;
5178 
5179 
5180  RowSecurityOptionalExpr:
5181  USING '(' a_expr ')'
5182  {
5183  $$ = cat_str(3,mm_strdup("using ("),$3,mm_strdup(")"));
5184 }
5185 |
5186  {
5187  $$=EMPTY; }
5188 ;
5189 
5190 
5191  RowSecurityOptionalWithCheck:
5192  WITH CHECK '(' a_expr ')'
5193  {
5194  $$ = cat_str(3,mm_strdup("with check ("),$4,mm_strdup(")"));
5195 }
5196 |
5197  {
5198  $$=EMPTY; }
5199 ;
5200 
5201 
5202  RowSecurityDefaultToRole:
5203  TO role_list
5204  {
5205  $$ = cat_str(2,mm_strdup("to"),$2);
5206 }
5207 |
5208  {
5209  $$=EMPTY; }
5210 ;
5211 
5212 
5213  RowSecurityOptionalToRole:
5214  TO role_list
5215  {
5216  $$ = cat_str(2,mm_strdup("to"),$2);
5217 }
5218 |
5219  {
5220  $$=EMPTY; }
5221 ;
5222 
5223 
5224  RowSecurityDefaultPermissive:
5225  AS ecpg_ident
5226  {
5227  $$ = cat_str(2,mm_strdup("as"),$2);
5228 }
5229 |
5230  {
5231  $$=EMPTY; }
5232 ;
5233 
5234 
5235  RowSecurityDefaultForCmd:
5236  FOR row_security_cmd
5237  {
5238  $$ = cat_str(2,mm_strdup("for"),$2);
5239 }
5240 |
5241  {
5242  $$=EMPTY; }
5243 ;
5244 
5245 
5246  row_security_cmd:
5247  ALL
5248  {
5249  $$ = mm_strdup("all");
5250 }
5251 |  SELECT
5252  {
5253  $$ = mm_strdup("select");
5254 }
5255 |  INSERT
5256  {
5257  $$ = mm_strdup("insert");
5258 }
5259 |  UPDATE
5260  {
5261  $$ = mm_strdup("update");
5262 }
5263 |  DELETE_P
5264  {
5265  $$ = mm_strdup("delete");
5266 }
5267 ;
5268 
5269 
5270  CreateAmStmt:
5271  CREATE ACCESS METHOD name TYPE_P INDEX HANDLER handler_name
5272  {
5273  $$ = cat_str(4,mm_strdup("create access method"),$4,mm_strdup("type index handler"),$8);
5274 }
5275 ;
5276 
5277 
5278  CreateTrigStmt:
5279  CREATE TRIGGER name TriggerActionTime TriggerEvents ON qualified_name TriggerReferencing TriggerForSpec TriggerWhen EXECUTE FUNCTION_or_PROCEDURE func_name '(' TriggerFuncArgs ')'
5280  {
5281  $$ = 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(")"));
5282 }
5283 |  CREATE CONSTRAINT TRIGGER name AFTER TriggerEvents ON qualified_name OptConstrFromTable ConstraintAttributeSpec FOR EACH ROW TriggerWhen EXECUTE FUNCTION_or_PROCEDURE func_name '(' TriggerFuncArgs ')'
5284  {
5285  $$ = 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(")"));
5286 }
5287 ;
5288 
5289 
5290  TriggerActionTime:
5291  BEFORE
5292  {
5293  $$ = mm_strdup("before");
5294 }
5295 |  AFTER
5296  {
5297  $$ = mm_strdup("after");
5298 }
5299 |  INSTEAD OF
5300  {
5301  $$ = mm_strdup("instead of");
5302 }
5303 ;
5304 
5305 
5306  TriggerEvents:
5307  TriggerOneEvent
5308  {
5309  $$ = $1;
5310 }
5311 |  TriggerEvents OR TriggerOneEvent
5312  {
5313  $$ = cat_str(3,$1,mm_strdup("or"),$3);
5314 }
5315 ;
5316 
5317 
5318  TriggerOneEvent:
5319  INSERT
5320  {
5321  $$ = mm_strdup("insert");
5322 }
5323 |  DELETE_P
5324  {
5325  $$ = mm_strdup("delete");
5326 }
5327 |  UPDATE
5328  {
5329  $$ = mm_strdup("update");
5330 }
5331 |  UPDATE OF columnList
5332  {
5333  $$ = cat_str(2,mm_strdup("update of"),$3);
5334 }
5335 |  TRUNCATE
5336  {
5337  $$ = mm_strdup("truncate");
5338 }
5339 ;
5340 
5341 
5342  TriggerReferencing:
5343  REFERENCING TriggerTransitions
5344  {
5345  $$ = cat_str(2,mm_strdup("referencing"),$2);
5346 }
5347 |
5348  {
5349  $$=EMPTY; }
5350 ;
5351 
5352 
5353  TriggerTransitions:
5354  TriggerTransition
5355  {
5356  $$ = $1;
5357 }
5358 |  TriggerTransitions TriggerTransition
5359  {
5360  $$ = cat_str(2,$1,$2);
5361 }
5362 ;
5363 
5364 
5365  TriggerTransition:
5366  TransitionOldOrNew TransitionRowOrTable opt_as TransitionRelName
5367  {
5368  $$ = cat_str(4,$1,$2,$3,$4);
5369 }
5370 ;
5371 
5372 
5373  TransitionOldOrNew:
5374  NEW
5375  {
5376  $$ = mm_strdup("new");
5377 }
5378 |  OLD
5379  {
5380  $$ = mm_strdup("old");
5381 }
5382 ;
5383 
5384 
5385  TransitionRowOrTable:
5386  TABLE
5387  {
5388  $$ = mm_strdup("table");
5389 }
5390 |  ROW
5391  {
5392  $$ = mm_strdup("row");
5393 }
5394 ;
5395 
5396 
5397  TransitionRelName:
5398  ColId
5399  {
5400  $$ = $1;
5401 }
5402 ;
5403 
5404 
5405  TriggerForSpec:
5406  FOR TriggerForOptEach TriggerForType
5407  {
5408  $$ = cat_str(3,mm_strdup("for"),$2,$3);
5409 }
5410 |
5411  {
5412  $$=EMPTY; }
5413 ;
5414 
5415 
5416  TriggerForOptEach:
5417  EACH
5418  {
5419  $$ = mm_strdup("each");
5420 }
5421 |
5422  {
5423  $$=EMPTY; }
5424 ;
5425 
5426 
5427  TriggerForType:
5428  ROW
5429  {
5430  $$ = mm_strdup("row");
5431 }
5432 |  STATEMENT
5433  {
5434  $$ = mm_strdup("statement");
5435 }
5436 ;
5437 
5438 
5439  TriggerWhen:
5440  WHEN '(' a_expr ')'
5441  {
5442  $$ = cat_str(3,mm_strdup("when ("),$3,mm_strdup(")"));
5443 }
5444 |
5445  {
5446  $$=EMPTY; }
5447 ;
5448 
5449 
5450  FUNCTION_or_PROCEDURE:
5451  FUNCTION
5452  {
5453  $$ = mm_strdup("function");
5454 }
5455 |  PROCEDURE
5456  {
5457  $$ = mm_strdup("procedure");
5458 }
5459 ;
5460 
5461 
5462  TriggerFuncArgs:
5463  TriggerFuncArg
5464  {
5465  $$ = $1;
5466 }
5467 |  TriggerFuncArgs ',' TriggerFuncArg
5468  {
5469  $$ = cat_str(3,$1,mm_strdup(","),$3);
5470 }
5471 |
5472  {
5473  $$=EMPTY; }
5474 ;
5475 
5476 
5477  TriggerFuncArg:
5478  Iconst
5479  {
5480  $$ = $1;
5481 }
5482 |  ecpg_fconst
5483  {
5484  $$ = $1;
5485 }
5486 |  ecpg_sconst
5487  {
5488  $$ = $1;
5489 }
5490 |  ColLabel
5491  {
5492  $$ = $1;
5493 }
5494 ;
5495 
5496 
5497  OptConstrFromTable:
5498  FROM qualified_name
5499  {
5500  $$ = cat_str(2,mm_strdup("from"),$2);
5501 }
5502 |
5503  {
5504  $$=EMPTY; }
5505 ;
5506 
5507 
5508  ConstraintAttributeSpec:
5509 
5510  {
5511  $$=EMPTY; }
5512 |  ConstraintAttributeSpec ConstraintAttributeElem
5513  {
5514  $$ = cat_str(2,$1,$2);
5515 }
5516 ;
5517 
5518 
5519  ConstraintAttributeElem:
5520  NOT DEFERRABLE
5521  {
5522  $$ = mm_strdup("not deferrable");
5523 }
5524 |  DEFERRABLE
5525  {
5526  $$ = mm_strdup("deferrable");
5527 }
5528 |  INITIALLY IMMEDIATE
5529  {
5530  $$ = mm_strdup("initially immediate");
5531 }
5532 |  INITIALLY DEFERRED
5533  {
5534  $$ = mm_strdup("initially deferred");
5535 }
5536 |  NOT VALID
5537  {
5538  $$ = mm_strdup("not valid");
5539 }
5540 |  NO INHERIT
5541  {
5542  $$ = mm_strdup("no inherit");
5543 }
5544 ;
5545 
5546 
5547  CreateEventTrigStmt:
5548  CREATE EVENT TRIGGER name ON ColLabel EXECUTE FUNCTION_or_PROCEDURE func_name '(' ')'
5549  {
5550  $$ = cat_str(8,mm_strdup("create event trigger"),$4,mm_strdup("on"),$6,mm_strdup("execute"),$8,$9,mm_strdup("( )"));
5551 }
5552 |  CREATE EVENT TRIGGER name ON ColLabel WHEN event_trigger_when_list EXECUTE FUNCTION_or_PROCEDURE func_name '(' ')'
5553  {
5554  $$ = cat_str(10,mm_strdup("create event trigger"),$4,mm_strdup("on"),$6,mm_strdup("when"),$8,mm_strdup("execute"),$10,$11,mm_strdup("( )"));
5555 }
5556 ;
5557 
5558 
5559  event_trigger_when_list:
5560  event_trigger_when_item
5561  {
5562  $$ = $1;
5563 }
5564 |  event_trigger_when_list AND event_trigger_when_item
5565  {
5566  $$ = cat_str(3,$1,mm_strdup("and"),$3);
5567 }
5568 ;
5569 
5570 
5571  event_trigger_when_item:
5572  ColId IN_P '(' event_trigger_value_list ')'
5573  {
5574  $$ = cat_str(4,$1,mm_strdup("in ("),$4,mm_strdup(")"));
5575 }
5576 ;
5577 
5578 
5579  event_trigger_value_list:
5580  SCONST
5581  {
5582  $$ = mm_strdup("sconst");
5583 }
5584 |  event_trigger_value_list ',' SCONST
5585  {
5586  $$ = cat_str(2,$1,mm_strdup(", sconst"));
5587 }
5588 ;
5589 
5590 
5591  AlterEventTrigStmt:
5592  ALTER EVENT TRIGGER name enable_trigger
5593  {
5594  $$ = cat_str(3,mm_strdup("alter event trigger"),$4,$5);
5595 }
5596 ;
5597 
5598 
5599  enable_trigger:
5600  ENABLE_P
5601  {
5602  $$ = mm_strdup("enable");
5603 }
5604 |  ENABLE_P REPLICA
5605  {
5606  $$ = mm_strdup("enable replica");
5607 }
5608 |  ENABLE_P ALWAYS
5609  {
5610  $$ = mm_strdup("enable always");
5611 }
5612 |  DISABLE_P
5613  {
5614  $$ = mm_strdup("disable");
5615 }
5616 ;
5617 
5618 
5619  CreateAssertStmt:
5620  CREATE ASSERTION name CHECK '(' a_expr ')' ConstraintAttributeSpec
5621  {
5622 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
5623  $$ = cat_str(6,mm_strdup("create assertion"),$3,mm_strdup("check ("),$6,mm_strdup(")"),$8);
5624 }
5625 ;
5626 
5627 
5628  DropAssertStmt:
5629  DROP ASSERTION name opt_drop_behavior
5630  {
5631 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
5632  $$ = cat_str(3,mm_strdup("drop assertion"),$3,$4);
5633 }
5634 ;
5635 
5636 
5637  DefineStmt:
5638  CREATE AGGREGATE func_name aggr_args definition
5639  {
5640  $$ = cat_str(4,mm_strdup("create aggregate"),$3,$4,$5);
5641 }
5642 |  CREATE AGGREGATE func_name old_aggr_definition
5643  {
5644  $$ = cat_str(3,mm_strdup("create aggregate"),$3,$4);
5645 }
5646 |  CREATE OPERATOR any_operator definition
5647  {
5648  $$ = cat_str(3,mm_strdup("create operator"),$3,$4);
5649 }
5650 |  CREATE TYPE_P any_name definition
5651  {
5652  $$ = cat_str(3,mm_strdup("create type"),$3,$4);
5653 }
5654 |  CREATE TYPE_P any_name
5655  {
5656  $$ = cat_str(2,mm_strdup("create type"),$3);
5657 }
5658 |  CREATE TYPE_P any_name AS '(' OptTableFuncElementList ')'
5659  {
5660  $$ = cat_str(5,mm_strdup("create type"),$3,mm_strdup("as ("),$6,mm_strdup(")"));
5661 }
5662 |  CREATE TYPE_P any_name AS ENUM_P '(' opt_enum_val_list ')'
5663  {
5664  $$ = cat_str(5,mm_strdup("create type"),$3,mm_strdup("as enum ("),$7,mm_strdup(")"));
5665 }
5666 |  CREATE TYPE_P any_name AS RANGE definition
5667  {
5668  $$ = cat_str(4,mm_strdup("create type"),$3,mm_strdup("as range"),$6);
5669 }
5670 |  CREATE TEXT_P SEARCH PARSER any_name definition
5671  {
5672  $$ = cat_str(3,mm_strdup("create text search parser"),$5,$6);
5673 }
5674 |  CREATE TEXT_P SEARCH DICTIONARY any_name definition
5675  {
5676  $$ = cat_str(3,mm_strdup("create text search dictionary"),$5,$6);
5677 }
5678 |  CREATE TEXT_P SEARCH TEMPLATE any_name definition
5679  {
5680  $$ = cat_str(3,mm_strdup("create text search template"),$5,$6);
5681 }
5682 |  CREATE TEXT_P SEARCH CONFIGURATION any_name definition
5683  {
5684  $$ = cat_str(3,mm_strdup("create text search configuration"),$5,$6);
5685 }
5686 |  CREATE COLLATION any_name definition
5687  {
5688  $$ = cat_str(3,mm_strdup("create collation"),$3,$4);
5689 }
5690 |  CREATE COLLATION IF_P NOT EXISTS any_name definition
5691  {
5692  $$ = cat_str(3,mm_strdup("create collation if not exists"),$6,$7);
5693 }
5694 |  CREATE COLLATION any_name FROM any_name
5695  {
5696  $$ = cat_str(4,mm_strdup("create collation"),$3,mm_strdup("from"),$5);
5697 }
5698 |  CREATE COLLATION IF_P NOT EXISTS any_name FROM any_name
5699  {
5700  $$ = cat_str(4,mm_strdup("create collation if not exists"),$6,mm_strdup("from"),$8);
5701 }
5702 ;
5703 
5704 
5705  definition:
5706  '(' def_list ')'
5707  {
5708  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
5709 }
5710 ;
5711 
5712 
5713  def_list:
5714  def_elem
5715  {
5716  $$ = $1;
5717 }
5718 |  def_list ',' def_elem
5719  {
5720  $$ = cat_str(3,$1,mm_strdup(","),$3);
5721 }
5722 ;
5723 
5724 
5725  def_elem:
5726  ColLabel '=' def_arg
5727  {
5728  $$ = cat_str(3,$1,mm_strdup("="),$3);
5729 }
5730 |  ColLabel
5731  {
5732  $$ = $1;
5733 }
5734 ;
5735 
5736 
5737  def_arg:
5738  func_type
5739  {
5740  $$ = $1;
5741 }
5742 |  reserved_keyword
5743  {
5744  $$ = $1;
5745 }
5746 |  qual_all_Op
5747  {
5748  $$ = $1;
5749 }
5750 |  NumericOnly
5751  {
5752  $$ = $1;
5753 }
5754 |  ecpg_sconst
5755  {
5756  $$ = $1;
5757 }
5758 |  NONE
5759  {
5760  $$ = mm_strdup("none");
5761 }
5762 ;
5763 
5764 
5765  old_aggr_definition:
5766  '(' old_aggr_list ')'
5767  {
5768  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
5769 }
5770 ;
5771 
5772 
5773  old_aggr_list:
5774  old_aggr_elem
5775  {
5776  $$ = $1;
5777 }
5778 |  old_aggr_list ',' old_aggr_elem
5779  {
5780  $$ = cat_str(3,$1,mm_strdup(","),$3);
5781 }
5782 ;
5783 
5784 
5785  old_aggr_elem:
5786  ecpg_ident '=' def_arg
5787  {
5788  $$ = cat_str(3,$1,mm_strdup("="),$3);
5789 }
5790 ;
5791 
5792 
5793  opt_enum_val_list:
5794  enum_val_list
5795  {
5796  $$ = $1;
5797 }
5798 |
5799  {
5800  $$=EMPTY; }
5801 ;
5802 
5803 
5804  enum_val_list:
5805  ecpg_sconst
5806  {
5807  $$ = $1;
5808 }
5809 |  enum_val_list ',' ecpg_sconst
5810  {
5811  $$ = cat_str(3,$1,mm_strdup(","),$3);
5812 }
5813 ;
5814 
5815 
5816  AlterEnumStmt:
5817  ALTER TYPE_P any_name ADD_P VALUE_P opt_if_not_exists ecpg_sconst
5818  {
5819  $$ = cat_str(5,mm_strdup("alter type"),$3,mm_strdup("add value"),$6,$7);
5820 }
5821 |  ALTER TYPE_P any_name ADD_P VALUE_P opt_if_not_exists ecpg_sconst BEFORE ecpg_sconst
5822  {
5823  $$ = cat_str(7,mm_strdup("alter type"),$3,mm_strdup("add value"),$6,$7,mm_strdup("before"),$9);
5824 }
5825 |  ALTER TYPE_P any_name ADD_P VALUE_P opt_if_not_exists ecpg_sconst AFTER ecpg_sconst
5826  {
5827  $$ = cat_str(7,mm_strdup("alter type"),$3,mm_strdup("add value"),$6,$7,mm_strdup("after"),$9);
5828 }
5829 |  ALTER TYPE_P any_name RENAME VALUE_P ecpg_sconst TO ecpg_sconst
5830  {
5831  $$ = cat_str(6,mm_strdup("alter type"),$3,mm_strdup("rename value"),$6,mm_strdup("to"),$8);
5832 }
5833 ;
5834 
5835 
5836  opt_if_not_exists:
5837  IF_P NOT EXISTS
5838  {
5839  $$ = mm_strdup("if not exists");
5840 }
5841 |
5842  {
5843  $$=EMPTY; }
5844 ;
5845 
5846 
5847  CreateOpClassStmt:
5848  CREATE OPERATOR CLASS any_name opt_default FOR TYPE_P Typename USING access_method opt_opfamily AS opclass_item_list
5849  {
5850  $$ = cat_str(10,mm_strdup("create operator class"),$4,$5,mm_strdup("for type"),$8,mm_strdup("using"),$10,$11,mm_strdup("as"),$13);
5851 }
5852 ;
5853 
5854 
5855  opclass_item_list:
5856  opclass_item
5857  {
5858  $$ = $1;
5859 }
5860 |  opclass_item_list ',' opclass_item
5861  {
5862  $$ = cat_str(3,$1,mm_strdup(","),$3);
5863 }
5864 ;
5865 
5866 
5867  opclass_item:
5868  OPERATOR Iconst any_operator opclass_purpose opt_recheck
5869  {
5870  $$ = cat_str(5,mm_strdup("operator"),$2,$3,$4,$5);
5871 }
5872 |  OPERATOR Iconst operator_with_argtypes opclass_purpose opt_recheck
5873  {
5874  $$ = cat_str(5,mm_strdup("operator"),$2,$3,$4,$5);
5875 }
5876 |  FUNCTION Iconst function_with_argtypes
5877  {
5878  $$ = cat_str(3,mm_strdup("function"),$2,$3);
5879 }
5880 |  FUNCTION Iconst '(' type_list ')' function_with_argtypes
5881  {
5882  $$ = cat_str(6,mm_strdup("function"),$2,mm_strdup("("),$4,mm_strdup(")"),$6);
5883 }
5884 |  STORAGE Typename
5885  {
5886  $$ = cat_str(2,mm_strdup("storage"),$2);
5887 }
5888 ;
5889 
5890 
5891  opt_default:
5892  DEFAULT
5893  {
5894  $$ = mm_strdup("default");
5895 }
5896 |
5897  {
5898  $$=EMPTY; }
5899 ;
5900 
5901 
5902  opt_opfamily:
5903  FAMILY any_name
5904  {
5905  $$ = cat_str(2,mm_strdup("family"),$2);
5906 }
5907 |
5908  {
5909  $$=EMPTY; }
5910 ;
5911 
5912 
5913  opclass_purpose:
5914  FOR SEARCH
5915  {
5916  $$ = mm_strdup("for search");
5917 }
5918 |  FOR ORDER BY any_name
5919  {
5920  $$ = cat_str(2,mm_strdup("for order by"),$4);
5921 }
5922 |
5923  {
5924  $$=EMPTY; }
5925 ;
5926 
5927 
5928  opt_recheck:
5929  RECHECK
5930  {
5931 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
5932  $$ = mm_strdup("recheck");
5933 }
5934 |
5935  {
5936  $$=EMPTY; }
5937 ;
5938 
5939 
5940  CreateOpFamilyStmt:
5941  CREATE OPERATOR FAMILY any_name USING access_method
5942  {
5943  $$ = cat_str(4,mm_strdup("create operator family"),$4,mm_strdup("using"),$6);
5944 }
5945 ;
5946 
5947 
5948  AlterOpFamilyStmt:
5949  ALTER OPERATOR FAMILY any_name USING access_method ADD_P opclass_item_list
5950  {
5951  $$ = cat_str(6,mm_strdup("alter operator family"),$4,mm_strdup("using"),$6,mm_strdup("add"),$8);
5952 }
5953 |  ALTER OPERATOR FAMILY any_name USING access_method DROP opclass_drop_list
5954  {
5955  $$ = cat_str(6,mm_strdup("alter operator family"),$4,mm_strdup("using"),$6,mm_strdup("drop"),$8);
5956 }
5957 ;
5958 
5959 
5960  opclass_drop_list:
5961  opclass_drop
5962  {
5963  $$ = $1;
5964 }
5965 |  opclass_drop_list ',' opclass_drop
5966  {
5967  $$ = cat_str(3,$1,mm_strdup(","),$3);
5968 }
5969 ;
5970 
5971 
5972  opclass_drop:
5973  OPERATOR Iconst '(' type_list ')'
5974  {
5975  $$ = cat_str(5,mm_strdup("operator"),$2,mm_strdup("("),$4,mm_strdup(")"));
5976 }
5977 |  FUNCTION Iconst '(' type_list ')'
5978  {
5979  $$ = cat_str(5,mm_strdup("function"),$2,mm_strdup("("),$4,mm_strdup(")"));
5980 }
5981 ;
5982 
5983 
5984  DropOpClassStmt:
5985  DROP OPERATOR CLASS any_name USING access_method opt_drop_behavior
5986  {
5987  $$ = cat_str(5,mm_strdup("drop operator class"),$4,mm_strdup("using"),$6,$7);
5988 }
5989 |  DROP OPERATOR CLASS IF_P EXISTS any_name USING access_method opt_drop_behavior
5990  {
5991  $$ = cat_str(5,mm_strdup("drop operator class if exists"),$6,mm_strdup("using"),$8,$9);
5992 }
5993 ;
5994 
5995 
5996  DropOpFamilyStmt:
5997  DROP OPERATOR FAMILY any_name USING access_method opt_drop_behavior
5998  {
5999  $$ = cat_str(5,mm_strdup("drop operator family"),$4,mm_strdup("using"),$6,$7);
6000 }
6001 |  DROP OPERATOR FAMILY IF_P EXISTS any_name USING access_method opt_drop_behavior
6002  {
6003  $$ = cat_str(5,mm_strdup("drop operator family if exists"),$6,mm_strdup("using"),$8,$9);
6004 }
6005 ;
6006 
6007 
6008  DropOwnedStmt:
6009  DROP OWNED BY role_list opt_drop_behavior
6010  {
6011  $$ = cat_str(3,mm_strdup("drop owned by"),$4,$5);
6012 }
6013 ;
6014 
6015 
6016  ReassignOwnedStmt:
6017  REASSIGN OWNED BY role_list TO RoleSpec
6018  {
6019  $$ = cat_str(4,mm_strdup("reassign owned by"),$4,mm_strdup("to"),$6);
6020 }
6021 ;
6022 
6023 
6024  DropStmt:
6025  DROP drop_type_any_name IF_P EXISTS any_name_list opt_drop_behavior
6026  {
6027  $$ = cat_str(5,mm_strdup("drop"),$2,mm_strdup("if exists"),$5,$6);
6028 }
6029 |  DROP drop_type_any_name any_name_list opt_drop_behavior
6030  {
6031  $$ = cat_str(4,mm_strdup("drop"),$2,$3,$4);
6032 }
6033 |  DROP drop_type_name IF_P EXISTS name_list opt_drop_behavior
6034  {
6035  $$ = cat_str(5,mm_strdup("drop"),$2,mm_strdup("if exists"),$5,$6);
6036 }
6037 |  DROP drop_type_name name_list opt_drop_behavior
6038  {
6039  $$ = cat_str(4,mm_strdup("drop"),$2,$3,$4);
6040 }
6041 |  DROP drop_type_name_on_any_name name ON any_name opt_drop_behavior
6042  {
6043  $$ = cat_str(6,mm_strdup("drop"),$2,$3,mm_strdup("on"),$5,$6);
6044 }
6045 |  DROP drop_type_name_on_any_name IF_P EXISTS name ON any_name opt_drop_behavior
6046  {
6047  $$ = cat_str(7,mm_strdup("drop"),$2,mm_strdup("if exists"),$5,mm_strdup("on"),$7,$8);
6048 }
6049 |  DROP TYPE_P type_name_list opt_drop_behavior
6050  {
6051  $$ = cat_str(3,mm_strdup("drop type"),$3,$4);
6052 }
6053 |  DROP TYPE_P IF_P EXISTS type_name_list opt_drop_behavior
6054  {
6055  $$ = cat_str(3,mm_strdup("drop type if exists"),$5,$6);
6056 }
6057 |  DROP DOMAIN_P type_name_list opt_drop_behavior
6058  {
6059  $$ = cat_str(3,mm_strdup("drop domain"),$3,$4);
6060 }
6061 |  DROP DOMAIN_P IF_P EXISTS type_name_list opt_drop_behavior
6062  {
6063  $$ = cat_str(3,mm_strdup("drop domain if exists"),$5,$6);
6064 }
6065 |  DROP INDEX CONCURRENTLY any_name_list opt_drop_behavior
6066  {
6067  $$ = cat_str(3,mm_strdup("drop index concurrently"),$4,$5);
6068 }
6069 |  DROP INDEX CONCURRENTLY IF_P EXISTS any_name_list opt_drop_behavior
6070  {
6071  $$ = cat_str(3,mm_strdup("drop index concurrently if exists"),$6,$7);
6072 }
6073 ;
6074 
6075 
6076  drop_type_any_name:
6077  TABLE
6078  {
6079  $$ = mm_strdup("table");
6080 }
6081 |  SEQUENCE
6082  {
6083  $$ = mm_strdup("sequence");
6084 }
6085 |  VIEW
6086  {
6087  $$ = mm_strdup("view");
6088 }
6089 |  MATERIALIZED VIEW
6090  {
6091  $$ = mm_strdup("materialized view");
6092 }
6093 |  INDEX
6094  {
6095  $$ = mm_strdup("index");
6096 }
6097 |  FOREIGN TABLE
6098  {
6099  $$ = mm_strdup("foreign table");
6100 }
6101 |  COLLATION
6102  {
6103  $$ = mm_strdup("collation");
6104 }
6105 |  CONVERSION_P
6106  {
6107  $$ = mm_strdup("conversion");
6108 }
6109 |  STATISTICS
6110  {
6111  $$ = mm_strdup("statistics");
6112 }
6113 |  TEXT_P SEARCH PARSER
6114  {
6115  $$ = mm_strdup("text search parser");
6116 }
6117 |  TEXT_P SEARCH DICTIONARY
6118  {
6119  $$ = mm_strdup("text search dictionary");
6120 }
6121 |  TEXT_P SEARCH TEMPLATE
6122  {
6123  $$ = mm_strdup("text search template");
6124 }
6125 |  TEXT_P SEARCH CONFIGURATION
6126  {
6127  $$ = mm_strdup("text search configuration");
6128 }
6129 ;
6130 
6131 
6132  drop_type_name:
6133  ACCESS METHOD
6134  {
6135  $$ = mm_strdup("access method");
6136 }
6137 |  EVENT TRIGGER
6138  {
6139  $$ = mm_strdup("event trigger");
6140 }
6141 |  EXTENSION
6142  {
6143  $$ = mm_strdup("extension");
6144 }
6145 |  FOREIGN DATA_P WRAPPER
6146  {
6147  $$ = mm_strdup("foreign data wrapper");
6148 }
6149 |  PUBLICATION
6150  {
6151  $$ = mm_strdup("publication");
6152 }
6153 |  SCHEMA
6154  {
6155  $$ = mm_strdup("schema");
6156 }
6157 |  SERVER
6158  {
6159  $$ = mm_strdup("server");
6160 }
6161 ;
6162 
6163 
6164  drop_type_name_on_any_name:
6165  POLICY
6166  {
6167  $$ = mm_strdup("policy");
6168 }
6169 |  RULE
6170  {
6171  $$ = mm_strdup("rule");
6172 }
6173 |  TRIGGER
6174  {
6175  $$ = mm_strdup("trigger");
6176 }
6177 ;
6178 
6179 
6180  any_name_list:
6181  any_name
6182  {
6183  $$ = $1;
6184 }
6185 |  any_name_list ',' any_name
6186  {
6187  $$ = cat_str(3,$1,mm_strdup(","),$3);
6188 }
6189 ;
6190 
6191 
6192  any_name:
6193  ColId
6194  {
6195  $$ = $1;
6196 }
6197 |  ColId attrs
6198  {
6199  $$ = cat_str(2,$1,$2);
6200 }
6201 ;
6202 
6203 
6204  attrs:
6205  '.' attr_name
6206  {
6207  $$ = cat_str(2,mm_strdup("."),$2);
6208 }
6209 |  attrs '.' attr_name
6210  {
6211  $$ = cat_str(3,$1,mm_strdup("."),$3);
6212 }
6213 ;
6214 
6215 
6216  type_name_list:
6217  Typename
6218  {
6219  $$ = $1;
6220 }
6221 |  type_name_list ',' Typename
6222  {
6223  $$ = cat_str(3,$1,mm_strdup(","),$3);
6224 }
6225 ;
6226 
6227 
6228  TruncateStmt:
6229  TRUNCATE opt_table relation_expr_list opt_restart_seqs opt_drop_behavior
6230  {
6231  $$ = cat_str(5,mm_strdup("truncate"),$2,$3,$4,$5);
6232 }
6233 ;
6234 
6235 
6236  opt_restart_seqs:
6237  CONTINUE_P IDENTITY_P
6238  {
6239  $$ = mm_strdup("continue identity");
6240 }
6241 |  RESTART IDENTITY_P
6242  {
6243  $$ = mm_strdup("restart identity");
6244 }
6245 |
6246  {
6247  $$=EMPTY; }
6248 ;
6249 
6250 
6251  CommentStmt:
6252  COMMENT ON comment_type_any_name any_name IS comment_text
6253  {
6254  $$ = cat_str(5,mm_strdup("comment on"),$3,$4,mm_strdup("is"),$6);
6255 }
6256 |  COMMENT ON comment_type_name name IS comment_text
6257  {
6258  $$ = cat_str(5,mm_strdup("comment on"),$3,$4,mm_strdup("is"),$6);
6259 }
6260 |  COMMENT ON TYPE_P Typename IS comment_text
6261  {
6262  $$ = cat_str(4,mm_strdup("comment on type"),$4,mm_strdup("is"),$6);
6263 }
6264 |  COMMENT ON DOMAIN_P Typename IS comment_text
6265  {
6266  $$ = cat_str(4,mm_strdup("comment on domain"),$4,mm_strdup("is"),$6);
6267 }
6268 |  COMMENT ON AGGREGATE aggregate_with_argtypes IS comment_text
6269  {
6270  $$ = cat_str(4,mm_strdup("comment on aggregate"),$4,mm_strdup("is"),$6);
6271 }
6272 |  COMMENT ON FUNCTION function_with_argtypes IS comment_text
6273  {
6274  $$ = cat_str(4,mm_strdup("comment on function"),$4,mm_strdup("is"),$6);
6275 }
6276 |  COMMENT ON OPERATOR operator_with_argtypes IS comment_text
6277  {
6278  $$ = cat_str(4,mm_strdup("comment on operator"),$4,mm_strdup("is"),$6);
6279 }
6280 |  COMMENT ON CONSTRAINT name ON any_name IS comment_text
6281  {
6282  $$ = cat_str(6,mm_strdup("comment on constraint"),$4,mm_strdup("on"),$6,mm_strdup("is"),$8);
6283 }
6284 |  COMMENT ON CONSTRAINT name ON DOMAIN_P any_name IS comment_text
6285  {
6286  $$ = cat_str(6,mm_strdup("comment on constraint"),$4,mm_strdup("on domain"),$7,mm_strdup("is"),$9);
6287 }
6288 |  COMMENT ON POLICY name ON any_name IS comment_text
6289  {
6290  $$ = cat_str(6,mm_strdup("comment on policy"),$4,mm_strdup("on"),$6,mm_strdup("is"),$8);
6291 }
6292 |  COMMENT ON PROCEDURE function_with_argtypes IS comment_text
6293  {
6294  $$ = cat_str(4,mm_strdup("comment on procedure"),$4,mm_strdup("is"),$6);
6295 }
6296 |  COMMENT ON ROUTINE function_with_argtypes IS comment_text
6297  {
6298  $$ = cat_str(4,mm_strdup("comment on routine"),$4,mm_strdup("is"),$6);
6299 }
6300 |  COMMENT ON RULE name ON any_name IS comment_text
6301  {
6302  $$ = cat_str(6,mm_strdup("comment on rule"),$4,mm_strdup("on"),$6,mm_strdup("is"),$8);
6303 }
6304 |  COMMENT ON TRANSFORM FOR Typename LANGUAGE name IS comment_text
6305  {
6306  $$ = cat_str(6,mm_strdup("comment on transform for"),$5,mm_strdup("language"),$7,mm_strdup("is"),$9);
6307 }
6308 |  COMMENT ON TRIGGER name ON any_name IS comment_text
6309  {
6310  $$ = cat_str(6,mm_strdup("comment on trigger"),$4,mm_strdup("on"),$6,mm_strdup("is"),$8);
6311 }
6312 |  COMMENT ON OPERATOR CLASS any_name USING access_method IS comment_text
6313  {
6314  $$ = cat_str(6,mm_strdup("comment on operator class"),$5,mm_strdup("using"),$7,mm_strdup("is"),$9);
6315 }
6316 |  COMMENT ON OPERATOR FAMILY any_name USING access_method IS comment_text
6317  {
6318  $$ = cat_str(6,mm_strdup("comment on operator family"),$5,mm_strdup("using"),$7,mm_strdup("is"),$9);
6319 }
6320 |  COMMENT ON LARGE_P OBJECT_P NumericOnly IS comment_text
6321  {
6322  $$ = cat_str(4,mm_strdup("comment on large object"),$5,mm_strdup("is"),$7);
6323 }
6324 |  COMMENT ON CAST '(' Typename AS Typename ')' IS comment_text
6325  {
6326  $$ = cat_str(6,mm_strdup("comment on cast ("),$5,mm_strdup("as"),$7,mm_strdup(") is"),$10);
6327 }
6328 ;
6329 
6330 
6331  comment_type_any_name:
6332  COLUMN
6333  {
6334  $$ = mm_strdup("column");
6335 }
6336 |  INDEX
6337  {
6338  $$ = mm_strdup("index");
6339 }
6340 |  SEQUENCE
6341  {
6342  $$ = mm_strdup("sequence");
6343 }
6344 |  STATISTICS
6345  {
6346  $$ = mm_strdup("statistics");
6347 }
6348 |  TABLE
6349  {
6350  $$ = mm_strdup("table");
6351 }
6352 |  VIEW
6353  {
6354  $$ = mm_strdup("view");
6355 }
6356 |  MATERIALIZED VIEW
6357  {
6358  $$ = mm_strdup("materialized view");
6359 }
6360 |  COLLATION
6361  {
6362  $$ = mm_strdup("collation");
6363 }
6364 |  CONVERSION_P
6365  {
6366  $$ = mm_strdup("conversion");
6367 }
6368 |  FOREIGN TABLE
6369  {
6370  $$ = mm_strdup("foreign table");
6371 }
6372 |  TEXT_P SEARCH CONFIGURATION
6373  {
6374  $$ = mm_strdup("text search configuration");
6375 }
6376 |  TEXT_P SEARCH DICTIONARY
6377  {
6378  $$ = mm_strdup("text search dictionary");
6379 }
6380 |  TEXT_P SEARCH PARSER
6381  {
6382  $$ = mm_strdup("text search parser");
6383 }
6384 |  TEXT_P SEARCH TEMPLATE
6385  {
6386  $$ = mm_strdup("text search template");
6387 }
6388 ;
6389 
6390 
6391  comment_type_name:
6392  ACCESS METHOD
6393  {
6394  $$ = mm_strdup("access method");
6395 }
6396 |  DATABASE
6397  {
6398  $$ = mm_strdup("database");
6399 }
6400 |  EVENT TRIGGER
6401  {
6402  $$ = mm_strdup("event trigger");
6403 }
6404 |  EXTENSION
6405  {
6406  $$ = mm_strdup("extension");
6407 }
6408 |  FOREIGN DATA_P WRAPPER
6409  {
6410  $$ = mm_strdup("foreign data wrapper");
6411 }
6412 |  opt_procedural LANGUAGE
6413  {
6414  $$ = cat_str(2,$1,mm_strdup("language"));
6415 }
6416 |  PUBLICATION
6417  {
6418  $$ = mm_strdup("publication");
6419 }
6420 |  ROLE
6421  {
6422  $$ = mm_strdup("role");
6423 }
6424 |  SCHEMA
6425  {
6426  $$ = mm_strdup("schema");
6427 }
6428 |  SERVER
6429  {
6430  $$ = mm_strdup("server");
6431 }
6432 |  SUBSCRIPTION
6433  {
6434  $$ = mm_strdup("subscription");
6435 }
6436 |  TABLESPACE
6437  {
6438  $$ = mm_strdup("tablespace");
6439 }
6440 ;
6441 
6442 
6443  comment_text:
6444  ecpg_sconst
6445  {
6446  $$ = $1;
6447 }
6448 |  NULL_P
6449  {
6450  $$ = mm_strdup("null");
6451 }
6452 ;
6453 
6454 
6455  SecLabelStmt:
6456  SECURITY LABEL opt_provider ON security_label_type_any_name any_name IS security_label
6457  {
6458  $$ = cat_str(7,mm_strdup("security label"),$3,mm_strdup("on"),$5,$6,mm_strdup("is"),$8);
6459 }
6460 |  SECURITY LABEL opt_provider ON security_label_type_name name IS security_label
6461  {
6462  $$ = cat_str(7,mm_strdup("security label"),$3,mm_strdup("on"),$5,$6,mm_strdup("is"),$8);
6463 }
6464 |  SECURITY LABEL opt_provider ON TYPE_P Typename IS security_label
6465  {
6466  $$ = cat_str(6,mm_strdup("security label"),$3,mm_strdup("on type"),$6,mm_strdup("is"),$8);
6467 }
6468 |  SECURITY LABEL opt_provider ON DOMAIN_P Typename IS security_label
6469  {
6470  $$ = cat_str(6,mm_strdup("security label"),$3,mm_strdup("on domain"),$6,mm_strdup("is"),$8);
6471 }
6472 |  SECURITY LABEL opt_provider ON AGGREGATE aggregate_with_argtypes IS security_label
6473  {
6474  $$ = cat_str(6,mm_strdup("security label"),$3,mm_strdup("on aggregate"),$6,mm_strdup("is"),$8);
6475 }
6476 |  SECURITY LABEL opt_provider ON FUNCTION function_with_argtypes IS security_label
6477  {
6478  $$ = cat_str(6,mm_strdup("security label"),$3,mm_strdup("on function"),$6,mm_strdup("is"),$8);
6479 }
6480 |  SECURITY LABEL opt_provider ON LARGE_P OBJECT_P NumericOnly IS security_label
6481  {
6482  $$ = cat_str(6,mm_strdup("security label"),$3,mm_strdup("on large object"),$7,mm_strdup("is"),$9);
6483 }
6484 |  SECURITY LABEL opt_provider ON PROCEDURE function_with_argtypes IS security_label
6485  {
6486  $$ = cat_str(6,mm_strdup("security label"),$3,mm_strdup("on procedure"),$6,mm_strdup("is"),$8);
6487 }
6488 |  SECURITY LABEL opt_provider ON ROUTINE function_with_argtypes IS security_label
6489  {
6490  $$ = cat_str(6,mm_strdup("security label"),$3,mm_strdup("on routine"),$6,mm_strdup("is"),$8);
6491 }
6492 ;
6493 
6494 
6495  opt_provider:
6496  FOR NonReservedWord_or_Sconst
6497  {
6498  $$ = cat_str(2,mm_strdup("for"),$2);
6499 }
6500 |
6501  {
6502  $$=EMPTY; }
6503 ;
6504 
6505 
6506  security_label_type_any_name:
6507  COLUMN
6508  {
6509  $$ = mm_strdup("column");
6510 }
6511 |  FOREIGN TABLE
6512  {
6513  $$ = mm_strdup("foreign table");
6514 }
6515 |  SEQUENCE
6516  {
6517  $$ = mm_strdup("sequence");
6518 }
6519 |  TABLE
6520  {
6521  $$ = mm_strdup("table");
6522 }
6523 |  VIEW
6524  {
6525  $$ = mm_strdup("view");
6526 }
6527 |  MATERIALIZED VIEW
6528  {
6529  $$ = mm_strdup("materialized view");
6530 }
6531 ;
6532 
6533 
6534  security_label_type_name:
6535  DATABASE
6536  {
6537  $$ = mm_strdup("database");
6538 }
6539 |  EVENT TRIGGER
6540  {
6541  $$ = mm_strdup("event trigger");
6542 }
6543 |  opt_procedural LANGUAGE
6544  {
6545  $$ = cat_str(2,$1,mm_strdup("language"));
6546 }
6547 |  PUBLICATION
6548  {
6549  $$ = mm_strdup("publication");
6550 }
6551 |  ROLE
6552  {
6553  $$ = mm_strdup("role");
6554 }
6555 |  SCHEMA
6556  {
6557  $$ = mm_strdup("schema");
6558 }
6559 |  SUBSCRIPTION
6560  {
6561  $$ = mm_strdup("subscription");
6562 }
6563 |  TABLESPACE
6564  {
6565  $$ = mm_strdup("tablespace");
6566 }
6567 ;
6568 
6569 
6570  security_label:
6571  ecpg_sconst
6572  {
6573  $$ = $1;
6574 }
6575 |  NULL_P
6576  {
6577  $$ = mm_strdup("null");
6578 }
6579 ;
6580 
6581 
6582  FetchStmt:
6583  FETCH fetch_args
6584  {
6585  $$ = cat_str(2,mm_strdup("fetch"),$2);
6586 }
6587 |  MOVE fetch_args
6588  {
6589  $$ = cat_str(2,mm_strdup("move"),$2);
6590 }
6591 	| FETCH fetch_args ecpg_fetch_into
6592 	{
6593 		$$ = cat2_str(mm_strdup("fetch"), $2);
6594 	}
6595 	| FETCH FORWARD cursor_name opt_ecpg_fetch_into
6596 	{
6597 		char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
6598 		add_additional_variables($3, false);
6599 		$$ = cat_str(2, mm_strdup("fetch forward"), cursor_marker);
6600 	}
6601 	| FETCH FORWARD from_in cursor_name opt_ecpg_fetch_into
6602 	{
6603 		char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
6604 		add_additional_variables($4, false);
6605 		$$ = cat_str(2, mm_strdup("fetch forward from"), cursor_marker);
6606 	}
6607 	| FETCH BACKWARD cursor_name opt_ecpg_fetch_into
6608 	{
6609 		char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
6610 		add_additional_variables($3, false);
6611 		$$ = cat_str(2, mm_strdup("fetch backward"), cursor_marker);
6612 	}
6613 	| FETCH BACKWARD from_in cursor_name opt_ecpg_fetch_into
6614 	{
6615 		char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
6616 		add_additional_variables($4, false);
6617 		$$ = cat_str(2, mm_strdup("fetch backward from"), cursor_marker);
6618 	}
6619 	| MOVE FORWARD cursor_name
6620 	{
6621 		char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
6622 		add_additional_variables($3, false);
6623 		$$ = cat_str(2, mm_strdup("move forward"), cursor_marker);
6624 	}
6625 	| MOVE FORWARD from_in cursor_name
6626 	{
6627 		char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
6628 		add_additional_variables($4, false);
6629 		$$ = cat_str(2, mm_strdup("move forward from"), cursor_marker);
6630 	}
6631 	| MOVE BACKWARD cursor_name
6632 	{
6633 		char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
6634 		add_additional_variables($3, false);
6635 		$$ = cat_str(2, mm_strdup("move backward"), cursor_marker);
6636 	}
6637 	| MOVE BACKWARD from_in cursor_name
6638 	{
6639 		char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
6640 		add_additional_variables($4, false);
6641 		$$ = cat_str(2, mm_strdup("move backward from"), cursor_marker);
6642 	}
6643 ;
6644 
6645 
6646  fetch_args:
6647  cursor_name
6648  {
6649 		add_additional_variables($1, false);
6650 		if ($1[0] == ':')
6651 		{
6652 			free($1);
6653 			$1 = mm_strdup("$0");
6654 		}
6655 
6656  $$ = $1;
6657 }
6658 |  from_in cursor_name
6659  {
6660 		add_additional_variables($2, false);
6661 		if ($2[0] == ':')
6662 		{
6663 			free($2);
6664 			$2 = mm_strdup("$0");
6665 		}
6666 
6667  $$ = cat_str(2,$1,$2);
6668 }
6669 |  NEXT opt_from_in cursor_name
6670  {
6671 		add_additional_variables($3, false);
6672 		if ($3[0] == ':')
6673 		{
6674 			free($3);
6675 			$3 = mm_strdup("$0");
6676 		}
6677 
6678  $$ = cat_str(3,mm_strdup("next"),$2,$3);
6679 }
6680 |  PRIOR opt_from_in cursor_name
6681  {
6682 		add_additional_variables($3, false);
6683 		if ($3[0] == ':')
6684 		{
6685 			free($3);
6686 			$3 = mm_strdup("$0");
6687 		}
6688 
6689  $$ = cat_str(3,mm_strdup("prior"),$2,$3);
6690 }
6691 |  FIRST_P opt_from_in cursor_name
6692  {
6693 		add_additional_variables($3, false);
6694 		if ($3[0] == ':')
6695 		{
6696 			free($3);
6697 			$3 = mm_strdup("$0");
6698 		}
6699 
6700  $$ = cat_str(3,mm_strdup("first"),$2,$3);
6701 }
6702 |  LAST_P opt_from_in cursor_name
6703  {
6704 		add_additional_variables($3, false);
6705 		if ($3[0] == ':')
6706 		{
6707 			free($3);
6708 			$3 = mm_strdup("$0");
6709 		}
6710 
6711  $$ = cat_str(3,mm_strdup("last"),$2,$3);
6712 }
6713 |  ABSOLUTE_P SignedIconst opt_from_in cursor_name
6714  {
6715 		add_additional_variables($4, false);
6716 		if ($4[0] == ':')
6717 		{
6718 			free($4);
6719 			$4 = mm_strdup("$0");
6720 		}
6721 		if ($2[0] == '$')
6722 		{
6723 			free($2);
6724 			$2 = mm_strdup("$0");
6725 		}
6726 
6727  $$ = cat_str(4,mm_strdup("absolute"),$2,$3,$4);
6728 }
6729 |  RELATIVE_P SignedIconst opt_from_in cursor_name
6730  {
6731 		add_additional_variables($4, false);
6732 		if ($4[0] == ':')
6733 		{
6734 			free($4);
6735 			$4 = mm_strdup("$0");
6736 		}
6737 		if ($2[0] == '$')
6738 		{
6739 			free($2);
6740 			$2 = mm_strdup("$0");
6741 		}
6742 
6743  $$ = cat_str(4,mm_strdup("relative"),$2,$3,$4);
6744 }
6745 |  SignedIconst opt_from_in cursor_name
6746  {
6747 		add_additional_variables($3, false);
6748 		if ($3[0] == ':')
6749 		{
6750 			free($3);
6751 			$3 = mm_strdup("$0");
6752 		}
6753 		if ($1[0] == '$')
6754 		{
6755 			free($1);
6756 			$1 = mm_strdup("$0");
6757 		}
6758 
6759  $$ = cat_str(3,$1,$2,$3);
6760 }
6761 |  ALL opt_from_in cursor_name
6762  {
6763 		add_additional_variables($3, false);
6764 		if ($3[0] == ':')
6765 		{
6766 			free($3);
6767 			$3 = mm_strdup("$0");
6768 		}
6769 
6770  $$ = cat_str(3,mm_strdup("all"),$2,$3);
6771 }
6772 |  FORWARD SignedIconst opt_from_in cursor_name
6773  {
6774 		add_additional_variables($4, false);
6775 		if ($4[0] == ':')
6776 		{
6777 			free($4);
6778 			$4 = mm_strdup("$0");
6779 		}
6780 		if ($2[0] == '$')
6781 		{
6782 			free($2);
6783 			$2 = mm_strdup("$0");
6784 		}
6785 
6786  $$ = cat_str(4,mm_strdup("forward"),$2,$3,$4);
6787 }
6788 |  FORWARD ALL opt_from_in cursor_name
6789  {
6790 		add_additional_variables($4, false);
6791 		if ($4[0] == ':')
6792 		{
6793 			free($4);
6794 			$4 = mm_strdup("$0");
6795 		}
6796 
6797  $$ = cat_str(3,mm_strdup("forward all"),$3,$4);
6798 }
6799 |  BACKWARD SignedIconst opt_from_in cursor_name
6800  {
6801 		add_additional_variables($4, false);
6802 		if ($4[0] == ':')
6803 		{
6804 			free($4);
6805 			$4 = mm_strdup("$0");
6806 		}
6807 		if ($2[0] == '$')
6808 		{
6809 			free($2);
6810 			$2 = mm_strdup("$0");
6811 		}
6812 
6813  $$ = cat_str(4,mm_strdup("backward"),$2,$3,$4);
6814 }
6815 |  BACKWARD ALL opt_from_in cursor_name
6816  {
6817 		add_additional_variables($4, false);
6818 		if ($4[0] == ':')
6819 		{
6820 			free($4);
6821 			$4 = mm_strdup("$0");
6822 		}
6823 
6824  $$ = cat_str(3,mm_strdup("backward all"),$3,$4);
6825 }
6826 ;
6827 
6828 
6829  from_in:
6830  FROM
6831  {
6832  $$ = mm_strdup("from");
6833 }
6834 |  IN_P
6835  {
6836  $$ = mm_strdup("in");
6837 }
6838 ;
6839 
6840 
6841  opt_from_in:
6842  from_in
6843  {
6844  $$ = $1;
6845 }
6846 |
6847  {
6848  $$=EMPTY; }
6849 ;
6850 
6851 
6852  GrantStmt:
6853  GRANT privileges ON privilege_target TO grantee_list opt_grant_grant_option
6854  {
6855  $$ = cat_str(7,mm_strdup("grant"),$2,mm_strdup("on"),$4,mm_strdup("to"),$6,$7);
6856 }
6857 ;
6858 
6859 
6860  RevokeStmt:
6861  REVOKE privileges ON privilege_target FROM grantee_list opt_drop_behavior
6862  {
6863  $$ = cat_str(7,mm_strdup("revoke"),$2,mm_strdup("on"),$4,mm_strdup("from"),$6,$7);
6864 }
6865 |  REVOKE GRANT OPTION FOR privileges ON privilege_target FROM grantee_list opt_drop_behavior
6866  {
6867  $$ = cat_str(7,mm_strdup("revoke grant option for"),$5,mm_strdup("on"),$7,mm_strdup("from"),$9,$10);
6868 }
6869 ;
6870 
6871 
6872  privileges:
6873  privilege_list
6874  {
6875  $$ = $1;
6876 }
6877 |  ALL
6878  {
6879  $$ = mm_strdup("all");
6880 }
6881 |  ALL PRIVILEGES
6882  {
6883  $$ = mm_strdup("all privileges");
6884 }
6885 |  ALL '(' columnList ')'
6886  {
6887  $$ = cat_str(3,mm_strdup("all ("),$3,mm_strdup(")"));
6888 }
6889 |  ALL PRIVILEGES '(' columnList ')'
6890  {
6891  $$ = cat_str(3,mm_strdup("all privileges ("),$4,mm_strdup(")"));
6892 }
6893 ;
6894 
6895 
6896  privilege_list:
6897  privilege
6898  {
6899  $$ = $1;
6900 }
6901 |  privilege_list ',' privilege
6902  {
6903  $$ = cat_str(3,$1,mm_strdup(","),$3);
6904 }
6905 ;
6906 
6907 
6908  privilege:
6909  SELECT opt_column_list
6910  {
6911  $$ = cat_str(2,mm_strdup("select"),$2);
6912 }
6913 |  REFERENCES opt_column_list
6914  {
6915  $$ = cat_str(2,mm_strdup("references"),$2);
6916 }
6917 |  CREATE opt_column_list
6918  {
6919  $$ = cat_str(2,mm_strdup("create"),$2);
6920 }
6921 |  ColId opt_column_list
6922  {
6923  $$ = cat_str(2,$1,$2);
6924 }
6925 ;
6926 
6927 
6928  privilege_target:
6929  qualified_name_list
6930  {
6931  $$ = $1;
6932 }
6933 |  TABLE qualified_name_list
6934  {
6935  $$ = cat_str(2,mm_strdup("table"),$2);
6936 }
6937 |  SEQUENCE qualified_name_list
6938  {
6939  $$ = cat_str(2,mm_strdup("sequence"),$2);
6940 }
6941 |  FOREIGN DATA_P WRAPPER name_list
6942  {
6943  $$ = cat_str(2,mm_strdup("foreign data wrapper"),$4);
6944 }
6945 |  FOREIGN SERVER name_list
6946  {
6947  $$ = cat_str(2,mm_strdup("foreign server"),$3);
6948 }
6949 |  FUNCTION function_with_argtypes_list
6950  {
6951  $$ = cat_str(2,mm_strdup("function"),$2);
6952 }
6953 |  PROCEDURE function_with_argtypes_list
6954  {
6955  $$ = cat_str(2,mm_strdup("procedure"),$2);
6956 }
6957 |  ROUTINE function_with_argtypes_list
6958  {
6959  $$ = cat_str(2,mm_strdup("routine"),$2);
6960 }
6961 |  DATABASE name_list
6962  {
6963  $$ = cat_str(2,mm_strdup("database"),$2);
6964 }
6965 |  DOMAIN_P any_name_list
6966  {
6967  $$ = cat_str(2,mm_strdup("domain"),$2);
6968 }
6969 |  LANGUAGE name_list
6970  {
6971  $$ = cat_str(2,mm_strdup("language"),$2);
6972 }
6973 |  LARGE_P OBJECT_P NumericOnly_list
6974  {
6975  $$ = cat_str(2,mm_strdup("large object"),$3);
6976 }
6977 |  SCHEMA name_list
6978  {
6979  $$ = cat_str(2,mm_strdup("schema"),$2);
6980 }
6981 |  TABLESPACE name_list
6982  {
6983  $$ = cat_str(2,mm_strdup("tablespace"),$2);
6984 }
6985 |  TYPE_P any_name_list
6986  {
6987  $$ = cat_str(2,mm_strdup("type"),$2);
6988 }
6989 |  ALL TABLES IN_P SCHEMA name_list
6990  {
6991  $$ = cat_str(2,mm_strdup("all tables in schema"),$5);
6992 }
6993 |  ALL SEQUENCES IN_P SCHEMA name_list
6994  {
6995  $$ = cat_str(2,mm_strdup("all sequences in schema"),$5);
6996 }
6997 |  ALL FUNCTIONS IN_P SCHEMA name_list
6998  {
6999  $$ = cat_str(2,mm_strdup("all functions in schema"),$5);
7000 }
7001 |  ALL PROCEDURES IN_P SCHEMA name_list
7002  {
7003  $$ = cat_str(2,mm_strdup("all procedures in schema"),$5);
7004 }
7005 |  ALL ROUTINES IN_P SCHEMA name_list
7006  {
7007  $$ = cat_str(2,mm_strdup("all routines in schema"),$5);
7008 }
7009 ;
7010 
7011 
7012  grantee_list:
7013  grantee
7014  {
7015  $$ = $1;
7016 }
7017 |  grantee_list ',' grantee
7018  {
7019  $$ = cat_str(3,$1,mm_strdup(","),$3);
7020 }
7021 ;
7022 
7023 
7024  grantee:
7025  RoleSpec
7026  {
7027  $$ = $1;
7028 }
7029 |  GROUP_P RoleSpec
7030  {
7031  $$ = cat_str(2,mm_strdup("group"),$2);
7032 }
7033 ;
7034 
7035 
7036  opt_grant_grant_option:
7037  WITH GRANT OPTION
7038  {
7039  $$ = mm_strdup("with grant option");
7040 }
7041 |
7042  {
7043  $$=EMPTY; }
7044 ;
7045 
7046 
7047  GrantRoleStmt:
7048  GRANT privilege_list TO role_list opt_grant_admin_option opt_granted_by
7049  {
7050  $$ = cat_str(6,mm_strdup("grant"),$2,mm_strdup("to"),$4,$5,$6);
7051 }
7052 ;
7053 
7054 
7055  RevokeRoleStmt:
7056  REVOKE privilege_list FROM role_list opt_granted_by opt_drop_behavior
7057  {
7058  $$ = cat_str(6,mm_strdup("revoke"),$2,mm_strdup("from"),$4,$5,$6);
7059 }
7060 |  REVOKE ADMIN OPTION FOR privilege_list FROM role_list opt_granted_by opt_drop_behavior
7061  {
7062  $$ = cat_str(6,mm_strdup("revoke admin option for"),$5,mm_strdup("from"),$7,$8,$9);
7063 }
7064 ;
7065 
7066 
7067  opt_grant_admin_option:
7068  WITH ADMIN OPTION
7069  {
7070  $$ = mm_strdup("with admin option");
7071 }
7072 |
7073  {
7074  $$=EMPTY; }
7075 ;
7076 
7077 
7078  opt_granted_by:
7079  GRANTED BY RoleSpec
7080  {
7081  $$ = cat_str(2,mm_strdup("granted by"),$3);
7082 }
7083 |
7084  {
7085  $$=EMPTY; }
7086 ;
7087 
7088 
7089  AlterDefaultPrivilegesStmt:
7090  ALTER DEFAULT PRIVILEGES DefACLOptionList DefACLAction
7091  {
7092  $$ = cat_str(3,mm_strdup("alter default privileges"),$4,$5);
7093 }
7094 ;
7095 
7096 
7097  DefACLOptionList:
7098  DefACLOptionList DefACLOption
7099  {
7100  $$ = cat_str(2,$1,$2);
7101 }
7102 |
7103  {
7104  $$=EMPTY; }
7105 ;
7106 
7107 
7108  DefACLOption:
7109  IN_P SCHEMA name_list
7110  {
7111  $$ = cat_str(2,mm_strdup("in schema"),$3);
7112 }
7113 |  FOR ROLE role_list
7114  {
7115  $$ = cat_str(2,mm_strdup("for role"),$3);
7116 }
7117 |  FOR USER role_list
7118  {
7119  $$ = cat_str(2,mm_strdup("for user"),$3);
7120 }
7121 ;
7122 
7123 
7124  DefACLAction:
7125  GRANT privileges ON defacl_privilege_target TO grantee_list opt_grant_grant_option
7126  {
7127  $$ = cat_str(7,mm_strdup("grant"),$2,mm_strdup("on"),$4,mm_strdup("to"),$6,$7);
7128 }
7129 |  REVOKE privileges ON defacl_privilege_target FROM grantee_list opt_drop_behavior
7130  {
7131  $$ = cat_str(7,mm_strdup("revoke"),$2,mm_strdup("on"),$4,mm_strdup("from"),$6,$7);
7132 }
7133 |  REVOKE GRANT OPTION FOR privileges ON defacl_privilege_target FROM grantee_list opt_drop_behavior
7134  {
7135  $$ = cat_str(7,mm_strdup("revoke grant option for"),$5,mm_strdup("on"),$7,mm_strdup("from"),$9,$10);
7136 }
7137 ;
7138 
7139 
7140  defacl_privilege_target:
7141  TABLES
7142  {
7143  $$ = mm_strdup("tables");
7144 }
7145 |  FUNCTIONS
7146  {
7147  $$ = mm_strdup("functions");
7148 }
7149 |  ROUTINES
7150  {
7151  $$ = mm_strdup("routines");
7152 }
7153 |  SEQUENCES
7154  {
7155  $$ = mm_strdup("sequences");
7156 }
7157 |  TYPES_P
7158  {
7159  $$ = mm_strdup("types");
7160 }
7161 |  SCHEMAS
7162  {
7163  $$ = mm_strdup("schemas");
7164 }
7165 ;
7166 
7167 
7168  IndexStmt:
7169  CREATE opt_unique INDEX opt_concurrently opt_index_name ON relation_expr access_method_clause '(' index_params ')' opt_include opt_reloptions OptTableSpace where_clause
7170  {
7171  $$ = 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);
7172 }
7173 |  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
7174  {
7175  $$ = 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);
7176 }
7177 ;
7178 
7179 
7180  opt_unique:
7181  UNIQUE
7182  {
7183  $$ = mm_strdup("unique");
7184 }
7185 |
7186  {
7187  $$=EMPTY; }
7188 ;
7189 
7190 
7191  opt_concurrently:
7192  CONCURRENTLY
7193  {
7194  $$ = mm_strdup("concurrently");
7195 }
7196 |
7197  {
7198  $$=EMPTY; }
7199 ;
7200 
7201 
7202  opt_index_name:
7203  index_name
7204  {
7205  $$ = $1;
7206 }
7207 |
7208  {
7209  $$=EMPTY; }
7210 ;
7211 
7212 
7213  access_method_clause:
7214  USING access_method
7215  {
7216  $$ = cat_str(2,mm_strdup("using"),$2);
7217 }
7218 |
7219  {
7220  $$=EMPTY; }
7221 ;
7222 
7223 
7224  index_params:
7225  index_elem
7226  {
7227  $$ = $1;
7228 }
7229 |  index_params ',' index_elem
7230  {
7231  $$ = cat_str(3,$1,mm_strdup(","),$3);
7232 }
7233 ;
7234 
7235 
7236  index_elem:
7237  ColId opt_collate opt_class opt_asc_desc opt_nulls_order
7238  {
7239  $$ = cat_str(5,$1,$2,$3,$4,$5);
7240 }
7241 |  func_expr_windowless opt_collate opt_class opt_asc_desc opt_nulls_order
7242  {
7243  $$ = cat_str(5,$1,$2,$3,$4,$5);
7244 }
7245 |  '(' a_expr ')' opt_collate opt_class opt_asc_desc opt_nulls_order
7246  {
7247  $$ = cat_str(7,mm_strdup("("),$2,mm_strdup(")"),$4,$5,$6,$7);
7248 }
7249 ;
7250 
7251 
7252  opt_include:
7253  INCLUDE '(' index_including_params ')'
7254  {
7255  $$ = cat_str(3,mm_strdup("include ("),$3,mm_strdup(")"));
7256 }
7257 |
7258  {
7259  $$=EMPTY; }
7260 ;
7261 
7262 
7263  index_including_params:
7264  index_elem
7265  {
7266  $$ = $1;
7267 }
7268 |  index_including_params ',' index_elem
7269  {
7270  $$ = cat_str(3,$1,mm_strdup(","),$3);
7271 }
7272 ;
7273 
7274 
7275  opt_collate:
7276  COLLATE any_name
7277  {
7278  $$ = cat_str(2,mm_strdup("collate"),$2);
7279 }
7280 |
7281  {
7282  $$=EMPTY; }
7283 ;
7284 
7285 
7286  opt_class:
7287  any_name
7288  {
7289  $$ = $1;
7290 }
7291 |
7292  {
7293  $$=EMPTY; }
7294 ;
7295 
7296 
7297  opt_asc_desc:
7298  ASC
7299  {
7300  $$ = mm_strdup("asc");
7301 }
7302 |  DESC
7303  {
7304  $$ = mm_strdup("desc");
7305 }
7306 |
7307  {
7308  $$=EMPTY; }
7309 ;
7310 
7311 
7312  opt_nulls_order:
7313  NULLS_LA FIRST_P
7314  {
7315  $$ = mm_strdup("nulls first");
7316 }
7317 |  NULLS_LA LAST_P
7318  {
7319  $$ = mm_strdup("nulls last");
7320 }
7321 |
7322  {
7323  $$=EMPTY; }
7324 ;
7325 
7326 
7327  CreateFunctionStmt:
7328  CREATE opt_or_replace FUNCTION func_name func_args_with_defaults RETURNS func_return createfunc_opt_list
7329  {
7330  $$ = cat_str(8,mm_strdup("create"),$2,mm_strdup("function"),$4,$5,mm_strdup("returns"),$7,$8);
7331 }
7332 |  CREATE opt_or_replace FUNCTION func_name func_args_with_defaults RETURNS TABLE '(' table_func_column_list ')' createfunc_opt_list
7333  {
7334  $$ = cat_str(9,mm_strdup("create"),$2,mm_strdup("function"),$4,$5,mm_strdup("returns table ("),$9,mm_strdup(")"),$11);
7335 }
7336 |  CREATE opt_or_replace FUNCTION func_name func_args_with_defaults createfunc_opt_list
7337  {
7338  $$ = cat_str(6,mm_strdup("create"),$2,mm_strdup("function"),$4,$5,$6);
7339 }
7340 |  CREATE opt_or_replace PROCEDURE func_name func_args_with_defaults createfunc_opt_list
7341  {
7342  $$ = cat_str(6,mm_strdup("create"),$2,mm_strdup("procedure"),$4,$5,$6);
7343 }
7344 ;
7345 
7346 
7347  opt_or_replace:
7348  OR REPLACE
7349  {
7350  $$ = mm_strdup("or replace");
7351 }
7352 |
7353  {
7354  $$=EMPTY; }
7355 ;
7356 
7357 
7358  func_args:
7359  '(' func_args_list ')'
7360  {
7361  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
7362 }
7363 |  '(' ')'
7364  {
7365  $$ = mm_strdup("( )");
7366 }
7367 ;
7368 
7369 
7370  func_args_list:
7371  func_arg
7372  {
7373  $$ = $1;
7374 }
7375 |  func_args_list ',' func_arg
7376  {
7377  $$ = cat_str(3,$1,mm_strdup(","),$3);
7378 }
7379 ;
7380 
7381 
7382  function_with_argtypes_list:
7383  function_with_argtypes
7384  {
7385  $$ = $1;
7386 }
7387 |  function_with_argtypes_list ',' function_with_argtypes
7388  {
7389  $$ = cat_str(3,$1,mm_strdup(","),$3);
7390 }
7391 ;
7392 
7393 
7394  function_with_argtypes:
7395  func_name func_args
7396  {
7397  $$ = cat_str(2,$1,$2);
7398 }
7399 |  type_func_name_keyword
7400  {
7401  $$ = $1;
7402 }
7403 |  ColId
7404  {
7405  $$ = $1;
7406 }
7407 |  ColId indirection
7408  {
7409  $$ = cat_str(2,$1,$2);
7410 }
7411 ;
7412 
7413 
7414  func_args_with_defaults:
7415  '(' func_args_with_defaults_list ')'
7416  {
7417  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
7418 }
7419 |  '(' ')'
7420  {
7421  $$ = mm_strdup("( )");
7422 }
7423 ;
7424 
7425 
7426  func_args_with_defaults_list:
7427  func_arg_with_default
7428  {
7429  $$ = $1;
7430 }
7431 |  func_args_with_defaults_list ',' func_arg_with_default
7432  {
7433  $$ = cat_str(3,$1,mm_strdup(","),$3);
7434 }
7435 ;
7436 
7437 
7438  func_arg:
7439  arg_class param_name func_type
7440  {
7441  $$ = cat_str(3,$1,$2,$3);
7442 }
7443 |  param_name arg_class func_type
7444  {
7445  $$ = cat_str(3,$1,$2,$3);
7446 }
7447 |  param_name func_type
7448  {
7449  $$ = cat_str(2,$1,$2);
7450 }
7451 |  arg_class func_type
7452  {
7453  $$ = cat_str(2,$1,$2);
7454 }
7455 |  func_type
7456  {
7457  $$ = $1;
7458 }
7459 ;
7460 
7461 
7462  arg_class:
7463  IN_P
7464  {
7465  $$ = mm_strdup("in");
7466 }
7467 |  OUT_P
7468  {
7469  $$ = mm_strdup("out");
7470 }
7471 |  INOUT
7472  {
7473  $$ = mm_strdup("inout");
7474 }
7475 |  IN_P OUT_P
7476  {
7477  $$ = mm_strdup("in out");
7478 }
7479 |  VARIADIC
7480  {
7481  $$ = mm_strdup("variadic");
7482 }
7483 ;
7484 
7485 
7486  param_name:
7487  type_function_name
7488  {
7489  $$ = $1;
7490 }
7491 ;
7492 
7493 
7494  func_return:
7495  func_type
7496  {
7497  $$ = $1;
7498 }
7499 ;
7500 
7501 
7502  func_type:
7503  Typename
7504  {
7505  $$ = $1;
7506 }
7507 |  type_function_name attrs '%' TYPE_P
7508  {
7509  $$ = cat_str(3,$1,$2,mm_strdup("% type"));
7510 }
7511 |  SETOF type_function_name attrs '%' TYPE_P
7512  {
7513  $$ = cat_str(4,mm_strdup("setof"),$2,$3,mm_strdup("% type"));
7514 }
7515 ;
7516 
7517 
7518  func_arg_with_default:
7519  func_arg
7520  {
7521  $$ = $1;
7522 }
7523 |  func_arg DEFAULT a_expr
7524  {
7525  $$ = cat_str(3,$1,mm_strdup("default"),$3);
7526 }
7527 |  func_arg '=' a_expr
7528  {
7529  $$ = cat_str(3,$1,mm_strdup("="),$3);
7530 }
7531 ;
7532 
7533 
7534  aggr_arg:
7535  func_arg
7536  {
7537 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
7538  $$ = $1;
7539 }
7540 ;
7541 
7542 
7543  aggr_args:
7544  '(' '*' ')'
7545  {
7546  $$ = mm_strdup("( * )");
7547 }
7548 |  '(' aggr_args_list ')'
7549  {
7550  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
7551 }
7552 |  '(' ORDER BY aggr_args_list ')'
7553  {
7554  $$ = cat_str(3,mm_strdup("( order by"),$4,mm_strdup(")"));
7555 }
7556 |  '(' aggr_args_list ORDER BY aggr_args_list ')'
7557  {
7558  $$ = cat_str(5,mm_strdup("("),$2,mm_strdup("order by"),$5,mm_strdup(")"));
7559 }
7560 ;
7561 
7562 
7563  aggr_args_list:
7564  aggr_arg
7565  {
7566  $$ = $1;
7567 }
7568 |  aggr_args_list ',' aggr_arg
7569  {
7570  $$ = cat_str(3,$1,mm_strdup(","),$3);
7571 }
7572 ;
7573 
7574 
7575  aggregate_with_argtypes:
7576  func_name aggr_args
7577  {
7578  $$ = cat_str(2,$1,$2);
7579 }
7580 ;
7581 
7582 
7583  aggregate_with_argtypes_list:
7584  aggregate_with_argtypes
7585  {
7586  $$ = $1;
7587 }
7588 |  aggregate_with_argtypes_list ',' aggregate_with_argtypes
7589  {
7590  $$ = cat_str(3,$1,mm_strdup(","),$3);
7591 }
7592 ;
7593 
7594 
7595  createfunc_opt_list:
7596  createfunc_opt_item
7597  {
7598  $$ = $1;
7599 }
7600 |  createfunc_opt_list createfunc_opt_item
7601  {
7602  $$ = cat_str(2,$1,$2);
7603 }
7604 ;
7605 
7606 
7607  common_func_opt_item:
7608  CALLED ON NULL_P INPUT_P
7609  {
7610  $$ = mm_strdup("called on null input");
7611 }
7612 |  RETURNS NULL_P ON NULL_P INPUT_P
7613  {
7614  $$ = mm_strdup("returns null on null input");
7615 }
7616 |  STRICT_P
7617  {
7618  $$ = mm_strdup("strict");
7619 }
7620 |  IMMUTABLE
7621  {
7622  $$ = mm_strdup("immutable");
7623 }
7624 |  STABLE
7625  {
7626  $$ = mm_strdup("stable");
7627 }
7628 |  VOLATILE
7629  {
7630  $$ = mm_strdup("volatile");
7631 }
7632 |  EXTERNAL SECURITY DEFINER
7633  {
7634  $$ = mm_strdup("external security definer");
7635 }
7636 |  EXTERNAL SECURITY INVOKER
7637  {
7638  $$ = mm_strdup("external security invoker");
7639 }
7640 |  SECURITY DEFINER
7641  {
7642  $$ = mm_strdup("security definer");
7643 }
7644 |  SECURITY INVOKER
7645  {
7646  $$ = mm_strdup("security invoker");
7647 }
7648 |  LEAKPROOF
7649  {
7650  $$ = mm_strdup("leakproof");
7651 }
7652 |  NOT LEAKPROOF
7653  {
7654  $$ = mm_strdup("not leakproof");
7655 }
7656 |  COST NumericOnly
7657  {
7658  $$ = cat_str(2,mm_strdup("cost"),$2);
7659 }
7660 |  ROWS NumericOnly
7661  {
7662  $$ = cat_str(2,mm_strdup("rows"),$2);
7663 }
7664 |  FunctionSetResetClause
7665  {
7666  $$ = $1;
7667 }
7668 |  PARALLEL ColId
7669  {
7670  $$ = cat_str(2,mm_strdup("parallel"),$2);
7671 }
7672 ;
7673 
7674 
7675  createfunc_opt_item:
7676  AS func_as
7677  {
7678  $$ = cat_str(2,mm_strdup("as"),$2);
7679 }
7680 |  LANGUAGE NonReservedWord_or_Sconst
7681  {
7682  $$ = cat_str(2,mm_strdup("language"),$2);
7683 }
7684 |  TRANSFORM transform_type_list
7685  {
7686  $$ = cat_str(2,mm_strdup("transform"),$2);
7687 }
7688 |  WINDOW
7689  {
7690  $$ = mm_strdup("window");
7691 }
7692 |  common_func_opt_item
7693  {
7694  $$ = $1;
7695 }
7696 ;
7697 
7698 
7699  func_as:
7700  ecpg_sconst
7701  {
7702  $$ = $1;
7703 }
7704 |  ecpg_sconst ',' ecpg_sconst
7705  {
7706  $$ = cat_str(3,$1,mm_strdup(","),$3);
7707 }
7708 ;
7709 
7710 
7711  transform_type_list:
7712  FOR TYPE_P Typename
7713  {
7714  $$ = cat_str(2,mm_strdup("for type"),$3);
7715 }
7716 |  transform_type_list ',' FOR TYPE_P Typename
7717  {
7718  $$ = cat_str(3,$1,mm_strdup(", for type"),$5);
7719 }
7720 ;
7721 
7722 
7723  opt_definition:
7724  WITH definition
7725  {
7726  $$ = cat_str(2,mm_strdup("with"),$2);
7727 }
7728 |
7729  {
7730  $$=EMPTY; }
7731 ;
7732 
7733 
7734  table_func_column:
7735  param_name func_type
7736  {
7737  $$ = cat_str(2,$1,$2);
7738 }
7739 ;
7740 
7741 
7742  table_func_column_list:
7743  table_func_column
7744  {
7745  $$ = $1;
7746 }
7747 |  table_func_column_list ',' table_func_column
7748  {
7749  $$ = cat_str(3,$1,mm_strdup(","),$3);
7750 }
7751 ;
7752 
7753 
7754  AlterFunctionStmt:
7755  ALTER FUNCTION function_with_argtypes alterfunc_opt_list opt_restrict
7756  {
7757  $$ = cat_str(4,mm_strdup("alter function"),$3,$4,$5);
7758 }
7759 |  ALTER PROCEDURE function_with_argtypes alterfunc_opt_list opt_restrict
7760  {
7761  $$ = cat_str(4,mm_strdup("alter procedure"),$3,$4,$5);
7762 }
7763 |  ALTER ROUTINE function_with_argtypes alterfunc_opt_list opt_restrict
7764  {
7765  $$ = cat_str(4,mm_strdup("alter routine"),$3,$4,$5);
7766 }
7767 ;
7768 
7769 
7770  alterfunc_opt_list:
7771  common_func_opt_item
7772  {
7773  $$ = $1;
7774 }
7775 |  alterfunc_opt_list common_func_opt_item
7776  {
7777  $$ = cat_str(2,$1,$2);
7778 }
7779 ;
7780 
7781 
7782  opt_restrict:
7783  RESTRICT
7784  {
7785  $$ = mm_strdup("restrict");
7786 }
7787 |
7788  {
7789  $$=EMPTY; }
7790 ;
7791 
7792 
7793  RemoveFuncStmt:
7794  DROP FUNCTION function_with_argtypes_list opt_drop_behavior
7795  {
7796  $$ = cat_str(3,mm_strdup("drop function"),$3,$4);
7797 }
7798 |  DROP FUNCTION IF_P EXISTS function_with_argtypes_list opt_drop_behavior
7799  {
7800  $$ = cat_str(3,mm_strdup("drop function if exists"),$5,$6);
7801 }
7802 |  DROP PROCEDURE function_with_argtypes_list opt_drop_behavior
7803  {
7804  $$ = cat_str(3,mm_strdup("drop procedure"),$3,$4);
7805 }
7806 |  DROP PROCEDURE IF_P EXISTS function_with_argtypes_list opt_drop_behavior
7807  {
7808  $$ = cat_str(3,mm_strdup("drop procedure if exists"),$5,$6);
7809 }
7810 |  DROP ROUTINE function_with_argtypes_list opt_drop_behavior
7811  {
7812  $$ = cat_str(3,mm_strdup("drop routine"),$3,$4);
7813 }
7814 |  DROP ROUTINE IF_P EXISTS function_with_argtypes_list opt_drop_behavior
7815  {
7816  $$ = cat_str(3,mm_strdup("drop routine if exists"),$5,$6);
7817 }
7818 ;
7819 
7820 
7821  RemoveAggrStmt:
7822  DROP AGGREGATE aggregate_with_argtypes_list opt_drop_behavior
7823  {
7824  $$ = cat_str(3,mm_strdup("drop aggregate"),$3,$4);
7825 }
7826 |  DROP AGGREGATE IF_P EXISTS aggregate_with_argtypes_list opt_drop_behavior
7827  {
7828  $$ = cat_str(3,mm_strdup("drop aggregate if exists"),$5,$6);
7829 }
7830 ;
7831 
7832 
7833  RemoveOperStmt:
7834  DROP OPERATOR operator_with_argtypes_list opt_drop_behavior
7835  {
7836  $$ = cat_str(3,mm_strdup("drop operator"),$3,$4);
7837 }
7838 |  DROP OPERATOR IF_P EXISTS operator_with_argtypes_list opt_drop_behavior
7839  {
7840  $$ = cat_str(3,mm_strdup("drop operator if exists"),$5,$6);
7841 }
7842 ;
7843 
7844 
7845  oper_argtypes:
7846  '(' Typename ')'
7847  {
7848  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
7849 }
7850 |  '(' Typename ',' Typename ')'
7851  {
7852  $$ = cat_str(5,mm_strdup("("),$2,mm_strdup(","),$4,mm_strdup(")"));
7853 }
7854 |  '(' NONE ',' Typename ')'
7855  {
7856  $$ = cat_str(3,mm_strdup("( none ,"),$4,mm_strdup(")"));
7857 }
7858 |  '(' Typename ',' NONE ')'
7859  {
7860  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(", none )"));
7861 }
7862 ;
7863 
7864 
7865  any_operator:
7866  all_Op
7867  {
7868  $$ = $1;
7869 }
7870 |  ColId '.' any_operator
7871  {
7872  $$ = cat_str(3,$1,mm_strdup("."),$3);
7873 }
7874 ;
7875 
7876 
7877  operator_with_argtypes_list:
7878  operator_with_argtypes
7879  {
7880  $$ = $1;
7881 }
7882 |  operator_with_argtypes_list ',' operator_with_argtypes
7883  {
7884  $$ = cat_str(3,$1,mm_strdup(","),$3);
7885 }
7886 ;
7887 
7888 
7889  operator_with_argtypes:
7890  any_operator oper_argtypes
7891  {
7892  $$ = cat_str(2,$1,$2);
7893 }
7894 ;
7895 
7896 
7897  DoStmt:
7898  DO dostmt_opt_list
7899  {
7900  $$ = cat_str(2,mm_strdup("do"),$2);
7901 }
7902 ;
7903 
7904 
7905  dostmt_opt_list:
7906  dostmt_opt_item
7907  {
7908  $$ = $1;
7909 }
7910 |  dostmt_opt_list dostmt_opt_item
7911  {
7912  $$ = cat_str(2,$1,$2);
7913 }
7914 ;
7915 
7916 
7917  dostmt_opt_item:
7918  ecpg_sconst
7919  {
7920  $$ = $1;
7921 }
7922 |  LANGUAGE NonReservedWord_or_Sconst
7923  {
7924  $$ = cat_str(2,mm_strdup("language"),$2);
7925 }
7926 ;
7927 
7928 
7929  CreateCastStmt:
7930  CREATE CAST '(' Typename AS Typename ')' WITH FUNCTION function_with_argtypes cast_context
7931  {
7932  $$ = cat_str(7,mm_strdup("create cast ("),$4,mm_strdup("as"),$6,mm_strdup(") with function"),$10,$11);
7933 }
7934 |  CREATE CAST '(' Typename AS Typename ')' WITHOUT FUNCTION cast_context
7935  {
7936  $$ = cat_str(6,mm_strdup("create cast ("),$4,mm_strdup("as"),$6,mm_strdup(") without function"),$10);
7937 }
7938 |  CREATE CAST '(' Typename AS Typename ')' WITH INOUT cast_context
7939  {
7940  $$ = cat_str(6,mm_strdup("create cast ("),$4,mm_strdup("as"),$6,mm_strdup(") with inout"),$10);
7941 }
7942 ;
7943 
7944 
7945  cast_context:
7946  AS IMPLICIT_P
7947  {
7948  $$ = mm_strdup("as implicit");
7949 }
7950 |  AS ASSIGNMENT
7951  {
7952  $$ = mm_strdup("as assignment");
7953 }
7954 |
7955  {
7956  $$=EMPTY; }
7957 ;
7958 
7959 
7960  DropCastStmt:
7961  DROP CAST opt_if_exists '(' Typename AS Typename ')' opt_drop_behavior
7962  {
7963  $$ = cat_str(8,mm_strdup("drop cast"),$3,mm_strdup("("),$5,mm_strdup("as"),$7,mm_strdup(")"),$9);
7964 }
7965 ;
7966 
7967 
7968  opt_if_exists:
7969  IF_P EXISTS
7970  {
7971  $$ = mm_strdup("if exists");
7972 }
7973 |
7974  {
7975  $$=EMPTY; }
7976 ;
7977 
7978 
7979  CreateTransformStmt:
7980  CREATE opt_or_replace TRANSFORM FOR Typename LANGUAGE name '(' transform_element_list ')'
7981  {
7982  $$ = cat_str(9,mm_strdup("create"),$2,mm_strdup("transform for"),$5,mm_strdup("language"),$7,mm_strdup("("),$9,mm_strdup(")"));
7983 }
7984 ;
7985 
7986 
7987  transform_element_list:
7988  FROM SQL_P WITH FUNCTION function_with_argtypes ',' TO SQL_P WITH FUNCTION function_with_argtypes
7989  {
7990  $$ = cat_str(4,mm_strdup("from sql with function"),$5,mm_strdup(", to sql with function"),$11);
7991 }
7992 |  TO SQL_P WITH FUNCTION function_with_argtypes ',' FROM SQL_P WITH FUNCTION function_with_argtypes
7993  {
7994  $$ = cat_str(4,mm_strdup("to sql with function"),$5,mm_strdup(", from sql with function"),$11);
7995 }
7996 |  FROM SQL_P WITH FUNCTION function_with_argtypes
7997  {
7998  $$ = cat_str(2,mm_strdup("from sql with function"),$5);
7999 }
8000 |  TO SQL_P WITH FUNCTION function_with_argtypes
8001  {
8002  $$ = cat_str(2,mm_strdup("to sql with function"),$5);
8003 }
8004 ;
8005 
8006 
8007  DropTransformStmt:
8008  DROP TRANSFORM opt_if_exists FOR Typename LANGUAGE name opt_drop_behavior
8009  {
8010  $$ = cat_str(7,mm_strdup("drop transform"),$3,mm_strdup("for"),$5,mm_strdup("language"),$7,$8);
8011 }
8012 ;
8013 
8014 
8015  ReindexStmt:
8016  REINDEX reindex_target_type qualified_name
8017  {
8018  $$ = cat_str(3,mm_strdup("reindex"),$2,$3);
8019 }
8020 |  REINDEX reindex_target_multitable name
8021  {
8022  $$ = cat_str(3,mm_strdup("reindex"),$2,$3);
8023 }
8024 |  REINDEX '(' reindex_option_list ')' reindex_target_type qualified_name
8025  {
8026  $$ = cat_str(5,mm_strdup("reindex ("),$3,mm_strdup(")"),$5,$6);
8027 }
8028 |  REINDEX '(' reindex_option_list ')' reindex_target_multitable name
8029  {
8030  $$ = cat_str(5,mm_strdup("reindex ("),$3,mm_strdup(")"),$5,$6);
8031 }
8032 ;
8033 
8034 
8035  reindex_target_type:
8036  INDEX
8037  {
8038  $$ = mm_strdup("index");
8039 }
8040 |  TABLE
8041  {
8042  $$ = mm_strdup("table");
8043 }
8044 ;
8045 
8046 
8047  reindex_target_multitable:
8048  SCHEMA
8049  {
8050  $$ = mm_strdup("schema");
8051 }
8052 |  SYSTEM_P
8053  {
8054  $$ = mm_strdup("system");
8055 }
8056 |  DATABASE
8057  {
8058  $$ = mm_strdup("database");
8059 }
8060 ;
8061 
8062 
8063  reindex_option_list:
8064  reindex_option_elem
8065  {
8066  $$ = $1;
8067 }
8068 |  reindex_option_list ',' reindex_option_elem
8069  {
8070  $$ = cat_str(3,$1,mm_strdup(","),$3);
8071 }
8072 ;
8073 
8074 
8075  reindex_option_elem:
8076  VERBOSE
8077  {
8078  $$ = mm_strdup("verbose");
8079 }
8080 ;
8081 
8082 
8083  AlterTblSpcStmt:
8084  ALTER TABLESPACE name SET reloptions
8085  {
8086  $$ = cat_str(4,mm_strdup("alter tablespace"),$3,mm_strdup("set"),$5);
8087 }
8088 |  ALTER TABLESPACE name RESET reloptions
8089  {
8090  $$ = cat_str(4,mm_strdup("alter tablespace"),$3,mm_strdup("reset"),$5);
8091 }
8092 ;
8093 
8094 
8095  RenameStmt:
8096  ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
8097  {
8098  $$ = cat_str(4,mm_strdup("alter aggregate"),$3,mm_strdup("rename to"),$6);
8099 }
8100 |  ALTER COLLATION any_name RENAME TO name
8101  {
8102  $$ = cat_str(4,mm_strdup("alter collation"),$3,mm_strdup("rename to"),$6);
8103 }
8104 |  ALTER CONVERSION_P any_name RENAME TO name
8105  {
8106  $$ = cat_str(4,mm_strdup("alter conversion"),$3,mm_strdup("rename to"),$6);
8107 }
8108 |  ALTER DATABASE database_name RENAME TO database_name
8109  {
8110  $$ = cat_str(4,mm_strdup("alter database"),$3,mm_strdup("rename to"),$6);
8111 }
8112 |  ALTER DOMAIN_P any_name RENAME TO name
8113  {
8114  $$ = cat_str(4,mm_strdup("alter domain"),$3,mm_strdup("rename to"),$6);
8115 }
8116 |  ALTER DOMAIN_P any_name RENAME CONSTRAINT name TO name
8117  {
8118  $$ = cat_str(6,mm_strdup("alter domain"),$3,mm_strdup("rename constraint"),$6,mm_strdup("to"),$8);
8119 }
8120 |  ALTER FOREIGN DATA_P WRAPPER name RENAME TO name
8121  {
8122  $$ = cat_str(4,mm_strdup("alter foreign data wrapper"),$5,mm_strdup("rename to"),$8);
8123 }
8124 |  ALTER FUNCTION function_with_argtypes RENAME TO name
8125  {
8126  $$ = cat_str(4,mm_strdup("alter function"),$3,mm_strdup("rename to"),$6);
8127 }
8128 |  ALTER GROUP_P RoleId RENAME TO RoleId
8129  {
8130  $$ = cat_str(4,mm_strdup("alter group"),$3,mm_strdup("rename to"),$6);
8131 }
8132 |  ALTER opt_procedural LANGUAGE name RENAME TO name
8133  {
8134  $$ = cat_str(6,mm_strdup("alter"),$2,mm_strdup("language"),$4,mm_strdup("rename to"),$7);
8135 }
8136 |  ALTER OPERATOR CLASS any_name USING access_method RENAME TO name
8137  {
8138  $$ = cat_str(6,mm_strdup("alter operator class"),$4,mm_strdup("using"),$6,mm_strdup("rename to"),$9);
8139 }
8140 |  ALTER OPERATOR FAMILY any_name USING access_method RENAME TO name
8141  {
8142  $$ = cat_str(6,mm_strdup("alter operator family"),$4,mm_strdup("using"),$6,mm_strdup("rename to"),$9);
8143 }
8144 |  ALTER POLICY name ON qualified_name RENAME TO name
8145  {
8146  $$ = cat_str(6,mm_strdup("alter policy"),$3,mm_strdup("on"),$5,mm_strdup("rename to"),$8);
8147 }
8148 |  ALTER POLICY IF_P EXISTS name ON qualified_name RENAME TO name
8149  {
8150  $$ = cat_str(6,mm_strdup("alter policy if exists"),$5,mm_strdup("on"),$7,mm_strdup("rename to"),$10);
8151 }
8152 |  ALTER PROCEDURE function_with_argtypes RENAME TO name
8153  {
8154  $$ = cat_str(4,mm_strdup("alter procedure"),$3,mm_strdup("rename to"),$6);
8155 }
8156 |  ALTER PUBLICATION name RENAME TO name
8157  {
8158  $$ = cat_str(4,mm_strdup("alter publication"),$3,mm_strdup("rename to"),$6);
8159 }
8160 |  ALTER ROUTINE function_with_argtypes RENAME TO name
8161  {
8162  $$ = cat_str(4,mm_strdup("alter routine"),$3,mm_strdup("rename to"),$6);
8163 }
8164 |  ALTER SCHEMA name RENAME TO name
8165  {
8166  $$ = cat_str(4,mm_strdup("alter schema"),$3,mm_strdup("rename to"),$6);
8167 }
8168 |  ALTER SERVER name RENAME TO name
8169  {
8170  $$ = cat_str(4,mm_strdup("alter server"),$3,mm_strdup("rename to"),$6);
8171 }
8172 |  ALTER SUBSCRIPTION name RENAME TO name
8173  {
8174  $$ = cat_str(4,mm_strdup("alter subscription"),$3,mm_strdup("rename to"),$6);
8175 }
8176 |  ALTER TABLE relation_expr RENAME TO name
8177  {
8178  $$ = cat_str(4,mm_strdup("alter table"),$3,mm_strdup("rename to"),$6);
8179 }
8180 |  ALTER TABLE IF_P EXISTS relation_expr RENAME TO name
8181  {
8182  $$ = cat_str(4,mm_strdup("alter table if exists"),$5,mm_strdup("rename to"),$8);
8183 }
8184 |  ALTER SEQUENCE qualified_name RENAME TO name
8185  {
8186  $$ = cat_str(4,mm_strdup("alter sequence"),$3,mm_strdup("rename to"),$6);
8187 }
8188 |  ALTER SEQUENCE IF_P EXISTS qualified_name RENAME TO name
8189  {
8190  $$ = cat_str(4,mm_strdup("alter sequence if exists"),$5,mm_strdup("rename to"),$8);
8191 }
8192 |  ALTER VIEW qualified_name RENAME TO name
8193  {
8194  $$ = cat_str(4,mm_strdup("alter view"),$3,mm_strdup("rename to"),$6);
8195 }
8196 |  ALTER VIEW IF_P EXISTS qualified_name RENAME TO name
8197  {
8198  $$ = cat_str(4,mm_strdup("alter view if exists"),$5,mm_strdup("rename to"),$8);
8199 }
8200 |  ALTER MATERIALIZED VIEW qualified_name RENAME TO name
8201  {
8202  $$ = cat_str(4,mm_strdup("alter materialized view"),$4,mm_strdup("rename to"),$7);
8203 }
8204 |  ALTER MATERIALIZED VIEW IF_P EXISTS qualified_name RENAME TO name
8205  {
8206  $$ = cat_str(4,mm_strdup("alter materialized view if exists"),$6,mm_strdup("rename to"),$9);
8207 }
8208 |  ALTER INDEX qualified_name RENAME TO name
8209  {
8210  $$ = cat_str(4,mm_strdup("alter index"),$3,mm_strdup("rename to"),$6);
8211 }
8212 |  ALTER INDEX IF_P EXISTS qualified_name RENAME TO name
8213  {
8214  $$ = cat_str(4,mm_strdup("alter index if exists"),$5,mm_strdup("rename to"),$8);
8215 }
8216 |  ALTER FOREIGN TABLE relation_expr RENAME TO name
8217  {
8218  $$ = cat_str(4,mm_strdup("alter foreign table"),$4,mm_strdup("rename to"),$7);
8219 }
8220 |  ALTER FOREIGN TABLE IF_P EXISTS relation_expr RENAME TO name
8221  {
8222  $$ = cat_str(4,mm_strdup("alter foreign table if exists"),$6,mm_strdup("rename to"),$9);
8223 }
8224 |  ALTER TABLE relation_expr RENAME opt_column name TO name
8225  {
8226  $$ = cat_str(7,mm_strdup("alter table"),$3,mm_strdup("rename"),$5,$6,mm_strdup("to"),$8);
8227 }
8228 |  ALTER TABLE IF_P EXISTS relation_expr RENAME opt_column name TO name
8229  {
8230  $$ = cat_str(7,mm_strdup("alter table if exists"),$5,mm_strdup("rename"),$7,$8,mm_strdup("to"),$10);
8231 }
8232 |  ALTER MATERIALIZED VIEW qualified_name RENAME opt_column name TO name
8233  {
8234  $$ = cat_str(7,mm_strdup("alter materialized view"),$4,mm_strdup("rename"),$6,$7,mm_strdup("to"),$9);
8235 }
8236 |  ALTER MATERIALIZED VIEW IF_P EXISTS qualified_name RENAME opt_column name TO name
8237  {
8238  $$ = cat_str(7,mm_strdup("alter materialized view if exists"),$6,mm_strdup("rename"),$8,$9,mm_strdup("to"),$11);
8239 }
8240 |  ALTER TABLE relation_expr RENAME CONSTRAINT name TO name
8241  {
8242  $$ = cat_str(6,mm_strdup("alter table"),$3,mm_strdup("rename constraint"),$6,mm_strdup("to"),$8);
8243 }
8244 |  ALTER TABLE IF_P EXISTS relation_expr RENAME CONSTRAINT name TO name
8245  {
8246  $$ = cat_str(6,mm_strdup("alter table if exists"),$5,mm_strdup("rename constraint"),$8,mm_strdup("to"),$10);
8247 }
8248 |  ALTER FOREIGN TABLE relation_expr RENAME opt_column name TO name
8249  {
8250  $$ = cat_str(7,mm_strdup("alter foreign table"),$4,mm_strdup("rename"),$6,$7,mm_strdup("to"),$9);
8251 }
8252 |  ALTER FOREIGN TABLE IF_P EXISTS relation_expr RENAME opt_column name TO name
8253  {
8254  $$ = cat_str(7,mm_strdup("alter foreign table if exists"),$6,mm_strdup("rename"),$8,$9,mm_strdup("to"),$11);
8255 }
8256 |  ALTER RULE name ON qualified_name RENAME TO name
8257  {
8258  $$ = cat_str(6,mm_strdup("alter rule"),$3,mm_strdup("on"),$5,mm_strdup("rename to"),$8);
8259 }
8260 |  ALTER TRIGGER name ON qualified_name RENAME TO name
8261  {
8262  $$ = cat_str(6,mm_strdup("alter trigger"),$3,mm_strdup("on"),$5,mm_strdup("rename to"),$8);
8263 }
8264 |  ALTER EVENT TRIGGER name RENAME TO name
8265  {
8266  $$ = cat_str(4,mm_strdup("alter event trigger"),$4,mm_strdup("rename to"),$7);
8267 }
8268 |  ALTER ROLE RoleId RENAME TO RoleId
8269  {
8270  $$ = cat_str(4,mm_strdup("alter role"),$3,mm_strdup("rename to"),$6);
8271 }
8272 |  ALTER USER RoleId RENAME TO RoleId
8273  {
8274  $$ = cat_str(4,mm_strdup("alter user"),$3,mm_strdup("rename to"),$6);
8275 }
8276 |  ALTER TABLESPACE name RENAME TO name
8277  {
8278  $$ = cat_str(4,mm_strdup("alter tablespace"),$3,mm_strdup("rename to"),$6);
8279 }
8280 |  ALTER STATISTICS any_name RENAME TO name
8281  {
8282  $$ = cat_str(4,mm_strdup("alter statistics"),$3,mm_strdup("rename to"),$6);
8283 }
8284 |  ALTER TEXT_P SEARCH PARSER any_name RENAME TO name
8285  {
8286  $$ = cat_str(4,mm_strdup("alter text search parser"),$5,mm_strdup("rename to"),$8);
8287 }
8288 |  ALTER TEXT_P SEARCH DICTIONARY any_name RENAME TO name
8289  {
8290  $$ = cat_str(4,mm_strdup("alter text search dictionary"),$5,mm_strdup("rename to"),$8);
8291 }
8292 |  ALTER TEXT_P SEARCH TEMPLATE any_name RENAME TO name
8293  {
8294  $$ = cat_str(4,mm_strdup("alter text search template"),$5,mm_strdup("rename to"),$8);
8295 }
8296 |  ALTER TEXT_P SEARCH CONFIGURATION any_name RENAME TO name
8297  {
8298  $$ = cat_str(4,mm_strdup("alter text search configuration"),$5,mm_strdup("rename to"),$8);
8299 }
8300 |  ALTER TYPE_P any_name RENAME TO name
8301  {
8302  $$ = cat_str(4,mm_strdup("alter type"),$3,mm_strdup("rename to"),$6);
8303 }
8304 |  ALTER TYPE_P any_name RENAME ATTRIBUTE name TO name opt_drop_behavior
8305  {
8306  $$ = cat_str(7,mm_strdup("alter type"),$3,mm_strdup("rename attribute"),$6,mm_strdup("to"),$8,$9);
8307 }
8308 ;
8309 
8310 
8311  opt_column:
8312  COLUMN
8313  {
8314  $$ = mm_strdup("column");
8315 }
8316 |
8317  {
8318  $$=EMPTY; }
8319 ;
8320 
8321 
8322  opt_set_data:
8323  SET DATA_P
8324  {
8325  $$ = mm_strdup("set data");
8326 }
8327 |
8328  {
8329  $$=EMPTY; }
8330 ;
8331 
8332 
8333  AlterObjectDependsStmt:
8334  ALTER FUNCTION function_with_argtypes DEPENDS ON EXTENSION name
8335  {
8336  $$ = cat_str(4,mm_strdup("alter function"),$3,mm_strdup("depends on extension"),$7);
8337 }
8338 |  ALTER PROCEDURE function_with_argtypes DEPENDS ON EXTENSION name
8339  {
8340  $$ = cat_str(4,mm_strdup("alter procedure"),$3,mm_strdup("depends on extension"),$7);
8341 }
8342 |  ALTER ROUTINE function_with_argtypes DEPENDS ON EXTENSION name
8343  {
8344  $$ = cat_str(4,mm_strdup("alter routine"),$3,mm_strdup("depends on extension"),$7);
8345 }
8346 |  ALTER TRIGGER name ON qualified_name DEPENDS ON EXTENSION name
8347  {
8348  $$ = cat_str(6,mm_strdup("alter trigger"),$3,mm_strdup("on"),$5,mm_strdup("depends on extension"),$9);
8349 }
8350 |  ALTER MATERIALIZED VIEW qualified_name DEPENDS ON EXTENSION name
8351  {
8352  $$ = cat_str(4,mm_strdup("alter materialized view"),$4,mm_strdup("depends on extension"),$8);
8353 }
8354 |  ALTER INDEX qualified_name DEPENDS ON EXTENSION name
8355  {
8356  $$ = cat_str(4,mm_strdup("alter index"),$3,mm_strdup("depends on extension"),$7);
8357 }
8358 ;
8359 
8360 
8361  AlterObjectSchemaStmt:
8362  ALTER AGGREGATE aggregate_with_argtypes SET SCHEMA name
8363  {
8364  $$ = cat_str(4,mm_strdup("alter aggregate"),$3,mm_strdup("set schema"),$6);
8365 }
8366 |  ALTER COLLATION any_name SET SCHEMA name
8367  {
8368  $$ = cat_str(4,mm_strdup("alter collation"),$3,mm_strdup("set schema"),$6);
8369 }
8370 |  ALTER CONVERSION_P any_name SET SCHEMA name
8371  {
8372  $$ = cat_str(4,mm_strdup("alter conversion"),$3,mm_strdup("set schema"),$6);
8373 }
8374 |  ALTER DOMAIN_P any_name SET SCHEMA name
8375  {
8376  $$ = cat_str(4,mm_strdup("alter domain"),$3,mm_strdup("set schema"),$6);
8377 }
8378 |  ALTER EXTENSION name SET SCHEMA name
8379  {
8380  $$ = cat_str(4,mm_strdup("alter extension"),$3,mm_strdup("set schema"),$6);
8381 }
8382 |  ALTER FUNCTION function_with_argtypes SET SCHEMA name
8383  {
8384  $$ = cat_str(4,mm_strdup("alter function"),$3,mm_strdup("set schema"),$6);
8385 }
8386 |  ALTER OPERATOR operator_with_argtypes SET SCHEMA name
8387  {
8388  $$ = cat_str(4,mm_strdup("alter operator"),$3,mm_strdup("set schema"),$6);
8389 }
8390 |  ALTER OPERATOR CLASS any_name USING access_method SET SCHEMA name
8391  {
8392  $$ = cat_str(6,mm_strdup("alter operator class"),$4,mm_strdup("using"),$6,mm_strdup("set schema"),$9);
8393 }
8394 |  ALTER OPERATOR FAMILY any_name USING access_method SET SCHEMA name
8395  {
8396  $$ = cat_str(6,mm_strdup("alter operator family"),$4,mm_strdup("using"),$6,mm_strdup("set schema"),$9);
8397 }
8398 |  ALTER PROCEDURE function_with_argtypes SET SCHEMA name
8399  {
8400  $$ = cat_str(4,mm_strdup("alter procedure"),$3,mm_strdup("set schema"),$6);
8401 }
8402 |  ALTER ROUTINE function_with_argtypes SET SCHEMA name
8403  {
8404  $$ = cat_str(4,mm_strdup("alter routine"),$3,mm_strdup("set schema"),$6);
8405 }
8406 |  ALTER TABLE relation_expr SET SCHEMA name
8407  {
8408  $$ = cat_str(4,mm_strdup("alter table"),$3,mm_strdup("set schema"),$6);
8409 }
8410 |  ALTER TABLE IF_P EXISTS relation_expr SET SCHEMA name
8411  {
8412  $$ = cat_str(4,mm_strdup("alter table if exists"),$5,mm_strdup("set schema"),$8);
8413 }
8414 |  ALTER STATISTICS any_name SET SCHEMA name
8415  {
8416  $$ = cat_str(4,mm_strdup("alter statistics"),$3,mm_strdup("set schema"),$6);
8417 }
8418 |  ALTER TEXT_P SEARCH PARSER any_name SET SCHEMA name
8419  {
8420  $$ = cat_str(4,mm_strdup("alter text search parser"),$5,mm_strdup("set schema"),$8);
8421 }
8422 |  ALTER TEXT_P SEARCH DICTIONARY any_name SET SCHEMA name
8423  {
8424  $$ = cat_str(4,mm_strdup("alter text search dictionary"),$5,mm_strdup("set schema"),$8);
8425 }
8426 |  ALTER TEXT_P SEARCH TEMPLATE any_name SET SCHEMA name
8427  {
8428  $$ = cat_str(4,mm_strdup("alter text search template"),$5,mm_strdup("set schema"),$8);
8429 }
8430 |  ALTER TEXT_P SEARCH CONFIGURATION any_name SET SCHEMA name
8431  {
8432  $$ = cat_str(4,mm_strdup("alter text search configuration"),$5,mm_strdup("set schema"),$8);
8433 }
8434 |  ALTER SEQUENCE qualified_name SET SCHEMA name
8435  {
8436  $$ = cat_str(4,mm_strdup("alter sequence"),$3,mm_strdup("set schema"),$6);
8437 }
8438 |  ALTER SEQUENCE IF_P EXISTS qualified_name SET SCHEMA name
8439  {
8440  $$ = cat_str(4,mm_strdup("alter sequence if exists"),$5,mm_strdup("set schema"),$8);
8441 }
8442 |  ALTER VIEW qualified_name SET SCHEMA name
8443  {
8444  $$ = cat_str(4,mm_strdup("alter view"),$3,mm_strdup("set schema"),$6);
8445 }
8446 |  ALTER VIEW IF_P EXISTS qualified_name SET SCHEMA name
8447  {
8448  $$ = cat_str(4,mm_strdup("alter view if exists"),$5,mm_strdup("set schema"),$8);
8449 }
8450 |  ALTER MATERIALIZED VIEW qualified_name SET SCHEMA name
8451  {
8452  $$ = cat_str(4,mm_strdup("alter materialized view"),$4,mm_strdup("set schema"),$7);
8453 }
8454 |  ALTER MATERIALIZED VIEW IF_P EXISTS qualified_name SET SCHEMA name
8455  {
8456  $$ = cat_str(4,mm_strdup("alter materialized view if exists"),$6,mm_strdup("set schema"),$9);
8457 }
8458 |  ALTER FOREIGN TABLE relation_expr SET SCHEMA name
8459  {
8460  $$ = cat_str(4,mm_strdup("alter foreign table"),$4,mm_strdup("set schema"),$7);
8461 }
8462 |  ALTER FOREIGN TABLE IF_P EXISTS relation_expr SET SCHEMA name
8463  {
8464  $$ = cat_str(4,mm_strdup("alter foreign table if exists"),$6,mm_strdup("set schema"),$9);
8465 }
8466 |  ALTER TYPE_P any_name SET SCHEMA name
8467  {
8468  $$ = cat_str(4,mm_strdup("alter type"),$3,mm_strdup("set schema"),$6);
8469 }
8470 ;
8471 
8472 
8473  AlterOperatorStmt:
8474  ALTER OPERATOR operator_with_argtypes SET '(' operator_def_list ')'
8475  {
8476  $$ = cat_str(5,mm_strdup("alter operator"),$3,mm_strdup("set ("),$6,mm_strdup(")"));
8477 }
8478 ;
8479 
8480 
8481  operator_def_list:
8482  operator_def_elem
8483  {
8484  $$ = $1;
8485 }
8486 |  operator_def_list ',' operator_def_elem
8487  {
8488  $$ = cat_str(3,$1,mm_strdup(","),$3);
8489 }
8490 ;
8491 
8492 
8493  operator_def_elem:
8494  ColLabel '=' NONE
8495  {
8496  $$ = cat_str(2,$1,mm_strdup("= none"));
8497 }
8498 |  ColLabel '=' operator_def_arg
8499  {
8500  $$ = cat_str(3,$1,mm_strdup("="),$3);
8501 }
8502 ;
8503 
8504 
8505  operator_def_arg:
8506  func_type
8507  {
8508  $$ = $1;
8509 }
8510 |  reserved_keyword
8511  {
8512  $$ = $1;
8513 }
8514 |  qual_all_Op
8515  {
8516  $$ = $1;
8517 }
8518 |  NumericOnly
8519  {
8520  $$ = $1;
8521 }
8522 |  ecpg_sconst
8523  {
8524  $$ = $1;
8525 }
8526 ;
8527 
8528 
8529  AlterOwnerStmt:
8530  ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
8531  {
8532  $$ = cat_str(4,mm_strdup("alter aggregate"),$3,mm_strdup("owner to"),$6);
8533 }
8534 |  ALTER COLLATION any_name OWNER TO RoleSpec
8535  {
8536  $$ = cat_str(4,mm_strdup("alter collation"),$3,mm_strdup("owner to"),$6);
8537 }
8538 |  ALTER CONVERSION_P any_name OWNER TO RoleSpec
8539  {
8540  $$ = cat_str(4,mm_strdup("alter conversion"),$3,mm_strdup("owner to"),$6);
8541 }
8542 |  ALTER DATABASE database_name OWNER TO RoleSpec
8543  {
8544  $$ = cat_str(4,mm_strdup("alter database"),$3,mm_strdup("owner to"),$6);
8545 }
8546 |  ALTER DOMAIN_P any_name OWNER TO RoleSpec
8547  {
8548  $$ = cat_str(4,mm_strdup("alter domain"),$3,mm_strdup("owner to"),$6);
8549 }
8550 |  ALTER FUNCTION function_with_argtypes OWNER TO RoleSpec
8551  {
8552  $$ = cat_str(4,mm_strdup("alter function"),$3,mm_strdup("owner to"),$6);
8553 }
8554 |  ALTER opt_procedural LANGUAGE name OWNER TO RoleSpec
8555  {
8556  $$ = cat_str(6,mm_strdup("alter"),$2,mm_strdup("language"),$4,mm_strdup("owner to"),$7);
8557 }
8558 |  ALTER LARGE_P OBJECT_P NumericOnly OWNER TO RoleSpec
8559  {
8560  $$ = cat_str(4,mm_strdup("alter large object"),$4,mm_strdup("owner to"),$7);
8561 }
8562 |  ALTER OPERATOR operator_with_argtypes OWNER TO RoleSpec
8563  {
8564  $$ = cat_str(4,mm_strdup("alter operator"),$3,mm_strdup("owner to"),$6);
8565 }
8566 |  ALTER OPERATOR CLASS any_name USING access_method OWNER TO RoleSpec
8567  {
8568  $$ = cat_str(6,mm_strdup("alter operator class"),$4,mm_strdup("using"),$6,mm_strdup("owner to"),$9);
8569 }
8570 |  ALTER OPERATOR FAMILY any_name USING access_method OWNER TO RoleSpec
8571  {
8572  $$ = cat_str(6,mm_strdup("alter operator family"),$4,mm_strdup("using"),$6,mm_strdup("owner to"),$9);
8573 }
8574 |  ALTER PROCEDURE function_with_argtypes OWNER TO RoleSpec
8575  {
8576  $$ = cat_str(4,mm_strdup("alter procedure"),$3,mm_strdup("owner to"),$6);
8577 }
8578 |  ALTER ROUTINE function_with_argtypes OWNER TO RoleSpec
8579  {
8580  $$ = cat_str(4,mm_strdup("alter routine"),$3,mm_strdup("owner to"),$6);
8581 }
8582 |  ALTER SCHEMA name OWNER TO RoleSpec
8583  {
8584  $$ = cat_str(4,mm_strdup("alter schema"),$3,mm_strdup("owner to"),$6);
8585 }
8586 |  ALTER TYPE_P any_name OWNER TO RoleSpec
8587  {
8588  $$ = cat_str(4,mm_strdup("alter type"),$3,mm_strdup("owner to"),$6);
8589 }
8590 |  ALTER TABLESPACE name OWNER TO RoleSpec
8591  {
8592  $$ = cat_str(4,mm_strdup("alter tablespace"),$3,mm_strdup("owner to"),$6);
8593 }
8594 |  ALTER STATISTICS any_name OWNER TO RoleSpec
8595  {
8596  $$ = cat_str(4,mm_strdup("alter statistics"),$3,mm_strdup("owner to"),$6);
8597 }
8598 |  ALTER TEXT_P SEARCH DICTIONARY any_name OWNER TO RoleSpec
8599  {
8600  $$ = cat_str(4,mm_strdup("alter text search dictionary"),$5,mm_strdup("owner to"),$8);
8601 }
8602 |  ALTER TEXT_P SEARCH CONFIGURATION any_name OWNER TO RoleSpec
8603  {
8604  $$ = cat_str(4,mm_strdup("alter text search configuration"),$5,mm_strdup("owner to"),$8);
8605 }
8606 |  ALTER FOREIGN DATA_P WRAPPER name OWNER TO RoleSpec
8607  {
8608  $$ = cat_str(4,mm_strdup("alter foreign data wrapper"),$5,mm_strdup("owner to"),$8);
8609 }
8610 |  ALTER SERVER name OWNER TO RoleSpec
8611  {
8612  $$ = cat_str(4,mm_strdup("alter server"),$3,mm_strdup("owner to"),$6);
8613 }
8614 |  ALTER EVENT TRIGGER name OWNER TO RoleSpec
8615  {
8616  $$ = cat_str(4,mm_strdup("alter event trigger"),$4,mm_strdup("owner to"),$7);
8617 }
8618 |  ALTER PUBLICATION name OWNER TO RoleSpec
8619  {
8620  $$ = cat_str(4,mm_strdup("alter publication"),$3,mm_strdup("owner to"),$6);
8621 }
8622 |  ALTER SUBSCRIPTION name OWNER TO RoleSpec
8623  {
8624  $$ = cat_str(4,mm_strdup("alter subscription"),$3,mm_strdup("owner to"),$6);
8625 }
8626 ;
8627 
8628 
8629  CreatePublicationStmt:
8630  CREATE PUBLICATION name opt_publication_for_tables opt_definition
8631  {
8632  $$ = cat_str(4,mm_strdup("create publication"),$3,$4,$5);
8633 }
8634 ;
8635 
8636 
8637  opt_publication_for_tables:
8638  publication_for_tables
8639  {
8640  $$ = $1;
8641 }
8642 |
8643  {
8644  $$=EMPTY; }
8645 ;
8646 
8647 
8648  publication_for_tables:
8649  FOR TABLE relation_expr_list
8650  {
8651  $$ = cat_str(2,mm_strdup("for table"),$3);
8652 }
8653 |  FOR ALL TABLES
8654  {
8655  $$ = mm_strdup("for all tables");
8656 }
8657 ;
8658 
8659 
8660  AlterPublicationStmt:
8661  ALTER PUBLICATION name SET definition
8662  {
8663  $$ = cat_str(4,mm_strdup("alter publication"),$3,mm_strdup("set"),$5);
8664 }
8665 |  ALTER PUBLICATION name ADD_P TABLE relation_expr_list
8666  {
8667  $$ = cat_str(4,mm_strdup("alter publication"),$3,mm_strdup("add table"),$6);
8668 }
8669 |  ALTER PUBLICATION name SET TABLE relation_expr_list
8670  {
8671  $$ = cat_str(4,mm_strdup("alter publication"),$3,mm_strdup("set table"),$6);
8672 }
8673 |  ALTER PUBLICATION name DROP TABLE relation_expr_list
8674  {
8675  $$ = cat_str(4,mm_strdup("alter publication"),$3,mm_strdup("drop table"),$6);
8676 }
8677 ;
8678 
8679 
8680  CreateSubscriptionStmt:
8681  CREATE SUBSCRIPTION name CONNECTION ecpg_sconst PUBLICATION publication_name_list opt_definition
8682  {
8683  $$ = cat_str(7,mm_strdup("create subscription"),$3,mm_strdup("connection"),$5,mm_strdup("publication"),$7,$8);
8684 }
8685 ;
8686 
8687 
8688  publication_name_list:
8689  publication_name_item
8690  {
8691  $$ = $1;
8692 }
8693 |  publication_name_list ',' publication_name_item
8694  {
8695  $$ = cat_str(3,$1,mm_strdup(","),$3);
8696 }
8697 ;
8698 
8699 
8700  publication_name_item:
8701  ColLabel
8702  {
8703  $$ = $1;
8704 }
8705 ;
8706 
8707 
8708  AlterSubscriptionStmt:
8709  ALTER SUBSCRIPTION name SET definition
8710  {
8711  $$ = cat_str(4,mm_strdup("alter subscription"),$3,mm_strdup("set"),$5);
8712 }
8713 |  ALTER SUBSCRIPTION name CONNECTION ecpg_sconst
8714  {
8715  $$ = cat_str(4,mm_strdup("alter subscription"),$3,mm_strdup("connection"),$5);
8716 }
8717 |  ALTER SUBSCRIPTION name REFRESH PUBLICATION opt_definition
8718  {
8719  $$ = cat_str(4,mm_strdup("alter subscription"),$3,mm_strdup("refresh publication"),$6);
8720 }
8721 |  ALTER SUBSCRIPTION name SET PUBLICATION publication_name_list opt_definition
8722  {
8723  $$ = cat_str(5,mm_strdup("alter subscription"),$3,mm_strdup("set publication"),$6,$7);
8724 }
8725 |  ALTER SUBSCRIPTION name ENABLE_P
8726  {
8727  $$ = cat_str(3,mm_strdup("alter subscription"),$3,mm_strdup("enable"));
8728 }
8729 |  ALTER SUBSCRIPTION name DISABLE_P
8730  {
8731  $$ = cat_str(3,mm_strdup("alter subscription"),$3,mm_strdup("disable"));
8732 }
8733 ;
8734 
8735 
8736  DropSubscriptionStmt:
8737  DROP SUBSCRIPTION name opt_drop_behavior
8738  {
8739  $$ = cat_str(3,mm_strdup("drop subscription"),$3,$4);
8740 }
8741 |  DROP SUBSCRIPTION IF_P EXISTS name opt_drop_behavior
8742  {
8743  $$ = cat_str(3,mm_strdup("drop subscription if exists"),$5,$6);
8744 }
8745 ;
8746 
8747 
8748  RuleStmt:
8749  CREATE opt_or_replace RULE name AS ON event TO qualified_name where_clause DO opt_instead RuleActionList
8750  {
8751  $$ = 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);
8752 }
8753 ;
8754 
8755 
8756  RuleActionList:
8757  NOTHING
8758  {
8759  $$ = mm_strdup("nothing");
8760 }
8761 |  RuleActionStmt
8762  {
8763  $$ = $1;
8764 }
8765 |  '(' RuleActionMulti ')'
8766  {
8767  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
8768 }
8769 ;
8770 
8771 
8772  RuleActionMulti:
8773  RuleActionMulti ';' RuleActionStmtOrEmpty
8774  {
8775  $$ = cat_str(3,$1,mm_strdup(";"),$3);
8776 }
8777 |  RuleActionStmtOrEmpty
8778  {
8779  $$ = $1;
8780 }
8781 ;
8782 
8783 
8784  RuleActionStmt:
8785  SelectStmt
8786  {
8787  $$ = $1;
8788 }
8789 |  InsertStmt
8790  {
8791  $$ = $1;
8792 }
8793 |  UpdateStmt
8794  {
8795  $$ = $1;
8796 }
8797 |  DeleteStmt
8798  {
8799  $$ = $1;
8800 }
8801 |  NotifyStmt
8802  {
8803  $$ = $1;
8804 }
8805 ;
8806 
8807 
8808  RuleActionStmtOrEmpty:
8809  RuleActionStmt
8810  {
8811  $$ = $1;
8812 }
8813 |
8814  {
8815  $$=EMPTY; }
8816 ;
8817 
8818 
8819  event:
8820  SELECT
8821  {
8822  $$ = mm_strdup("select");
8823 }
8824 |  UPDATE
8825  {
8826  $$ = mm_strdup("update");
8827 }
8828 |  DELETE_P
8829  {
8830  $$ = mm_strdup("delete");
8831 }
8832 |  INSERT
8833  {
8834  $$ = mm_strdup("insert");
8835 }
8836 ;
8837 
8838 
8839  opt_instead:
8840  INSTEAD
8841  {
8842  $$ = mm_strdup("instead");
8843 }
8844 |  ALSO
8845  {
8846  $$ = mm_strdup("also");
8847 }
8848 |
8849  {
8850  $$=EMPTY; }
8851 ;
8852 
8853 
8854  NotifyStmt:
8855  NOTIFY ColId notify_payload
8856  {
8857  $$ = cat_str(3,mm_strdup("notify"),$2,$3);
8858 }
8859 ;
8860 
8861 
8862  notify_payload:
8863  ',' ecpg_sconst
8864  {
8865  $$ = cat_str(2,mm_strdup(","),$2);
8866 }
8867 |
8868  {
8869  $$=EMPTY; }
8870 ;
8871 
8872 
8873  ListenStmt:
8874  LISTEN ColId
8875  {
8876  $$ = cat_str(2,mm_strdup("listen"),$2);
8877 }
8878 ;
8879 
8880 
8881  UnlistenStmt:
8882  UNLISTEN ColId
8883  {
8884  $$ = cat_str(2,mm_strdup("unlisten"),$2);
8885 }
8886 |  UNLISTEN '*'
8887  {
8888  $$ = mm_strdup("unlisten *");
8889 }
8890 ;
8891 
8892 
8893  TransactionStmt:
8894  ABORT_P opt_transaction
8895  {
8896  $$ = cat_str(2,mm_strdup("abort"),$2);
8897 }
8898 |  BEGIN_P opt_transaction transaction_mode_list_or_empty
8899  {
8900  $$ = cat_str(3,mm_strdup("begin"),$2,$3);
8901 }
8902 |  START TRANSACTION transaction_mode_list_or_empty
8903  {
8904  $$ = cat_str(2,mm_strdup("start transaction"),$3);
8905 }
8906 |  COMMIT opt_transaction
8907  {
8908  $$ = cat_str(2,mm_strdup("commit"),$2);
8909 }
8910 |  END_P opt_transaction
8911  {
8912  $$ = cat_str(2,mm_strdup("end"),$2);
8913 }
8914 |  ROLLBACK opt_transaction
8915  {
8916  $$ = cat_str(2,mm_strdup("rollback"),$2);
8917 }
8918 |  SAVEPOINT ColId
8919  {
8920  $$ = cat_str(2,mm_strdup("savepoint"),$2);
8921 }
8922 |  RELEASE SAVEPOINT ColId
8923  {
8924  $$ = cat_str(2,mm_strdup("release savepoint"),$3);
8925 }
8926 |  RELEASE ColId
8927  {
8928  $$ = cat_str(2,mm_strdup("release"),$2);
8929 }
8930 |  ROLLBACK opt_transaction TO SAVEPOINT ColId
8931  {
8932  $$ = cat_str(4,mm_strdup("rollback"),$2,mm_strdup("to savepoint"),$5);
8933 }
8934 |  ROLLBACK opt_transaction TO ColId
8935  {
8936  $$ = cat_str(4,mm_strdup("rollback"),$2,mm_strdup("to"),$4);
8937 }
8938 |  PREPARE TRANSACTION ecpg_sconst
8939  {
8940  $$ = cat_str(2,mm_strdup("prepare transaction"),$3);
8941 }
8942 |  COMMIT PREPARED ecpg_sconst
8943  {
8944  $$ = cat_str(2,mm_strdup("commit prepared"),$3);
8945 }
8946 |  ROLLBACK PREPARED ecpg_sconst
8947  {
8948  $$ = cat_str(2,mm_strdup("rollback prepared"),$3);
8949 }
8950 ;
8951 
8952 
8953  opt_transaction:
8954  WORK
8955  {
8956  $$ = mm_strdup("work");
8957 }
8958 |  TRANSACTION
8959  {
8960  $$ = mm_strdup("transaction");
8961 }
8962 |
8963  {
8964  $$=EMPTY; }
8965 ;
8966 
8967 
8968  transaction_mode_item:
8969  ISOLATION LEVEL iso_level
8970  {
8971  $$ = cat_str(2,mm_strdup("isolation level"),$3);
8972 }
8973 |  READ ONLY
8974  {
8975  $$ = mm_strdup("read only");
8976 }
8977 |  READ WRITE
8978  {
8979  $$ = mm_strdup("read write");
8980 }
8981 |  DEFERRABLE
8982  {
8983  $$ = mm_strdup("deferrable");
8984 }
8985 |  NOT DEFERRABLE
8986  {
8987  $$ = mm_strdup("not deferrable");
8988 }
8989 ;
8990 
8991 
8992  transaction_mode_list:
8993  transaction_mode_item
8994  {
8995  $$ = $1;
8996 }
8997 |  transaction_mode_list ',' transaction_mode_item
8998  {
8999  $$ = cat_str(3,$1,mm_strdup(","),$3);
9000 }
9001 |  transaction_mode_list transaction_mode_item
9002  {
9003  $$ = cat_str(2,$1,$2);
9004 }
9005 ;
9006 
9007 
9008  transaction_mode_list_or_empty:
9009  transaction_mode_list
9010  {
9011  $$ = $1;
9012 }
9013 |
9014  {
9015  $$=EMPTY; }
9016 ;
9017 
9018 
9019  ViewStmt:
9020  CREATE OptTemp VIEW qualified_name opt_column_list opt_reloptions AS SelectStmt opt_check_option
9021  {
9022  $$ = cat_str(9,mm_strdup("create"),$2,mm_strdup("view"),$4,$5,$6,mm_strdup("as"),$8,$9);
9023 }
9024 |  CREATE OR REPLACE OptTemp VIEW qualified_name opt_column_list opt_reloptions AS SelectStmt opt_check_option
9025  {
9026  $$ = cat_str(9,mm_strdup("create or replace"),$4,mm_strdup("view"),$6,$7,$8,mm_strdup("as"),$10,$11);
9027 }
9028 |  CREATE OptTemp RECURSIVE VIEW qualified_name '(' columnList ')' opt_reloptions AS SelectStmt opt_check_option
9029  {
9030 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
9031  $$ = cat_str(11,mm_strdup("create"),$2,mm_strdup("recursive view"),$5,mm_strdup("("),$7,mm_strdup(")"),$9,mm_strdup("as"),$11,$12);
9032 }
9033 |  CREATE OR REPLACE OptTemp RECURSIVE VIEW qualified_name '(' columnList ')' opt_reloptions AS SelectStmt opt_check_option
9034  {
9035 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
9036  $$ = 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);
9037 }
9038 ;
9039 
9040 
9041  opt_check_option:
9042  WITH CHECK OPTION
9043  {
9044  $$ = mm_strdup("with check option");
9045 }
9046 |  WITH CASCADED CHECK OPTION
9047  {
9048  $$ = mm_strdup("with cascaded check option");
9049 }
9050 |  WITH LOCAL CHECK OPTION
9051  {
9052  $$ = mm_strdup("with local check option");
9053 }
9054 |
9055  {
9056  $$=EMPTY; }
9057 ;
9058 
9059 
9060  LoadStmt:
9061  LOAD file_name
9062  {
9063  $$ = cat_str(2,mm_strdup("load"),$2);
9064 }
9065 ;
9066 
9067 
9068  CreatedbStmt:
9069  CREATE DATABASE database_name opt_with createdb_opt_list
9070  {
9071  $$ = cat_str(4,mm_strdup("create database"),$3,$4,$5);
9072 }
9073 ;
9074 
9075 
9076  createdb_opt_list:
9077  createdb_opt_items
9078  {
9079  $$ = $1;
9080 }
9081 |
9082  {
9083  $$=EMPTY; }
9084 ;
9085 
9086 
9087  createdb_opt_items:
9088  createdb_opt_item
9089  {
9090  $$ = $1;
9091 }
9092 |  createdb_opt_items createdb_opt_item
9093  {
9094  $$ = cat_str(2,$1,$2);
9095 }
9096 ;
9097 
9098 
9099  createdb_opt_item:
9100  createdb_opt_name opt_equal SignedIconst
9101  {
9102  $$ = cat_str(3,$1,$2,$3);
9103 }
9104 |  createdb_opt_name opt_equal opt_boolean_or_string
9105  {
9106  $$ = cat_str(3,$1,$2,$3);
9107 }
9108 |  createdb_opt_name opt_equal DEFAULT
9109  {
9110  $$ = cat_str(3,$1,$2,mm_strdup("default"));
9111 }
9112 ;
9113 
9114 
9115  createdb_opt_name:
9116  ecpg_ident
9117  {
9118  $$ = $1;
9119 }
9120 |  CONNECTION LIMIT
9121  {
9122  $$ = mm_strdup("connection limit");
9123 }
9124 |  ENCODING
9125  {
9126  $$ = mm_strdup("encoding");
9127 }
9128 |  LOCATION
9129  {
9130  $$ = mm_strdup("location");
9131 }
9132 |  OWNER
9133  {
9134  $$ = mm_strdup("owner");
9135 }
9136 |  TABLESPACE
9137  {
9138  $$ = mm_strdup("tablespace");
9139 }
9140 |  TEMPLATE
9141  {
9142  $$ = mm_strdup("template");
9143 }
9144 ;
9145 
9146 
9147  opt_equal:
9148  '='
9149  {
9150  $$ = mm_strdup("=");
9151 }
9152 |
9153  {
9154  $$=EMPTY; }
9155 ;
9156 
9157 
9158  AlterDatabaseStmt:
9159  ALTER DATABASE database_name WITH createdb_opt_list
9160  {
9161  $$ = cat_str(4,mm_strdup("alter database"),$3,mm_strdup("with"),$5);
9162 }
9163 |  ALTER DATABASE database_name createdb_opt_list
9164  {
9165  $$ = cat_str(3,mm_strdup("alter database"),$3,$4);
9166 }
9167 |  ALTER DATABASE database_name SET TABLESPACE name
9168  {
9169  $$ = cat_str(4,mm_strdup("alter database"),$3,mm_strdup("set tablespace"),$6);
9170 }
9171 ;
9172 
9173 
9174  AlterDatabaseSetStmt:
9175  ALTER DATABASE database_name SetResetClause
9176  {
9177  $$ = cat_str(3,mm_strdup("alter database"),$3,$4);
9178 }
9179 ;
9180 
9181 
9182  DropdbStmt:
9183  DROP DATABASE database_name
9184  {
9185  $$ = cat_str(2,mm_strdup("drop database"),$3);
9186 }
9187 |  DROP DATABASE IF_P EXISTS database_name
9188  {
9189  $$ = cat_str(2,mm_strdup("drop database if exists"),$5);
9190 }
9191 ;
9192 
9193 
9194  AlterCollationStmt:
9195  ALTER COLLATION any_name REFRESH VERSION_P
9196  {
9197  $$ = cat_str(3,mm_strdup("alter collation"),$3,mm_strdup("refresh version"));
9198 }
9199 ;
9200 
9201 
9202  AlterSystemStmt:
9203  ALTER SYSTEM_P SET generic_set
9204  {
9205  $$ = cat_str(2,mm_strdup("alter system set"),$4);
9206 }
9207 |  ALTER SYSTEM_P RESET generic_reset
9208  {
9209  $$ = cat_str(2,mm_strdup("alter system reset"),$4);
9210 }
9211 ;
9212 
9213 
9214  CreateDomainStmt:
9215  CREATE DOMAIN_P any_name opt_as Typename ColQualList
9216  {
9217  $$ = cat_str(5,mm_strdup("create domain"),$3,$4,$5,$6);
9218 }
9219 ;
9220 
9221 
9222  AlterDomainStmt:
9223  ALTER DOMAIN_P any_name alter_column_default
9224  {
9225  $$ = cat_str(3,mm_strdup("alter domain"),$3,$4);
9226 }
9227 |  ALTER DOMAIN_P any_name DROP NOT NULL_P
9228  {
9229  $$ = cat_str(3,mm_strdup("alter domain"),$3,mm_strdup("drop not null"));
9230 }
9231 |  ALTER DOMAIN_P any_name SET NOT NULL_P
9232  {
9233  $$ = cat_str(3,mm_strdup("alter domain"),$3,mm_strdup("set not null"));
9234 }
9235 |  ALTER DOMAIN_P any_name ADD_P TableConstraint
9236  {
9237  $$ = cat_str(4,mm_strdup("alter domain"),$3,mm_strdup("add"),$5);
9238 }
9239 |  ALTER DOMAIN_P any_name DROP CONSTRAINT name opt_drop_behavior
9240  {
9241  $$ = cat_str(5,mm_strdup("alter domain"),$3,mm_strdup("drop constraint"),$6,$7);
9242 }
9243 |  ALTER DOMAIN_P any_name DROP CONSTRAINT IF_P EXISTS name opt_drop_behavior
9244  {
9245  $$ = cat_str(5,mm_strdup("alter domain"),$3,mm_strdup("drop constraint if exists"),$8,$9);
9246 }
9247 |  ALTER DOMAIN_P any_name VALIDATE CONSTRAINT name
9248  {
9249  $$ = cat_str(4,mm_strdup("alter domain"),$3,mm_strdup("validate constraint"),$6);
9250 }
9251 ;
9252 
9253 
9254  opt_as:
9255  AS
9256  {
9257  $$ = mm_strdup("as");
9258 }
9259 |
9260  {
9261  $$=EMPTY; }
9262 ;
9263 
9264 
9265  AlterTSDictionaryStmt:
9266  ALTER TEXT_P SEARCH DICTIONARY any_name definition
9267  {
9268  $$ = cat_str(3,mm_strdup("alter text search dictionary"),$5,$6);
9269 }
9270 ;
9271 
9272 
9273  AlterTSConfigurationStmt:
9274  ALTER TEXT_P SEARCH CONFIGURATION any_name ADD_P MAPPING FOR name_list any_with any_name_list
9275  {
9276  $$ = cat_str(6,mm_strdup("alter text search configuration"),$5,mm_strdup("add mapping for"),$9,$10,$11);
9277 }
9278 |  ALTER TEXT_P SEARCH CONFIGURATION any_name ALTER MAPPING FOR name_list any_with any_name_list
9279  {
9280  $$ = cat_str(6,mm_strdup("alter text search configuration"),$5,mm_strdup("alter mapping for"),$9,$10,$11);
9281 }
9282 |  ALTER TEXT_P SEARCH CONFIGURATION any_name ALTER MAPPING REPLACE any_name any_with any_name
9283  {
9284  $$ = cat_str(6,mm_strdup("alter text search configuration"),$5,mm_strdup("alter mapping replace"),$9,$10,$11);
9285 }
9286 |  ALTER TEXT_P SEARCH CONFIGURATION any_name ALTER MAPPING FOR name_list REPLACE any_name any_with any_name
9287  {
9288  $$ = cat_str(8,mm_strdup("alter text search configuration"),$5,mm_strdup("alter mapping for"),$9,mm_strdup("replace"),$11,$12,$13);
9289 }
9290 |  ALTER TEXT_P SEARCH CONFIGURATION any_name DROP MAPPING FOR name_list
9291  {
9292  $$ = cat_str(4,mm_strdup("alter text search configuration"),$5,mm_strdup("drop mapping for"),$9);
9293 }
9294 |  ALTER TEXT_P SEARCH CONFIGURATION any_name DROP MAPPING IF_P EXISTS FOR name_list
9295  {
9296  $$ = cat_str(4,mm_strdup("alter text search configuration"),$5,mm_strdup("drop mapping if exists for"),$11);
9297 }
9298 ;
9299 
9300 
9301  any_with:
9302  WITH
9303  {
9304  $$ = mm_strdup("with");
9305 }
9306 |  WITH_LA
9307  {
9308  $$ = mm_strdup("with");
9309 }
9310 ;
9311 
9312 
9313  CreateConversionStmt:
9314  CREATE opt_default CONVERSION_P any_name FOR ecpg_sconst TO ecpg_sconst FROM any_name
9315  {
9316  $$ = cat_str(10,mm_strdup("create"),$2,mm_strdup("conversion"),$4,mm_strdup("for"),$6,mm_strdup("to"),$8,mm_strdup("from"),$10);
9317 }
9318 ;
9319 
9320 
9321  ClusterStmt:
9322  CLUSTER opt_verbose qualified_name cluster_index_specification
9323  {
9324  $$ = cat_str(4,mm_strdup("cluster"),$2,$3,$4);
9325 }
9326 |  CLUSTER opt_verbose
9327  {
9328  $$ = cat_str(2,mm_strdup("cluster"),$2);
9329 }
9330 |  CLUSTER opt_verbose index_name ON qualified_name
9331  {
9332  $$ = cat_str(5,mm_strdup("cluster"),$2,$3,mm_strdup("on"),$5);
9333 }
9334 ;
9335 
9336 
9337  cluster_index_specification:
9338  USING index_name
9339  {
9340  $$ = cat_str(2,mm_strdup("using"),$2);
9341 }
9342 |
9343  {
9344  $$=EMPTY; }
9345 ;
9346 
9347 
9348  VacuumStmt:
9349  VACUUM opt_full opt_freeze opt_verbose opt_analyze opt_vacuum_relation_list
9350  {
9351  $$ = cat_str(6,mm_strdup("vacuum"),$2,$3,$4,$5,$6);
9352 }
9353 |  VACUUM '(' vacuum_option_list ')' opt_vacuum_relation_list
9354  {
9355  $$ = cat_str(4,mm_strdup("vacuum ("),$3,mm_strdup(")"),$5);
9356 }
9357 ;
9358 
9359 
9360  vacuum_option_list:
9361  vacuum_option_elem
9362  {
9363  $$ = $1;
9364 }
9365 |  vacuum_option_list ',' vacuum_option_elem
9366  {
9367  $$ = cat_str(3,$1,mm_strdup(","),$3);
9368 }
9369 ;
9370 
9371 
9372  vacuum_option_elem:
9373  analyze_keyword
9374  {
9375  $$ = $1;
9376 }
9377 |  VERBOSE
9378  {
9379  $$ = mm_strdup("verbose");
9380 }
9381 |  FREEZE
9382  {
9383  $$ = mm_strdup("freeze");
9384 }
9385 |  FULL
9386  {
9387  $$ = mm_strdup("full");
9388 }
9389 |  ecpg_ident
9390  {
9391  $$ = $1;
9392 }
9393 ;
9394 
9395 
9396  AnalyzeStmt:
9397  analyze_keyword opt_verbose opt_vacuum_relation_list
9398  {
9399  $$ = cat_str(3,$1,$2,$3);
9400 }
9401 |  analyze_keyword '(' analyze_option_list ')' opt_vacuum_relation_list
9402  {
9403  $$ = cat_str(5,$1,mm_strdup("("),$3,mm_strdup(")"),$5);
9404 }
9405 ;
9406 
9407 
9408  analyze_option_list:
9409  analyze_option_elem
9410  {
9411  $$ = $1;
9412 }
9413 |  analyze_option_list ',' analyze_option_elem
9414  {
9415  $$ = cat_str(3,$1,mm_strdup(","),$3);
9416 }
9417 ;
9418 
9419 
9420  analyze_option_elem:
9421  VERBOSE
9422  {
9423  $$ = mm_strdup("verbose");
9424 }
9425 ;
9426 
9427 
9428  analyze_keyword:
9429  ANALYZE
9430  {
9431  $$ = mm_strdup("analyze");
9432 }
9433 |  ANALYSE
9434  {
9435  $$ = mm_strdup("analyse");
9436 }
9437 ;
9438 
9439 
9440  opt_analyze:
9441  analyze_keyword
9442  {
9443  $$ = $1;
9444 }
9445 |
9446  {
9447  $$=EMPTY; }
9448 ;
9449 
9450 
9451  opt_verbose:
9452  VERBOSE
9453  {
9454  $$ = mm_strdup("verbose");
9455 }
9456 |
9457  {
9458  $$=EMPTY; }
9459 ;
9460 
9461 
9462  opt_full:
9463  FULL
9464  {
9465  $$ = mm_strdup("full");
9466 }
9467 |
9468  {
9469  $$=EMPTY; }
9470 ;
9471 
9472 
9473  opt_freeze:
9474  FREEZE
9475  {
9476  $$ = mm_strdup("freeze");
9477 }
9478 |
9479  {
9480  $$=EMPTY; }
9481 ;
9482 
9483 
9484  opt_name_list:
9485  '(' name_list ')'
9486  {
9487  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
9488 }
9489 |
9490  {
9491  $$=EMPTY; }
9492 ;
9493 
9494 
9495  vacuum_relation:
9496  qualified_name opt_name_list
9497  {
9498  $$ = cat_str(2,$1,$2);
9499 }
9500 ;
9501 
9502 
9503  vacuum_relation_list:
9504  vacuum_relation
9505  {
9506  $$ = $1;
9507 }
9508 |  vacuum_relation_list ',' vacuum_relation
9509  {
9510  $$ = cat_str(3,$1,mm_strdup(","),$3);
9511 }
9512 ;
9513 
9514 
9515  opt_vacuum_relation_list:
9516  vacuum_relation_list
9517  {
9518  $$ = $1;
9519 }
9520 |
9521  {
9522  $$=EMPTY; }
9523 ;
9524 
9525 
9526  ExplainStmt:
9527  EXPLAIN ExplainableStmt
9528  {
9529  $$ = cat_str(2,mm_strdup("explain"),$2);
9530 }
9531 |  EXPLAIN analyze_keyword opt_verbose ExplainableStmt
9532  {
9533  $$ = cat_str(4,mm_strdup("explain"),$2,$3,$4);
9534 }
9535 |  EXPLAIN VERBOSE ExplainableStmt
9536  {
9537  $$ = cat_str(2,mm_strdup("explain verbose"),$3);
9538 }
9539 |  EXPLAIN '(' explain_option_list ')' ExplainableStmt
9540  {
9541  $$ = cat_str(4,mm_strdup("explain ("),$3,mm_strdup(")"),$5);
9542 }
9543 ;
9544 
9545 
9546  ExplainableStmt:
9547  SelectStmt
9548  {
9549  $$ = $1;
9550 }
9551 |  InsertStmt
9552  {
9553  $$ = $1;
9554 }
9555 |  UpdateStmt
9556  {
9557  $$ = $1;
9558 }
9559 |  DeleteStmt
9560  {
9561  $$ = $1;
9562 }
9563 |  DeclareCursorStmt
9564  {
9565  $$ = $1;
9566 }
9567 |  CreateAsStmt
9568  {
9569  $$ = $1;
9570 }
9571 |  CreateMatViewStmt
9572  {
9573  $$ = $1;
9574 }
9575 |  RefreshMatViewStmt
9576  {
9577  $$ = $1;
9578 }
9579 |  ExecuteStmt
9580  {
9581  $$ = $1;
9582 }
9583 ;
9584 
9585 
9586  explain_option_list:
9587  explain_option_elem
9588  {
9589  $$ = $1;
9590 }
9591 |  explain_option_list ',' explain_option_elem
9592  {
9593  $$ = cat_str(3,$1,mm_strdup(","),$3);
9594 }
9595 ;
9596 
9597 
9598  explain_option_elem:
9599  explain_option_name explain_option_arg
9600  {
9601  $$ = cat_str(2,$1,$2);
9602 }
9603 ;
9604 
9605 
9606  explain_option_name:
9607  NonReservedWord
9608  {
9609  $$ = $1;
9610 }
9611 |  analyze_keyword
9612  {
9613  $$ = $1;
9614 }
9615 ;
9616 
9617 
9618  explain_option_arg:
9619  opt_boolean_or_string
9620  {
9621  $$ = $1;
9622 }
9623 |  NumericOnly
9624  {
9625  $$ = $1;
9626 }
9627 |
9628  {
9629  $$=EMPTY; }
9630 ;
9631 
9632 
9633  PrepareStmt:
9634 PREPARE prepared_name prep_type_clause AS PreparableStmt
9635 	{
9636 		$$.name = $2;
9637 		$$.type = $3;
9638 		$$.stmt = cat_str(3, mm_strdup("\""), $5, mm_strdup("\""));
9639 	}
9640 	| PREPARE prepared_name FROM execstring
9641 	{
9642 		$$.name = $2;
9643 		$$.type = NULL;
9644 		$$.stmt = $4;
9645 	}
9646 ;
9647 
9648 
9649  prep_type_clause:
9650  '(' type_list ')'
9651  {
9652  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
9653 }
9654 |
9655  {
9656  $$=EMPTY; }
9657 ;
9658 
9659 
9660  PreparableStmt:
9661  SelectStmt
9662  {
9663  $$ = $1;
9664 }
9665 |  InsertStmt
9666  {
9667  $$ = $1;
9668 }
9669 |  UpdateStmt
9670  {
9671  $$ = $1;
9672 }
9673 |  DeleteStmt
9674  {
9675  $$ = $1;
9676 }
9677 ;
9678 
9679 
9680  ExecuteStmt:
9681 EXECUTE prepared_name execute_param_clause execute_rest
9682 	{ $$ = $2; }
9683 |  CREATE OptTemp TABLE create_as_target AS EXECUTE name execute_param_clause opt_with_data
9684  {
9685  $$ = cat_str(8,mm_strdup("create"),$2,mm_strdup("table"),$4,mm_strdup("as execute"),$7,$8,$9);
9686 }
9687 |  CREATE OptTemp TABLE IF_P NOT EXISTS create_as_target AS EXECUTE name execute_param_clause opt_with_data
9688  {
9689  $$ = cat_str(8,mm_strdup("create"),$2,mm_strdup("table if not exists"),$7,mm_strdup("as execute"),$10,$11,$12);
9690 }
9691 ;
9692 
9693 
9694  execute_param_clause:
9695  '(' expr_list ')'
9696  {
9697  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
9698 }
9699 |
9700  {
9701  $$=EMPTY; }
9702 ;
9703 
9704 
9705  InsertStmt:
9706  opt_with_clause INSERT INTO insert_target insert_rest opt_on_conflict returning_clause
9707  {
9708  $$ = cat_str(6,$1,mm_strdup("insert into"),$4,$5,$6,$7);
9709 }
9710 ;
9711 
9712 
9713  insert_target:
9714  qualified_name
9715  {
9716  $$ = $1;
9717 }
9718 |  qualified_name AS ColId
9719  {
9720  $$ = cat_str(3,$1,mm_strdup("as"),$3);
9721 }
9722 ;
9723 
9724 
9725  insert_rest:
9726  SelectStmt
9727  {
9728  $$ = $1;
9729 }
9730 |  OVERRIDING override_kind VALUE_P SelectStmt
9731  {
9732  $$ = cat_str(4,mm_strdup("overriding"),$2,mm_strdup("value"),$4);
9733 }
9734 |  '(' insert_column_list ')' SelectStmt
9735  {
9736  $$ = cat_str(4,mm_strdup("("),$2,mm_strdup(")"),$4);
9737 }
9738 |  '(' insert_column_list ')' OVERRIDING override_kind VALUE_P SelectStmt
9739  {
9740  $$ = cat_str(6,mm_strdup("("),$2,mm_strdup(") overriding"),$5,mm_strdup("value"),$7);
9741 }
9742 |  DEFAULT VALUES
9743  {
9744  $$ = mm_strdup("default values");
9745 }
9746 ;
9747 
9748 
9749  override_kind:
9750  USER
9751  {
9752  $$ = mm_strdup("user");
9753 }
9754 |  SYSTEM_P
9755  {
9756  $$ = mm_strdup("system");
9757 }
9758 ;
9759 
9760 
9761  insert_column_list:
9762  insert_column_item
9763  {
9764  $$ = $1;
9765 }
9766 |  insert_column_list ',' insert_column_item
9767  {
9768  $$ = cat_str(3,$1,mm_strdup(","),$3);
9769 }
9770 ;
9771 
9772 
9773  insert_column_item:
9774  ColId opt_indirection
9775  {
9776  $$ = cat_str(2,$1,$2);
9777 }
9778 ;
9779 
9780 
9781  opt_on_conflict:
9782  ON CONFLICT opt_conf_expr DO UPDATE SET set_clause_list where_clause
9783  {
9784  $$ = cat_str(5,mm_strdup("on conflict"),$3,mm_strdup("do update set"),$7,$8);
9785 }
9786 |  ON CONFLICT opt_conf_expr DO NOTHING
9787  {
9788  $$ = cat_str(3,mm_strdup("on conflict"),$3,mm_strdup("do nothing"));
9789 }
9790 |
9791  {
9792  $$=EMPTY; }
9793 ;
9794 
9795 
9796  opt_conf_expr:
9797  '(' index_params ')' where_clause
9798  {
9799  $$ = cat_str(4,mm_strdup("("),$2,mm_strdup(")"),$4);
9800 }
9801 |  ON CONSTRAINT name
9802  {
9803  $$ = cat_str(2,mm_strdup("on constraint"),$3);
9804 }
9805 |
9806  {
9807  $$=EMPTY; }
9808 ;
9809 
9810 
9811  returning_clause:
9812 RETURNING target_list opt_ecpg_into
9813  {
9814  $$ = cat_str(2,mm_strdup("returning"),$2);
9815 }
9816 |
9817  {
9818  $$=EMPTY; }
9819 ;
9820 
9821 
9822  DeleteStmt:
9823  opt_with_clause DELETE_P FROM relation_expr_opt_alias using_clause where_or_current_clause returning_clause
9824  {
9825  $$ = cat_str(6,$1,mm_strdup("delete from"),$4,$5,$6,$7);
9826 }
9827 ;
9828 
9829 
9830  using_clause:
9831  USING from_list
9832  {
9833  $$ = cat_str(2,mm_strdup("using"),$2);
9834 }
9835 |
9836  {
9837  $$=EMPTY; }
9838 ;
9839 
9840 
9841  LockStmt:
9842  LOCK_P opt_table relation_expr_list opt_lock opt_nowait
9843  {
9844  $$ = cat_str(5,mm_strdup("lock"),$2,$3,$4,$5);
9845 }
9846 ;
9847 
9848 
9849  opt_lock:
9850  IN_P lock_type MODE
9851  {
9852  $$ = cat_str(3,mm_strdup("in"),$2,mm_strdup("mode"));
9853 }
9854 |
9855  {
9856  $$=EMPTY; }
9857 ;
9858 
9859 
9860  lock_type:
9861  ACCESS SHARE
9862  {
9863  $$ = mm_strdup("access share");
9864 }
9865 |  ROW SHARE
9866  {
9867  $$ = mm_strdup("row share");
9868 }
9869 |  ROW EXCLUSIVE
9870  {
9871  $$ = mm_strdup("row exclusive");
9872 }
9873 |  SHARE UPDATE EXCLUSIVE
9874  {
9875  $$ = mm_strdup("share update exclusive");
9876 }
9877 |  SHARE
9878  {
9879  $$ = mm_strdup("share");
9880 }
9881 |  SHARE ROW EXCLUSIVE
9882  {
9883  $$ = mm_strdup("share row exclusive");
9884 }
9885 |  EXCLUSIVE
9886  {
9887  $$ = mm_strdup("exclusive");
9888 }
9889 |  ACCESS EXCLUSIVE
9890  {
9891  $$ = mm_strdup("access exclusive");
9892 }
9893 ;
9894 
9895 
9896  opt_nowait:
9897  NOWAIT
9898  {
9899  $$ = mm_strdup("nowait");
9900 }
9901 |
9902  {
9903  $$=EMPTY; }
9904 ;
9905 
9906 
9907  opt_nowait_or_skip:
9908  NOWAIT
9909  {
9910  $$ = mm_strdup("nowait");
9911 }
9912 |  SKIP LOCKED
9913  {
9914  $$ = mm_strdup("skip locked");
9915 }
9916 |
9917  {
9918  $$=EMPTY; }
9919 ;
9920 
9921 
9922  UpdateStmt:
9923  opt_with_clause UPDATE relation_expr_opt_alias SET set_clause_list from_clause where_or_current_clause returning_clause
9924  {
9925  $$ = cat_str(8,$1,mm_strdup("update"),$3,mm_strdup("set"),$5,$6,$7,$8);
9926 }
9927 ;
9928 
9929 
9930  set_clause_list:
9931  set_clause
9932  {
9933  $$ = $1;
9934 }
9935 |  set_clause_list ',' set_clause
9936  {
9937  $$ = cat_str(3,$1,mm_strdup(","),$3);
9938 }
9939 ;
9940 
9941 
9942  set_clause:
9943  set_target '=' a_expr
9944  {
9945  $$ = cat_str(3,$1,mm_strdup("="),$3);
9946 }
9947 |  '(' set_target_list ')' '=' a_expr
9948  {
9949  $$ = cat_str(4,mm_strdup("("),$2,mm_strdup(") ="),$5);
9950 }
9951 ;
9952 
9953 
9954  set_target:
9955  ColId opt_indirection
9956  {
9957  $$ = cat_str(2,$1,$2);
9958 }
9959 ;
9960 
9961 
9962  set_target_list:
9963  set_target
9964  {
9965  $$ = $1;
9966 }
9967 |  set_target_list ',' set_target
9968  {
9969  $$ = cat_str(3,$1,mm_strdup(","),$3);
9970 }
9971 ;
9972 
9973 
9974  DeclareCursorStmt:
9975  DECLARE cursor_name cursor_options CURSOR opt_hold FOR SelectStmt
9976 	{
9977 		struct cursor *ptr, *this;
9978 		char *cursor_marker = $2[0] == ':' ? mm_strdup("$0") : mm_strdup($2);
9979 		char *comment, *c1, *c2;
9980 		int (* strcmp_fn)(const char *, const char *) = (($2[0] == ':' || $2[0] == '"') ? strcmp : pg_strcasecmp);
9981 
9982 		for (ptr = cur; ptr != NULL; ptr = ptr->next)
9983 		{
9984 			if (strcmp_fn($2, ptr->name) == 0)
9985 			{
9986 				if ($2[0] == ':')
9987 					mmerror(PARSE_ERROR, ET_ERROR, "using variable \"%s\" in different declare statements is not supported", $2+1);
9988 				else
9989 					mmerror(PARSE_ERROR, ET_ERROR, "cursor \"%s\" is already defined", $2);
9990 			}
9991 		}
9992 
9993 		this = (struct cursor *) mm_alloc(sizeof(struct cursor));
9994 
9995 		this->next = cur;
9996 		this->name = $2;
9997 		this->function = (current_function ? mm_strdup(current_function) : NULL);
9998 		this->connection = connection;
9999 		this->opened = false;
10000 		this->command =  cat_str(7, mm_strdup("declare"), cursor_marker, $3, mm_strdup("cursor"), $5, mm_strdup("for"), $7);
10001 		this->argsinsert = argsinsert;
10002 		this->argsinsert_oos = NULL;
10003 		this->argsresult = argsresult;
10004 		this->argsresult_oos = NULL;
10005 		argsinsert = argsresult = NULL;
10006 		cur = this;
10007 
10008 		c1 = mm_strdup(this->command);
10009 		if ((c2 = strstr(c1, "*/")) != NULL)
10010 		{
10011 			/* We put this text into a comment, so we better remove [*][/]. */
10012 			c2[0] = '.';
10013 			c2[1] = '.';
10014 		}
10015 		comment = cat_str(3, mm_strdup("/*"), c1, mm_strdup("*/"));
10016 
10017 		if ((braces_open > 0) && INFORMIX_MODE) /* we're in a function */
10018 			$$ = cat_str(3, adjust_outofscope_cursor_vars(this),
10019 				mm_strdup("ECPG_informix_reset_sqlca();"),
10020 				comment);
10021 		else
10022 			$$ = cat2_str(adjust_outofscope_cursor_vars(this), comment);
10023 	}
10024 ;
10025 
10026 
10027  cursor_name:
10028  name
10029  {
10030  $$ = $1;
10031 }
10032 	| char_civar
10033 		{
10034 			char *curname = mm_alloc(strlen($1) + 2);
10035 			sprintf(curname, ":%s", $1);
10036 			free($1);
10037 			$1 = curname;
10038 			$$ = $1;
10039 		}
10040 ;
10041 
10042 
10043  cursor_options:
10044 
10045  {
10046  $$=EMPTY; }
10047 |  cursor_options NO SCROLL
10048  {
10049  $$ = cat_str(2,$1,mm_strdup("no scroll"));
10050 }
10051 |  cursor_options SCROLL
10052  {
10053  $$ = cat_str(2,$1,mm_strdup("scroll"));
10054 }
10055 |  cursor_options BINARY
10056  {
10057  $$ = cat_str(2,$1,mm_strdup("binary"));
10058 }
10059 |  cursor_options INSENSITIVE
10060  {
10061  $$ = cat_str(2,$1,mm_strdup("insensitive"));
10062 }
10063 ;
10064 
10065 
10066  opt_hold:
10067 
10068 	{
10069 		if (compat == ECPG_COMPAT_INFORMIX_SE && autocommit)
10070 			$$ = mm_strdup("with hold");
10071 		else
10072 			$$ = EMPTY;
10073 	}
10074 |  WITH HOLD
10075  {
10076  $$ = mm_strdup("with hold");
10077 }
10078 |  WITHOUT HOLD
10079  {
10080  $$ = mm_strdup("without hold");
10081 }
10082 ;
10083 
10084 
10085  SelectStmt:
10086  select_no_parens %prec UMINUS
10087  {
10088  $$ = $1;
10089 }
10090 |  select_with_parens %prec UMINUS
10091  {
10092  $$ = $1;
10093 }
10094 ;
10095 
10096 
10097  select_with_parens:
10098  '(' select_no_parens ')'
10099  {
10100  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
10101 }
10102 |  '(' select_with_parens ')'
10103  {
10104  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
10105 }
10106 ;
10107 
10108 
10109  select_no_parens:
10110  simple_select
10111  {
10112  $$ = $1;
10113 }
10114 |  select_clause sort_clause
10115  {
10116  $$ = cat_str(2,$1,$2);
10117 }
10118 |  select_clause opt_sort_clause for_locking_clause opt_select_limit
10119  {
10120  $$ = cat_str(4,$1,$2,$3,$4);
10121 }
10122 |  select_clause opt_sort_clause select_limit opt_for_locking_clause
10123  {
10124  $$ = cat_str(4,$1,$2,$3,$4);
10125 }
10126 |  with_clause select_clause
10127  {
10128  $$ = cat_str(2,$1,$2);
10129 }
10130 |  with_clause select_clause sort_clause
10131  {
10132  $$ = cat_str(3,$1,$2,$3);
10133 }
10134 |  with_clause select_clause opt_sort_clause for_locking_clause opt_select_limit
10135  {
10136  $$ = cat_str(5,$1,$2,$3,$4,$5);
10137 }
10138 |  with_clause select_clause opt_sort_clause select_limit opt_for_locking_clause
10139  {
10140  $$ = cat_str(5,$1,$2,$3,$4,$5);
10141 }
10142 ;
10143 
10144 
10145  select_clause:
10146  simple_select
10147  {
10148  $$ = $1;
10149 }
10150 |  select_with_parens
10151  {
10152  $$ = $1;
10153 }
10154 ;
10155 
10156 
10157  simple_select:
10158  SELECT opt_all_clause opt_target_list into_clause from_clause where_clause group_clause having_clause window_clause
10159  {
10160  $$ = cat_str(9,mm_strdup("select"),$2,$3,$4,$5,$6,$7,$8,$9);
10161 }
10162 |  SELECT distinct_clause target_list into_clause from_clause where_clause group_clause having_clause window_clause
10163  {
10164  $$ = cat_str(9,mm_strdup("select"),$2,$3,$4,$5,$6,$7,$8,$9);
10165 }
10166 |  values_clause
10167  {
10168  $$ = $1;
10169 }
10170 |  TABLE relation_expr
10171  {
10172  $$ = cat_str(2,mm_strdup("table"),$2);
10173 }
10174 |  select_clause UNION all_or_distinct select_clause
10175  {
10176  $$ = cat_str(4,$1,mm_strdup("union"),$3,$4);
10177 }
10178 |  select_clause INTERSECT all_or_distinct select_clause
10179  {
10180  $$ = cat_str(4,$1,mm_strdup("intersect"),$3,$4);
10181 }
10182 |  select_clause EXCEPT all_or_distinct select_clause
10183  {
10184  $$ = cat_str(4,$1,mm_strdup("except"),$3,$4);
10185 }
10186 ;
10187 
10188 
10189  with_clause:
10190  WITH cte_list
10191  {
10192  $$ = cat_str(2,mm_strdup("with"),$2);
10193 }
10194 |  WITH_LA cte_list
10195  {
10196  $$ = cat_str(2,mm_strdup("with"),$2);
10197 }
10198 |  WITH RECURSIVE cte_list
10199  {
10200  $$ = cat_str(2,mm_strdup("with recursive"),$3);
10201 }
10202 ;
10203 
10204 
10205  cte_list:
10206  common_table_expr
10207  {
10208  $$ = $1;
10209 }
10210 |  cte_list ',' common_table_expr
10211  {
10212  $$ = cat_str(3,$1,mm_strdup(","),$3);
10213 }
10214 ;
10215 
10216 
10217  common_table_expr:
10218  name opt_name_list AS '(' PreparableStmt ')'
10219  {
10220  $$ = cat_str(5,$1,$2,mm_strdup("as ("),$5,mm_strdup(")"));
10221 }
10222 ;
10223 
10224 
10225  opt_with_clause:
10226  with_clause
10227  {
10228  $$ = $1;
10229 }
10230 |
10231  {
10232  $$=EMPTY; }
10233 ;
10234 
10235 
10236  into_clause:
10237  INTO OptTempTableName
10238 					{
10239 						FoundInto = 1;
10240 						$$= cat2_str(mm_strdup("into"), $2);
10241 					}
10242 	| ecpg_into { $$ = EMPTY; }
10243 |
10244  {
10245  $$=EMPTY; }
10246 ;
10247 
10248 
10249  OptTempTableName:
10250  TEMPORARY opt_table qualified_name
10251  {
10252  $$ = cat_str(3,mm_strdup("temporary"),$2,$3);
10253 }
10254 |  TEMP opt_table qualified_name
10255  {
10256  $$ = cat_str(3,mm_strdup("temp"),$2,$3);
10257 }
10258 |  LOCAL TEMPORARY opt_table qualified_name
10259  {
10260  $$ = cat_str(3,mm_strdup("local temporary"),$3,$4);
10261 }
10262 |  LOCAL TEMP opt_table qualified_name
10263  {
10264  $$ = cat_str(3,mm_strdup("local temp"),$3,$4);
10265 }
10266 |  GLOBAL TEMPORARY opt_table qualified_name
10267  {
10268  $$ = cat_str(3,mm_strdup("global temporary"),$3,$4);
10269 }
10270 |  GLOBAL TEMP opt_table qualified_name
10271  {
10272  $$ = cat_str(3,mm_strdup("global temp"),$3,$4);
10273 }
10274 |  UNLOGGED opt_table qualified_name
10275  {
10276  $$ = cat_str(3,mm_strdup("unlogged"),$2,$3);
10277 }
10278 |  TABLE qualified_name
10279  {
10280  $$ = cat_str(2,mm_strdup("table"),$2);
10281 }
10282 |  qualified_name
10283  {
10284  $$ = $1;
10285 }
10286 ;
10287 
10288 
10289  opt_table:
10290  TABLE
10291  {
10292  $$ = mm_strdup("table");
10293 }
10294 |
10295  {
10296  $$=EMPTY; }
10297 ;
10298 
10299 
10300  all_or_distinct:
10301  ALL
10302  {
10303  $$ = mm_strdup("all");
10304 }
10305 |  DISTINCT
10306  {
10307  $$ = mm_strdup("distinct");
10308 }
10309 |
10310  {
10311  $$=EMPTY; }
10312 ;
10313 
10314 
10315  distinct_clause:
10316  DISTINCT
10317  {
10318  $$ = mm_strdup("distinct");
10319 }
10320 |  DISTINCT ON '(' expr_list ')'
10321  {
10322  $$ = cat_str(3,mm_strdup("distinct on ("),$4,mm_strdup(")"));
10323 }
10324 ;
10325 
10326 
10327  opt_all_clause:
10328  ALL
10329  {
10330  $$ = mm_strdup("all");
10331 }
10332 |
10333  {
10334  $$=EMPTY; }
10335 ;
10336 
10337 
10338  opt_sort_clause:
10339  sort_clause
10340  {
10341  $$ = $1;
10342 }
10343 |
10344  {
10345  $$=EMPTY; }
10346 ;
10347 
10348 
10349  sort_clause:
10350  ORDER BY sortby_list
10351  {
10352  $$ = cat_str(2,mm_strdup("order by"),$3);
10353 }
10354 ;
10355 
10356 
10357  sortby_list:
10358  sortby
10359  {
10360  $$ = $1;
10361 }
10362 |  sortby_list ',' sortby
10363  {
10364  $$ = cat_str(3,$1,mm_strdup(","),$3);
10365 }
10366 ;
10367 
10368 
10369  sortby:
10370  a_expr USING qual_all_Op opt_nulls_order
10371  {
10372  $$ = cat_str(4,$1,mm_strdup("using"),$3,$4);
10373 }
10374 |  a_expr opt_asc_desc opt_nulls_order
10375  {
10376  $$ = cat_str(3,$1,$2,$3);
10377 }
10378 ;
10379 
10380 
10381  select_limit:
10382  limit_clause offset_clause
10383  {
10384  $$ = cat_str(2,$1,$2);
10385 }
10386 |  offset_clause limit_clause
10387  {
10388  $$ = cat_str(2,$1,$2);
10389 }
10390 |  limit_clause
10391  {
10392  $$ = $1;
10393 }
10394 |  offset_clause
10395  {
10396  $$ = $1;
10397 }
10398 ;
10399 
10400 
10401  opt_select_limit:
10402  select_limit
10403  {
10404  $$ = $1;
10405 }
10406 |
10407  {
10408  $$=EMPTY; }
10409 ;
10410 
10411 
10412  limit_clause:
10413  LIMIT select_limit_value
10414  {
10415  $$ = cat_str(2,mm_strdup("limit"),$2);
10416 }
10417 |  LIMIT select_limit_value ',' select_offset_value
10418 	{
10419 		mmerror(PARSE_ERROR, ET_WARNING, "no longer supported LIMIT #,# syntax passed to server");
10420 		$$ = cat_str(4, mm_strdup("limit"), $2, mm_strdup(","), $4);
10421 	}
10422 |  FETCH first_or_next select_fetch_first_value row_or_rows ONLY
10423  {
10424  $$ = cat_str(5,mm_strdup("fetch"),$2,$3,$4,mm_strdup("only"));
10425 }
10426 |  FETCH first_or_next row_or_rows ONLY
10427  {
10428  $$ = cat_str(4,mm_strdup("fetch"),$2,$3,mm_strdup("only"));
10429 }
10430 ;
10431 
10432 
10433  offset_clause:
10434  OFFSET select_offset_value
10435  {
10436  $$ = cat_str(2,mm_strdup("offset"),$2);
10437 }
10438 |  OFFSET select_fetch_first_value row_or_rows
10439  {
10440  $$ = cat_str(3,mm_strdup("offset"),$2,$3);
10441 }
10442 ;
10443 
10444 
10445  select_limit_value:
10446  a_expr
10447  {
10448  $$ = $1;
10449 }
10450 |  ALL
10451  {
10452  $$ = mm_strdup("all");
10453 }
10454 ;
10455 
10456 
10457  select_offset_value:
10458  a_expr
10459  {
10460  $$ = $1;
10461 }
10462 ;
10463 
10464 
10465  select_fetch_first_value:
10466  c_expr
10467  {
10468  $$ = $1;
10469 }
10470 |  '+' I_or_F_const
10471  {
10472  $$ = cat_str(2,mm_strdup("+"),$2);
10473 }
10474 |  '-' I_or_F_const
10475  {
10476  $$ = cat_str(2,mm_strdup("-"),$2);
10477 }
10478 ;
10479 
10480 
10481  I_or_F_const:
10482  Iconst
10483  {
10484  $$ = $1;
10485 }
10486 |  ecpg_fconst
10487  {
10488  $$ = $1;
10489 }
10490 ;
10491 
10492 
10493  row_or_rows:
10494  ROW
10495  {
10496  $$ = mm_strdup("row");
10497 }
10498 |  ROWS
10499  {
10500  $$ = mm_strdup("rows");
10501 }
10502 ;
10503 
10504 
10505  first_or_next:
10506  FIRST_P
10507  {
10508  $$ = mm_strdup("first");
10509 }
10510 |  NEXT
10511  {
10512  $$ = mm_strdup("next");
10513 }
10514 ;
10515 
10516 
10517  group_clause:
10518  GROUP_P BY group_by_list
10519  {
10520  $$ = cat_str(2,mm_strdup("group by"),$3);
10521 }
10522 |
10523  {
10524  $$=EMPTY; }
10525 ;
10526 
10527 
10528  group_by_list:
10529  group_by_item
10530  {
10531  $$ = $1;
10532 }
10533 |  group_by_list ',' group_by_item
10534  {
10535  $$ = cat_str(3,$1,mm_strdup(","),$3);
10536 }
10537 ;
10538 
10539 
10540  group_by_item:
10541  a_expr
10542  {
10543  $$ = $1;
10544 }
10545 |  empty_grouping_set
10546  {
10547  $$ = $1;
10548 }
10549 |  cube_clause
10550  {
10551  $$ = $1;
10552 }
10553 |  rollup_clause
10554  {
10555  $$ = $1;
10556 }
10557 |  grouping_sets_clause
10558  {
10559  $$ = $1;
10560 }
10561 ;
10562 
10563 
10564  empty_grouping_set:
10565  '(' ')'
10566  {
10567  $$ = mm_strdup("( )");
10568 }
10569 ;
10570 
10571 
10572  rollup_clause:
10573  ROLLUP '(' expr_list ')'
10574  {
10575  $$ = cat_str(3,mm_strdup("rollup ("),$3,mm_strdup(")"));
10576 }
10577 ;
10578 
10579 
10580  cube_clause:
10581  CUBE '(' expr_list ')'
10582  {
10583  $$ = cat_str(3,mm_strdup("cube ("),$3,mm_strdup(")"));
10584 }
10585 ;
10586 
10587 
10588  grouping_sets_clause:
10589  GROUPING SETS '(' group_by_list ')'
10590  {
10591  $$ = cat_str(3,mm_strdup("grouping sets ("),$4,mm_strdup(")"));
10592 }
10593 ;
10594 
10595 
10596  having_clause:
10597  HAVING a_expr
10598  {
10599  $$ = cat_str(2,mm_strdup("having"),$2);
10600 }
10601 |
10602  {
10603  $$=EMPTY; }
10604 ;
10605 
10606 
10607  for_locking_clause:
10608  for_locking_items
10609  {
10610  $$ = $1;
10611 }
10612 |  FOR READ ONLY
10613  {
10614  $$ = mm_strdup("for read only");
10615 }
10616 ;
10617 
10618 
10619  opt_for_locking_clause:
10620  for_locking_clause
10621  {
10622  $$ = $1;
10623 }
10624 |
10625  {
10626  $$=EMPTY; }
10627 ;
10628 
10629 
10630  for_locking_items:
10631  for_locking_item
10632  {
10633  $$ = $1;
10634 }
10635 |  for_locking_items for_locking_item
10636  {
10637  $$ = cat_str(2,$1,$2);
10638 }
10639 ;
10640 
10641 
10642  for_locking_item:
10643  for_locking_strength locked_rels_list opt_nowait_or_skip
10644  {
10645  $$ = cat_str(3,$1,$2,$3);
10646 }
10647 ;
10648 
10649 
10650  for_locking_strength:
10651  FOR UPDATE
10652  {
10653  $$ = mm_strdup("for update");
10654 }
10655 |  FOR NO KEY UPDATE
10656  {
10657  $$ = mm_strdup("for no key update");
10658 }
10659 |  FOR SHARE
10660  {
10661  $$ = mm_strdup("for share");
10662 }
10663 |  FOR KEY SHARE
10664  {
10665  $$ = mm_strdup("for key share");
10666 }
10667 ;
10668 
10669 
10670  locked_rels_list:
10671  OF qualified_name_list
10672  {
10673  $$ = cat_str(2,mm_strdup("of"),$2);
10674 }
10675 |
10676  {
10677  $$=EMPTY; }
10678 ;
10679 
10680 
10681  values_clause:
10682  VALUES '(' expr_list ')'
10683  {
10684  $$ = cat_str(3,mm_strdup("values ("),$3,mm_strdup(")"));
10685 }
10686 |  values_clause ',' '(' expr_list ')'
10687  {
10688  $$ = cat_str(4,$1,mm_strdup(", ("),$4,mm_strdup(")"));
10689 }
10690 ;
10691 
10692 
10693  from_clause:
10694  FROM from_list
10695  {
10696  $$ = cat_str(2,mm_strdup("from"),$2);
10697 }
10698 |
10699  {
10700  $$=EMPTY; }
10701 ;
10702 
10703 
10704  from_list:
10705  table_ref
10706  {
10707  $$ = $1;
10708 }
10709 |  from_list ',' table_ref
10710  {
10711  $$ = cat_str(3,$1,mm_strdup(","),$3);
10712 }
10713 ;
10714 
10715 
10716  table_ref:
10717  relation_expr opt_alias_clause
10718  {
10719  $$ = cat_str(2,$1,$2);
10720 }
10721 |  relation_expr opt_alias_clause tablesample_clause
10722  {
10723  $$ = cat_str(3,$1,$2,$3);
10724 }
10725 |  func_table func_alias_clause
10726  {
10727  $$ = cat_str(2,$1,$2);
10728 }
10729 |  LATERAL_P func_table func_alias_clause
10730  {
10731  $$ = cat_str(3,mm_strdup("lateral"),$2,$3);
10732 }
10733 |  xmltable opt_alias_clause
10734  {
10735  $$ = cat_str(2,$1,$2);
10736 }
10737 |  LATERAL_P xmltable opt_alias_clause
10738  {
10739  $$ = cat_str(3,mm_strdup("lateral"),$2,$3);
10740 }
10741 |  select_with_parens opt_alias_clause
10742  {
10743 	if ($2 == NULL)
10744 		mmerror(PARSE_ERROR, ET_ERROR, "subquery in FROM must have an alias");
10745 
10746  $$ = cat_str(2,$1,$2);
10747 }
10748 |  LATERAL_P select_with_parens opt_alias_clause
10749  {
10750 	if ($3 == NULL)
10751 		mmerror(PARSE_ERROR, ET_ERROR, "subquery in FROM must have an alias");
10752 
10753  $$ = cat_str(3,mm_strdup("lateral"),$2,$3);
10754 }
10755 |  joined_table
10756  {
10757  $$ = $1;
10758 }
10759 |  '(' joined_table ')' alias_clause
10760  {
10761  $$ = cat_str(4,mm_strdup("("),$2,mm_strdup(")"),$4);
10762 }
10763 ;
10764 
10765 
10766  joined_table:
10767  '(' joined_table ')'
10768  {
10769  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
10770 }
10771 |  table_ref CROSS JOIN table_ref
10772  {
10773  $$ = cat_str(3,$1,mm_strdup("cross join"),$4);
10774 }
10775 |  table_ref join_type JOIN table_ref join_qual
10776  {
10777  $$ = cat_str(5,$1,$2,mm_strdup("join"),$4,$5);
10778 }
10779 |  table_ref JOIN table_ref join_qual
10780  {
10781  $$ = cat_str(4,$1,mm_strdup("join"),$3,$4);
10782 }
10783 |  table_ref NATURAL join_type JOIN table_ref
10784  {
10785  $$ = cat_str(5,$1,mm_strdup("natural"),$3,mm_strdup("join"),$5);
10786 }
10787 |  table_ref NATURAL JOIN table_ref
10788  {
10789  $$ = cat_str(3,$1,mm_strdup("natural join"),$4);
10790 }
10791 ;
10792 
10793 
10794  alias_clause:
10795  AS ColId '(' name_list ')'
10796  {
10797  $$ = cat_str(5,mm_strdup("as"),$2,mm_strdup("("),$4,mm_strdup(")"));
10798 }
10799 |  AS ColId
10800  {
10801  $$ = cat_str(2,mm_strdup("as"),$2);
10802 }
10803 |  ColId '(' name_list ')'
10804  {
10805  $$ = cat_str(4,$1,mm_strdup("("),$3,mm_strdup(")"));
10806 }
10807 |  ColId
10808  {
10809  $$ = $1;
10810 }
10811 ;
10812 
10813 
10814  opt_alias_clause:
10815  alias_clause
10816  {
10817  $$ = $1;
10818 }
10819 |
10820  {
10821  $$=EMPTY; }
10822 ;
10823 
10824 
10825  func_alias_clause:
10826  alias_clause
10827  {
10828  $$ = $1;
10829 }
10830 |  AS '(' TableFuncElementList ')'
10831  {
10832  $$ = cat_str(3,mm_strdup("as ("),$3,mm_strdup(")"));
10833 }
10834 |  AS ColId '(' TableFuncElementList ')'
10835  {
10836  $$ = cat_str(5,mm_strdup("as"),$2,mm_strdup("("),$4,mm_strdup(")"));
10837 }
10838 |  ColId '(' TableFuncElementList ')'
10839  {
10840  $$ = cat_str(4,$1,mm_strdup("("),$3,mm_strdup(")"));
10841 }
10842 |
10843  {
10844  $$=EMPTY; }
10845 ;
10846 
10847 
10848  join_type:
10849  FULL join_outer
10850  {
10851  $$ = cat_str(2,mm_strdup("full"),$2);
10852 }
10853 |  LEFT join_outer
10854  {
10855  $$ = cat_str(2,mm_strdup("left"),$2);
10856 }
10857 |  RIGHT join_outer
10858  {
10859  $$ = cat_str(2,mm_strdup("right"),$2);
10860 }
10861 |  INNER_P
10862  {
10863  $$ = mm_strdup("inner");
10864 }
10865 ;
10866 
10867 
10868  join_outer:
10869  OUTER_P
10870  {
10871  $$ = mm_strdup("outer");
10872 }
10873 |
10874  {
10875  $$=EMPTY; }
10876 ;
10877 
10878 
10879  join_qual:
10880  USING '(' name_list ')'
10881  {
10882  $$ = cat_str(3,mm_strdup("using ("),$3,mm_strdup(")"));
10883 }
10884 |  ON a_expr
10885  {
10886  $$ = cat_str(2,mm_strdup("on"),$2);
10887 }
10888 ;
10889 
10890 
10891  relation_expr:
10892  qualified_name
10893  {
10894  $$ = $1;
10895 }
10896 |  qualified_name '*'
10897  {
10898  $$ = cat_str(2,$1,mm_strdup("*"));
10899 }
10900 |  ONLY qualified_name
10901  {
10902  $$ = cat_str(2,mm_strdup("only"),$2);
10903 }
10904 |  ONLY '(' qualified_name ')'
10905  {
10906  $$ = cat_str(3,mm_strdup("only ("),$3,mm_strdup(")"));
10907 }
10908 ;
10909 
10910 
10911  relation_expr_list:
10912  relation_expr
10913  {
10914  $$ = $1;
10915 }
10916 |  relation_expr_list ',' relation_expr
10917  {
10918  $$ = cat_str(3,$1,mm_strdup(","),$3);
10919 }
10920 ;
10921 
10922 
10923  relation_expr_opt_alias:
10924  relation_expr %prec UMINUS
10925  {
10926  $$ = $1;
10927 }
10928 |  relation_expr ColId
10929  {
10930  $$ = cat_str(2,$1,$2);
10931 }
10932 |  relation_expr AS ColId
10933  {
10934  $$ = cat_str(3,$1,mm_strdup("as"),$3);
10935 }
10936 ;
10937 
10938 
10939  tablesample_clause:
10940  TABLESAMPLE func_name '(' expr_list ')' opt_repeatable_clause
10941  {
10942  $$ = cat_str(6,mm_strdup("tablesample"),$2,mm_strdup("("),$4,mm_strdup(")"),$6);
10943 }
10944 ;
10945 
10946 
10947  opt_repeatable_clause:
10948  REPEATABLE '(' a_expr ')'
10949  {
10950  $$ = cat_str(3,mm_strdup("repeatable ("),$3,mm_strdup(")"));
10951 }
10952 |
10953  {
10954  $$=EMPTY; }
10955 ;
10956 
10957 
10958  func_table:
10959  func_expr_windowless opt_ordinality
10960  {
10961  $$ = cat_str(2,$1,$2);
10962 }
10963 |  ROWS FROM '(' rowsfrom_list ')' opt_ordinality
10964  {
10965  $$ = cat_str(4,mm_strdup("rows from ("),$4,mm_strdup(")"),$6);
10966 }
10967 ;
10968 
10969 
10970  rowsfrom_item:
10971  func_expr_windowless opt_col_def_list
10972  {
10973  $$ = cat_str(2,$1,$2);
10974 }
10975 ;
10976 
10977 
10978  rowsfrom_list:
10979  rowsfrom_item
10980  {
10981  $$ = $1;
10982 }
10983 |  rowsfrom_list ',' rowsfrom_item
10984  {
10985  $$ = cat_str(3,$1,mm_strdup(","),$3);
10986 }
10987 ;
10988 
10989 
10990  opt_col_def_list:
10991  AS '(' TableFuncElementList ')'
10992  {
10993  $$ = cat_str(3,mm_strdup("as ("),$3,mm_strdup(")"));
10994 }
10995 |
10996  {
10997  $$=EMPTY; }
10998 ;
10999 
11000 
11001  opt_ordinality:
11002  WITH_LA ORDINALITY
11003  {
11004  $$ = mm_strdup("with ordinality");
11005 }
11006 |
11007  {
11008  $$=EMPTY; }
11009 ;
11010 
11011 
11012  where_clause:
11013  WHERE a_expr
11014  {
11015  $$ = cat_str(2,mm_strdup("where"),$2);
11016 }
11017 |
11018  {
11019  $$=EMPTY; }
11020 ;
11021 
11022 
11023  where_or_current_clause:
11024  WHERE a_expr
11025  {
11026  $$ = cat_str(2,mm_strdup("where"),$2);
11027 }
11028 |  WHERE CURRENT_P OF cursor_name
11029 	{
11030 		char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
11031 		$$ = cat_str(2,mm_strdup("where current of"), cursor_marker);
11032 	}
11033 |
11034  {
11035  $$=EMPTY; }
11036 ;
11037 
11038 
11039  OptTableFuncElementList:
11040  TableFuncElementList
11041  {
11042  $$ = $1;
11043 }
11044 |
11045  {
11046  $$=EMPTY; }
11047 ;
11048 
11049 
11050  TableFuncElementList:
11051  TableFuncElement
11052  {
11053  $$ = $1;
11054 }
11055 |  TableFuncElementList ',' TableFuncElement
11056  {
11057  $$ = cat_str(3,$1,mm_strdup(","),$3);
11058 }
11059 ;
11060 
11061 
11062  TableFuncElement:
11063  ColId Typename opt_collate_clause
11064  {
11065  $$ = cat_str(3,$1,$2,$3);
11066 }
11067 ;
11068 
11069 
11070  xmltable:
11071  XMLTABLE '(' c_expr xmlexists_argument COLUMNS xmltable_column_list ')'
11072  {
11073  $$ = cat_str(6,mm_strdup("xmltable ("),$3,$4,mm_strdup("columns"),$6,mm_strdup(")"));
11074 }
11075 |  XMLTABLE '(' XMLNAMESPACES '(' xml_namespace_list ')' ',' c_expr xmlexists_argument COLUMNS xmltable_column_list ')'
11076  {
11077  $$ = cat_str(8,mm_strdup("xmltable ( xmlnamespaces ("),$5,mm_strdup(") ,"),$8,$9,mm_strdup("columns"),$11,mm_strdup(")"));
11078 }
11079 ;
11080 
11081 
11082  xmltable_column_list:
11083  xmltable_column_el
11084  {
11085  $$ = $1;
11086 }
11087 |  xmltable_column_list ',' xmltable_column_el
11088  {
11089  $$ = cat_str(3,$1,mm_strdup(","),$3);
11090 }
11091 ;
11092 
11093 
11094  xmltable_column_el:
11095  ColId Typename
11096  {
11097  $$ = cat_str(2,$1,$2);
11098 }
11099 |  ColId Typename xmltable_column_option_list
11100  {
11101  $$ = cat_str(3,$1,$2,$3);
11102 }
11103 |  ColId FOR ORDINALITY
11104  {
11105  $$ = cat_str(2,$1,mm_strdup("for ordinality"));
11106 }
11107 ;
11108 
11109 
11110  xmltable_column_option_list:
11111  xmltable_column_option_el
11112  {
11113  $$ = $1;
11114 }
11115 |  xmltable_column_option_list xmltable_column_option_el
11116  {
11117  $$ = cat_str(2,$1,$2);
11118 }
11119 ;
11120 
11121 
11122  xmltable_column_option_el:
11123  ecpg_ident b_expr
11124  {
11125  $$ = cat_str(2,$1,$2);
11126 }
11127 |  DEFAULT b_expr
11128  {
11129  $$ = cat_str(2,mm_strdup("default"),$2);
11130 }
11131 |  NOT NULL_P
11132  {
11133  $$ = mm_strdup("not null");
11134 }
11135 |  NULL_P
11136  {
11137  $$ = mm_strdup("null");
11138 }
11139 ;
11140 
11141 
11142  xml_namespace_list:
11143  xml_namespace_el
11144  {
11145  $$ = $1;
11146 }
11147 |  xml_namespace_list ',' xml_namespace_el
11148  {
11149  $$ = cat_str(3,$1,mm_strdup(","),$3);
11150 }
11151 ;
11152 
11153 
11154  xml_namespace_el:
11155  b_expr AS ColLabel
11156  {
11157  $$ = cat_str(3,$1,mm_strdup("as"),$3);
11158 }
11159 |  DEFAULT b_expr
11160  {
11161  $$ = cat_str(2,mm_strdup("default"),$2);
11162 }
11163 ;
11164 
11165 
11166  Typename:
11167  SimpleTypename opt_array_bounds
11168 	{	$$ = cat2_str($1, $2.str); }
11169 |  SETOF SimpleTypename opt_array_bounds
11170 	{	$$ = cat_str(3, mm_strdup("setof"), $2, $3.str); }
11171 |  SimpleTypename ARRAY '[' Iconst ']'
11172  {
11173  $$ = cat_str(4,$1,mm_strdup("array ["),$4,mm_strdup("]"));
11174 }
11175 |  SETOF SimpleTypename ARRAY '[' Iconst ']'
11176  {
11177  $$ = cat_str(5,mm_strdup("setof"),$2,mm_strdup("array ["),$5,mm_strdup("]"));
11178 }
11179 |  SimpleTypename ARRAY
11180  {
11181  $$ = cat_str(2,$1,mm_strdup("array"));
11182 }
11183 |  SETOF SimpleTypename ARRAY
11184  {
11185  $$ = cat_str(3,mm_strdup("setof"),$2,mm_strdup("array"));
11186 }
11187 ;
11188 
11189 
11190  opt_array_bounds:
11191  opt_array_bounds '[' ']'
11192 	{
11193 		$$.index1 = $1.index1;
11194 		$$.index2 = $1.index2;
11195 		if (strcmp($$.index1, "-1") == 0)
11196 			$$.index1 = mm_strdup("0");
11197 		else if (strcmp($1.index2, "-1") == 0)
11198 			$$.index2 = mm_strdup("0");
11199 		$$.str = cat_str(2, $1.str, mm_strdup("[]"));
11200 	}
11201 	| opt_array_bounds '[' Iresult ']'
11202 	{
11203 		$$.index1 = $1.index1;
11204 		$$.index2 = $1.index2;
11205 		if (strcmp($1.index1, "-1") == 0)
11206 			$$.index1 = mm_strdup($3);
11207 		else if (strcmp($1.index2, "-1") == 0)
11208 			$$.index2 = mm_strdup($3);
11209 		$$.str = cat_str(4, $1.str, mm_strdup("["), $3, mm_strdup("]"));
11210 	}
11211 |
11212 	{
11213 		$$.index1 = mm_strdup("-1");
11214 		$$.index2 = mm_strdup("-1");
11215 		$$.str= EMPTY;
11216 	}
11217 ;
11218 
11219 
11220  SimpleTypename:
11221  GenericType
11222  {
11223  $$ = $1;
11224 }
11225 |  Numeric
11226  {
11227  $$ = $1;
11228 }
11229 |  Bit
11230  {
11231  $$ = $1;
11232 }
11233 |  Character
11234  {
11235  $$ = $1;
11236 }
11237 |  ConstDatetime
11238  {
11239  $$ = $1;
11240 }
11241 |  ConstInterval opt_interval
11242  {
11243  $$ = cat_str(2,$1,$2);
11244 }
11245 |  ConstInterval '(' Iconst ')'
11246  {
11247  $$ = cat_str(4,$1,mm_strdup("("),$3,mm_strdup(")"));
11248 }
11249 ;
11250 
11251 
11252  ConstTypename:
11253  Numeric
11254  {
11255  $$ = $1;
11256 }
11257 |  ConstBit
11258  {
11259  $$ = $1;
11260 }
11261 |  ConstCharacter
11262  {
11263  $$ = $1;
11264 }
11265 |  ConstDatetime
11266  {
11267  $$ = $1;
11268 }
11269 ;
11270 
11271 
11272  GenericType:
11273  type_function_name opt_type_modifiers
11274  {
11275  $$ = cat_str(2,$1,$2);
11276 }
11277 |  type_function_name attrs opt_type_modifiers
11278  {
11279  $$ = cat_str(3,$1,$2,$3);
11280 }
11281 ;
11282 
11283 
11284  opt_type_modifiers:
11285  '(' expr_list ')'
11286  {
11287  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
11288 }
11289 |
11290  {
11291  $$=EMPTY; }
11292 ;
11293 
11294 
11295  Numeric:
11296  INT_P
11297  {
11298  $$ = mm_strdup("int");
11299 }
11300 |  INTEGER
11301  {
11302  $$ = mm_strdup("integer");
11303 }
11304 |  SMALLINT
11305  {
11306  $$ = mm_strdup("smallint");
11307 }
11308 |  BIGINT
11309  {
11310  $$ = mm_strdup("bigint");
11311 }
11312 |  REAL
11313  {
11314  $$ = mm_strdup("real");
11315 }
11316 |  FLOAT_P opt_float
11317  {
11318  $$ = cat_str(2,mm_strdup("float"),$2);
11319 }
11320 |  DOUBLE_P PRECISION
11321  {
11322  $$ = mm_strdup("double precision");
11323 }
11324 |  DECIMAL_P opt_type_modifiers
11325  {
11326  $$ = cat_str(2,mm_strdup("decimal"),$2);
11327 }
11328 |  DEC opt_type_modifiers
11329  {
11330  $$ = cat_str(2,mm_strdup("dec"),$2);
11331 }
11332 |  NUMERIC opt_type_modifiers
11333  {
11334  $$ = cat_str(2,mm_strdup("numeric"),$2);
11335 }
11336 |  BOOLEAN_P
11337  {
11338  $$ = mm_strdup("boolean");
11339 }
11340 ;
11341 
11342 
11343  opt_float:
11344  '(' Iconst ')'
11345  {
11346  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
11347 }
11348 |
11349  {
11350  $$=EMPTY; }
11351 ;
11352 
11353 
11354  Bit:
11355  BitWithLength
11356  {
11357  $$ = $1;
11358 }
11359 |  BitWithoutLength
11360  {
11361  $$ = $1;
11362 }
11363 ;
11364 
11365 
11366  ConstBit:
11367  BitWithLength
11368  {
11369  $$ = $1;
11370 }
11371 |  BitWithoutLength
11372  {
11373  $$ = $1;
11374 }
11375 ;
11376 
11377 
11378  BitWithLength:
11379  BIT opt_varying '(' expr_list ')'
11380  {
11381  $$ = cat_str(5,mm_strdup("bit"),$2,mm_strdup("("),$4,mm_strdup(")"));
11382 }
11383 ;
11384 
11385 
11386  BitWithoutLength:
11387  BIT opt_varying
11388  {
11389  $$ = cat_str(2,mm_strdup("bit"),$2);
11390 }
11391 ;
11392 
11393 
11394  Character:
11395  CharacterWithLength
11396  {
11397  $$ = $1;
11398 }
11399 |  CharacterWithoutLength
11400  {
11401  $$ = $1;
11402 }
11403 ;
11404 
11405 
11406  ConstCharacter:
11407  CharacterWithLength
11408  {
11409  $$ = $1;
11410 }
11411 |  CharacterWithoutLength
11412  {
11413  $$ = $1;
11414 }
11415 ;
11416 
11417 
11418  CharacterWithLength:
11419  character '(' Iconst ')'
11420  {
11421  $$ = cat_str(4,$1,mm_strdup("("),$3,mm_strdup(")"));
11422 }
11423 ;
11424 
11425 
11426  CharacterWithoutLength:
11427  character
11428  {
11429  $$ = $1;
11430 }
11431 ;
11432 
11433 
11434  character:
11435  CHARACTER opt_varying
11436  {
11437  $$ = cat_str(2,mm_strdup("character"),$2);
11438 }
11439 |  CHAR_P opt_varying
11440  {
11441  $$ = cat_str(2,mm_strdup("char"),$2);
11442 }
11443 |  VARCHAR
11444  {
11445  $$ = mm_strdup("varchar");
11446 }
11447 |  NATIONAL CHARACTER opt_varying
11448  {
11449  $$ = cat_str(2,mm_strdup("national character"),$3);
11450 }
11451 |  NATIONAL CHAR_P opt_varying
11452  {
11453  $$ = cat_str(2,mm_strdup("national char"),$3);
11454 }
11455 |  NCHAR opt_varying
11456  {
11457  $$ = cat_str(2,mm_strdup("nchar"),$2);
11458 }
11459 ;
11460 
11461 
11462  opt_varying:
11463  VARYING
11464  {
11465  $$ = mm_strdup("varying");
11466 }
11467 |
11468  {
11469  $$=EMPTY; }
11470 ;
11471 
11472 
11473  ConstDatetime:
11474  TIMESTAMP '(' Iconst ')' opt_timezone
11475  {
11476  $$ = cat_str(4,mm_strdup("timestamp ("),$3,mm_strdup(")"),$5);
11477 }
11478 |  TIMESTAMP opt_timezone
11479  {
11480  $$ = cat_str(2,mm_strdup("timestamp"),$2);
11481 }
11482 |  TIME '(' Iconst ')' opt_timezone
11483  {
11484  $$ = cat_str(4,mm_strdup("time ("),$3,mm_strdup(")"),$5);
11485 }
11486 |  TIME opt_timezone
11487  {
11488  $$ = cat_str(2,mm_strdup("time"),$2);
11489 }
11490 ;
11491 
11492 
11493  ConstInterval:
11494  INTERVAL
11495  {
11496  $$ = mm_strdup("interval");
11497 }
11498 ;
11499 
11500 
11501  opt_timezone:
11502  WITH_LA TIME ZONE
11503  {
11504  $$ = mm_strdup("with time zone");
11505 }
11506 |  WITHOUT TIME ZONE
11507  {
11508  $$ = mm_strdup("without time zone");
11509 }
11510 |
11511  {
11512  $$=EMPTY; }
11513 ;
11514 
11515 
11516  opt_interval:
11517  YEAR_P
11518  {
11519  $$ = mm_strdup("year");
11520 }
11521 |  MONTH_P
11522  {
11523  $$ = mm_strdup("month");
11524 }
11525 |  DAY_P
11526  {
11527  $$ = mm_strdup("day");
11528 }
11529 |  HOUR_P
11530  {
11531  $$ = mm_strdup("hour");
11532 }
11533 |  MINUTE_P
11534  {
11535  $$ = mm_strdup("minute");
11536 }
11537 |  interval_second
11538  {
11539  $$ = $1;
11540 }
11541 |  YEAR_P TO MONTH_P
11542  {
11543  $$ = mm_strdup("year to month");
11544 }
11545 |  DAY_P TO HOUR_P
11546  {
11547  $$ = mm_strdup("day to hour");
11548 }
11549 |  DAY_P TO MINUTE_P
11550  {
11551  $$ = mm_strdup("day to minute");
11552 }
11553 |  DAY_P TO interval_second
11554  {
11555  $$ = cat_str(2,mm_strdup("day to"),$3);
11556 }
11557 |  HOUR_P TO MINUTE_P
11558  {
11559  $$ = mm_strdup("hour to minute");
11560 }
11561 |  HOUR_P TO interval_second
11562  {
11563  $$ = cat_str(2,mm_strdup("hour to"),$3);
11564 }
11565 |  MINUTE_P TO interval_second
11566  {
11567  $$ = cat_str(2,mm_strdup("minute to"),$3);
11568 }
11569 |
11570  {
11571  $$=EMPTY; }
11572 ;
11573 
11574 
11575  interval_second:
11576  SECOND_P
11577  {
11578  $$ = mm_strdup("second");
11579 }
11580 |  SECOND_P '(' Iconst ')'
11581  {
11582  $$ = cat_str(3,mm_strdup("second ("),$3,mm_strdup(")"));
11583 }
11584 ;
11585 
11586 
11587  a_expr:
11588  c_expr
11589  {
11590  $$ = $1;
11591 }
11592 |  a_expr TYPECAST Typename
11593  {
11594  $$ = cat_str(3,$1,mm_strdup("::"),$3);
11595 }
11596 |  a_expr COLLATE any_name
11597  {
11598  $$ = cat_str(3,$1,mm_strdup("collate"),$3);
11599 }
11600 |  a_expr AT TIME ZONE a_expr %prec AT
11601  {
11602  $$ = cat_str(3,$1,mm_strdup("at time zone"),$5);
11603 }
11604 |  '+' a_expr %prec UMINUS
11605  {
11606  $$ = cat_str(2,mm_strdup("+"),$2);
11607 }
11608 |  '-' a_expr %prec UMINUS
11609  {
11610  $$ = cat_str(2,mm_strdup("-"),$2);
11611 }
11612 |  a_expr '+' a_expr
11613  {
11614  $$ = cat_str(3,$1,mm_strdup("+"),$3);
11615 }
11616 |  a_expr '-' a_expr
11617  {
11618  $$ = cat_str(3,$1,mm_strdup("-"),$3);
11619 }
11620 |  a_expr '*' a_expr
11621  {
11622  $$ = cat_str(3,$1,mm_strdup("*"),$3);
11623 }
11624 |  a_expr '/' a_expr
11625  {
11626  $$ = cat_str(3,$1,mm_strdup("/"),$3);
11627 }
11628 |  a_expr '%' a_expr
11629  {
11630  $$ = cat_str(3,$1,mm_strdup("%"),$3);
11631 }
11632 |  a_expr '^' a_expr
11633  {
11634  $$ = cat_str(3,$1,mm_strdup("^"),$3);
11635 }
11636 |  a_expr '<' a_expr
11637  {
11638  $$ = cat_str(3,$1,mm_strdup("<"),$3);
11639 }
11640 |  a_expr '>' a_expr
11641  {
11642  $$ = cat_str(3,$1,mm_strdup(">"),$3);
11643 }
11644 |  a_expr '=' a_expr
11645  {
11646  $$ = cat_str(3,$1,mm_strdup("="),$3);
11647 }
11648 |  a_expr LESS_EQUALS a_expr
11649  {
11650  $$ = cat_str(3,$1,mm_strdup("<="),$3);
11651 }
11652 |  a_expr GREATER_EQUALS a_expr
11653  {
11654  $$ = cat_str(3,$1,mm_strdup(">="),$3);
11655 }
11656 |  a_expr NOT_EQUALS a_expr
11657  {
11658  $$ = cat_str(3,$1,mm_strdup("<>"),$3);
11659 }
11660 |  a_expr qual_Op a_expr %prec Op
11661  {
11662  $$ = cat_str(3,$1,$2,$3);
11663 }
11664 |  qual_Op a_expr %prec Op
11665  {
11666  $$ = cat_str(2,$1,$2);
11667 }
11668 |  a_expr qual_Op %prec POSTFIXOP
11669  {
11670  $$ = cat_str(2,$1,$2);
11671 }
11672 |  a_expr AND a_expr
11673  {
11674  $$ = cat_str(3,$1,mm_strdup("and"),$3);
11675 }
11676 |  a_expr OR a_expr
11677  {
11678  $$ = cat_str(3,$1,mm_strdup("or"),$3);
11679 }
11680 |  NOT a_expr
11681  {
11682  $$ = cat_str(2,mm_strdup("not"),$2);
11683 }
11684 |  NOT_LA a_expr %prec NOT
11685  {
11686  $$ = cat_str(2,mm_strdup("not"),$2);
11687 }
11688 |  a_expr LIKE a_expr
11689  {
11690  $$ = cat_str(3,$1,mm_strdup("like"),$3);
11691 }
11692 |  a_expr LIKE a_expr ESCAPE a_expr %prec LIKE
11693  {
11694  $$ = cat_str(5,$1,mm_strdup("like"),$3,mm_strdup("escape"),$5);
11695 }
11696 |  a_expr NOT_LA LIKE a_expr %prec NOT_LA
11697  {
11698  $$ = cat_str(3,$1,mm_strdup("not like"),$4);
11699 }
11700 |  a_expr NOT_LA LIKE a_expr ESCAPE a_expr %prec NOT_LA
11701  {
11702  $$ = cat_str(5,$1,mm_strdup("not like"),$4,mm_strdup("escape"),$6);
11703 }
11704 |  a_expr ILIKE a_expr
11705  {
11706  $$ = cat_str(3,$1,mm_strdup("ilike"),$3);
11707 }
11708 |  a_expr ILIKE a_expr ESCAPE a_expr %prec ILIKE
11709  {
11710  $$ = cat_str(5,$1,mm_strdup("ilike"),$3,mm_strdup("escape"),$5);
11711 }
11712 |  a_expr NOT_LA ILIKE a_expr %prec NOT_LA
11713  {
11714  $$ = cat_str(3,$1,mm_strdup("not ilike"),$4);
11715 }
11716 |  a_expr NOT_LA ILIKE a_expr ESCAPE a_expr %prec NOT_LA
11717  {
11718  $$ = cat_str(5,$1,mm_strdup("not ilike"),$4,mm_strdup("escape"),$6);
11719 }
11720 |  a_expr SIMILAR TO a_expr %prec SIMILAR
11721  {
11722  $$ = cat_str(3,$1,mm_strdup("similar to"),$4);
11723 }
11724 |  a_expr SIMILAR TO a_expr ESCAPE a_expr %prec SIMILAR
11725  {
11726  $$ = cat_str(5,$1,mm_strdup("similar to"),$4,mm_strdup("escape"),$6);
11727 }
11728 |  a_expr NOT_LA SIMILAR TO a_expr %prec NOT_LA
11729  {
11730  $$ = cat_str(3,$1,mm_strdup("not similar to"),$5);
11731 }
11732 |  a_expr NOT_LA SIMILAR TO a_expr ESCAPE a_expr %prec NOT_LA
11733  {
11734  $$ = cat_str(5,$1,mm_strdup("not similar to"),$5,mm_strdup("escape"),$7);
11735 }
11736 |  a_expr IS NULL_P %prec IS
11737  {
11738  $$ = cat_str(2,$1,mm_strdup("is null"));
11739 }
11740 |  a_expr ISNULL
11741  {
11742  $$ = cat_str(2,$1,mm_strdup("isnull"));
11743 }
11744 |  a_expr IS NOT NULL_P %prec IS
11745  {
11746  $$ = cat_str(2,$1,mm_strdup("is not null"));
11747 }
11748 |  a_expr NOTNULL
11749  {
11750  $$ = cat_str(2,$1,mm_strdup("notnull"));
11751 }
11752 |  row OVERLAPS row
11753  {
11754  $$ = cat_str(3,$1,mm_strdup("overlaps"),$3);
11755 }
11756 |  a_expr IS TRUE_P %prec IS
11757  {
11758  $$ = cat_str(2,$1,mm_strdup("is true"));
11759 }
11760 |  a_expr IS NOT TRUE_P %prec IS
11761  {
11762  $$ = cat_str(2,$1,mm_strdup("is not true"));
11763 }
11764 |  a_expr IS FALSE_P %prec IS
11765  {
11766  $$ = cat_str(2,$1,mm_strdup("is false"));
11767 }
11768 |  a_expr IS NOT FALSE_P %prec IS
11769  {
11770  $$ = cat_str(2,$1,mm_strdup("is not false"));
11771 }
11772 |  a_expr IS UNKNOWN %prec IS
11773  {
11774  $$ = cat_str(2,$1,mm_strdup("is unknown"));
11775 }
11776 |  a_expr IS NOT UNKNOWN %prec IS
11777  {
11778  $$ = cat_str(2,$1,mm_strdup("is not unknown"));
11779 }
11780 |  a_expr IS DISTINCT FROM a_expr %prec IS
11781  {
11782  $$ = cat_str(3,$1,mm_strdup("is distinct from"),$5);
11783 }
11784 |  a_expr IS NOT DISTINCT FROM a_expr %prec IS
11785  {
11786  $$ = cat_str(3,$1,mm_strdup("is not distinct from"),$6);
11787 }
11788 |  a_expr IS OF '(' type_list ')' %prec IS
11789  {
11790  $$ = cat_str(4,$1,mm_strdup("is of ("),$5,mm_strdup(")"));
11791 }
11792 |  a_expr IS NOT OF '(' type_list ')' %prec IS
11793  {
11794  $$ = cat_str(4,$1,mm_strdup("is not of ("),$6,mm_strdup(")"));
11795 }
11796 |  a_expr BETWEEN opt_asymmetric b_expr AND a_expr %prec BETWEEN
11797  {
11798  $$ = cat_str(6,$1,mm_strdup("between"),$3,$4,mm_strdup("and"),$6);
11799 }
11800 |  a_expr NOT_LA BETWEEN opt_asymmetric b_expr AND a_expr %prec NOT_LA
11801  {
11802  $$ = cat_str(6,$1,mm_strdup("not between"),$4,$5,mm_strdup("and"),$7);
11803 }
11804 |  a_expr BETWEEN SYMMETRIC b_expr AND a_expr %prec BETWEEN
11805  {
11806  $$ = cat_str(5,$1,mm_strdup("between symmetric"),$4,mm_strdup("and"),$6);
11807 }
11808 |  a_expr NOT_LA BETWEEN SYMMETRIC b_expr AND a_expr %prec NOT_LA
11809  {
11810  $$ = cat_str(5,$1,mm_strdup("not between symmetric"),$5,mm_strdup("and"),$7);
11811 }
11812 |  a_expr IN_P in_expr
11813  {
11814  $$ = cat_str(3,$1,mm_strdup("in"),$3);
11815 }
11816 |  a_expr NOT_LA IN_P in_expr %prec NOT_LA
11817  {
11818  $$ = cat_str(3,$1,mm_strdup("not in"),$4);
11819 }
11820 |  a_expr subquery_Op sub_type select_with_parens %prec Op
11821  {
11822  $$ = cat_str(4,$1,$2,$3,$4);
11823 }
11824 |  a_expr subquery_Op sub_type '(' a_expr ')' %prec Op
11825  {
11826  $$ = cat_str(6,$1,$2,$3,mm_strdup("("),$5,mm_strdup(")"));
11827 }
11828 |  UNIQUE select_with_parens
11829  {
11830 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
11831  $$ = cat_str(2,mm_strdup("unique"),$2);
11832 }
11833 |  a_expr IS DOCUMENT_P %prec IS
11834  {
11835  $$ = cat_str(2,$1,mm_strdup("is document"));
11836 }
11837 |  a_expr IS NOT DOCUMENT_P %prec IS
11838  {
11839  $$ = cat_str(2,$1,mm_strdup("is not document"));
11840 }
11841 |  DEFAULT
11842  {
11843  $$ = mm_strdup("default");
11844 }
11845 ;
11846 
11847 
11848  b_expr:
11849  c_expr
11850  {
11851  $$ = $1;
11852 }
11853 |  b_expr TYPECAST Typename
11854  {
11855  $$ = cat_str(3,$1,mm_strdup("::"),$3);
11856 }
11857 |  '+' b_expr %prec UMINUS
11858  {
11859  $$ = cat_str(2,mm_strdup("+"),$2);
11860 }
11861 |  '-' b_expr %prec UMINUS
11862  {
11863  $$ = cat_str(2,mm_strdup("-"),$2);
11864 }
11865 |  b_expr '+' b_expr
11866  {
11867  $$ = cat_str(3,$1,mm_strdup("+"),$3);
11868 }
11869 |  b_expr '-' b_expr
11870  {
11871  $$ = cat_str(3,$1,mm_strdup("-"),$3);
11872 }
11873 |  b_expr '*' b_expr
11874  {
11875  $$ = cat_str(3,$1,mm_strdup("*"),$3);
11876 }
11877 |  b_expr '/' b_expr
11878  {
11879  $$ = cat_str(3,$1,mm_strdup("/"),$3);
11880 }
11881 |  b_expr '%' b_expr
11882  {
11883  $$ = cat_str(3,$1,mm_strdup("%"),$3);
11884 }
11885 |  b_expr '^' b_expr
11886  {
11887  $$ = cat_str(3,$1,mm_strdup("^"),$3);
11888 }
11889 |  b_expr '<' b_expr
11890  {
11891  $$ = cat_str(3,$1,mm_strdup("<"),$3);
11892 }
11893 |  b_expr '>' b_expr
11894  {
11895  $$ = cat_str(3,$1,mm_strdup(">"),$3);
11896 }
11897 |  b_expr '=' b_expr
11898  {
11899  $$ = cat_str(3,$1,mm_strdup("="),$3);
11900 }
11901 |  b_expr LESS_EQUALS b_expr
11902  {
11903  $$ = cat_str(3,$1,mm_strdup("<="),$3);
11904 }
11905 |  b_expr GREATER_EQUALS b_expr
11906  {
11907  $$ = cat_str(3,$1,mm_strdup(">="),$3);
11908 }
11909 |  b_expr NOT_EQUALS b_expr
11910  {
11911  $$ = cat_str(3,$1,mm_strdup("<>"),$3);
11912 }
11913 |  b_expr qual_Op b_expr %prec Op
11914  {
11915  $$ = cat_str(3,$1,$2,$3);
11916 }
11917 |  qual_Op b_expr %prec Op
11918  {
11919  $$ = cat_str(2,$1,$2);
11920 }
11921 |  b_expr qual_Op %prec POSTFIXOP
11922  {
11923  $$ = cat_str(2,$1,$2);
11924 }
11925 |  b_expr IS DISTINCT FROM b_expr %prec IS
11926  {
11927  $$ = cat_str(3,$1,mm_strdup("is distinct from"),$5);
11928 }
11929 |  b_expr IS NOT DISTINCT FROM b_expr %prec IS
11930  {
11931  $$ = cat_str(3,$1,mm_strdup("is not distinct from"),$6);
11932 }
11933 |  b_expr IS OF '(' type_list ')' %prec IS
11934  {
11935  $$ = cat_str(4,$1,mm_strdup("is of ("),$5,mm_strdup(")"));
11936 }
11937 |  b_expr IS NOT OF '(' type_list ')' %prec IS
11938  {
11939  $$ = cat_str(4,$1,mm_strdup("is not of ("),$6,mm_strdup(")"));
11940 }
11941 |  b_expr IS DOCUMENT_P %prec IS
11942  {
11943  $$ = cat_str(2,$1,mm_strdup("is document"));
11944 }
11945 |  b_expr IS NOT DOCUMENT_P %prec IS
11946  {
11947  $$ = cat_str(2,$1,mm_strdup("is not document"));
11948 }
11949 ;
11950 
11951 
11952  c_expr:
11953  columnref
11954  {
11955  $$ = $1;
11956 }
11957 |  AexprConst
11958  {
11959  $$ = $1;
11960 }
11961 |  ecpg_param opt_indirection
11962  {
11963  $$ = cat_str(2,$1,$2);
11964 }
11965 |  '(' a_expr ')' opt_indirection
11966  {
11967  $$ = cat_str(4,mm_strdup("("),$2,mm_strdup(")"),$4);
11968 }
11969 |  case_expr
11970  {
11971  $$ = $1;
11972 }
11973 |  func_expr
11974  {
11975  $$ = $1;
11976 }
11977 |  select_with_parens %prec UMINUS
11978  {
11979  $$ = $1;
11980 }
11981 |  select_with_parens indirection
11982  {
11983  $$ = cat_str(2,$1,$2);
11984 }
11985 |  EXISTS select_with_parens
11986  {
11987  $$ = cat_str(2,mm_strdup("exists"),$2);
11988 }
11989 |  ARRAY select_with_parens
11990  {
11991  $$ = cat_str(2,mm_strdup("array"),$2);
11992 }
11993 |  ARRAY array_expr
11994  {
11995  $$ = cat_str(2,mm_strdup("array"),$2);
11996 }
11997 |  explicit_row
11998  {
11999  $$ = $1;
12000 }
12001 |  implicit_row
12002  {
12003  $$ = $1;
12004 }
12005 |  GROUPING '(' expr_list ')'
12006  {
12007  $$ = cat_str(3,mm_strdup("grouping ("),$3,mm_strdup(")"));
12008 }
12009 ;
12010 
12011 
12012  func_application:
12013  func_name '(' ')'
12014  {
12015  $$ = cat_str(2,$1,mm_strdup("( )"));
12016 }
12017 |  func_name '(' func_arg_list opt_sort_clause ')'
12018  {
12019  $$ = cat_str(5,$1,mm_strdup("("),$3,$4,mm_strdup(")"));
12020 }
12021 |  func_name '(' VARIADIC func_arg_expr opt_sort_clause ')'
12022  {
12023  $$ = cat_str(5,$1,mm_strdup("( variadic"),$4,$5,mm_strdup(")"));
12024 }
12025 |  func_name '(' func_arg_list ',' VARIADIC func_arg_expr opt_sort_clause ')'
12026  {
12027  $$ = cat_str(7,$1,mm_strdup("("),$3,mm_strdup(", variadic"),$6,$7,mm_strdup(")"));
12028 }
12029 |  func_name '(' ALL func_arg_list opt_sort_clause ')'
12030  {
12031  $$ = cat_str(5,$1,mm_strdup("( all"),$4,$5,mm_strdup(")"));
12032 }
12033 |  func_name '(' DISTINCT func_arg_list opt_sort_clause ')'
12034  {
12035  $$ = cat_str(5,$1,mm_strdup("( distinct"),$4,$5,mm_strdup(")"));
12036 }
12037 |  func_name '(' '*' ')'
12038  {
12039  $$ = cat_str(2,$1,mm_strdup("( * )"));
12040 }
12041 ;
12042 
12043 
12044  func_expr:
12045  func_application within_group_clause filter_clause over_clause
12046  {
12047  $$ = cat_str(4,$1,$2,$3,$4);
12048 }
12049 |  func_expr_common_subexpr
12050  {
12051  $$ = $1;
12052 }
12053 ;
12054 
12055 
12056  func_expr_windowless:
12057  func_application
12058  {
12059  $$ = $1;
12060 }
12061 |  func_expr_common_subexpr
12062  {
12063  $$ = $1;
12064 }
12065 ;
12066 
12067 
12068  func_expr_common_subexpr:
12069  COLLATION FOR '(' a_expr ')'
12070  {
12071  $$ = cat_str(3,mm_strdup("collation for ("),$4,mm_strdup(")"));
12072 }
12073 |  CURRENT_DATE
12074  {
12075  $$ = mm_strdup("current_date");
12076 }
12077 |  CURRENT_TIME
12078  {
12079  $$ = mm_strdup("current_time");
12080 }
12081 |  CURRENT_TIME '(' Iconst ')'
12082  {
12083  $$ = cat_str(3,mm_strdup("current_time ("),$3,mm_strdup(")"));
12084 }
12085 |  CURRENT_TIMESTAMP
12086  {
12087  $$ = mm_strdup("current_timestamp");
12088 }
12089 |  CURRENT_TIMESTAMP '(' Iconst ')'
12090  {
12091  $$ = cat_str(3,mm_strdup("current_timestamp ("),$3,mm_strdup(")"));
12092 }
12093 |  LOCALTIME
12094  {
12095  $$ = mm_strdup("localtime");
12096 }
12097 |  LOCALTIME '(' Iconst ')'
12098  {
12099  $$ = cat_str(3,mm_strdup("localtime ("),$3,mm_strdup(")"));
12100 }
12101 |  LOCALTIMESTAMP
12102  {
12103  $$ = mm_strdup("localtimestamp");
12104 }
12105 |  LOCALTIMESTAMP '(' Iconst ')'
12106  {
12107  $$ = cat_str(3,mm_strdup("localtimestamp ("),$3,mm_strdup(")"));
12108 }
12109 |  CURRENT_ROLE
12110  {
12111  $$ = mm_strdup("current_role");
12112 }
12113 |  CURRENT_USER
12114  {
12115  $$ = mm_strdup("current_user");
12116 }
12117 |  SESSION_USER
12118  {
12119  $$ = mm_strdup("session_user");
12120 }
12121 |  USER
12122  {
12123  $$ = mm_strdup("user");
12124 }
12125 |  CURRENT_CATALOG
12126  {
12127  $$ = mm_strdup("current_catalog");
12128 }
12129 |  CURRENT_SCHEMA
12130  {
12131  $$ = mm_strdup("current_schema");
12132 }
12133 |  CAST '(' a_expr AS Typename ')'
12134  {
12135  $$ = cat_str(5,mm_strdup("cast ("),$3,mm_strdup("as"),$5,mm_strdup(")"));
12136 }
12137 |  EXTRACT '(' extract_list ')'
12138  {
12139  $$ = cat_str(3,mm_strdup("extract ("),$3,mm_strdup(")"));
12140 }
12141 |  OVERLAY '(' overlay_list ')'
12142  {
12143  $$ = cat_str(3,mm_strdup("overlay ("),$3,mm_strdup(")"));
12144 }
12145 |  POSITION '(' position_list ')'
12146  {
12147  $$ = cat_str(3,mm_strdup("position ("),$3,mm_strdup(")"));
12148 }
12149 |  SUBSTRING '(' substr_list ')'
12150  {
12151  $$ = cat_str(3,mm_strdup("substring ("),$3,mm_strdup(")"));
12152 }
12153 |  TREAT '(' a_expr AS Typename ')'
12154  {
12155  $$ = cat_str(5,mm_strdup("treat ("),$3,mm_strdup("as"),$5,mm_strdup(")"));
12156 }
12157 |  TRIM '(' BOTH trim_list ')'
12158  {
12159  $$ = cat_str(3,mm_strdup("trim ( both"),$4,mm_strdup(")"));
12160 }
12161 |  TRIM '(' LEADING trim_list ')'
12162  {
12163  $$ = cat_str(3,mm_strdup("trim ( leading"),$4,mm_strdup(")"));
12164 }
12165 |  TRIM '(' TRAILING trim_list ')'
12166  {
12167  $$ = cat_str(3,mm_strdup("trim ( trailing"),$4,mm_strdup(")"));
12168 }
12169 |  TRIM '(' trim_list ')'
12170  {
12171  $$ = cat_str(3,mm_strdup("trim ("),$3,mm_strdup(")"));
12172 }
12173 |  NULLIF '(' a_expr ',' a_expr ')'
12174  {
12175  $$ = cat_str(5,mm_strdup("nullif ("),$3,mm_strdup(","),$5,mm_strdup(")"));
12176 }
12177 |  COALESCE '(' expr_list ')'
12178  {
12179  $$ = cat_str(3,mm_strdup("coalesce ("),$3,mm_strdup(")"));
12180 }
12181 |  GREATEST '(' expr_list ')'
12182  {
12183  $$ = cat_str(3,mm_strdup("greatest ("),$3,mm_strdup(")"));
12184 }
12185 |  LEAST '(' expr_list ')'
12186  {
12187  $$ = cat_str(3,mm_strdup("least ("),$3,mm_strdup(")"));
12188 }
12189 |  XMLCONCAT '(' expr_list ')'
12190  {
12191  $$ = cat_str(3,mm_strdup("xmlconcat ("),$3,mm_strdup(")"));
12192 }
12193 |  XMLELEMENT '(' NAME_P ColLabel ')'
12194  {
12195  $$ = cat_str(3,mm_strdup("xmlelement ( name"),$4,mm_strdup(")"));
12196 }
12197 |  XMLELEMENT '(' NAME_P ColLabel ',' xml_attributes ')'
12198  {
12199  $$ = cat_str(5,mm_strdup("xmlelement ( name"),$4,mm_strdup(","),$6,mm_strdup(")"));
12200 }
12201 |  XMLELEMENT '(' NAME_P ColLabel ',' expr_list ')'
12202  {
12203  $$ = cat_str(5,mm_strdup("xmlelement ( name"),$4,mm_strdup(","),$6,mm_strdup(")"));
12204 }
12205 |  XMLELEMENT '(' NAME_P ColLabel ',' xml_attributes ',' expr_list ')'
12206  {
12207  $$ = cat_str(7,mm_strdup("xmlelement ( name"),$4,mm_strdup(","),$6,mm_strdup(","),$8,mm_strdup(")"));
12208 }
12209 |  XMLEXISTS '(' c_expr xmlexists_argument ')'
12210  {
12211  $$ = cat_str(4,mm_strdup("xmlexists ("),$3,$4,mm_strdup(")"));
12212 }
12213 |  XMLFOREST '(' xml_attribute_list ')'
12214  {
12215  $$ = cat_str(3,mm_strdup("xmlforest ("),$3,mm_strdup(")"));
12216 }
12217 |  XMLPARSE '(' document_or_content a_expr xml_whitespace_option ')'
12218  {
12219  $$ = cat_str(5,mm_strdup("xmlparse ("),$3,$4,$5,mm_strdup(")"));
12220 }
12221 |  XMLPI '(' NAME_P ColLabel ')'
12222  {
12223  $$ = cat_str(3,mm_strdup("xmlpi ( name"),$4,mm_strdup(")"));
12224 }
12225 |  XMLPI '(' NAME_P ColLabel ',' a_expr ')'
12226  {
12227  $$ = cat_str(5,mm_strdup("xmlpi ( name"),$4,mm_strdup(","),$6,mm_strdup(")"));
12228 }
12229 |  XMLROOT '(' a_expr ',' xml_root_version opt_xml_root_standalone ')'
12230  {
12231  $$ = cat_str(6,mm_strdup("xmlroot ("),$3,mm_strdup(","),$5,$6,mm_strdup(")"));
12232 }
12233 |  XMLSERIALIZE '(' document_or_content a_expr AS SimpleTypename ')'
12234  {
12235  $$ = cat_str(6,mm_strdup("xmlserialize ("),$3,$4,mm_strdup("as"),$6,mm_strdup(")"));
12236 }
12237 ;
12238 
12239 
12240  xml_root_version:
12241  VERSION_P a_expr
12242  {
12243  $$ = cat_str(2,mm_strdup("version"),$2);
12244 }
12245 |  VERSION_P NO VALUE_P
12246  {
12247  $$ = mm_strdup("version no value");
12248 }
12249 ;
12250 
12251 
12252  opt_xml_root_standalone:
12253  ',' STANDALONE_P YES_P
12254  {
12255  $$ = mm_strdup(", standalone yes");
12256 }
12257 |  ',' STANDALONE_P NO
12258  {
12259  $$ = mm_strdup(", standalone no");
12260 }
12261 |  ',' STANDALONE_P NO VALUE_P
12262  {
12263  $$ = mm_strdup(", standalone no value");
12264 }
12265 |
12266  {
12267  $$=EMPTY; }
12268 ;
12269 
12270 
12271  xml_attributes:
12272  XMLATTRIBUTES '(' xml_attribute_list ')'
12273  {
12274  $$ = cat_str(3,mm_strdup("xmlattributes ("),$3,mm_strdup(")"));
12275 }
12276 ;
12277 
12278 
12279  xml_attribute_list:
12280  xml_attribute_el
12281  {
12282  $$ = $1;
12283 }
12284 |  xml_attribute_list ',' xml_attribute_el
12285  {
12286  $$ = cat_str(3,$1,mm_strdup(","),$3);
12287 }
12288 ;
12289 
12290 
12291  xml_attribute_el:
12292  a_expr AS ColLabel
12293  {
12294  $$ = cat_str(3,$1,mm_strdup("as"),$3);
12295 }
12296 |  a_expr
12297  {
12298  $$ = $1;
12299 }
12300 ;
12301 
12302 
12303  document_or_content:
12304  DOCUMENT_P
12305  {
12306  $$ = mm_strdup("document");
12307 }
12308 |  CONTENT_P
12309  {
12310  $$ = mm_strdup("content");
12311 }
12312 ;
12313 
12314 
12315  xml_whitespace_option:
12316  PRESERVE WHITESPACE_P
12317  {
12318  $$ = mm_strdup("preserve whitespace");
12319 }
12320 |  STRIP_P WHITESPACE_P
12321  {
12322  $$ = mm_strdup("strip whitespace");
12323 }
12324 |
12325  {
12326  $$=EMPTY; }
12327 ;
12328 
12329 
12330  xmlexists_argument:
12331  PASSING c_expr
12332  {
12333  $$ = cat_str(2,mm_strdup("passing"),$2);
12334 }
12335 |  PASSING c_expr BY REF
12336  {
12337  $$ = cat_str(3,mm_strdup("passing"),$2,mm_strdup("by ref"));
12338 }
12339 |  PASSING BY REF c_expr
12340  {
12341  $$ = cat_str(2,mm_strdup("passing by ref"),$4);
12342 }
12343 |  PASSING BY REF c_expr BY REF
12344  {
12345  $$ = cat_str(3,mm_strdup("passing by ref"),$4,mm_strdup("by ref"));
12346 }
12347 ;
12348 
12349 
12350  within_group_clause:
12351  WITHIN GROUP_P '(' sort_clause ')'
12352  {
12353  $$ = cat_str(3,mm_strdup("within group ("),$4,mm_strdup(")"));
12354 }
12355 |
12356  {
12357  $$=EMPTY; }
12358 ;
12359 
12360 
12361  filter_clause:
12362  FILTER '(' WHERE a_expr ')'
12363  {
12364  $$ = cat_str(3,mm_strdup("filter ( where"),$4,mm_strdup(")"));
12365 }
12366 |
12367  {
12368  $$=EMPTY; }
12369 ;
12370 
12371 
12372  window_clause:
12373  WINDOW window_definition_list
12374  {
12375  $$ = cat_str(2,mm_strdup("window"),$2);
12376 }
12377 |
12378  {
12379  $$=EMPTY; }
12380 ;
12381 
12382 
12383  window_definition_list:
12384  window_definition
12385  {
12386  $$ = $1;
12387 }
12388 |  window_definition_list ',' window_definition
12389  {
12390  $$ = cat_str(3,$1,mm_strdup(","),$3);
12391 }
12392 ;
12393 
12394 
12395  window_definition:
12396  ColId AS window_specification
12397  {
12398  $$ = cat_str(3,$1,mm_strdup("as"),$3);
12399 }
12400 ;
12401 
12402 
12403  over_clause:
12404  OVER window_specification
12405  {
12406  $$ = cat_str(2,mm_strdup("over"),$2);
12407 }
12408 |  OVER ColId
12409  {
12410  $$ = cat_str(2,mm_strdup("over"),$2);
12411 }
12412 |
12413  {
12414  $$=EMPTY; }
12415 ;
12416 
12417 
12418  window_specification:
12419  '(' opt_existing_window_name opt_partition_clause opt_sort_clause opt_frame_clause ')'
12420  {
12421  $$ = cat_str(6,mm_strdup("("),$2,$3,$4,$5,mm_strdup(")"));
12422 }
12423 ;
12424 
12425 
12426  opt_existing_window_name:
12427  ColId
12428  {
12429  $$ = $1;
12430 }
12431 |  %prec Op
12432  {
12433  $$=EMPTY; }
12434 ;
12435 
12436 
12437  opt_partition_clause:
12438  PARTITION BY expr_list
12439  {
12440  $$ = cat_str(2,mm_strdup("partition by"),$3);
12441 }
12442 |
12443  {
12444  $$=EMPTY; }
12445 ;
12446 
12447 
12448  opt_frame_clause:
12449  RANGE frame_extent opt_window_exclusion_clause
12450  {
12451  $$ = cat_str(3,mm_strdup("range"),$2,$3);
12452 }
12453 |  ROWS frame_extent opt_window_exclusion_clause
12454  {
12455  $$ = cat_str(3,mm_strdup("rows"),$2,$3);
12456 }
12457 |  GROUPS frame_extent opt_window_exclusion_clause
12458  {
12459  $$ = cat_str(3,mm_strdup("groups"),$2,$3);
12460 }
12461 |
12462  {
12463  $$=EMPTY; }
12464 ;
12465 
12466 
12467  frame_extent:
12468  frame_bound
12469  {
12470  $$ = $1;
12471 }
12472 |  BETWEEN frame_bound AND frame_bound
12473  {
12474  $$ = cat_str(4,mm_strdup("between"),$2,mm_strdup("and"),$4);
12475 }
12476 ;
12477 
12478 
12479  frame_bound:
12480  UNBOUNDED PRECEDING
12481  {
12482  $$ = mm_strdup("unbounded preceding");
12483 }
12484 |  UNBOUNDED FOLLOWING
12485  {
12486  $$ = mm_strdup("unbounded following");
12487 }
12488 |  CURRENT_P ROW
12489  {
12490  $$ = mm_strdup("current row");
12491 }
12492 |  a_expr PRECEDING
12493  {
12494  $$ = cat_str(2,$1,mm_strdup("preceding"));
12495 }
12496 |  a_expr FOLLOWING
12497  {
12498  $$ = cat_str(2,$1,mm_strdup("following"));
12499 }
12500 ;
12501 
12502 
12503  opt_window_exclusion_clause:
12504  EXCLUDE CURRENT_P ROW
12505  {
12506  $$ = mm_strdup("exclude current row");
12507 }
12508 |  EXCLUDE GROUP_P
12509  {
12510  $$ = mm_strdup("exclude group");
12511 }
12512 |  EXCLUDE TIES
12513  {
12514  $$ = mm_strdup("exclude ties");
12515 }
12516 |  EXCLUDE NO OTHERS
12517  {
12518  $$ = mm_strdup("exclude no others");
12519 }
12520 |
12521  {
12522  $$=EMPTY; }
12523 ;
12524 
12525 
12526  row:
12527  ROW '(' expr_list ')'
12528  {
12529  $$ = cat_str(3,mm_strdup("row ("),$3,mm_strdup(")"));
12530 }
12531 |  ROW '(' ')'
12532  {
12533  $$ = mm_strdup("row ( )");
12534 }
12535 |  '(' expr_list ',' a_expr ')'
12536  {
12537  $$ = cat_str(5,mm_strdup("("),$2,mm_strdup(","),$4,mm_strdup(")"));
12538 }
12539 ;
12540 
12541 
12542  explicit_row:
12543  ROW '(' expr_list ')'
12544  {
12545  $$ = cat_str(3,mm_strdup("row ("),$3,mm_strdup(")"));
12546 }
12547 |  ROW '(' ')'
12548  {
12549  $$ = mm_strdup("row ( )");
12550 }
12551 ;
12552 
12553 
12554  implicit_row:
12555  '(' expr_list ',' a_expr ')'
12556  {
12557  $$ = cat_str(5,mm_strdup("("),$2,mm_strdup(","),$4,mm_strdup(")"));
12558 }
12559 ;
12560 
12561 
12562  sub_type:
12563  ANY
12564  {
12565  $$ = mm_strdup("any");
12566 }
12567 |  SOME
12568  {
12569  $$ = mm_strdup("some");
12570 }
12571 |  ALL
12572  {
12573  $$ = mm_strdup("all");
12574 }
12575 ;
12576 
12577 
12578  all_Op:
12579  Op
12580  {
12581  $$ = $1;
12582 }
12583 |  MathOp
12584  {
12585  $$ = $1;
12586 }
12587 ;
12588 
12589 
12590  MathOp:
12591  '+'
12592  {
12593  $$ = mm_strdup("+");
12594 }
12595 |  '-'
12596  {
12597  $$ = mm_strdup("-");
12598 }
12599 |  '*'
12600  {
12601  $$ = mm_strdup("*");
12602 }
12603 |  '/'
12604  {
12605  $$ = mm_strdup("/");
12606 }
12607 |  '%'
12608  {
12609  $$ = mm_strdup("%");
12610 }
12611 |  '^'
12612  {
12613  $$ = mm_strdup("^");
12614 }
12615 |  '<'
12616  {
12617  $$ = mm_strdup("<");
12618 }
12619 |  '>'
12620  {
12621  $$ = mm_strdup(">");
12622 }
12623 |  '='
12624  {
12625  $$ = mm_strdup("=");
12626 }
12627 |  LESS_EQUALS
12628  {
12629  $$ = mm_strdup("<=");
12630 }
12631 |  GREATER_EQUALS
12632  {
12633  $$ = mm_strdup(">=");
12634 }
12635 |  NOT_EQUALS
12636  {
12637  $$ = mm_strdup("<>");
12638 }
12639 ;
12640 
12641 
12642  qual_Op:
12643  Op
12644  {
12645  $$ = $1;
12646 }
12647 |  OPERATOR '(' any_operator ')'
12648  {
12649  $$ = cat_str(3,mm_strdup("operator ("),$3,mm_strdup(")"));
12650 }
12651 ;
12652 
12653 
12654  qual_all_Op:
12655  all_Op
12656  {
12657  $$ = $1;
12658 }
12659 |  OPERATOR '(' any_operator ')'
12660  {
12661  $$ = cat_str(3,mm_strdup("operator ("),$3,mm_strdup(")"));
12662 }
12663 ;
12664 
12665 
12666  subquery_Op:
12667  all_Op
12668  {
12669  $$ = $1;
12670 }
12671 |  OPERATOR '(' any_operator ')'
12672  {
12673  $$ = cat_str(3,mm_strdup("operator ("),$3,mm_strdup(")"));
12674 }
12675 |  LIKE
12676  {
12677  $$ = mm_strdup("like");
12678 }
12679 |  NOT_LA LIKE
12680  {
12681  $$ = mm_strdup("not like");
12682 }
12683 |  ILIKE
12684  {
12685  $$ = mm_strdup("ilike");
12686 }
12687 |  NOT_LA ILIKE
12688  {
12689  $$ = mm_strdup("not ilike");
12690 }
12691 ;
12692 
12693 
12694  expr_list:
12695  a_expr
12696  {
12697  $$ = $1;
12698 }
12699 |  expr_list ',' a_expr
12700  {
12701  $$ = cat_str(3,$1,mm_strdup(","),$3);
12702 }
12703 ;
12704 
12705 
12706  func_arg_list:
12707  func_arg_expr
12708  {
12709  $$ = $1;
12710 }
12711 |  func_arg_list ',' func_arg_expr
12712  {
12713  $$ = cat_str(3,$1,mm_strdup(","),$3);
12714 }
12715 ;
12716 
12717 
12718  func_arg_expr:
12719  a_expr
12720  {
12721  $$ = $1;
12722 }
12723 |  param_name COLON_EQUALS a_expr
12724  {
12725  $$ = cat_str(3,$1,mm_strdup(":="),$3);
12726 }
12727 |  param_name EQUALS_GREATER a_expr
12728  {
12729  $$ = cat_str(3,$1,mm_strdup("=>"),$3);
12730 }
12731 ;
12732 
12733 
12734  type_list:
12735  Typename
12736  {
12737  $$ = $1;
12738 }
12739 |  type_list ',' Typename
12740  {
12741  $$ = cat_str(3,$1,mm_strdup(","),$3);
12742 }
12743 ;
12744 
12745 
12746  array_expr:
12747  '[' expr_list ']'
12748  {
12749  $$ = cat_str(3,mm_strdup("["),$2,mm_strdup("]"));
12750 }
12751 |  '[' array_expr_list ']'
12752  {
12753  $$ = cat_str(3,mm_strdup("["),$2,mm_strdup("]"));
12754 }
12755 |  '[' ']'
12756  {
12757  $$ = mm_strdup("[ ]");
12758 }
12759 ;
12760 
12761 
12762  array_expr_list:
12763  array_expr
12764  {
12765  $$ = $1;
12766 }
12767 |  array_expr_list ',' array_expr
12768  {
12769  $$ = cat_str(3,$1,mm_strdup(","),$3);
12770 }
12771 ;
12772 
12773 
12774  extract_list:
12775  extract_arg FROM a_expr
12776  {
12777  $$ = cat_str(3,$1,mm_strdup("from"),$3);
12778 }
12779 |
12780  {
12781  $$=EMPTY; }
12782 ;
12783 
12784 
12785  extract_arg:
12786  ecpg_ident
12787  {
12788  $$ = $1;
12789 }
12790 |  YEAR_P
12791  {
12792  $$ = mm_strdup("year");
12793 }
12794 |  MONTH_P
12795  {
12796  $$ = mm_strdup("month");
12797 }
12798 |  DAY_P
12799  {
12800  $$ = mm_strdup("day");
12801 }
12802 |  HOUR_P
12803  {
12804  $$ = mm_strdup("hour");
12805 }
12806 |  MINUTE_P
12807  {
12808  $$ = mm_strdup("minute");
12809 }
12810 |  SECOND_P
12811  {
12812  $$ = mm_strdup("second");
12813 }
12814 |  ecpg_sconst
12815  {
12816  $$ = $1;
12817 }
12818 ;
12819 
12820 
12821  overlay_list:
12822  a_expr overlay_placing substr_from substr_for
12823  {
12824  $$ = cat_str(4,$1,$2,$3,$4);
12825 }
12826 |  a_expr overlay_placing substr_from
12827  {
12828  $$ = cat_str(3,$1,$2,$3);
12829 }
12830 ;
12831 
12832 
12833  overlay_placing:
12834  PLACING a_expr
12835  {
12836  $$ = cat_str(2,mm_strdup("placing"),$2);
12837 }
12838 ;
12839 
12840 
12841  position_list:
12842  b_expr IN_P b_expr
12843  {
12844  $$ = cat_str(3,$1,mm_strdup("in"),$3);
12845 }
12846 |
12847  {
12848  $$=EMPTY; }
12849 ;
12850 
12851 
12852  substr_list:
12853  a_expr substr_from substr_for
12854  {
12855  $$ = cat_str(3,$1,$2,$3);
12856 }
12857 |  a_expr substr_for substr_from
12858  {
12859  $$ = cat_str(3,$1,$2,$3);
12860 }
12861 |  a_expr substr_from
12862  {
12863  $$ = cat_str(2,$1,$2);
12864 }
12865 |  a_expr substr_for
12866  {
12867  $$ = cat_str(2,$1,$2);
12868 }
12869 |  expr_list
12870  {
12871  $$ = $1;
12872 }
12873 |
12874  {
12875  $$=EMPTY; }
12876 ;
12877 
12878 
12879  substr_from:
12880  FROM a_expr
12881  {
12882  $$ = cat_str(2,mm_strdup("from"),$2);
12883 }
12884 ;
12885 
12886 
12887  substr_for:
12888  FOR a_expr
12889  {
12890  $$ = cat_str(2,mm_strdup("for"),$2);
12891 }
12892 ;
12893 
12894 
12895  trim_list:
12896  a_expr FROM expr_list
12897  {
12898  $$ = cat_str(3,$1,mm_strdup("from"),$3);
12899 }
12900 |  FROM expr_list
12901  {
12902  $$ = cat_str(2,mm_strdup("from"),$2);
12903 }
12904 |  expr_list
12905  {
12906  $$ = $1;
12907 }
12908 ;
12909 
12910 
12911  in_expr:
12912  select_with_parens
12913  {
12914  $$ = $1;
12915 }
12916 |  '(' expr_list ')'
12917  {
12918  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
12919 }
12920 ;
12921 
12922 
12923  case_expr:
12924  CASE case_arg when_clause_list case_default END_P
12925  {
12926  $$ = cat_str(5,mm_strdup("case"),$2,$3,$4,mm_strdup("end"));
12927 }
12928 ;
12929 
12930 
12931  when_clause_list:
12932  when_clause
12933  {
12934  $$ = $1;
12935 }
12936 |  when_clause_list when_clause
12937  {
12938  $$ = cat_str(2,$1,$2);
12939 }
12940 ;
12941 
12942 
12943  when_clause:
12944  WHEN a_expr THEN a_expr
12945  {
12946  $$ = cat_str(4,mm_strdup("when"),$2,mm_strdup("then"),$4);
12947 }
12948 ;
12949 
12950 
12951  case_default:
12952  ELSE a_expr
12953  {
12954  $$ = cat_str(2,mm_strdup("else"),$2);
12955 }
12956 |
12957  {
12958  $$=EMPTY; }
12959 ;
12960 
12961 
12962  case_arg:
12963  a_expr
12964  {
12965  $$ = $1;
12966 }
12967 |
12968  {
12969  $$=EMPTY; }
12970 ;
12971 
12972 
12973  columnref:
12974  ColId
12975  {
12976  $$ = $1;
12977 }
12978 |  ColId indirection
12979  {
12980  $$ = cat_str(2,$1,$2);
12981 }
12982 ;
12983 
12984 
12985  indirection_el:
12986  '.' attr_name
12987  {
12988  $$ = cat_str(2,mm_strdup("."),$2);
12989 }
12990 |  '.' '*'
12991  {
12992  $$ = mm_strdup(". *");
12993 }
12994 |  '[' a_expr ']'
12995  {
12996  $$ = cat_str(3,mm_strdup("["),$2,mm_strdup("]"));
12997 }
12998 |  '[' opt_slice_bound ':' opt_slice_bound ']'
12999  {
13000  $$ = cat_str(5,mm_strdup("["),$2,mm_strdup(":"),$4,mm_strdup("]"));
13001 }
13002 ;
13003 
13004 
13005  opt_slice_bound:
13006  a_expr
13007  {
13008  $$ = $1;
13009 }
13010 |
13011  {
13012  $$=EMPTY; }
13013 ;
13014 
13015 
13016  indirection:
13017  indirection_el
13018  {
13019  $$ = $1;
13020 }
13021 |  indirection indirection_el
13022  {
13023  $$ = cat_str(2,$1,$2);
13024 }
13025 ;
13026 
13027 
13028  opt_indirection:
13029 
13030  {
13031  $$=EMPTY; }
13032 |  opt_indirection indirection_el
13033  {
13034  $$ = cat_str(2,$1,$2);
13035 }
13036 ;
13037 
13038 
13039  opt_asymmetric:
13040  ASYMMETRIC
13041  {
13042  $$ = mm_strdup("asymmetric");
13043 }
13044 |
13045  {
13046  $$=EMPTY; }
13047 ;
13048 
13049 
13050  opt_target_list:
13051  target_list
13052  {
13053  $$ = $1;
13054 }
13055 |
13056  {
13057  $$=EMPTY; }
13058 ;
13059 
13060 
13061  target_list:
13062  target_el
13063  {
13064  $$ = $1;
13065 }
13066 |  target_list ',' target_el
13067  {
13068  $$ = cat_str(3,$1,mm_strdup(","),$3);
13069 }
13070 ;
13071 
13072 
13073  target_el:
13074  a_expr AS ColLabel
13075  {
13076  $$ = cat_str(3,$1,mm_strdup("as"),$3);
13077 }
13078 |  a_expr ecpg_ident
13079  {
13080  $$ = cat_str(2,$1,$2);
13081 }
13082 |  a_expr
13083  {
13084  $$ = $1;
13085 }
13086 |  '*'
13087  {
13088  $$ = mm_strdup("*");
13089 }
13090 ;
13091 
13092 
13093  qualified_name_list:
13094  qualified_name
13095  {
13096  $$ = $1;
13097 }
13098 |  qualified_name_list ',' qualified_name
13099  {
13100  $$ = cat_str(3,$1,mm_strdup(","),$3);
13101 }
13102 ;
13103 
13104 
13105  qualified_name:
13106  ColId
13107  {
13108  $$ = $1;
13109 }
13110 |  ColId indirection
13111  {
13112  $$ = cat_str(2,$1,$2);
13113 }
13114 ;
13115 
13116 
13117  name_list:
13118  name
13119  {
13120  $$ = $1;
13121 }
13122 |  name_list ',' name
13123  {
13124  $$ = cat_str(3,$1,mm_strdup(","),$3);
13125 }
13126 ;
13127 
13128 
13129  name:
13130  ColId
13131  {
13132  $$ = $1;
13133 }
13134 ;
13135 
13136 
13137  database_name:
13138  ColId
13139  {
13140  $$ = $1;
13141 }
13142 ;
13143 
13144 
13145  access_method:
13146  ColId
13147  {
13148  $$ = $1;
13149 }
13150 ;
13151 
13152 
13153  attr_name:
13154  ColLabel
13155  {
13156  $$ = $1;
13157 }
13158 ;
13159 
13160 
13161  index_name:
13162  ColId
13163  {
13164  $$ = $1;
13165 }
13166 ;
13167 
13168 
13169  file_name:
13170  ecpg_sconst
13171  {
13172  $$ = $1;
13173 }
13174 ;
13175 
13176 
13177  func_name:
13178  type_function_name
13179  {
13180  $$ = $1;
13181 }
13182 |  ColId indirection
13183  {
13184  $$ = cat_str(2,$1,$2);
13185 }
13186 ;
13187 
13188 
13189  AexprConst:
13190  Iconst
13191  {
13192  $$ = $1;
13193 }
13194 |  ecpg_fconst
13195  {
13196  $$ = $1;
13197 }
13198 |  ecpg_sconst
13199  {
13200  $$ = $1;
13201 }
13202 |  ecpg_bconst
13203  {
13204  $$ = $1;
13205 }
13206 |  XCONST
13207  {
13208  $$ = mm_strdup("xconst");
13209 }
13210 |  func_name ecpg_sconst
13211  {
13212  $$ = cat_str(2,$1,$2);
13213 }
13214 |  func_name '(' func_arg_list opt_sort_clause ')' ecpg_sconst
13215  {
13216  $$ = cat_str(6,$1,mm_strdup("("),$3,$4,mm_strdup(")"),$6);
13217 }
13218 |  ConstTypename ecpg_sconst
13219  {
13220  $$ = cat_str(2,$1,$2);
13221 }
13222 |  ConstInterval ecpg_sconst opt_interval
13223  {
13224  $$ = cat_str(3,$1,$2,$3);
13225 }
13226 |  ConstInterval '(' Iconst ')' ecpg_sconst
13227  {
13228  $$ = cat_str(5,$1,mm_strdup("("),$3,mm_strdup(")"),$5);
13229 }
13230 |  TRUE_P
13231  {
13232  $$ = mm_strdup("true");
13233 }
13234 |  FALSE_P
13235  {
13236  $$ = mm_strdup("false");
13237 }
13238 |  NULL_P
13239  {
13240  $$ = mm_strdup("null");
13241 }
13242 	| civar			{ $$ = $1; }
13243 	| civarind		{ $$ = $1; }
13244 ;
13245 
13246 
13247  Iconst:
13248  ICONST
13249 	{ $$ = make_name(); }
13250 ;
13251 
13252 
13253  SignedIconst:
13254  Iconst
13255  {
13256  $$ = $1;
13257 }
13258 	| civar	{ $$ = $1; }
13259 |  '+' Iconst
13260  {
13261  $$ = cat_str(2,mm_strdup("+"),$2);
13262 }
13263 |  '-' Iconst
13264  {
13265  $$ = cat_str(2,mm_strdup("-"),$2);
13266 }
13267 ;
13268 
13269 
13270  RoleId:
13271  RoleSpec
13272  {
13273  $$ = $1;
13274 }
13275 ;
13276 
13277 
13278  RoleSpec:
13279  NonReservedWord
13280  {
13281  $$ = $1;
13282 }
13283 |  CURRENT_USER
13284  {
13285  $$ = mm_strdup("current_user");
13286 }
13287 |  SESSION_USER
13288  {
13289  $$ = mm_strdup("session_user");
13290 }
13291 ;
13292 
13293 
13294  role_list:
13295  RoleSpec
13296  {
13297  $$ = $1;
13298 }
13299 |  role_list ',' RoleSpec
13300  {
13301  $$ = cat_str(3,$1,mm_strdup(","),$3);
13302 }
13303 ;
13304 
13305 
13306  NonReservedWord:
13307  ecpg_ident
13308  {
13309  $$ = $1;
13310 }
13311 |  unreserved_keyword
13312  {
13313  $$ = $1;
13314 }
13315 |  col_name_keyword
13316  {
13317  $$ = $1;
13318 }
13319 |  type_func_name_keyword
13320  {
13321  $$ = $1;
13322 }
13323 ;
13324 
13325 
13326  unreserved_keyword:
13327  ABORT_P
13328  {
13329  $$ = mm_strdup("abort");
13330 }
13331 |  ABSOLUTE_P
13332  {
13333  $$ = mm_strdup("absolute");
13334 }
13335 |  ACCESS
13336  {
13337  $$ = mm_strdup("access");
13338 }
13339 |  ACTION
13340  {
13341  $$ = mm_strdup("action");
13342 }
13343 |  ADD_P
13344  {
13345  $$ = mm_strdup("add");
13346 }
13347 |  ADMIN
13348  {
13349  $$ = mm_strdup("admin");
13350 }
13351 |  AFTER
13352  {
13353  $$ = mm_strdup("after");
13354 }
13355 |  AGGREGATE
13356  {
13357  $$ = mm_strdup("aggregate");
13358 }
13359 |  ALSO
13360  {
13361  $$ = mm_strdup("also");
13362 }
13363 |  ALTER
13364  {
13365  $$ = mm_strdup("alter");
13366 }
13367 |  ALWAYS
13368  {
13369  $$ = mm_strdup("always");
13370 }
13371 |  ASSERTION
13372  {
13373  $$ = mm_strdup("assertion");
13374 }
13375 |  ASSIGNMENT
13376  {
13377  $$ = mm_strdup("assignment");
13378 }
13379 |  AT
13380  {
13381  $$ = mm_strdup("at");
13382 }
13383 |  ATTACH
13384  {
13385  $$ = mm_strdup("attach");
13386 }
13387 |  ATTRIBUTE
13388  {
13389  $$ = mm_strdup("attribute");
13390 }
13391 |  BACKWARD
13392  {
13393  $$ = mm_strdup("backward");
13394 }
13395 |  BEFORE
13396  {
13397  $$ = mm_strdup("before");
13398 }
13399 |  BEGIN_P
13400  {
13401  $$ = mm_strdup("begin");
13402 }
13403 |  BY
13404  {
13405  $$ = mm_strdup("by");
13406 }
13407 |  CACHE
13408  {
13409  $$ = mm_strdup("cache");
13410 }
13411 |  CALL
13412  {
13413  $$ = mm_strdup("call");
13414 }
13415 |  CALLED
13416  {
13417  $$ = mm_strdup("called");
13418 }
13419 |  CASCADE
13420  {
13421  $$ = mm_strdup("cascade");
13422 }
13423 |  CASCADED
13424  {
13425  $$ = mm_strdup("cascaded");
13426 }
13427 |  CATALOG_P
13428  {
13429  $$ = mm_strdup("catalog");
13430 }
13431 |  CHAIN
13432  {
13433  $$ = mm_strdup("chain");
13434 }
13435 |  CHARACTERISTICS
13436  {
13437  $$ = mm_strdup("characteristics");
13438 }
13439 |  CHECKPOINT
13440  {
13441  $$ = mm_strdup("checkpoint");
13442 }
13443 |  CLASS
13444  {
13445  $$ = mm_strdup("class");
13446 }
13447 |  CLOSE
13448  {
13449  $$ = mm_strdup("close");
13450 }
13451 |  CLUSTER
13452  {
13453  $$ = mm_strdup("cluster");
13454 }
13455 |  COLUMNS
13456  {
13457  $$ = mm_strdup("columns");
13458 }
13459 |  COMMENT
13460  {
13461  $$ = mm_strdup("comment");
13462 }
13463 |  COMMENTS
13464  {
13465  $$ = mm_strdup("comments");
13466 }
13467 |  COMMIT
13468  {
13469  $$ = mm_strdup("commit");
13470 }
13471 |  COMMITTED
13472  {
13473  $$ = mm_strdup("committed");
13474 }
13475 |  CONFIGURATION
13476  {
13477  $$ = mm_strdup("configuration");
13478 }
13479 |  CONFLICT
13480  {
13481  $$ = mm_strdup("conflict");
13482 }
13483 |  CONSTRAINTS
13484  {
13485  $$ = mm_strdup("constraints");
13486 }
13487 |  CONTENT_P
13488  {
13489  $$ = mm_strdup("content");
13490 }
13491 |  CONTINUE_P
13492  {
13493  $$ = mm_strdup("continue");
13494 }
13495 |  CONVERSION_P
13496  {
13497  $$ = mm_strdup("conversion");
13498 }
13499 |  COPY
13500  {
13501  $$ = mm_strdup("copy");
13502 }
13503 |  COST
13504  {
13505  $$ = mm_strdup("cost");
13506 }
13507 |  CSV
13508  {
13509  $$ = mm_strdup("csv");
13510 }
13511 |  CUBE
13512  {
13513  $$ = mm_strdup("cube");
13514 }
13515 |  CURSOR
13516  {
13517  $$ = mm_strdup("cursor");
13518 }
13519 |  CYCLE
13520  {
13521  $$ = mm_strdup("cycle");
13522 }
13523 |  DATA_P
13524  {
13525  $$ = mm_strdup("data");
13526 }
13527 |  DATABASE
13528  {
13529  $$ = mm_strdup("database");
13530 }
13531 |  DEALLOCATE
13532  {
13533  $$ = mm_strdup("deallocate");
13534 }
13535 |  DECLARE
13536  {
13537  $$ = mm_strdup("declare");
13538 }
13539 |  DEFAULTS
13540  {
13541  $$ = mm_strdup("defaults");
13542 }
13543 |  DEFERRED
13544  {
13545  $$ = mm_strdup("deferred");
13546 }
13547 |  DEFINER
13548  {
13549  $$ = mm_strdup("definer");
13550 }
13551 |  DELETE_P
13552  {
13553  $$ = mm_strdup("delete");
13554 }
13555 |  DELIMITER
13556  {
13557  $$ = mm_strdup("delimiter");
13558 }
13559 |  DELIMITERS
13560  {
13561  $$ = mm_strdup("delimiters");
13562 }
13563 |  DEPENDS
13564  {
13565  $$ = mm_strdup("depends");
13566 }
13567 |  DETACH
13568  {
13569  $$ = mm_strdup("detach");
13570 }
13571 |  DICTIONARY
13572  {
13573  $$ = mm_strdup("dictionary");
13574 }
13575 |  DISABLE_P
13576  {
13577  $$ = mm_strdup("disable");
13578 }
13579 |  DISCARD
13580  {
13581  $$ = mm_strdup("discard");
13582 }
13583 |  DOCUMENT_P
13584  {
13585  $$ = mm_strdup("document");
13586 }
13587 |  DOMAIN_P
13588  {
13589  $$ = mm_strdup("domain");
13590 }
13591 |  DOUBLE_P
13592  {
13593  $$ = mm_strdup("double");
13594 }
13595 |  DROP
13596  {
13597  $$ = mm_strdup("drop");
13598 }
13599 |  EACH
13600  {
13601  $$ = mm_strdup("each");
13602 }
13603 |  ENABLE_P
13604  {
13605  $$ = mm_strdup("enable");
13606 }
13607 |  ENCODING
13608  {
13609  $$ = mm_strdup("encoding");
13610 }
13611 |  ENCRYPTED
13612  {
13613  $$ = mm_strdup("encrypted");
13614 }
13615 |  ENUM_P
13616  {
13617  $$ = mm_strdup("enum");
13618 }
13619 |  ESCAPE
13620  {
13621  $$ = mm_strdup("escape");
13622 }
13623 |  EVENT
13624  {
13625  $$ = mm_strdup("event");
13626 }
13627 |  EXCLUDE
13628  {
13629  $$ = mm_strdup("exclude");
13630 }
13631 |  EXCLUDING
13632  {
13633  $$ = mm_strdup("excluding");
13634 }
13635 |  EXCLUSIVE
13636  {
13637  $$ = mm_strdup("exclusive");
13638 }
13639 |  EXECUTE
13640  {
13641  $$ = mm_strdup("execute");
13642 }
13643 |  EXPLAIN
13644  {
13645  $$ = mm_strdup("explain");
13646 }
13647 |  EXTENSION
13648  {
13649  $$ = mm_strdup("extension");
13650 }
13651 |  EXTERNAL
13652  {
13653  $$ = mm_strdup("external");
13654 }
13655 |  FAMILY
13656  {
13657  $$ = mm_strdup("family");
13658 }
13659 |  FILTER
13660  {
13661  $$ = mm_strdup("filter");
13662 }
13663 |  FIRST_P
13664  {
13665  $$ = mm_strdup("first");
13666 }
13667 |  FOLLOWING
13668  {
13669  $$ = mm_strdup("following");
13670 }
13671 |  FORCE
13672  {
13673  $$ = mm_strdup("force");
13674 }
13675 |  FORWARD
13676  {
13677  $$ = mm_strdup("forward");
13678 }
13679 |  FUNCTION
13680  {
13681  $$ = mm_strdup("function");
13682 }
13683 |  FUNCTIONS
13684  {
13685  $$ = mm_strdup("functions");
13686 }
13687 |  GENERATED
13688  {
13689  $$ = mm_strdup("generated");
13690 }
13691 |  GLOBAL
13692  {
13693  $$ = mm_strdup("global");
13694 }
13695 |  GRANTED
13696  {
13697  $$ = mm_strdup("granted");
13698 }
13699 |  GROUPS
13700  {
13701  $$ = mm_strdup("groups");
13702 }
13703 |  HANDLER
13704  {
13705  $$ = mm_strdup("handler");
13706 }
13707 |  HEADER_P
13708  {
13709  $$ = mm_strdup("header");
13710 }
13711 |  HOLD
13712  {
13713  $$ = mm_strdup("hold");
13714 }
13715 |  IDENTITY_P
13716  {
13717  $$ = mm_strdup("identity");
13718 }
13719 |  IF_P
13720  {
13721  $$ = mm_strdup("if");
13722 }
13723 |  IMMEDIATE
13724  {
13725  $$ = mm_strdup("immediate");
13726 }
13727 |  IMMUTABLE
13728  {
13729  $$ = mm_strdup("immutable");
13730 }
13731 |  IMPLICIT_P
13732  {
13733  $$ = mm_strdup("implicit");
13734 }
13735 |  IMPORT_P
13736  {
13737  $$ = mm_strdup("import");
13738 }
13739 |  INCLUDE
13740  {
13741  $$ = mm_strdup("include");
13742 }
13743 |  INCLUDING
13744  {
13745  $$ = mm_strdup("including");
13746 }
13747 |  INCREMENT
13748  {
13749  $$ = mm_strdup("increment");
13750 }
13751 |  INDEX
13752  {
13753  $$ = mm_strdup("index");
13754 }
13755 |  INDEXES
13756  {
13757  $$ = mm_strdup("indexes");
13758 }
13759 |  INHERIT
13760  {
13761  $$ = mm_strdup("inherit");
13762 }
13763 |  INHERITS
13764  {
13765  $$ = mm_strdup("inherits");
13766 }
13767 |  INLINE_P
13768  {
13769  $$ = mm_strdup("inline");
13770 }
13771 |  INSENSITIVE
13772  {
13773  $$ = mm_strdup("insensitive");
13774 }
13775 |  INSERT
13776  {
13777  $$ = mm_strdup("insert");
13778 }
13779 |  INSTEAD
13780  {
13781  $$ = mm_strdup("instead");
13782 }
13783 |  INVOKER
13784  {
13785  $$ = mm_strdup("invoker");
13786 }
13787 |  ISOLATION
13788  {
13789  $$ = mm_strdup("isolation");
13790 }
13791 |  KEY
13792  {
13793  $$ = mm_strdup("key");
13794 }
13795 |  LABEL
13796  {
13797  $$ = mm_strdup("label");
13798 }
13799 |  LANGUAGE
13800  {
13801  $$ = mm_strdup("language");
13802 }
13803 |  LARGE_P
13804  {
13805  $$ = mm_strdup("large");
13806 }
13807 |  LAST_P
13808  {
13809  $$ = mm_strdup("last");
13810 }
13811 |  LEAKPROOF
13812  {
13813  $$ = mm_strdup("leakproof");
13814 }
13815 |  LEVEL
13816  {
13817  $$ = mm_strdup("level");
13818 }
13819 |  LISTEN
13820  {
13821  $$ = mm_strdup("listen");
13822 }
13823 |  LOAD
13824  {
13825  $$ = mm_strdup("load");
13826 }
13827 |  LOCAL
13828  {
13829  $$ = mm_strdup("local");
13830 }
13831 |  LOCATION
13832  {
13833  $$ = mm_strdup("location");
13834 }
13835 |  LOCK_P
13836  {
13837  $$ = mm_strdup("lock");
13838 }
13839 |  LOCKED
13840  {
13841  $$ = mm_strdup("locked");
13842 }
13843 |  LOGGED
13844  {
13845  $$ = mm_strdup("logged");
13846 }
13847 |  MAPPING
13848  {
13849  $$ = mm_strdup("mapping");
13850 }
13851 |  MATCH
13852  {
13853  $$ = mm_strdup("match");
13854 }
13855 |  MATERIALIZED
13856  {
13857  $$ = mm_strdup("materialized");
13858 }
13859 |  MAXVALUE
13860  {
13861  $$ = mm_strdup("maxvalue");
13862 }
13863 |  METHOD
13864  {
13865  $$ = mm_strdup("method");
13866 }
13867 |  MINVALUE
13868  {
13869  $$ = mm_strdup("minvalue");
13870 }
13871 |  MODE
13872  {
13873  $$ = mm_strdup("mode");
13874 }
13875 |  MOVE
13876  {
13877  $$ = mm_strdup("move");
13878 }
13879 |  NAME_P
13880  {
13881  $$ = mm_strdup("name");
13882 }
13883 |  NAMES
13884  {
13885  $$ = mm_strdup("names");
13886 }
13887 |  NEW
13888  {
13889  $$ = mm_strdup("new");
13890 }
13891 |  NEXT
13892  {
13893  $$ = mm_strdup("next");
13894 }
13895 |  NO
13896  {
13897  $$ = mm_strdup("no");
13898 }
13899 |  NOTHING
13900  {
13901  $$ = mm_strdup("nothing");
13902 }
13903 |  NOTIFY
13904  {
13905  $$ = mm_strdup("notify");
13906 }
13907 |  NOWAIT
13908  {
13909  $$ = mm_strdup("nowait");
13910 }
13911 |  NULLS_P
13912  {
13913  $$ = mm_strdup("nulls");
13914 }
13915 |  OBJECT_P
13916  {
13917  $$ = mm_strdup("object");
13918 }
13919 |  OF
13920  {
13921  $$ = mm_strdup("of");
13922 }
13923 |  OFF
13924  {
13925  $$ = mm_strdup("off");
13926 }
13927 |  OIDS
13928  {
13929  $$ = mm_strdup("oids");
13930 }
13931 |  OLD
13932  {
13933  $$ = mm_strdup("old");
13934 }
13935 |  OPERATOR
13936  {
13937  $$ = mm_strdup("operator");
13938 }
13939 |  OPTION
13940  {
13941  $$ = mm_strdup("option");
13942 }
13943 |  OPTIONS
13944  {
13945  $$ = mm_strdup("options");
13946 }
13947 |  ORDINALITY
13948  {
13949  $$ = mm_strdup("ordinality");
13950 }
13951 |  OTHERS
13952  {
13953  $$ = mm_strdup("others");
13954 }
13955 |  OVER
13956  {
13957  $$ = mm_strdup("over");
13958 }
13959 |  OVERRIDING
13960  {
13961  $$ = mm_strdup("overriding");
13962 }
13963 |  OWNED
13964  {
13965  $$ = mm_strdup("owned");
13966 }
13967 |  OWNER
13968  {
13969  $$ = mm_strdup("owner");
13970 }
13971 |  PARALLEL
13972  {
13973  $$ = mm_strdup("parallel");
13974 }
13975 |  PARSER
13976  {
13977  $$ = mm_strdup("parser");
13978 }
13979 |  PARTIAL
13980  {
13981  $$ = mm_strdup("partial");
13982 }
13983 |  PARTITION
13984  {
13985  $$ = mm_strdup("partition");
13986 }
13987 |  PASSING
13988  {
13989  $$ = mm_strdup("passing");
13990 }
13991 |  PASSWORD
13992  {
13993  $$ = mm_strdup("password");
13994 }
13995 |  PLANS
13996  {
13997  $$ = mm_strdup("plans");
13998 }
13999 |  POLICY
14000  {
14001  $$ = mm_strdup("policy");
14002 }
14003 |  PRECEDING
14004  {
14005  $$ = mm_strdup("preceding");
14006 }
14007 |  PREPARE
14008  {
14009  $$ = mm_strdup("prepare");
14010 }
14011 |  PREPARED
14012  {
14013  $$ = mm_strdup("prepared");
14014 }
14015 |  PRESERVE
14016  {
14017  $$ = mm_strdup("preserve");
14018 }
14019 |  PRIOR
14020  {
14021  $$ = mm_strdup("prior");
14022 }
14023 |  PRIVILEGES
14024  {
14025  $$ = mm_strdup("privileges");
14026 }
14027 |  PROCEDURAL
14028  {
14029  $$ = mm_strdup("procedural");
14030 }
14031 |  PROCEDURE
14032  {
14033  $$ = mm_strdup("procedure");
14034 }
14035 |  PROCEDURES
14036  {
14037  $$ = mm_strdup("procedures");
14038 }
14039 |  PROGRAM
14040  {
14041  $$ = mm_strdup("program");
14042 }
14043 |  PUBLICATION
14044  {
14045  $$ = mm_strdup("publication");
14046 }
14047 |  QUOTE
14048  {
14049  $$ = mm_strdup("quote");
14050 }
14051 |  RANGE
14052  {
14053  $$ = mm_strdup("range");
14054 }
14055 |  READ
14056  {
14057  $$ = mm_strdup("read");
14058 }
14059 |  REASSIGN
14060  {
14061  $$ = mm_strdup("reassign");
14062 }
14063 |  RECHECK
14064  {
14065  $$ = mm_strdup("recheck");
14066 }
14067 |  RECURSIVE
14068  {
14069  $$ = mm_strdup("recursive");
14070 }
14071 |  REF
14072  {
14073  $$ = mm_strdup("ref");
14074 }
14075 |  REFERENCING
14076  {
14077  $$ = mm_strdup("referencing");
14078 }
14079 |  REFRESH
14080  {
14081  $$ = mm_strdup("refresh");
14082 }
14083 |  REINDEX
14084  {
14085  $$ = mm_strdup("reindex");
14086 }
14087 |  RELATIVE_P
14088  {
14089  $$ = mm_strdup("relative");
14090 }
14091 |  RELEASE
14092  {
14093  $$ = mm_strdup("release");
14094 }
14095 |  RENAME
14096  {
14097  $$ = mm_strdup("rename");
14098 }
14099 |  REPEATABLE
14100  {
14101  $$ = mm_strdup("repeatable");
14102 }
14103 |  REPLACE
14104  {
14105  $$ = mm_strdup("replace");
14106 }
14107 |  REPLICA
14108  {
14109  $$ = mm_strdup("replica");
14110 }
14111 |  RESET
14112  {
14113  $$ = mm_strdup("reset");
14114 }
14115 |  RESTART
14116  {
14117  $$ = mm_strdup("restart");
14118 }
14119 |  RESTRICT
14120  {
14121  $$ = mm_strdup("restrict");
14122 }
14123 |  RETURNS
14124  {
14125  $$ = mm_strdup("returns");
14126 }
14127 |  REVOKE
14128  {
14129  $$ = mm_strdup("revoke");
14130 }
14131 |  ROLE
14132  {
14133  $$ = mm_strdup("role");
14134 }
14135 |  ROLLBACK
14136  {
14137  $$ = mm_strdup("rollback");
14138 }
14139 |  ROLLUP
14140  {
14141  $$ = mm_strdup("rollup");
14142 }
14143 |  ROUTINE
14144  {
14145  $$ = mm_strdup("routine");
14146 }
14147 |  ROUTINES
14148  {
14149  $$ = mm_strdup("routines");
14150 }
14151 |  ROWS
14152  {
14153  $$ = mm_strdup("rows");
14154 }
14155 |  RULE
14156  {
14157  $$ = mm_strdup("rule");
14158 }
14159 |  SAVEPOINT
14160  {
14161  $$ = mm_strdup("savepoint");
14162 }
14163 |  SCHEMA
14164  {
14165  $$ = mm_strdup("schema");
14166 }
14167 |  SCHEMAS
14168  {
14169  $$ = mm_strdup("schemas");
14170 }
14171 |  SCROLL
14172  {
14173  $$ = mm_strdup("scroll");
14174 }
14175 |  SEARCH
14176  {
14177  $$ = mm_strdup("search");
14178 }
14179 |  SECURITY
14180  {
14181  $$ = mm_strdup("security");
14182 }
14183 |  SEQUENCE
14184  {
14185  $$ = mm_strdup("sequence");
14186 }
14187 |  SEQUENCES
14188  {
14189  $$ = mm_strdup("sequences");
14190 }
14191 |  SERIALIZABLE
14192  {
14193  $$ = mm_strdup("serializable");
14194 }
14195 |  SERVER
14196  {
14197  $$ = mm_strdup("server");
14198 }
14199 |  SESSION
14200  {
14201  $$ = mm_strdup("session");
14202 }
14203 |  SET
14204  {
14205  $$ = mm_strdup("set");
14206 }
14207 |  SETS
14208  {
14209  $$ = mm_strdup("sets");
14210 }
14211 |  SHARE
14212  {
14213  $$ = mm_strdup("share");
14214 }
14215 |  SHOW
14216  {
14217  $$ = mm_strdup("show");
14218 }
14219 |  SIMPLE
14220  {
14221  $$ = mm_strdup("simple");
14222 }
14223 |  SKIP
14224  {
14225  $$ = mm_strdup("skip");
14226 }
14227 |  SNAPSHOT
14228  {
14229  $$ = mm_strdup("snapshot");
14230 }
14231 |  SQL_P
14232  {
14233  $$ = mm_strdup("sql");
14234 }
14235 |  STABLE
14236  {
14237  $$ = mm_strdup("stable");
14238 }
14239 |  STANDALONE_P
14240  {
14241  $$ = mm_strdup("standalone");
14242 }
14243 |  START
14244  {
14245  $$ = mm_strdup("start");
14246 }
14247 |  STATEMENT
14248  {
14249  $$ = mm_strdup("statement");
14250 }
14251 |  STATISTICS
14252  {
14253  $$ = mm_strdup("statistics");
14254 }
14255 |  STDIN
14256  {
14257  $$ = mm_strdup("stdin");
14258 }
14259 |  STDOUT
14260  {
14261  $$ = mm_strdup("stdout");
14262 }
14263 |  STORAGE
14264  {
14265  $$ = mm_strdup("storage");
14266 }
14267 |  STRICT_P
14268  {
14269  $$ = mm_strdup("strict");
14270 }
14271 |  STRIP_P
14272  {
14273  $$ = mm_strdup("strip");
14274 }
14275 |  SUBSCRIPTION
14276  {
14277  $$ = mm_strdup("subscription");
14278 }
14279 |  SYSID
14280  {
14281  $$ = mm_strdup("sysid");
14282 }
14283 |  SYSTEM_P
14284  {
14285  $$ = mm_strdup("system");
14286 }
14287 |  TABLES
14288  {
14289  $$ = mm_strdup("tables");
14290 }
14291 |  TABLESPACE
14292  {
14293  $$ = mm_strdup("tablespace");
14294 }
14295 |  TEMP
14296  {
14297  $$ = mm_strdup("temp");
14298 }
14299 |  TEMPLATE
14300  {
14301  $$ = mm_strdup("template");
14302 }
14303 |  TEMPORARY
14304  {
14305  $$ = mm_strdup("temporary");
14306 }
14307 |  TEXT_P
14308  {
14309  $$ = mm_strdup("text");
14310 }
14311 |  TIES
14312  {
14313  $$ = mm_strdup("ties");
14314 }
14315 |  TRANSACTION
14316  {
14317  $$ = mm_strdup("transaction");
14318 }
14319 |  TRANSFORM
14320  {
14321  $$ = mm_strdup("transform");
14322 }
14323 |  TRIGGER
14324  {
14325  $$ = mm_strdup("trigger");
14326 }
14327 |  TRUNCATE
14328  {
14329  $$ = mm_strdup("truncate");
14330 }
14331 |  TRUSTED
14332  {
14333  $$ = mm_strdup("trusted");
14334 }
14335 |  TYPE_P
14336  {
14337  $$ = mm_strdup("type");
14338 }
14339 |  TYPES_P
14340  {
14341  $$ = mm_strdup("types");
14342 }
14343 |  UNBOUNDED
14344  {
14345  $$ = mm_strdup("unbounded");
14346 }
14347 |  UNCOMMITTED
14348  {
14349  $$ = mm_strdup("uncommitted");
14350 }
14351 |  UNENCRYPTED
14352  {
14353  $$ = mm_strdup("unencrypted");
14354 }
14355 |  UNKNOWN
14356  {
14357  $$ = mm_strdup("unknown");
14358 }
14359 |  UNLISTEN
14360  {
14361  $$ = mm_strdup("unlisten");
14362 }
14363 |  UNLOGGED
14364  {
14365  $$ = mm_strdup("unlogged");
14366 }
14367 |  UNTIL
14368  {
14369  $$ = mm_strdup("until");
14370 }
14371 |  UPDATE
14372  {
14373  $$ = mm_strdup("update");
14374 }
14375 |  VACUUM
14376  {
14377  $$ = mm_strdup("vacuum");
14378 }
14379 |  VALID
14380  {
14381  $$ = mm_strdup("valid");
14382 }
14383 |  VALIDATE
14384  {
14385  $$ = mm_strdup("validate");
14386 }
14387 |  VALIDATOR
14388  {
14389  $$ = mm_strdup("validator");
14390 }
14391 |  VALUE_P
14392  {
14393  $$ = mm_strdup("value");
14394 }
14395 |  VARYING
14396  {
14397  $$ = mm_strdup("varying");
14398 }
14399 |  VERSION_P
14400  {
14401  $$ = mm_strdup("version");
14402 }
14403 |  VIEW
14404  {
14405  $$ = mm_strdup("view");
14406 }
14407 |  VIEWS
14408  {
14409  $$ = mm_strdup("views");
14410 }
14411 |  VOLATILE
14412  {
14413  $$ = mm_strdup("volatile");
14414 }
14415 |  WHITESPACE_P
14416  {
14417  $$ = mm_strdup("whitespace");
14418 }
14419 |  WITHIN
14420  {
14421  $$ = mm_strdup("within");
14422 }
14423 |  WITHOUT
14424  {
14425  $$ = mm_strdup("without");
14426 }
14427 |  WORK
14428  {
14429  $$ = mm_strdup("work");
14430 }
14431 |  WRAPPER
14432  {
14433  $$ = mm_strdup("wrapper");
14434 }
14435 |  WRITE
14436  {
14437  $$ = mm_strdup("write");
14438 }
14439 |  XML_P
14440  {
14441  $$ = mm_strdup("xml");
14442 }
14443 |  YES_P
14444  {
14445  $$ = mm_strdup("yes");
14446 }
14447 |  ZONE
14448  {
14449  $$ = mm_strdup("zone");
14450 }
14451 ;
14452 
14453 
14454  col_name_keyword:
14455  BETWEEN
14456  {
14457  $$ = mm_strdup("between");
14458 }
14459 |  BIGINT
14460  {
14461  $$ = mm_strdup("bigint");
14462 }
14463 |  BIT
14464  {
14465  $$ = mm_strdup("bit");
14466 }
14467 |  BOOLEAN_P
14468  {
14469  $$ = mm_strdup("boolean");
14470 }
14471 |  CHARACTER
14472  {
14473  $$ = mm_strdup("character");
14474 }
14475 |  COALESCE
14476  {
14477  $$ = mm_strdup("coalesce");
14478 }
14479 |  DEC
14480  {
14481  $$ = mm_strdup("dec");
14482 }
14483 |  DECIMAL_P
14484  {
14485  $$ = mm_strdup("decimal");
14486 }
14487 |  EXISTS
14488  {
14489  $$ = mm_strdup("exists");
14490 }
14491 |  EXTRACT
14492  {
14493  $$ = mm_strdup("extract");
14494 }
14495 |  FLOAT_P
14496  {
14497  $$ = mm_strdup("float");
14498 }
14499 |  GREATEST
14500  {
14501  $$ = mm_strdup("greatest");
14502 }
14503 |  GROUPING
14504  {
14505  $$ = mm_strdup("grouping");
14506 }
14507 |  INOUT
14508  {
14509  $$ = mm_strdup("inout");
14510 }
14511 |  INTEGER
14512  {
14513  $$ = mm_strdup("integer");
14514 }
14515 |  INTERVAL
14516  {
14517  $$ = mm_strdup("interval");
14518 }
14519 |  LEAST
14520  {
14521  $$ = mm_strdup("least");
14522 }
14523 |  NATIONAL
14524  {
14525  $$ = mm_strdup("national");
14526 }
14527 |  NCHAR
14528  {
14529  $$ = mm_strdup("nchar");
14530 }
14531 |  NONE
14532  {
14533  $$ = mm_strdup("none");
14534 }
14535 |  NULLIF
14536  {
14537  $$ = mm_strdup("nullif");
14538 }
14539 |  NUMERIC
14540  {
14541  $$ = mm_strdup("numeric");
14542 }
14543 |  OUT_P
14544  {
14545  $$ = mm_strdup("out");
14546 }
14547 |  OVERLAY
14548  {
14549  $$ = mm_strdup("overlay");
14550 }
14551 |  POSITION
14552  {
14553  $$ = mm_strdup("position");
14554 }
14555 |  PRECISION
14556  {
14557  $$ = mm_strdup("precision");
14558 }
14559 |  REAL
14560  {
14561  $$ = mm_strdup("real");
14562 }
14563 |  ROW
14564  {
14565  $$ = mm_strdup("row");
14566 }
14567 |  SETOF
14568  {
14569  $$ = mm_strdup("setof");
14570 }
14571 |  SMALLINT
14572  {
14573  $$ = mm_strdup("smallint");
14574 }
14575 |  SUBSTRING
14576  {
14577  $$ = mm_strdup("substring");
14578 }
14579 |  TIME
14580  {
14581  $$ = mm_strdup("time");
14582 }
14583 |  TIMESTAMP
14584  {
14585  $$ = mm_strdup("timestamp");
14586 }
14587 |  TREAT
14588  {
14589  $$ = mm_strdup("treat");
14590 }
14591 |  TRIM
14592  {
14593  $$ = mm_strdup("trim");
14594 }
14595 |  VARCHAR
14596  {
14597  $$ = mm_strdup("varchar");
14598 }
14599 |  XMLATTRIBUTES
14600  {
14601  $$ = mm_strdup("xmlattributes");
14602 }
14603 |  XMLCONCAT
14604  {
14605  $$ = mm_strdup("xmlconcat");
14606 }
14607 |  XMLELEMENT
14608  {
14609  $$ = mm_strdup("xmlelement");
14610 }
14611 |  XMLEXISTS
14612  {
14613  $$ = mm_strdup("xmlexists");
14614 }
14615 |  XMLFOREST
14616  {
14617  $$ = mm_strdup("xmlforest");
14618 }
14619 |  XMLNAMESPACES
14620  {
14621  $$ = mm_strdup("xmlnamespaces");
14622 }
14623 |  XMLPARSE
14624  {
14625  $$ = mm_strdup("xmlparse");
14626 }
14627 |  XMLPI
14628  {
14629  $$ = mm_strdup("xmlpi");
14630 }
14631 |  XMLROOT
14632  {
14633  $$ = mm_strdup("xmlroot");
14634 }
14635 |  XMLSERIALIZE
14636  {
14637  $$ = mm_strdup("xmlserialize");
14638 }
14639 |  XMLTABLE
14640  {
14641  $$ = mm_strdup("xmltable");
14642 }
14643 ;
14644 
14645 
14646  type_func_name_keyword:
14647  AUTHORIZATION
14648  {
14649  $$ = mm_strdup("authorization");
14650 }
14651 |  BINARY
14652  {
14653  $$ = mm_strdup("binary");
14654 }
14655 |  COLLATION
14656  {
14657  $$ = mm_strdup("collation");
14658 }
14659 |  CONCURRENTLY
14660  {
14661  $$ = mm_strdup("concurrently");
14662 }
14663 |  CROSS
14664  {
14665  $$ = mm_strdup("cross");
14666 }
14667 |  CURRENT_SCHEMA
14668  {
14669  $$ = mm_strdup("current_schema");
14670 }
14671 |  FREEZE
14672  {
14673  $$ = mm_strdup("freeze");
14674 }
14675 |  FULL
14676  {
14677  $$ = mm_strdup("full");
14678 }
14679 |  ILIKE
14680  {
14681  $$ = mm_strdup("ilike");
14682 }
14683 |  INNER_P
14684  {
14685  $$ = mm_strdup("inner");
14686 }
14687 |  IS
14688  {
14689  $$ = mm_strdup("is");
14690 }
14691 |  ISNULL
14692  {
14693  $$ = mm_strdup("isnull");
14694 }
14695 |  JOIN
14696  {
14697  $$ = mm_strdup("join");
14698 }
14699 |  LEFT
14700  {
14701  $$ = mm_strdup("left");
14702 }
14703 |  LIKE
14704  {
14705  $$ = mm_strdup("like");
14706 }
14707 |  NATURAL
14708  {
14709  $$ = mm_strdup("natural");
14710 }
14711 |  NOTNULL
14712  {
14713  $$ = mm_strdup("notnull");
14714 }
14715 |  OUTER_P
14716  {
14717  $$ = mm_strdup("outer");
14718 }
14719 |  OVERLAPS
14720  {
14721  $$ = mm_strdup("overlaps");
14722 }
14723 |  RIGHT
14724  {
14725  $$ = mm_strdup("right");
14726 }
14727 |  SIMILAR
14728  {
14729  $$ = mm_strdup("similar");
14730 }
14731 |  TABLESAMPLE
14732  {
14733  $$ = mm_strdup("tablesample");
14734 }
14735 |  VERBOSE
14736  {
14737  $$ = mm_strdup("verbose");
14738 }
14739 ;
14740 
14741 
14742  reserved_keyword:
14743  ALL
14744  {
14745  $$ = mm_strdup("all");
14746 }
14747 |  ANALYSE
14748  {
14749  $$ = mm_strdup("analyse");
14750 }
14751 |  ANALYZE
14752  {
14753  $$ = mm_strdup("analyze");
14754 }
14755 |  AND
14756  {
14757  $$ = mm_strdup("and");
14758 }
14759 |  ANY
14760  {
14761  $$ = mm_strdup("any");
14762 }
14763 |  ARRAY
14764  {
14765  $$ = mm_strdup("array");
14766 }
14767 |  AS
14768  {
14769  $$ = mm_strdup("as");
14770 }
14771 |  ASC
14772  {
14773  $$ = mm_strdup("asc");
14774 }
14775 |  ASYMMETRIC
14776  {
14777  $$ = mm_strdup("asymmetric");
14778 }
14779 |  BOTH
14780  {
14781  $$ = mm_strdup("both");
14782 }
14783 |  CASE
14784  {
14785  $$ = mm_strdup("case");
14786 }
14787 |  CAST
14788  {
14789  $$ = mm_strdup("cast");
14790 }
14791 |  CHECK
14792  {
14793  $$ = mm_strdup("check");
14794 }
14795 |  COLLATE
14796  {
14797  $$ = mm_strdup("collate");
14798 }
14799 |  COLUMN
14800  {
14801  $$ = mm_strdup("column");
14802 }
14803 |  CONSTRAINT
14804  {
14805  $$ = mm_strdup("constraint");
14806 }
14807 |  CREATE
14808  {
14809  $$ = mm_strdup("create");
14810 }
14811 |  CURRENT_CATALOG
14812  {
14813  $$ = mm_strdup("current_catalog");
14814 }
14815 |  CURRENT_DATE
14816  {
14817  $$ = mm_strdup("current_date");
14818 }
14819 |  CURRENT_ROLE
14820  {
14821  $$ = mm_strdup("current_role");
14822 }
14823 |  CURRENT_TIME
14824  {
14825  $$ = mm_strdup("current_time");
14826 }
14827 |  CURRENT_TIMESTAMP
14828  {
14829  $$ = mm_strdup("current_timestamp");
14830 }
14831 |  CURRENT_USER
14832  {
14833  $$ = mm_strdup("current_user");
14834 }
14835 |  DEFAULT
14836  {
14837  $$ = mm_strdup("default");
14838 }
14839 |  DEFERRABLE
14840  {
14841  $$ = mm_strdup("deferrable");
14842 }
14843 |  DESC
14844  {
14845  $$ = mm_strdup("desc");
14846 }
14847 |  DISTINCT
14848  {
14849  $$ = mm_strdup("distinct");
14850 }
14851 |  DO
14852  {
14853  $$ = mm_strdup("do");
14854 }
14855 |  ELSE
14856  {
14857  $$ = mm_strdup("else");
14858 }
14859 |  END_P
14860  {
14861  $$ = mm_strdup("end");
14862 }
14863 |  EXCEPT
14864  {
14865  $$ = mm_strdup("except");
14866 }
14867 |  FALSE_P
14868  {
14869  $$ = mm_strdup("false");
14870 }
14871 |  FETCH
14872  {
14873  $$ = mm_strdup("fetch");
14874 }
14875 |  FOR
14876  {
14877  $$ = mm_strdup("for");
14878 }
14879 |  FOREIGN
14880  {
14881  $$ = mm_strdup("foreign");
14882 }
14883 |  FROM
14884  {
14885  $$ = mm_strdup("from");
14886 }
14887 |  GRANT
14888  {
14889  $$ = mm_strdup("grant");
14890 }
14891 |  GROUP_P
14892  {
14893  $$ = mm_strdup("group");
14894 }
14895 |  HAVING
14896  {
14897  $$ = mm_strdup("having");
14898 }
14899 |  IN_P
14900  {
14901  $$ = mm_strdup("in");
14902 }
14903 |  INITIALLY
14904  {
14905  $$ = mm_strdup("initially");
14906 }
14907 |  INTERSECT
14908  {
14909  $$ = mm_strdup("intersect");
14910 }
14911 |  INTO
14912  {
14913  $$ = mm_strdup("into");
14914 }
14915 |  LATERAL_P
14916  {
14917  $$ = mm_strdup("lateral");
14918 }
14919 |  LEADING
14920  {
14921  $$ = mm_strdup("leading");
14922 }
14923 |  LIMIT
14924  {
14925  $$ = mm_strdup("limit");
14926 }
14927 |  LOCALTIME
14928  {
14929  $$ = mm_strdup("localtime");
14930 }
14931 |  LOCALTIMESTAMP
14932  {
14933  $$ = mm_strdup("localtimestamp");
14934 }
14935 |  NOT
14936  {
14937  $$ = mm_strdup("not");
14938 }
14939 |  NULL_P
14940  {
14941  $$ = mm_strdup("null");
14942 }
14943 |  OFFSET
14944  {
14945  $$ = mm_strdup("offset");
14946 }
14947 |  ON
14948  {
14949  $$ = mm_strdup("on");
14950 }
14951 |  ONLY
14952  {
14953  $$ = mm_strdup("only");
14954 }
14955 |  OR
14956  {
14957  $$ = mm_strdup("or");
14958 }
14959 |  ORDER
14960  {
14961  $$ = mm_strdup("order");
14962 }
14963 |  PLACING
14964  {
14965  $$ = mm_strdup("placing");
14966 }
14967 |  PRIMARY
14968  {
14969  $$ = mm_strdup("primary");
14970 }
14971 |  REFERENCES
14972  {
14973  $$ = mm_strdup("references");
14974 }
14975 |  RETURNING
14976  {
14977  $$ = mm_strdup("returning");
14978 }
14979 |  SELECT
14980  {
14981  $$ = mm_strdup("select");
14982 }
14983 |  SESSION_USER
14984  {
14985  $$ = mm_strdup("session_user");
14986 }
14987 |  SOME
14988  {
14989  $$ = mm_strdup("some");
14990 }
14991 |  SYMMETRIC
14992  {
14993  $$ = mm_strdup("symmetric");
14994 }
14995 |  TABLE
14996  {
14997  $$ = mm_strdup("table");
14998 }
14999 |  THEN
15000  {
15001  $$ = mm_strdup("then");
15002 }
15003 |  TRAILING
15004  {
15005  $$ = mm_strdup("trailing");
15006 }
15007 |  TRUE_P
15008  {
15009  $$ = mm_strdup("true");
15010 }
15011 |  UNIQUE
15012  {
15013  $$ = mm_strdup("unique");
15014 }
15015 |  USER
15016  {
15017  $$ = mm_strdup("user");
15018 }
15019 |  USING
15020  {
15021  $$ = mm_strdup("using");
15022 }
15023 |  VARIADIC
15024  {
15025  $$ = mm_strdup("variadic");
15026 }
15027 |  WHEN
15028  {
15029  $$ = mm_strdup("when");
15030 }
15031 |  WHERE
15032  {
15033  $$ = mm_strdup("where");
15034 }
15035 |  WINDOW
15036  {
15037  $$ = mm_strdup("window");
15038 }
15039 |  WITH
15040  {
15041  $$ = mm_strdup("with");
15042 }
15043 ;
15044 
15045 
15046 /* trailer */
15047 /* src/interfaces/ecpg/preproc/ecpg.trailer */
15048 
15049 statements: /*EMPTY*/
15050 				| statements statement
15051 		;
15052 
15053 statement: ecpgstart at stmt ';' { connection = NULL; }
15054 				| ecpgstart stmt ';'
15055 				| ecpgstart ECPGVarDeclaration
15056 				{
15057 					fprintf(base_yyout, "%s", $2);
15058 					free($2);
15059 					output_line_number();
15060 				}
15061 				| ECPGDeclaration
15062 				| c_thing               { fprintf(base_yyout, "%s", $1); free($1); }
15063 				| CPP_LINE              { fprintf(base_yyout, "%s", $1); free($1); }
15064 				| '{'                   { braces_open++; fputs("{", base_yyout); }
15065 				| '}'
15066 		{
15067 			remove_typedefs(braces_open);
15068 			remove_variables(braces_open--);
15069 			if (braces_open == 0)
15070 			{
15071 				free(current_function);
15072 				current_function = NULL;
15073 			}
15074 			fputs("}", base_yyout);
15075 		}
15076 		;
15077 
15078 CreateAsStmt: CREATE OptTemp TABLE create_as_target AS {FoundInto = 0;} SelectStmt opt_with_data
15079 		{
15080 			if (FoundInto == 1)
15081 				mmerror(PARSE_ERROR, ET_ERROR, "CREATE TABLE AS cannot specify INTO");
15082 
15083 			$$ = cat_str(7, mm_strdup("create"), $2, mm_strdup("table"), $4, mm_strdup("as"), $7, $8);
15084 		}
15085                 |  CREATE OptTemp TABLE IF_P NOT EXISTS create_as_target AS {FoundInto = 0;} SelectStmt opt_with_data
15086 		{
15087 			if (FoundInto == 1)
15088 				mmerror(PARSE_ERROR, ET_ERROR, "CREATE TABLE AS cannot specify INTO");
15089 
15090 			$$ = cat_str(7, mm_strdup("create"), $2, mm_strdup("table if not exists"), $7, mm_strdup("as"), $10, $11);
15091 		}
15092 		;
15093 
15094 at: AT connection_object
15095 		{
15096 			connection = $2;
15097 			/*
15098 			 * Do we have a variable as connection target?  Remove the variable
15099 			 * from the variable list or else it will be used twice.
15100 			 */
15101 			if (argsinsert != NULL)
15102 				argsinsert = NULL;
15103 		}
15104 		;
15105 
15106 /*
15107  * the exec sql connect statement: connect to the given database
15108  */
15109 ECPGConnect: SQL_CONNECT TO connection_target opt_connection_name opt_user
15110 			{ $$ = cat_str(5, $3, mm_strdup(","), $5, mm_strdup(","), $4); }
15111 		| SQL_CONNECT TO DEFAULT
15112 			{ $$ = mm_strdup("NULL, NULL, NULL, \"DEFAULT\""); }
15113 		  /* also allow ORACLE syntax */
15114 		| SQL_CONNECT ora_user
15115 			{ $$ = cat_str(3, mm_strdup("NULL,"), $2, mm_strdup(", NULL")); }
15116 		| DATABASE connection_target
15117 			{ $$ = cat2_str($2, mm_strdup(", NULL, NULL, NULL")); }
15118 		;
15119 
15120 connection_target: opt_database_name opt_server opt_port
15121 		{
15122 			/* old style: dbname[@server][:port] */
15123 			if (strlen($2) > 0 && *($2) != '@')
15124 				mmerror(PARSE_ERROR, ET_ERROR, "expected \"@\", found \"%s\"", $2);
15125 
15126 			/* C strings need to be handled differently */
15127 			if ($1[0] == '\"')
15128 				$$ = $1;
15129 			else
15130 				$$ = make3_str(mm_strdup("\""), make3_str($1, $2, $3), mm_strdup("\""));
15131 		}
15132 		|  db_prefix ':' server opt_port '/' opt_database_name opt_options
15133 		{
15134 			/* new style: <tcp|unix>:postgresql://server[:port][/dbname] */
15135 			if (strncmp($1, "unix:postgresql", strlen("unix:postgresql")) != 0 && strncmp($1, "tcp:postgresql", strlen("tcp:postgresql")) != 0)
15136 				mmerror(PARSE_ERROR, ET_ERROR, "only protocols \"tcp\" and \"unix\" and database type \"postgresql\" are supported");
15137 
15138 			if (strncmp($3, "//", strlen("//")) != 0)
15139 				mmerror(PARSE_ERROR, ET_ERROR, "expected \"://\", found \"%s\"", $3);
15140 
15141 			if (strncmp($1, "unix", strlen("unix")) == 0 &&
15142 				strncmp($3 + strlen("//"), "localhost", strlen("localhost")) != 0 &&
15143 				strncmp($3 + strlen("//"), "127.0.0.1", strlen("127.0.0.1")) != 0)
15144 				mmerror(PARSE_ERROR, ET_ERROR, "Unix-domain sockets only work on \"localhost\" but not on \"%s\"", $3 + strlen("//"));
15145 
15146 			$$ = make3_str(make3_str(mm_strdup("\""), $1, mm_strdup(":")), $3, make3_str(make3_str($4, mm_strdup("/"), $6), $7, mm_strdup("\"")));
15147 		}
15148 		| char_variable
15149 		{
15150 			$$ = $1;
15151 		}
15152 		| ecpg_sconst
15153 		{
15154 			/* We can only process double quoted strings not single quotes ones,
15155 			 * so we change the quotes.
15156 			 * Note, that the rule for ecpg_sconst adds these single quotes. */
15157 			$1[0] = '\"';
15158 			$1[strlen($1)-1] = '\"';
15159 			$$ = $1;
15160 		}
15161 		;
15162 
15163 opt_database_name: database_name		{ $$ = $1; }
15164 		| /*EMPTY*/			{ $$ = EMPTY; }
15165 		;
15166 
15167 db_prefix: ecpg_ident cvariable
15168 		{
15169 			if (strcmp($2, "postgresql") != 0 && strcmp($2, "postgres") != 0)
15170 				mmerror(PARSE_ERROR, ET_ERROR, "expected \"postgresql\", found \"%s\"", $2);
15171 
15172 			if (strcmp($1, "tcp") != 0 && strcmp($1, "unix") != 0)
15173 				mmerror(PARSE_ERROR, ET_ERROR, "invalid connection type: %s", $1);
15174 
15175 			$$ = make3_str($1, mm_strdup(":"), $2);
15176 		}
15177 		;
15178 
15179 server: Op server_name
15180 		{
15181 			if (strcmp($1, "@") != 0 && strcmp($1, "//") != 0)
15182 				mmerror(PARSE_ERROR, ET_ERROR, "expected \"@\" or \"://\", found \"%s\"", $1);
15183 
15184 			$$ = make2_str($1, $2);
15185 		}
15186 		;
15187 
15188 opt_server: server			{ $$ = $1; }
15189 		| /*EMPTY*/			{ $$ = EMPTY; }
15190 		;
15191 
15192 server_name: ColId					{ $$ = $1; }
15193 		| ColId '.' server_name		{ $$ = make3_str($1, mm_strdup("."), $3); }
15194 		| IP						{ $$ = make_name(); }
15195 		;
15196 
15197 opt_port: ':' Iconst		{ $$ = make2_str(mm_strdup(":"), $2); }
15198 		| /*EMPTY*/	{ $$ = EMPTY; }
15199 		;
15200 
15201 opt_connection_name: AS connection_object	{ $$ = $2; }
15202 		| /*EMPTY*/			{ $$ = mm_strdup("NULL"); }
15203 		;
15204 
15205 opt_user: USER ora_user		{ $$ = $2; }
15206 		| /*EMPTY*/			{ $$ = mm_strdup("NULL, NULL"); }
15207 		;
15208 
15209 ora_user: user_name
15210 			{ $$ = cat2_str($1, mm_strdup(", NULL")); }
15211 		| user_name '/' user_name
15212 			{ $$ = cat_str(3, $1, mm_strdup(","), $3); }
15213 		| user_name SQL_IDENTIFIED BY user_name
15214 			{ $$ = cat_str(3, $1, mm_strdup(","), $4); }
15215 		| user_name USING user_name
15216 			{ $$ = cat_str(3, $1, mm_strdup(","), $3); }
15217 		;
15218 
15219 user_name: RoleId
15220 		{
15221 			if ($1[0] == '\"')
15222 				$$ = $1;
15223 			else
15224 				$$ = make3_str(mm_strdup("\""), $1, mm_strdup("\""));
15225 		}
15226 		| ecpg_sconst
15227 		{
15228 			if ($1[0] == '\"')
15229 				$$ = $1;
15230 			else
15231 				$$ = make3_str(mm_strdup("\""), $1, mm_strdup("\""));
15232 		}
15233 		| civar
15234 		{
15235 			enum ECPGttype type = argsinsert->variable->type->type;
15236 
15237 			/* if array see what's inside */
15238 			if (type == ECPGt_array)
15239 				type = argsinsert->variable->type->u.element->type;
15240 
15241 			/* handle varchars */
15242 			if (type == ECPGt_varchar)
15243 				$$ = make2_str(mm_strdup(argsinsert->variable->name), mm_strdup(".arr"));
15244 			else
15245 				$$ = mm_strdup(argsinsert->variable->name);
15246 		}
15247 		;
15248 
15249 char_variable: cvariable
15250 		{
15251 			/* check if we have a string variable */
15252 			struct variable *p = find_variable($1);
15253 			enum ECPGttype type = p->type->type;
15254 
15255 			/* If we have just one character this is not a string */
15256 			if (atol(p->type->size) == 1)
15257 					mmerror(PARSE_ERROR, ET_ERROR, "invalid data type");
15258 			else
15259 			{
15260 				/* if array see what's inside */
15261 				if (type == ECPGt_array)
15262 					type = p->type->u.element->type;
15263 
15264 				switch (type)
15265 				{
15266 					case ECPGt_char:
15267 					case ECPGt_unsigned_char:
15268 					case ECPGt_string:
15269 						$$ = $1;
15270 						break;
15271 					case ECPGt_varchar:
15272 						$$ = make2_str($1, mm_strdup(".arr"));
15273 						break;
15274 					default:
15275 						mmerror(PARSE_ERROR, ET_ERROR, "invalid data type");
15276 						$$ = $1;
15277 						break;
15278 				}
15279 			}
15280 		}
15281 		;
15282 
15283 opt_options: Op connect_options
15284 		{
15285 			if (strlen($1) == 0)
15286 				mmerror(PARSE_ERROR, ET_ERROR, "incomplete statement");
15287 
15288 			if (strcmp($1, "?") != 0)
15289 				mmerror(PARSE_ERROR, ET_ERROR, "unrecognized token \"%s\"", $1);
15290 
15291 			$$ = make2_str(mm_strdup("?"), $2);
15292 		}
15293 		| /*EMPTY*/	{ $$ = EMPTY; }
15294 		;
15295 
15296 connect_options:  ColId opt_opt_value
15297 			{
15298 				$$ = make2_str($1, $2);
15299 			}
15300 		| ColId opt_opt_value Op connect_options
15301 			{
15302 				if (strlen($3) == 0)
15303 					mmerror(PARSE_ERROR, ET_ERROR, "incomplete statement");
15304 
15305 				if (strcmp($3, "&") != 0)
15306 					mmerror(PARSE_ERROR, ET_ERROR, "unrecognized token \"%s\"", $3);
15307 
15308 				$$ = cat_str(3, make2_str($1, $2), $3, $4);
15309 			}
15310 		;
15311 
15312 opt_opt_value: /*EMPTY*/
15313 			{ $$ = EMPTY; }
15314 		| '=' Iconst
15315 			{ $$ = make2_str(mm_strdup("="), $2); }
15316 		| '=' ecpg_ident
15317 			{ $$ = make2_str(mm_strdup("="), $2); }
15318 		| '=' civar
15319 			{ $$ = make2_str(mm_strdup("="), $2); }
15320 		;
15321 
15322 prepared_name: name
15323 		{
15324 			if ($1[0] == '\"' && $1[strlen($1)-1] == '\"') /* already quoted? */
15325 				$$ = $1;
15326 			else /* not quoted => convert to lowercase */
15327 			{
15328 				size_t i;
15329 
15330 				for (i = 0; i< strlen($1); i++)
15331 					$1[i] = tolower((unsigned char) $1[i]);
15332 
15333 				$$ = make3_str(mm_strdup("\""), $1, mm_strdup("\""));
15334 			}
15335 		}
15336 		| char_variable { $$ = $1; }
15337 		;
15338 
15339 /*
15340  * Declare a prepared cursor. The syntax is different from the standard
15341  * declare statement, so we create a new rule.
15342  */
15343 ECPGCursorStmt:  DECLARE cursor_name cursor_options CURSOR opt_hold FOR prepared_name
15344 		{
15345 			struct cursor *ptr, *this;
15346 			char *cursor_marker = $2[0] == ':' ? mm_strdup("$0") : mm_strdup($2);
15347 			int (* strcmp_fn)(const char *, const char *) = (($2[0] == ':' || $2[0] == '"') ? strcmp : pg_strcasecmp);
15348 			struct variable *thisquery = (struct variable *)mm_alloc(sizeof(struct variable));
15349 			const char *con = connection ? connection : "NULL";
15350 			char *comment;
15351 
15352 			for (ptr = cur; ptr != NULL; ptr = ptr->next)
15353 			{
15354 				if (strcmp_fn($2, ptr->name) == 0)
15355 				{
15356 					/* re-definition is a bug */
15357 					if ($2[0] == ':')
15358 						mmerror(PARSE_ERROR, ET_ERROR, "using variable \"%s\" in different declare statements is not supported", $2+1);
15359 					else
15360 						mmerror(PARSE_ERROR, ET_ERROR, "cursor \"%s\" is already defined", $2);
15361 				}
15362 			}
15363 
15364 			this = (struct cursor *) mm_alloc(sizeof(struct cursor));
15365 
15366 			/* initial definition */
15367 			this->next = cur;
15368 			this->name = $2;
15369 			this->function = (current_function ? mm_strdup(current_function) : NULL);
15370 			this->connection = connection;
15371 			this->command =  cat_str(6, mm_strdup("declare"), cursor_marker, $3, mm_strdup("cursor"), $5, mm_strdup("for $1"));
15372 			this->argsresult = NULL;
15373 			this->argsresult_oos = NULL;
15374 
15375 			thisquery->type = &ecpg_query;
15376 			thisquery->brace_level = 0;
15377 			thisquery->next = NULL;
15378 			thisquery->name = (char *) mm_alloc(sizeof("ECPGprepared_statement(, , __LINE__)") + strlen(con) + strlen($7));
15379 			sprintf(thisquery->name, "ECPGprepared_statement(%s, %s, __LINE__)", con, $7);
15380 
15381 			this->argsinsert = NULL;
15382 			this->argsinsert_oos = NULL;
15383 			if ($2[0] == ':')
15384 			{
15385 				struct variable *var = find_variable($2 + 1);
15386 				remove_variable_from_list(&argsinsert, var);
15387 				add_variable_to_head(&(this->argsinsert), var, &no_indicator);
15388 			}
15389 			add_variable_to_head(&(this->argsinsert), thisquery, &no_indicator);
15390 
15391 			cur = this;
15392 
15393 			comment = cat_str(3, mm_strdup("/*"), mm_strdup(this->command), mm_strdup("*/"));
15394 
15395 			if ((braces_open > 0) && INFORMIX_MODE) /* we're in a function */
15396 				$$ = cat_str(3, adjust_outofscope_cursor_vars(this),
15397 					mm_strdup("ECPG_informix_reset_sqlca();"),
15398 					comment);
15399 			else
15400 				$$ = cat2_str(adjust_outofscope_cursor_vars(this), comment);
15401 		}
15402 		;
15403 
15404 ECPGExecuteImmediateStmt: EXECUTE IMMEDIATE execstring
15405 			{
15406 			  /* execute immediate means prepare the statement and
15407 			   * immediately execute it */
15408 			  $$ = $3;
15409 			};
15410 /*
15411  * variable declaration outside exec sql declare block
15412  */
15413 ECPGVarDeclaration: single_vt_declaration;
15414 
15415 single_vt_declaration: type_declaration		{ $$ = $1; }
15416 		| var_declaration		{ $$ = $1; }
15417 		;
15418 
15419 precision:	NumericOnly	{ $$ = $1; };
15420 
15421 opt_scale:	',' NumericOnly	{ $$ = $2; }
15422 		| /* EMPTY */	{ $$ = EMPTY; }
15423 		;
15424 
15425 ecpg_interval:	opt_interval	{ $$ = $1; }
15426 		| YEAR_P TO MINUTE_P	{ $$ = mm_strdup("year to minute"); }
15427 		| YEAR_P TO SECOND_P	{ $$ = mm_strdup("year to second"); }
15428 		| DAY_P TO DAY_P		{ $$ = mm_strdup("day to day"); }
15429 		| MONTH_P TO MONTH_P	{ $$ = mm_strdup("month to month"); }
15430 		;
15431 
15432 /*
15433  * variable declaration inside exec sql declare block
15434  */
15435 ECPGDeclaration: sql_startdeclare
15436 		{ fputs("/* exec sql begin declare section */", base_yyout); }
15437 		var_type_declarations sql_enddeclare
15438 		{
15439 			fprintf(base_yyout, "%s/* exec sql end declare section */", $3);
15440 			free($3);
15441 			output_line_number();
15442 		}
15443 		;
15444 
15445 sql_startdeclare: ecpgstart BEGIN_P DECLARE SQL_SECTION ';' {};
15446 
15447 sql_enddeclare: ecpgstart END_P DECLARE SQL_SECTION ';' {};
15448 
15449 var_type_declarations:	/*EMPTY*/			{ $$ = EMPTY; }
15450 		| vt_declarations			{ $$ = $1; }
15451 		;
15452 
15453 vt_declarations:  single_vt_declaration			{ $$ = $1; }
15454 		| CPP_LINE				{ $$ = $1; }
15455 		| vt_declarations single_vt_declaration	{ $$ = cat2_str($1, $2); }
15456 		| vt_declarations CPP_LINE		{ $$ = cat2_str($1, $2); }
15457 		;
15458 
15459 variable_declarations:	var_declaration	{ $$ = $1; }
15460 		| variable_declarations var_declaration	{ $$ = cat2_str($1, $2); }
15461 		;
15462 
15463 type_declaration: S_TYPEDEF
15464 	{
15465 		/* reset this variable so we see if there was */
15466 		/* an initializer specified */
15467 		initializer = 0;
15468 	}
15469 	var_type opt_pointer ECPGColLabelCommon opt_array_bounds ';'
15470 	{
15471 		add_typedef($5, $6.index1, $6.index2, $3.type_enum, $3.type_dimension, $3.type_index, initializer, *$4 ? 1 : 0);
15472 
15473 		fprintf(base_yyout, "typedef %s %s %s %s;\n", $3.type_str, *$4 ? "*" : "", $5, $6.str);
15474 		output_line_number();
15475 		$$ = mm_strdup("");
15476 	};
15477 
15478 var_declaration: storage_declaration
15479 		var_type
15480 		{
15481 			actual_type[struct_level].type_enum = $2.type_enum;
15482 			actual_type[struct_level].type_str = $2.type_str;
15483 			actual_type[struct_level].type_dimension = $2.type_dimension;
15484 			actual_type[struct_level].type_index = $2.type_index;
15485 			actual_type[struct_level].type_sizeof = $2.type_sizeof;
15486 
15487 			actual_startline[struct_level] = hashline_number();
15488 		}
15489 		variable_list ';'
15490 		{
15491 			$$ = cat_str(5, actual_startline[struct_level], $1, $2.type_str, $4, mm_strdup(";\n"));
15492 		}
15493 		| var_type
15494 		{
15495 			actual_type[struct_level].type_enum = $1.type_enum;
15496 			actual_type[struct_level].type_str = $1.type_str;
15497 			actual_type[struct_level].type_dimension = $1.type_dimension;
15498 			actual_type[struct_level].type_index = $1.type_index;
15499 			actual_type[struct_level].type_sizeof = $1.type_sizeof;
15500 
15501 			actual_startline[struct_level] = hashline_number();
15502 		}
15503 		variable_list ';'
15504 		{
15505 			$$ = cat_str(4, actual_startline[struct_level], $1.type_str, $3, mm_strdup(";\n"));
15506 		}
15507 		| struct_union_type_with_symbol ';'
15508 		{
15509 			$$ = cat2_str($1, mm_strdup(";"));
15510 		}
15511 		;
15512 
15513 opt_bit_field:	':' Iconst	{ $$ =cat2_str(mm_strdup(":"), $2); }
15514 		| /* EMPTY */	{ $$ = EMPTY; }
15515 		;
15516 
15517 storage_declaration: storage_clause storage_modifier
15518 			{$$ = cat2_str ($1, $2); }
15519 		| storage_clause		{$$ = $1; }
15520 		| storage_modifier		{$$ = $1; }
15521 		;
15522 
15523 storage_clause : S_EXTERN	{ $$ = mm_strdup("extern"); }
15524 		| S_STATIC			{ $$ = mm_strdup("static"); }
15525 		| S_REGISTER		{ $$ = mm_strdup("register"); }
15526 		| S_AUTO			{ $$ = mm_strdup("auto"); }
15527 		;
15528 
15529 storage_modifier : S_CONST	{ $$ = mm_strdup("const"); }
15530 		| S_VOLATILE		{ $$ = mm_strdup("volatile"); }
15531 		;
15532 
15533 var_type:	simple_type
15534 		{
15535 			$$.type_enum = $1;
15536 			$$.type_str = mm_strdup(ecpg_type_name($1));
15537 			$$.type_dimension = mm_strdup("-1");
15538 			$$.type_index = mm_strdup("-1");
15539 			$$.type_sizeof = NULL;
15540 		}
15541 		| struct_union_type
15542 		{
15543 			$$.type_str = $1;
15544 			$$.type_dimension = mm_strdup("-1");
15545 			$$.type_index = mm_strdup("-1");
15546 
15547 			if (strncmp($1, "struct", sizeof("struct")-1) == 0)
15548 			{
15549 				$$.type_enum = ECPGt_struct;
15550 				$$.type_sizeof = ECPGstruct_sizeof;
15551 			}
15552 			else
15553 			{
15554 				$$.type_enum = ECPGt_union;
15555 				$$.type_sizeof = NULL;
15556 			}
15557 		}
15558 		| enum_type
15559 		{
15560 			$$.type_str = $1;
15561 			$$.type_enum = ECPGt_int;
15562 			$$.type_dimension = mm_strdup("-1");
15563 			$$.type_index = mm_strdup("-1");
15564 			$$.type_sizeof = NULL;
15565 		}
15566 		| ECPGColLabelCommon '(' precision opt_scale ')'
15567 		{
15568 			if (strcmp($1, "numeric") == 0)
15569 			{
15570 				$$.type_enum = ECPGt_numeric;
15571 				$$.type_str = mm_strdup("numeric");
15572 			}
15573 			else if (strcmp($1, "decimal") == 0)
15574 			{
15575 				$$.type_enum = ECPGt_decimal;
15576 				$$.type_str = mm_strdup("decimal");
15577 			}
15578 			else
15579 			{
15580 				mmerror(PARSE_ERROR, ET_ERROR, "only data types numeric and decimal have precision/scale argument");
15581 				$$.type_enum = ECPGt_numeric;
15582 				$$.type_str = mm_strdup("numeric");
15583 			}
15584 
15585 			$$.type_dimension = mm_strdup("-1");
15586 			$$.type_index = mm_strdup("-1");
15587 			$$.type_sizeof = NULL;
15588 		}
15589 		| ECPGColLabelCommon ecpg_interval
15590 		{
15591 			if (strlen($2) != 0 && strcmp ($1, "datetime") != 0 && strcmp ($1, "interval") != 0)
15592 				mmerror (PARSE_ERROR, ET_ERROR, "interval specification not allowed here");
15593 
15594 			/*
15595 			 * Check for type names that the SQL grammar treats as
15596 			 * unreserved keywords
15597 			 */
15598 			if (strcmp($1, "varchar") == 0)
15599 			{
15600 				$$.type_enum = ECPGt_varchar;
15601 				$$.type_str = EMPTY; /*mm_strdup("varchar");*/
15602 				$$.type_dimension = mm_strdup("-1");
15603 				$$.type_index = mm_strdup("-1");
15604 				$$.type_sizeof = NULL;
15605 			}
15606 			else if (strcmp($1, "float") == 0)
15607 			{
15608 				$$.type_enum = ECPGt_float;
15609 				$$.type_str = mm_strdup("float");
15610 				$$.type_dimension = mm_strdup("-1");
15611 				$$.type_index = mm_strdup("-1");
15612 				$$.type_sizeof = NULL;
15613 			}
15614 			else if (strcmp($1, "double") == 0)
15615 			{
15616 				$$.type_enum = ECPGt_double;
15617 				$$.type_str = mm_strdup("double");
15618 				$$.type_dimension = mm_strdup("-1");
15619 				$$.type_index = mm_strdup("-1");
15620 				$$.type_sizeof = NULL;
15621 			}
15622 			else if (strcmp($1, "numeric") == 0)
15623 			{
15624 				$$.type_enum = ECPGt_numeric;
15625 				$$.type_str = mm_strdup("numeric");
15626 				$$.type_dimension = mm_strdup("-1");
15627 				$$.type_index = mm_strdup("-1");
15628 				$$.type_sizeof = NULL;
15629 			}
15630 			else if (strcmp($1, "decimal") == 0)
15631 			{
15632 				$$.type_enum = ECPGt_decimal;
15633 				$$.type_str = mm_strdup("decimal");
15634 				$$.type_dimension = mm_strdup("-1");
15635 				$$.type_index = mm_strdup("-1");
15636 				$$.type_sizeof = NULL;
15637 			}
15638 			else if (strcmp($1, "date") == 0)
15639 			{
15640 				$$.type_enum = ECPGt_date;
15641 				$$.type_str = mm_strdup("date");
15642 				$$.type_dimension = mm_strdup("-1");
15643 				$$.type_index = mm_strdup("-1");
15644 				$$.type_sizeof = NULL;
15645 			}
15646 			else if (strcmp($1, "timestamp") == 0)
15647 			{
15648 				$$.type_enum = ECPGt_timestamp;
15649 				$$.type_str = mm_strdup("timestamp");
15650 				$$.type_dimension = mm_strdup("-1");
15651 				$$.type_index = mm_strdup("-1");
15652 				$$.type_sizeof = NULL;
15653 			}
15654 			else if (strcmp($1, "interval") == 0)
15655 			{
15656 				$$.type_enum = ECPGt_interval;
15657 				$$.type_str = mm_strdup("interval");
15658 				$$.type_dimension = mm_strdup("-1");
15659 				$$.type_index = mm_strdup("-1");
15660 				$$.type_sizeof = NULL;
15661 			}
15662 			else if (strcmp($1, "datetime") == 0)
15663 			{
15664 				$$.type_enum = ECPGt_timestamp;
15665 				$$.type_str = mm_strdup("timestamp");
15666 				$$.type_dimension = mm_strdup("-1");
15667 				$$.type_index = mm_strdup("-1");
15668 				$$.type_sizeof = NULL;
15669 			}
15670 			else if ((strcmp($1, "string") == 0) && INFORMIX_MODE)
15671 			{
15672 				$$.type_enum = ECPGt_string;
15673 				$$.type_str = mm_strdup("char");
15674 				$$.type_dimension = mm_strdup("-1");
15675 				$$.type_index = mm_strdup("-1");
15676 				$$.type_sizeof = NULL;
15677 			}
15678 			else
15679 			{
15680 				/* this is for typedef'ed types */
15681 				struct typedefs *this = get_typedef($1);
15682 
15683 				$$.type_str = (this->type->type_enum == ECPGt_varchar) ? EMPTY : mm_strdup(this->name);
15684 				$$.type_enum = this->type->type_enum;
15685 				$$.type_dimension = this->type->type_dimension;
15686 				$$.type_index = this->type->type_index;
15687 				if (this->type->type_sizeof && strlen(this->type->type_sizeof) != 0)
15688 					$$.type_sizeof = this->type->type_sizeof;
15689 				else
15690 					$$.type_sizeof = cat_str(3, mm_strdup("sizeof("), mm_strdup(this->name), mm_strdup(")"));
15691 
15692 				struct_member_list[struct_level] = ECPGstruct_member_dup(this->struct_member_list);
15693 			}
15694 		}
15695 		| s_struct_union_symbol
15696 		{
15697 			/* this is for named structs/unions */
15698 			char *name;
15699 			struct typedefs *this;
15700 			bool forward = (forward_name != NULL && strcmp($1.symbol, forward_name) == 0 && strcmp($1.su, "struct") == 0);
15701 
15702 			name = cat2_str($1.su, $1.symbol);
15703 			/* Do we have a forward definition? */
15704 			if (!forward)
15705 			{
15706 				/* No */
15707 
15708 				this = get_typedef(name);
15709 				$$.type_str = mm_strdup(this->name);
15710 				$$.type_enum = this->type->type_enum;
15711 				$$.type_dimension = this->type->type_dimension;
15712 				$$.type_index = this->type->type_index;
15713 				$$.type_sizeof = this->type->type_sizeof;
15714 				struct_member_list[struct_level] = ECPGstruct_member_dup(this->struct_member_list);
15715 				free(name);
15716 			}
15717 			else
15718 			{
15719 				$$.type_str = name;
15720 				$$.type_enum = ECPGt_long;
15721 				$$.type_dimension = mm_strdup("-1");
15722 				$$.type_index = mm_strdup("-1");
15723 				$$.type_sizeof = mm_strdup("");
15724 				struct_member_list[struct_level] = NULL;
15725 			}
15726 		}
15727 		;
15728 
15729 enum_type: ENUM_P symbol enum_definition
15730 			{ $$ = cat_str(3, mm_strdup("enum"), $2, $3); }
15731 		| ENUM_P enum_definition
15732 			{ $$ = cat2_str(mm_strdup("enum"), $2); }
15733 		| ENUM_P symbol
15734 			{ $$ = cat2_str(mm_strdup("enum"), $2); }
15735 		;
15736 
15737 enum_definition: '{' c_list '}'
15738 			{ $$ = cat_str(3, mm_strdup("{"), $2, mm_strdup("}")); };
15739 
15740 struct_union_type_with_symbol: s_struct_union_symbol
15741 		{
15742 			struct_member_list[struct_level++] = NULL;
15743 			if (struct_level >= STRUCT_DEPTH)
15744 				 mmerror(PARSE_ERROR, ET_ERROR, "too many levels in nested structure/union definition");
15745 			forward_name = mm_strdup($1.symbol);
15746 		}
15747 		'{' variable_declarations '}'
15748 		{
15749 			struct typedefs *ptr, *this;
15750 			struct this_type su_type;
15751 
15752 			ECPGfree_struct_member(struct_member_list[struct_level]);
15753 			struct_member_list[struct_level] = NULL;
15754 			struct_level--;
15755 			if (strncmp($1.su, "struct", sizeof("struct")-1) == 0)
15756 				su_type.type_enum = ECPGt_struct;
15757 			else
15758 				su_type.type_enum = ECPGt_union;
15759 			su_type.type_str = cat2_str($1.su, $1.symbol);
15760 			free(forward_name);
15761 			forward_name = NULL;
15762 
15763 			/* This is essentially a typedef but needs the keyword struct/union as well.
15764 			 * So we create the typedef for each struct definition with symbol */
15765 			for (ptr = types; ptr != NULL; ptr = ptr->next)
15766 			{
15767 					if (strcmp(su_type.type_str, ptr->name) == 0)
15768 							/* re-definition is a bug */
15769 							mmerror(PARSE_ERROR, ET_ERROR, "type \"%s\" is already defined", su_type.type_str);
15770 			}
15771 
15772 			this = (struct typedefs *) mm_alloc(sizeof(struct typedefs));
15773 
15774 			/* initial definition */
15775 			this->next = types;
15776 			this->name = mm_strdup(su_type.type_str);
15777 			this->brace_level = braces_open;
15778 			this->type = (struct this_type *) mm_alloc(sizeof(struct this_type));
15779 			this->type->type_enum = su_type.type_enum;
15780 			this->type->type_str = mm_strdup(su_type.type_str);
15781 			this->type->type_dimension = mm_strdup("-1"); /* dimension of array */
15782 			this->type->type_index = mm_strdup("-1");	/* length of string */
15783 			this->type->type_sizeof = ECPGstruct_sizeof;
15784 			this->struct_member_list = struct_member_list[struct_level];
15785 
15786 			types = this;
15787 			$$ = cat_str(4, su_type.type_str, mm_strdup("{"), $4, mm_strdup("}"));
15788 		}
15789 		;
15790 
15791 struct_union_type: struct_union_type_with_symbol	{ $$ = $1; }
15792 		| s_struct_union
15793 		{
15794 			struct_member_list[struct_level++] = NULL;
15795 			if (struct_level >= STRUCT_DEPTH)
15796 				 mmerror(PARSE_ERROR, ET_ERROR, "too many levels in nested structure/union definition");
15797 		}
15798 		'{' variable_declarations '}'
15799 		{
15800 			ECPGfree_struct_member(struct_member_list[struct_level]);
15801 			struct_member_list[struct_level] = NULL;
15802 			struct_level--;
15803 			$$ = cat_str(4, $1, mm_strdup("{"), $4, mm_strdup("}"));
15804 		}
15805 		;
15806 
15807 s_struct_union_symbol: SQL_STRUCT symbol
15808 		{
15809 			$$.su = mm_strdup("struct");
15810 			$$.symbol = $2;
15811 			ECPGstruct_sizeof = cat_str(3, mm_strdup("sizeof("), cat2_str(mm_strdup($$.su), mm_strdup($$.symbol)), mm_strdup(")"));
15812 		}
15813 		| UNION symbol
15814 		{
15815 			$$.su = mm_strdup("union");
15816 			$$.symbol = $2;
15817 		}
15818 		;
15819 
15820 s_struct_union: SQL_STRUCT
15821 		{
15822 			ECPGstruct_sizeof = mm_strdup(""); /* This must not be NULL to distinguish from simple types. */
15823 			$$ = mm_strdup("struct");
15824 		}
15825 		| UNION
15826 		{
15827 			$$ = mm_strdup("union");
15828 		}
15829 		;
15830 
15831 simple_type: unsigned_type					{ $$=$1; }
15832 		|	opt_signed signed_type			{ $$=$2; }
15833 		;
15834 
15835 unsigned_type: SQL_UNSIGNED SQL_SHORT		{ $$ = ECPGt_unsigned_short; }
15836 		| SQL_UNSIGNED SQL_SHORT INT_P	{ $$ = ECPGt_unsigned_short; }
15837 		| SQL_UNSIGNED						{ $$ = ECPGt_unsigned_int; }
15838 		| SQL_UNSIGNED INT_P				{ $$ = ECPGt_unsigned_int; }
15839 		| SQL_UNSIGNED SQL_LONG				{ $$ = ECPGt_unsigned_long; }
15840 		| SQL_UNSIGNED SQL_LONG INT_P		{ $$ = ECPGt_unsigned_long; }
15841 		| SQL_UNSIGNED SQL_LONG SQL_LONG
15842 		{
15843 #ifdef HAVE_LONG_LONG_INT
15844 			$$ = ECPGt_unsigned_long_long;
15845 #else
15846 			$$ = ECPGt_unsigned_long;
15847 #endif
15848 		}
15849 		| SQL_UNSIGNED SQL_LONG SQL_LONG INT_P
15850 		{
15851 #ifdef HAVE_LONG_LONG_INT
15852 			$$ = ECPGt_unsigned_long_long;
15853 #else
15854 			$$ = ECPGt_unsigned_long;
15855 #endif
15856 		}
15857 		| SQL_UNSIGNED CHAR_P			{ $$ = ECPGt_unsigned_char; }
15858 		;
15859 
15860 signed_type: SQL_SHORT				{ $$ = ECPGt_short; }
15861 		| SQL_SHORT INT_P			{ $$ = ECPGt_short; }
15862 		| INT_P						{ $$ = ECPGt_int; }
15863 		| SQL_LONG					{ $$ = ECPGt_long; }
15864 		| SQL_LONG INT_P			{ $$ = ECPGt_long; }
15865 		| SQL_LONG SQL_LONG
15866 		{
15867 #ifdef HAVE_LONG_LONG_INT
15868 			$$ = ECPGt_long_long;
15869 #else
15870 			$$ = ECPGt_long;
15871 #endif
15872 		}
15873 		| SQL_LONG SQL_LONG INT_P
15874 		{
15875 #ifdef HAVE_LONG_LONG_INT
15876 			$$ = ECPGt_long_long;
15877 #else
15878 			$$ = ECPGt_long;
15879 #endif
15880 		}
15881 		| SQL_BOOL					{ $$ = ECPGt_bool; }
15882 		| CHAR_P					{ $$ = ECPGt_char; }
15883 		| DOUBLE_P					{ $$ = ECPGt_double; }
15884 		;
15885 
15886 opt_signed: SQL_SIGNED
15887 		|	/* EMPTY */
15888 		;
15889 
15890 variable_list: variable
15891 			{ $$ = $1; }
15892 		| variable_list ',' variable
15893 		{
15894 			if (actual_type[struct_level].type_enum == ECPGt_varchar)
15895 				$$ = cat_str(3, $1, mm_strdup(";"), $3);
15896 			else
15897 				$$ = cat_str(3, $1, mm_strdup(","), $3);
15898 		}
15899 		;
15900 
15901 variable: opt_pointer ECPGColLabel opt_array_bounds opt_bit_field opt_initializer
15902 		{
15903 			struct ECPGtype * type;
15904 			char *dimension = $3.index1;	/* dimension of array */
15905 			char *length = $3.index2;		/* length of string */
15906 			char *dim_str;
15907 			char *vcn;
15908 
15909 			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);
15910 
15911 			switch (actual_type[struct_level].type_enum)
15912 			{
15913 				case ECPGt_struct:
15914 				case ECPGt_union:
15915 					if (atoi(dimension) < 0)
15916 						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);
15917 					else
15918 						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);
15919 
15920 					$$ = cat_str(5, $1, mm_strdup($2), $3.str, $4, $5);
15921 					break;
15922 
15923 				case ECPGt_varchar:
15924 					if (atoi(dimension) < 0)
15925 						type = ECPGmake_simple_type(actual_type[struct_level].type_enum, length, varchar_counter);
15926 					else
15927 						type = ECPGmake_array_type(ECPGmake_simple_type(actual_type[struct_level].type_enum, length, varchar_counter), dimension);
15928 
15929 					if (strcmp(dimension, "0") == 0 || abs(atoi(dimension)) == 1)
15930 							dim_str=mm_strdup("");
15931 					else
15932 							dim_str=cat_str(3, mm_strdup("["), mm_strdup(dimension), mm_strdup("]"));
15933 					/* cannot check for atoi <= 0 because a defined constant will yield 0 here as well */
15934 					if (atoi(length) < 0 || strcmp(length, "0") == 0)
15935 						mmerror(PARSE_ERROR, ET_ERROR, "pointers to varchar are not implemented");
15936 
15937 					/* make sure varchar struct name is unique by adding a unique counter to its definition */
15938 					vcn = (char *) mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
15939 					sprintf(vcn, "%d", varchar_counter);
15940 					if (strcmp(dimension, "0") == 0)
15941 						$$ = cat_str(7, make2_str(mm_strdup(" struct varchar_"), vcn), mm_strdup(" { int len; char arr["), mm_strdup(length), mm_strdup("]; } *"), mm_strdup($2), $4, $5);
15942 					else
15943 						$$ = cat_str(8, make2_str(mm_strdup(" struct varchar_"), vcn), mm_strdup(" { int len; char arr["), mm_strdup(length), mm_strdup("]; } "), mm_strdup($2), dim_str, $4, $5);
15944 					varchar_counter++;
15945 					break;
15946 
15947 				case ECPGt_char:
15948 				case ECPGt_unsigned_char:
15949 				case ECPGt_string:
15950 					if (atoi(dimension) == -1)
15951 					{
15952 						int i = strlen($5);
15953 
15954 						if (atoi(length) == -1 && i > 0) /* char <var>[] = "string" */
15955 						{
15956 							/* if we have an initializer but no string size set, let's use the initializer's length */
15957 							free(length);
15958 							length = mm_alloc(i+sizeof("sizeof()"));
15959 							sprintf(length, "sizeof(%s)", $5+2);
15960 						}
15961 						type = ECPGmake_simple_type(actual_type[struct_level].type_enum, length, 0);
15962 					}
15963 					else
15964 						type = ECPGmake_array_type(ECPGmake_simple_type(actual_type[struct_level].type_enum, length, 0), dimension);
15965 
15966 					$$ = cat_str(5, $1, mm_strdup($2), $3.str, $4, $5);
15967 					break;
15968 
15969 				default:
15970 					if (atoi(dimension) < 0)
15971 						type = ECPGmake_simple_type(actual_type[struct_level].type_enum, mm_strdup("1"), 0);
15972 					else
15973 						type = ECPGmake_array_type(ECPGmake_simple_type(actual_type[struct_level].type_enum, mm_strdup("1"), 0), dimension);
15974 
15975 					$$ = cat_str(5, $1, mm_strdup($2), $3.str, $4, $5);
15976 					break;
15977 			}
15978 
15979 			if (struct_level == 0)
15980 				new_variable($2, type, braces_open);
15981 			else
15982 				ECPGmake_struct_member($2, type, &(struct_member_list[struct_level - 1]));
15983 
15984 			free($2);
15985 		}
15986 		;
15987 
15988 opt_initializer: /*EMPTY*/
15989 			{ $$ = EMPTY; }
15990 		| '=' c_term
15991 		{
15992 			initializer = 1;
15993 			$$ = cat2_str(mm_strdup("="), $2);
15994 		}
15995 		;
15996 
15997 opt_pointer: /*EMPTY*/				{ $$ = EMPTY; }
15998 		| '*'						{ $$ = mm_strdup("*"); }
15999 		| '*' '*'					{ $$ = mm_strdup("**"); }
16000 		;
16001 
16002 /*
16003  * We try to simulate the correct DECLARE syntax here so we get dynamic SQL
16004  */
16005 ECPGDeclare: DECLARE STATEMENT ecpg_ident
16006 		{
16007 			/* this is only supported for compatibility */
16008 			$$ = cat_str(3, mm_strdup("/* declare statement"), $3, mm_strdup("*/"));
16009 		}
16010 		;
16011 /*
16012  * the exec sql disconnect statement: disconnect from the given database
16013  */
16014 ECPGDisconnect: SQL_DISCONNECT dis_name { $$ = $2; }
16015 		;
16016 
16017 dis_name: connection_object			{ $$ = $1; }
16018 		| CURRENT_P			{ $$ = mm_strdup("\"CURRENT\""); }
16019 		| ALL				{ $$ = mm_strdup("\"ALL\""); }
16020 		| /* EMPTY */			{ $$ = mm_strdup("\"CURRENT\""); }
16021 		;
16022 
16023 connection_object: database_name		{ $$ = make3_str(mm_strdup("\""), $1, mm_strdup("\"")); }
16024 		| DEFAULT			{ $$ = mm_strdup("\"DEFAULT\""); }
16025 		| char_variable			{ $$ = $1; }
16026 		;
16027 
16028 execstring: char_variable
16029 			{ $$ = $1; }
16030 		|	CSTRING
16031 			{ $$ = make3_str(mm_strdup("\""), $1, mm_strdup("\"")); }
16032 		;
16033 
16034 /*
16035  * the exec sql free command to deallocate a previously
16036  * prepared statement
16037  */
16038 ECPGFree:	SQL_FREE cursor_name	{ $$ = $2; }
16039 		| SQL_FREE ALL	{ $$ = mm_strdup("all"); }
16040 		;
16041 
16042 /*
16043  * open is an open cursor, at the moment this has to be removed
16044  */
16045 ECPGOpen: SQL_OPEN cursor_name opt_ecpg_using
16046 		{
16047 			if ($2[0] == ':')
16048 				remove_variable_from_list(&argsinsert, find_variable($2 + 1));
16049 			$$ = $2;
16050 		}
16051 		;
16052 
16053 opt_ecpg_using: /*EMPTY*/	{ $$ = EMPTY; }
16054 		| ecpg_using		{ $$ = $1; }
16055 		;
16056 
16057 ecpg_using:	USING using_list	{ $$ = EMPTY; }
16058 		| using_descriptor		{ $$ = $1; }
16059 		;
16060 
16061 using_descriptor: USING SQL_P SQL_DESCRIPTOR quoted_ident_stringvar
16062 		{
16063 			add_variable_to_head(&argsinsert, descriptor_variable($4,0), &no_indicator);
16064 			$$ = EMPTY;
16065 		}
16066 		| USING SQL_DESCRIPTOR name
16067 		{
16068 			add_variable_to_head(&argsinsert, sqlda_variable($3), &no_indicator);
16069 			$$ = EMPTY;
16070 		}
16071 		;
16072 
16073 into_descriptor: INTO SQL_P SQL_DESCRIPTOR quoted_ident_stringvar
16074 		{
16075 			add_variable_to_head(&argsresult, descriptor_variable($4,1), &no_indicator);
16076 			$$ = EMPTY;
16077 		}
16078 		| INTO SQL_DESCRIPTOR name
16079 		{
16080 			add_variable_to_head(&argsresult, sqlda_variable($3), &no_indicator);
16081 			$$ = EMPTY;
16082 		}
16083 		;
16084 
16085 into_sqlda: INTO name
16086 		{
16087 			add_variable_to_head(&argsresult, sqlda_variable($2), &no_indicator);
16088 			$$ = EMPTY;
16089 		}
16090 		;
16091 
16092 using_list: UsingValue | UsingValue ',' using_list;
16093 
16094 UsingValue: UsingConst
16095 		{
16096 			char *length = mm_alloc(32);
16097 
16098 			sprintf(length, "%d", (int) strlen($1));
16099 			add_variable_to_head(&argsinsert, new_variable($1, ECPGmake_simple_type(ECPGt_const, length, 0), 0), &no_indicator);
16100 		}
16101 		| civar { $$ = EMPTY; }
16102 		| civarind { $$ = EMPTY; }
16103 		;
16104 
16105 UsingConst: Iconst			{ $$ = $1; }
16106 		| '+' Iconst		{ $$ = cat_str(2, mm_strdup("+"), $2); }
16107 		| '-' Iconst		{ $$ = cat_str(2, mm_strdup("-"), $2); }
16108 		| ecpg_fconst		{ $$ = $1; }
16109 		| '+' ecpg_fconst	{ $$ = cat_str(2, mm_strdup("+"), $2); }
16110 		| '-' ecpg_fconst	{ $$ = cat_str(2, mm_strdup("-"), $2); }
16111 		| ecpg_sconst		{ $$ = $1; }
16112 		| ecpg_bconst		{ $$ = $1; }
16113 		| ecpg_xconst		{ $$ = $1; }
16114 		;
16115 
16116 /*
16117  * We accept DESCRIBE [OUTPUT] but do nothing with DESCRIBE INPUT so far.
16118  */
16119 ECPGDescribe: SQL_DESCRIBE INPUT_P prepared_name using_descriptor
16120 	{
16121 		const char *con = connection ? connection : "NULL";
16122 		mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
16123 		$$ = (char *) mm_alloc(sizeof("1, , ") + strlen(con) + strlen($3));
16124 		sprintf($$, "1, %s, %s", con, $3);
16125 	}
16126 	| SQL_DESCRIBE opt_output prepared_name using_descriptor
16127 	{
16128 		const char *con = connection ? connection : "NULL";
16129 		struct variable *var;
16130 
16131 		var = argsinsert->variable;
16132 		remove_variable_from_list(&argsinsert, var);
16133 		add_variable_to_head(&argsresult, var, &no_indicator);
16134 
16135 		$$ = (char *) mm_alloc(sizeof("0, , ") + strlen(con) + strlen($3));
16136 		sprintf($$, "0, %s, %s", con, $3);
16137 	}
16138 	| SQL_DESCRIBE opt_output prepared_name into_descriptor
16139 	{
16140 		const char *con = connection ? connection : "NULL";
16141 		$$ = (char *) mm_alloc(sizeof("0, , ") + strlen(con) + strlen($3));
16142 		sprintf($$, "0, %s, %s", con, $3);
16143 	}
16144 	| SQL_DESCRIBE INPUT_P prepared_name into_sqlda
16145 	{
16146 		const char *con = connection ? connection : "NULL";
16147 		mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
16148 		$$ = (char *) mm_alloc(sizeof("1, , ") + strlen(con) + strlen($3));
16149 		sprintf($$, "1, %s, %s", con, $3);
16150 	}
16151 	| SQL_DESCRIBE opt_output prepared_name into_sqlda
16152 	{
16153 		const char *con = connection ? connection : "NULL";
16154 		$$ = (char *) mm_alloc(sizeof("0, , ") + strlen(con) + strlen($3));
16155 		sprintf($$, "0, %s, %s", con, $3);
16156 	}
16157 	;
16158 
16159 opt_output:	SQL_OUTPUT	{ $$ = mm_strdup("output"); }
16160 	|	/* EMPTY */	{ $$ = EMPTY; }
16161 	;
16162 
16163 /*
16164  * dynamic SQL: descriptor based access
16165  *	originally written by Christof Petig <christof.petig@wtal.de>
16166  *			and Peter Eisentraut <peter.eisentraut@credativ.de>
16167  */
16168 
16169 /*
16170  * allocate a descriptor
16171  */
16172 ECPGAllocateDescr: SQL_ALLOCATE SQL_DESCRIPTOR quoted_ident_stringvar
16173 		{
16174 			add_descriptor($3,connection);
16175 			$$ = $3;
16176 		}
16177 		;
16178 
16179 
16180 /*
16181  * deallocate a descriptor
16182  */
16183 ECPGDeallocateDescr:	DEALLOCATE SQL_DESCRIPTOR quoted_ident_stringvar
16184 		{
16185 			drop_descriptor($3,connection);
16186 			$$ = $3;
16187 		}
16188 		;
16189 
16190 /*
16191  * manipulate a descriptor header
16192  */
16193 
16194 ECPGGetDescriptorHeader: SQL_GET SQL_DESCRIPTOR quoted_ident_stringvar ECPGGetDescHeaderItems
16195 			{  $$ = $3; }
16196 		;
16197 
16198 ECPGGetDescHeaderItems: ECPGGetDescHeaderItem
16199 		| ECPGGetDescHeaderItems ',' ECPGGetDescHeaderItem
16200 		;
16201 
16202 ECPGGetDescHeaderItem: cvariable '=' desc_header_item
16203 			{ push_assignment($1, $3); }
16204 		;
16205 
16206 
16207 ECPGSetDescriptorHeader: SET SQL_DESCRIPTOR quoted_ident_stringvar ECPGSetDescHeaderItems
16208 			{ $$ = $3; }
16209 		;
16210 
16211 ECPGSetDescHeaderItems: ECPGSetDescHeaderItem
16212 		| ECPGSetDescHeaderItems ',' ECPGSetDescHeaderItem
16213 		;
16214 
16215 ECPGSetDescHeaderItem: desc_header_item '=' IntConstVar
16216 		{
16217 			push_assignment($3, $1);
16218 		}
16219 		;
16220 
16221 IntConstVar: Iconst
16222 		{
16223 			char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
16224 
16225 			sprintf(length, "%d", (int) strlen($1));
16226 			new_variable($1, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
16227 			$$ = $1;
16228 		}
16229 		| cvariable
16230 		{
16231 			$$ = $1;
16232 		}
16233 		;
16234 
16235 desc_header_item:	SQL_COUNT			{ $$ = ECPGd_count; }
16236 		;
16237 
16238 /*
16239  * manipulate a descriptor
16240  */
16241 
16242 ECPGGetDescriptor:	SQL_GET SQL_DESCRIPTOR quoted_ident_stringvar VALUE_P IntConstVar ECPGGetDescItems
16243 			{  $$.str = $5; $$.name = $3; }
16244 		;
16245 
16246 ECPGGetDescItems: ECPGGetDescItem
16247 		| ECPGGetDescItems ',' ECPGGetDescItem
16248 		;
16249 
16250 ECPGGetDescItem: cvariable '=' descriptor_item	{ push_assignment($1, $3); };
16251 
16252 
16253 ECPGSetDescriptor:	SET SQL_DESCRIPTOR quoted_ident_stringvar VALUE_P IntConstVar ECPGSetDescItems
16254 			{  $$.str = $5; $$.name = $3; }
16255 		;
16256 
16257 ECPGSetDescItems: ECPGSetDescItem
16258 		| ECPGSetDescItems ',' ECPGSetDescItem
16259 		;
16260 
16261 ECPGSetDescItem: descriptor_item '=' AllConstVar
16262 		{
16263 			push_assignment($3, $1);
16264 		}
16265 		;
16266 
16267 AllConstVar: ecpg_fconst
16268 		{
16269 			char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
16270 
16271 			sprintf(length, "%d", (int) strlen($1));
16272 			new_variable($1, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
16273 			$$ = $1;
16274 		}
16275 
16276 		| IntConstVar
16277 		{
16278 			$$ = $1;
16279 		}
16280 
16281 		| '-' ecpg_fconst
16282 		{
16283 			char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
16284 			char *var = cat2_str(mm_strdup("-"), $2);
16285 
16286 			sprintf(length, "%d", (int) strlen(var));
16287 			new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
16288 			$$ = var;
16289 		}
16290 
16291 		| '-' Iconst
16292 		{
16293 			char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
16294 			char *var = cat2_str(mm_strdup("-"), $2);
16295 
16296 			sprintf(length, "%d", (int) strlen(var));
16297 			new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
16298 			$$ = var;
16299 		}
16300 
16301 		| ecpg_sconst
16302 		{
16303 			char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
16304 			char *var = $1 + 1;
16305 
16306 			var[strlen(var) - 1] = '\0';
16307 			sprintf(length, "%d", (int) strlen(var));
16308 			new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
16309 			$$ = var;
16310 		}
16311 		;
16312 
16313 descriptor_item:	SQL_CARDINALITY			{ $$ = ECPGd_cardinality; }
16314 		| DATA_P				{ $$ = ECPGd_data; }
16315 		| SQL_DATETIME_INTERVAL_CODE		{ $$ = ECPGd_di_code; }
16316 		| SQL_DATETIME_INTERVAL_PRECISION	{ $$ = ECPGd_di_precision; }
16317 		| SQL_INDICATOR				{ $$ = ECPGd_indicator; }
16318 		| SQL_KEY_MEMBER			{ $$ = ECPGd_key_member; }
16319 		| SQL_LENGTH				{ $$ = ECPGd_length; }
16320 		| NAME_P				{ $$ = ECPGd_name; }
16321 		| SQL_NULLABLE				{ $$ = ECPGd_nullable; }
16322 		| SQL_OCTET_LENGTH			{ $$ = ECPGd_octet; }
16323 		| PRECISION				{ $$ = ECPGd_precision; }
16324 		| SQL_RETURNED_LENGTH			{ $$ = ECPGd_length; }
16325 		| SQL_RETURNED_OCTET_LENGTH		{ $$ = ECPGd_ret_octet; }
16326 		| SQL_SCALE				{ $$ = ECPGd_scale; }
16327 		| TYPE_P				{ $$ = ECPGd_type; }
16328 		;
16329 
16330 /*
16331  * set/reset the automatic transaction mode, this needs a different handling
16332  * as the other set commands
16333  */
16334 ECPGSetAutocommit:	SET SQL_AUTOCOMMIT '=' on_off	{ $$ = $4; }
16335 		|  SET SQL_AUTOCOMMIT TO on_off   { $$ = $4; }
16336 		;
16337 
16338 on_off: ON				{ $$ = mm_strdup("on"); }
16339 		| OFF			{ $$ = mm_strdup("off"); }
16340 		;
16341 
16342 /*
16343  * set the actual connection, this needs a different handling as the other
16344  * set commands
16345  */
16346 ECPGSetConnection:	SET CONNECTION TO connection_object { $$ = $4; }
16347 		| SET CONNECTION '=' connection_object { $$ = $4; }
16348 		| SET CONNECTION  connection_object { $$ = $3; }
16349 		;
16350 
16351 /*
16352  * define a new type for embedded SQL
16353  */
16354 ECPGTypedef: TYPE_P
16355 		{
16356 			/* reset this variable so we see if there was */
16357 			/* an initializer specified */
16358 			initializer = 0;
16359 		}
16360 		ECPGColLabelCommon IS var_type opt_array_bounds opt_reference
16361 		{
16362 			add_typedef($3, $6.index1, $6.index2, $5.type_enum, $5.type_dimension, $5.type_index, initializer, *$7 ? 1 : 0);
16363 
16364 			if (auto_create_c == false)
16365 				$$ = 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("*/"));
16366 			else
16367 				$$ = 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(";"));
16368 		}
16369 		;
16370 
16371 opt_reference: SQL_REFERENCE		{ $$ = mm_strdup("reference"); }
16372 		| /*EMPTY*/					{ $$ = EMPTY; }
16373 		;
16374 
16375 /*
16376  * define the type of one variable for embedded SQL
16377  */
16378 ECPGVar: SQL_VAR
16379 		{
16380 			/* reset this variable so we see if there was */
16381 			/* an initializer specified */
16382 			initializer = 0;
16383 		}
16384 		ColLabel IS var_type opt_array_bounds opt_reference
16385 		{
16386 			struct variable *p = find_variable($3);
16387 			char *dimension = $6.index1;
16388 			char *length = $6.index2;
16389 			struct ECPGtype * type;
16390 
16391 			if (($5.type_enum == ECPGt_struct ||
16392 				 $5.type_enum == ECPGt_union) &&
16393 				initializer == 1)
16394 				mmerror(PARSE_ERROR, ET_ERROR, "initializer not allowed in EXEC SQL VAR command");
16395 			else
16396 			{
16397 				adjust_array($5.type_enum, &dimension, &length, $5.type_dimension, $5.type_index, *$7?1:0, false);
16398 
16399 				switch ($5.type_enum)
16400 				{
16401 					case ECPGt_struct:
16402 					case ECPGt_union:
16403 						if (atoi(dimension) < 0)
16404 							type = ECPGmake_struct_type(struct_member_list[struct_level], $5.type_enum, $5.type_str, $5.type_sizeof);
16405 						else
16406 							type = ECPGmake_array_type(ECPGmake_struct_type(struct_member_list[struct_level], $5.type_enum, $5.type_str, $5.type_sizeof), dimension);
16407 						break;
16408 
16409 					case ECPGt_varchar:
16410 						if (atoi(dimension) == -1)
16411 							type = ECPGmake_simple_type($5.type_enum, length, 0);
16412 						else
16413 							type = ECPGmake_array_type(ECPGmake_simple_type($5.type_enum, length, 0), dimension);
16414 						break;
16415 
16416 					case ECPGt_char:
16417 					case ECPGt_unsigned_char:
16418 					case ECPGt_string:
16419 						if (atoi(dimension) == -1)
16420 							type = ECPGmake_simple_type($5.type_enum, length, 0);
16421 						else
16422 							type = ECPGmake_array_type(ECPGmake_simple_type($5.type_enum, length, 0), dimension);
16423 						break;
16424 
16425 					default:
16426 						if (atoi(length) >= 0)
16427 							mmerror(PARSE_ERROR, ET_ERROR, "multidimensional arrays for simple data types are not supported");
16428 
16429 						if (atoi(dimension) < 0)
16430 							type = ECPGmake_simple_type($5.type_enum, mm_strdup("1"), 0);
16431 						else
16432 							type = ECPGmake_array_type(ECPGmake_simple_type($5.type_enum, mm_strdup("1"), 0), dimension);
16433 						break;
16434 				}
16435 
16436 				ECPGfree_type(p->type);
16437 				p->type = type;
16438 			}
16439 
16440 			$$ = 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("*/"));
16441 		}
16442 		;
16443 
16444 /*
16445  * whenever statement: decide what to do in case of error/no data found
16446  * according to SQL standards we lack: SQLSTATE, CONSTRAINT and SQLEXCEPTION
16447  */
16448 ECPGWhenever: SQL_WHENEVER SQL_SQLERROR action
16449 		{
16450 			when_error.code = $<action>3.code;
16451 			when_error.command = $<action>3.command;
16452 			$$ = cat_str(3, mm_strdup("/* exec sql whenever sqlerror "), $3.str, mm_strdup("; */"));
16453 		}
16454 		| SQL_WHENEVER NOT SQL_FOUND action
16455 		{
16456 			when_nf.code = $<action>4.code;
16457 			when_nf.command = $<action>4.command;
16458 			$$ = cat_str(3, mm_strdup("/* exec sql whenever not found "), $4.str, mm_strdup("; */"));
16459 		}
16460 		| SQL_WHENEVER SQL_SQLWARNING action
16461 		{
16462 			when_warn.code = $<action>3.code;
16463 			when_warn.command = $<action>3.command;
16464 			$$ = cat_str(3, mm_strdup("/* exec sql whenever sql_warning "), $3.str, mm_strdup("; */"));
16465 		}
16466 		;
16467 
16468 action : CONTINUE_P
16469 		{
16470 			$<action>$.code = W_NOTHING;
16471 			$<action>$.command = NULL;
16472 			$<action>$.str = mm_strdup("continue");
16473 		}
16474 		| SQL_SQLPRINT
16475 		{
16476 			$<action>$.code = W_SQLPRINT;
16477 			$<action>$.command = NULL;
16478 			$<action>$.str = mm_strdup("sqlprint");
16479 		}
16480 		| SQL_STOP
16481 		{
16482 			$<action>$.code = W_STOP;
16483 			$<action>$.command = NULL;
16484 			$<action>$.str = mm_strdup("stop");
16485 		}
16486 		| SQL_GOTO name
16487 		{
16488 			$<action>$.code = W_GOTO;
16489 			$<action>$.command = mm_strdup($2);
16490 			$<action>$.str = cat2_str(mm_strdup("goto "), $2);
16491 		}
16492 		| SQL_GO TO name
16493 		{
16494 			$<action>$.code = W_GOTO;
16495 			$<action>$.command = mm_strdup($3);
16496 			$<action>$.str = cat2_str(mm_strdup("goto "), $3);
16497 		}
16498 		| DO name '(' c_args ')'
16499 		{
16500 			$<action>$.code = W_DO;
16501 			$<action>$.command = cat_str(4, $2, mm_strdup("("), $4, mm_strdup(")"));
16502 			$<action>$.str = cat2_str(mm_strdup("do"), mm_strdup($<action>$.command));
16503 		}
16504 		| DO SQL_BREAK
16505 		{
16506 			$<action>$.code = W_BREAK;
16507 			$<action>$.command = NULL;
16508 			$<action>$.str = mm_strdup("break");
16509 		}
16510 		| DO CONTINUE_P
16511 		{
16512 			$<action>$.code = W_CONTINUE;
16513 			$<action>$.command = NULL;
16514 			$<action>$.str = mm_strdup("continue");
16515 		}
16516 		| CALL name '(' c_args ')'
16517 		{
16518 			$<action>$.code = W_DO;
16519 			$<action>$.command = cat_str(4, $2, mm_strdup("("), $4, mm_strdup(")"));
16520 			$<action>$.str = cat2_str(mm_strdup("call"), mm_strdup($<action>$.command));
16521 		}
16522 		| CALL name
16523 		{
16524 			$<action>$.code = W_DO;
16525 			$<action>$.command = cat2_str($2, mm_strdup("()"));
16526 			$<action>$.str = cat2_str(mm_strdup("call"), mm_strdup($<action>$.command));
16527 		}
16528 		;
16529 
16530 /* some other stuff for ecpg */
16531 
16532 /* additional unreserved keywords */
16533 ECPGKeywords: ECPGKeywords_vanames	{ $$ = $1; }
16534 		| ECPGKeywords_rest	{ $$ = $1; }
16535 		;
16536 
16537 ECPGKeywords_vanames:  SQL_BREAK		{ $$ = mm_strdup("break"); }
16538 		| SQL_CARDINALITY				{ $$ = mm_strdup("cardinality"); }
16539 		| SQL_COUNT						{ $$ = mm_strdup("count"); }
16540 		| SQL_DATETIME_INTERVAL_CODE	{ $$ = mm_strdup("datetime_interval_code"); }
16541 		| SQL_DATETIME_INTERVAL_PRECISION	{ $$ = mm_strdup("datetime_interval_precision"); }
16542 		| SQL_FOUND						{ $$ = mm_strdup("found"); }
16543 		| SQL_GO						{ $$ = mm_strdup("go"); }
16544 		| SQL_GOTO						{ $$ = mm_strdup("goto"); }
16545 		| SQL_IDENTIFIED				{ $$ = mm_strdup("identified"); }
16546 		| SQL_INDICATOR				{ $$ = mm_strdup("indicator"); }
16547 		| SQL_KEY_MEMBER			{ $$ = mm_strdup("key_member"); }
16548 		| SQL_LENGTH				{ $$ = mm_strdup("length"); }
16549 		| SQL_NULLABLE				{ $$ = mm_strdup("nullable"); }
16550 		| SQL_OCTET_LENGTH			{ $$ = mm_strdup("octet_length"); }
16551 		| SQL_RETURNED_LENGTH		{ $$ = mm_strdup("returned_length"); }
16552 		| SQL_RETURNED_OCTET_LENGTH	{ $$ = mm_strdup("returned_octet_length"); }
16553 		| SQL_SCALE					{ $$ = mm_strdup("scale"); }
16554 		| SQL_SECTION				{ $$ = mm_strdup("section"); }
16555 		| SQL_SQLERROR				{ $$ = mm_strdup("sqlerror"); }
16556 		| SQL_SQLPRINT				{ $$ = mm_strdup("sqlprint"); }
16557 		| SQL_SQLWARNING			{ $$ = mm_strdup("sqlwarning"); }
16558 		| SQL_STOP					{ $$ = mm_strdup("stop"); }
16559 		;
16560 
16561 ECPGKeywords_rest:  SQL_CONNECT		{ $$ = mm_strdup("connect"); }
16562 		| SQL_DESCRIBE				{ $$ = mm_strdup("describe"); }
16563 		| SQL_DISCONNECT			{ $$ = mm_strdup("disconnect"); }
16564 		| SQL_OPEN					{ $$ = mm_strdup("open"); }
16565 		| SQL_VAR					{ $$ = mm_strdup("var"); }
16566 		| SQL_WHENEVER				{ $$ = mm_strdup("whenever"); }
16567 		;
16568 
16569 /* additional keywords that can be SQL type names (but not ECPGColLabels) */
16570 ECPGTypeName:  SQL_BOOL				{ $$ = mm_strdup("bool"); }
16571 		| SQL_LONG					{ $$ = mm_strdup("long"); }
16572 		| SQL_OUTPUT				{ $$ = mm_strdup("output"); }
16573 		| SQL_SHORT					{ $$ = mm_strdup("short"); }
16574 		| SQL_STRUCT				{ $$ = mm_strdup("struct"); }
16575 		| SQL_SIGNED				{ $$ = mm_strdup("signed"); }
16576 		| SQL_UNSIGNED				{ $$ = mm_strdup("unsigned"); }
16577 		;
16578 
16579 symbol: ColLabel					{ $$ = $1; }
16580 		;
16581 
16582 ECPGColId: ecpg_ident				{ $$ = $1; }
16583 		| unreserved_keyword		{ $$ = $1; }
16584 		| col_name_keyword			{ $$ = $1; }
16585 		| ECPGunreserved_interval	{ $$ = $1; }
16586 		| ECPGKeywords				{ $$ = $1; }
16587 		| ECPGCKeywords				{ $$ = $1; }
16588 		| CHAR_P					{ $$ = mm_strdup("char"); }
16589 		| VALUES					{ $$ = mm_strdup("values"); }
16590 		;
16591 
16592 /*
16593  * Name classification hierarchy.
16594  *
16595  * These productions should match those in the core grammar, except that
16596  * we use all_unreserved_keyword instead of unreserved_keyword, and
16597  * where possible include ECPG keywords as well as core keywords.
16598  */
16599 
16600 /* Column identifier --- names that can be column, table, etc names.
16601  */
16602 ColId:	ecpg_ident					{ $$ = $1; }
16603 		| all_unreserved_keyword	{ $$ = $1; }
16604 		| col_name_keyword			{ $$ = $1; }
16605 		| ECPGKeywords				{ $$ = $1; }
16606 		| ECPGCKeywords				{ $$ = $1; }
16607 		| CHAR_P					{ $$ = mm_strdup("char"); }
16608 		| VALUES					{ $$ = mm_strdup("values"); }
16609 		;
16610 
16611 /* Type/function identifier --- names that can be type or function names.
16612  */
16613 type_function_name:	ecpg_ident		{ $$ = $1; }
16614 		| all_unreserved_keyword	{ $$ = $1; }
16615 		| type_func_name_keyword	{ $$ = $1; }
16616 		| ECPGKeywords				{ $$ = $1; }
16617 		| ECPGCKeywords				{ $$ = $1; }
16618 		| ECPGTypeName				{ $$ = $1; }
16619 		;
16620 
16621 /* Column label --- allowed labels in "AS" clauses.
16622  * This presently includes *all* Postgres keywords.
16623  */
16624 ColLabel:  ECPGColLabel				{ $$ = $1; }
16625 		| ECPGTypeName				{ $$ = $1; }
16626 		| CHAR_P					{ $$ = mm_strdup("char"); }
16627 		| CURRENT_P					{ $$ = mm_strdup("current"); }
16628 		| INPUT_P					{ $$ = mm_strdup("input"); }
16629 		| INT_P						{ $$ = mm_strdup("int"); }
16630 		| TO						{ $$ = mm_strdup("to"); }
16631 		| UNION						{ $$ = mm_strdup("union"); }
16632 		| VALUES					{ $$ = mm_strdup("values"); }
16633 		| ECPGCKeywords				{ $$ = $1; }
16634 		| ECPGunreserved_interval	{ $$ = $1; }
16635 		;
16636 
16637 ECPGColLabel:  ECPGColLabelCommon	{ $$ = $1; }
16638 		| unreserved_keyword		{ $$ = $1; }
16639 		| reserved_keyword			{ $$ = $1; }
16640 		| ECPGKeywords_rest			{ $$ = $1; }
16641 		| CONNECTION				{ $$ = mm_strdup("connection"); }
16642 		;
16643 
16644 ECPGColLabelCommon:  ecpg_ident		{ $$ = $1; }
16645 		| col_name_keyword			{ $$ = $1; }
16646 		| type_func_name_keyword	{ $$ = $1; }
16647 		| ECPGKeywords_vanames		{ $$ = $1; }
16648 		;
16649 
16650 ECPGCKeywords: S_AUTO				{ $$ = mm_strdup("auto"); }
16651 		| S_CONST					{ $$ = mm_strdup("const"); }
16652 		| S_EXTERN					{ $$ = mm_strdup("extern"); }
16653 		| S_REGISTER				{ $$ = mm_strdup("register"); }
16654 		| S_STATIC					{ $$ = mm_strdup("static"); }
16655 		| S_TYPEDEF					{ $$ = mm_strdup("typedef"); }
16656 		| S_VOLATILE				{ $$ = mm_strdup("volatile"); }
16657 		;
16658 
16659 /* "Unreserved" keywords --- available for use as any kind of name.
16660  */
16661 
16662 /*
16663  * The following symbols must be excluded from ECPGColLabel and directly
16664  * included into ColLabel to enable C variables to get names from ECPGColLabel:
16665  * DAY_P, HOUR_P, MINUTE_P, MONTH_P, SECOND_P, YEAR_P.
16666  *
16667  * We also have to exclude CONNECTION, CURRENT, and INPUT for various reasons.
16668  * CONNECTION can be added back in all_unreserved_keyword, but CURRENT and
16669  * INPUT are reserved for ecpg purposes.
16670  *
16671  * The mentioned exclusions are done by $replace_line settings in parse.pl.
16672  */
16673 all_unreserved_keyword: unreserved_keyword	{ $$ = $1; }
16674 		| ECPGunreserved_interval			{ $$ = $1; }
16675 		| CONNECTION						{ $$ = mm_strdup("connection"); }
16676 		;
16677 
16678 ECPGunreserved_interval: DAY_P				{ $$ = mm_strdup("day"); }
16679 		| HOUR_P							{ $$ = mm_strdup("hour"); }
16680 		| MINUTE_P							{ $$ = mm_strdup("minute"); }
16681 		| MONTH_P							{ $$ = mm_strdup("month"); }
16682 		| SECOND_P							{ $$ = mm_strdup("second"); }
16683 		| YEAR_P							{ $$ = mm_strdup("year"); }
16684 		;
16685 
16686 
16687 into_list : coutputvariable | into_list ',' coutputvariable
16688 		;
16689 
16690 ecpgstart: SQL_START	{
16691 				reset_variables();
16692 				pacounter = 1;
16693 			}
16694 		;
16695 
16696 c_args: /*EMPTY*/		{ $$ = EMPTY; }
16697 		| c_list		{ $$ = $1; }
16698 		;
16699 
16700 coutputvariable: cvariable indicator
16701 			{ add_variable_to_head(&argsresult, find_variable($1), find_variable($2)); }
16702 		| cvariable
16703 			{ add_variable_to_head(&argsresult, find_variable($1), &no_indicator); }
16704 		;
16705 
16706 
16707 civarind: cvariable indicator
16708 		{
16709 			if (find_variable($2)->type->type == ECPGt_array)
16710 				mmerror(PARSE_ERROR, ET_ERROR, "arrays of indicators are not allowed on input");
16711 
16712 			add_variable_to_head(&argsinsert, find_variable($1), find_variable($2));
16713 			$$ = create_questionmarks($1, false);
16714 		}
16715 		;
16716 
16717 char_civar: char_variable
16718 		{
16719 			char *ptr = strstr($1, ".arr");
16720 
16721 			if (ptr) /* varchar, we need the struct name here, not the struct element */
16722 				*ptr = '\0';
16723 			add_variable_to_head(&argsinsert, find_variable($1), &no_indicator);
16724 			$$ = $1;
16725 		}
16726 		;
16727 
16728 civar: cvariable
16729 		{
16730 			add_variable_to_head(&argsinsert, find_variable($1), &no_indicator);
16731 			$$ = create_questionmarks($1, false);
16732 		}
16733 		;
16734 
16735 indicator: cvariable				{ check_indicator((find_variable($1))->type); $$ = $1; }
16736 		| SQL_INDICATOR cvariable	{ check_indicator((find_variable($2))->type); $$ = $2; }
16737 		| SQL_INDICATOR name		{ check_indicator((find_variable($2))->type); $$ = $2; }
16738 		;
16739 
16740 cvariable:	CVARIABLE
16741 		{
16742 			/* As long as multidimensional arrays are not implemented we have to check for those here */
16743 			char *ptr = $1;
16744 			int brace_open=0, brace = false;
16745 
16746 			for (; *ptr; ptr++)
16747 			{
16748 				switch (*ptr)
16749 				{
16750 					case '[':
16751 							if (brace)
16752 								mmfatal(PARSE_ERROR, "multidimensional arrays for simple data types are not supported");
16753 							brace_open++;
16754 							break;
16755 					case ']':
16756 							brace_open--;
16757 							if (brace_open == 0)
16758 								brace = true;
16759 							break;
16760 					case '\t':
16761 					case ' ':
16762 							break;
16763 					default:
16764 							if (brace_open == 0)
16765 								brace = false;
16766 							break;
16767 				}
16768 			}
16769 			$$ = $1;
16770 		}
16771 		;
16772 
16773 ecpg_param:	PARAM		{ $$ = make_name(); } ;
16774 
16775 ecpg_bconst:	BCONST		{ $$ = make_name(); } ;
16776 
16777 ecpg_fconst:	FCONST		{ $$ = make_name(); } ;
16778 
16779 ecpg_sconst:
16780 		SCONST
16781 		{
16782 			/* could have been input as '' or $$ */
16783 			$$ = (char *)mm_alloc(strlen($1) + 3);
16784 			$$[0]='\'';
16785 			strcpy($$+1, $1);
16786 			$$[strlen($1)+1]='\'';
16787 			$$[strlen($1)+2]='\0';
16788 			free($1);
16789 		}
16790 		| ECONST
16791 		{
16792 			$$ = (char *)mm_alloc(strlen($1) + 4);
16793 			$$[0]='E';
16794 			$$[1]='\'';
16795 			strcpy($$+2, $1);
16796 			$$[strlen($1)+2]='\'';
16797 			$$[strlen($1)+3]='\0';
16798 			free($1);
16799 		}
16800 		| NCONST
16801 		{
16802 			$$ = (char *)mm_alloc(strlen($1) + 4);
16803 			$$[0]='N';
16804 			$$[1]='\'';
16805 			strcpy($$+2, $1);
16806 			$$[strlen($1)+2]='\'';
16807 			$$[strlen($1)+3]='\0';
16808 			free($1);
16809 		}
16810 		| UCONST	{ $$ = $1; }
16811 		| DOLCONST	{ $$ = $1; }
16812 		;
16813 
16814 ecpg_xconst:	XCONST		{ $$ = make_name(); } ;
16815 
16816 ecpg_ident:	IDENT		{ $$ = make_name(); }
16817 		| CSTRING	{ $$ = make3_str(mm_strdup("\""), $1, mm_strdup("\"")); }
16818 		| UIDENT	{ $$ = $1; }
16819 		;
16820 
16821 quoted_ident_stringvar: name
16822 			{ $$ = make3_str(mm_strdup("\""), $1, mm_strdup("\"")); }
16823 		| char_variable
16824 			{ $$ = make3_str(mm_strdup("("), $1, mm_strdup(")")); }
16825 		;
16826 
16827 /*
16828  * C stuff
16829  */
16830 
16831 c_stuff_item: c_anything			{ $$ = $1; }
16832 		| '(' ')'			{ $$ = mm_strdup("()"); }
16833 		| '(' c_stuff ')'
16834 			{ $$ = cat_str(3, mm_strdup("("), $2, mm_strdup(")")); }
16835 		;
16836 
16837 c_stuff: c_stuff_item			{ $$ = $1; }
16838 		| c_stuff c_stuff_item
16839 			{ $$ = cat2_str($1, $2); }
16840 		;
16841 
16842 c_list: c_term				{ $$ = $1; }
16843 		| c_list ',' c_term	{ $$ = cat_str(3, $1, mm_strdup(","), $3); }
16844 		;
16845 
16846 c_term:  c_stuff			{ $$ = $1; }
16847 		| '{' c_list '}'	{ $$ = cat_str(3, mm_strdup("{"), $2, mm_strdup("}")); }
16848 		;
16849 
16850 c_thing:	c_anything		{ $$ = $1; }
16851 		|	'('		{ $$ = mm_strdup("("); }
16852 		|	')'		{ $$ = mm_strdup(")"); }
16853 		|	','		{ $$ = mm_strdup(","); }
16854 		|	';'		{ $$ = mm_strdup(";"); }
16855 		;
16856 
16857 c_anything:  ecpg_ident				{ $$ = $1; }
16858 		| Iconst			{ $$ = $1; }
16859 		| ecpg_fconst			{ $$ = $1; }
16860 		| ecpg_sconst			{ $$ = $1; }
16861 		| '*'				{ $$ = mm_strdup("*"); }
16862 		| '+'				{ $$ = mm_strdup("+"); }
16863 		| '-'				{ $$ = mm_strdup("-"); }
16864 		| '/'				{ $$ = mm_strdup("/"); }
16865 		| '%'				{ $$ = mm_strdup("%"); }
16866 		| NULL_P			{ $$ = mm_strdup("NULL"); }
16867 		| S_ADD				{ $$ = mm_strdup("+="); }
16868 		| S_AND				{ $$ = mm_strdup("&&"); }
16869 		| S_ANYTHING			{ $$ = make_name(); }
16870 		| S_AUTO			{ $$ = mm_strdup("auto"); }
16871 		| S_CONST			{ $$ = mm_strdup("const"); }
16872 		| S_DEC				{ $$ = mm_strdup("--"); }
16873 		| S_DIV				{ $$ = mm_strdup("/="); }
16874 		| S_DOTPOINT			{ $$ = mm_strdup(".*"); }
16875 		| S_EQUAL			{ $$ = mm_strdup("=="); }
16876 		| S_EXTERN			{ $$ = mm_strdup("extern"); }
16877 		| S_INC				{ $$ = mm_strdup("++"); }
16878 		| S_LSHIFT			{ $$ = mm_strdup("<<"); }
16879 		| S_MEMBER			{ $$ = mm_strdup("->"); }
16880 		| S_MEMPOINT			{ $$ = mm_strdup("->*"); }
16881 		| S_MOD				{ $$ = mm_strdup("%="); }
16882 		| S_MUL				{ $$ = mm_strdup("*="); }
16883 		| S_NEQUAL			{ $$ = mm_strdup("!="); }
16884 		| S_OR				{ $$ = mm_strdup("||"); }
16885 		| S_REGISTER			{ $$ = mm_strdup("register"); }
16886 		| S_RSHIFT			{ $$ = mm_strdup(">>"); }
16887 		| S_STATIC			{ $$ = mm_strdup("static"); }
16888 		| S_SUB				{ $$ = mm_strdup("-="); }
16889 		| S_TYPEDEF			{ $$ = mm_strdup("typedef"); }
16890 		| S_VOLATILE			{ $$ = mm_strdup("volatile"); }
16891 		| SQL_BOOL			{ $$ = mm_strdup("bool"); }
16892 		| ENUM_P			{ $$ = mm_strdup("enum"); }
16893 		| HOUR_P			{ $$ = mm_strdup("hour"); }
16894 		| INT_P				{ $$ = mm_strdup("int"); }
16895 		| SQL_LONG			{ $$ = mm_strdup("long"); }
16896 		| MINUTE_P			{ $$ = mm_strdup("minute"); }
16897 		| MONTH_P			{ $$ = mm_strdup("month"); }
16898 		| SECOND_P			{ $$ = mm_strdup("second"); }
16899 		| SQL_SHORT			{ $$ = mm_strdup("short"); }
16900 		| SQL_SIGNED			{ $$ = mm_strdup("signed"); }
16901 		| SQL_STRUCT			{ $$ = mm_strdup("struct"); }
16902 		| SQL_UNSIGNED			{ $$ = mm_strdup("unsigned"); }
16903 		| YEAR_P			{ $$ = mm_strdup("year"); }
16904 		| CHAR_P			{ $$ = mm_strdup("char"); }
16905 		| FLOAT_P			{ $$ = mm_strdup("float"); }
16906 		| TO				{ $$ = mm_strdup("to"); }
16907 		| UNION				{ $$ = mm_strdup("union"); }
16908 		| VARCHAR			{ $$ = mm_strdup("varchar"); }
16909 		| '['				{ $$ = mm_strdup("["); }
16910 		| ']'				{ $$ = mm_strdup("]"); }
16911 		| '='				{ $$ = mm_strdup("="); }
16912 		| ':'				{ $$ = mm_strdup(":"); }
16913 		;
16914 
16915 DeallocateStmt: DEALLOCATE prepared_name                { $$ = $2; }
16916                 | DEALLOCATE PREPARE prepared_name      { $$ = $3; }
16917                 | DEALLOCATE ALL                        { $$ = mm_strdup("all"); }
16918                 | DEALLOCATE PREPARE ALL                { $$ = mm_strdup("all"); }
16919                 ;
16920 
16921 Iresult:        Iconst				{ $$ = $1; }
16922                 | '(' Iresult ')'		{ $$ = cat_str(3, mm_strdup("("), $2, mm_strdup(")")); }
16923                 | Iresult '+' Iresult		{ $$ = cat_str(3, $1, mm_strdup("+"), $3); }
16924                 | Iresult '-' Iresult		{ $$ = cat_str(3, $1, mm_strdup("-"), $3); }
16925                 | Iresult '*' Iresult		{ $$ = cat_str(3, $1, mm_strdup("*"), $3); }
16926                 | Iresult '/' Iresult		{ $$ = cat_str(3, $1, mm_strdup("/"), $3); }
16927                 | Iresult '%' Iresult		{ $$ = cat_str(3, $1, mm_strdup("%"), $3); }
16928                 | ecpg_sconst			{ $$ = $1; }
16929                 | ColId				{ $$ = $1; }
16930 		| ColId '(' var_type ')'        { if (pg_strcasecmp($1, "sizeof") != 0)
16931 							mmerror(PARSE_ERROR, ET_ERROR, "operator not allowed in variable definition");
16932 						  else
16933 							$$ = cat_str(4, $1, mm_strdup("("), $3.type_str, mm_strdup(")"));
16934 						}
16935                 ;
16936 
16937 execute_rest: /* EMPTY */	{ $$ = EMPTY; }
16938 	| ecpg_using opt_ecpg_into  { $$ = EMPTY; }
16939 	| ecpg_into ecpg_using  { $$ = EMPTY; }
16940 	| ecpg_into				{ $$ = EMPTY; }
16941 	;
16942 
16943 ecpg_into: INTO into_list	{ $$ = EMPTY; }
16944 	| into_descriptor		{ $$ = $1; }
16945 	;
16946 
16947 opt_ecpg_into:	/* EMPTY */	{ $$ = EMPTY; }
16948 	| ecpg_into		{ $$ = $1; }
16949 	;
16950 
16951 ecpg_fetch_into: ecpg_into	{ $$ = $1; }
16952 	| using_descriptor
16953 	{
16954 		struct variable *var;
16955 
16956 		var = argsinsert->variable;
16957 		remove_variable_from_list(&argsinsert, var);
16958 		add_variable_to_head(&argsresult, var, &no_indicator);
16959 		$$ = $1;
16960 	}
16961 	;
16962 
16963 opt_ecpg_fetch_into:	/* EMPTY */	{ $$ = EMPTY; }
16964 	| ecpg_fetch_into		{ $$ = $1; }
16965 	;
16966 
16967 %%
16968 
16969 void base_yyerror(const char *error)
16970 {
16971 	/* translator: %s is typically the translation of "syntax error" */
16972 	mmerror(PARSE_ERROR, ET_ERROR, "%s at or near \"%s\"",
16973 			_(error), token_start ? token_start : base_yytext);
16974 }
16975 
parser_init(void)16976 void parser_init(void)
16977 {
16978  /* This function is empty. It only exists for compatibility with the backend parser right now. */
16979 }
16980