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_CALL 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> CreateRoleStmt
626 %type <str> opt_with
627 %type <str> OptRoleList
628 %type <str> AlterOptRoleList
629 %type <str> AlterOptRoleElem
630 %type <str> CreateOptRoleElem
631 %type <str> CreateUserStmt
632 %type <str> AlterRoleStmt
633 %type <str> opt_in_database
634 %type <str> AlterRoleSetStmt
635 %type <str> DropRoleStmt
636 %type <str> CreateGroupStmt
637 %type <str> AlterGroupStmt
638 %type <str> add_drop
639 %type <str> CreateSchemaStmt
640 %type <str> OptSchemaName
641 %type <str> OptSchemaEltList
642 %type <str> schema_stmt
643 %type <str> VariableSetStmt
644 %type <str> set_rest
645 %type <str> generic_set
646 %type <str> set_rest_more
647 %type <str> var_name
648 %type <str> var_list
649 %type <str> var_value
650 %type <str> iso_level
651 %type <str> opt_boolean_or_string
652 %type <str> zone_value
653 %type <str> opt_encoding
654 %type <str> NonReservedWord_or_Sconst
655 %type <str> VariableResetStmt
656 %type <str> reset_rest
657 %type <str> generic_reset
658 %type <str> SetResetClause
659 %type <str> FunctionSetResetClause
660 %type <str> VariableShowStmt
661 %type <str> ConstraintsSetStmt
662 %type <str> constraints_set_list
663 %type <str> constraints_set_mode
664 %type <str> CheckPointStmt
665 %type <str> DiscardStmt
666 %type <str> AlterTableStmt
667 %type <str> alter_table_cmds
668 %type <str> partition_cmd
669 %type <str> alter_table_cmd
670 %type <str> alter_column_default
671 %type <str> opt_drop_behavior
672 %type <str> opt_collate_clause
673 %type <str> alter_using
674 %type <str> replica_identity
675 %type <str> reloptions
676 %type <str> opt_reloptions
677 %type <str> reloption_list
678 %type <str> reloption_elem
679 %type <str> alter_identity_column_option_list
680 %type <str> alter_identity_column_option
681 %type <str> ForValues
682 %type <str> partbound_datum
683 %type <str> partbound_datum_list
684 %type <str> range_datum_list
685 %type <str> PartitionRangeDatum
686 %type <str> AlterCompositeTypeStmt
687 %type <str> alter_type_cmds
688 %type <str> alter_type_cmd
689 %type <str> ClosePortalStmt
690 %type <str> CopyStmt
691 %type <str> copy_from
692 %type <str> opt_program
693 %type <str> copy_file_name
694 %type <str> copy_options
695 %type <str> copy_opt_list
696 %type <str> copy_opt_item
697 %type <str> opt_binary
698 %type <str> opt_oids
699 %type <str> copy_delimiter
700 %type <str> opt_using
701 %type <str> copy_generic_opt_list
702 %type <str> copy_generic_opt_elem
703 %type <str> copy_generic_opt_arg
704 %type <str> copy_generic_opt_arg_list
705 %type <str> copy_generic_opt_arg_list_item
706 %type <str> CreateStmt
707 %type <str> OptTemp
708 %type <str> OptTableElementList
709 %type <str> OptTypedTableElementList
710 %type <str> TableElementList
711 %type <str> TypedTableElementList
712 %type <str> TableElement
713 %type <str> TypedTableElement
714 %type <str> columnDef
715 %type <str> columnOptions
716 %type <str> ColQualList
717 %type <str> ColConstraint
718 %type <str> ColConstraintElem
719 %type <str> generated_when
720 %type <str> ConstraintAttr
721 %type <str> TableLikeClause
722 %type <str> TableLikeOptionList
723 %type <str> TableLikeOption
724 %type <str> TableConstraint
725 %type <str> ConstraintElem
726 %type <str> opt_no_inherit
727 %type <str> opt_column_list
728 %type <str> columnList
729 %type <str> columnElem
730 %type <str> key_match
731 %type <str> ExclusionConstraintList
732 %type <str> ExclusionConstraintElem
733 %type <str> ExclusionWhereClause
734 %type <str> key_actions
735 %type <str> key_update
736 %type <str> key_delete
737 %type <str> key_action
738 %type <str> OptInherit
739 %type <str> OptPartitionSpec
740 %type <str> PartitionSpec
741 %type <str> part_strategy
742 %type <str> part_params
743 %type <str> part_elem
744 %type <str> OptWith
745 %type <str> OnCommitOption
746 %type <str> OptTableSpace
747 %type <str> OptConsTableSpace
748 %type <str> ExistingIndex
749 %type <str> CreateStatsStmt
750 %type <str> create_as_target
751 %type <str> opt_with_data
752 %type <str> CreateMatViewStmt
753 %type <str> create_mv_target
754 %type <str> OptNoLog
755 %type <str> RefreshMatViewStmt
756 %type <str> CreateSeqStmt
757 %type <str> AlterSeqStmt
758 %type <str> OptSeqOptList
759 %type <str> OptParenthesizedSeqOptList
760 %type <str> SeqOptList
761 %type <str> SeqOptElem
762 %type <str> opt_by
763 %type <str> NumericOnly
764 %type <str> NumericOnly_list
765 %type <str> CreatePLangStmt
766 %type <str> opt_trusted
767 %type <str> handler_name
768 %type <str> opt_inline_handler
769 %type <str> validator_clause
770 %type <str> opt_validator
771 %type <str> DropPLangStmt
772 %type <str> opt_procedural
773 %type <str> CreateTableSpaceStmt
774 %type <str> OptTableSpaceOwner
775 %type <str> DropTableSpaceStmt
776 %type <str> CreateExtensionStmt
777 %type <str> create_extension_opt_list
778 %type <str> create_extension_opt_item
779 %type <str> AlterExtensionStmt
780 %type <str> alter_extension_opt_list
781 %type <str> alter_extension_opt_item
782 %type <str> AlterExtensionContentsStmt
783 %type <str> CreateFdwStmt
784 %type <str> fdw_option
785 %type <str> fdw_options
786 %type <str> opt_fdw_options
787 %type <str> AlterFdwStmt
788 %type <str> create_generic_options
789 %type <str> generic_option_list
790 %type <str> alter_generic_options
791 %type <str> alter_generic_option_list
792 %type <str> alter_generic_option_elem
793 %type <str> generic_option_elem
794 %type <str> generic_option_name
795 %type <str> generic_option_arg
796 %type <str> CreateForeignServerStmt
797 %type <str> opt_type
798 %type <str> foreign_server_version
799 %type <str> opt_foreign_server_version
800 %type <str> AlterForeignServerStmt
801 %type <str> CreateForeignTableStmt
802 %type <str> AlterForeignTableStmt
803 %type <str> ImportForeignSchemaStmt
804 %type <str> import_qualification_type
805 %type <str> import_qualification
806 %type <str> CreateUserMappingStmt
807 %type <str> auth_ident
808 %type <str> DropUserMappingStmt
809 %type <str> AlterUserMappingStmt
810 %type <str> CreatePolicyStmt
811 %type <str> AlterPolicyStmt
812 %type <str> RowSecurityOptionalExpr
813 %type <str> RowSecurityOptionalWithCheck
814 %type <str> RowSecurityDefaultToRole
815 %type <str> RowSecurityOptionalToRole
816 %type <str> RowSecurityDefaultPermissive
817 %type <str> RowSecurityDefaultForCmd
818 %type <str> row_security_cmd
819 %type <str> CreateAmStmt
820 %type <str> CreateTrigStmt
821 %type <str> TriggerActionTime
822 %type <str> TriggerEvents
823 %type <str> TriggerOneEvent
824 %type <str> TriggerReferencing
825 %type <str> TriggerTransitions
826 %type <str> TriggerTransition
827 %type <str> TransitionOldOrNew
828 %type <str> TransitionRowOrTable
829 %type <str> TransitionRelName
830 %type <str> TriggerForSpec
831 %type <str> TriggerForOptEach
832 %type <str> TriggerForType
833 %type <str> TriggerWhen
834 %type <str> TriggerFuncArgs
835 %type <str> TriggerFuncArg
836 %type <str> OptConstrFromTable
837 %type <str> ConstraintAttributeSpec
838 %type <str> ConstraintAttributeElem
839 %type <str> CreateEventTrigStmt
840 %type <str> event_trigger_when_list
841 %type <str> event_trigger_when_item
842 %type <str> event_trigger_value_list
843 %type <str> AlterEventTrigStmt
844 %type <str> enable_trigger
845 %type <str> CreateAssertStmt
846 %type <str> DropAssertStmt
847 %type <str> DefineStmt
848 %type <str> definition
849 %type <str> def_list
850 %type <str> def_elem
851 %type <str> def_arg
852 %type <str> old_aggr_definition
853 %type <str> old_aggr_list
854 %type <str> old_aggr_elem
855 %type <str> opt_enum_val_list
856 %type <str> enum_val_list
857 %type <str> AlterEnumStmt
858 %type <str> opt_if_not_exists
859 %type <str> CreateOpClassStmt
860 %type <str> opclass_item_list
861 %type <str> opclass_item
862 %type <str> opt_default
863 %type <str> opt_opfamily
864 %type <str> opclass_purpose
865 %type <str> opt_recheck
866 %type <str> CreateOpFamilyStmt
867 %type <str> AlterOpFamilyStmt
868 %type <str> opclass_drop_list
869 %type <str> opclass_drop
870 %type <str> DropOpClassStmt
871 %type <str> DropOpFamilyStmt
872 %type <str> DropOwnedStmt
873 %type <str> ReassignOwnedStmt
874 %type <str> DropStmt
875 %type <str> drop_type_any_name
876 %type <str> drop_type_name
877 %type <str> drop_type_name_on_any_name
878 %type <str> any_name_list
879 %type <str> any_name
880 %type <str> attrs
881 %type <str> type_name_list
882 %type <str> TruncateStmt
883 %type <str> opt_restart_seqs
884 %type <str> CommentStmt
885 %type <str> comment_type_any_name
886 %type <str> comment_type_name
887 %type <str> comment_text
888 %type <str> SecLabelStmt
889 %type <str> opt_provider
890 %type <str> security_label_type_any_name
891 %type <str> security_label_type_name
892 %type <str> security_label
893 %type <str> FetchStmt
894 %type <str> fetch_args
895 %type <str> from_in
896 %type <str> opt_from_in
897 %type <str> GrantStmt
898 %type <str> RevokeStmt
899 %type <str> privileges
900 %type <str> privilege_list
901 %type <str> privilege
902 %type <str> privilege_target
903 %type <str> grantee_list
904 %type <str> grantee
905 %type <str> opt_grant_grant_option
906 %type <str> GrantRoleStmt
907 %type <str> RevokeRoleStmt
908 %type <str> opt_grant_admin_option
909 %type <str> opt_granted_by
910 %type <str> AlterDefaultPrivilegesStmt
911 %type <str> DefACLOptionList
912 %type <str> DefACLOption
913 %type <str> DefACLAction
914 %type <str> defacl_privilege_target
915 %type <str> IndexStmt
916 %type <str> opt_unique
917 %type <str> opt_concurrently
918 %type <str> opt_index_name
919 %type <str> access_method_clause
920 %type <str> index_params
921 %type <str> index_elem
922 %type <str> opt_collate
923 %type <str> opt_class
924 %type <str> opt_asc_desc
925 %type <str> opt_nulls_order
926 %type <str> CreateFunctionStmt
927 %type <str> opt_or_replace
928 %type <str> func_args
929 %type <str> func_args_list
930 %type <str> function_with_argtypes_list
931 %type <str> function_with_argtypes
932 %type <str> func_args_with_defaults
933 %type <str> func_args_with_defaults_list
934 %type <str> func_arg
935 %type <str> arg_class
936 %type <str> param_name
937 %type <str> func_return
938 %type <str> func_type
939 %type <str> func_arg_with_default
940 %type <str> aggr_arg
941 %type <str> aggr_args
942 %type <str> aggr_args_list
943 %type <str> aggregate_with_argtypes
944 %type <str> aggregate_with_argtypes_list
945 %type <str> createfunc_opt_list
946 %type <str> common_func_opt_item
947 %type <str> createfunc_opt_item
948 %type <str> func_as
949 %type <str> transform_type_list
950 %type <str> opt_definition
951 %type <str> table_func_column
952 %type <str> table_func_column_list
953 %type <str> AlterFunctionStmt
954 %type <str> alterfunc_opt_list
955 %type <str> opt_restrict
956 %type <str> RemoveFuncStmt
957 %type <str> RemoveAggrStmt
958 %type <str> RemoveOperStmt
959 %type <str> oper_argtypes
960 %type <str> any_operator
961 %type <str> operator_with_argtypes_list
962 %type <str> operator_with_argtypes
963 %type <str> DoStmt
964 %type <str> dostmt_opt_list
965 %type <str> dostmt_opt_item
966 %type <str> CreateCastStmt
967 %type <str> cast_context
968 %type <str> DropCastStmt
969 %type <str> opt_if_exists
970 %type <str> CreateTransformStmt
971 %type <str> transform_element_list
972 %type <str> DropTransformStmt
973 %type <str> ReindexStmt
974 %type <str> reindex_target_type
975 %type <str> reindex_target_multitable
976 %type <str> reindex_option_list
977 %type <str> reindex_option_elem
978 %type <str> AlterTblSpcStmt
979 %type <str> RenameStmt
980 %type <str> opt_column
981 %type <str> opt_set_data
982 %type <str> AlterObjectDependsStmt
983 %type <str> AlterObjectSchemaStmt
984 %type <str> AlterOperatorStmt
985 %type <str> operator_def_list
986 %type <str> operator_def_elem
987 %type <str> operator_def_arg
988 %type <str> AlterOwnerStmt
989 %type <str> CreatePublicationStmt
990 %type <str> opt_publication_for_tables
991 %type <str> publication_for_tables
992 %type <str> AlterPublicationStmt
993 %type <str> CreateSubscriptionStmt
994 %type <str> publication_name_list
995 %type <str> publication_name_item
996 %type <str> AlterSubscriptionStmt
997 %type <str> DropSubscriptionStmt
998 %type <str> RuleStmt
999 %type <str> RuleActionList
1000 %type <str> RuleActionMulti
1001 %type <str> RuleActionStmt
1002 %type <str> RuleActionStmtOrEmpty
1003 %type <str> event
1004 %type <str> opt_instead
1005 %type <str> NotifyStmt
1006 %type <str> notify_payload
1007 %type <str> ListenStmt
1008 %type <str> UnlistenStmt
1009 %type <str> TransactionStmt
1010 %type <str> opt_transaction
1011 %type <str> transaction_mode_item
1012 %type <str> transaction_mode_list
1013 %type <str> transaction_mode_list_or_empty
1014 %type <str> ViewStmt
1015 %type <str> opt_check_option
1016 %type <str> LoadStmt
1017 %type <str> CreatedbStmt
1018 %type <str> createdb_opt_list
1019 %type <str> createdb_opt_items
1020 %type <str> createdb_opt_item
1021 %type <str> createdb_opt_name
1022 %type <str> opt_equal
1023 %type <str> AlterDatabaseStmt
1024 %type <str> AlterDatabaseSetStmt
1025 %type <str> DropdbStmt
1026 %type <str> AlterCollationStmt
1027 %type <str> AlterSystemStmt
1028 %type <str> CreateDomainStmt
1029 %type <str> AlterDomainStmt
1030 %type <str> opt_as
1031 %type <str> AlterTSDictionaryStmt
1032 %type <str> AlterTSConfigurationStmt
1033 %type <str> any_with
1034 %type <str> CreateConversionStmt
1035 %type <str> ClusterStmt
1036 %type <str> cluster_index_specification
1037 %type <str> VacuumStmt
1038 %type <str> vacuum_option_list
1039 %type <str> vacuum_option_elem
1040 %type <str> AnalyzeStmt
1041 %type <str> analyze_keyword
1042 %type <str> opt_verbose
1043 %type <str> opt_full
1044 %type <str> opt_freeze
1045 %type <str> opt_name_list
1046 %type <str> ExplainStmt
1047 %type <str> ExplainableStmt
1048 %type <str> explain_option_list
1049 %type <str> explain_option_elem
1050 %type <str> explain_option_name
1051 %type <str> explain_option_arg
1052 %type <prep> PrepareStmt
1053 %type <str> prep_type_clause
1054 %type <str> PreparableStmt
1055 %type <str> ExecuteStmt
1056 %type <str> execute_param_clause
1057 %type <str> InsertStmt
1058 %type <str> insert_target
1059 %type <str> insert_rest
1060 %type <str> override_kind
1061 %type <str> insert_column_list
1062 %type <str> insert_column_item
1063 %type <str> opt_on_conflict
1064 %type <str> opt_conf_expr
1065 %type <str> returning_clause
1066 %type <str> DeleteStmt
1067 %type <str> using_clause
1068 %type <str> LockStmt
1069 %type <str> opt_lock
1070 %type <str> lock_type
1071 %type <str> opt_nowait
1072 %type <str> opt_nowait_or_skip
1073 %type <str> UpdateStmt
1074 %type <str> set_clause_list
1075 %type <str> set_clause
1076 %type <str> set_target
1077 %type <str> set_target_list
1078 %type <str> DeclareCursorStmt
1079 %type <str> cursor_name
1080 %type <str> cursor_options
1081 %type <str> opt_hold
1082 %type <str> SelectStmt
1083 %type <str> select_with_parens
1084 %type <str> select_no_parens
1085 %type <str> select_clause
1086 %type <str> simple_select
1087 %type <str> with_clause
1088 %type <str> cte_list
1089 %type <str> common_table_expr
1090 %type <str> opt_with_clause
1091 %type <str> into_clause
1092 %type <str> OptTempTableName
1093 %type <str> opt_table
1094 %type <str> all_or_distinct
1095 %type <str> distinct_clause
1096 %type <str> opt_all_clause
1097 %type <str> opt_sort_clause
1098 %type <str> sort_clause
1099 %type <str> sortby_list
1100 %type <str> sortby
1101 %type <str> select_limit
1102 %type <str> opt_select_limit
1103 %type <str> limit_clause
1104 %type <str> offset_clause
1105 %type <str> select_limit_value
1106 %type <str> select_offset_value
1107 %type <str> select_fetch_first_value
1108 %type <str> I_or_F_const
1109 %type <str> row_or_rows
1110 %type <str> first_or_next
1111 %type <str> group_clause
1112 %type <str> group_by_list
1113 %type <str> group_by_item
1114 %type <str> empty_grouping_set
1115 %type <str> rollup_clause
1116 %type <str> cube_clause
1117 %type <str> grouping_sets_clause
1118 %type <str> having_clause
1119 %type <str> for_locking_clause
1120 %type <str> opt_for_locking_clause
1121 %type <str> for_locking_items
1122 %type <str> for_locking_item
1123 %type <str> for_locking_strength
1124 %type <str> locked_rels_list
1125 %type <str> values_clause
1126 %type <str> from_clause
1127 %type <str> from_list
1128 %type <str> table_ref
1129 %type <str> joined_table
1130 %type <str> alias_clause
1131 %type <str> opt_alias_clause
1132 %type <str> func_alias_clause
1133 %type <str> join_type
1134 %type <str> join_outer
1135 %type <str> join_qual
1136 %type <str> relation_expr
1137 %type <str> relation_expr_list
1138 %type <str> relation_expr_opt_alias
1139 %type <str> tablesample_clause
1140 %type <str> opt_repeatable_clause
1141 %type <str> func_table
1142 %type <str> rowsfrom_item
1143 %type <str> rowsfrom_list
1144 %type <str> opt_col_def_list
1145 %type <str> opt_ordinality
1146 %type <str> where_clause
1147 %type <str> where_or_current_clause
1148 %type <str> OptTableFuncElementList
1149 %type <str> TableFuncElementList
1150 %type <str> TableFuncElement
1151 %type <str> xmltable
1152 %type <str> xmltable_column_list
1153 %type <str> xmltable_column_el
1154 %type <str> xmltable_column_option_list
1155 %type <str> xmltable_column_option_el
1156 %type <str> xml_namespace_list
1157 %type <str> xml_namespace_el
1158 %type <str> Typename
1159 %type <index> opt_array_bounds
1160 %type <str> SimpleTypename
1161 %type <str> ConstTypename
1162 %type <str> GenericType
1163 %type <str> opt_type_modifiers
1164 %type <str> Numeric
1165 %type <str> opt_float
1166 %type <str> Bit
1167 %type <str> ConstBit
1168 %type <str> BitWithLength
1169 %type <str> BitWithoutLength
1170 %type <str> Character
1171 %type <str> ConstCharacter
1172 %type <str> CharacterWithLength
1173 %type <str> CharacterWithoutLength
1174 %type <str> character
1175 %type <str> opt_varying
1176 %type <str> ConstDatetime
1177 %type <str> ConstInterval
1178 %type <str> opt_timezone
1179 %type <str> opt_interval
1180 %type <str> interval_second
1181 %type <str> a_expr
1182 %type <str> b_expr
1183 %type <str> c_expr
1184 %type <str> func_application
1185 %type <str> func_expr
1186 %type <str> func_expr_windowless
1187 %type <str> func_expr_common_subexpr
1188 %type <str> xml_root_version
1189 %type <str> opt_xml_root_standalone
1190 %type <str> xml_attributes
1191 %type <str> xml_attribute_list
1192 %type <str> xml_attribute_el
1193 %type <str> document_or_content
1194 %type <str> xml_whitespace_option
1195 %type <str> xmlexists_argument
1196 %type <str> within_group_clause
1197 %type <str> filter_clause
1198 %type <str> window_clause
1199 %type <str> window_definition_list
1200 %type <str> window_definition
1201 %type <str> over_clause
1202 %type <str> window_specification
1203 %type <str> opt_existing_window_name
1204 %type <str> opt_partition_clause
1205 %type <str> opt_frame_clause
1206 %type <str> frame_extent
1207 %type <str> frame_bound
1208 %type <str> row
1209 %type <str> explicit_row
1210 %type <str> implicit_row
1211 %type <str> sub_type
1212 %type <str> all_Op
1213 %type <str> MathOp
1214 %type <str> qual_Op
1215 %type <str> qual_all_Op
1216 %type <str> subquery_Op
1217 %type <str> expr_list
1218 %type <str> func_arg_list
1219 %type <str> func_arg_expr
1220 %type <str> type_list
1221 %type <str> array_expr
1222 %type <str> array_expr_list
1223 %type <str> extract_list
1224 %type <str> extract_arg
1225 %type <str> overlay_list
1226 %type <str> overlay_placing
1227 %type <str> position_list
1228 %type <str> substr_list
1229 %type <str> substr_from
1230 %type <str> substr_for
1231 %type <str> trim_list
1232 %type <str> in_expr
1233 %type <str> case_expr
1234 %type <str> when_clause_list
1235 %type <str> when_clause
1236 %type <str> case_default
1237 %type <str> case_arg
1238 %type <str> columnref
1239 %type <str> indirection_el
1240 %type <str> opt_slice_bound
1241 %type <str> indirection
1242 %type <str> opt_indirection
1243 %type <str> opt_asymmetric
1244 %type <str> opt_target_list
1245 %type <str> target_list
1246 %type <str> target_el
1247 %type <str> qualified_name_list
1248 %type <str> qualified_name
1249 %type <str> name_list
1250 %type <str> name
1251 %type <str> database_name
1252 %type <str> access_method
1253 %type <str> attr_name
1254 %type <str> index_name
1255 %type <str> file_name
1256 %type <str> func_name
1257 %type <str> AexprConst
1258 %type <str> Iconst
1259 %type <str> SignedIconst
1260 %type <str> RoleId
1261 %type <str> RoleSpec
1262 %type <str> role_list
1263 %type <str> NonReservedWord
1264 %type <str> unreserved_keyword
1265 %type <str> col_name_keyword
1266 %type <str> type_func_name_keyword
1267 %type <str> reserved_keyword
1268 /* ecpgtype */
1269 /* src/interfaces/ecpg/preproc/ecpg.type */
1270 %type <str> ECPGAllocateDescr
1271 %type <str> ECPGCKeywords
1272 %type <str> ECPGColId
1273 %type <str> ECPGColLabel
1274 %type <str> ECPGColLabelCommon
1275 %type <str> ECPGConnect
1276 %type <str> ECPGCursorStmt
1277 %type <str> ECPGDeallocateDescr
1278 %type <str> ECPGDeclaration
1279 %type <str> ECPGDeclare
1280 %type <str> ECPGDescribe
1281 %type <str> ECPGDisconnect
1282 %type <str> ECPGExecuteImmediateStmt
1283 %type <str> ECPGFree
1284 %type <str> ECPGGetDescHeaderItem
1285 %type <str> ECPGGetDescItem
1286 %type <str> ECPGGetDescriptorHeader
1287 %type <str> ECPGKeywords
1288 %type <str> ECPGKeywords_rest
1289 %type <str> ECPGKeywords_vanames
1290 %type <str> ECPGOpen
1291 %type <str> ECPGSetAutocommit
1292 %type <str> ECPGSetConnection
1293 %type <str> ECPGSetDescHeaderItem
1294 %type <str> ECPGSetDescItem
1295 %type <str> ECPGSetDescriptorHeader
1296 %type <str> ECPGTypeName
1297 %type <str> ECPGTypedef
1298 %type <str> ECPGVar
1299 %type <str> ECPGVarDeclaration
1300 %type <str> ECPGWhenever
1301 %type <str> ECPGunreserved_interval
1302 %type <str> UsingConst
1303 %type <str> UsingValue
1304 %type <str> all_unreserved_keyword
1305 %type <str> c_anything
1306 %type <str> c_args
1307 %type <str> c_list
1308 %type <str> c_stuff
1309 %type <str> c_stuff_item
1310 %type <str> c_term
1311 %type <str> c_thing
1312 %type <str> char_variable
1313 %type <str> char_civar
1314 %type <str> civar
1315 %type <str> civarind
1316 %type <str> ColId
1317 %type <str> ColLabel
1318 %type <str> connect_options
1319 %type <str> connection_object
1320 %type <str> connection_target
1321 %type <str> coutputvariable
1322 %type <str> cvariable
1323 %type <str> db_prefix
1324 %type <str> CreateAsStmt
1325 %type <str> DeallocateStmt
1326 %type <str> dis_name
1327 %type <str> ecpg_bconst
1328 %type <str> ecpg_fconst
1329 %type <str> ecpg_ident
1330 %type <str> ecpg_interval
1331 %type <str> ecpg_into
1332 %type <str> ecpg_fetch_into
1333 %type <str> ecpg_param
1334 %type <str> ecpg_sconst
1335 %type <str> ecpg_using
1336 %type <str> ecpg_xconst
1337 %type <str> enum_definition
1338 %type <str> enum_type
1339 %type <str> execstring
1340 %type <str> execute_rest
1341 %type <str> indicator
1342 %type <str> into_descriptor
1343 %type <str> into_sqlda
1344 %type <str> Iresult
1345 %type <str> on_off
1346 %type <str> opt_bit_field
1347 %type <str> opt_connection_name
1348 %type <str> opt_database_name
1349 %type <str> opt_ecpg_into
1350 %type <str> opt_ecpg_fetch_into
1351 %type <str> opt_ecpg_using
1352 %type <str> opt_initializer
1353 %type <str> opt_options
1354 %type <str> opt_output
1355 %type <str> opt_pointer
1356 %type <str> opt_port
1357 %type <str> opt_reference
1358 %type <str> opt_scale
1359 %type <str> opt_server
1360 %type <str> opt_user
1361 %type <str> opt_opt_value
1362 %type <str> ora_user
1363 %type <str> precision
1364 %type <str> prepared_name
1365 %type <str> quoted_ident_stringvar
1366 %type <str> s_struct_union
1367 %type <str> server
1368 %type <str> server_name
1369 %type <str> single_vt_declaration
1370 %type <str> storage_clause
1371 %type <str> storage_declaration
1372 %type <str> storage_modifier
1373 %type <str> struct_union_type
1374 %type <str> struct_union_type_with_symbol
1375 %type <str> symbol
1376 %type <str> type_declaration
1377 %type <str> type_function_name
1378 %type <str> user_name
1379 %type <str> using_descriptor
1380 %type <str> var_declaration
1381 %type <str> var_type_declarations
1382 %type <str> variable
1383 %type <str> variable_declarations
1384 %type <str> variable_list
1385 %type <str> vt_declarations
1386 
1387 %type <str> Op
1388 %type <str> IntConstVar
1389 %type <str> AllConstVar
1390 %type <str> CSTRING
1391 %type <str> CPP_LINE
1392 %type <str> CVARIABLE
1393 %type <str> DOLCONST
1394 %type <str> ECONST
1395 %type <str> NCONST
1396 %type <str> SCONST
1397 %type <str> UCONST
1398 %type <str> UIDENT
1399 
1400 %type  <struct_union> s_struct_union_symbol
1401 
1402 %type  <descriptor> ECPGGetDescriptor
1403 %type  <descriptor> ECPGSetDescriptor
1404 
1405 %type  <type_enum> simple_type
1406 %type  <type_enum> signed_type
1407 %type  <type_enum> unsigned_type
1408 
1409 %type  <dtype_enum> descriptor_item
1410 %type  <dtype_enum> desc_header_item
1411 
1412 %type  <type>   var_type
1413 
1414 %type  <action> action
1415 /* orig_tokens */
1416  %token IDENT FCONST SCONST BCONST XCONST Op
1417  %token ICONST PARAM
1418  %token TYPECAST DOT_DOT COLON_EQUALS EQUALS_GREATER
1419  %token LESS_EQUALS GREATER_EQUALS NOT_EQUALS
1420 
1421 
1422 
1423 
1424 
1425 
1426 
1427 
1428 
1429  %token ABORT_P ABSOLUTE_P ACCESS ACTION ADD_P ADMIN AFTER
1430  AGGREGATE ALL ALSO ALTER ALWAYS ANALYSE ANALYZE AND ANY ARRAY AS ASC
1431  ASSERTION ASSIGNMENT ASYMMETRIC AT ATTACH ATTRIBUTE AUTHORIZATION
1432 
1433  BACKWARD BEFORE BEGIN_P BETWEEN BIGINT BINARY BIT
1434  BOOLEAN_P BOTH BY
1435 
1436  CACHE CALLED CASCADE CASCADED CASE CAST CATALOG_P CHAIN CHAR_P
1437  CHARACTER CHARACTERISTICS CHECK CHECKPOINT CLASS CLOSE
1438  CLUSTER COALESCE COLLATE COLLATION COLUMN COLUMNS COMMENT COMMENTS COMMIT
1439  COMMITTED CONCURRENTLY CONFIGURATION CONFLICT CONNECTION CONSTRAINT
1440  CONSTRAINTS CONTENT_P CONTINUE_P CONVERSION_P COPY COST CREATE
1441  CROSS CSV CUBE CURRENT_P
1442  CURRENT_CATALOG CURRENT_DATE CURRENT_ROLE CURRENT_SCHEMA
1443  CURRENT_TIME CURRENT_TIMESTAMP CURRENT_USER CURSOR CYCLE
1444 
1445  DATA_P DATABASE DAY_P DEALLOCATE DEC DECIMAL_P DECLARE DEFAULT DEFAULTS
1446  DEFERRABLE DEFERRED DEFINER DELETE_P DELIMITER DELIMITERS DEPENDS DESC
1447  DETACH DICTIONARY DISABLE_P DISCARD DISTINCT DO DOCUMENT_P DOMAIN_P
1448  DOUBLE_P DROP
1449 
1450  EACH ELSE ENABLE_P ENCODING ENCRYPTED END_P ENUM_P ESCAPE EVENT EXCEPT
1451  EXCLUDE EXCLUDING EXCLUSIVE EXECUTE EXISTS EXPLAIN
1452  EXTENSION EXTERNAL EXTRACT
1453 
1454  FALSE_P FAMILY FETCH FILTER FIRST_P FLOAT_P FOLLOWING FOR
1455  FORCE FOREIGN FORWARD FREEZE FROM FULL FUNCTION FUNCTIONS
1456 
1457  GENERATED GLOBAL GRANT GRANTED GREATEST GROUP_P GROUPING
1458 
1459  HANDLER HAVING HEADER_P HOLD HOUR_P
1460 
1461  IDENTITY_P IF_P ILIKE IMMEDIATE IMMUTABLE IMPLICIT_P IMPORT_P IN_P
1462  INCLUDING INCREMENT INDEX INDEXES INHERIT INHERITS INITIALLY INLINE_P
1463  INNER_P INOUT INPUT_P INSENSITIVE INSERT INSTEAD INT_P INTEGER
1464  INTERSECT INTERVAL INTO INVOKER IS ISNULL ISOLATION
1465 
1466  JOIN
1467 
1468  KEY
1469 
1470  LABEL LANGUAGE LARGE_P LAST_P LATERAL_P
1471  LEADING LEAKPROOF LEAST LEFT LEVEL LIKE LIMIT LISTEN LOAD LOCAL
1472  LOCALTIME LOCALTIMESTAMP LOCATION LOCK_P LOCKED LOGGED
1473 
1474  MAPPING MATCH MATERIALIZED MAXVALUE METHOD MINUTE_P MINVALUE MODE MONTH_P MOVE
1475 
1476  NAME_P NAMES NATIONAL NATURAL NCHAR NEW NEXT NO NONE
1477  NOT NOTHING NOTIFY NOTNULL NOWAIT NULL_P NULLIF
1478  NULLS_P NUMERIC
1479 
1480  OBJECT_P OF OFF OFFSET OIDS OLD ON ONLY OPERATOR OPTION OPTIONS OR
1481  ORDER ORDINALITY OUT_P OUTER_P OVER OVERLAPS OVERLAY OVERRIDING OWNED OWNER
1482 
1483  PARALLEL PARSER PARTIAL PARTITION PASSING PASSWORD PLACING PLANS POLICY
1484  POSITION PRECEDING PRECISION PRESERVE PREPARE PREPARED PRIMARY
1485  PRIOR PRIVILEGES PROCEDURAL PROCEDURE PROGRAM PUBLICATION
1486 
1487  QUOTE
1488 
1489  RANGE READ REAL REASSIGN RECHECK RECURSIVE REF REFERENCES REFERENCING
1490  REFRESH REINDEX RELATIVE_P RELEASE RENAME REPEATABLE REPLACE REPLICA
1491  RESET RESTART RESTRICT RETURNING RETURNS REVOKE RIGHT ROLE ROLLBACK ROLLUP
1492  ROW ROWS RULE
1493 
1494  SAVEPOINT SCHEMA SCHEMAS SCROLL SEARCH SECOND_P SECURITY SELECT SEQUENCE SEQUENCES
1495  SERIALIZABLE SERVER SESSION SESSION_USER SET SETS SETOF SHARE SHOW
1496  SIMILAR SIMPLE SKIP SMALLINT SNAPSHOT SOME SQL_P STABLE STANDALONE_P
1497  START STATEMENT STATISTICS STDIN STDOUT STORAGE STRICT_P STRIP_P
1498  SUBSCRIPTION SUBSTRING SYMMETRIC SYSID SYSTEM_P
1499 
1500  TABLE TABLES TABLESAMPLE TABLESPACE TEMP TEMPLATE TEMPORARY TEXT_P THEN
1501  TIME TIMESTAMP TO TRAILING TRANSACTION TRANSFORM TREAT TRIGGER TRIM TRUE_P
1502  TRUNCATE TRUSTED TYPE_P TYPES_P
1503 
1504  UNBOUNDED UNCOMMITTED UNENCRYPTED UNION UNIQUE UNKNOWN UNLISTEN UNLOGGED
1505  UNTIL UPDATE USER USING
1506 
1507  VACUUM VALID VALIDATE VALIDATOR VALUE_P VALUES VARCHAR VARIADIC VARYING
1508  VERBOSE VERSION_P VIEW VIEWS VOLATILE
1509 
1510  WHEN WHERE WHITESPACE_P WINDOW WITH WITHIN WITHOUT WORK WRAPPER WRITE
1511 
1512  XML_P XMLATTRIBUTES XMLCONCAT XMLELEMENT XMLEXISTS XMLFOREST XMLNAMESPACES
1513  XMLPARSE XMLPI XMLROOT XMLSERIALIZE XMLTABLE
1514 
1515  YEAR_P YES_P
1516 
1517  ZONE
1518 
1519 
1520 
1521 
1522 
1523 
1524 
1525 
1526 
1527 
1528 
1529  %token NOT_LA NULLS_LA WITH_LA
1530 
1531 
1532 
1533  %nonassoc SET
1534  %left UNION EXCEPT
1535  %left INTERSECT
1536  %left OR
1537  %left AND
1538  %right NOT
1539  %nonassoc IS ISNULL NOTNULL
1540  %nonassoc '<' '>' '=' LESS_EQUALS GREATER_EQUALS NOT_EQUALS
1541  %nonassoc BETWEEN IN_P LIKE ILIKE SIMILAR NOT_LA
1542  %nonassoc ESCAPE
1543  %left POSTFIXOP
1544 
1545 
1546 
1547 
1548 
1549 
1550 
1551 
1552 
1553 
1554 
1555 
1556 
1557 
1558 
1559 
1560 
1561 
1562 
1563 
1564 
1565 
1566 
1567 
1568 
1569 
1570  %nonassoc UNBOUNDED
1571  %nonassoc IDENT
1572 %nonassoc CSTRING
1573 %nonassoc UIDENT GENERATED NULL_P PARTITION RANGE ROWS PRECEDING FOLLOWING CUBE ROLLUP
1574  %left Op OPERATOR
1575  %left '+' '-'
1576  %left '*' '/' '%'
1577  %left '^'
1578 
1579  %left AT
1580  %left COLLATE
1581  %right UMINUS
1582  %left '[' ']'
1583  %left '(' ')'
1584  %left TYPECAST
1585  %left '.'
1586 
1587 
1588 
1589 
1590 
1591 
1592 
1593  %left JOIN CROSS LEFT FULL RIGHT INNER_P NATURAL
1594 
1595  %right PRESERVE STRIP_P
1596 
1597 %%
1598 prog: statements;
1599 /* rules */
1600  stmt:
1601  AlterEventTrigStmt
1602  { output_statement($1, 0, ECPGst_normal); }
1603 |  AlterCollationStmt
1604  { output_statement($1, 0, ECPGst_normal); }
1605 |  AlterDatabaseStmt
1606  { output_statement($1, 0, ECPGst_normal); }
1607 |  AlterDatabaseSetStmt
1608  { output_statement($1, 0, ECPGst_normal); }
1609 |  AlterDefaultPrivilegesStmt
1610  { output_statement($1, 0, ECPGst_normal); }
1611 |  AlterDomainStmt
1612  { output_statement($1, 0, ECPGst_normal); }
1613 |  AlterEnumStmt
1614  { output_statement($1, 0, ECPGst_normal); }
1615 |  AlterExtensionStmt
1616  { output_statement($1, 0, ECPGst_normal); }
1617 |  AlterExtensionContentsStmt
1618  { output_statement($1, 0, ECPGst_normal); }
1619 |  AlterFdwStmt
1620  { output_statement($1, 0, ECPGst_normal); }
1621 |  AlterForeignServerStmt
1622  { output_statement($1, 0, ECPGst_normal); }
1623 |  AlterForeignTableStmt
1624  { output_statement($1, 0, ECPGst_normal); }
1625 |  AlterFunctionStmt
1626  { output_statement($1, 0, ECPGst_normal); }
1627 |  AlterGroupStmt
1628  { output_statement($1, 0, ECPGst_normal); }
1629 |  AlterObjectDependsStmt
1630  { output_statement($1, 0, ECPGst_normal); }
1631 |  AlterObjectSchemaStmt
1632  { output_statement($1, 0, ECPGst_normal); }
1633 |  AlterOwnerStmt
1634  { output_statement($1, 0, ECPGst_normal); }
1635 |  AlterOperatorStmt
1636  { output_statement($1, 0, ECPGst_normal); }
1637 |  AlterPolicyStmt
1638  { output_statement($1, 0, ECPGst_normal); }
1639 |  AlterSeqStmt
1640  { output_statement($1, 0, ECPGst_normal); }
1641 |  AlterSystemStmt
1642  { output_statement($1, 0, ECPGst_normal); }
1643 |  AlterTableStmt
1644  { output_statement($1, 0, ECPGst_normal); }
1645 |  AlterTblSpcStmt
1646  { output_statement($1, 0, ECPGst_normal); }
1647 |  AlterCompositeTypeStmt
1648  { output_statement($1, 0, ECPGst_normal); }
1649 |  AlterPublicationStmt
1650  { output_statement($1, 0, ECPGst_normal); }
1651 |  AlterRoleSetStmt
1652  { output_statement($1, 0, ECPGst_normal); }
1653 |  AlterRoleStmt
1654  { output_statement($1, 0, ECPGst_normal); }
1655 |  AlterSubscriptionStmt
1656  { output_statement($1, 0, ECPGst_normal); }
1657 |  AlterTSConfigurationStmt
1658  { output_statement($1, 0, ECPGst_normal); }
1659 |  AlterTSDictionaryStmt
1660  { output_statement($1, 0, ECPGst_normal); }
1661 |  AlterUserMappingStmt
1662  { output_statement($1, 0, ECPGst_normal); }
1663 |  AnalyzeStmt
1664  { output_statement($1, 0, ECPGst_normal); }
1665 |  CheckPointStmt
1666  { output_statement($1, 0, ECPGst_normal); }
1667 |  ClosePortalStmt
1668 	{
1669 		if (INFORMIX_MODE)
1670 		{
1671 			if (pg_strcasecmp($1+strlen("close "), "database") == 0)
1672 			{
1673 				if (connection)
1674 					mmerror(PARSE_ERROR, ET_ERROR, "AT option not allowed in CLOSE DATABASE statement");
1675 
1676 				fprintf(base_yyout, "{ ECPGdisconnect(__LINE__, \"CURRENT\");");
1677 				whenever_action(2);
1678 				free($1);
1679 				break;
1680 			}
1681 		}
1682 
1683 		output_statement($1, 0, ECPGst_normal);
1684 	}
1685 |  ClusterStmt
1686  { output_statement($1, 0, ECPGst_normal); }
1687 |  CommentStmt
1688  { output_statement($1, 0, ECPGst_normal); }
1689 |  ConstraintsSetStmt
1690  { output_statement($1, 0, ECPGst_normal); }
1691 |  CopyStmt
1692  { output_statement($1, 0, ECPGst_normal); }
1693 |  CreateAmStmt
1694  { output_statement($1, 0, ECPGst_normal); }
1695 |  CreateAsStmt
1696  { output_statement($1, 0, ECPGst_normal); }
1697 |  CreateAssertStmt
1698  { output_statement($1, 0, ECPGst_normal); }
1699 |  CreateCastStmt
1700  { output_statement($1, 0, ECPGst_normal); }
1701 |  CreateConversionStmt
1702  { output_statement($1, 0, ECPGst_normal); }
1703 |  CreateDomainStmt
1704  { output_statement($1, 0, ECPGst_normal); }
1705 |  CreateExtensionStmt
1706  { output_statement($1, 0, ECPGst_normal); }
1707 |  CreateFdwStmt
1708  { output_statement($1, 0, ECPGst_normal); }
1709 |  CreateForeignServerStmt
1710  { output_statement($1, 0, ECPGst_normal); }
1711 |  CreateForeignTableStmt
1712  { output_statement($1, 0, ECPGst_normal); }
1713 |  CreateFunctionStmt
1714  { output_statement($1, 0, ECPGst_normal); }
1715 |  CreateGroupStmt
1716  { output_statement($1, 0, ECPGst_normal); }
1717 |  CreateMatViewStmt
1718  { output_statement($1, 0, ECPGst_normal); }
1719 |  CreateOpClassStmt
1720  { output_statement($1, 0, ECPGst_normal); }
1721 |  CreateOpFamilyStmt
1722  { output_statement($1, 0, ECPGst_normal); }
1723 |  CreatePublicationStmt
1724  { output_statement($1, 0, ECPGst_normal); }
1725 |  AlterOpFamilyStmt
1726  { output_statement($1, 0, ECPGst_normal); }
1727 |  CreatePolicyStmt
1728  { output_statement($1, 0, ECPGst_normal); }
1729 |  CreatePLangStmt
1730  { output_statement($1, 0, ECPGst_normal); }
1731 |  CreateSchemaStmt
1732  { output_statement($1, 0, ECPGst_normal); }
1733 |  CreateSeqStmt
1734  { output_statement($1, 0, ECPGst_normal); }
1735 |  CreateStmt
1736  { output_statement($1, 0, ECPGst_normal); }
1737 |  CreateSubscriptionStmt
1738  { output_statement($1, 0, ECPGst_normal); }
1739 |  CreateStatsStmt
1740  { output_statement($1, 0, ECPGst_normal); }
1741 |  CreateTableSpaceStmt
1742  { output_statement($1, 0, ECPGst_normal); }
1743 |  CreateTransformStmt
1744  { output_statement($1, 0, ECPGst_normal); }
1745 |  CreateTrigStmt
1746  { output_statement($1, 0, ECPGst_normal); }
1747 |  CreateEventTrigStmt
1748  { output_statement($1, 0, ECPGst_normal); }
1749 |  CreateRoleStmt
1750  { output_statement($1, 0, ECPGst_normal); }
1751 |  CreateUserStmt
1752  { output_statement($1, 0, ECPGst_normal); }
1753 |  CreateUserMappingStmt
1754  { output_statement($1, 0, ECPGst_normal); }
1755 |  CreatedbStmt
1756  { output_statement($1, 0, ECPGst_normal); }
1757 |  DeallocateStmt
1758 	{
1759 		output_deallocate_prepare_statement($1);
1760 	}
1761 |  DeclareCursorStmt
1762 	{ output_simple_statement($1); }
1763 |  DefineStmt
1764  { output_statement($1, 0, ECPGst_normal); }
1765 |  DeleteStmt
1766 	{ output_statement($1, 1, ECPGst_prepnormal); }
1767 |  DiscardStmt
1768 	{ output_statement($1, 1, ECPGst_normal); }
1769 |  DoStmt
1770  { output_statement($1, 0, ECPGst_normal); }
1771 |  DropAssertStmt
1772  { output_statement($1, 0, ECPGst_normal); }
1773 |  DropCastStmt
1774  { output_statement($1, 0, ECPGst_normal); }
1775 |  DropOpClassStmt
1776  { output_statement($1, 0, ECPGst_normal); }
1777 |  DropOpFamilyStmt
1778  { output_statement($1, 0, ECPGst_normal); }
1779 |  DropOwnedStmt
1780  { output_statement($1, 0, ECPGst_normal); }
1781 |  DropPLangStmt
1782  { output_statement($1, 0, ECPGst_normal); }
1783 |  DropStmt
1784  { output_statement($1, 0, ECPGst_normal); }
1785 |  DropSubscriptionStmt
1786  { output_statement($1, 0, ECPGst_normal); }
1787 |  DropTableSpaceStmt
1788  { output_statement($1, 0, ECPGst_normal); }
1789 |  DropTransformStmt
1790  { output_statement($1, 0, ECPGst_normal); }
1791 |  DropRoleStmt
1792  { output_statement($1, 0, ECPGst_normal); }
1793 |  DropUserMappingStmt
1794  { output_statement($1, 0, ECPGst_normal); }
1795 |  DropdbStmt
1796  { output_statement($1, 0, ECPGst_normal); }
1797 |  ExecuteStmt
1798 	{ output_statement($1, 1, ECPGst_execute); }
1799 |  ExplainStmt
1800  { output_statement($1, 0, ECPGst_normal); }
1801 |  FetchStmt
1802 	{ output_statement($1, 1, ECPGst_normal); }
1803 |  GrantStmt
1804  { output_statement($1, 0, ECPGst_normal); }
1805 |  GrantRoleStmt
1806  { output_statement($1, 0, ECPGst_normal); }
1807 |  ImportForeignSchemaStmt
1808  { output_statement($1, 0, ECPGst_normal); }
1809 |  IndexStmt
1810  { output_statement($1, 0, ECPGst_normal); }
1811 |  InsertStmt
1812 	{ output_statement($1, 1, ECPGst_prepnormal); }
1813 |  ListenStmt
1814  { output_statement($1, 0, ECPGst_normal); }
1815 |  RefreshMatViewStmt
1816  { output_statement($1, 0, ECPGst_normal); }
1817 |  LoadStmt
1818  { output_statement($1, 0, ECPGst_normal); }
1819 |  LockStmt
1820  { output_statement($1, 0, ECPGst_normal); }
1821 |  NotifyStmt
1822  { output_statement($1, 0, ECPGst_normal); }
1823 |  PrepareStmt
1824 	{
1825 		if ($1.type == NULL || strlen($1.type) == 0)
1826 			output_prepare_statement($1.name, $1.stmt);
1827 		else
1828 			output_statement(cat_str(5, mm_strdup("prepare"), $1.name, $1.type, mm_strdup("as"), $1.stmt), 0, ECPGst_normal);
1829 	}
1830 |  ReassignOwnedStmt
1831  { output_statement($1, 0, ECPGst_normal); }
1832 |  ReindexStmt
1833  { output_statement($1, 0, ECPGst_normal); }
1834 |  RemoveAggrStmt
1835  { output_statement($1, 0, ECPGst_normal); }
1836 |  RemoveFuncStmt
1837  { output_statement($1, 0, ECPGst_normal); }
1838 |  RemoveOperStmt
1839  { output_statement($1, 0, ECPGst_normal); }
1840 |  RenameStmt
1841  { output_statement($1, 0, ECPGst_normal); }
1842 |  RevokeStmt
1843  { output_statement($1, 0, ECPGst_normal); }
1844 |  RevokeRoleStmt
1845  { output_statement($1, 0, ECPGst_normal); }
1846 |  RuleStmt
1847  { output_statement($1, 0, ECPGst_normal); }
1848 |  SecLabelStmt
1849  { output_statement($1, 0, ECPGst_normal); }
1850 |  SelectStmt
1851 	{ output_statement($1, 1, ECPGst_prepnormal); }
1852 |  TransactionStmt
1853 	{
1854 		fprintf(base_yyout, "{ ECPGtrans(__LINE__, %s, \"%s\");", connection ? connection : "NULL", $1);
1855 		whenever_action(2);
1856 		free($1);
1857 	}
1858 |  TruncateStmt
1859  { output_statement($1, 0, ECPGst_normal); }
1860 |  UnlistenStmt
1861  { output_statement($1, 0, ECPGst_normal); }
1862 |  UpdateStmt
1863 	{ output_statement($1, 1, ECPGst_prepnormal); }
1864 |  VacuumStmt
1865  { output_statement($1, 0, ECPGst_normal); }
1866 |  VariableResetStmt
1867  { output_statement($1, 0, ECPGst_normal); }
1868 |  VariableSetStmt
1869  { output_statement($1, 0, ECPGst_normal); }
1870 |  VariableShowStmt
1871  { output_statement($1, 0, ECPGst_normal); }
1872 |  ViewStmt
1873  { output_statement($1, 0, ECPGst_normal); }
1874 	| ECPGAllocateDescr
1875 	{
1876 		fprintf(base_yyout,"ECPGallocate_desc(__LINE__, %s);",$1);
1877 		whenever_action(0);
1878 		free($1);
1879 	}
1880 	| ECPGConnect
1881 	{
1882 		if (connection)
1883 			mmerror(PARSE_ERROR, ET_ERROR, "AT option not allowed in CONNECT statement");
1884 
1885 		fprintf(base_yyout, "{ ECPGconnect(__LINE__, %d, %s, %d); ", compat, $1, autocommit);
1886 		reset_variables();
1887 		whenever_action(2);
1888 		free($1);
1889 	}
1890 	| ECPGCursorStmt
1891 	{
1892 		output_simple_statement($1);
1893 	}
1894 	| ECPGDeallocateDescr
1895 	{
1896 		fprintf(base_yyout,"ECPGdeallocate_desc(__LINE__, %s);",$1);
1897 		whenever_action(0);
1898 		free($1);
1899 	}
1900 	| ECPGDeclare
1901 	{
1902 		output_simple_statement($1);
1903 	}
1904 	| ECPGDescribe
1905 	{
1906 		fprintf(base_yyout, "{ ECPGdescribe(__LINE__, %d, %s,", compat, $1);
1907 		dump_variables(argsresult, 1);
1908 		fputs("ECPGt_EORT);", base_yyout);
1909 		fprintf(base_yyout, "}");
1910 		output_line_number();
1911 
1912 		free($1);
1913 	}
1914 	| ECPGDisconnect
1915 	{
1916 		if (connection)
1917 			mmerror(PARSE_ERROR, ET_ERROR, "AT option not allowed in DISCONNECT statement");
1918 
1919 		fprintf(base_yyout, "{ ECPGdisconnect(__LINE__, %s);",
1920 				$1 ? $1 : "\"CURRENT\"");
1921 		whenever_action(2);
1922 		free($1);
1923 	}
1924 	| ECPGExecuteImmediateStmt	{ output_statement($1, 0, ECPGst_exec_immediate); }
1925 	| ECPGFree
1926 	{
1927 		const char *con = connection ? connection : "NULL";
1928 
1929 		if (strcmp($1, "all") == 0)
1930 			fprintf(base_yyout, "{ ECPGdeallocate_all(__LINE__, %d, %s);", compat, con);
1931 		else if ($1[0] == ':')
1932 			fprintf(base_yyout, "{ ECPGdeallocate(__LINE__, %d, %s, %s);", compat, con, $1+1);
1933 		else
1934 			fprintf(base_yyout, "{ ECPGdeallocate(__LINE__, %d, %s, \"%s\");", compat, con, $1);
1935 
1936 		whenever_action(2);
1937 		free($1);
1938 	}
1939 	| ECPGGetDescriptor
1940 	{
1941 		lookup_descriptor($1.name, connection);
1942 		output_get_descr($1.name, $1.str);
1943 		free($1.name);
1944 		free($1.str);
1945 	}
1946 	| ECPGGetDescriptorHeader
1947 	{
1948 		lookup_descriptor($1, connection);
1949 		output_get_descr_header($1);
1950 		free($1);
1951 	}
1952 	| ECPGOpen
1953 	{
1954 		struct cursor *ptr;
1955 
1956 		if ((ptr = add_additional_variables($1, true)) != NULL)
1957 		{
1958 			connection = ptr->connection ? mm_strdup(ptr->connection) : NULL;
1959 			output_statement(mm_strdup(ptr->command), 0, ECPGst_normal);
1960 			ptr->opened = true;
1961 		}
1962 	}
1963 	| ECPGSetAutocommit
1964 	{
1965 		fprintf(base_yyout, "{ ECPGsetcommit(__LINE__, \"%s\", %s);", $1, connection ? connection : "NULL");
1966 		whenever_action(2);
1967 		free($1);
1968 	}
1969 	| ECPGSetConnection
1970 	{
1971 		if (connection)
1972 			mmerror(PARSE_ERROR, ET_ERROR, "AT option not allowed in SET CONNECTION statement");
1973 
1974 		fprintf(base_yyout, "{ ECPGsetconn(__LINE__, %s);", $1);
1975 		whenever_action(2);
1976 		free($1);
1977 	}
1978 	| ECPGSetDescriptor
1979 	{
1980 		lookup_descriptor($1.name, connection);
1981 		output_set_descr($1.name, $1.str);
1982 		free($1.name);
1983 		free($1.str);
1984 	}
1985 	| ECPGSetDescriptorHeader
1986 	{
1987 		lookup_descriptor($1, connection);
1988 		output_set_descr_header($1);
1989 		free($1);
1990 	}
1991 	| ECPGTypedef
1992 	{
1993 		if (connection)
1994 			mmerror(PARSE_ERROR, ET_ERROR, "AT option not allowed in TYPE statement");
1995 
1996 		fprintf(base_yyout, "%s", $1);
1997 		free($1);
1998 		output_line_number();
1999 	}
2000 	| ECPGVar
2001 	{
2002 		if (connection)
2003 			mmerror(PARSE_ERROR, ET_ERROR, "AT option not allowed in VAR statement");
2004 
2005 		output_simple_statement($1);
2006 	}
2007 	| ECPGWhenever
2008 	{
2009 		if (connection)
2010 			mmerror(PARSE_ERROR, ET_ERROR, "AT option not allowed in WHENEVER statement");
2011 
2012 		output_simple_statement($1);
2013 	}
2014 |
2015  { $$ = NULL; }
2016 ;
2017 
2018 
2019  CreateRoleStmt:
2020  CREATE ROLE RoleId opt_with OptRoleList
2021  {
2022  $$ = cat_str(4,mm_strdup("create role"),$3,$4,$5);
2023 }
2024 ;
2025 
2026 
2027  opt_with:
2028  WITH
2029  {
2030  $$ = mm_strdup("with");
2031 }
2032 |  WITH_LA
2033  {
2034  $$ = mm_strdup("with");
2035 }
2036 |
2037  {
2038  $$=EMPTY; }
2039 ;
2040 
2041 
2042  OptRoleList:
2043  OptRoleList CreateOptRoleElem
2044  {
2045  $$ = cat_str(2,$1,$2);
2046 }
2047 |
2048  {
2049  $$=EMPTY; }
2050 ;
2051 
2052 
2053  AlterOptRoleList:
2054  AlterOptRoleList AlterOptRoleElem
2055  {
2056  $$ = cat_str(2,$1,$2);
2057 }
2058 |
2059  {
2060  $$=EMPTY; }
2061 ;
2062 
2063 
2064  AlterOptRoleElem:
2065  PASSWORD ecpg_sconst
2066  {
2067  $$ = cat_str(2,mm_strdup("password"),$2);
2068 }
2069 |  PASSWORD NULL_P
2070  {
2071  $$ = mm_strdup("password null");
2072 }
2073 |  ENCRYPTED PASSWORD ecpg_sconst
2074  {
2075  $$ = cat_str(2,mm_strdup("encrypted password"),$3);
2076 }
2077 |  UNENCRYPTED PASSWORD ecpg_sconst
2078  {
2079 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
2080  $$ = cat_str(2,mm_strdup("unencrypted password"),$3);
2081 }
2082 |  INHERIT
2083  {
2084  $$ = mm_strdup("inherit");
2085 }
2086 |  CONNECTION LIMIT SignedIconst
2087  {
2088  $$ = cat_str(2,mm_strdup("connection limit"),$3);
2089 }
2090 |  VALID UNTIL ecpg_sconst
2091  {
2092  $$ = cat_str(2,mm_strdup("valid until"),$3);
2093 }
2094 |  USER role_list
2095  {
2096  $$ = cat_str(2,mm_strdup("user"),$2);
2097 }
2098 |  ecpg_ident
2099  {
2100  $$ = $1;
2101 }
2102 ;
2103 
2104 
2105  CreateOptRoleElem:
2106  AlterOptRoleElem
2107  {
2108  $$ = $1;
2109 }
2110 |  SYSID Iconst
2111  {
2112  $$ = cat_str(2,mm_strdup("sysid"),$2);
2113 }
2114 |  ADMIN role_list
2115  {
2116  $$ = cat_str(2,mm_strdup("admin"),$2);
2117 }
2118 |  ROLE role_list
2119  {
2120  $$ = cat_str(2,mm_strdup("role"),$2);
2121 }
2122 |  IN_P ROLE role_list
2123  {
2124  $$ = cat_str(2,mm_strdup("in role"),$3);
2125 }
2126 |  IN_P GROUP_P role_list
2127  {
2128  $$ = cat_str(2,mm_strdup("in group"),$3);
2129 }
2130 ;
2131 
2132 
2133  CreateUserStmt:
2134  CREATE USER RoleId opt_with OptRoleList
2135  {
2136  $$ = cat_str(4,mm_strdup("create user"),$3,$4,$5);
2137 }
2138 ;
2139 
2140 
2141  AlterRoleStmt:
2142  ALTER ROLE RoleSpec opt_with AlterOptRoleList
2143  {
2144  $$ = cat_str(4,mm_strdup("alter role"),$3,$4,$5);
2145 }
2146 |  ALTER USER RoleSpec opt_with AlterOptRoleList
2147  {
2148  $$ = cat_str(4,mm_strdup("alter user"),$3,$4,$5);
2149 }
2150 ;
2151 
2152 
2153  opt_in_database:
2154 
2155  {
2156  $$=EMPTY; }
2157 |  IN_P DATABASE database_name
2158  {
2159  $$ = cat_str(2,mm_strdup("in database"),$3);
2160 }
2161 ;
2162 
2163 
2164  AlterRoleSetStmt:
2165  ALTER ROLE RoleSpec opt_in_database SetResetClause
2166  {
2167  $$ = cat_str(4,mm_strdup("alter role"),$3,$4,$5);
2168 }
2169 |  ALTER ROLE ALL opt_in_database SetResetClause
2170  {
2171  $$ = cat_str(3,mm_strdup("alter role all"),$4,$5);
2172 }
2173 |  ALTER USER RoleSpec opt_in_database SetResetClause
2174  {
2175  $$ = cat_str(4,mm_strdup("alter user"),$3,$4,$5);
2176 }
2177 |  ALTER USER ALL opt_in_database SetResetClause
2178  {
2179  $$ = cat_str(3,mm_strdup("alter user all"),$4,$5);
2180 }
2181 ;
2182 
2183 
2184  DropRoleStmt:
2185  DROP ROLE role_list
2186  {
2187  $$ = cat_str(2,mm_strdup("drop role"),$3);
2188 }
2189 |  DROP ROLE IF_P EXISTS role_list
2190  {
2191  $$ = cat_str(2,mm_strdup("drop role if exists"),$5);
2192 }
2193 |  DROP USER role_list
2194  {
2195  $$ = cat_str(2,mm_strdup("drop user"),$3);
2196 }
2197 |  DROP USER IF_P EXISTS role_list
2198  {
2199  $$ = cat_str(2,mm_strdup("drop user if exists"),$5);
2200 }
2201 |  DROP GROUP_P role_list
2202  {
2203  $$ = cat_str(2,mm_strdup("drop group"),$3);
2204 }
2205 |  DROP GROUP_P IF_P EXISTS role_list
2206  {
2207  $$ = cat_str(2,mm_strdup("drop group if exists"),$5);
2208 }
2209 ;
2210 
2211 
2212  CreateGroupStmt:
2213  CREATE GROUP_P RoleId opt_with OptRoleList
2214  {
2215  $$ = cat_str(4,mm_strdup("create group"),$3,$4,$5);
2216 }
2217 ;
2218 
2219 
2220  AlterGroupStmt:
2221  ALTER GROUP_P RoleSpec add_drop USER role_list
2222  {
2223  $$ = cat_str(5,mm_strdup("alter group"),$3,$4,mm_strdup("user"),$6);
2224 }
2225 ;
2226 
2227 
2228  add_drop:
2229  ADD_P
2230  {
2231  $$ = mm_strdup("add");
2232 }
2233 |  DROP
2234  {
2235  $$ = mm_strdup("drop");
2236 }
2237 ;
2238 
2239 
2240  CreateSchemaStmt:
2241  CREATE SCHEMA OptSchemaName AUTHORIZATION RoleSpec OptSchemaEltList
2242  {
2243  $$ = cat_str(5,mm_strdup("create schema"),$3,mm_strdup("authorization"),$5,$6);
2244 }
2245 |  CREATE SCHEMA ColId OptSchemaEltList
2246  {
2247  $$ = cat_str(3,mm_strdup("create schema"),$3,$4);
2248 }
2249 |  CREATE SCHEMA IF_P NOT EXISTS OptSchemaName AUTHORIZATION RoleSpec OptSchemaEltList
2250  {
2251 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
2252  $$ = cat_str(5,mm_strdup("create schema if not exists"),$6,mm_strdup("authorization"),$8,$9);
2253 }
2254 |  CREATE SCHEMA IF_P NOT EXISTS ColId OptSchemaEltList
2255  {
2256 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
2257  $$ = cat_str(3,mm_strdup("create schema if not exists"),$6,$7);
2258 }
2259 ;
2260 
2261 
2262  OptSchemaName:
2263  ColId
2264  {
2265  $$ = $1;
2266 }
2267 |
2268  {
2269  $$=EMPTY; }
2270 ;
2271 
2272 
2273  OptSchemaEltList:
2274  OptSchemaEltList schema_stmt
2275  {
2276  $$ = cat_str(2,$1,$2);
2277 }
2278 |
2279  {
2280  $$=EMPTY; }
2281 ;
2282 
2283 
2284  schema_stmt:
2285  CreateStmt
2286  {
2287  $$ = $1;
2288 }
2289 |  IndexStmt
2290  {
2291  $$ = $1;
2292 }
2293 |  CreateSeqStmt
2294  {
2295  $$ = $1;
2296 }
2297 |  CreateTrigStmt
2298  {
2299  $$ = $1;
2300 }
2301 |  GrantStmt
2302  {
2303  $$ = $1;
2304 }
2305 |  ViewStmt
2306  {
2307  $$ = $1;
2308 }
2309 ;
2310 
2311 
2312  VariableSetStmt:
2313  SET set_rest
2314  {
2315  $$ = cat_str(2,mm_strdup("set"),$2);
2316 }
2317 |  SET LOCAL set_rest
2318  {
2319  $$ = cat_str(2,mm_strdup("set local"),$3);
2320 }
2321 |  SET SESSION set_rest
2322  {
2323  $$ = cat_str(2,mm_strdup("set session"),$3);
2324 }
2325 ;
2326 
2327 
2328  set_rest:
2329  TRANSACTION transaction_mode_list
2330  {
2331  $$ = cat_str(2,mm_strdup("transaction"),$2);
2332 }
2333 |  SESSION CHARACTERISTICS AS TRANSACTION transaction_mode_list
2334  {
2335  $$ = cat_str(2,mm_strdup("session characteristics as transaction"),$5);
2336 }
2337 |  set_rest_more
2338  {
2339  $$ = $1;
2340 }
2341 ;
2342 
2343 
2344  generic_set:
2345  var_name TO var_list
2346  {
2347  $$ = cat_str(3,$1,mm_strdup("to"),$3);
2348 }
2349 |  var_name '=' var_list
2350  {
2351  $$ = cat_str(3,$1,mm_strdup("="),$3);
2352 }
2353 |  var_name TO DEFAULT
2354  {
2355  $$ = cat_str(2,$1,mm_strdup("to default"));
2356 }
2357 |  var_name '=' DEFAULT
2358  {
2359  $$ = cat_str(2,$1,mm_strdup("= default"));
2360 }
2361 ;
2362 
2363 
2364  set_rest_more:
2365  generic_set
2366  {
2367  $$ = $1;
2368 }
2369 |  var_name FROM CURRENT_P
2370  {
2371  $$ = cat_str(2,$1,mm_strdup("from current"));
2372 }
2373 |  TIME ZONE zone_value
2374  {
2375  $$ = cat_str(2,mm_strdup("time zone"),$3);
2376 }
2377 |  CATALOG_P ecpg_sconst
2378  {
2379 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
2380  $$ = cat_str(2,mm_strdup("catalog"),$2);
2381 }
2382 |  SCHEMA ecpg_sconst
2383  {
2384  $$ = cat_str(2,mm_strdup("schema"),$2);
2385 }
2386 |  NAMES opt_encoding
2387  {
2388  $$ = cat_str(2,mm_strdup("names"),$2);
2389 }
2390 |  ROLE NonReservedWord_or_Sconst
2391  {
2392  $$ = cat_str(2,mm_strdup("role"),$2);
2393 }
2394 |  SESSION AUTHORIZATION NonReservedWord_or_Sconst
2395  {
2396  $$ = cat_str(2,mm_strdup("session authorization"),$3);
2397 }
2398 |  SESSION AUTHORIZATION DEFAULT
2399  {
2400  $$ = mm_strdup("session authorization default");
2401 }
2402 |  XML_P OPTION document_or_content
2403  {
2404  $$ = cat_str(2,mm_strdup("xml option"),$3);
2405 }
2406 |  TRANSACTION SNAPSHOT ecpg_sconst
2407  {
2408  $$ = cat_str(2,mm_strdup("transaction snapshot"),$3);
2409 }
2410 ;
2411 
2412 
2413  var_name:
2414 ECPGColId
2415  {
2416  $$ = $1;
2417 }
2418 |  var_name '.' ColId
2419  {
2420  $$ = cat_str(3,$1,mm_strdup("."),$3);
2421 }
2422 ;
2423 
2424 
2425  var_list:
2426  var_value
2427  {
2428  $$ = $1;
2429 }
2430 |  var_list ',' var_value
2431  {
2432  $$ = cat_str(3,$1,mm_strdup(","),$3);
2433 }
2434 ;
2435 
2436 
2437  var_value:
2438  opt_boolean_or_string
2439  {
2440  $$ = $1;
2441 }
2442 |  NumericOnly
2443  {
2444 		if ($1[0] == '$')
2445 		{
2446 			free($1);
2447 			$1 = mm_strdup("$0");
2448 		}
2449 
2450  $$ = $1;
2451 }
2452 ;
2453 
2454 
2455  iso_level:
2456  READ UNCOMMITTED
2457  {
2458  $$ = mm_strdup("read uncommitted");
2459 }
2460 |  READ COMMITTED
2461  {
2462  $$ = mm_strdup("read committed");
2463 }
2464 |  REPEATABLE READ
2465  {
2466  $$ = mm_strdup("repeatable read");
2467 }
2468 |  SERIALIZABLE
2469  {
2470  $$ = mm_strdup("serializable");
2471 }
2472 ;
2473 
2474 
2475  opt_boolean_or_string:
2476  TRUE_P
2477  {
2478  $$ = mm_strdup("true");
2479 }
2480 |  FALSE_P
2481  {
2482  $$ = mm_strdup("false");
2483 }
2484 |  ON
2485  {
2486  $$ = mm_strdup("on");
2487 }
2488 |  NonReservedWord_or_Sconst
2489  {
2490  $$ = $1;
2491 }
2492 ;
2493 
2494 
2495  zone_value:
2496  ecpg_sconst
2497  {
2498  $$ = $1;
2499 }
2500 |  ecpg_ident
2501  {
2502  $$ = $1;
2503 }
2504 |  ConstInterval ecpg_sconst opt_interval
2505  {
2506  $$ = cat_str(3,$1,$2,$3);
2507 }
2508 |  ConstInterval '(' Iconst ')' ecpg_sconst
2509  {
2510  $$ = cat_str(5,$1,mm_strdup("("),$3,mm_strdup(")"),$5);
2511 }
2512 |  NumericOnly
2513  {
2514  $$ = $1;
2515 }
2516 |  DEFAULT
2517  {
2518  $$ = mm_strdup("default");
2519 }
2520 |  LOCAL
2521  {
2522  $$ = mm_strdup("local");
2523 }
2524 ;
2525 
2526 
2527  opt_encoding:
2528  ecpg_sconst
2529  {
2530  $$ = $1;
2531 }
2532 |  DEFAULT
2533  {
2534  $$ = mm_strdup("default");
2535 }
2536 |
2537  {
2538  $$=EMPTY; }
2539 ;
2540 
2541 
2542  NonReservedWord_or_Sconst:
2543  NonReservedWord
2544  {
2545  $$ = $1;
2546 }
2547 |  ecpg_sconst
2548  {
2549  $$ = $1;
2550 }
2551 ;
2552 
2553 
2554  VariableResetStmt:
2555  RESET reset_rest
2556  {
2557  $$ = cat_str(2,mm_strdup("reset"),$2);
2558 }
2559 ;
2560 
2561 
2562  reset_rest:
2563  generic_reset
2564  {
2565  $$ = $1;
2566 }
2567 |  TIME ZONE
2568  {
2569  $$ = mm_strdup("time zone");
2570 }
2571 |  TRANSACTION ISOLATION LEVEL
2572  {
2573  $$ = mm_strdup("transaction isolation level");
2574 }
2575 |  SESSION AUTHORIZATION
2576  {
2577  $$ = mm_strdup("session authorization");
2578 }
2579 ;
2580 
2581 
2582  generic_reset:
2583  var_name
2584  {
2585  $$ = $1;
2586 }
2587 |  ALL
2588  {
2589  $$ = mm_strdup("all");
2590 }
2591 ;
2592 
2593 
2594  SetResetClause:
2595  SET set_rest
2596  {
2597  $$ = cat_str(2,mm_strdup("set"),$2);
2598 }
2599 |  VariableResetStmt
2600  {
2601  $$ = $1;
2602 }
2603 ;
2604 
2605 
2606  FunctionSetResetClause:
2607  SET set_rest_more
2608  {
2609  $$ = cat_str(2,mm_strdup("set"),$2);
2610 }
2611 |  VariableResetStmt
2612  {
2613  $$ = $1;
2614 }
2615 ;
2616 
2617 
2618  VariableShowStmt:
2619 SHOW var_name ecpg_into
2620  {
2621  $$ = cat_str(2,mm_strdup("show"),$2);
2622 }
2623 | SHOW TIME ZONE ecpg_into
2624  {
2625  $$ = mm_strdup("show time zone");
2626 }
2627 | SHOW TRANSACTION ISOLATION LEVEL ecpg_into
2628  {
2629  $$ = mm_strdup("show transaction isolation level");
2630 }
2631 | SHOW SESSION AUTHORIZATION ecpg_into
2632  {
2633  $$ = mm_strdup("show session authorization");
2634 }
2635 |  SHOW ALL
2636 	{
2637 		mmerror(PARSE_ERROR, ET_ERROR, "SHOW ALL is not implemented");
2638 		$$ = EMPTY;
2639 	}
2640 ;
2641 
2642 
2643  ConstraintsSetStmt:
2644  SET CONSTRAINTS constraints_set_list constraints_set_mode
2645  {
2646  $$ = cat_str(3,mm_strdup("set constraints"),$3,$4);
2647 }
2648 ;
2649 
2650 
2651  constraints_set_list:
2652  ALL
2653  {
2654  $$ = mm_strdup("all");
2655 }
2656 |  qualified_name_list
2657  {
2658  $$ = $1;
2659 }
2660 ;
2661 
2662 
2663  constraints_set_mode:
2664  DEFERRED
2665  {
2666  $$ = mm_strdup("deferred");
2667 }
2668 |  IMMEDIATE
2669  {
2670  $$ = mm_strdup("immediate");
2671 }
2672 ;
2673 
2674 
2675  CheckPointStmt:
2676  CHECKPOINT
2677  {
2678  $$ = mm_strdup("checkpoint");
2679 }
2680 ;
2681 
2682 
2683  DiscardStmt:
2684  DISCARD ALL
2685  {
2686  $$ = mm_strdup("discard all");
2687 }
2688 |  DISCARD TEMP
2689  {
2690  $$ = mm_strdup("discard temp");
2691 }
2692 |  DISCARD TEMPORARY
2693  {
2694  $$ = mm_strdup("discard temporary");
2695 }
2696 |  DISCARD PLANS
2697  {
2698  $$ = mm_strdup("discard plans");
2699 }
2700 |  DISCARD SEQUENCES
2701  {
2702  $$ = mm_strdup("discard sequences");
2703 }
2704 ;
2705 
2706 
2707  AlterTableStmt:
2708  ALTER TABLE relation_expr alter_table_cmds
2709  {
2710  $$ = cat_str(3,mm_strdup("alter table"),$3,$4);
2711 }
2712 |  ALTER TABLE IF_P EXISTS relation_expr alter_table_cmds
2713  {
2714  $$ = cat_str(3,mm_strdup("alter table if exists"),$5,$6);
2715 }
2716 |  ALTER TABLE relation_expr partition_cmd
2717  {
2718  $$ = cat_str(3,mm_strdup("alter table"),$3,$4);
2719 }
2720 |  ALTER TABLE IF_P EXISTS relation_expr partition_cmd
2721  {
2722  $$ = cat_str(3,mm_strdup("alter table if exists"),$5,$6);
2723 }
2724 |  ALTER TABLE ALL IN_P TABLESPACE name SET TABLESPACE name opt_nowait
2725  {
2726  $$ = cat_str(5,mm_strdup("alter table all in tablespace"),$6,mm_strdup("set tablespace"),$9,$10);
2727 }
2728 |  ALTER TABLE ALL IN_P TABLESPACE name OWNED BY role_list SET TABLESPACE name opt_nowait
2729  {
2730  $$ = cat_str(7,mm_strdup("alter table all in tablespace"),$6,mm_strdup("owned by"),$9,mm_strdup("set tablespace"),$12,$13);
2731 }
2732 |  ALTER INDEX qualified_name alter_table_cmds
2733  {
2734  $$ = cat_str(3,mm_strdup("alter index"),$3,$4);
2735 }
2736 |  ALTER INDEX IF_P EXISTS qualified_name alter_table_cmds
2737  {
2738  $$ = cat_str(3,mm_strdup("alter index if exists"),$5,$6);
2739 }
2740 |  ALTER INDEX ALL IN_P TABLESPACE name SET TABLESPACE name opt_nowait
2741  {
2742  $$ = cat_str(5,mm_strdup("alter index all in tablespace"),$6,mm_strdup("set tablespace"),$9,$10);
2743 }
2744 |  ALTER INDEX ALL IN_P TABLESPACE name OWNED BY role_list SET TABLESPACE name opt_nowait
2745  {
2746  $$ = cat_str(7,mm_strdup("alter index all in tablespace"),$6,mm_strdup("owned by"),$9,mm_strdup("set tablespace"),$12,$13);
2747 }
2748 |  ALTER SEQUENCE qualified_name alter_table_cmds
2749  {
2750  $$ = cat_str(3,mm_strdup("alter sequence"),$3,$4);
2751 }
2752 |  ALTER SEQUENCE IF_P EXISTS qualified_name alter_table_cmds
2753  {
2754  $$ = cat_str(3,mm_strdup("alter sequence if exists"),$5,$6);
2755 }
2756 |  ALTER VIEW qualified_name alter_table_cmds
2757  {
2758  $$ = cat_str(3,mm_strdup("alter view"),$3,$4);
2759 }
2760 |  ALTER VIEW IF_P EXISTS qualified_name alter_table_cmds
2761  {
2762  $$ = cat_str(3,mm_strdup("alter view if exists"),$5,$6);
2763 }
2764 |  ALTER MATERIALIZED VIEW qualified_name alter_table_cmds
2765  {
2766  $$ = cat_str(3,mm_strdup("alter materialized view"),$4,$5);
2767 }
2768 |  ALTER MATERIALIZED VIEW IF_P EXISTS qualified_name alter_table_cmds
2769  {
2770  $$ = cat_str(3,mm_strdup("alter materialized view if exists"),$6,$7);
2771 }
2772 |  ALTER MATERIALIZED VIEW ALL IN_P TABLESPACE name SET TABLESPACE name opt_nowait
2773  {
2774  $$ = cat_str(5,mm_strdup("alter materialized view all in tablespace"),$7,mm_strdup("set tablespace"),$10,$11);
2775 }
2776 |  ALTER MATERIALIZED VIEW ALL IN_P TABLESPACE name OWNED BY role_list SET TABLESPACE name opt_nowait
2777  {
2778  $$ = cat_str(7,mm_strdup("alter materialized view all in tablespace"),$7,mm_strdup("owned by"),$10,mm_strdup("set tablespace"),$13,$14);
2779 }
2780 ;
2781 
2782 
2783  alter_table_cmds:
2784  alter_table_cmd
2785  {
2786  $$ = $1;
2787 }
2788 |  alter_table_cmds ',' alter_table_cmd
2789  {
2790  $$ = cat_str(3,$1,mm_strdup(","),$3);
2791 }
2792 ;
2793 
2794 
2795  partition_cmd:
2796  ATTACH PARTITION qualified_name ForValues
2797  {
2798  $$ = cat_str(3,mm_strdup("attach partition"),$3,$4);
2799 }
2800 |  DETACH PARTITION qualified_name
2801  {
2802  $$ = cat_str(2,mm_strdup("detach partition"),$3);
2803 }
2804 ;
2805 
2806 
2807  alter_table_cmd:
2808  ADD_P columnDef
2809  {
2810  $$ = cat_str(2,mm_strdup("add"),$2);
2811 }
2812 |  ADD_P IF_P NOT EXISTS columnDef
2813  {
2814  $$ = cat_str(2,mm_strdup("add if not exists"),$5);
2815 }
2816 |  ADD_P COLUMN columnDef
2817  {
2818  $$ = cat_str(2,mm_strdup("add column"),$3);
2819 }
2820 |  ADD_P COLUMN IF_P NOT EXISTS columnDef
2821  {
2822  $$ = cat_str(2,mm_strdup("add column if not exists"),$6);
2823 }
2824 |  ALTER opt_column ColId alter_column_default
2825  {
2826  $$ = cat_str(4,mm_strdup("alter"),$2,$3,$4);
2827 }
2828 |  ALTER opt_column ColId DROP NOT NULL_P
2829  {
2830  $$ = cat_str(4,mm_strdup("alter"),$2,$3,mm_strdup("drop not null"));
2831 }
2832 |  ALTER opt_column ColId SET NOT NULL_P
2833  {
2834  $$ = cat_str(4,mm_strdup("alter"),$2,$3,mm_strdup("set not null"));
2835 }
2836 |  ALTER opt_column ColId SET STATISTICS SignedIconst
2837  {
2838  $$ = cat_str(5,mm_strdup("alter"),$2,$3,mm_strdup("set statistics"),$6);
2839 }
2840 |  ALTER opt_column ColId SET reloptions
2841  {
2842  $$ = cat_str(5,mm_strdup("alter"),$2,$3,mm_strdup("set"),$5);
2843 }
2844 |  ALTER opt_column ColId RESET reloptions
2845  {
2846  $$ = cat_str(5,mm_strdup("alter"),$2,$3,mm_strdup("reset"),$5);
2847 }
2848 |  ALTER opt_column ColId SET STORAGE ColId
2849  {
2850  $$ = cat_str(5,mm_strdup("alter"),$2,$3,mm_strdup("set storage"),$6);
2851 }
2852 |  ALTER opt_column ColId ADD_P GENERATED generated_when AS IDENTITY_P OptParenthesizedSeqOptList
2853  {
2854  $$ = cat_str(7,mm_strdup("alter"),$2,$3,mm_strdup("add generated"),$6,mm_strdup("as identity"),$9);
2855 }
2856 |  ALTER opt_column ColId alter_identity_column_option_list
2857  {
2858  $$ = cat_str(4,mm_strdup("alter"),$2,$3,$4);
2859 }
2860 |  ALTER opt_column ColId DROP IDENTITY_P
2861  {
2862  $$ = cat_str(4,mm_strdup("alter"),$2,$3,mm_strdup("drop identity"));
2863 }
2864 |  ALTER opt_column ColId DROP IDENTITY_P IF_P EXISTS
2865  {
2866  $$ = cat_str(4,mm_strdup("alter"),$2,$3,mm_strdup("drop identity if exists"));
2867 }
2868 |  DROP opt_column IF_P EXISTS ColId opt_drop_behavior
2869  {
2870  $$ = cat_str(5,mm_strdup("drop"),$2,mm_strdup("if exists"),$5,$6);
2871 }
2872 |  DROP opt_column ColId opt_drop_behavior
2873  {
2874  $$ = cat_str(4,mm_strdup("drop"),$2,$3,$4);
2875 }
2876 |  ALTER opt_column ColId opt_set_data TYPE_P Typename opt_collate_clause alter_using
2877  {
2878  $$ = cat_str(8,mm_strdup("alter"),$2,$3,$4,mm_strdup("type"),$6,$7,$8);
2879 }
2880 |  ALTER opt_column ColId alter_generic_options
2881  {
2882  $$ = cat_str(4,mm_strdup("alter"),$2,$3,$4);
2883 }
2884 |  ADD_P TableConstraint
2885  {
2886  $$ = cat_str(2,mm_strdup("add"),$2);
2887 }
2888 |  ALTER CONSTRAINT name ConstraintAttributeSpec
2889  {
2890  $$ = cat_str(3,mm_strdup("alter constraint"),$3,$4);
2891 }
2892 |  VALIDATE CONSTRAINT name
2893  {
2894  $$ = cat_str(2,mm_strdup("validate constraint"),$3);
2895 }
2896 |  DROP CONSTRAINT IF_P EXISTS name opt_drop_behavior
2897  {
2898  $$ = cat_str(3,mm_strdup("drop constraint if exists"),$5,$6);
2899 }
2900 |  DROP CONSTRAINT name opt_drop_behavior
2901  {
2902  $$ = cat_str(3,mm_strdup("drop constraint"),$3,$4);
2903 }
2904 |  SET WITH OIDS
2905  {
2906  $$ = mm_strdup("set with oids");
2907 }
2908 |  SET WITHOUT OIDS
2909  {
2910  $$ = mm_strdup("set without oids");
2911 }
2912 |  CLUSTER ON name
2913  {
2914  $$ = cat_str(2,mm_strdup("cluster on"),$3);
2915 }
2916 |  SET WITHOUT CLUSTER
2917  {
2918  $$ = mm_strdup("set without cluster");
2919 }
2920 |  SET LOGGED
2921  {
2922  $$ = mm_strdup("set logged");
2923 }
2924 |  SET UNLOGGED
2925  {
2926  $$ = mm_strdup("set unlogged");
2927 }
2928 |  ENABLE_P TRIGGER name
2929  {
2930  $$ = cat_str(2,mm_strdup("enable trigger"),$3);
2931 }
2932 |  ENABLE_P ALWAYS TRIGGER name
2933  {
2934  $$ = cat_str(2,mm_strdup("enable always trigger"),$4);
2935 }
2936 |  ENABLE_P REPLICA TRIGGER name
2937  {
2938  $$ = cat_str(2,mm_strdup("enable replica trigger"),$4);
2939 }
2940 |  ENABLE_P TRIGGER ALL
2941  {
2942  $$ = mm_strdup("enable trigger all");
2943 }
2944 |  ENABLE_P TRIGGER USER
2945  {
2946  $$ = mm_strdup("enable trigger user");
2947 }
2948 |  DISABLE_P TRIGGER name
2949  {
2950  $$ = cat_str(2,mm_strdup("disable trigger"),$3);
2951 }
2952 |  DISABLE_P TRIGGER ALL
2953  {
2954  $$ = mm_strdup("disable trigger all");
2955 }
2956 |  DISABLE_P TRIGGER USER
2957  {
2958  $$ = mm_strdup("disable trigger user");
2959 }
2960 |  ENABLE_P RULE name
2961  {
2962  $$ = cat_str(2,mm_strdup("enable rule"),$3);
2963 }
2964 |  ENABLE_P ALWAYS RULE name
2965  {
2966  $$ = cat_str(2,mm_strdup("enable always rule"),$4);
2967 }
2968 |  ENABLE_P REPLICA RULE name
2969  {
2970  $$ = cat_str(2,mm_strdup("enable replica rule"),$4);
2971 }
2972 |  DISABLE_P RULE name
2973  {
2974  $$ = cat_str(2,mm_strdup("disable rule"),$3);
2975 }
2976 |  INHERIT qualified_name
2977  {
2978  $$ = cat_str(2,mm_strdup("inherit"),$2);
2979 }
2980 |  NO INHERIT qualified_name
2981  {
2982  $$ = cat_str(2,mm_strdup("no inherit"),$3);
2983 }
2984 |  OF any_name
2985  {
2986  $$ = cat_str(2,mm_strdup("of"),$2);
2987 }
2988 |  NOT OF
2989  {
2990  $$ = mm_strdup("not of");
2991 }
2992 |  OWNER TO RoleSpec
2993  {
2994  $$ = cat_str(2,mm_strdup("owner to"),$3);
2995 }
2996 |  SET TABLESPACE name
2997  {
2998  $$ = cat_str(2,mm_strdup("set tablespace"),$3);
2999 }
3000 |  SET reloptions
3001  {
3002  $$ = cat_str(2,mm_strdup("set"),$2);
3003 }
3004 |  RESET reloptions
3005  {
3006  $$ = cat_str(2,mm_strdup("reset"),$2);
3007 }
3008 |  REPLICA IDENTITY_P replica_identity
3009  {
3010  $$ = cat_str(2,mm_strdup("replica identity"),$3);
3011 }
3012 |  ENABLE_P ROW LEVEL SECURITY
3013  {
3014  $$ = mm_strdup("enable row level security");
3015 }
3016 |  DISABLE_P ROW LEVEL SECURITY
3017  {
3018  $$ = mm_strdup("disable row level security");
3019 }
3020 |  FORCE ROW LEVEL SECURITY
3021  {
3022  $$ = mm_strdup("force row level security");
3023 }
3024 |  NO FORCE ROW LEVEL SECURITY
3025  {
3026  $$ = mm_strdup("no force row level security");
3027 }
3028 |  alter_generic_options
3029  {
3030  $$ = $1;
3031 }
3032 ;
3033 
3034 
3035  alter_column_default:
3036  SET DEFAULT a_expr
3037  {
3038  $$ = cat_str(2,mm_strdup("set default"),$3);
3039 }
3040 |  DROP DEFAULT
3041  {
3042  $$ = mm_strdup("drop default");
3043 }
3044 ;
3045 
3046 
3047  opt_drop_behavior:
3048  CASCADE
3049  {
3050  $$ = mm_strdup("cascade");
3051 }
3052 |  RESTRICT
3053  {
3054  $$ = mm_strdup("restrict");
3055 }
3056 |
3057  {
3058  $$=EMPTY; }
3059 ;
3060 
3061 
3062  opt_collate_clause:
3063  COLLATE any_name
3064  {
3065  $$ = cat_str(2,mm_strdup("collate"),$2);
3066 }
3067 |
3068  {
3069  $$=EMPTY; }
3070 ;
3071 
3072 
3073  alter_using:
3074  USING a_expr
3075  {
3076  $$ = cat_str(2,mm_strdup("using"),$2);
3077 }
3078 |
3079  {
3080  $$=EMPTY; }
3081 ;
3082 
3083 
3084  replica_identity:
3085  NOTHING
3086  {
3087  $$ = mm_strdup("nothing");
3088 }
3089 |  FULL
3090  {
3091  $$ = mm_strdup("full");
3092 }
3093 |  DEFAULT
3094  {
3095  $$ = mm_strdup("default");
3096 }
3097 |  USING INDEX name
3098  {
3099  $$ = cat_str(2,mm_strdup("using index"),$3);
3100 }
3101 ;
3102 
3103 
3104  reloptions:
3105  '(' reloption_list ')'
3106  {
3107  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
3108 }
3109 ;
3110 
3111 
3112  opt_reloptions:
3113  WITH reloptions
3114  {
3115  $$ = cat_str(2,mm_strdup("with"),$2);
3116 }
3117 |
3118  {
3119  $$=EMPTY; }
3120 ;
3121 
3122 
3123  reloption_list:
3124  reloption_elem
3125  {
3126  $$ = $1;
3127 }
3128 |  reloption_list ',' reloption_elem
3129  {
3130  $$ = cat_str(3,$1,mm_strdup(","),$3);
3131 }
3132 ;
3133 
3134 
3135  reloption_elem:
3136  ColLabel '=' def_arg
3137  {
3138  $$ = cat_str(3,$1,mm_strdup("="),$3);
3139 }
3140 |  ColLabel
3141  {
3142  $$ = $1;
3143 }
3144 |  ColLabel '.' ColLabel '=' def_arg
3145  {
3146  $$ = cat_str(5,$1,mm_strdup("."),$3,mm_strdup("="),$5);
3147 }
3148 |  ColLabel '.' ColLabel
3149  {
3150  $$ = cat_str(3,$1,mm_strdup("."),$3);
3151 }
3152 ;
3153 
3154 
3155  alter_identity_column_option_list:
3156  alter_identity_column_option
3157  {
3158  $$ = $1;
3159 }
3160 |  alter_identity_column_option_list alter_identity_column_option
3161  {
3162  $$ = cat_str(2,$1,$2);
3163 }
3164 ;
3165 
3166 
3167  alter_identity_column_option:
3168  RESTART
3169  {
3170  $$ = mm_strdup("restart");
3171 }
3172 |  RESTART opt_with NumericOnly
3173  {
3174  $$ = cat_str(3,mm_strdup("restart"),$2,$3);
3175 }
3176 |  SET SeqOptElem
3177  {
3178  $$ = cat_str(2,mm_strdup("set"),$2);
3179 }
3180 |  SET GENERATED generated_when
3181  {
3182  $$ = cat_str(2,mm_strdup("set generated"),$3);
3183 }
3184 ;
3185 
3186 
3187  ForValues:
3188  FOR VALUES IN_P '(' partbound_datum_list ')'
3189  {
3190  $$ = cat_str(3,mm_strdup("for values in ("),$5,mm_strdup(")"));
3191 }
3192 |  FOR VALUES FROM '(' range_datum_list ')' TO '(' range_datum_list ')'
3193  {
3194  $$ = cat_str(5,mm_strdup("for values from ("),$5,mm_strdup(") to ("),$9,mm_strdup(")"));
3195 }
3196 ;
3197 
3198 
3199  partbound_datum:
3200  ecpg_sconst
3201  {
3202  $$ = $1;
3203 }
3204 |  NumericOnly
3205  {
3206  $$ = $1;
3207 }
3208 |  TRUE_P
3209  {
3210  $$ = mm_strdup("true");
3211 }
3212 |  FALSE_P
3213  {
3214  $$ = mm_strdup("false");
3215 }
3216 |  NULL_P
3217  {
3218  $$ = mm_strdup("null");
3219 }
3220 ;
3221 
3222 
3223  partbound_datum_list:
3224  partbound_datum
3225  {
3226  $$ = $1;
3227 }
3228 |  partbound_datum_list ',' partbound_datum
3229  {
3230  $$ = cat_str(3,$1,mm_strdup(","),$3);
3231 }
3232 ;
3233 
3234 
3235  range_datum_list:
3236  PartitionRangeDatum
3237  {
3238  $$ = $1;
3239 }
3240 |  range_datum_list ',' PartitionRangeDatum
3241  {
3242  $$ = cat_str(3,$1,mm_strdup(","),$3);
3243 }
3244 ;
3245 
3246 
3247  PartitionRangeDatum:
3248  MINVALUE
3249  {
3250  $$ = mm_strdup("minvalue");
3251 }
3252 |  MAXVALUE
3253  {
3254  $$ = mm_strdup("maxvalue");
3255 }
3256 |  partbound_datum
3257  {
3258  $$ = $1;
3259 }
3260 ;
3261 
3262 
3263  AlterCompositeTypeStmt:
3264  ALTER TYPE_P any_name alter_type_cmds
3265  {
3266  $$ = cat_str(3,mm_strdup("alter type"),$3,$4);
3267 }
3268 ;
3269 
3270 
3271  alter_type_cmds:
3272  alter_type_cmd
3273  {
3274  $$ = $1;
3275 }
3276 |  alter_type_cmds ',' alter_type_cmd
3277  {
3278  $$ = cat_str(3,$1,mm_strdup(","),$3);
3279 }
3280 ;
3281 
3282 
3283  alter_type_cmd:
3284  ADD_P ATTRIBUTE TableFuncElement opt_drop_behavior
3285  {
3286  $$ = cat_str(3,mm_strdup("add attribute"),$3,$4);
3287 }
3288 |  DROP ATTRIBUTE IF_P EXISTS ColId opt_drop_behavior
3289  {
3290  $$ = cat_str(3,mm_strdup("drop attribute if exists"),$5,$6);
3291 }
3292 |  DROP ATTRIBUTE ColId opt_drop_behavior
3293  {
3294  $$ = cat_str(3,mm_strdup("drop attribute"),$3,$4);
3295 }
3296 |  ALTER ATTRIBUTE ColId opt_set_data TYPE_P Typename opt_collate_clause opt_drop_behavior
3297  {
3298  $$ = cat_str(7,mm_strdup("alter attribute"),$3,$4,mm_strdup("type"),$6,$7,$8);
3299 }
3300 ;
3301 
3302 
3303  ClosePortalStmt:
3304  CLOSE cursor_name
3305 	{
3306 		char *cursor_marker = $2[0] == ':' ? mm_strdup("$0") : $2;
3307 		$$ = cat2_str(mm_strdup("close"), cursor_marker);
3308 	}
3309 |  CLOSE ALL
3310  {
3311  $$ = mm_strdup("close all");
3312 }
3313 ;
3314 
3315 
3316  CopyStmt:
3317  COPY opt_binary qualified_name opt_column_list opt_oids copy_from opt_program copy_file_name copy_delimiter opt_with copy_options
3318  {
3319 			if (strcmp($6, "from") == 0 &&
3320 			   (strcmp($7, "stdin") == 0 || strcmp($7, "stdout") == 0))
3321 				mmerror(PARSE_ERROR, ET_WARNING, "COPY FROM STDIN is not implemented");
3322 
3323  $$ = cat_str(11,mm_strdup("copy"),$2,$3,$4,$5,$6,$7,$8,$9,$10,$11);
3324 }
3325 |  COPY '(' PreparableStmt ')' TO opt_program copy_file_name opt_with copy_options
3326  {
3327  $$ = cat_str(7,mm_strdup("copy ("),$3,mm_strdup(") to"),$6,$7,$8,$9);
3328 }
3329 ;
3330 
3331 
3332  copy_from:
3333  FROM
3334  {
3335  $$ = mm_strdup("from");
3336 }
3337 |  TO
3338  {
3339  $$ = mm_strdup("to");
3340 }
3341 ;
3342 
3343 
3344  opt_program:
3345  PROGRAM
3346  {
3347  $$ = mm_strdup("program");
3348 }
3349 |
3350  {
3351  $$=EMPTY; }
3352 ;
3353 
3354 
3355  copy_file_name:
3356  ecpg_sconst
3357  {
3358  $$ = $1;
3359 }
3360 |  STDIN
3361  {
3362  $$ = mm_strdup("stdin");
3363 }
3364 |  STDOUT
3365  {
3366  $$ = mm_strdup("stdout");
3367 }
3368 ;
3369 
3370 
3371  copy_options:
3372  copy_opt_list
3373  {
3374  $$ = $1;
3375 }
3376 |  '(' copy_generic_opt_list ')'
3377  {
3378  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
3379 }
3380 ;
3381 
3382 
3383  copy_opt_list:
3384  copy_opt_list copy_opt_item
3385  {
3386  $$ = cat_str(2,$1,$2);
3387 }
3388 |
3389  {
3390  $$=EMPTY; }
3391 ;
3392 
3393 
3394  copy_opt_item:
3395  BINARY
3396  {
3397  $$ = mm_strdup("binary");
3398 }
3399 |  OIDS
3400  {
3401  $$ = mm_strdup("oids");
3402 }
3403 |  FREEZE
3404  {
3405  $$ = mm_strdup("freeze");
3406 }
3407 |  DELIMITER opt_as ecpg_sconst
3408  {
3409  $$ = cat_str(3,mm_strdup("delimiter"),$2,$3);
3410 }
3411 |  NULL_P opt_as ecpg_sconst
3412  {
3413  $$ = cat_str(3,mm_strdup("null"),$2,$3);
3414 }
3415 |  CSV
3416  {
3417  $$ = mm_strdup("csv");
3418 }
3419 |  HEADER_P
3420  {
3421  $$ = mm_strdup("header");
3422 }
3423 |  QUOTE opt_as ecpg_sconst
3424  {
3425  $$ = cat_str(3,mm_strdup("quote"),$2,$3);
3426 }
3427 |  ESCAPE opt_as ecpg_sconst
3428  {
3429  $$ = cat_str(3,mm_strdup("escape"),$2,$3);
3430 }
3431 |  FORCE QUOTE columnList
3432  {
3433  $$ = cat_str(2,mm_strdup("force quote"),$3);
3434 }
3435 |  FORCE QUOTE '*'
3436  {
3437  $$ = mm_strdup("force quote *");
3438 }
3439 |  FORCE NOT NULL_P columnList
3440  {
3441  $$ = cat_str(2,mm_strdup("force not null"),$4);
3442 }
3443 |  FORCE NULL_P columnList
3444  {
3445  $$ = cat_str(2,mm_strdup("force null"),$3);
3446 }
3447 |  ENCODING ecpg_sconst
3448  {
3449  $$ = cat_str(2,mm_strdup("encoding"),$2);
3450 }
3451 ;
3452 
3453 
3454  opt_binary:
3455  BINARY
3456  {
3457  $$ = mm_strdup("binary");
3458 }
3459 |
3460  {
3461  $$=EMPTY; }
3462 ;
3463 
3464 
3465  opt_oids:
3466  WITH OIDS
3467  {
3468  $$ = mm_strdup("with oids");
3469 }
3470 |
3471  {
3472  $$=EMPTY; }
3473 ;
3474 
3475 
3476  copy_delimiter:
3477  opt_using DELIMITERS ecpg_sconst
3478  {
3479  $$ = cat_str(3,$1,mm_strdup("delimiters"),$3);
3480 }
3481 |
3482  {
3483  $$=EMPTY; }
3484 ;
3485 
3486 
3487  opt_using:
3488  USING
3489  {
3490  $$ = mm_strdup("using");
3491 }
3492 |
3493  {
3494  $$=EMPTY; }
3495 ;
3496 
3497 
3498  copy_generic_opt_list:
3499  copy_generic_opt_elem
3500  {
3501  $$ = $1;
3502 }
3503 |  copy_generic_opt_list ',' copy_generic_opt_elem
3504  {
3505  $$ = cat_str(3,$1,mm_strdup(","),$3);
3506 }
3507 ;
3508 
3509 
3510  copy_generic_opt_elem:
3511  ColLabel copy_generic_opt_arg
3512  {
3513  $$ = cat_str(2,$1,$2);
3514 }
3515 ;
3516 
3517 
3518  copy_generic_opt_arg:
3519  opt_boolean_or_string
3520  {
3521  $$ = $1;
3522 }
3523 |  NumericOnly
3524  {
3525  $$ = $1;
3526 }
3527 |  '*'
3528  {
3529  $$ = mm_strdup("*");
3530 }
3531 |  '(' copy_generic_opt_arg_list ')'
3532  {
3533  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
3534 }
3535 |
3536  {
3537  $$=EMPTY; }
3538 ;
3539 
3540 
3541  copy_generic_opt_arg_list:
3542  copy_generic_opt_arg_list_item
3543  {
3544  $$ = $1;
3545 }
3546 |  copy_generic_opt_arg_list ',' copy_generic_opt_arg_list_item
3547  {
3548  $$ = cat_str(3,$1,mm_strdup(","),$3);
3549 }
3550 ;
3551 
3552 
3553  copy_generic_opt_arg_list_item:
3554  opt_boolean_or_string
3555  {
3556  $$ = $1;
3557 }
3558 ;
3559 
3560 
3561  CreateStmt:
3562  CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')' OptInherit OptPartitionSpec OptWith OnCommitOption OptTableSpace
3563  {
3564  $$ = cat_str(12,mm_strdup("create"),$2,mm_strdup("table"),$4,mm_strdup("("),$6,mm_strdup(")"),$8,$9,$10,$11,$12);
3565 }
3566 |  CREATE OptTemp TABLE IF_P NOT EXISTS qualified_name '(' OptTableElementList ')' OptInherit OptPartitionSpec OptWith OnCommitOption OptTableSpace
3567  {
3568  $$ = cat_str(12,mm_strdup("create"),$2,mm_strdup("table if not exists"),$7,mm_strdup("("),$9,mm_strdup(")"),$11,$12,$13,$14,$15);
3569 }
3570 |  CREATE OptTemp TABLE qualified_name OF any_name OptTypedTableElementList OptPartitionSpec OptWith OnCommitOption OptTableSpace
3571  {
3572  $$ = cat_str(11,mm_strdup("create"),$2,mm_strdup("table"),$4,mm_strdup("of"),$6,$7,$8,$9,$10,$11);
3573 }
3574 |  CREATE OptTemp TABLE IF_P NOT EXISTS qualified_name OF any_name OptTypedTableElementList OptPartitionSpec OptWith OnCommitOption OptTableSpace
3575  {
3576  $$ = cat_str(11,mm_strdup("create"),$2,mm_strdup("table if not exists"),$7,mm_strdup("of"),$9,$10,$11,$12,$13,$14);
3577 }
3578 |  CREATE OptTemp TABLE qualified_name PARTITION OF qualified_name OptTypedTableElementList ForValues OptPartitionSpec OptWith OnCommitOption OptTableSpace
3579  {
3580  $$ = cat_str(12,mm_strdup("create"),$2,mm_strdup("table"),$4,mm_strdup("partition of"),$7,$8,$9,$10,$11,$12,$13);
3581 }
3582 |  CREATE OptTemp TABLE IF_P NOT EXISTS qualified_name PARTITION OF qualified_name OptTypedTableElementList ForValues OptPartitionSpec OptWith OnCommitOption OptTableSpace
3583  {
3584  $$ = 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);
3585 }
3586 ;
3587 
3588 
3589  OptTemp:
3590  TEMPORARY
3591  {
3592  $$ = mm_strdup("temporary");
3593 }
3594 |  TEMP
3595  {
3596  $$ = mm_strdup("temp");
3597 }
3598 |  LOCAL TEMPORARY
3599  {
3600  $$ = mm_strdup("local temporary");
3601 }
3602 |  LOCAL TEMP
3603  {
3604  $$ = mm_strdup("local temp");
3605 }
3606 |  GLOBAL TEMPORARY
3607  {
3608  $$ = mm_strdup("global temporary");
3609 }
3610 |  GLOBAL TEMP
3611  {
3612  $$ = mm_strdup("global temp");
3613 }
3614 |  UNLOGGED
3615  {
3616  $$ = mm_strdup("unlogged");
3617 }
3618 |
3619  {
3620  $$=EMPTY; }
3621 ;
3622 
3623 
3624  OptTableElementList:
3625  TableElementList
3626  {
3627  $$ = $1;
3628 }
3629 |
3630  {
3631  $$=EMPTY; }
3632 ;
3633 
3634 
3635  OptTypedTableElementList:
3636  '(' TypedTableElementList ')'
3637  {
3638  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
3639 }
3640 |
3641  {
3642  $$=EMPTY; }
3643 ;
3644 
3645 
3646  TableElementList:
3647  TableElement
3648  {
3649  $$ = $1;
3650 }
3651 |  TableElementList ',' TableElement
3652  {
3653  $$ = cat_str(3,$1,mm_strdup(","),$3);
3654 }
3655 ;
3656 
3657 
3658  TypedTableElementList:
3659  TypedTableElement
3660  {
3661  $$ = $1;
3662 }
3663 |  TypedTableElementList ',' TypedTableElement
3664  {
3665  $$ = cat_str(3,$1,mm_strdup(","),$3);
3666 }
3667 ;
3668 
3669 
3670  TableElement:
3671  columnDef
3672  {
3673  $$ = $1;
3674 }
3675 |  TableLikeClause
3676  {
3677  $$ = $1;
3678 }
3679 |  TableConstraint
3680  {
3681  $$ = $1;
3682 }
3683 ;
3684 
3685 
3686  TypedTableElement:
3687  columnOptions
3688  {
3689  $$ = $1;
3690 }
3691 |  TableConstraint
3692  {
3693  $$ = $1;
3694 }
3695 ;
3696 
3697 
3698  columnDef:
3699  ColId Typename create_generic_options ColQualList
3700  {
3701  $$ = cat_str(4,$1,$2,$3,$4);
3702 }
3703 ;
3704 
3705 
3706  columnOptions:
3707  ColId ColQualList
3708  {
3709  $$ = cat_str(2,$1,$2);
3710 }
3711 |  ColId WITH OPTIONS ColQualList
3712  {
3713  $$ = cat_str(3,$1,mm_strdup("with options"),$4);
3714 }
3715 ;
3716 
3717 
3718  ColQualList:
3719  ColQualList ColConstraint
3720  {
3721  $$ = cat_str(2,$1,$2);
3722 }
3723 |
3724  {
3725  $$=EMPTY; }
3726 ;
3727 
3728 
3729  ColConstraint:
3730  CONSTRAINT name ColConstraintElem
3731  {
3732  $$ = cat_str(3,mm_strdup("constraint"),$2,$3);
3733 }
3734 |  ColConstraintElem
3735  {
3736  $$ = $1;
3737 }
3738 |  ConstraintAttr
3739  {
3740  $$ = $1;
3741 }
3742 |  COLLATE any_name
3743  {
3744  $$ = cat_str(2,mm_strdup("collate"),$2);
3745 }
3746 ;
3747 
3748 
3749  ColConstraintElem:
3750  NOT NULL_P
3751  {
3752  $$ = mm_strdup("not null");
3753 }
3754 |  NULL_P
3755  {
3756  $$ = mm_strdup("null");
3757 }
3758 |  UNIQUE opt_definition OptConsTableSpace
3759  {
3760  $$ = cat_str(3,mm_strdup("unique"),$2,$3);
3761 }
3762 |  PRIMARY KEY opt_definition OptConsTableSpace
3763  {
3764  $$ = cat_str(3,mm_strdup("primary key"),$3,$4);
3765 }
3766 |  CHECK '(' a_expr ')' opt_no_inherit
3767  {
3768  $$ = cat_str(4,mm_strdup("check ("),$3,mm_strdup(")"),$5);
3769 }
3770 |  DEFAULT b_expr
3771  {
3772  $$ = cat_str(2,mm_strdup("default"),$2);
3773 }
3774 |  GENERATED generated_when AS IDENTITY_P OptParenthesizedSeqOptList
3775  {
3776  $$ = cat_str(4,mm_strdup("generated"),$2,mm_strdup("as identity"),$5);
3777 }
3778 |  REFERENCES qualified_name opt_column_list key_match key_actions
3779  {
3780  $$ = cat_str(5,mm_strdup("references"),$2,$3,$4,$5);
3781 }
3782 ;
3783 
3784 
3785  generated_when:
3786  ALWAYS
3787  {
3788  $$ = mm_strdup("always");
3789 }
3790 |  BY DEFAULT
3791  {
3792  $$ = mm_strdup("by default");
3793 }
3794 ;
3795 
3796 
3797  ConstraintAttr:
3798  DEFERRABLE
3799  {
3800  $$ = mm_strdup("deferrable");
3801 }
3802 |  NOT DEFERRABLE
3803  {
3804  $$ = mm_strdup("not deferrable");
3805 }
3806 |  INITIALLY DEFERRED
3807  {
3808  $$ = mm_strdup("initially deferred");
3809 }
3810 |  INITIALLY IMMEDIATE
3811  {
3812  $$ = mm_strdup("initially immediate");
3813 }
3814 ;
3815 
3816 
3817  TableLikeClause:
3818  LIKE qualified_name TableLikeOptionList
3819  {
3820  $$ = cat_str(3,mm_strdup("like"),$2,$3);
3821 }
3822 ;
3823 
3824 
3825  TableLikeOptionList:
3826  TableLikeOptionList INCLUDING TableLikeOption
3827  {
3828  $$ = cat_str(3,$1,mm_strdup("including"),$3);
3829 }
3830 |  TableLikeOptionList EXCLUDING TableLikeOption
3831  {
3832  $$ = cat_str(3,$1,mm_strdup("excluding"),$3);
3833 }
3834 |
3835  {
3836  $$=EMPTY; }
3837 ;
3838 
3839 
3840  TableLikeOption:
3841  COMMENTS
3842  {
3843  $$ = mm_strdup("comments");
3844 }
3845 |  CONSTRAINTS
3846  {
3847  $$ = mm_strdup("constraints");
3848 }
3849 |  DEFAULTS
3850  {
3851  $$ = mm_strdup("defaults");
3852 }
3853 |  IDENTITY_P
3854  {
3855  $$ = mm_strdup("identity");
3856 }
3857 |  INDEXES
3858  {
3859  $$ = mm_strdup("indexes");
3860 }
3861 |  STATISTICS
3862  {
3863  $$ = mm_strdup("statistics");
3864 }
3865 |  STORAGE
3866  {
3867  $$ = mm_strdup("storage");
3868 }
3869 |  ALL
3870  {
3871  $$ = mm_strdup("all");
3872 }
3873 ;
3874 
3875 
3876  TableConstraint:
3877  CONSTRAINT name ConstraintElem
3878  {
3879  $$ = cat_str(3,mm_strdup("constraint"),$2,$3);
3880 }
3881 |  ConstraintElem
3882  {
3883  $$ = $1;
3884 }
3885 ;
3886 
3887 
3888  ConstraintElem:
3889  CHECK '(' a_expr ')' ConstraintAttributeSpec
3890  {
3891  $$ = cat_str(4,mm_strdup("check ("),$3,mm_strdup(")"),$5);
3892 }
3893 |  UNIQUE '(' columnList ')' opt_definition OptConsTableSpace ConstraintAttributeSpec
3894  {
3895  $$ = cat_str(6,mm_strdup("unique ("),$3,mm_strdup(")"),$5,$6,$7);
3896 }
3897 |  UNIQUE ExistingIndex ConstraintAttributeSpec
3898  {
3899  $$ = cat_str(3,mm_strdup("unique"),$2,$3);
3900 }
3901 |  PRIMARY KEY '(' columnList ')' opt_definition OptConsTableSpace ConstraintAttributeSpec
3902  {
3903  $$ = cat_str(6,mm_strdup("primary key ("),$4,mm_strdup(")"),$6,$7,$8);
3904 }
3905 |  PRIMARY KEY ExistingIndex ConstraintAttributeSpec
3906  {
3907  $$ = cat_str(3,mm_strdup("primary key"),$3,$4);
3908 }
3909 |  EXCLUDE access_method_clause '(' ExclusionConstraintList ')' opt_definition OptConsTableSpace ExclusionWhereClause ConstraintAttributeSpec
3910  {
3911  $$ = cat_str(9,mm_strdup("exclude"),$2,mm_strdup("("),$4,mm_strdup(")"),$6,$7,$8,$9);
3912 }
3913 |  FOREIGN KEY '(' columnList ')' REFERENCES qualified_name opt_column_list key_match key_actions ConstraintAttributeSpec
3914  {
3915  $$ = cat_str(8,mm_strdup("foreign key ("),$4,mm_strdup(") references"),$7,$8,$9,$10,$11);
3916 }
3917 ;
3918 
3919 
3920  opt_no_inherit:
3921  NO INHERIT
3922  {
3923  $$ = mm_strdup("no inherit");
3924 }
3925 |
3926  {
3927  $$=EMPTY; }
3928 ;
3929 
3930 
3931  opt_column_list:
3932  '(' columnList ')'
3933  {
3934  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
3935 }
3936 |
3937  {
3938  $$=EMPTY; }
3939 ;
3940 
3941 
3942  columnList:
3943  columnElem
3944  {
3945  $$ = $1;
3946 }
3947 |  columnList ',' columnElem
3948  {
3949  $$ = cat_str(3,$1,mm_strdup(","),$3);
3950 }
3951 ;
3952 
3953 
3954  columnElem:
3955  ColId
3956  {
3957  $$ = $1;
3958 }
3959 ;
3960 
3961 
3962  key_match:
3963  MATCH FULL
3964  {
3965  $$ = mm_strdup("match full");
3966 }
3967 |  MATCH PARTIAL
3968  {
3969 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
3970  $$ = mm_strdup("match partial");
3971 }
3972 |  MATCH SIMPLE
3973  {
3974  $$ = mm_strdup("match simple");
3975 }
3976 |
3977  {
3978  $$=EMPTY; }
3979 ;
3980 
3981 
3982  ExclusionConstraintList:
3983  ExclusionConstraintElem
3984  {
3985  $$ = $1;
3986 }
3987 |  ExclusionConstraintList ',' ExclusionConstraintElem
3988  {
3989  $$ = cat_str(3,$1,mm_strdup(","),$3);
3990 }
3991 ;
3992 
3993 
3994  ExclusionConstraintElem:
3995  index_elem WITH any_operator
3996  {
3997  $$ = cat_str(3,$1,mm_strdup("with"),$3);
3998 }
3999 |  index_elem WITH OPERATOR '(' any_operator ')'
4000  {
4001  $$ = cat_str(4,$1,mm_strdup("with operator ("),$5,mm_strdup(")"));
4002 }
4003 ;
4004 
4005 
4006  ExclusionWhereClause:
4007  WHERE '(' a_expr ')'
4008  {
4009  $$ = cat_str(3,mm_strdup("where ("),$3,mm_strdup(")"));
4010 }
4011 |
4012  {
4013  $$=EMPTY; }
4014 ;
4015 
4016 
4017  key_actions:
4018  key_update
4019  {
4020  $$ = $1;
4021 }
4022 |  key_delete
4023  {
4024  $$ = $1;
4025 }
4026 |  key_update key_delete
4027  {
4028  $$ = cat_str(2,$1,$2);
4029 }
4030 |  key_delete key_update
4031  {
4032  $$ = cat_str(2,$1,$2);
4033 }
4034 |
4035  {
4036  $$=EMPTY; }
4037 ;
4038 
4039 
4040  key_update:
4041  ON UPDATE key_action
4042  {
4043  $$ = cat_str(2,mm_strdup("on update"),$3);
4044 }
4045 ;
4046 
4047 
4048  key_delete:
4049  ON DELETE_P key_action
4050  {
4051  $$ = cat_str(2,mm_strdup("on delete"),$3);
4052 }
4053 ;
4054 
4055 
4056  key_action:
4057  NO ACTION
4058  {
4059  $$ = mm_strdup("no action");
4060 }
4061 |  RESTRICT
4062  {
4063  $$ = mm_strdup("restrict");
4064 }
4065 |  CASCADE
4066  {
4067  $$ = mm_strdup("cascade");
4068 }
4069 |  SET NULL_P
4070  {
4071  $$ = mm_strdup("set null");
4072 }
4073 |  SET DEFAULT
4074  {
4075  $$ = mm_strdup("set default");
4076 }
4077 ;
4078 
4079 
4080  OptInherit:
4081  INHERITS '(' qualified_name_list ')'
4082  {
4083  $$ = cat_str(3,mm_strdup("inherits ("),$3,mm_strdup(")"));
4084 }
4085 |
4086  {
4087  $$=EMPTY; }
4088 ;
4089 
4090 
4091  OptPartitionSpec:
4092  PartitionSpec
4093  {
4094  $$ = $1;
4095 }
4096 |
4097  {
4098  $$=EMPTY; }
4099 ;
4100 
4101 
4102  PartitionSpec:
4103  PARTITION BY part_strategy '(' part_params ')'
4104  {
4105  $$ = cat_str(5,mm_strdup("partition by"),$3,mm_strdup("("),$5,mm_strdup(")"));
4106 }
4107 ;
4108 
4109 
4110  part_strategy:
4111  ecpg_ident
4112  {
4113  $$ = $1;
4114 }
4115 |  unreserved_keyword
4116  {
4117  $$ = $1;
4118 }
4119 ;
4120 
4121 
4122  part_params:
4123  part_elem
4124  {
4125  $$ = $1;
4126 }
4127 |  part_params ',' part_elem
4128  {
4129  $$ = cat_str(3,$1,mm_strdup(","),$3);
4130 }
4131 ;
4132 
4133 
4134  part_elem:
4135  ColId opt_collate opt_class
4136  {
4137  $$ = cat_str(3,$1,$2,$3);
4138 }
4139 |  func_expr_windowless opt_collate opt_class
4140  {
4141  $$ = cat_str(3,$1,$2,$3);
4142 }
4143 |  '(' a_expr ')' opt_collate opt_class
4144  {
4145  $$ = cat_str(5,mm_strdup("("),$2,mm_strdup(")"),$4,$5);
4146 }
4147 ;
4148 
4149 
4150  OptWith:
4151  WITH reloptions
4152  {
4153  $$ = cat_str(2,mm_strdup("with"),$2);
4154 }
4155 |  WITH OIDS
4156  {
4157  $$ = mm_strdup("with oids");
4158 }
4159 |  WITHOUT OIDS
4160  {
4161  $$ = mm_strdup("without oids");
4162 }
4163 |
4164  {
4165  $$=EMPTY; }
4166 ;
4167 
4168 
4169  OnCommitOption:
4170  ON COMMIT DROP
4171  {
4172  $$ = mm_strdup("on commit drop");
4173 }
4174 |  ON COMMIT DELETE_P ROWS
4175  {
4176  $$ = mm_strdup("on commit delete rows");
4177 }
4178 |  ON COMMIT PRESERVE ROWS
4179  {
4180  $$ = mm_strdup("on commit preserve rows");
4181 }
4182 |
4183  {
4184  $$=EMPTY; }
4185 ;
4186 
4187 
4188  OptTableSpace:
4189  TABLESPACE name
4190  {
4191  $$ = cat_str(2,mm_strdup("tablespace"),$2);
4192 }
4193 |
4194  {
4195  $$=EMPTY; }
4196 ;
4197 
4198 
4199  OptConsTableSpace:
4200  USING INDEX TABLESPACE name
4201  {
4202  $$ = cat_str(2,mm_strdup("using index tablespace"),$4);
4203 }
4204 |
4205  {
4206  $$=EMPTY; }
4207 ;
4208 
4209 
4210  ExistingIndex:
4211  USING INDEX index_name
4212  {
4213  $$ = cat_str(2,mm_strdup("using index"),$3);
4214 }
4215 ;
4216 
4217 
4218  CreateStatsStmt:
4219  CREATE STATISTICS any_name opt_name_list ON expr_list FROM from_list
4220  {
4221  $$ = cat_str(7,mm_strdup("create statistics"),$3,$4,mm_strdup("on"),$6,mm_strdup("from"),$8);
4222 }
4223 |  CREATE STATISTICS IF_P NOT EXISTS any_name opt_name_list ON expr_list FROM from_list
4224  {
4225  $$ = cat_str(7,mm_strdup("create statistics if not exists"),$6,$7,mm_strdup("on"),$9,mm_strdup("from"),$11);
4226 }
4227 ;
4228 
4229 
4230  create_as_target:
4231  qualified_name opt_column_list OptWith OnCommitOption OptTableSpace
4232  {
4233  $$ = cat_str(5,$1,$2,$3,$4,$5);
4234 }
4235 ;
4236 
4237 
4238  opt_with_data:
4239  WITH DATA_P
4240  {
4241  $$ = mm_strdup("with data");
4242 }
4243 |  WITH NO DATA_P
4244  {
4245  $$ = mm_strdup("with no data");
4246 }
4247 |
4248  {
4249  $$=EMPTY; }
4250 ;
4251 
4252 
4253  CreateMatViewStmt:
4254  CREATE OptNoLog MATERIALIZED VIEW create_mv_target AS SelectStmt opt_with_data
4255  {
4256  $$ = cat_str(7,mm_strdup("create"),$2,mm_strdup("materialized view"),$5,mm_strdup("as"),$7,$8);
4257 }
4258 |  CREATE OptNoLog MATERIALIZED VIEW IF_P NOT EXISTS create_mv_target AS SelectStmt opt_with_data
4259  {
4260  $$ = cat_str(7,mm_strdup("create"),$2,mm_strdup("materialized view if not exists"),$8,mm_strdup("as"),$10,$11);
4261 }
4262 ;
4263 
4264 
4265  create_mv_target:
4266  qualified_name opt_column_list opt_reloptions OptTableSpace
4267  {
4268  $$ = cat_str(4,$1,$2,$3,$4);
4269 }
4270 ;
4271 
4272 
4273  OptNoLog:
4274  UNLOGGED
4275  {
4276  $$ = mm_strdup("unlogged");
4277 }
4278 |
4279  {
4280  $$=EMPTY; }
4281 ;
4282 
4283 
4284  RefreshMatViewStmt:
4285  REFRESH MATERIALIZED VIEW opt_concurrently qualified_name opt_with_data
4286  {
4287  $$ = cat_str(4,mm_strdup("refresh materialized view"),$4,$5,$6);
4288 }
4289 ;
4290 
4291 
4292  CreateSeqStmt:
4293  CREATE OptTemp SEQUENCE qualified_name OptSeqOptList
4294  {
4295  $$ = cat_str(5,mm_strdup("create"),$2,mm_strdup("sequence"),$4,$5);
4296 }
4297 |  CREATE OptTemp SEQUENCE IF_P NOT EXISTS qualified_name OptSeqOptList
4298  {
4299  $$ = cat_str(5,mm_strdup("create"),$2,mm_strdup("sequence if not exists"),$7,$8);
4300 }
4301 ;
4302 
4303 
4304  AlterSeqStmt:
4305  ALTER SEQUENCE qualified_name SeqOptList
4306  {
4307  $$ = cat_str(3,mm_strdup("alter sequence"),$3,$4);
4308 }
4309 |  ALTER SEQUENCE IF_P EXISTS qualified_name SeqOptList
4310  {
4311  $$ = cat_str(3,mm_strdup("alter sequence if exists"),$5,$6);
4312 }
4313 ;
4314 
4315 
4316  OptSeqOptList:
4317  SeqOptList
4318  {
4319  $$ = $1;
4320 }
4321 |
4322  {
4323  $$=EMPTY; }
4324 ;
4325 
4326 
4327  OptParenthesizedSeqOptList:
4328  '(' SeqOptList ')'
4329  {
4330  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
4331 }
4332 |
4333  {
4334  $$=EMPTY; }
4335 ;
4336 
4337 
4338  SeqOptList:
4339  SeqOptElem
4340  {
4341  $$ = $1;
4342 }
4343 |  SeqOptList SeqOptElem
4344  {
4345  $$ = cat_str(2,$1,$2);
4346 }
4347 ;
4348 
4349 
4350  SeqOptElem:
4351  AS SimpleTypename
4352  {
4353  $$ = cat_str(2,mm_strdup("as"),$2);
4354 }
4355 |  CACHE NumericOnly
4356  {
4357  $$ = cat_str(2,mm_strdup("cache"),$2);
4358 }
4359 |  CYCLE
4360  {
4361  $$ = mm_strdup("cycle");
4362 }
4363 |  NO CYCLE
4364  {
4365  $$ = mm_strdup("no cycle");
4366 }
4367 |  INCREMENT opt_by NumericOnly
4368  {
4369  $$ = cat_str(3,mm_strdup("increment"),$2,$3);
4370 }
4371 |  MAXVALUE NumericOnly
4372  {
4373  $$ = cat_str(2,mm_strdup("maxvalue"),$2);
4374 }
4375 |  MINVALUE NumericOnly
4376  {
4377  $$ = cat_str(2,mm_strdup("minvalue"),$2);
4378 }
4379 |  NO MAXVALUE
4380  {
4381  $$ = mm_strdup("no maxvalue");
4382 }
4383 |  NO MINVALUE
4384  {
4385  $$ = mm_strdup("no minvalue");
4386 }
4387 |  OWNED BY any_name
4388  {
4389  $$ = cat_str(2,mm_strdup("owned by"),$3);
4390 }
4391 |  SEQUENCE NAME_P any_name
4392  {
4393  $$ = cat_str(2,mm_strdup("sequence name"),$3);
4394 }
4395 |  START opt_with NumericOnly
4396  {
4397  $$ = cat_str(3,mm_strdup("start"),$2,$3);
4398 }
4399 |  RESTART
4400  {
4401  $$ = mm_strdup("restart");
4402 }
4403 |  RESTART opt_with NumericOnly
4404  {
4405  $$ = cat_str(3,mm_strdup("restart"),$2,$3);
4406 }
4407 ;
4408 
4409 
4410  opt_by:
4411  BY
4412  {
4413  $$ = mm_strdup("by");
4414 }
4415 |
4416  {
4417  $$=EMPTY; }
4418 ;
4419 
4420 
4421  NumericOnly:
4422  ecpg_fconst
4423  {
4424  $$ = $1;
4425 }
4426 |  '+' ecpg_fconst
4427  {
4428  $$ = cat_str(2,mm_strdup("+"),$2);
4429 }
4430 |  '-' ecpg_fconst
4431  {
4432  $$ = cat_str(2,mm_strdup("-"),$2);
4433 }
4434 |  SignedIconst
4435  {
4436  $$ = $1;
4437 }
4438 ;
4439 
4440 
4441  NumericOnly_list:
4442  NumericOnly
4443  {
4444  $$ = $1;
4445 }
4446 |  NumericOnly_list ',' NumericOnly
4447  {
4448  $$ = cat_str(3,$1,mm_strdup(","),$3);
4449 }
4450 ;
4451 
4452 
4453  CreatePLangStmt:
4454  CREATE opt_or_replace opt_trusted opt_procedural LANGUAGE NonReservedWord_or_Sconst
4455  {
4456  $$ = cat_str(6,mm_strdup("create"),$2,$3,$4,mm_strdup("language"),$6);
4457 }
4458 |  CREATE opt_or_replace opt_trusted opt_procedural LANGUAGE NonReservedWord_or_Sconst HANDLER handler_name opt_inline_handler opt_validator
4459  {
4460  $$ = cat_str(10,mm_strdup("create"),$2,$3,$4,mm_strdup("language"),$6,mm_strdup("handler"),$8,$9,$10);
4461 }
4462 ;
4463 
4464 
4465  opt_trusted:
4466  TRUSTED
4467  {
4468  $$ = mm_strdup("trusted");
4469 }
4470 |
4471  {
4472  $$=EMPTY; }
4473 ;
4474 
4475 
4476  handler_name:
4477  name
4478  {
4479  $$ = $1;
4480 }
4481 |  name attrs
4482  {
4483  $$ = cat_str(2,$1,$2);
4484 }
4485 ;
4486 
4487 
4488  opt_inline_handler:
4489  INLINE_P handler_name
4490  {
4491  $$ = cat_str(2,mm_strdup("inline"),$2);
4492 }
4493 |
4494  {
4495  $$=EMPTY; }
4496 ;
4497 
4498 
4499  validator_clause:
4500  VALIDATOR handler_name
4501  {
4502  $$ = cat_str(2,mm_strdup("validator"),$2);
4503 }
4504 |  NO VALIDATOR
4505  {
4506  $$ = mm_strdup("no validator");
4507 }
4508 ;
4509 
4510 
4511  opt_validator:
4512  validator_clause
4513  {
4514  $$ = $1;
4515 }
4516 |
4517  {
4518  $$=EMPTY; }
4519 ;
4520 
4521 
4522  DropPLangStmt:
4523  DROP opt_procedural LANGUAGE NonReservedWord_or_Sconst opt_drop_behavior
4524  {
4525  $$ = cat_str(5,mm_strdup("drop"),$2,mm_strdup("language"),$4,$5);
4526 }
4527 |  DROP opt_procedural LANGUAGE IF_P EXISTS NonReservedWord_or_Sconst opt_drop_behavior
4528  {
4529  $$ = cat_str(5,mm_strdup("drop"),$2,mm_strdup("language if exists"),$6,$7);
4530 }
4531 ;
4532 
4533 
4534  opt_procedural:
4535  PROCEDURAL
4536  {
4537  $$ = mm_strdup("procedural");
4538 }
4539 |
4540  {
4541  $$=EMPTY; }
4542 ;
4543 
4544 
4545  CreateTableSpaceStmt:
4546  CREATE TABLESPACE name OptTableSpaceOwner LOCATION ecpg_sconst opt_reloptions
4547  {
4548  $$ = cat_str(6,mm_strdup("create tablespace"),$3,$4,mm_strdup("location"),$6,$7);
4549 }
4550 ;
4551 
4552 
4553  OptTableSpaceOwner:
4554  OWNER RoleSpec
4555  {
4556  $$ = cat_str(2,mm_strdup("owner"),$2);
4557 }
4558 |
4559  {
4560  $$=EMPTY; }
4561 ;
4562 
4563 
4564  DropTableSpaceStmt:
4565  DROP TABLESPACE name
4566  {
4567  $$ = cat_str(2,mm_strdup("drop tablespace"),$3);
4568 }
4569 |  DROP TABLESPACE IF_P EXISTS name
4570  {
4571  $$ = cat_str(2,mm_strdup("drop tablespace if exists"),$5);
4572 }
4573 ;
4574 
4575 
4576  CreateExtensionStmt:
4577  CREATE EXTENSION name opt_with create_extension_opt_list
4578  {
4579  $$ = cat_str(4,mm_strdup("create extension"),$3,$4,$5);
4580 }
4581 |  CREATE EXTENSION IF_P NOT EXISTS name opt_with create_extension_opt_list
4582  {
4583  $$ = cat_str(4,mm_strdup("create extension if not exists"),$6,$7,$8);
4584 }
4585 ;
4586 
4587 
4588  create_extension_opt_list:
4589  create_extension_opt_list create_extension_opt_item
4590  {
4591  $$ = cat_str(2,$1,$2);
4592 }
4593 |
4594  {
4595  $$=EMPTY; }
4596 ;
4597 
4598 
4599  create_extension_opt_item:
4600  SCHEMA name
4601  {
4602  $$ = cat_str(2,mm_strdup("schema"),$2);
4603 }
4604 |  VERSION_P NonReservedWord_or_Sconst
4605  {
4606  $$ = cat_str(2,mm_strdup("version"),$2);
4607 }
4608 |  FROM NonReservedWord_or_Sconst
4609  {
4610  $$ = cat_str(2,mm_strdup("from"),$2);
4611 }
4612 |  CASCADE
4613  {
4614  $$ = mm_strdup("cascade");
4615 }
4616 ;
4617 
4618 
4619  AlterExtensionStmt:
4620  ALTER EXTENSION name UPDATE alter_extension_opt_list
4621  {
4622  $$ = cat_str(4,mm_strdup("alter extension"),$3,mm_strdup("update"),$5);
4623 }
4624 ;
4625 
4626 
4627  alter_extension_opt_list:
4628  alter_extension_opt_list alter_extension_opt_item
4629  {
4630  $$ = cat_str(2,$1,$2);
4631 }
4632 |
4633  {
4634  $$=EMPTY; }
4635 ;
4636 
4637 
4638  alter_extension_opt_item:
4639  TO NonReservedWord_or_Sconst
4640  {
4641  $$ = cat_str(2,mm_strdup("to"),$2);
4642 }
4643 ;
4644 
4645 
4646  AlterExtensionContentsStmt:
4647  ALTER EXTENSION name add_drop ACCESS METHOD name
4648  {
4649  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("access method"),$7);
4650 }
4651 |  ALTER EXTENSION name add_drop AGGREGATE aggregate_with_argtypes
4652  {
4653  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("aggregate"),$6);
4654 }
4655 |  ALTER EXTENSION name add_drop CAST '(' Typename AS Typename ')'
4656  {
4657  $$ = cat_str(8,mm_strdup("alter extension"),$3,$4,mm_strdup("cast ("),$7,mm_strdup("as"),$9,mm_strdup(")"));
4658 }
4659 |  ALTER EXTENSION name add_drop COLLATION any_name
4660  {
4661  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("collation"),$6);
4662 }
4663 |  ALTER EXTENSION name add_drop CONVERSION_P any_name
4664  {
4665  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("conversion"),$6);
4666 }
4667 |  ALTER EXTENSION name add_drop DOMAIN_P Typename
4668  {
4669  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("domain"),$6);
4670 }
4671 |  ALTER EXTENSION name add_drop FUNCTION function_with_argtypes
4672  {
4673  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("function"),$6);
4674 }
4675 |  ALTER EXTENSION name add_drop opt_procedural LANGUAGE name
4676  {
4677  $$ = cat_str(6,mm_strdup("alter extension"),$3,$4,$5,mm_strdup("language"),$7);
4678 }
4679 |  ALTER EXTENSION name add_drop OPERATOR operator_with_argtypes
4680  {
4681  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("operator"),$6);
4682 }
4683 |  ALTER EXTENSION name add_drop OPERATOR CLASS any_name USING access_method
4684  {
4685  $$ = cat_str(7,mm_strdup("alter extension"),$3,$4,mm_strdup("operator class"),$7,mm_strdup("using"),$9);
4686 }
4687 |  ALTER EXTENSION name add_drop OPERATOR FAMILY any_name USING access_method
4688  {
4689  $$ = cat_str(7,mm_strdup("alter extension"),$3,$4,mm_strdup("operator family"),$7,mm_strdup("using"),$9);
4690 }
4691 |  ALTER EXTENSION name add_drop SCHEMA name
4692  {
4693  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("schema"),$6);
4694 }
4695 |  ALTER EXTENSION name add_drop EVENT TRIGGER name
4696  {
4697  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("event trigger"),$7);
4698 }
4699 |  ALTER EXTENSION name add_drop TABLE any_name
4700  {
4701  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("table"),$6);
4702 }
4703 |  ALTER EXTENSION name add_drop TEXT_P SEARCH PARSER any_name
4704  {
4705  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("text search parser"),$8);
4706 }
4707 |  ALTER EXTENSION name add_drop TEXT_P SEARCH DICTIONARY any_name
4708  {
4709  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("text search dictionary"),$8);
4710 }
4711 |  ALTER EXTENSION name add_drop TEXT_P SEARCH TEMPLATE any_name
4712  {
4713  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("text search template"),$8);
4714 }
4715 |  ALTER EXTENSION name add_drop TEXT_P SEARCH CONFIGURATION any_name
4716  {
4717  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("text search configuration"),$8);
4718 }
4719 |  ALTER EXTENSION name add_drop SEQUENCE any_name
4720  {
4721  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("sequence"),$6);
4722 }
4723 |  ALTER EXTENSION name add_drop VIEW any_name
4724  {
4725  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("view"),$6);
4726 }
4727 |  ALTER EXTENSION name add_drop MATERIALIZED VIEW any_name
4728  {
4729  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("materialized view"),$7);
4730 }
4731 |  ALTER EXTENSION name add_drop FOREIGN TABLE any_name
4732  {
4733  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("foreign table"),$7);
4734 }
4735 |  ALTER EXTENSION name add_drop FOREIGN DATA_P WRAPPER name
4736  {
4737  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("foreign data wrapper"),$8);
4738 }
4739 |  ALTER EXTENSION name add_drop SERVER name
4740  {
4741  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("server"),$6);
4742 }
4743 |  ALTER EXTENSION name add_drop TRANSFORM FOR Typename LANGUAGE name
4744  {
4745  $$ = cat_str(7,mm_strdup("alter extension"),$3,$4,mm_strdup("transform for"),$7,mm_strdup("language"),$9);
4746 }
4747 |  ALTER EXTENSION name add_drop TYPE_P Typename
4748  {
4749  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("type"),$6);
4750 }
4751 ;
4752 
4753 
4754  CreateFdwStmt:
4755  CREATE FOREIGN DATA_P WRAPPER name opt_fdw_options create_generic_options
4756  {
4757  $$ = cat_str(4,mm_strdup("create foreign data wrapper"),$5,$6,$7);
4758 }
4759 ;
4760 
4761 
4762  fdw_option:
4763  HANDLER handler_name
4764  {
4765  $$ = cat_str(2,mm_strdup("handler"),$2);
4766 }
4767 |  NO HANDLER
4768  {
4769  $$ = mm_strdup("no handler");
4770 }
4771 |  VALIDATOR handler_name
4772  {
4773  $$ = cat_str(2,mm_strdup("validator"),$2);
4774 }
4775 |  NO VALIDATOR
4776  {
4777  $$ = mm_strdup("no validator");
4778 }
4779 ;
4780 
4781 
4782  fdw_options:
4783  fdw_option
4784  {
4785  $$ = $1;
4786 }
4787 |  fdw_options fdw_option
4788  {
4789  $$ = cat_str(2,$1,$2);
4790 }
4791 ;
4792 
4793 
4794  opt_fdw_options:
4795  fdw_options
4796  {
4797  $$ = $1;
4798 }
4799 |
4800  {
4801  $$=EMPTY; }
4802 ;
4803 
4804 
4805  AlterFdwStmt:
4806  ALTER FOREIGN DATA_P WRAPPER name opt_fdw_options alter_generic_options
4807  {
4808  $$ = cat_str(4,mm_strdup("alter foreign data wrapper"),$5,$6,$7);
4809 }
4810 |  ALTER FOREIGN DATA_P WRAPPER name fdw_options
4811  {
4812  $$ = cat_str(3,mm_strdup("alter foreign data wrapper"),$5,$6);
4813 }
4814 ;
4815 
4816 
4817  create_generic_options:
4818  OPTIONS '(' generic_option_list ')'
4819  {
4820  $$ = cat_str(3,mm_strdup("options ("),$3,mm_strdup(")"));
4821 }
4822 |
4823  {
4824  $$=EMPTY; }
4825 ;
4826 
4827 
4828  generic_option_list:
4829  generic_option_elem
4830  {
4831  $$ = $1;
4832 }
4833 |  generic_option_list ',' generic_option_elem
4834  {
4835  $$ = cat_str(3,$1,mm_strdup(","),$3);
4836 }
4837 ;
4838 
4839 
4840  alter_generic_options:
4841  OPTIONS '(' alter_generic_option_list ')'
4842  {
4843  $$ = cat_str(3,mm_strdup("options ("),$3,mm_strdup(")"));
4844 }
4845 ;
4846 
4847 
4848  alter_generic_option_list:
4849  alter_generic_option_elem
4850  {
4851  $$ = $1;
4852 }
4853 |  alter_generic_option_list ',' alter_generic_option_elem
4854  {
4855  $$ = cat_str(3,$1,mm_strdup(","),$3);
4856 }
4857 ;
4858 
4859 
4860  alter_generic_option_elem:
4861  generic_option_elem
4862  {
4863  $$ = $1;
4864 }
4865 |  SET generic_option_elem
4866  {
4867  $$ = cat_str(2,mm_strdup("set"),$2);
4868 }
4869 |  ADD_P generic_option_elem
4870  {
4871  $$ = cat_str(2,mm_strdup("add"),$2);
4872 }
4873 |  DROP generic_option_name
4874  {
4875  $$ = cat_str(2,mm_strdup("drop"),$2);
4876 }
4877 ;
4878 
4879 
4880  generic_option_elem:
4881  generic_option_name generic_option_arg
4882  {
4883  $$ = cat_str(2,$1,$2);
4884 }
4885 ;
4886 
4887 
4888  generic_option_name:
4889  ColLabel
4890  {
4891  $$ = $1;
4892 }
4893 ;
4894 
4895 
4896  generic_option_arg:
4897  ecpg_sconst
4898  {
4899  $$ = $1;
4900 }
4901 ;
4902 
4903 
4904  CreateForeignServerStmt:
4905  CREATE SERVER name opt_type opt_foreign_server_version FOREIGN DATA_P WRAPPER name create_generic_options
4906  {
4907  $$ = cat_str(7,mm_strdup("create server"),$3,$4,$5,mm_strdup("foreign data wrapper"),$9,$10);
4908 }
4909 |  CREATE SERVER IF_P NOT EXISTS name opt_type opt_foreign_server_version FOREIGN DATA_P WRAPPER name create_generic_options
4910  {
4911  $$ = cat_str(7,mm_strdup("create server if not exists"),$6,$7,$8,mm_strdup("foreign data wrapper"),$12,$13);
4912 }
4913 ;
4914 
4915 
4916  opt_type:
4917  TYPE_P ecpg_sconst
4918  {
4919  $$ = cat_str(2,mm_strdup("type"),$2);
4920 }
4921 |
4922  {
4923  $$=EMPTY; }
4924 ;
4925 
4926 
4927  foreign_server_version:
4928  VERSION_P ecpg_sconst
4929  {
4930  $$ = cat_str(2,mm_strdup("version"),$2);
4931 }
4932 |  VERSION_P NULL_P
4933  {
4934  $$ = mm_strdup("version null");
4935 }
4936 ;
4937 
4938 
4939  opt_foreign_server_version:
4940  foreign_server_version
4941  {
4942  $$ = $1;
4943 }
4944 |
4945  {
4946  $$=EMPTY; }
4947 ;
4948 
4949 
4950  AlterForeignServerStmt:
4951  ALTER SERVER name foreign_server_version alter_generic_options
4952  {
4953  $$ = cat_str(4,mm_strdup("alter server"),$3,$4,$5);
4954 }
4955 |  ALTER SERVER name foreign_server_version
4956  {
4957  $$ = cat_str(3,mm_strdup("alter server"),$3,$4);
4958 }
4959 |  ALTER SERVER name alter_generic_options
4960  {
4961  $$ = cat_str(3,mm_strdup("alter server"),$3,$4);
4962 }
4963 ;
4964 
4965 
4966  CreateForeignTableStmt:
4967  CREATE FOREIGN TABLE qualified_name '(' OptTableElementList ')' OptInherit SERVER name create_generic_options
4968  {
4969  $$ = cat_str(9,mm_strdup("create foreign table"),$4,mm_strdup("("),$6,mm_strdup(")"),$8,mm_strdup("server"),$10,$11);
4970 }
4971 |  CREATE FOREIGN TABLE IF_P NOT EXISTS qualified_name '(' OptTableElementList ')' OptInherit SERVER name create_generic_options
4972  {
4973  $$ = cat_str(9,mm_strdup("create foreign table if not exists"),$7,mm_strdup("("),$9,mm_strdup(")"),$11,mm_strdup("server"),$13,$14);
4974 }
4975 |  CREATE FOREIGN TABLE qualified_name PARTITION OF qualified_name OptTypedTableElementList ForValues SERVER name create_generic_options
4976  {
4977  $$ = cat_str(9,mm_strdup("create foreign table"),$4,mm_strdup("partition of"),$7,$8,$9,mm_strdup("server"),$11,$12);
4978 }
4979 |  CREATE FOREIGN TABLE IF_P NOT EXISTS qualified_name PARTITION OF qualified_name OptTypedTableElementList ForValues SERVER name create_generic_options
4980  {
4981  $$ = cat_str(9,mm_strdup("create foreign table if not exists"),$7,mm_strdup("partition of"),$10,$11,$12,mm_strdup("server"),$14,$15);
4982 }
4983 ;
4984 
4985 
4986  AlterForeignTableStmt:
4987  ALTER FOREIGN TABLE relation_expr alter_table_cmds
4988  {
4989  $$ = cat_str(3,mm_strdup("alter foreign table"),$4,$5);
4990 }
4991 |  ALTER FOREIGN TABLE IF_P EXISTS relation_expr alter_table_cmds
4992  {
4993  $$ = cat_str(3,mm_strdup("alter foreign table if exists"),$6,$7);
4994 }
4995 ;
4996 
4997 
4998  ImportForeignSchemaStmt:
4999  IMPORT_P FOREIGN SCHEMA name import_qualification FROM SERVER name INTO name create_generic_options
5000  {
5001  $$ = cat_str(8,mm_strdup("import foreign schema"),$4,$5,mm_strdup("from server"),$8,mm_strdup("into"),$10,$11);
5002 }
5003 ;
5004 
5005 
5006  import_qualification_type:
5007  LIMIT TO
5008  {
5009  $$ = mm_strdup("limit to");
5010 }
5011 |  EXCEPT
5012  {
5013  $$ = mm_strdup("except");
5014 }
5015 ;
5016 
5017 
5018  import_qualification:
5019  import_qualification_type '(' relation_expr_list ')'
5020  {
5021  $$ = cat_str(4,$1,mm_strdup("("),$3,mm_strdup(")"));
5022 }
5023 |
5024  {
5025  $$=EMPTY; }
5026 ;
5027 
5028 
5029  CreateUserMappingStmt:
5030  CREATE USER MAPPING FOR auth_ident SERVER name create_generic_options
5031  {
5032  $$ = cat_str(5,mm_strdup("create user mapping for"),$5,mm_strdup("server"),$7,$8);
5033 }
5034 |  CREATE USER MAPPING IF_P NOT EXISTS FOR auth_ident SERVER name create_generic_options
5035  {
5036  $$ = cat_str(5,mm_strdup("create user mapping if not exists for"),$8,mm_strdup("server"),$10,$11);
5037 }
5038 ;
5039 
5040 
5041  auth_ident:
5042  RoleSpec
5043  {
5044  $$ = $1;
5045 }
5046 |  USER
5047  {
5048  $$ = mm_strdup("user");
5049 }
5050 ;
5051 
5052 
5053  DropUserMappingStmt:
5054  DROP USER MAPPING FOR auth_ident SERVER name
5055  {
5056  $$ = cat_str(4,mm_strdup("drop user mapping for"),$5,mm_strdup("server"),$7);
5057 }
5058 |  DROP USER MAPPING IF_P EXISTS FOR auth_ident SERVER name
5059  {
5060  $$ = cat_str(4,mm_strdup("drop user mapping if exists for"),$7,mm_strdup("server"),$9);
5061 }
5062 ;
5063 
5064 
5065  AlterUserMappingStmt:
5066  ALTER USER MAPPING FOR auth_ident SERVER name alter_generic_options
5067  {
5068  $$ = cat_str(5,mm_strdup("alter user mapping for"),$5,mm_strdup("server"),$7,$8);
5069 }
5070 ;
5071 
5072 
5073  CreatePolicyStmt:
5074  CREATE POLICY name ON qualified_name RowSecurityDefaultPermissive RowSecurityDefaultForCmd RowSecurityDefaultToRole RowSecurityOptionalExpr RowSecurityOptionalWithCheck
5075  {
5076  $$ = cat_str(9,mm_strdup("create policy"),$3,mm_strdup("on"),$5,$6,$7,$8,$9,$10);
5077 }
5078 ;
5079 
5080 
5081  AlterPolicyStmt:
5082  ALTER POLICY name ON qualified_name RowSecurityOptionalToRole RowSecurityOptionalExpr RowSecurityOptionalWithCheck
5083  {
5084  $$ = cat_str(7,mm_strdup("alter policy"),$3,mm_strdup("on"),$5,$6,$7,$8);
5085 }
5086 ;
5087 
5088 
5089  RowSecurityOptionalExpr:
5090  USING '(' a_expr ')'
5091  {
5092  $$ = cat_str(3,mm_strdup("using ("),$3,mm_strdup(")"));
5093 }
5094 |
5095  {
5096  $$=EMPTY; }
5097 ;
5098 
5099 
5100  RowSecurityOptionalWithCheck:
5101  WITH CHECK '(' a_expr ')'
5102  {
5103  $$ = cat_str(3,mm_strdup("with check ("),$4,mm_strdup(")"));
5104 }
5105 |
5106  {
5107  $$=EMPTY; }
5108 ;
5109 
5110 
5111  RowSecurityDefaultToRole:
5112  TO role_list
5113  {
5114  $$ = cat_str(2,mm_strdup("to"),$2);
5115 }
5116 |
5117  {
5118  $$=EMPTY; }
5119 ;
5120 
5121 
5122  RowSecurityOptionalToRole:
5123  TO role_list
5124  {
5125  $$ = cat_str(2,mm_strdup("to"),$2);
5126 }
5127 |
5128  {
5129  $$=EMPTY; }
5130 ;
5131 
5132 
5133  RowSecurityDefaultPermissive:
5134  AS ecpg_ident
5135  {
5136  $$ = cat_str(2,mm_strdup("as"),$2);
5137 }
5138 |
5139  {
5140  $$=EMPTY; }
5141 ;
5142 
5143 
5144  RowSecurityDefaultForCmd:
5145  FOR row_security_cmd
5146  {
5147  $$ = cat_str(2,mm_strdup("for"),$2);
5148 }
5149 |
5150  {
5151  $$=EMPTY; }
5152 ;
5153 
5154 
5155  row_security_cmd:
5156  ALL
5157  {
5158  $$ = mm_strdup("all");
5159 }
5160 |  SELECT
5161  {
5162  $$ = mm_strdup("select");
5163 }
5164 |  INSERT
5165  {
5166  $$ = mm_strdup("insert");
5167 }
5168 |  UPDATE
5169  {
5170  $$ = mm_strdup("update");
5171 }
5172 |  DELETE_P
5173  {
5174  $$ = mm_strdup("delete");
5175 }
5176 ;
5177 
5178 
5179  CreateAmStmt:
5180  CREATE ACCESS METHOD name TYPE_P INDEX HANDLER handler_name
5181  {
5182  $$ = cat_str(4,mm_strdup("create access method"),$4,mm_strdup("type index handler"),$8);
5183 }
5184 ;
5185 
5186 
5187  CreateTrigStmt:
5188  CREATE TRIGGER name TriggerActionTime TriggerEvents ON qualified_name TriggerReferencing TriggerForSpec TriggerWhen EXECUTE PROCEDURE func_name '(' TriggerFuncArgs ')'
5189  {
5190  $$ = cat_str(14,mm_strdup("create trigger"),$3,$4,$5,mm_strdup("on"),$7,$8,$9,$10,mm_strdup("execute procedure"),$13,mm_strdup("("),$15,mm_strdup(")"));
5191 }
5192 |  CREATE CONSTRAINT TRIGGER name AFTER TriggerEvents ON qualified_name OptConstrFromTable ConstraintAttributeSpec FOR EACH ROW TriggerWhen EXECUTE PROCEDURE func_name '(' TriggerFuncArgs ')'
5193  {
5194  $$ = cat_str(15,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 procedure"),$17,mm_strdup("("),$19,mm_strdup(")"));
5195 }
5196 ;
5197 
5198 
5199  TriggerActionTime:
5200  BEFORE
5201  {
5202  $$ = mm_strdup("before");
5203 }
5204 |  AFTER
5205  {
5206  $$ = mm_strdup("after");
5207 }
5208 |  INSTEAD OF
5209  {
5210  $$ = mm_strdup("instead of");
5211 }
5212 ;
5213 
5214 
5215  TriggerEvents:
5216  TriggerOneEvent
5217  {
5218  $$ = $1;
5219 }
5220 |  TriggerEvents OR TriggerOneEvent
5221  {
5222  $$ = cat_str(3,$1,mm_strdup("or"),$3);
5223 }
5224 ;
5225 
5226 
5227  TriggerOneEvent:
5228  INSERT
5229  {
5230  $$ = mm_strdup("insert");
5231 }
5232 |  DELETE_P
5233  {
5234  $$ = mm_strdup("delete");
5235 }
5236 |  UPDATE
5237  {
5238  $$ = mm_strdup("update");
5239 }
5240 |  UPDATE OF columnList
5241  {
5242  $$ = cat_str(2,mm_strdup("update of"),$3);
5243 }
5244 |  TRUNCATE
5245  {
5246  $$ = mm_strdup("truncate");
5247 }
5248 ;
5249 
5250 
5251  TriggerReferencing:
5252  REFERENCING TriggerTransitions
5253  {
5254  $$ = cat_str(2,mm_strdup("referencing"),$2);
5255 }
5256 |
5257  {
5258  $$=EMPTY; }
5259 ;
5260 
5261 
5262  TriggerTransitions:
5263  TriggerTransition
5264  {
5265  $$ = $1;
5266 }
5267 |  TriggerTransitions TriggerTransition
5268  {
5269  $$ = cat_str(2,$1,$2);
5270 }
5271 ;
5272 
5273 
5274  TriggerTransition:
5275  TransitionOldOrNew TransitionRowOrTable opt_as TransitionRelName
5276  {
5277  $$ = cat_str(4,$1,$2,$3,$4);
5278 }
5279 ;
5280 
5281 
5282  TransitionOldOrNew:
5283  NEW
5284  {
5285  $$ = mm_strdup("new");
5286 }
5287 |  OLD
5288  {
5289  $$ = mm_strdup("old");
5290 }
5291 ;
5292 
5293 
5294  TransitionRowOrTable:
5295  TABLE
5296  {
5297  $$ = mm_strdup("table");
5298 }
5299 |  ROW
5300  {
5301  $$ = mm_strdup("row");
5302 }
5303 ;
5304 
5305 
5306  TransitionRelName:
5307  ColId
5308  {
5309  $$ = $1;
5310 }
5311 ;
5312 
5313 
5314  TriggerForSpec:
5315  FOR TriggerForOptEach TriggerForType
5316  {
5317  $$ = cat_str(3,mm_strdup("for"),$2,$3);
5318 }
5319 |
5320  {
5321  $$=EMPTY; }
5322 ;
5323 
5324 
5325  TriggerForOptEach:
5326  EACH
5327  {
5328  $$ = mm_strdup("each");
5329 }
5330 |
5331  {
5332  $$=EMPTY; }
5333 ;
5334 
5335 
5336  TriggerForType:
5337  ROW
5338  {
5339  $$ = mm_strdup("row");
5340 }
5341 |  STATEMENT
5342  {
5343  $$ = mm_strdup("statement");
5344 }
5345 ;
5346 
5347 
5348  TriggerWhen:
5349  WHEN '(' a_expr ')'
5350  {
5351  $$ = cat_str(3,mm_strdup("when ("),$3,mm_strdup(")"));
5352 }
5353 |
5354  {
5355  $$=EMPTY; }
5356 ;
5357 
5358 
5359  TriggerFuncArgs:
5360  TriggerFuncArg
5361  {
5362  $$ = $1;
5363 }
5364 |  TriggerFuncArgs ',' TriggerFuncArg
5365  {
5366  $$ = cat_str(3,$1,mm_strdup(","),$3);
5367 }
5368 |
5369  {
5370  $$=EMPTY; }
5371 ;
5372 
5373 
5374  TriggerFuncArg:
5375  Iconst
5376  {
5377  $$ = $1;
5378 }
5379 |  ecpg_fconst
5380  {
5381  $$ = $1;
5382 }
5383 |  ecpg_sconst
5384  {
5385  $$ = $1;
5386 }
5387 |  ColLabel
5388  {
5389  $$ = $1;
5390 }
5391 ;
5392 
5393 
5394  OptConstrFromTable:
5395  FROM qualified_name
5396  {
5397  $$ = cat_str(2,mm_strdup("from"),$2);
5398 }
5399 |
5400  {
5401  $$=EMPTY; }
5402 ;
5403 
5404 
5405  ConstraintAttributeSpec:
5406 
5407  {
5408  $$=EMPTY; }
5409 |  ConstraintAttributeSpec ConstraintAttributeElem
5410  {
5411  $$ = cat_str(2,$1,$2);
5412 }
5413 ;
5414 
5415 
5416  ConstraintAttributeElem:
5417  NOT DEFERRABLE
5418  {
5419  $$ = mm_strdup("not deferrable");
5420 }
5421 |  DEFERRABLE
5422  {
5423  $$ = mm_strdup("deferrable");
5424 }
5425 |  INITIALLY IMMEDIATE
5426  {
5427  $$ = mm_strdup("initially immediate");
5428 }
5429 |  INITIALLY DEFERRED
5430  {
5431  $$ = mm_strdup("initially deferred");
5432 }
5433 |  NOT VALID
5434  {
5435  $$ = mm_strdup("not valid");
5436 }
5437 |  NO INHERIT
5438  {
5439  $$ = mm_strdup("no inherit");
5440 }
5441 ;
5442 
5443 
5444  CreateEventTrigStmt:
5445  CREATE EVENT TRIGGER name ON ColLabel EXECUTE PROCEDURE func_name '(' ')'
5446  {
5447  $$ = cat_str(7,mm_strdup("create event trigger"),$4,mm_strdup("on"),$6,mm_strdup("execute procedure"),$9,mm_strdup("( )"));
5448 }
5449 |  CREATE EVENT TRIGGER name ON ColLabel WHEN event_trigger_when_list EXECUTE PROCEDURE func_name '(' ')'
5450  {
5451  $$ = cat_str(9,mm_strdup("create event trigger"),$4,mm_strdup("on"),$6,mm_strdup("when"),$8,mm_strdup("execute procedure"),$11,mm_strdup("( )"));
5452 }
5453 ;
5454 
5455 
5456  event_trigger_when_list:
5457  event_trigger_when_item
5458  {
5459  $$ = $1;
5460 }
5461 |  event_trigger_when_list AND event_trigger_when_item
5462  {
5463  $$ = cat_str(3,$1,mm_strdup("and"),$3);
5464 }
5465 ;
5466 
5467 
5468  event_trigger_when_item:
5469  ColId IN_P '(' event_trigger_value_list ')'
5470  {
5471  $$ = cat_str(4,$1,mm_strdup("in ("),$4,mm_strdup(")"));
5472 }
5473 ;
5474 
5475 
5476  event_trigger_value_list:
5477  SCONST
5478  {
5479  $$ = mm_strdup("sconst");
5480 }
5481 |  event_trigger_value_list ',' SCONST
5482  {
5483  $$ = cat_str(2,$1,mm_strdup(", sconst"));
5484 }
5485 ;
5486 
5487 
5488  AlterEventTrigStmt:
5489  ALTER EVENT TRIGGER name enable_trigger
5490  {
5491  $$ = cat_str(3,mm_strdup("alter event trigger"),$4,$5);
5492 }
5493 ;
5494 
5495 
5496  enable_trigger:
5497  ENABLE_P
5498  {
5499  $$ = mm_strdup("enable");
5500 }
5501 |  ENABLE_P REPLICA
5502  {
5503  $$ = mm_strdup("enable replica");
5504 }
5505 |  ENABLE_P ALWAYS
5506  {
5507  $$ = mm_strdup("enable always");
5508 }
5509 |  DISABLE_P
5510  {
5511  $$ = mm_strdup("disable");
5512 }
5513 ;
5514 
5515 
5516  CreateAssertStmt:
5517  CREATE ASSERTION name CHECK '(' a_expr ')' ConstraintAttributeSpec
5518  {
5519 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
5520  $$ = cat_str(6,mm_strdup("create assertion"),$3,mm_strdup("check ("),$6,mm_strdup(")"),$8);
5521 }
5522 ;
5523 
5524 
5525  DropAssertStmt:
5526  DROP ASSERTION name opt_drop_behavior
5527  {
5528 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
5529  $$ = cat_str(3,mm_strdup("drop assertion"),$3,$4);
5530 }
5531 ;
5532 
5533 
5534  DefineStmt:
5535  CREATE AGGREGATE func_name aggr_args definition
5536  {
5537  $$ = cat_str(4,mm_strdup("create aggregate"),$3,$4,$5);
5538 }
5539 |  CREATE AGGREGATE func_name old_aggr_definition
5540  {
5541  $$ = cat_str(3,mm_strdup("create aggregate"),$3,$4);
5542 }
5543 |  CREATE OPERATOR any_operator definition
5544  {
5545  $$ = cat_str(3,mm_strdup("create operator"),$3,$4);
5546 }
5547 |  CREATE TYPE_P any_name definition
5548  {
5549  $$ = cat_str(3,mm_strdup("create type"),$3,$4);
5550 }
5551 |  CREATE TYPE_P any_name
5552  {
5553  $$ = cat_str(2,mm_strdup("create type"),$3);
5554 }
5555 |  CREATE TYPE_P any_name AS '(' OptTableFuncElementList ')'
5556  {
5557  $$ = cat_str(5,mm_strdup("create type"),$3,mm_strdup("as ("),$6,mm_strdup(")"));
5558 }
5559 |  CREATE TYPE_P any_name AS ENUM_P '(' opt_enum_val_list ')'
5560  {
5561  $$ = cat_str(5,mm_strdup("create type"),$3,mm_strdup("as enum ("),$7,mm_strdup(")"));
5562 }
5563 |  CREATE TYPE_P any_name AS RANGE definition
5564  {
5565  $$ = cat_str(4,mm_strdup("create type"),$3,mm_strdup("as range"),$6);
5566 }
5567 |  CREATE TEXT_P SEARCH PARSER any_name definition
5568  {
5569  $$ = cat_str(3,mm_strdup("create text search parser"),$5,$6);
5570 }
5571 |  CREATE TEXT_P SEARCH DICTIONARY any_name definition
5572  {
5573  $$ = cat_str(3,mm_strdup("create text search dictionary"),$5,$6);
5574 }
5575 |  CREATE TEXT_P SEARCH TEMPLATE any_name definition
5576  {
5577  $$ = cat_str(3,mm_strdup("create text search template"),$5,$6);
5578 }
5579 |  CREATE TEXT_P SEARCH CONFIGURATION any_name definition
5580  {
5581  $$ = cat_str(3,mm_strdup("create text search configuration"),$5,$6);
5582 }
5583 |  CREATE COLLATION any_name definition
5584  {
5585  $$ = cat_str(3,mm_strdup("create collation"),$3,$4);
5586 }
5587 |  CREATE COLLATION IF_P NOT EXISTS any_name definition
5588  {
5589  $$ = cat_str(3,mm_strdup("create collation if not exists"),$6,$7);
5590 }
5591 |  CREATE COLLATION any_name FROM any_name
5592  {
5593  $$ = cat_str(4,mm_strdup("create collation"),$3,mm_strdup("from"),$5);
5594 }
5595 |  CREATE COLLATION IF_P NOT EXISTS any_name FROM any_name
5596  {
5597  $$ = cat_str(4,mm_strdup("create collation if not exists"),$6,mm_strdup("from"),$8);
5598 }
5599 ;
5600 
5601 
5602  definition:
5603  '(' def_list ')'
5604  {
5605  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
5606 }
5607 ;
5608 
5609 
5610  def_list:
5611  def_elem
5612  {
5613  $$ = $1;
5614 }
5615 |  def_list ',' def_elem
5616  {
5617  $$ = cat_str(3,$1,mm_strdup(","),$3);
5618 }
5619 ;
5620 
5621 
5622  def_elem:
5623  ColLabel '=' def_arg
5624  {
5625  $$ = cat_str(3,$1,mm_strdup("="),$3);
5626 }
5627 |  ColLabel
5628  {
5629  $$ = $1;
5630 }
5631 ;
5632 
5633 
5634  def_arg:
5635  func_type
5636  {
5637  $$ = $1;
5638 }
5639 |  reserved_keyword
5640  {
5641  $$ = $1;
5642 }
5643 |  qual_all_Op
5644  {
5645  $$ = $1;
5646 }
5647 |  NumericOnly
5648  {
5649  $$ = $1;
5650 }
5651 |  ecpg_sconst
5652  {
5653  $$ = $1;
5654 }
5655 |  NONE
5656  {
5657  $$ = mm_strdup("none");
5658 }
5659 ;
5660 
5661 
5662  old_aggr_definition:
5663  '(' old_aggr_list ')'
5664  {
5665  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
5666 }
5667 ;
5668 
5669 
5670  old_aggr_list:
5671  old_aggr_elem
5672  {
5673  $$ = $1;
5674 }
5675 |  old_aggr_list ',' old_aggr_elem
5676  {
5677  $$ = cat_str(3,$1,mm_strdup(","),$3);
5678 }
5679 ;
5680 
5681 
5682  old_aggr_elem:
5683  ecpg_ident '=' def_arg
5684  {
5685  $$ = cat_str(3,$1,mm_strdup("="),$3);
5686 }
5687 ;
5688 
5689 
5690  opt_enum_val_list:
5691  enum_val_list
5692  {
5693  $$ = $1;
5694 }
5695 |
5696  {
5697  $$=EMPTY; }
5698 ;
5699 
5700 
5701  enum_val_list:
5702  ecpg_sconst
5703  {
5704  $$ = $1;
5705 }
5706 |  enum_val_list ',' ecpg_sconst
5707  {
5708  $$ = cat_str(3,$1,mm_strdup(","),$3);
5709 }
5710 ;
5711 
5712 
5713  AlterEnumStmt:
5714  ALTER TYPE_P any_name ADD_P VALUE_P opt_if_not_exists ecpg_sconst
5715  {
5716  $$ = cat_str(5,mm_strdup("alter type"),$3,mm_strdup("add value"),$6,$7);
5717 }
5718 |  ALTER TYPE_P any_name ADD_P VALUE_P opt_if_not_exists ecpg_sconst BEFORE ecpg_sconst
5719  {
5720  $$ = cat_str(7,mm_strdup("alter type"),$3,mm_strdup("add value"),$6,$7,mm_strdup("before"),$9);
5721 }
5722 |  ALTER TYPE_P any_name ADD_P VALUE_P opt_if_not_exists ecpg_sconst AFTER ecpg_sconst
5723  {
5724  $$ = cat_str(7,mm_strdup("alter type"),$3,mm_strdup("add value"),$6,$7,mm_strdup("after"),$9);
5725 }
5726 |  ALTER TYPE_P any_name RENAME VALUE_P ecpg_sconst TO ecpg_sconst
5727  {
5728  $$ = cat_str(6,mm_strdup("alter type"),$3,mm_strdup("rename value"),$6,mm_strdup("to"),$8);
5729 }
5730 ;
5731 
5732 
5733  opt_if_not_exists:
5734  IF_P NOT EXISTS
5735  {
5736  $$ = mm_strdup("if not exists");
5737 }
5738 |
5739  {
5740  $$=EMPTY; }
5741 ;
5742 
5743 
5744  CreateOpClassStmt:
5745  CREATE OPERATOR CLASS any_name opt_default FOR TYPE_P Typename USING access_method opt_opfamily AS opclass_item_list
5746  {
5747  $$ = cat_str(10,mm_strdup("create operator class"),$4,$5,mm_strdup("for type"),$8,mm_strdup("using"),$10,$11,mm_strdup("as"),$13);
5748 }
5749 ;
5750 
5751 
5752  opclass_item_list:
5753  opclass_item
5754  {
5755  $$ = $1;
5756 }
5757 |  opclass_item_list ',' opclass_item
5758  {
5759  $$ = cat_str(3,$1,mm_strdup(","),$3);
5760 }
5761 ;
5762 
5763 
5764  opclass_item:
5765  OPERATOR Iconst any_operator opclass_purpose opt_recheck
5766  {
5767  $$ = cat_str(5,mm_strdup("operator"),$2,$3,$4,$5);
5768 }
5769 |  OPERATOR Iconst operator_with_argtypes opclass_purpose opt_recheck
5770  {
5771  $$ = cat_str(5,mm_strdup("operator"),$2,$3,$4,$5);
5772 }
5773 |  FUNCTION Iconst function_with_argtypes
5774  {
5775  $$ = cat_str(3,mm_strdup("function"),$2,$3);
5776 }
5777 |  FUNCTION Iconst '(' type_list ')' function_with_argtypes
5778  {
5779  $$ = cat_str(6,mm_strdup("function"),$2,mm_strdup("("),$4,mm_strdup(")"),$6);
5780 }
5781 |  STORAGE Typename
5782  {
5783  $$ = cat_str(2,mm_strdup("storage"),$2);
5784 }
5785 ;
5786 
5787 
5788  opt_default:
5789  DEFAULT
5790  {
5791  $$ = mm_strdup("default");
5792 }
5793 |
5794  {
5795  $$=EMPTY; }
5796 ;
5797 
5798 
5799  opt_opfamily:
5800  FAMILY any_name
5801  {
5802  $$ = cat_str(2,mm_strdup("family"),$2);
5803 }
5804 |
5805  {
5806  $$=EMPTY; }
5807 ;
5808 
5809 
5810  opclass_purpose:
5811  FOR SEARCH
5812  {
5813  $$ = mm_strdup("for search");
5814 }
5815 |  FOR ORDER BY any_name
5816  {
5817  $$ = cat_str(2,mm_strdup("for order by"),$4);
5818 }
5819 |
5820  {
5821  $$=EMPTY; }
5822 ;
5823 
5824 
5825  opt_recheck:
5826  RECHECK
5827  {
5828 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
5829  $$ = mm_strdup("recheck");
5830 }
5831 |
5832  {
5833  $$=EMPTY; }
5834 ;
5835 
5836 
5837  CreateOpFamilyStmt:
5838  CREATE OPERATOR FAMILY any_name USING access_method
5839  {
5840  $$ = cat_str(4,mm_strdup("create operator family"),$4,mm_strdup("using"),$6);
5841 }
5842 ;
5843 
5844 
5845  AlterOpFamilyStmt:
5846  ALTER OPERATOR FAMILY any_name USING access_method ADD_P opclass_item_list
5847  {
5848  $$ = cat_str(6,mm_strdup("alter operator family"),$4,mm_strdup("using"),$6,mm_strdup("add"),$8);
5849 }
5850 |  ALTER OPERATOR FAMILY any_name USING access_method DROP opclass_drop_list
5851  {
5852  $$ = cat_str(6,mm_strdup("alter operator family"),$4,mm_strdup("using"),$6,mm_strdup("drop"),$8);
5853 }
5854 ;
5855 
5856 
5857  opclass_drop_list:
5858  opclass_drop
5859  {
5860  $$ = $1;
5861 }
5862 |  opclass_drop_list ',' opclass_drop
5863  {
5864  $$ = cat_str(3,$1,mm_strdup(","),$3);
5865 }
5866 ;
5867 
5868 
5869  opclass_drop:
5870  OPERATOR Iconst '(' type_list ')'
5871  {
5872  $$ = cat_str(5,mm_strdup("operator"),$2,mm_strdup("("),$4,mm_strdup(")"));
5873 }
5874 |  FUNCTION Iconst '(' type_list ')'
5875  {
5876  $$ = cat_str(5,mm_strdup("function"),$2,mm_strdup("("),$4,mm_strdup(")"));
5877 }
5878 ;
5879 
5880 
5881  DropOpClassStmt:
5882  DROP OPERATOR CLASS any_name USING access_method opt_drop_behavior
5883  {
5884  $$ = cat_str(5,mm_strdup("drop operator class"),$4,mm_strdup("using"),$6,$7);
5885 }
5886 |  DROP OPERATOR CLASS IF_P EXISTS any_name USING access_method opt_drop_behavior
5887  {
5888  $$ = cat_str(5,mm_strdup("drop operator class if exists"),$6,mm_strdup("using"),$8,$9);
5889 }
5890 ;
5891 
5892 
5893  DropOpFamilyStmt:
5894  DROP OPERATOR FAMILY any_name USING access_method opt_drop_behavior
5895  {
5896  $$ = cat_str(5,mm_strdup("drop operator family"),$4,mm_strdup("using"),$6,$7);
5897 }
5898 |  DROP OPERATOR FAMILY IF_P EXISTS any_name USING access_method opt_drop_behavior
5899  {
5900  $$ = cat_str(5,mm_strdup("drop operator family if exists"),$6,mm_strdup("using"),$8,$9);
5901 }
5902 ;
5903 
5904 
5905  DropOwnedStmt:
5906  DROP OWNED BY role_list opt_drop_behavior
5907  {
5908  $$ = cat_str(3,mm_strdup("drop owned by"),$4,$5);
5909 }
5910 ;
5911 
5912 
5913  ReassignOwnedStmt:
5914  REASSIGN OWNED BY role_list TO RoleSpec
5915  {
5916  $$ = cat_str(4,mm_strdup("reassign owned by"),$4,mm_strdup("to"),$6);
5917 }
5918 ;
5919 
5920 
5921  DropStmt:
5922  DROP drop_type_any_name IF_P EXISTS any_name_list opt_drop_behavior
5923  {
5924  $$ = cat_str(5,mm_strdup("drop"),$2,mm_strdup("if exists"),$5,$6);
5925 }
5926 |  DROP drop_type_any_name any_name_list opt_drop_behavior
5927  {
5928  $$ = cat_str(4,mm_strdup("drop"),$2,$3,$4);
5929 }
5930 |  DROP drop_type_name IF_P EXISTS name_list opt_drop_behavior
5931  {
5932  $$ = cat_str(5,mm_strdup("drop"),$2,mm_strdup("if exists"),$5,$6);
5933 }
5934 |  DROP drop_type_name name_list opt_drop_behavior
5935  {
5936  $$ = cat_str(4,mm_strdup("drop"),$2,$3,$4);
5937 }
5938 |  DROP drop_type_name_on_any_name name ON any_name opt_drop_behavior
5939  {
5940  $$ = cat_str(6,mm_strdup("drop"),$2,$3,mm_strdup("on"),$5,$6);
5941 }
5942 |  DROP drop_type_name_on_any_name IF_P EXISTS name ON any_name opt_drop_behavior
5943  {
5944  $$ = cat_str(7,mm_strdup("drop"),$2,mm_strdup("if exists"),$5,mm_strdup("on"),$7,$8);
5945 }
5946 |  DROP TYPE_P type_name_list opt_drop_behavior
5947  {
5948  $$ = cat_str(3,mm_strdup("drop type"),$3,$4);
5949 }
5950 |  DROP TYPE_P IF_P EXISTS type_name_list opt_drop_behavior
5951  {
5952  $$ = cat_str(3,mm_strdup("drop type if exists"),$5,$6);
5953 }
5954 |  DROP DOMAIN_P type_name_list opt_drop_behavior
5955  {
5956  $$ = cat_str(3,mm_strdup("drop domain"),$3,$4);
5957 }
5958 |  DROP DOMAIN_P IF_P EXISTS type_name_list opt_drop_behavior
5959  {
5960  $$ = cat_str(3,mm_strdup("drop domain if exists"),$5,$6);
5961 }
5962 |  DROP INDEX CONCURRENTLY any_name_list opt_drop_behavior
5963  {
5964  $$ = cat_str(3,mm_strdup("drop index concurrently"),$4,$5);
5965 }
5966 |  DROP INDEX CONCURRENTLY IF_P EXISTS any_name_list opt_drop_behavior
5967  {
5968  $$ = cat_str(3,mm_strdup("drop index concurrently if exists"),$6,$7);
5969 }
5970 ;
5971 
5972 
5973  drop_type_any_name:
5974  TABLE
5975  {
5976  $$ = mm_strdup("table");
5977 }
5978 |  SEQUENCE
5979  {
5980  $$ = mm_strdup("sequence");
5981 }
5982 |  VIEW
5983  {
5984  $$ = mm_strdup("view");
5985 }
5986 |  MATERIALIZED VIEW
5987  {
5988  $$ = mm_strdup("materialized view");
5989 }
5990 |  INDEX
5991  {
5992  $$ = mm_strdup("index");
5993 }
5994 |  FOREIGN TABLE
5995  {
5996  $$ = mm_strdup("foreign table");
5997 }
5998 |  COLLATION
5999  {
6000  $$ = mm_strdup("collation");
6001 }
6002 |  CONVERSION_P
6003  {
6004  $$ = mm_strdup("conversion");
6005 }
6006 |  STATISTICS
6007  {
6008  $$ = mm_strdup("statistics");
6009 }
6010 |  TEXT_P SEARCH PARSER
6011  {
6012  $$ = mm_strdup("text search parser");
6013 }
6014 |  TEXT_P SEARCH DICTIONARY
6015  {
6016  $$ = mm_strdup("text search dictionary");
6017 }
6018 |  TEXT_P SEARCH TEMPLATE
6019  {
6020  $$ = mm_strdup("text search template");
6021 }
6022 |  TEXT_P SEARCH CONFIGURATION
6023  {
6024  $$ = mm_strdup("text search configuration");
6025 }
6026 ;
6027 
6028 
6029  drop_type_name:
6030  ACCESS METHOD
6031  {
6032  $$ = mm_strdup("access method");
6033 }
6034 |  EVENT TRIGGER
6035  {
6036  $$ = mm_strdup("event trigger");
6037 }
6038 |  EXTENSION
6039  {
6040  $$ = mm_strdup("extension");
6041 }
6042 |  FOREIGN DATA_P WRAPPER
6043  {
6044  $$ = mm_strdup("foreign data wrapper");
6045 }
6046 |  PUBLICATION
6047  {
6048  $$ = mm_strdup("publication");
6049 }
6050 |  SCHEMA
6051  {
6052  $$ = mm_strdup("schema");
6053 }
6054 |  SERVER
6055  {
6056  $$ = mm_strdup("server");
6057 }
6058 ;
6059 
6060 
6061  drop_type_name_on_any_name:
6062  POLICY
6063  {
6064  $$ = mm_strdup("policy");
6065 }
6066 |  RULE
6067  {
6068  $$ = mm_strdup("rule");
6069 }
6070 |  TRIGGER
6071  {
6072  $$ = mm_strdup("trigger");
6073 }
6074 ;
6075 
6076 
6077  any_name_list:
6078  any_name
6079  {
6080  $$ = $1;
6081 }
6082 |  any_name_list ',' any_name
6083  {
6084  $$ = cat_str(3,$1,mm_strdup(","),$3);
6085 }
6086 ;
6087 
6088 
6089  any_name:
6090  ColId
6091  {
6092  $$ = $1;
6093 }
6094 |  ColId attrs
6095  {
6096  $$ = cat_str(2,$1,$2);
6097 }
6098 ;
6099 
6100 
6101  attrs:
6102  '.' attr_name
6103  {
6104  $$ = cat_str(2,mm_strdup("."),$2);
6105 }
6106 |  attrs '.' attr_name
6107  {
6108  $$ = cat_str(3,$1,mm_strdup("."),$3);
6109 }
6110 ;
6111 
6112 
6113  type_name_list:
6114  Typename
6115  {
6116  $$ = $1;
6117 }
6118 |  type_name_list ',' Typename
6119  {
6120  $$ = cat_str(3,$1,mm_strdup(","),$3);
6121 }
6122 ;
6123 
6124 
6125  TruncateStmt:
6126  TRUNCATE opt_table relation_expr_list opt_restart_seqs opt_drop_behavior
6127  {
6128  $$ = cat_str(5,mm_strdup("truncate"),$2,$3,$4,$5);
6129 }
6130 ;
6131 
6132 
6133  opt_restart_seqs:
6134  CONTINUE_P IDENTITY_P
6135  {
6136  $$ = mm_strdup("continue identity");
6137 }
6138 |  RESTART IDENTITY_P
6139  {
6140  $$ = mm_strdup("restart identity");
6141 }
6142 |
6143  {
6144  $$=EMPTY; }
6145 ;
6146 
6147 
6148  CommentStmt:
6149  COMMENT ON comment_type_any_name any_name IS comment_text
6150  {
6151  $$ = cat_str(5,mm_strdup("comment on"),$3,$4,mm_strdup("is"),$6);
6152 }
6153 |  COMMENT ON comment_type_name name IS comment_text
6154  {
6155  $$ = cat_str(5,mm_strdup("comment on"),$3,$4,mm_strdup("is"),$6);
6156 }
6157 |  COMMENT ON TYPE_P Typename IS comment_text
6158  {
6159  $$ = cat_str(4,mm_strdup("comment on type"),$4,mm_strdup("is"),$6);
6160 }
6161 |  COMMENT ON DOMAIN_P Typename IS comment_text
6162  {
6163  $$ = cat_str(4,mm_strdup("comment on domain"),$4,mm_strdup("is"),$6);
6164 }
6165 |  COMMENT ON AGGREGATE aggregate_with_argtypes IS comment_text
6166  {
6167  $$ = cat_str(4,mm_strdup("comment on aggregate"),$4,mm_strdup("is"),$6);
6168 }
6169 |  COMMENT ON FUNCTION function_with_argtypes IS comment_text
6170  {
6171  $$ = cat_str(4,mm_strdup("comment on function"),$4,mm_strdup("is"),$6);
6172 }
6173 |  COMMENT ON OPERATOR operator_with_argtypes IS comment_text
6174  {
6175  $$ = cat_str(4,mm_strdup("comment on operator"),$4,mm_strdup("is"),$6);
6176 }
6177 |  COMMENT ON CONSTRAINT name ON any_name IS comment_text
6178  {
6179  $$ = cat_str(6,mm_strdup("comment on constraint"),$4,mm_strdup("on"),$6,mm_strdup("is"),$8);
6180 }
6181 |  COMMENT ON CONSTRAINT name ON DOMAIN_P any_name IS comment_text
6182  {
6183  $$ = cat_str(6,mm_strdup("comment on constraint"),$4,mm_strdup("on domain"),$7,mm_strdup("is"),$9);
6184 }
6185 |  COMMENT ON POLICY name ON any_name IS comment_text
6186  {
6187  $$ = cat_str(6,mm_strdup("comment on policy"),$4,mm_strdup("on"),$6,mm_strdup("is"),$8);
6188 }
6189 |  COMMENT ON RULE name ON any_name IS comment_text
6190  {
6191  $$ = cat_str(6,mm_strdup("comment on rule"),$4,mm_strdup("on"),$6,mm_strdup("is"),$8);
6192 }
6193 |  COMMENT ON TRANSFORM FOR Typename LANGUAGE name IS comment_text
6194  {
6195  $$ = cat_str(6,mm_strdup("comment on transform for"),$5,mm_strdup("language"),$7,mm_strdup("is"),$9);
6196 }
6197 |  COMMENT ON TRIGGER name ON any_name IS comment_text
6198  {
6199  $$ = cat_str(6,mm_strdup("comment on trigger"),$4,mm_strdup("on"),$6,mm_strdup("is"),$8);
6200 }
6201 |  COMMENT ON OPERATOR CLASS any_name USING access_method IS comment_text
6202  {
6203  $$ = cat_str(6,mm_strdup("comment on operator class"),$5,mm_strdup("using"),$7,mm_strdup("is"),$9);
6204 }
6205 |  COMMENT ON OPERATOR FAMILY any_name USING access_method IS comment_text
6206  {
6207  $$ = cat_str(6,mm_strdup("comment on operator family"),$5,mm_strdup("using"),$7,mm_strdup("is"),$9);
6208 }
6209 |  COMMENT ON LARGE_P OBJECT_P NumericOnly IS comment_text
6210  {
6211  $$ = cat_str(4,mm_strdup("comment on large object"),$5,mm_strdup("is"),$7);
6212 }
6213 |  COMMENT ON CAST '(' Typename AS Typename ')' IS comment_text
6214  {
6215  $$ = cat_str(6,mm_strdup("comment on cast ("),$5,mm_strdup("as"),$7,mm_strdup(") is"),$10);
6216 }
6217 ;
6218 
6219 
6220  comment_type_any_name:
6221  COLUMN
6222  {
6223  $$ = mm_strdup("column");
6224 }
6225 |  INDEX
6226  {
6227  $$ = mm_strdup("index");
6228 }
6229 |  SEQUENCE
6230  {
6231  $$ = mm_strdup("sequence");
6232 }
6233 |  STATISTICS
6234  {
6235  $$ = mm_strdup("statistics");
6236 }
6237 |  TABLE
6238  {
6239  $$ = mm_strdup("table");
6240 }
6241 |  VIEW
6242  {
6243  $$ = mm_strdup("view");
6244 }
6245 |  MATERIALIZED VIEW
6246  {
6247  $$ = mm_strdup("materialized view");
6248 }
6249 |  COLLATION
6250  {
6251  $$ = mm_strdup("collation");
6252 }
6253 |  CONVERSION_P
6254  {
6255  $$ = mm_strdup("conversion");
6256 }
6257 |  FOREIGN TABLE
6258  {
6259  $$ = mm_strdup("foreign table");
6260 }
6261 |  TEXT_P SEARCH CONFIGURATION
6262  {
6263  $$ = mm_strdup("text search configuration");
6264 }
6265 |  TEXT_P SEARCH DICTIONARY
6266  {
6267  $$ = mm_strdup("text search dictionary");
6268 }
6269 |  TEXT_P SEARCH PARSER
6270  {
6271  $$ = mm_strdup("text search parser");
6272 }
6273 |  TEXT_P SEARCH TEMPLATE
6274  {
6275  $$ = mm_strdup("text search template");
6276 }
6277 ;
6278 
6279 
6280  comment_type_name:
6281  ACCESS METHOD
6282  {
6283  $$ = mm_strdup("access method");
6284 }
6285 |  DATABASE
6286  {
6287  $$ = mm_strdup("database");
6288 }
6289 |  EVENT TRIGGER
6290  {
6291  $$ = mm_strdup("event trigger");
6292 }
6293 |  EXTENSION
6294  {
6295  $$ = mm_strdup("extension");
6296 }
6297 |  FOREIGN DATA_P WRAPPER
6298  {
6299  $$ = mm_strdup("foreign data wrapper");
6300 }
6301 |  opt_procedural LANGUAGE
6302  {
6303  $$ = cat_str(2,$1,mm_strdup("language"));
6304 }
6305 |  PUBLICATION
6306  {
6307  $$ = mm_strdup("publication");
6308 }
6309 |  ROLE
6310  {
6311  $$ = mm_strdup("role");
6312 }
6313 |  SCHEMA
6314  {
6315  $$ = mm_strdup("schema");
6316 }
6317 |  SERVER
6318  {
6319  $$ = mm_strdup("server");
6320 }
6321 |  SUBSCRIPTION
6322  {
6323  $$ = mm_strdup("subscription");
6324 }
6325 |  TABLESPACE
6326  {
6327  $$ = mm_strdup("tablespace");
6328 }
6329 ;
6330 
6331 
6332  comment_text:
6333  ecpg_sconst
6334  {
6335  $$ = $1;
6336 }
6337 |  NULL_P
6338  {
6339  $$ = mm_strdup("null");
6340 }
6341 ;
6342 
6343 
6344  SecLabelStmt:
6345  SECURITY LABEL opt_provider ON security_label_type_any_name any_name IS security_label
6346  {
6347  $$ = cat_str(7,mm_strdup("security label"),$3,mm_strdup("on"),$5,$6,mm_strdup("is"),$8);
6348 }
6349 |  SECURITY LABEL opt_provider ON security_label_type_name name IS security_label
6350  {
6351  $$ = cat_str(7,mm_strdup("security label"),$3,mm_strdup("on"),$5,$6,mm_strdup("is"),$8);
6352 }
6353 |  SECURITY LABEL opt_provider ON TYPE_P Typename IS security_label
6354  {
6355  $$ = cat_str(6,mm_strdup("security label"),$3,mm_strdup("on type"),$6,mm_strdup("is"),$8);
6356 }
6357 |  SECURITY LABEL opt_provider ON DOMAIN_P Typename IS security_label
6358  {
6359  $$ = cat_str(6,mm_strdup("security label"),$3,mm_strdup("on domain"),$6,mm_strdup("is"),$8);
6360 }
6361 |  SECURITY LABEL opt_provider ON AGGREGATE aggregate_with_argtypes IS security_label
6362  {
6363  $$ = cat_str(6,mm_strdup("security label"),$3,mm_strdup("on aggregate"),$6,mm_strdup("is"),$8);
6364 }
6365 |  SECURITY LABEL opt_provider ON FUNCTION function_with_argtypes IS security_label
6366  {
6367  $$ = cat_str(6,mm_strdup("security label"),$3,mm_strdup("on function"),$6,mm_strdup("is"),$8);
6368 }
6369 |  SECURITY LABEL opt_provider ON LARGE_P OBJECT_P NumericOnly IS security_label
6370  {
6371  $$ = cat_str(6,mm_strdup("security label"),$3,mm_strdup("on large object"),$7,mm_strdup("is"),$9);
6372 }
6373 ;
6374 
6375 
6376  opt_provider:
6377  FOR NonReservedWord_or_Sconst
6378  {
6379  $$ = cat_str(2,mm_strdup("for"),$2);
6380 }
6381 |
6382  {
6383  $$=EMPTY; }
6384 ;
6385 
6386 
6387  security_label_type_any_name:
6388  COLUMN
6389  {
6390  $$ = mm_strdup("column");
6391 }
6392 |  FOREIGN TABLE
6393  {
6394  $$ = mm_strdup("foreign table");
6395 }
6396 |  SEQUENCE
6397  {
6398  $$ = mm_strdup("sequence");
6399 }
6400 |  TABLE
6401  {
6402  $$ = mm_strdup("table");
6403 }
6404 |  VIEW
6405  {
6406  $$ = mm_strdup("view");
6407 }
6408 |  MATERIALIZED VIEW
6409  {
6410  $$ = mm_strdup("materialized view");
6411 }
6412 ;
6413 
6414 
6415  security_label_type_name:
6416  DATABASE
6417  {
6418  $$ = mm_strdup("database");
6419 }
6420 |  EVENT TRIGGER
6421  {
6422  $$ = mm_strdup("event trigger");
6423 }
6424 |  opt_procedural LANGUAGE
6425  {
6426  $$ = cat_str(2,$1,mm_strdup("language"));
6427 }
6428 |  PUBLICATION
6429  {
6430  $$ = mm_strdup("publication");
6431 }
6432 |  ROLE
6433  {
6434  $$ = mm_strdup("role");
6435 }
6436 |  SCHEMA
6437  {
6438  $$ = mm_strdup("schema");
6439 }
6440 |  SUBSCRIPTION
6441  {
6442  $$ = mm_strdup("subscription");
6443 }
6444 |  TABLESPACE
6445  {
6446  $$ = mm_strdup("tablespace");
6447 }
6448 ;
6449 
6450 
6451  security_label:
6452  ecpg_sconst
6453  {
6454  $$ = $1;
6455 }
6456 |  NULL_P
6457  {
6458  $$ = mm_strdup("null");
6459 }
6460 ;
6461 
6462 
6463  FetchStmt:
6464  FETCH fetch_args
6465  {
6466  $$ = cat_str(2,mm_strdup("fetch"),$2);
6467 }
6468 |  MOVE fetch_args
6469  {
6470  $$ = cat_str(2,mm_strdup("move"),$2);
6471 }
6472 	| FETCH fetch_args ecpg_fetch_into
6473 	{
6474 		$$ = cat2_str(mm_strdup("fetch"), $2);
6475 	}
6476 	| FETCH FORWARD cursor_name opt_ecpg_fetch_into
6477 	{
6478 		char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
6479 		add_additional_variables($3, false);
6480 		$$ = cat_str(2, mm_strdup("fetch forward"), cursor_marker);
6481 	}
6482 	| FETCH FORWARD from_in cursor_name opt_ecpg_fetch_into
6483 	{
6484 		char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
6485 		add_additional_variables($4, false);
6486 		$$ = cat_str(2, mm_strdup("fetch forward from"), cursor_marker);
6487 	}
6488 	| FETCH BACKWARD cursor_name opt_ecpg_fetch_into
6489 	{
6490 		char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
6491 		add_additional_variables($3, false);
6492 		$$ = cat_str(2, mm_strdup("fetch backward"), cursor_marker);
6493 	}
6494 	| FETCH BACKWARD from_in cursor_name opt_ecpg_fetch_into
6495 	{
6496 		char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
6497 		add_additional_variables($4, false);
6498 		$$ = cat_str(2, mm_strdup("fetch backward from"), cursor_marker);
6499 	}
6500 	| MOVE FORWARD cursor_name
6501 	{
6502 		char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
6503 		add_additional_variables($3, false);
6504 		$$ = cat_str(2, mm_strdup("move forward"), cursor_marker);
6505 	}
6506 	| MOVE FORWARD from_in cursor_name
6507 	{
6508 		char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
6509 		add_additional_variables($4, false);
6510 		$$ = cat_str(2, mm_strdup("move forward from"), cursor_marker);
6511 	}
6512 	| MOVE BACKWARD cursor_name
6513 	{
6514 		char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
6515 		add_additional_variables($3, false);
6516 		$$ = cat_str(2, mm_strdup("move backward"), cursor_marker);
6517 	}
6518 	| MOVE BACKWARD from_in cursor_name
6519 	{
6520 		char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
6521 		add_additional_variables($4, false);
6522 		$$ = cat_str(2, mm_strdup("move backward from"), cursor_marker);
6523 	}
6524 ;
6525 
6526 
6527  fetch_args:
6528  cursor_name
6529  {
6530 		add_additional_variables($1, false);
6531 		if ($1[0] == ':')
6532 		{
6533 			free($1);
6534 			$1 = mm_strdup("$0");
6535 		}
6536 
6537  $$ = $1;
6538 }
6539 |  from_in cursor_name
6540  {
6541 		add_additional_variables($2, false);
6542 		if ($2[0] == ':')
6543 		{
6544 			free($2);
6545 			$2 = mm_strdup("$0");
6546 		}
6547 
6548  $$ = cat_str(2,$1,$2);
6549 }
6550 |  NEXT opt_from_in cursor_name
6551  {
6552 		add_additional_variables($3, false);
6553 		if ($3[0] == ':')
6554 		{
6555 			free($3);
6556 			$3 = mm_strdup("$0");
6557 		}
6558 
6559  $$ = cat_str(3,mm_strdup("next"),$2,$3);
6560 }
6561 |  PRIOR opt_from_in cursor_name
6562  {
6563 		add_additional_variables($3, false);
6564 		if ($3[0] == ':')
6565 		{
6566 			free($3);
6567 			$3 = mm_strdup("$0");
6568 		}
6569 
6570  $$ = cat_str(3,mm_strdup("prior"),$2,$3);
6571 }
6572 |  FIRST_P opt_from_in cursor_name
6573  {
6574 		add_additional_variables($3, false);
6575 		if ($3[0] == ':')
6576 		{
6577 			free($3);
6578 			$3 = mm_strdup("$0");
6579 		}
6580 
6581  $$ = cat_str(3,mm_strdup("first"),$2,$3);
6582 }
6583 |  LAST_P opt_from_in cursor_name
6584  {
6585 		add_additional_variables($3, false);
6586 		if ($3[0] == ':')
6587 		{
6588 			free($3);
6589 			$3 = mm_strdup("$0");
6590 		}
6591 
6592  $$ = cat_str(3,mm_strdup("last"),$2,$3);
6593 }
6594 |  ABSOLUTE_P SignedIconst opt_from_in cursor_name
6595  {
6596 		add_additional_variables($4, false);
6597 		if ($4[0] == ':')
6598 		{
6599 			free($4);
6600 			$4 = mm_strdup("$0");
6601 		}
6602 		if ($2[0] == '$')
6603 		{
6604 			free($2);
6605 			$2 = mm_strdup("$0");
6606 		}
6607 
6608  $$ = cat_str(4,mm_strdup("absolute"),$2,$3,$4);
6609 }
6610 |  RELATIVE_P SignedIconst opt_from_in cursor_name
6611  {
6612 		add_additional_variables($4, false);
6613 		if ($4[0] == ':')
6614 		{
6615 			free($4);
6616 			$4 = mm_strdup("$0");
6617 		}
6618 		if ($2[0] == '$')
6619 		{
6620 			free($2);
6621 			$2 = mm_strdup("$0");
6622 		}
6623 
6624  $$ = cat_str(4,mm_strdup("relative"),$2,$3,$4);
6625 }
6626 |  SignedIconst opt_from_in cursor_name
6627  {
6628 		add_additional_variables($3, false);
6629 		if ($3[0] == ':')
6630 		{
6631 			free($3);
6632 			$3 = mm_strdup("$0");
6633 		}
6634 		if ($1[0] == '$')
6635 		{
6636 			free($1);
6637 			$1 = mm_strdup("$0");
6638 		}
6639 
6640  $$ = cat_str(3,$1,$2,$3);
6641 }
6642 |  ALL opt_from_in cursor_name
6643  {
6644 		add_additional_variables($3, false);
6645 		if ($3[0] == ':')
6646 		{
6647 			free($3);
6648 			$3 = mm_strdup("$0");
6649 		}
6650 
6651  $$ = cat_str(3,mm_strdup("all"),$2,$3);
6652 }
6653 |  FORWARD SignedIconst opt_from_in cursor_name
6654  {
6655 		add_additional_variables($4, false);
6656 		if ($4[0] == ':')
6657 		{
6658 			free($4);
6659 			$4 = mm_strdup("$0");
6660 		}
6661 		if ($2[0] == '$')
6662 		{
6663 			free($2);
6664 			$2 = mm_strdup("$0");
6665 		}
6666 
6667  $$ = cat_str(4,mm_strdup("forward"),$2,$3,$4);
6668 }
6669 |  FORWARD ALL opt_from_in cursor_name
6670  {
6671 		add_additional_variables($4, false);
6672 		if ($4[0] == ':')
6673 		{
6674 			free($4);
6675 			$4 = mm_strdup("$0");
6676 		}
6677 
6678  $$ = cat_str(3,mm_strdup("forward all"),$3,$4);
6679 }
6680 |  BACKWARD SignedIconst opt_from_in cursor_name
6681  {
6682 		add_additional_variables($4, false);
6683 		if ($4[0] == ':')
6684 		{
6685 			free($4);
6686 			$4 = mm_strdup("$0");
6687 		}
6688 		if ($2[0] == '$')
6689 		{
6690 			free($2);
6691 			$2 = mm_strdup("$0");
6692 		}
6693 
6694  $$ = cat_str(4,mm_strdup("backward"),$2,$3,$4);
6695 }
6696 |  BACKWARD ALL opt_from_in cursor_name
6697  {
6698 		add_additional_variables($4, false);
6699 		if ($4[0] == ':')
6700 		{
6701 			free($4);
6702 			$4 = mm_strdup("$0");
6703 		}
6704 
6705  $$ = cat_str(3,mm_strdup("backward all"),$3,$4);
6706 }
6707 ;
6708 
6709 
6710  from_in:
6711  FROM
6712  {
6713  $$ = mm_strdup("from");
6714 }
6715 |  IN_P
6716  {
6717  $$ = mm_strdup("in");
6718 }
6719 ;
6720 
6721 
6722  opt_from_in:
6723  from_in
6724  {
6725  $$ = $1;
6726 }
6727 |
6728  {
6729  $$=EMPTY; }
6730 ;
6731 
6732 
6733  GrantStmt:
6734  GRANT privileges ON privilege_target TO grantee_list opt_grant_grant_option
6735  {
6736  $$ = cat_str(7,mm_strdup("grant"),$2,mm_strdup("on"),$4,mm_strdup("to"),$6,$7);
6737 }
6738 ;
6739 
6740 
6741  RevokeStmt:
6742  REVOKE privileges ON privilege_target FROM grantee_list opt_drop_behavior
6743  {
6744  $$ = cat_str(7,mm_strdup("revoke"),$2,mm_strdup("on"),$4,mm_strdup("from"),$6,$7);
6745 }
6746 |  REVOKE GRANT OPTION FOR privileges ON privilege_target FROM grantee_list opt_drop_behavior
6747  {
6748  $$ = cat_str(7,mm_strdup("revoke grant option for"),$5,mm_strdup("on"),$7,mm_strdup("from"),$9,$10);
6749 }
6750 ;
6751 
6752 
6753  privileges:
6754  privilege_list
6755  {
6756  $$ = $1;
6757 }
6758 |  ALL
6759  {
6760  $$ = mm_strdup("all");
6761 }
6762 |  ALL PRIVILEGES
6763  {
6764  $$ = mm_strdup("all privileges");
6765 }
6766 |  ALL '(' columnList ')'
6767  {
6768  $$ = cat_str(3,mm_strdup("all ("),$3,mm_strdup(")"));
6769 }
6770 |  ALL PRIVILEGES '(' columnList ')'
6771  {
6772  $$ = cat_str(3,mm_strdup("all privileges ("),$4,mm_strdup(")"));
6773 }
6774 ;
6775 
6776 
6777  privilege_list:
6778  privilege
6779  {
6780  $$ = $1;
6781 }
6782 |  privilege_list ',' privilege
6783  {
6784  $$ = cat_str(3,$1,mm_strdup(","),$3);
6785 }
6786 ;
6787 
6788 
6789  privilege:
6790  SELECT opt_column_list
6791  {
6792  $$ = cat_str(2,mm_strdup("select"),$2);
6793 }
6794 |  REFERENCES opt_column_list
6795  {
6796  $$ = cat_str(2,mm_strdup("references"),$2);
6797 }
6798 |  CREATE opt_column_list
6799  {
6800  $$ = cat_str(2,mm_strdup("create"),$2);
6801 }
6802 |  ColId opt_column_list
6803  {
6804  $$ = cat_str(2,$1,$2);
6805 }
6806 ;
6807 
6808 
6809  privilege_target:
6810  qualified_name_list
6811  {
6812  $$ = $1;
6813 }
6814 |  TABLE qualified_name_list
6815  {
6816  $$ = cat_str(2,mm_strdup("table"),$2);
6817 }
6818 |  SEQUENCE qualified_name_list
6819  {
6820  $$ = cat_str(2,mm_strdup("sequence"),$2);
6821 }
6822 |  FOREIGN DATA_P WRAPPER name_list
6823  {
6824  $$ = cat_str(2,mm_strdup("foreign data wrapper"),$4);
6825 }
6826 |  FOREIGN SERVER name_list
6827  {
6828  $$ = cat_str(2,mm_strdup("foreign server"),$3);
6829 }
6830 |  FUNCTION function_with_argtypes_list
6831  {
6832  $$ = cat_str(2,mm_strdup("function"),$2);
6833 }
6834 |  DATABASE name_list
6835  {
6836  $$ = cat_str(2,mm_strdup("database"),$2);
6837 }
6838 |  DOMAIN_P any_name_list
6839  {
6840  $$ = cat_str(2,mm_strdup("domain"),$2);
6841 }
6842 |  LANGUAGE name_list
6843  {
6844  $$ = cat_str(2,mm_strdup("language"),$2);
6845 }
6846 |  LARGE_P OBJECT_P NumericOnly_list
6847  {
6848  $$ = cat_str(2,mm_strdup("large object"),$3);
6849 }
6850 |  SCHEMA name_list
6851  {
6852  $$ = cat_str(2,mm_strdup("schema"),$2);
6853 }
6854 |  TABLESPACE name_list
6855  {
6856  $$ = cat_str(2,mm_strdup("tablespace"),$2);
6857 }
6858 |  TYPE_P any_name_list
6859  {
6860  $$ = cat_str(2,mm_strdup("type"),$2);
6861 }
6862 |  ALL TABLES IN_P SCHEMA name_list
6863  {
6864  $$ = cat_str(2,mm_strdup("all tables in schema"),$5);
6865 }
6866 |  ALL SEQUENCES IN_P SCHEMA name_list
6867  {
6868  $$ = cat_str(2,mm_strdup("all sequences in schema"),$5);
6869 }
6870 |  ALL FUNCTIONS IN_P SCHEMA name_list
6871  {
6872  $$ = cat_str(2,mm_strdup("all functions in schema"),$5);
6873 }
6874 ;
6875 
6876 
6877  grantee_list:
6878  grantee
6879  {
6880  $$ = $1;
6881 }
6882 |  grantee_list ',' grantee
6883  {
6884  $$ = cat_str(3,$1,mm_strdup(","),$3);
6885 }
6886 ;
6887 
6888 
6889  grantee:
6890  RoleSpec
6891  {
6892  $$ = $1;
6893 }
6894 |  GROUP_P RoleSpec
6895  {
6896  $$ = cat_str(2,mm_strdup("group"),$2);
6897 }
6898 ;
6899 
6900 
6901  opt_grant_grant_option:
6902  WITH GRANT OPTION
6903  {
6904  $$ = mm_strdup("with grant option");
6905 }
6906 |
6907  {
6908  $$=EMPTY; }
6909 ;
6910 
6911 
6912  GrantRoleStmt:
6913  GRANT privilege_list TO role_list opt_grant_admin_option opt_granted_by
6914  {
6915  $$ = cat_str(6,mm_strdup("grant"),$2,mm_strdup("to"),$4,$5,$6);
6916 }
6917 ;
6918 
6919 
6920  RevokeRoleStmt:
6921  REVOKE privilege_list FROM role_list opt_granted_by opt_drop_behavior
6922  {
6923  $$ = cat_str(6,mm_strdup("revoke"),$2,mm_strdup("from"),$4,$5,$6);
6924 }
6925 |  REVOKE ADMIN OPTION FOR privilege_list FROM role_list opt_granted_by opt_drop_behavior
6926  {
6927  $$ = cat_str(6,mm_strdup("revoke admin option for"),$5,mm_strdup("from"),$7,$8,$9);
6928 }
6929 ;
6930 
6931 
6932  opt_grant_admin_option:
6933  WITH ADMIN OPTION
6934  {
6935  $$ = mm_strdup("with admin option");
6936 }
6937 |
6938  {
6939  $$=EMPTY; }
6940 ;
6941 
6942 
6943  opt_granted_by:
6944  GRANTED BY RoleSpec
6945  {
6946  $$ = cat_str(2,mm_strdup("granted by"),$3);
6947 }
6948 |
6949  {
6950  $$=EMPTY; }
6951 ;
6952 
6953 
6954  AlterDefaultPrivilegesStmt:
6955  ALTER DEFAULT PRIVILEGES DefACLOptionList DefACLAction
6956  {
6957  $$ = cat_str(3,mm_strdup("alter default privileges"),$4,$5);
6958 }
6959 ;
6960 
6961 
6962  DefACLOptionList:
6963  DefACLOptionList DefACLOption
6964  {
6965  $$ = cat_str(2,$1,$2);
6966 }
6967 |
6968  {
6969  $$=EMPTY; }
6970 ;
6971 
6972 
6973  DefACLOption:
6974  IN_P SCHEMA name_list
6975  {
6976  $$ = cat_str(2,mm_strdup("in schema"),$3);
6977 }
6978 |  FOR ROLE role_list
6979  {
6980  $$ = cat_str(2,mm_strdup("for role"),$3);
6981 }
6982 |  FOR USER role_list
6983  {
6984  $$ = cat_str(2,mm_strdup("for user"),$3);
6985 }
6986 ;
6987 
6988 
6989  DefACLAction:
6990  GRANT privileges ON defacl_privilege_target TO grantee_list opt_grant_grant_option
6991  {
6992  $$ = cat_str(7,mm_strdup("grant"),$2,mm_strdup("on"),$4,mm_strdup("to"),$6,$7);
6993 }
6994 |  REVOKE privileges ON defacl_privilege_target FROM grantee_list opt_drop_behavior
6995  {
6996  $$ = cat_str(7,mm_strdup("revoke"),$2,mm_strdup("on"),$4,mm_strdup("from"),$6,$7);
6997 }
6998 |  REVOKE GRANT OPTION FOR privileges ON defacl_privilege_target FROM grantee_list opt_drop_behavior
6999  {
7000  $$ = cat_str(7,mm_strdup("revoke grant option for"),$5,mm_strdup("on"),$7,mm_strdup("from"),$9,$10);
7001 }
7002 ;
7003 
7004 
7005  defacl_privilege_target:
7006  TABLES
7007  {
7008  $$ = mm_strdup("tables");
7009 }
7010 |  FUNCTIONS
7011  {
7012  $$ = mm_strdup("functions");
7013 }
7014 |  SEQUENCES
7015  {
7016  $$ = mm_strdup("sequences");
7017 }
7018 |  TYPES_P
7019  {
7020  $$ = mm_strdup("types");
7021 }
7022 |  SCHEMAS
7023  {
7024  $$ = mm_strdup("schemas");
7025 }
7026 ;
7027 
7028 
7029  IndexStmt:
7030  CREATE opt_unique INDEX opt_concurrently opt_index_name ON qualified_name access_method_clause '(' index_params ')' opt_reloptions OptTableSpace where_clause
7031  {
7032  $$ = cat_str(14,mm_strdup("create"),$2,mm_strdup("index"),$4,$5,mm_strdup("on"),$7,$8,mm_strdup("("),$10,mm_strdup(")"),$12,$13,$14);
7033 }
7034 |  CREATE opt_unique INDEX opt_concurrently IF_P NOT EXISTS index_name ON qualified_name access_method_clause '(' index_params ')' opt_reloptions OptTableSpace where_clause
7035  {
7036  $$ = cat_str(15,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);
7037 }
7038 ;
7039 
7040 
7041  opt_unique:
7042  UNIQUE
7043  {
7044  $$ = mm_strdup("unique");
7045 }
7046 |
7047  {
7048  $$=EMPTY; }
7049 ;
7050 
7051 
7052  opt_concurrently:
7053  CONCURRENTLY
7054  {
7055  $$ = mm_strdup("concurrently");
7056 }
7057 |
7058  {
7059  $$=EMPTY; }
7060 ;
7061 
7062 
7063  opt_index_name:
7064  index_name
7065  {
7066  $$ = $1;
7067 }
7068 |
7069  {
7070  $$=EMPTY; }
7071 ;
7072 
7073 
7074  access_method_clause:
7075  USING access_method
7076  {
7077  $$ = cat_str(2,mm_strdup("using"),$2);
7078 }
7079 |
7080  {
7081  $$=EMPTY; }
7082 ;
7083 
7084 
7085  index_params:
7086  index_elem
7087  {
7088  $$ = $1;
7089 }
7090 |  index_params ',' index_elem
7091  {
7092  $$ = cat_str(3,$1,mm_strdup(","),$3);
7093 }
7094 ;
7095 
7096 
7097  index_elem:
7098  ColId opt_collate opt_class opt_asc_desc opt_nulls_order
7099  {
7100  $$ = cat_str(5,$1,$2,$3,$4,$5);
7101 }
7102 |  func_expr_windowless opt_collate opt_class opt_asc_desc opt_nulls_order
7103  {
7104  $$ = cat_str(5,$1,$2,$3,$4,$5);
7105 }
7106 |  '(' a_expr ')' opt_collate opt_class opt_asc_desc opt_nulls_order
7107  {
7108  $$ = cat_str(7,mm_strdup("("),$2,mm_strdup(")"),$4,$5,$6,$7);
7109 }
7110 ;
7111 
7112 
7113  opt_collate:
7114  COLLATE any_name
7115  {
7116  $$ = cat_str(2,mm_strdup("collate"),$2);
7117 }
7118 |
7119  {
7120  $$=EMPTY; }
7121 ;
7122 
7123 
7124  opt_class:
7125  any_name
7126  {
7127  $$ = $1;
7128 }
7129 |
7130  {
7131  $$=EMPTY; }
7132 ;
7133 
7134 
7135  opt_asc_desc:
7136  ASC
7137  {
7138  $$ = mm_strdup("asc");
7139 }
7140 |  DESC
7141  {
7142  $$ = mm_strdup("desc");
7143 }
7144 |
7145  {
7146  $$=EMPTY; }
7147 ;
7148 
7149 
7150  opt_nulls_order:
7151  NULLS_LA FIRST_P
7152  {
7153  $$ = mm_strdup("nulls first");
7154 }
7155 |  NULLS_LA LAST_P
7156  {
7157  $$ = mm_strdup("nulls last");
7158 }
7159 |
7160  {
7161  $$=EMPTY; }
7162 ;
7163 
7164 
7165  CreateFunctionStmt:
7166  CREATE opt_or_replace FUNCTION func_name func_args_with_defaults RETURNS func_return createfunc_opt_list opt_definition
7167  {
7168  $$ = cat_str(9,mm_strdup("create"),$2,mm_strdup("function"),$4,$5,mm_strdup("returns"),$7,$8,$9);
7169 }
7170 |  CREATE opt_or_replace FUNCTION func_name func_args_with_defaults RETURNS TABLE '(' table_func_column_list ')' createfunc_opt_list opt_definition
7171  {
7172  $$ = cat_str(10,mm_strdup("create"),$2,mm_strdup("function"),$4,$5,mm_strdup("returns table ("),$9,mm_strdup(")"),$11,$12);
7173 }
7174 |  CREATE opt_or_replace FUNCTION func_name func_args_with_defaults createfunc_opt_list opt_definition
7175  {
7176  $$ = cat_str(7,mm_strdup("create"),$2,mm_strdup("function"),$4,$5,$6,$7);
7177 }
7178 ;
7179 
7180 
7181  opt_or_replace:
7182  OR REPLACE
7183  {
7184  $$ = mm_strdup("or replace");
7185 }
7186 |
7187  {
7188  $$=EMPTY; }
7189 ;
7190 
7191 
7192  func_args:
7193  '(' func_args_list ')'
7194  {
7195  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
7196 }
7197 |  '(' ')'
7198  {
7199  $$ = mm_strdup("( )");
7200 }
7201 ;
7202 
7203 
7204  func_args_list:
7205  func_arg
7206  {
7207  $$ = $1;
7208 }
7209 |  func_args_list ',' func_arg
7210  {
7211  $$ = cat_str(3,$1,mm_strdup(","),$3);
7212 }
7213 ;
7214 
7215 
7216  function_with_argtypes_list:
7217  function_with_argtypes
7218  {
7219  $$ = $1;
7220 }
7221 |  function_with_argtypes_list ',' function_with_argtypes
7222  {
7223  $$ = cat_str(3,$1,mm_strdup(","),$3);
7224 }
7225 ;
7226 
7227 
7228  function_with_argtypes:
7229  func_name func_args
7230  {
7231  $$ = cat_str(2,$1,$2);
7232 }
7233 |  type_func_name_keyword
7234  {
7235  $$ = $1;
7236 }
7237 |  ColId
7238  {
7239  $$ = $1;
7240 }
7241 |  ColId indirection
7242  {
7243  $$ = cat_str(2,$1,$2);
7244 }
7245 ;
7246 
7247 
7248  func_args_with_defaults:
7249  '(' func_args_with_defaults_list ')'
7250  {
7251  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
7252 }
7253 |  '(' ')'
7254  {
7255  $$ = mm_strdup("( )");
7256 }
7257 ;
7258 
7259 
7260  func_args_with_defaults_list:
7261  func_arg_with_default
7262  {
7263  $$ = $1;
7264 }
7265 |  func_args_with_defaults_list ',' func_arg_with_default
7266  {
7267  $$ = cat_str(3,$1,mm_strdup(","),$3);
7268 }
7269 ;
7270 
7271 
7272  func_arg:
7273  arg_class param_name func_type
7274  {
7275  $$ = cat_str(3,$1,$2,$3);
7276 }
7277 |  param_name arg_class func_type
7278  {
7279  $$ = cat_str(3,$1,$2,$3);
7280 }
7281 |  param_name func_type
7282  {
7283  $$ = cat_str(2,$1,$2);
7284 }
7285 |  arg_class func_type
7286  {
7287  $$ = cat_str(2,$1,$2);
7288 }
7289 |  func_type
7290  {
7291  $$ = $1;
7292 }
7293 ;
7294 
7295 
7296  arg_class:
7297  IN_P
7298  {
7299  $$ = mm_strdup("in");
7300 }
7301 |  OUT_P
7302  {
7303  $$ = mm_strdup("out");
7304 }
7305 |  INOUT
7306  {
7307  $$ = mm_strdup("inout");
7308 }
7309 |  IN_P OUT_P
7310  {
7311  $$ = mm_strdup("in out");
7312 }
7313 |  VARIADIC
7314  {
7315  $$ = mm_strdup("variadic");
7316 }
7317 ;
7318 
7319 
7320  param_name:
7321  type_function_name
7322  {
7323  $$ = $1;
7324 }
7325 ;
7326 
7327 
7328  func_return:
7329  func_type
7330  {
7331  $$ = $1;
7332 }
7333 ;
7334 
7335 
7336  func_type:
7337  Typename
7338  {
7339  $$ = $1;
7340 }
7341 |  type_function_name attrs '%' TYPE_P
7342  {
7343  $$ = cat_str(3,$1,$2,mm_strdup("% type"));
7344 }
7345 |  SETOF type_function_name attrs '%' TYPE_P
7346  {
7347  $$ = cat_str(4,mm_strdup("setof"),$2,$3,mm_strdup("% type"));
7348 }
7349 ;
7350 
7351 
7352  func_arg_with_default:
7353  func_arg
7354  {
7355  $$ = $1;
7356 }
7357 |  func_arg DEFAULT a_expr
7358  {
7359  $$ = cat_str(3,$1,mm_strdup("default"),$3);
7360 }
7361 |  func_arg '=' a_expr
7362  {
7363  $$ = cat_str(3,$1,mm_strdup("="),$3);
7364 }
7365 ;
7366 
7367 
7368  aggr_arg:
7369  func_arg
7370  {
7371 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
7372  $$ = $1;
7373 }
7374 ;
7375 
7376 
7377  aggr_args:
7378  '(' '*' ')'
7379  {
7380  $$ = mm_strdup("( * )");
7381 }
7382 |  '(' aggr_args_list ')'
7383  {
7384  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
7385 }
7386 |  '(' ORDER BY aggr_args_list ')'
7387  {
7388  $$ = cat_str(3,mm_strdup("( order by"),$4,mm_strdup(")"));
7389 }
7390 |  '(' aggr_args_list ORDER BY aggr_args_list ')'
7391  {
7392  $$ = cat_str(5,mm_strdup("("),$2,mm_strdup("order by"),$5,mm_strdup(")"));
7393 }
7394 ;
7395 
7396 
7397  aggr_args_list:
7398  aggr_arg
7399  {
7400  $$ = $1;
7401 }
7402 |  aggr_args_list ',' aggr_arg
7403  {
7404  $$ = cat_str(3,$1,mm_strdup(","),$3);
7405 }
7406 ;
7407 
7408 
7409  aggregate_with_argtypes:
7410  func_name aggr_args
7411  {
7412  $$ = cat_str(2,$1,$2);
7413 }
7414 ;
7415 
7416 
7417  aggregate_with_argtypes_list:
7418  aggregate_with_argtypes
7419  {
7420  $$ = $1;
7421 }
7422 |  aggregate_with_argtypes_list ',' aggregate_with_argtypes
7423  {
7424  $$ = cat_str(3,$1,mm_strdup(","),$3);
7425 }
7426 ;
7427 
7428 
7429  createfunc_opt_list:
7430  createfunc_opt_item
7431  {
7432  $$ = $1;
7433 }
7434 |  createfunc_opt_list createfunc_opt_item
7435  {
7436  $$ = cat_str(2,$1,$2);
7437 }
7438 ;
7439 
7440 
7441  common_func_opt_item:
7442  CALLED ON NULL_P INPUT_P
7443  {
7444  $$ = mm_strdup("called on null input");
7445 }
7446 |  RETURNS NULL_P ON NULL_P INPUT_P
7447  {
7448  $$ = mm_strdup("returns null on null input");
7449 }
7450 |  STRICT_P
7451  {
7452  $$ = mm_strdup("strict");
7453 }
7454 |  IMMUTABLE
7455  {
7456  $$ = mm_strdup("immutable");
7457 }
7458 |  STABLE
7459  {
7460  $$ = mm_strdup("stable");
7461 }
7462 |  VOLATILE
7463  {
7464  $$ = mm_strdup("volatile");
7465 }
7466 |  EXTERNAL SECURITY DEFINER
7467  {
7468  $$ = mm_strdup("external security definer");
7469 }
7470 |  EXTERNAL SECURITY INVOKER
7471  {
7472  $$ = mm_strdup("external security invoker");
7473 }
7474 |  SECURITY DEFINER
7475  {
7476  $$ = mm_strdup("security definer");
7477 }
7478 |  SECURITY INVOKER
7479  {
7480  $$ = mm_strdup("security invoker");
7481 }
7482 |  LEAKPROOF
7483  {
7484  $$ = mm_strdup("leakproof");
7485 }
7486 |  NOT LEAKPROOF
7487  {
7488  $$ = mm_strdup("not leakproof");
7489 }
7490 |  COST NumericOnly
7491  {
7492  $$ = cat_str(2,mm_strdup("cost"),$2);
7493 }
7494 |  ROWS NumericOnly
7495  {
7496  $$ = cat_str(2,mm_strdup("rows"),$2);
7497 }
7498 |  FunctionSetResetClause
7499  {
7500  $$ = $1;
7501 }
7502 |  PARALLEL ColId
7503  {
7504  $$ = cat_str(2,mm_strdup("parallel"),$2);
7505 }
7506 ;
7507 
7508 
7509  createfunc_opt_item:
7510  AS func_as
7511  {
7512  $$ = cat_str(2,mm_strdup("as"),$2);
7513 }
7514 |  LANGUAGE NonReservedWord_or_Sconst
7515  {
7516  $$ = cat_str(2,mm_strdup("language"),$2);
7517 }
7518 |  TRANSFORM transform_type_list
7519  {
7520  $$ = cat_str(2,mm_strdup("transform"),$2);
7521 }
7522 |  WINDOW
7523  {
7524  $$ = mm_strdup("window");
7525 }
7526 |  common_func_opt_item
7527  {
7528  $$ = $1;
7529 }
7530 ;
7531 
7532 
7533  func_as:
7534  ecpg_sconst
7535  {
7536  $$ = $1;
7537 }
7538 |  ecpg_sconst ',' ecpg_sconst
7539  {
7540  $$ = cat_str(3,$1,mm_strdup(","),$3);
7541 }
7542 ;
7543 
7544 
7545  transform_type_list:
7546  FOR TYPE_P Typename
7547  {
7548  $$ = cat_str(2,mm_strdup("for type"),$3);
7549 }
7550 |  transform_type_list ',' FOR TYPE_P Typename
7551  {
7552  $$ = cat_str(3,$1,mm_strdup(", for type"),$5);
7553 }
7554 ;
7555 
7556 
7557  opt_definition:
7558  WITH definition
7559  {
7560  $$ = cat_str(2,mm_strdup("with"),$2);
7561 }
7562 |
7563  {
7564  $$=EMPTY; }
7565 ;
7566 
7567 
7568  table_func_column:
7569  param_name func_type
7570  {
7571  $$ = cat_str(2,$1,$2);
7572 }
7573 ;
7574 
7575 
7576  table_func_column_list:
7577  table_func_column
7578  {
7579  $$ = $1;
7580 }
7581 |  table_func_column_list ',' table_func_column
7582  {
7583  $$ = cat_str(3,$1,mm_strdup(","),$3);
7584 }
7585 ;
7586 
7587 
7588  AlterFunctionStmt:
7589  ALTER FUNCTION function_with_argtypes alterfunc_opt_list opt_restrict
7590  {
7591  $$ = cat_str(4,mm_strdup("alter function"),$3,$4,$5);
7592 }
7593 ;
7594 
7595 
7596  alterfunc_opt_list:
7597  common_func_opt_item
7598  {
7599  $$ = $1;
7600 }
7601 |  alterfunc_opt_list common_func_opt_item
7602  {
7603  $$ = cat_str(2,$1,$2);
7604 }
7605 ;
7606 
7607 
7608  opt_restrict:
7609  RESTRICT
7610  {
7611  $$ = mm_strdup("restrict");
7612 }
7613 |
7614  {
7615  $$=EMPTY; }
7616 ;
7617 
7618 
7619  RemoveFuncStmt:
7620  DROP FUNCTION function_with_argtypes_list opt_drop_behavior
7621  {
7622  $$ = cat_str(3,mm_strdup("drop function"),$3,$4);
7623 }
7624 |  DROP FUNCTION IF_P EXISTS function_with_argtypes_list opt_drop_behavior
7625  {
7626  $$ = cat_str(3,mm_strdup("drop function if exists"),$5,$6);
7627 }
7628 ;
7629 
7630 
7631  RemoveAggrStmt:
7632  DROP AGGREGATE aggregate_with_argtypes_list opt_drop_behavior
7633  {
7634  $$ = cat_str(3,mm_strdup("drop aggregate"),$3,$4);
7635 }
7636 |  DROP AGGREGATE IF_P EXISTS aggregate_with_argtypes_list opt_drop_behavior
7637  {
7638  $$ = cat_str(3,mm_strdup("drop aggregate if exists"),$5,$6);
7639 }
7640 ;
7641 
7642 
7643  RemoveOperStmt:
7644  DROP OPERATOR operator_with_argtypes_list opt_drop_behavior
7645  {
7646  $$ = cat_str(3,mm_strdup("drop operator"),$3,$4);
7647 }
7648 |  DROP OPERATOR IF_P EXISTS operator_with_argtypes_list opt_drop_behavior
7649  {
7650  $$ = cat_str(3,mm_strdup("drop operator if exists"),$5,$6);
7651 }
7652 ;
7653 
7654 
7655  oper_argtypes:
7656  '(' Typename ')'
7657  {
7658  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
7659 }
7660 |  '(' Typename ',' Typename ')'
7661  {
7662  $$ = cat_str(5,mm_strdup("("),$2,mm_strdup(","),$4,mm_strdup(")"));
7663 }
7664 |  '(' NONE ',' Typename ')'
7665  {
7666  $$ = cat_str(3,mm_strdup("( none ,"),$4,mm_strdup(")"));
7667 }
7668 |  '(' Typename ',' NONE ')'
7669  {
7670  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(", none )"));
7671 }
7672 ;
7673 
7674 
7675  any_operator:
7676  all_Op
7677  {
7678  $$ = $1;
7679 }
7680 |  ColId '.' any_operator
7681  {
7682  $$ = cat_str(3,$1,mm_strdup("."),$3);
7683 }
7684 ;
7685 
7686 
7687  operator_with_argtypes_list:
7688  operator_with_argtypes
7689  {
7690  $$ = $1;
7691 }
7692 |  operator_with_argtypes_list ',' operator_with_argtypes
7693  {
7694  $$ = cat_str(3,$1,mm_strdup(","),$3);
7695 }
7696 ;
7697 
7698 
7699  operator_with_argtypes:
7700  any_operator oper_argtypes
7701  {
7702  $$ = cat_str(2,$1,$2);
7703 }
7704 ;
7705 
7706 
7707  DoStmt:
7708  DO dostmt_opt_list
7709  {
7710  $$ = cat_str(2,mm_strdup("do"),$2);
7711 }
7712 ;
7713 
7714 
7715  dostmt_opt_list:
7716  dostmt_opt_item
7717  {
7718  $$ = $1;
7719 }
7720 |  dostmt_opt_list dostmt_opt_item
7721  {
7722  $$ = cat_str(2,$1,$2);
7723 }
7724 ;
7725 
7726 
7727  dostmt_opt_item:
7728  ecpg_sconst
7729  {
7730  $$ = $1;
7731 }
7732 |  LANGUAGE NonReservedWord_or_Sconst
7733  {
7734  $$ = cat_str(2,mm_strdup("language"),$2);
7735 }
7736 ;
7737 
7738 
7739  CreateCastStmt:
7740  CREATE CAST '(' Typename AS Typename ')' WITH FUNCTION function_with_argtypes cast_context
7741  {
7742  $$ = cat_str(7,mm_strdup("create cast ("),$4,mm_strdup("as"),$6,mm_strdup(") with function"),$10,$11);
7743 }
7744 |  CREATE CAST '(' Typename AS Typename ')' WITHOUT FUNCTION cast_context
7745  {
7746  $$ = cat_str(6,mm_strdup("create cast ("),$4,mm_strdup("as"),$6,mm_strdup(") without function"),$10);
7747 }
7748 |  CREATE CAST '(' Typename AS Typename ')' WITH INOUT cast_context
7749  {
7750  $$ = cat_str(6,mm_strdup("create cast ("),$4,mm_strdup("as"),$6,mm_strdup(") with inout"),$10);
7751 }
7752 ;
7753 
7754 
7755  cast_context:
7756  AS IMPLICIT_P
7757  {
7758  $$ = mm_strdup("as implicit");
7759 }
7760 |  AS ASSIGNMENT
7761  {
7762  $$ = mm_strdup("as assignment");
7763 }
7764 |
7765  {
7766  $$=EMPTY; }
7767 ;
7768 
7769 
7770  DropCastStmt:
7771  DROP CAST opt_if_exists '(' Typename AS Typename ')' opt_drop_behavior
7772  {
7773  $$ = cat_str(8,mm_strdup("drop cast"),$3,mm_strdup("("),$5,mm_strdup("as"),$7,mm_strdup(")"),$9);
7774 }
7775 ;
7776 
7777 
7778  opt_if_exists:
7779  IF_P EXISTS
7780  {
7781  $$ = mm_strdup("if exists");
7782 }
7783 |
7784  {
7785  $$=EMPTY; }
7786 ;
7787 
7788 
7789  CreateTransformStmt:
7790  CREATE opt_or_replace TRANSFORM FOR Typename LANGUAGE name '(' transform_element_list ')'
7791  {
7792  $$ = cat_str(9,mm_strdup("create"),$2,mm_strdup("transform for"),$5,mm_strdup("language"),$7,mm_strdup("("),$9,mm_strdup(")"));
7793 }
7794 ;
7795 
7796 
7797  transform_element_list:
7798  FROM SQL_P WITH FUNCTION function_with_argtypes ',' TO SQL_P WITH FUNCTION function_with_argtypes
7799  {
7800  $$ = cat_str(4,mm_strdup("from sql with function"),$5,mm_strdup(", to sql with function"),$11);
7801 }
7802 |  TO SQL_P WITH FUNCTION function_with_argtypes ',' FROM SQL_P WITH FUNCTION function_with_argtypes
7803  {
7804  $$ = cat_str(4,mm_strdup("to sql with function"),$5,mm_strdup(", from sql with function"),$11);
7805 }
7806 |  FROM SQL_P WITH FUNCTION function_with_argtypes
7807  {
7808  $$ = cat_str(2,mm_strdup("from sql with function"),$5);
7809 }
7810 |  TO SQL_P WITH FUNCTION function_with_argtypes
7811  {
7812  $$ = cat_str(2,mm_strdup("to sql with function"),$5);
7813 }
7814 ;
7815 
7816 
7817  DropTransformStmt:
7818  DROP TRANSFORM opt_if_exists FOR Typename LANGUAGE name opt_drop_behavior
7819  {
7820  $$ = cat_str(7,mm_strdup("drop transform"),$3,mm_strdup("for"),$5,mm_strdup("language"),$7,$8);
7821 }
7822 ;
7823 
7824 
7825  ReindexStmt:
7826  REINDEX reindex_target_type qualified_name
7827  {
7828  $$ = cat_str(3,mm_strdup("reindex"),$2,$3);
7829 }
7830 |  REINDEX reindex_target_multitable name
7831  {
7832  $$ = cat_str(3,mm_strdup("reindex"),$2,$3);
7833 }
7834 |  REINDEX '(' reindex_option_list ')' reindex_target_type qualified_name
7835  {
7836  $$ = cat_str(5,mm_strdup("reindex ("),$3,mm_strdup(")"),$5,$6);
7837 }
7838 |  REINDEX '(' reindex_option_list ')' reindex_target_multitable name
7839  {
7840  $$ = cat_str(5,mm_strdup("reindex ("),$3,mm_strdup(")"),$5,$6);
7841 }
7842 ;
7843 
7844 
7845  reindex_target_type:
7846  INDEX
7847  {
7848  $$ = mm_strdup("index");
7849 }
7850 |  TABLE
7851  {
7852  $$ = mm_strdup("table");
7853 }
7854 ;
7855 
7856 
7857  reindex_target_multitable:
7858  SCHEMA
7859  {
7860  $$ = mm_strdup("schema");
7861 }
7862 |  SYSTEM_P
7863  {
7864  $$ = mm_strdup("system");
7865 }
7866 |  DATABASE
7867  {
7868  $$ = mm_strdup("database");
7869 }
7870 ;
7871 
7872 
7873  reindex_option_list:
7874  reindex_option_elem
7875  {
7876  $$ = $1;
7877 }
7878 |  reindex_option_list ',' reindex_option_elem
7879  {
7880  $$ = cat_str(3,$1,mm_strdup(","),$3);
7881 }
7882 ;
7883 
7884 
7885  reindex_option_elem:
7886  VERBOSE
7887  {
7888  $$ = mm_strdup("verbose");
7889 }
7890 ;
7891 
7892 
7893  AlterTblSpcStmt:
7894  ALTER TABLESPACE name SET reloptions
7895  {
7896  $$ = cat_str(4,mm_strdup("alter tablespace"),$3,mm_strdup("set"),$5);
7897 }
7898 |  ALTER TABLESPACE name RESET reloptions
7899  {
7900  $$ = cat_str(4,mm_strdup("alter tablespace"),$3,mm_strdup("reset"),$5);
7901 }
7902 ;
7903 
7904 
7905  RenameStmt:
7906  ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
7907  {
7908  $$ = cat_str(4,mm_strdup("alter aggregate"),$3,mm_strdup("rename to"),$6);
7909 }
7910 |  ALTER COLLATION any_name RENAME TO name
7911  {
7912  $$ = cat_str(4,mm_strdup("alter collation"),$3,mm_strdup("rename to"),$6);
7913 }
7914 |  ALTER CONVERSION_P any_name RENAME TO name
7915  {
7916  $$ = cat_str(4,mm_strdup("alter conversion"),$3,mm_strdup("rename to"),$6);
7917 }
7918 |  ALTER DATABASE database_name RENAME TO database_name
7919  {
7920  $$ = cat_str(4,mm_strdup("alter database"),$3,mm_strdup("rename to"),$6);
7921 }
7922 |  ALTER DOMAIN_P any_name RENAME TO name
7923  {
7924  $$ = cat_str(4,mm_strdup("alter domain"),$3,mm_strdup("rename to"),$6);
7925 }
7926 |  ALTER DOMAIN_P any_name RENAME CONSTRAINT name TO name
7927  {
7928  $$ = cat_str(6,mm_strdup("alter domain"),$3,mm_strdup("rename constraint"),$6,mm_strdup("to"),$8);
7929 }
7930 |  ALTER FOREIGN DATA_P WRAPPER name RENAME TO name
7931  {
7932  $$ = cat_str(4,mm_strdup("alter foreign data wrapper"),$5,mm_strdup("rename to"),$8);
7933 }
7934 |  ALTER FUNCTION function_with_argtypes RENAME TO name
7935  {
7936  $$ = cat_str(4,mm_strdup("alter function"),$3,mm_strdup("rename to"),$6);
7937 }
7938 |  ALTER GROUP_P RoleId RENAME TO RoleId
7939  {
7940  $$ = cat_str(4,mm_strdup("alter group"),$3,mm_strdup("rename to"),$6);
7941 }
7942 |  ALTER opt_procedural LANGUAGE name RENAME TO name
7943  {
7944  $$ = cat_str(6,mm_strdup("alter"),$2,mm_strdup("language"),$4,mm_strdup("rename to"),$7);
7945 }
7946 |  ALTER OPERATOR CLASS any_name USING access_method RENAME TO name
7947  {
7948  $$ = cat_str(6,mm_strdup("alter operator class"),$4,mm_strdup("using"),$6,mm_strdup("rename to"),$9);
7949 }
7950 |  ALTER OPERATOR FAMILY any_name USING access_method RENAME TO name
7951  {
7952  $$ = cat_str(6,mm_strdup("alter operator family"),$4,mm_strdup("using"),$6,mm_strdup("rename to"),$9);
7953 }
7954 |  ALTER POLICY name ON qualified_name RENAME TO name
7955  {
7956  $$ = cat_str(6,mm_strdup("alter policy"),$3,mm_strdup("on"),$5,mm_strdup("rename to"),$8);
7957 }
7958 |  ALTER POLICY IF_P EXISTS name ON qualified_name RENAME TO name
7959  {
7960  $$ = cat_str(6,mm_strdup("alter policy if exists"),$5,mm_strdup("on"),$7,mm_strdup("rename to"),$10);
7961 }
7962 |  ALTER PUBLICATION name RENAME TO name
7963  {
7964  $$ = cat_str(4,mm_strdup("alter publication"),$3,mm_strdup("rename to"),$6);
7965 }
7966 |  ALTER SCHEMA name RENAME TO name
7967  {
7968  $$ = cat_str(4,mm_strdup("alter schema"),$3,mm_strdup("rename to"),$6);
7969 }
7970 |  ALTER SERVER name RENAME TO name
7971  {
7972  $$ = cat_str(4,mm_strdup("alter server"),$3,mm_strdup("rename to"),$6);
7973 }
7974 |  ALTER SUBSCRIPTION name RENAME TO name
7975  {
7976  $$ = cat_str(4,mm_strdup("alter subscription"),$3,mm_strdup("rename to"),$6);
7977 }
7978 |  ALTER TABLE relation_expr RENAME TO name
7979  {
7980  $$ = cat_str(4,mm_strdup("alter table"),$3,mm_strdup("rename to"),$6);
7981 }
7982 |  ALTER TABLE IF_P EXISTS relation_expr RENAME TO name
7983  {
7984  $$ = cat_str(4,mm_strdup("alter table if exists"),$5,mm_strdup("rename to"),$8);
7985 }
7986 |  ALTER SEQUENCE qualified_name RENAME TO name
7987  {
7988  $$ = cat_str(4,mm_strdup("alter sequence"),$3,mm_strdup("rename to"),$6);
7989 }
7990 |  ALTER SEQUENCE IF_P EXISTS qualified_name RENAME TO name
7991  {
7992  $$ = cat_str(4,mm_strdup("alter sequence if exists"),$5,mm_strdup("rename to"),$8);
7993 }
7994 |  ALTER VIEW qualified_name RENAME TO name
7995  {
7996  $$ = cat_str(4,mm_strdup("alter view"),$3,mm_strdup("rename to"),$6);
7997 }
7998 |  ALTER VIEW IF_P EXISTS qualified_name RENAME TO name
7999  {
8000  $$ = cat_str(4,mm_strdup("alter view if exists"),$5,mm_strdup("rename to"),$8);
8001 }
8002 |  ALTER MATERIALIZED VIEW qualified_name RENAME TO name
8003  {
8004  $$ = cat_str(4,mm_strdup("alter materialized view"),$4,mm_strdup("rename to"),$7);
8005 }
8006 |  ALTER MATERIALIZED VIEW IF_P EXISTS qualified_name RENAME TO name
8007  {
8008  $$ = cat_str(4,mm_strdup("alter materialized view if exists"),$6,mm_strdup("rename to"),$9);
8009 }
8010 |  ALTER INDEX qualified_name RENAME TO name
8011  {
8012  $$ = cat_str(4,mm_strdup("alter index"),$3,mm_strdup("rename to"),$6);
8013 }
8014 |  ALTER INDEX IF_P EXISTS qualified_name RENAME TO name
8015  {
8016  $$ = cat_str(4,mm_strdup("alter index if exists"),$5,mm_strdup("rename to"),$8);
8017 }
8018 |  ALTER FOREIGN TABLE relation_expr RENAME TO name
8019  {
8020  $$ = cat_str(4,mm_strdup("alter foreign table"),$4,mm_strdup("rename to"),$7);
8021 }
8022 |  ALTER FOREIGN TABLE IF_P EXISTS relation_expr RENAME TO name
8023  {
8024  $$ = cat_str(4,mm_strdup("alter foreign table if exists"),$6,mm_strdup("rename to"),$9);
8025 }
8026 |  ALTER TABLE relation_expr RENAME opt_column name TO name
8027  {
8028  $$ = cat_str(7,mm_strdup("alter table"),$3,mm_strdup("rename"),$5,$6,mm_strdup("to"),$8);
8029 }
8030 |  ALTER TABLE IF_P EXISTS relation_expr RENAME opt_column name TO name
8031  {
8032  $$ = cat_str(7,mm_strdup("alter table if exists"),$5,mm_strdup("rename"),$7,$8,mm_strdup("to"),$10);
8033 }
8034 |  ALTER MATERIALIZED VIEW qualified_name RENAME opt_column name TO name
8035  {
8036  $$ = cat_str(7,mm_strdup("alter materialized view"),$4,mm_strdup("rename"),$6,$7,mm_strdup("to"),$9);
8037 }
8038 |  ALTER MATERIALIZED VIEW IF_P EXISTS qualified_name RENAME opt_column name TO name
8039  {
8040  $$ = cat_str(7,mm_strdup("alter materialized view if exists"),$6,mm_strdup("rename"),$8,$9,mm_strdup("to"),$11);
8041 }
8042 |  ALTER TABLE relation_expr RENAME CONSTRAINT name TO name
8043  {
8044  $$ = cat_str(6,mm_strdup("alter table"),$3,mm_strdup("rename constraint"),$6,mm_strdup("to"),$8);
8045 }
8046 |  ALTER TABLE IF_P EXISTS relation_expr RENAME CONSTRAINT name TO name
8047  {
8048  $$ = cat_str(6,mm_strdup("alter table if exists"),$5,mm_strdup("rename constraint"),$8,mm_strdup("to"),$10);
8049 }
8050 |  ALTER FOREIGN TABLE relation_expr RENAME opt_column name TO name
8051  {
8052  $$ = cat_str(7,mm_strdup("alter foreign table"),$4,mm_strdup("rename"),$6,$7,mm_strdup("to"),$9);
8053 }
8054 |  ALTER FOREIGN TABLE IF_P EXISTS relation_expr RENAME opt_column name TO name
8055  {
8056  $$ = cat_str(7,mm_strdup("alter foreign table if exists"),$6,mm_strdup("rename"),$8,$9,mm_strdup("to"),$11);
8057 }
8058 |  ALTER RULE name ON qualified_name RENAME TO name
8059  {
8060  $$ = cat_str(6,mm_strdup("alter rule"),$3,mm_strdup("on"),$5,mm_strdup("rename to"),$8);
8061 }
8062 |  ALTER TRIGGER name ON qualified_name RENAME TO name
8063  {
8064  $$ = cat_str(6,mm_strdup("alter trigger"),$3,mm_strdup("on"),$5,mm_strdup("rename to"),$8);
8065 }
8066 |  ALTER EVENT TRIGGER name RENAME TO name
8067  {
8068  $$ = cat_str(4,mm_strdup("alter event trigger"),$4,mm_strdup("rename to"),$7);
8069 }
8070 |  ALTER ROLE RoleId RENAME TO RoleId
8071  {
8072  $$ = cat_str(4,mm_strdup("alter role"),$3,mm_strdup("rename to"),$6);
8073 }
8074 |  ALTER USER RoleId RENAME TO RoleId
8075  {
8076  $$ = cat_str(4,mm_strdup("alter user"),$3,mm_strdup("rename to"),$6);
8077 }
8078 |  ALTER TABLESPACE name RENAME TO name
8079  {
8080  $$ = cat_str(4,mm_strdup("alter tablespace"),$3,mm_strdup("rename to"),$6);
8081 }
8082 |  ALTER STATISTICS any_name RENAME TO name
8083  {
8084  $$ = cat_str(4,mm_strdup("alter statistics"),$3,mm_strdup("rename to"),$6);
8085 }
8086 |  ALTER TEXT_P SEARCH PARSER any_name RENAME TO name
8087  {
8088  $$ = cat_str(4,mm_strdup("alter text search parser"),$5,mm_strdup("rename to"),$8);
8089 }
8090 |  ALTER TEXT_P SEARCH DICTIONARY any_name RENAME TO name
8091  {
8092  $$ = cat_str(4,mm_strdup("alter text search dictionary"),$5,mm_strdup("rename to"),$8);
8093 }
8094 |  ALTER TEXT_P SEARCH TEMPLATE any_name RENAME TO name
8095  {
8096  $$ = cat_str(4,mm_strdup("alter text search template"),$5,mm_strdup("rename to"),$8);
8097 }
8098 |  ALTER TEXT_P SEARCH CONFIGURATION any_name RENAME TO name
8099  {
8100  $$ = cat_str(4,mm_strdup("alter text search configuration"),$5,mm_strdup("rename to"),$8);
8101 }
8102 |  ALTER TYPE_P any_name RENAME TO name
8103  {
8104  $$ = cat_str(4,mm_strdup("alter type"),$3,mm_strdup("rename to"),$6);
8105 }
8106 |  ALTER TYPE_P any_name RENAME ATTRIBUTE name TO name opt_drop_behavior
8107  {
8108  $$ = cat_str(7,mm_strdup("alter type"),$3,mm_strdup("rename attribute"),$6,mm_strdup("to"),$8,$9);
8109 }
8110 ;
8111 
8112 
8113  opt_column:
8114  COLUMN
8115  {
8116  $$ = mm_strdup("column");
8117 }
8118 |
8119  {
8120  $$=EMPTY; }
8121 ;
8122 
8123 
8124  opt_set_data:
8125  SET DATA_P
8126  {
8127  $$ = mm_strdup("set data");
8128 }
8129 |
8130  {
8131  $$=EMPTY; }
8132 ;
8133 
8134 
8135  AlterObjectDependsStmt:
8136  ALTER FUNCTION function_with_argtypes DEPENDS ON EXTENSION name
8137  {
8138  $$ = cat_str(4,mm_strdup("alter function"),$3,mm_strdup("depends on extension"),$7);
8139 }
8140 |  ALTER TRIGGER name ON qualified_name DEPENDS ON EXTENSION name
8141  {
8142  $$ = cat_str(6,mm_strdup("alter trigger"),$3,mm_strdup("on"),$5,mm_strdup("depends on extension"),$9);
8143 }
8144 |  ALTER MATERIALIZED VIEW qualified_name DEPENDS ON EXTENSION name
8145  {
8146  $$ = cat_str(4,mm_strdup("alter materialized view"),$4,mm_strdup("depends on extension"),$8);
8147 }
8148 |  ALTER INDEX qualified_name DEPENDS ON EXTENSION name
8149  {
8150  $$ = cat_str(4,mm_strdup("alter index"),$3,mm_strdup("depends on extension"),$7);
8151 }
8152 ;
8153 
8154 
8155  AlterObjectSchemaStmt:
8156  ALTER AGGREGATE aggregate_with_argtypes SET SCHEMA name
8157  {
8158  $$ = cat_str(4,mm_strdup("alter aggregate"),$3,mm_strdup("set schema"),$6);
8159 }
8160 |  ALTER COLLATION any_name SET SCHEMA name
8161  {
8162  $$ = cat_str(4,mm_strdup("alter collation"),$3,mm_strdup("set schema"),$6);
8163 }
8164 |  ALTER CONVERSION_P any_name SET SCHEMA name
8165  {
8166  $$ = cat_str(4,mm_strdup("alter conversion"),$3,mm_strdup("set schema"),$6);
8167 }
8168 |  ALTER DOMAIN_P any_name SET SCHEMA name
8169  {
8170  $$ = cat_str(4,mm_strdup("alter domain"),$3,mm_strdup("set schema"),$6);
8171 }
8172 |  ALTER EXTENSION name SET SCHEMA name
8173  {
8174  $$ = cat_str(4,mm_strdup("alter extension"),$3,mm_strdup("set schema"),$6);
8175 }
8176 |  ALTER FUNCTION function_with_argtypes SET SCHEMA name
8177  {
8178  $$ = cat_str(4,mm_strdup("alter function"),$3,mm_strdup("set schema"),$6);
8179 }
8180 |  ALTER OPERATOR operator_with_argtypes SET SCHEMA name
8181  {
8182  $$ = cat_str(4,mm_strdup("alter operator"),$3,mm_strdup("set schema"),$6);
8183 }
8184 |  ALTER OPERATOR CLASS any_name USING access_method SET SCHEMA name
8185  {
8186  $$ = cat_str(6,mm_strdup("alter operator class"),$4,mm_strdup("using"),$6,mm_strdup("set schema"),$9);
8187 }
8188 |  ALTER OPERATOR FAMILY any_name USING access_method SET SCHEMA name
8189  {
8190  $$ = cat_str(6,mm_strdup("alter operator family"),$4,mm_strdup("using"),$6,mm_strdup("set schema"),$9);
8191 }
8192 |  ALTER TABLE relation_expr SET SCHEMA name
8193  {
8194  $$ = cat_str(4,mm_strdup("alter table"),$3,mm_strdup("set schema"),$6);
8195 }
8196 |  ALTER TABLE IF_P EXISTS relation_expr SET SCHEMA name
8197  {
8198  $$ = cat_str(4,mm_strdup("alter table if exists"),$5,mm_strdup("set schema"),$8);
8199 }
8200 |  ALTER STATISTICS any_name SET SCHEMA name
8201  {
8202  $$ = cat_str(4,mm_strdup("alter statistics"),$3,mm_strdup("set schema"),$6);
8203 }
8204 |  ALTER TEXT_P SEARCH PARSER any_name SET SCHEMA name
8205  {
8206  $$ = cat_str(4,mm_strdup("alter text search parser"),$5,mm_strdup("set schema"),$8);
8207 }
8208 |  ALTER TEXT_P SEARCH DICTIONARY any_name SET SCHEMA name
8209  {
8210  $$ = cat_str(4,mm_strdup("alter text search dictionary"),$5,mm_strdup("set schema"),$8);
8211 }
8212 |  ALTER TEXT_P SEARCH TEMPLATE any_name SET SCHEMA name
8213  {
8214  $$ = cat_str(4,mm_strdup("alter text search template"),$5,mm_strdup("set schema"),$8);
8215 }
8216 |  ALTER TEXT_P SEARCH CONFIGURATION any_name SET SCHEMA name
8217  {
8218  $$ = cat_str(4,mm_strdup("alter text search configuration"),$5,mm_strdup("set schema"),$8);
8219 }
8220 |  ALTER SEQUENCE qualified_name SET SCHEMA name
8221  {
8222  $$ = cat_str(4,mm_strdup("alter sequence"),$3,mm_strdup("set schema"),$6);
8223 }
8224 |  ALTER SEQUENCE IF_P EXISTS qualified_name SET SCHEMA name
8225  {
8226  $$ = cat_str(4,mm_strdup("alter sequence if exists"),$5,mm_strdup("set schema"),$8);
8227 }
8228 |  ALTER VIEW qualified_name SET SCHEMA name
8229  {
8230  $$ = cat_str(4,mm_strdup("alter view"),$3,mm_strdup("set schema"),$6);
8231 }
8232 |  ALTER VIEW IF_P EXISTS qualified_name SET SCHEMA name
8233  {
8234  $$ = cat_str(4,mm_strdup("alter view if exists"),$5,mm_strdup("set schema"),$8);
8235 }
8236 |  ALTER MATERIALIZED VIEW qualified_name SET SCHEMA name
8237  {
8238  $$ = cat_str(4,mm_strdup("alter materialized view"),$4,mm_strdup("set schema"),$7);
8239 }
8240 |  ALTER MATERIALIZED VIEW IF_P EXISTS qualified_name SET SCHEMA name
8241  {
8242  $$ = cat_str(4,mm_strdup("alter materialized view if exists"),$6,mm_strdup("set schema"),$9);
8243 }
8244 |  ALTER FOREIGN TABLE relation_expr SET SCHEMA name
8245  {
8246  $$ = cat_str(4,mm_strdup("alter foreign table"),$4,mm_strdup("set schema"),$7);
8247 }
8248 |  ALTER FOREIGN TABLE IF_P EXISTS relation_expr SET SCHEMA name
8249  {
8250  $$ = cat_str(4,mm_strdup("alter foreign table if exists"),$6,mm_strdup("set schema"),$9);
8251 }
8252 |  ALTER TYPE_P any_name SET SCHEMA name
8253  {
8254  $$ = cat_str(4,mm_strdup("alter type"),$3,mm_strdup("set schema"),$6);
8255 }
8256 ;
8257 
8258 
8259  AlterOperatorStmt:
8260  ALTER OPERATOR operator_with_argtypes SET '(' operator_def_list ')'
8261  {
8262  $$ = cat_str(5,mm_strdup("alter operator"),$3,mm_strdup("set ("),$6,mm_strdup(")"));
8263 }
8264 ;
8265 
8266 
8267  operator_def_list:
8268  operator_def_elem
8269  {
8270  $$ = $1;
8271 }
8272 |  operator_def_list ',' operator_def_elem
8273  {
8274  $$ = cat_str(3,$1,mm_strdup(","),$3);
8275 }
8276 ;
8277 
8278 
8279  operator_def_elem:
8280  ColLabel '=' NONE
8281  {
8282  $$ = cat_str(2,$1,mm_strdup("= none"));
8283 }
8284 |  ColLabel '=' operator_def_arg
8285  {
8286  $$ = cat_str(3,$1,mm_strdup("="),$3);
8287 }
8288 ;
8289 
8290 
8291  operator_def_arg:
8292  func_type
8293  {
8294  $$ = $1;
8295 }
8296 |  reserved_keyword
8297  {
8298  $$ = $1;
8299 }
8300 |  qual_all_Op
8301  {
8302  $$ = $1;
8303 }
8304 |  NumericOnly
8305  {
8306  $$ = $1;
8307 }
8308 |  ecpg_sconst
8309  {
8310  $$ = $1;
8311 }
8312 ;
8313 
8314 
8315  AlterOwnerStmt:
8316  ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
8317  {
8318  $$ = cat_str(4,mm_strdup("alter aggregate"),$3,mm_strdup("owner to"),$6);
8319 }
8320 |  ALTER COLLATION any_name OWNER TO RoleSpec
8321  {
8322  $$ = cat_str(4,mm_strdup("alter collation"),$3,mm_strdup("owner to"),$6);
8323 }
8324 |  ALTER CONVERSION_P any_name OWNER TO RoleSpec
8325  {
8326  $$ = cat_str(4,mm_strdup("alter conversion"),$3,mm_strdup("owner to"),$6);
8327 }
8328 |  ALTER DATABASE database_name OWNER TO RoleSpec
8329  {
8330  $$ = cat_str(4,mm_strdup("alter database"),$3,mm_strdup("owner to"),$6);
8331 }
8332 |  ALTER DOMAIN_P any_name OWNER TO RoleSpec
8333  {
8334  $$ = cat_str(4,mm_strdup("alter domain"),$3,mm_strdup("owner to"),$6);
8335 }
8336 |  ALTER FUNCTION function_with_argtypes OWNER TO RoleSpec
8337  {
8338  $$ = cat_str(4,mm_strdup("alter function"),$3,mm_strdup("owner to"),$6);
8339 }
8340 |  ALTER opt_procedural LANGUAGE name OWNER TO RoleSpec
8341  {
8342  $$ = cat_str(6,mm_strdup("alter"),$2,mm_strdup("language"),$4,mm_strdup("owner to"),$7);
8343 }
8344 |  ALTER LARGE_P OBJECT_P NumericOnly OWNER TO RoleSpec
8345  {
8346  $$ = cat_str(4,mm_strdup("alter large object"),$4,mm_strdup("owner to"),$7);
8347 }
8348 |  ALTER OPERATOR operator_with_argtypes OWNER TO RoleSpec
8349  {
8350  $$ = cat_str(4,mm_strdup("alter operator"),$3,mm_strdup("owner to"),$6);
8351 }
8352 |  ALTER OPERATOR CLASS any_name USING access_method OWNER TO RoleSpec
8353  {
8354  $$ = cat_str(6,mm_strdup("alter operator class"),$4,mm_strdup("using"),$6,mm_strdup("owner to"),$9);
8355 }
8356 |  ALTER OPERATOR FAMILY any_name USING access_method OWNER TO RoleSpec
8357  {
8358  $$ = cat_str(6,mm_strdup("alter operator family"),$4,mm_strdup("using"),$6,mm_strdup("owner to"),$9);
8359 }
8360 |  ALTER SCHEMA name OWNER TO RoleSpec
8361  {
8362  $$ = cat_str(4,mm_strdup("alter schema"),$3,mm_strdup("owner to"),$6);
8363 }
8364 |  ALTER TYPE_P any_name OWNER TO RoleSpec
8365  {
8366  $$ = cat_str(4,mm_strdup("alter type"),$3,mm_strdup("owner to"),$6);
8367 }
8368 |  ALTER TABLESPACE name OWNER TO RoleSpec
8369  {
8370  $$ = cat_str(4,mm_strdup("alter tablespace"),$3,mm_strdup("owner to"),$6);
8371 }
8372 |  ALTER STATISTICS any_name OWNER TO RoleSpec
8373  {
8374  $$ = cat_str(4,mm_strdup("alter statistics"),$3,mm_strdup("owner to"),$6);
8375 }
8376 |  ALTER TEXT_P SEARCH DICTIONARY any_name OWNER TO RoleSpec
8377  {
8378  $$ = cat_str(4,mm_strdup("alter text search dictionary"),$5,mm_strdup("owner to"),$8);
8379 }
8380 |  ALTER TEXT_P SEARCH CONFIGURATION any_name OWNER TO RoleSpec
8381  {
8382  $$ = cat_str(4,mm_strdup("alter text search configuration"),$5,mm_strdup("owner to"),$8);
8383 }
8384 |  ALTER FOREIGN DATA_P WRAPPER name OWNER TO RoleSpec
8385  {
8386  $$ = cat_str(4,mm_strdup("alter foreign data wrapper"),$5,mm_strdup("owner to"),$8);
8387 }
8388 |  ALTER SERVER name OWNER TO RoleSpec
8389  {
8390  $$ = cat_str(4,mm_strdup("alter server"),$3,mm_strdup("owner to"),$6);
8391 }
8392 |  ALTER EVENT TRIGGER name OWNER TO RoleSpec
8393  {
8394  $$ = cat_str(4,mm_strdup("alter event trigger"),$4,mm_strdup("owner to"),$7);
8395 }
8396 |  ALTER PUBLICATION name OWNER TO RoleSpec
8397  {
8398  $$ = cat_str(4,mm_strdup("alter publication"),$3,mm_strdup("owner to"),$6);
8399 }
8400 |  ALTER SUBSCRIPTION name OWNER TO RoleSpec
8401  {
8402  $$ = cat_str(4,mm_strdup("alter subscription"),$3,mm_strdup("owner to"),$6);
8403 }
8404 ;
8405 
8406 
8407  CreatePublicationStmt:
8408  CREATE PUBLICATION name opt_publication_for_tables opt_definition
8409  {
8410  $$ = cat_str(4,mm_strdup("create publication"),$3,$4,$5);
8411 }
8412 ;
8413 
8414 
8415  opt_publication_for_tables:
8416  publication_for_tables
8417  {
8418  $$ = $1;
8419 }
8420 |
8421  {
8422  $$=EMPTY; }
8423 ;
8424 
8425 
8426  publication_for_tables:
8427  FOR TABLE relation_expr_list
8428  {
8429  $$ = cat_str(2,mm_strdup("for table"),$3);
8430 }
8431 |  FOR ALL TABLES
8432  {
8433  $$ = mm_strdup("for all tables");
8434 }
8435 ;
8436 
8437 
8438  AlterPublicationStmt:
8439  ALTER PUBLICATION name SET definition
8440  {
8441  $$ = cat_str(4,mm_strdup("alter publication"),$3,mm_strdup("set"),$5);
8442 }
8443 |  ALTER PUBLICATION name ADD_P TABLE relation_expr_list
8444  {
8445  $$ = cat_str(4,mm_strdup("alter publication"),$3,mm_strdup("add table"),$6);
8446 }
8447 |  ALTER PUBLICATION name SET TABLE relation_expr_list
8448  {
8449  $$ = cat_str(4,mm_strdup("alter publication"),$3,mm_strdup("set table"),$6);
8450 }
8451 |  ALTER PUBLICATION name DROP TABLE relation_expr_list
8452  {
8453  $$ = cat_str(4,mm_strdup("alter publication"),$3,mm_strdup("drop table"),$6);
8454 }
8455 ;
8456 
8457 
8458  CreateSubscriptionStmt:
8459  CREATE SUBSCRIPTION name CONNECTION ecpg_sconst PUBLICATION publication_name_list opt_definition
8460  {
8461  $$ = cat_str(7,mm_strdup("create subscription"),$3,mm_strdup("connection"),$5,mm_strdup("publication"),$7,$8);
8462 }
8463 ;
8464 
8465 
8466  publication_name_list:
8467  publication_name_item
8468  {
8469  $$ = $1;
8470 }
8471 |  publication_name_list ',' publication_name_item
8472  {
8473  $$ = cat_str(3,$1,mm_strdup(","),$3);
8474 }
8475 ;
8476 
8477 
8478  publication_name_item:
8479  ColLabel
8480  {
8481  $$ = $1;
8482 }
8483 ;
8484 
8485 
8486  AlterSubscriptionStmt:
8487  ALTER SUBSCRIPTION name SET definition
8488  {
8489  $$ = cat_str(4,mm_strdup("alter subscription"),$3,mm_strdup("set"),$5);
8490 }
8491 |  ALTER SUBSCRIPTION name CONNECTION ecpg_sconst
8492  {
8493  $$ = cat_str(4,mm_strdup("alter subscription"),$3,mm_strdup("connection"),$5);
8494 }
8495 |  ALTER SUBSCRIPTION name REFRESH PUBLICATION opt_definition
8496  {
8497  $$ = cat_str(4,mm_strdup("alter subscription"),$3,mm_strdup("refresh publication"),$6);
8498 }
8499 |  ALTER SUBSCRIPTION name SET PUBLICATION publication_name_list opt_definition
8500  {
8501  $$ = cat_str(5,mm_strdup("alter subscription"),$3,mm_strdup("set publication"),$6,$7);
8502 }
8503 |  ALTER SUBSCRIPTION name ENABLE_P
8504  {
8505  $$ = cat_str(3,mm_strdup("alter subscription"),$3,mm_strdup("enable"));
8506 }
8507 |  ALTER SUBSCRIPTION name DISABLE_P
8508  {
8509  $$ = cat_str(3,mm_strdup("alter subscription"),$3,mm_strdup("disable"));
8510 }
8511 ;
8512 
8513 
8514  DropSubscriptionStmt:
8515  DROP SUBSCRIPTION name opt_drop_behavior
8516  {
8517  $$ = cat_str(3,mm_strdup("drop subscription"),$3,$4);
8518 }
8519 |  DROP SUBSCRIPTION IF_P EXISTS name opt_drop_behavior
8520  {
8521  $$ = cat_str(3,mm_strdup("drop subscription if exists"),$5,$6);
8522 }
8523 ;
8524 
8525 
8526  RuleStmt:
8527  CREATE opt_or_replace RULE name AS ON event TO qualified_name where_clause DO opt_instead RuleActionList
8528  {
8529  $$ = 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);
8530 }
8531 ;
8532 
8533 
8534  RuleActionList:
8535  NOTHING
8536  {
8537  $$ = mm_strdup("nothing");
8538 }
8539 |  RuleActionStmt
8540  {
8541  $$ = $1;
8542 }
8543 |  '(' RuleActionMulti ')'
8544  {
8545  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
8546 }
8547 ;
8548 
8549 
8550  RuleActionMulti:
8551  RuleActionMulti ';' RuleActionStmtOrEmpty
8552  {
8553  $$ = cat_str(3,$1,mm_strdup(";"),$3);
8554 }
8555 |  RuleActionStmtOrEmpty
8556  {
8557  $$ = $1;
8558 }
8559 ;
8560 
8561 
8562  RuleActionStmt:
8563  SelectStmt
8564  {
8565  $$ = $1;
8566 }
8567 |  InsertStmt
8568  {
8569  $$ = $1;
8570 }
8571 |  UpdateStmt
8572  {
8573  $$ = $1;
8574 }
8575 |  DeleteStmt
8576  {
8577  $$ = $1;
8578 }
8579 |  NotifyStmt
8580  {
8581  $$ = $1;
8582 }
8583 ;
8584 
8585 
8586  RuleActionStmtOrEmpty:
8587  RuleActionStmt
8588  {
8589  $$ = $1;
8590 }
8591 |
8592  {
8593  $$=EMPTY; }
8594 ;
8595 
8596 
8597  event:
8598  SELECT
8599  {
8600  $$ = mm_strdup("select");
8601 }
8602 |  UPDATE
8603  {
8604  $$ = mm_strdup("update");
8605 }
8606 |  DELETE_P
8607  {
8608  $$ = mm_strdup("delete");
8609 }
8610 |  INSERT
8611  {
8612  $$ = mm_strdup("insert");
8613 }
8614 ;
8615 
8616 
8617  opt_instead:
8618  INSTEAD
8619  {
8620  $$ = mm_strdup("instead");
8621 }
8622 |  ALSO
8623  {
8624  $$ = mm_strdup("also");
8625 }
8626 |
8627  {
8628  $$=EMPTY; }
8629 ;
8630 
8631 
8632  NotifyStmt:
8633  NOTIFY ColId notify_payload
8634  {
8635  $$ = cat_str(3,mm_strdup("notify"),$2,$3);
8636 }
8637 ;
8638 
8639 
8640  notify_payload:
8641  ',' ecpg_sconst
8642  {
8643  $$ = cat_str(2,mm_strdup(","),$2);
8644 }
8645 |
8646  {
8647  $$=EMPTY; }
8648 ;
8649 
8650 
8651  ListenStmt:
8652  LISTEN ColId
8653  {
8654  $$ = cat_str(2,mm_strdup("listen"),$2);
8655 }
8656 ;
8657 
8658 
8659  UnlistenStmt:
8660  UNLISTEN ColId
8661  {
8662  $$ = cat_str(2,mm_strdup("unlisten"),$2);
8663 }
8664 |  UNLISTEN '*'
8665  {
8666  $$ = mm_strdup("unlisten *");
8667 }
8668 ;
8669 
8670 
8671  TransactionStmt:
8672  ABORT_P opt_transaction
8673  {
8674  $$ = cat_str(2,mm_strdup("abort"),$2);
8675 }
8676 |  BEGIN_P opt_transaction transaction_mode_list_or_empty
8677  {
8678  $$ = cat_str(3,mm_strdup("begin"),$2,$3);
8679 }
8680 |  START TRANSACTION transaction_mode_list_or_empty
8681  {
8682  $$ = cat_str(2,mm_strdup("start transaction"),$3);
8683 }
8684 |  COMMIT opt_transaction
8685  {
8686  $$ = cat_str(2,mm_strdup("commit"),$2);
8687 }
8688 |  END_P opt_transaction
8689  {
8690  $$ = cat_str(2,mm_strdup("end"),$2);
8691 }
8692 |  ROLLBACK opt_transaction
8693  {
8694  $$ = cat_str(2,mm_strdup("rollback"),$2);
8695 }
8696 |  SAVEPOINT ColId
8697  {
8698  $$ = cat_str(2,mm_strdup("savepoint"),$2);
8699 }
8700 |  RELEASE SAVEPOINT ColId
8701  {
8702  $$ = cat_str(2,mm_strdup("release savepoint"),$3);
8703 }
8704 |  RELEASE ColId
8705  {
8706  $$ = cat_str(2,mm_strdup("release"),$2);
8707 }
8708 |  ROLLBACK opt_transaction TO SAVEPOINT ColId
8709  {
8710  $$ = cat_str(4,mm_strdup("rollback"),$2,mm_strdup("to savepoint"),$5);
8711 }
8712 |  ROLLBACK opt_transaction TO ColId
8713  {
8714  $$ = cat_str(4,mm_strdup("rollback"),$2,mm_strdup("to"),$4);
8715 }
8716 |  PREPARE TRANSACTION ecpg_sconst
8717  {
8718  $$ = cat_str(2,mm_strdup("prepare transaction"),$3);
8719 }
8720 |  COMMIT PREPARED ecpg_sconst
8721  {
8722  $$ = cat_str(2,mm_strdup("commit prepared"),$3);
8723 }
8724 |  ROLLBACK PREPARED ecpg_sconst
8725  {
8726  $$ = cat_str(2,mm_strdup("rollback prepared"),$3);
8727 }
8728 ;
8729 
8730 
8731  opt_transaction:
8732  WORK
8733  {
8734  $$ = mm_strdup("work");
8735 }
8736 |  TRANSACTION
8737  {
8738  $$ = mm_strdup("transaction");
8739 }
8740 |
8741  {
8742  $$=EMPTY; }
8743 ;
8744 
8745 
8746  transaction_mode_item:
8747  ISOLATION LEVEL iso_level
8748  {
8749  $$ = cat_str(2,mm_strdup("isolation level"),$3);
8750 }
8751 |  READ ONLY
8752  {
8753  $$ = mm_strdup("read only");
8754 }
8755 |  READ WRITE
8756  {
8757  $$ = mm_strdup("read write");
8758 }
8759 |  DEFERRABLE
8760  {
8761  $$ = mm_strdup("deferrable");
8762 }
8763 |  NOT DEFERRABLE
8764  {
8765  $$ = mm_strdup("not deferrable");
8766 }
8767 ;
8768 
8769 
8770  transaction_mode_list:
8771  transaction_mode_item
8772  {
8773  $$ = $1;
8774 }
8775 |  transaction_mode_list ',' transaction_mode_item
8776  {
8777  $$ = cat_str(3,$1,mm_strdup(","),$3);
8778 }
8779 |  transaction_mode_list transaction_mode_item
8780  {
8781  $$ = cat_str(2,$1,$2);
8782 }
8783 ;
8784 
8785 
8786  transaction_mode_list_or_empty:
8787  transaction_mode_list
8788  {
8789  $$ = $1;
8790 }
8791 |
8792  {
8793  $$=EMPTY; }
8794 ;
8795 
8796 
8797  ViewStmt:
8798  CREATE OptTemp VIEW qualified_name opt_column_list opt_reloptions AS SelectStmt opt_check_option
8799  {
8800  $$ = cat_str(9,mm_strdup("create"),$2,mm_strdup("view"),$4,$5,$6,mm_strdup("as"),$8,$9);
8801 }
8802 |  CREATE OR REPLACE OptTemp VIEW qualified_name opt_column_list opt_reloptions AS SelectStmt opt_check_option
8803  {
8804  $$ = cat_str(9,mm_strdup("create or replace"),$4,mm_strdup("view"),$6,$7,$8,mm_strdup("as"),$10,$11);
8805 }
8806 |  CREATE OptTemp RECURSIVE VIEW qualified_name '(' columnList ')' opt_reloptions AS SelectStmt opt_check_option
8807  {
8808 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
8809  $$ = cat_str(11,mm_strdup("create"),$2,mm_strdup("recursive view"),$5,mm_strdup("("),$7,mm_strdup(")"),$9,mm_strdup("as"),$11,$12);
8810 }
8811 |  CREATE OR REPLACE OptTemp RECURSIVE VIEW qualified_name '(' columnList ')' opt_reloptions AS SelectStmt opt_check_option
8812  {
8813 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
8814  $$ = 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);
8815 }
8816 ;
8817 
8818 
8819  opt_check_option:
8820  WITH CHECK OPTION
8821  {
8822  $$ = mm_strdup("with check option");
8823 }
8824 |  WITH CASCADED CHECK OPTION
8825  {
8826  $$ = mm_strdup("with cascaded check option");
8827 }
8828 |  WITH LOCAL CHECK OPTION
8829  {
8830  $$ = mm_strdup("with local check option");
8831 }
8832 |
8833  {
8834  $$=EMPTY; }
8835 ;
8836 
8837 
8838  LoadStmt:
8839  LOAD file_name
8840  {
8841  $$ = cat_str(2,mm_strdup("load"),$2);
8842 }
8843 ;
8844 
8845 
8846  CreatedbStmt:
8847  CREATE DATABASE database_name opt_with createdb_opt_list
8848  {
8849  $$ = cat_str(4,mm_strdup("create database"),$3,$4,$5);
8850 }
8851 ;
8852 
8853 
8854  createdb_opt_list:
8855  createdb_opt_items
8856  {
8857  $$ = $1;
8858 }
8859 |
8860  {
8861  $$=EMPTY; }
8862 ;
8863 
8864 
8865  createdb_opt_items:
8866  createdb_opt_item
8867  {
8868  $$ = $1;
8869 }
8870 |  createdb_opt_items createdb_opt_item
8871  {
8872  $$ = cat_str(2,$1,$2);
8873 }
8874 ;
8875 
8876 
8877  createdb_opt_item:
8878  createdb_opt_name opt_equal SignedIconst
8879  {
8880  $$ = cat_str(3,$1,$2,$3);
8881 }
8882 |  createdb_opt_name opt_equal opt_boolean_or_string
8883  {
8884  $$ = cat_str(3,$1,$2,$3);
8885 }
8886 |  createdb_opt_name opt_equal DEFAULT
8887  {
8888  $$ = cat_str(3,$1,$2,mm_strdup("default"));
8889 }
8890 ;
8891 
8892 
8893  createdb_opt_name:
8894  ecpg_ident
8895  {
8896  $$ = $1;
8897 }
8898 |  CONNECTION LIMIT
8899  {
8900  $$ = mm_strdup("connection limit");
8901 }
8902 |  ENCODING
8903  {
8904  $$ = mm_strdup("encoding");
8905 }
8906 |  LOCATION
8907  {
8908  $$ = mm_strdup("location");
8909 }
8910 |  OWNER
8911  {
8912  $$ = mm_strdup("owner");
8913 }
8914 |  TABLESPACE
8915  {
8916  $$ = mm_strdup("tablespace");
8917 }
8918 |  TEMPLATE
8919  {
8920  $$ = mm_strdup("template");
8921 }
8922 ;
8923 
8924 
8925  opt_equal:
8926  '='
8927  {
8928  $$ = mm_strdup("=");
8929 }
8930 |
8931  {
8932  $$=EMPTY; }
8933 ;
8934 
8935 
8936  AlterDatabaseStmt:
8937  ALTER DATABASE database_name WITH createdb_opt_list
8938  {
8939  $$ = cat_str(4,mm_strdup("alter database"),$3,mm_strdup("with"),$5);
8940 }
8941 |  ALTER DATABASE database_name createdb_opt_list
8942  {
8943  $$ = cat_str(3,mm_strdup("alter database"),$3,$4);
8944 }
8945 |  ALTER DATABASE database_name SET TABLESPACE name
8946  {
8947  $$ = cat_str(4,mm_strdup("alter database"),$3,mm_strdup("set tablespace"),$6);
8948 }
8949 ;
8950 
8951 
8952  AlterDatabaseSetStmt:
8953  ALTER DATABASE database_name SetResetClause
8954  {
8955  $$ = cat_str(3,mm_strdup("alter database"),$3,$4);
8956 }
8957 ;
8958 
8959 
8960  DropdbStmt:
8961  DROP DATABASE database_name
8962  {
8963  $$ = cat_str(2,mm_strdup("drop database"),$3);
8964 }
8965 |  DROP DATABASE IF_P EXISTS database_name
8966  {
8967  $$ = cat_str(2,mm_strdup("drop database if exists"),$5);
8968 }
8969 ;
8970 
8971 
8972  AlterCollationStmt:
8973  ALTER COLLATION any_name REFRESH VERSION_P
8974  {
8975  $$ = cat_str(3,mm_strdup("alter collation"),$3,mm_strdup("refresh version"));
8976 }
8977 ;
8978 
8979 
8980  AlterSystemStmt:
8981  ALTER SYSTEM_P SET generic_set
8982  {
8983  $$ = cat_str(2,mm_strdup("alter system set"),$4);
8984 }
8985 |  ALTER SYSTEM_P RESET generic_reset
8986  {
8987  $$ = cat_str(2,mm_strdup("alter system reset"),$4);
8988 }
8989 ;
8990 
8991 
8992  CreateDomainStmt:
8993  CREATE DOMAIN_P any_name opt_as Typename ColQualList
8994  {
8995  $$ = cat_str(5,mm_strdup("create domain"),$3,$4,$5,$6);
8996 }
8997 ;
8998 
8999 
9000  AlterDomainStmt:
9001  ALTER DOMAIN_P any_name alter_column_default
9002  {
9003  $$ = cat_str(3,mm_strdup("alter domain"),$3,$4);
9004 }
9005 |  ALTER DOMAIN_P any_name DROP NOT NULL_P
9006  {
9007  $$ = cat_str(3,mm_strdup("alter domain"),$3,mm_strdup("drop not null"));
9008 }
9009 |  ALTER DOMAIN_P any_name SET NOT NULL_P
9010  {
9011  $$ = cat_str(3,mm_strdup("alter domain"),$3,mm_strdup("set not null"));
9012 }
9013 |  ALTER DOMAIN_P any_name ADD_P TableConstraint
9014  {
9015  $$ = cat_str(4,mm_strdup("alter domain"),$3,mm_strdup("add"),$5);
9016 }
9017 |  ALTER DOMAIN_P any_name DROP CONSTRAINT name opt_drop_behavior
9018  {
9019  $$ = cat_str(5,mm_strdup("alter domain"),$3,mm_strdup("drop constraint"),$6,$7);
9020 }
9021 |  ALTER DOMAIN_P any_name DROP CONSTRAINT IF_P EXISTS name opt_drop_behavior
9022  {
9023  $$ = cat_str(5,mm_strdup("alter domain"),$3,mm_strdup("drop constraint if exists"),$8,$9);
9024 }
9025 |  ALTER DOMAIN_P any_name VALIDATE CONSTRAINT name
9026  {
9027  $$ = cat_str(4,mm_strdup("alter domain"),$3,mm_strdup("validate constraint"),$6);
9028 }
9029 ;
9030 
9031 
9032  opt_as:
9033  AS
9034  {
9035  $$ = mm_strdup("as");
9036 }
9037 |
9038  {
9039  $$=EMPTY; }
9040 ;
9041 
9042 
9043  AlterTSDictionaryStmt:
9044  ALTER TEXT_P SEARCH DICTIONARY any_name definition
9045  {
9046  $$ = cat_str(3,mm_strdup("alter text search dictionary"),$5,$6);
9047 }
9048 ;
9049 
9050 
9051  AlterTSConfigurationStmt:
9052  ALTER TEXT_P SEARCH CONFIGURATION any_name ADD_P MAPPING FOR name_list any_with any_name_list
9053  {
9054  $$ = cat_str(6,mm_strdup("alter text search configuration"),$5,mm_strdup("add mapping for"),$9,$10,$11);
9055 }
9056 |  ALTER TEXT_P SEARCH CONFIGURATION any_name ALTER MAPPING FOR name_list any_with any_name_list
9057  {
9058  $$ = cat_str(6,mm_strdup("alter text search configuration"),$5,mm_strdup("alter mapping for"),$9,$10,$11);
9059 }
9060 |  ALTER TEXT_P SEARCH CONFIGURATION any_name ALTER MAPPING REPLACE any_name any_with any_name
9061  {
9062  $$ = cat_str(6,mm_strdup("alter text search configuration"),$5,mm_strdup("alter mapping replace"),$9,$10,$11);
9063 }
9064 |  ALTER TEXT_P SEARCH CONFIGURATION any_name ALTER MAPPING FOR name_list REPLACE any_name any_with any_name
9065  {
9066  $$ = cat_str(8,mm_strdup("alter text search configuration"),$5,mm_strdup("alter mapping for"),$9,mm_strdup("replace"),$11,$12,$13);
9067 }
9068 |  ALTER TEXT_P SEARCH CONFIGURATION any_name DROP MAPPING FOR name_list
9069  {
9070  $$ = cat_str(4,mm_strdup("alter text search configuration"),$5,mm_strdup("drop mapping for"),$9);
9071 }
9072 |  ALTER TEXT_P SEARCH CONFIGURATION any_name DROP MAPPING IF_P EXISTS FOR name_list
9073  {
9074  $$ = cat_str(4,mm_strdup("alter text search configuration"),$5,mm_strdup("drop mapping if exists for"),$11);
9075 }
9076 ;
9077 
9078 
9079  any_with:
9080  WITH
9081  {
9082  $$ = mm_strdup("with");
9083 }
9084 |  WITH_LA
9085  {
9086  $$ = mm_strdup("with");
9087 }
9088 ;
9089 
9090 
9091  CreateConversionStmt:
9092  CREATE opt_default CONVERSION_P any_name FOR ecpg_sconst TO ecpg_sconst FROM any_name
9093  {
9094  $$ = cat_str(10,mm_strdup("create"),$2,mm_strdup("conversion"),$4,mm_strdup("for"),$6,mm_strdup("to"),$8,mm_strdup("from"),$10);
9095 }
9096 ;
9097 
9098 
9099  ClusterStmt:
9100  CLUSTER opt_verbose qualified_name cluster_index_specification
9101  {
9102  $$ = cat_str(4,mm_strdup("cluster"),$2,$3,$4);
9103 }
9104 |  CLUSTER opt_verbose
9105  {
9106  $$ = cat_str(2,mm_strdup("cluster"),$2);
9107 }
9108 |  CLUSTER opt_verbose index_name ON qualified_name
9109  {
9110  $$ = cat_str(5,mm_strdup("cluster"),$2,$3,mm_strdup("on"),$5);
9111 }
9112 ;
9113 
9114 
9115  cluster_index_specification:
9116  USING index_name
9117  {
9118  $$ = cat_str(2,mm_strdup("using"),$2);
9119 }
9120 |
9121  {
9122  $$=EMPTY; }
9123 ;
9124 
9125 
9126  VacuumStmt:
9127  VACUUM opt_full opt_freeze opt_verbose
9128  {
9129  $$ = cat_str(4,mm_strdup("vacuum"),$2,$3,$4);
9130 }
9131 |  VACUUM opt_full opt_freeze opt_verbose qualified_name
9132  {
9133  $$ = cat_str(5,mm_strdup("vacuum"),$2,$3,$4,$5);
9134 }
9135 |  VACUUM opt_full opt_freeze opt_verbose AnalyzeStmt
9136  {
9137  $$ = cat_str(5,mm_strdup("vacuum"),$2,$3,$4,$5);
9138 }
9139 |  VACUUM '(' vacuum_option_list ')'
9140  {
9141  $$ = cat_str(3,mm_strdup("vacuum ("),$3,mm_strdup(")"));
9142 }
9143 |  VACUUM '(' vacuum_option_list ')' qualified_name opt_name_list
9144  {
9145  $$ = cat_str(5,mm_strdup("vacuum ("),$3,mm_strdup(")"),$5,$6);
9146 }
9147 ;
9148 
9149 
9150  vacuum_option_list:
9151  vacuum_option_elem
9152  {
9153  $$ = $1;
9154 }
9155 |  vacuum_option_list ',' vacuum_option_elem
9156  {
9157  $$ = cat_str(3,$1,mm_strdup(","),$3);
9158 }
9159 ;
9160 
9161 
9162  vacuum_option_elem:
9163  analyze_keyword
9164  {
9165  $$ = $1;
9166 }
9167 |  VERBOSE
9168  {
9169  $$ = mm_strdup("verbose");
9170 }
9171 |  FREEZE
9172  {
9173  $$ = mm_strdup("freeze");
9174 }
9175 |  FULL
9176  {
9177  $$ = mm_strdup("full");
9178 }
9179 |  ecpg_ident
9180  {
9181  $$ = $1;
9182 }
9183 ;
9184 
9185 
9186  AnalyzeStmt:
9187  analyze_keyword opt_verbose
9188  {
9189  $$ = cat_str(2,$1,$2);
9190 }
9191 |  analyze_keyword opt_verbose qualified_name opt_name_list
9192  {
9193  $$ = cat_str(4,$1,$2,$3,$4);
9194 }
9195 ;
9196 
9197 
9198  analyze_keyword:
9199  ANALYZE
9200  {
9201  $$ = mm_strdup("analyze");
9202 }
9203 |  ANALYSE
9204  {
9205  $$ = mm_strdup("analyse");
9206 }
9207 ;
9208 
9209 
9210  opt_verbose:
9211  VERBOSE
9212  {
9213  $$ = mm_strdup("verbose");
9214 }
9215 |
9216  {
9217  $$=EMPTY; }
9218 ;
9219 
9220 
9221  opt_full:
9222  FULL
9223  {
9224  $$ = mm_strdup("full");
9225 }
9226 |
9227  {
9228  $$=EMPTY; }
9229 ;
9230 
9231 
9232  opt_freeze:
9233  FREEZE
9234  {
9235  $$ = mm_strdup("freeze");
9236 }
9237 |
9238  {
9239  $$=EMPTY; }
9240 ;
9241 
9242 
9243  opt_name_list:
9244  '(' name_list ')'
9245  {
9246  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
9247 }
9248 |
9249  {
9250  $$=EMPTY; }
9251 ;
9252 
9253 
9254  ExplainStmt:
9255  EXPLAIN ExplainableStmt
9256  {
9257  $$ = cat_str(2,mm_strdup("explain"),$2);
9258 }
9259 |  EXPLAIN analyze_keyword opt_verbose ExplainableStmt
9260  {
9261  $$ = cat_str(4,mm_strdup("explain"),$2,$3,$4);
9262 }
9263 |  EXPLAIN VERBOSE ExplainableStmt
9264  {
9265  $$ = cat_str(2,mm_strdup("explain verbose"),$3);
9266 }
9267 |  EXPLAIN '(' explain_option_list ')' ExplainableStmt
9268  {
9269  $$ = cat_str(4,mm_strdup("explain ("),$3,mm_strdup(")"),$5);
9270 }
9271 ;
9272 
9273 
9274  ExplainableStmt:
9275  SelectStmt
9276  {
9277  $$ = $1;
9278 }
9279 |  InsertStmt
9280  {
9281  $$ = $1;
9282 }
9283 |  UpdateStmt
9284  {
9285  $$ = $1;
9286 }
9287 |  DeleteStmt
9288  {
9289  $$ = $1;
9290 }
9291 |  DeclareCursorStmt
9292  {
9293  $$ = $1;
9294 }
9295 |  CreateAsStmt
9296  {
9297  $$ = $1;
9298 }
9299 |  CreateMatViewStmt
9300  {
9301  $$ = $1;
9302 }
9303 |  RefreshMatViewStmt
9304  {
9305  $$ = $1;
9306 }
9307 |  ExecuteStmt
9308  {
9309  $$ = $1;
9310 }
9311 ;
9312 
9313 
9314  explain_option_list:
9315  explain_option_elem
9316  {
9317  $$ = $1;
9318 }
9319 |  explain_option_list ',' explain_option_elem
9320  {
9321  $$ = cat_str(3,$1,mm_strdup(","),$3);
9322 }
9323 ;
9324 
9325 
9326  explain_option_elem:
9327  explain_option_name explain_option_arg
9328  {
9329  $$ = cat_str(2,$1,$2);
9330 }
9331 ;
9332 
9333 
9334  explain_option_name:
9335  NonReservedWord
9336  {
9337  $$ = $1;
9338 }
9339 |  analyze_keyword
9340  {
9341  $$ = $1;
9342 }
9343 ;
9344 
9345 
9346  explain_option_arg:
9347  opt_boolean_or_string
9348  {
9349  $$ = $1;
9350 }
9351 |  NumericOnly
9352  {
9353  $$ = $1;
9354 }
9355 |
9356  {
9357  $$=EMPTY; }
9358 ;
9359 
9360 
9361  PrepareStmt:
9362 PREPARE prepared_name prep_type_clause AS PreparableStmt
9363 	{
9364 		$$.name = $2;
9365 		$$.type = $3;
9366 		$$.stmt = cat_str(3, mm_strdup("\""), $5, mm_strdup("\""));
9367 	}
9368 	| PREPARE prepared_name FROM execstring
9369 	{
9370 		$$.name = $2;
9371 		$$.type = NULL;
9372 		$$.stmt = $4;
9373 	}
9374 ;
9375 
9376 
9377  prep_type_clause:
9378  '(' type_list ')'
9379  {
9380  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
9381 }
9382 |
9383  {
9384  $$=EMPTY; }
9385 ;
9386 
9387 
9388  PreparableStmt:
9389  SelectStmt
9390  {
9391  $$ = $1;
9392 }
9393 |  InsertStmt
9394  {
9395  $$ = $1;
9396 }
9397 |  UpdateStmt
9398  {
9399  $$ = $1;
9400 }
9401 |  DeleteStmt
9402  {
9403  $$ = $1;
9404 }
9405 ;
9406 
9407 
9408  ExecuteStmt:
9409 EXECUTE prepared_name execute_param_clause execute_rest
9410 	{ $$ = $2; }
9411 |  CREATE OptTemp TABLE create_as_target AS EXECUTE name execute_param_clause opt_with_data
9412  {
9413  $$ = cat_str(8,mm_strdup("create"),$2,mm_strdup("table"),$4,mm_strdup("as execute"),$7,$8,$9);
9414 }
9415 |  CREATE OptTemp TABLE IF_P NOT EXISTS create_as_target AS EXECUTE name execute_param_clause opt_with_data
9416  {
9417  $$ = cat_str(8,mm_strdup("create"),$2,mm_strdup("table if not exists"),$7,mm_strdup("as execute"),$10,$11,$12);
9418 }
9419 ;
9420 
9421 
9422  execute_param_clause:
9423  '(' expr_list ')'
9424  {
9425  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
9426 }
9427 |
9428  {
9429  $$=EMPTY; }
9430 ;
9431 
9432 
9433  InsertStmt:
9434  opt_with_clause INSERT INTO insert_target insert_rest opt_on_conflict returning_clause
9435  {
9436  $$ = cat_str(6,$1,mm_strdup("insert into"),$4,$5,$6,$7);
9437 }
9438 ;
9439 
9440 
9441  insert_target:
9442  qualified_name
9443  {
9444  $$ = $1;
9445 }
9446 |  qualified_name AS ColId
9447  {
9448  $$ = cat_str(3,$1,mm_strdup("as"),$3);
9449 }
9450 ;
9451 
9452 
9453  insert_rest:
9454  SelectStmt
9455  {
9456  $$ = $1;
9457 }
9458 |  OVERRIDING override_kind VALUE_P SelectStmt
9459  {
9460  $$ = cat_str(4,mm_strdup("overriding"),$2,mm_strdup("value"),$4);
9461 }
9462 |  '(' insert_column_list ')' SelectStmt
9463  {
9464  $$ = cat_str(4,mm_strdup("("),$2,mm_strdup(")"),$4);
9465 }
9466 |  '(' insert_column_list ')' OVERRIDING override_kind VALUE_P SelectStmt
9467  {
9468  $$ = cat_str(6,mm_strdup("("),$2,mm_strdup(") overriding"),$5,mm_strdup("value"),$7);
9469 }
9470 |  DEFAULT VALUES
9471  {
9472  $$ = mm_strdup("default values");
9473 }
9474 ;
9475 
9476 
9477  override_kind:
9478  USER
9479  {
9480  $$ = mm_strdup("user");
9481 }
9482 |  SYSTEM_P
9483  {
9484  $$ = mm_strdup("system");
9485 }
9486 ;
9487 
9488 
9489  insert_column_list:
9490  insert_column_item
9491  {
9492  $$ = $1;
9493 }
9494 |  insert_column_list ',' insert_column_item
9495  {
9496  $$ = cat_str(3,$1,mm_strdup(","),$3);
9497 }
9498 ;
9499 
9500 
9501  insert_column_item:
9502  ColId opt_indirection
9503  {
9504  $$ = cat_str(2,$1,$2);
9505 }
9506 ;
9507 
9508 
9509  opt_on_conflict:
9510  ON CONFLICT opt_conf_expr DO UPDATE SET set_clause_list where_clause
9511  {
9512  $$ = cat_str(5,mm_strdup("on conflict"),$3,mm_strdup("do update set"),$7,$8);
9513 }
9514 |  ON CONFLICT opt_conf_expr DO NOTHING
9515  {
9516  $$ = cat_str(3,mm_strdup("on conflict"),$3,mm_strdup("do nothing"));
9517 }
9518 |
9519  {
9520  $$=EMPTY; }
9521 ;
9522 
9523 
9524  opt_conf_expr:
9525  '(' index_params ')' where_clause
9526  {
9527  $$ = cat_str(4,mm_strdup("("),$2,mm_strdup(")"),$4);
9528 }
9529 |  ON CONSTRAINT name
9530  {
9531  $$ = cat_str(2,mm_strdup("on constraint"),$3);
9532 }
9533 |
9534  {
9535  $$=EMPTY; }
9536 ;
9537 
9538 
9539  returning_clause:
9540 RETURNING target_list opt_ecpg_into
9541  {
9542  $$ = cat_str(2,mm_strdup("returning"),$2);
9543 }
9544 |
9545  {
9546  $$=EMPTY; }
9547 ;
9548 
9549 
9550  DeleteStmt:
9551  opt_with_clause DELETE_P FROM relation_expr_opt_alias using_clause where_or_current_clause returning_clause
9552  {
9553  $$ = cat_str(6,$1,mm_strdup("delete from"),$4,$5,$6,$7);
9554 }
9555 ;
9556 
9557 
9558  using_clause:
9559  USING from_list
9560  {
9561  $$ = cat_str(2,mm_strdup("using"),$2);
9562 }
9563 |
9564  {
9565  $$=EMPTY; }
9566 ;
9567 
9568 
9569  LockStmt:
9570  LOCK_P opt_table relation_expr_list opt_lock opt_nowait
9571  {
9572  $$ = cat_str(5,mm_strdup("lock"),$2,$3,$4,$5);
9573 }
9574 ;
9575 
9576 
9577  opt_lock:
9578  IN_P lock_type MODE
9579  {
9580  $$ = cat_str(3,mm_strdup("in"),$2,mm_strdup("mode"));
9581 }
9582 |
9583  {
9584  $$=EMPTY; }
9585 ;
9586 
9587 
9588  lock_type:
9589  ACCESS SHARE
9590  {
9591  $$ = mm_strdup("access share");
9592 }
9593 |  ROW SHARE
9594  {
9595  $$ = mm_strdup("row share");
9596 }
9597 |  ROW EXCLUSIVE
9598  {
9599  $$ = mm_strdup("row exclusive");
9600 }
9601 |  SHARE UPDATE EXCLUSIVE
9602  {
9603  $$ = mm_strdup("share update exclusive");
9604 }
9605 |  SHARE
9606  {
9607  $$ = mm_strdup("share");
9608 }
9609 |  SHARE ROW EXCLUSIVE
9610  {
9611  $$ = mm_strdup("share row exclusive");
9612 }
9613 |  EXCLUSIVE
9614  {
9615  $$ = mm_strdup("exclusive");
9616 }
9617 |  ACCESS EXCLUSIVE
9618  {
9619  $$ = mm_strdup("access exclusive");
9620 }
9621 ;
9622 
9623 
9624  opt_nowait:
9625  NOWAIT
9626  {
9627  $$ = mm_strdup("nowait");
9628 }
9629 |
9630  {
9631  $$=EMPTY; }
9632 ;
9633 
9634 
9635  opt_nowait_or_skip:
9636  NOWAIT
9637  {
9638  $$ = mm_strdup("nowait");
9639 }
9640 |  SKIP LOCKED
9641  {
9642  $$ = mm_strdup("skip locked");
9643 }
9644 |
9645  {
9646  $$=EMPTY; }
9647 ;
9648 
9649 
9650  UpdateStmt:
9651  opt_with_clause UPDATE relation_expr_opt_alias SET set_clause_list from_clause where_or_current_clause returning_clause
9652  {
9653  $$ = cat_str(8,$1,mm_strdup("update"),$3,mm_strdup("set"),$5,$6,$7,$8);
9654 }
9655 ;
9656 
9657 
9658  set_clause_list:
9659  set_clause
9660  {
9661  $$ = $1;
9662 }
9663 |  set_clause_list ',' set_clause
9664  {
9665  $$ = cat_str(3,$1,mm_strdup(","),$3);
9666 }
9667 ;
9668 
9669 
9670  set_clause:
9671  set_target '=' a_expr
9672  {
9673  $$ = cat_str(3,$1,mm_strdup("="),$3);
9674 }
9675 |  '(' set_target_list ')' '=' a_expr
9676  {
9677  $$ = cat_str(4,mm_strdup("("),$2,mm_strdup(") ="),$5);
9678 }
9679 ;
9680 
9681 
9682  set_target:
9683  ColId opt_indirection
9684  {
9685  $$ = cat_str(2,$1,$2);
9686 }
9687 ;
9688 
9689 
9690  set_target_list:
9691  set_target
9692  {
9693  $$ = $1;
9694 }
9695 |  set_target_list ',' set_target
9696  {
9697  $$ = cat_str(3,$1,mm_strdup(","),$3);
9698 }
9699 ;
9700 
9701 
9702  DeclareCursorStmt:
9703  DECLARE cursor_name cursor_options CURSOR opt_hold FOR SelectStmt
9704 	{
9705 		struct cursor *ptr, *this;
9706 		char *cursor_marker = $2[0] == ':' ? mm_strdup("$0") : mm_strdup($2);
9707 		char *comment, *c1, *c2;
9708 		int (* strcmp_fn)(const char *, const char *) = (($2[0] == ':' || $2[0] == '"') ? strcmp : pg_strcasecmp);
9709 
9710 		for (ptr = cur; ptr != NULL; ptr = ptr->next)
9711 		{
9712 			if (strcmp_fn($2, ptr->name) == 0)
9713 			{
9714 				if ($2[0] == ':')
9715 					mmerror(PARSE_ERROR, ET_ERROR, "using variable \"%s\" in different declare statements is not supported", $2+1);
9716 				else
9717 					mmerror(PARSE_ERROR, ET_ERROR, "cursor \"%s\" is already defined", $2);
9718 			}
9719 		}
9720 
9721 		this = (struct cursor *) mm_alloc(sizeof(struct cursor));
9722 
9723 		this->next = cur;
9724 		this->name = $2;
9725 		this->function = (current_function ? mm_strdup(current_function) : NULL);
9726 		this->connection = connection;
9727 		this->opened = false;
9728 		this->command =  cat_str(7, mm_strdup("declare"), cursor_marker, $3, mm_strdup("cursor"), $5, mm_strdup("for"), $7);
9729 		this->argsinsert = argsinsert;
9730 		this->argsinsert_oos = NULL;
9731 		this->argsresult = argsresult;
9732 		this->argsresult_oos = NULL;
9733 		argsinsert = argsresult = NULL;
9734 		cur = this;
9735 
9736 		c1 = mm_strdup(this->command);
9737 		if ((c2 = strstr(c1, "*/")) != NULL)
9738 		{
9739 			/* We put this text into a comment, so we better remove [*][/]. */
9740 			c2[0] = '.';
9741 			c2[1] = '.';
9742 		}
9743 		comment = cat_str(3, mm_strdup("/*"), c1, mm_strdup("*/"));
9744 
9745 		if ((braces_open > 0) && INFORMIX_MODE) /* we're in a function */
9746 			$$ = cat_str(3, adjust_outofscope_cursor_vars(this),
9747 				mm_strdup("ECPG_informix_reset_sqlca();"),
9748 				comment);
9749 		else
9750 			$$ = cat2_str(adjust_outofscope_cursor_vars(this), comment);
9751 	}
9752 ;
9753 
9754 
9755  cursor_name:
9756  name
9757  {
9758  $$ = $1;
9759 }
9760 	| char_civar
9761 		{
9762 			char *curname = mm_alloc(strlen($1) + 2);
9763 			sprintf(curname, ":%s", $1);
9764 			free($1);
9765 			$1 = curname;
9766 			$$ = $1;
9767 		}
9768 ;
9769 
9770 
9771  cursor_options:
9772 
9773  {
9774  $$=EMPTY; }
9775 |  cursor_options NO SCROLL
9776  {
9777  $$ = cat_str(2,$1,mm_strdup("no scroll"));
9778 }
9779 |  cursor_options SCROLL
9780  {
9781  $$ = cat_str(2,$1,mm_strdup("scroll"));
9782 }
9783 |  cursor_options BINARY
9784  {
9785  $$ = cat_str(2,$1,mm_strdup("binary"));
9786 }
9787 |  cursor_options INSENSITIVE
9788  {
9789  $$ = cat_str(2,$1,mm_strdup("insensitive"));
9790 }
9791 ;
9792 
9793 
9794  opt_hold:
9795 
9796 	{
9797 		if (compat == ECPG_COMPAT_INFORMIX_SE && autocommit)
9798 			$$ = mm_strdup("with hold");
9799 		else
9800 			$$ = EMPTY;
9801 	}
9802 |  WITH HOLD
9803  {
9804  $$ = mm_strdup("with hold");
9805 }
9806 |  WITHOUT HOLD
9807  {
9808  $$ = mm_strdup("without hold");
9809 }
9810 ;
9811 
9812 
9813  SelectStmt:
9814  select_no_parens %prec UMINUS
9815  {
9816  $$ = $1;
9817 }
9818 |  select_with_parens %prec UMINUS
9819  {
9820  $$ = $1;
9821 }
9822 ;
9823 
9824 
9825  select_with_parens:
9826  '(' select_no_parens ')'
9827  {
9828  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
9829 }
9830 |  '(' select_with_parens ')'
9831  {
9832  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
9833 }
9834 ;
9835 
9836 
9837  select_no_parens:
9838  simple_select
9839  {
9840  $$ = $1;
9841 }
9842 |  select_clause sort_clause
9843  {
9844  $$ = cat_str(2,$1,$2);
9845 }
9846 |  select_clause opt_sort_clause for_locking_clause opt_select_limit
9847  {
9848  $$ = cat_str(4,$1,$2,$3,$4);
9849 }
9850 |  select_clause opt_sort_clause select_limit opt_for_locking_clause
9851  {
9852  $$ = cat_str(4,$1,$2,$3,$4);
9853 }
9854 |  with_clause select_clause
9855  {
9856  $$ = cat_str(2,$1,$2);
9857 }
9858 |  with_clause select_clause sort_clause
9859  {
9860  $$ = cat_str(3,$1,$2,$3);
9861 }
9862 |  with_clause select_clause opt_sort_clause for_locking_clause opt_select_limit
9863  {
9864  $$ = cat_str(5,$1,$2,$3,$4,$5);
9865 }
9866 |  with_clause select_clause opt_sort_clause select_limit opt_for_locking_clause
9867  {
9868  $$ = cat_str(5,$1,$2,$3,$4,$5);
9869 }
9870 ;
9871 
9872 
9873  select_clause:
9874  simple_select
9875  {
9876  $$ = $1;
9877 }
9878 |  select_with_parens
9879  {
9880  $$ = $1;
9881 }
9882 ;
9883 
9884 
9885  simple_select:
9886  SELECT opt_all_clause opt_target_list into_clause from_clause where_clause group_clause having_clause window_clause
9887  {
9888  $$ = cat_str(9,mm_strdup("select"),$2,$3,$4,$5,$6,$7,$8,$9);
9889 }
9890 |  SELECT distinct_clause target_list into_clause from_clause where_clause group_clause having_clause window_clause
9891  {
9892  $$ = cat_str(9,mm_strdup("select"),$2,$3,$4,$5,$6,$7,$8,$9);
9893 }
9894 |  values_clause
9895  {
9896  $$ = $1;
9897 }
9898 |  TABLE relation_expr
9899  {
9900  $$ = cat_str(2,mm_strdup("table"),$2);
9901 }
9902 |  select_clause UNION all_or_distinct select_clause
9903  {
9904  $$ = cat_str(4,$1,mm_strdup("union"),$3,$4);
9905 }
9906 |  select_clause INTERSECT all_or_distinct select_clause
9907  {
9908  $$ = cat_str(4,$1,mm_strdup("intersect"),$3,$4);
9909 }
9910 |  select_clause EXCEPT all_or_distinct select_clause
9911  {
9912  $$ = cat_str(4,$1,mm_strdup("except"),$3,$4);
9913 }
9914 ;
9915 
9916 
9917  with_clause:
9918  WITH cte_list
9919  {
9920  $$ = cat_str(2,mm_strdup("with"),$2);
9921 }
9922 |  WITH_LA cte_list
9923  {
9924  $$ = cat_str(2,mm_strdup("with"),$2);
9925 }
9926 |  WITH RECURSIVE cte_list
9927  {
9928  $$ = cat_str(2,mm_strdup("with recursive"),$3);
9929 }
9930 ;
9931 
9932 
9933  cte_list:
9934  common_table_expr
9935  {
9936  $$ = $1;
9937 }
9938 |  cte_list ',' common_table_expr
9939  {
9940  $$ = cat_str(3,$1,mm_strdup(","),$3);
9941 }
9942 ;
9943 
9944 
9945  common_table_expr:
9946  name opt_name_list AS '(' PreparableStmt ')'
9947  {
9948  $$ = cat_str(5,$1,$2,mm_strdup("as ("),$5,mm_strdup(")"));
9949 }
9950 ;
9951 
9952 
9953  opt_with_clause:
9954  with_clause
9955  {
9956  $$ = $1;
9957 }
9958 |
9959  {
9960  $$=EMPTY; }
9961 ;
9962 
9963 
9964  into_clause:
9965  INTO OptTempTableName
9966 					{
9967 						FoundInto = 1;
9968 						$$= cat2_str(mm_strdup("into"), $2);
9969 					}
9970 	| ecpg_into { $$ = EMPTY; }
9971 |
9972  {
9973  $$=EMPTY; }
9974 ;
9975 
9976 
9977  OptTempTableName:
9978  TEMPORARY opt_table qualified_name
9979  {
9980  $$ = cat_str(3,mm_strdup("temporary"),$2,$3);
9981 }
9982 |  TEMP opt_table qualified_name
9983  {
9984  $$ = cat_str(3,mm_strdup("temp"),$2,$3);
9985 }
9986 |  LOCAL TEMPORARY opt_table qualified_name
9987  {
9988  $$ = cat_str(3,mm_strdup("local temporary"),$3,$4);
9989 }
9990 |  LOCAL TEMP opt_table qualified_name
9991  {
9992  $$ = cat_str(3,mm_strdup("local temp"),$3,$4);
9993 }
9994 |  GLOBAL TEMPORARY opt_table qualified_name
9995  {
9996  $$ = cat_str(3,mm_strdup("global temporary"),$3,$4);
9997 }
9998 |  GLOBAL TEMP opt_table qualified_name
9999  {
10000  $$ = cat_str(3,mm_strdup("global temp"),$3,$4);
10001 }
10002 |  UNLOGGED opt_table qualified_name
10003  {
10004  $$ = cat_str(3,mm_strdup("unlogged"),$2,$3);
10005 }
10006 |  TABLE qualified_name
10007  {
10008  $$ = cat_str(2,mm_strdup("table"),$2);
10009 }
10010 |  qualified_name
10011  {
10012  $$ = $1;
10013 }
10014 ;
10015 
10016 
10017  opt_table:
10018  TABLE
10019  {
10020  $$ = mm_strdup("table");
10021 }
10022 |
10023  {
10024  $$=EMPTY; }
10025 ;
10026 
10027 
10028  all_or_distinct:
10029  ALL
10030  {
10031  $$ = mm_strdup("all");
10032 }
10033 |  DISTINCT
10034  {
10035  $$ = mm_strdup("distinct");
10036 }
10037 |
10038  {
10039  $$=EMPTY; }
10040 ;
10041 
10042 
10043  distinct_clause:
10044  DISTINCT
10045  {
10046  $$ = mm_strdup("distinct");
10047 }
10048 |  DISTINCT ON '(' expr_list ')'
10049  {
10050  $$ = cat_str(3,mm_strdup("distinct on ("),$4,mm_strdup(")"));
10051 }
10052 ;
10053 
10054 
10055  opt_all_clause:
10056  ALL
10057  {
10058  $$ = mm_strdup("all");
10059 }
10060 |
10061  {
10062  $$=EMPTY; }
10063 ;
10064 
10065 
10066  opt_sort_clause:
10067  sort_clause
10068  {
10069  $$ = $1;
10070 }
10071 |
10072  {
10073  $$=EMPTY; }
10074 ;
10075 
10076 
10077  sort_clause:
10078  ORDER BY sortby_list
10079  {
10080  $$ = cat_str(2,mm_strdup("order by"),$3);
10081 }
10082 ;
10083 
10084 
10085  sortby_list:
10086  sortby
10087  {
10088  $$ = $1;
10089 }
10090 |  sortby_list ',' sortby
10091  {
10092  $$ = cat_str(3,$1,mm_strdup(","),$3);
10093 }
10094 ;
10095 
10096 
10097  sortby:
10098  a_expr USING qual_all_Op opt_nulls_order
10099  {
10100  $$ = cat_str(4,$1,mm_strdup("using"),$3,$4);
10101 }
10102 |  a_expr opt_asc_desc opt_nulls_order
10103  {
10104  $$ = cat_str(3,$1,$2,$3);
10105 }
10106 ;
10107 
10108 
10109  select_limit:
10110  limit_clause offset_clause
10111  {
10112  $$ = cat_str(2,$1,$2);
10113 }
10114 |  offset_clause limit_clause
10115  {
10116  $$ = cat_str(2,$1,$2);
10117 }
10118 |  limit_clause
10119  {
10120  $$ = $1;
10121 }
10122 |  offset_clause
10123  {
10124  $$ = $1;
10125 }
10126 ;
10127 
10128 
10129  opt_select_limit:
10130  select_limit
10131  {
10132  $$ = $1;
10133 }
10134 |
10135  {
10136  $$=EMPTY; }
10137 ;
10138 
10139 
10140  limit_clause:
10141  LIMIT select_limit_value
10142  {
10143  $$ = cat_str(2,mm_strdup("limit"),$2);
10144 }
10145 |  LIMIT select_limit_value ',' select_offset_value
10146 	{
10147 		mmerror(PARSE_ERROR, ET_WARNING, "no longer supported LIMIT #,# syntax passed to server");
10148 		$$ = cat_str(4, mm_strdup("limit"), $2, mm_strdup(","), $4);
10149 	}
10150 |  FETCH first_or_next select_fetch_first_value row_or_rows ONLY
10151  {
10152  $$ = cat_str(5,mm_strdup("fetch"),$2,$3,$4,mm_strdup("only"));
10153 }
10154 |  FETCH first_or_next row_or_rows ONLY
10155  {
10156  $$ = cat_str(4,mm_strdup("fetch"),$2,$3,mm_strdup("only"));
10157 }
10158 ;
10159 
10160 
10161  offset_clause:
10162  OFFSET select_offset_value
10163  {
10164  $$ = cat_str(2,mm_strdup("offset"),$2);
10165 }
10166 |  OFFSET select_fetch_first_value row_or_rows
10167  {
10168  $$ = cat_str(3,mm_strdup("offset"),$2,$3);
10169 }
10170 ;
10171 
10172 
10173  select_limit_value:
10174  a_expr
10175  {
10176  $$ = $1;
10177 }
10178 |  ALL
10179  {
10180  $$ = mm_strdup("all");
10181 }
10182 ;
10183 
10184 
10185  select_offset_value:
10186  a_expr
10187  {
10188  $$ = $1;
10189 }
10190 ;
10191 
10192 
10193  select_fetch_first_value:
10194  c_expr
10195  {
10196  $$ = $1;
10197 }
10198 |  '+' I_or_F_const
10199  {
10200  $$ = cat_str(2,mm_strdup("+"),$2);
10201 }
10202 |  '-' I_or_F_const
10203  {
10204  $$ = cat_str(2,mm_strdup("-"),$2);
10205 }
10206 ;
10207 
10208 
10209  I_or_F_const:
10210  Iconst
10211  {
10212  $$ = $1;
10213 }
10214 |  ecpg_fconst
10215  {
10216  $$ = $1;
10217 }
10218 ;
10219 
10220 
10221  row_or_rows:
10222  ROW
10223  {
10224  $$ = mm_strdup("row");
10225 }
10226 |  ROWS
10227  {
10228  $$ = mm_strdup("rows");
10229 }
10230 ;
10231 
10232 
10233  first_or_next:
10234  FIRST_P
10235  {
10236  $$ = mm_strdup("first");
10237 }
10238 |  NEXT
10239  {
10240  $$ = mm_strdup("next");
10241 }
10242 ;
10243 
10244 
10245  group_clause:
10246  GROUP_P BY group_by_list
10247  {
10248  $$ = cat_str(2,mm_strdup("group by"),$3);
10249 }
10250 |
10251  {
10252  $$=EMPTY; }
10253 ;
10254 
10255 
10256  group_by_list:
10257  group_by_item
10258  {
10259  $$ = $1;
10260 }
10261 |  group_by_list ',' group_by_item
10262  {
10263  $$ = cat_str(3,$1,mm_strdup(","),$3);
10264 }
10265 ;
10266 
10267 
10268  group_by_item:
10269  a_expr
10270  {
10271  $$ = $1;
10272 }
10273 |  empty_grouping_set
10274  {
10275  $$ = $1;
10276 }
10277 |  cube_clause
10278  {
10279  $$ = $1;
10280 }
10281 |  rollup_clause
10282  {
10283  $$ = $1;
10284 }
10285 |  grouping_sets_clause
10286  {
10287  $$ = $1;
10288 }
10289 ;
10290 
10291 
10292  empty_grouping_set:
10293  '(' ')'
10294  {
10295  $$ = mm_strdup("( )");
10296 }
10297 ;
10298 
10299 
10300  rollup_clause:
10301  ROLLUP '(' expr_list ')'
10302  {
10303  $$ = cat_str(3,mm_strdup("rollup ("),$3,mm_strdup(")"));
10304 }
10305 ;
10306 
10307 
10308  cube_clause:
10309  CUBE '(' expr_list ')'
10310  {
10311  $$ = cat_str(3,mm_strdup("cube ("),$3,mm_strdup(")"));
10312 }
10313 ;
10314 
10315 
10316  grouping_sets_clause:
10317  GROUPING SETS '(' group_by_list ')'
10318  {
10319  $$ = cat_str(3,mm_strdup("grouping sets ("),$4,mm_strdup(")"));
10320 }
10321 ;
10322 
10323 
10324  having_clause:
10325  HAVING a_expr
10326  {
10327  $$ = cat_str(2,mm_strdup("having"),$2);
10328 }
10329 |
10330  {
10331  $$=EMPTY; }
10332 ;
10333 
10334 
10335  for_locking_clause:
10336  for_locking_items
10337  {
10338  $$ = $1;
10339 }
10340 |  FOR READ ONLY
10341  {
10342  $$ = mm_strdup("for read only");
10343 }
10344 ;
10345 
10346 
10347  opt_for_locking_clause:
10348  for_locking_clause
10349  {
10350  $$ = $1;
10351 }
10352 |
10353  {
10354  $$=EMPTY; }
10355 ;
10356 
10357 
10358  for_locking_items:
10359  for_locking_item
10360  {
10361  $$ = $1;
10362 }
10363 |  for_locking_items for_locking_item
10364  {
10365  $$ = cat_str(2,$1,$2);
10366 }
10367 ;
10368 
10369 
10370  for_locking_item:
10371  for_locking_strength locked_rels_list opt_nowait_or_skip
10372  {
10373  $$ = cat_str(3,$1,$2,$3);
10374 }
10375 ;
10376 
10377 
10378  for_locking_strength:
10379  FOR UPDATE
10380  {
10381  $$ = mm_strdup("for update");
10382 }
10383 |  FOR NO KEY UPDATE
10384  {
10385  $$ = mm_strdup("for no key update");
10386 }
10387 |  FOR SHARE
10388  {
10389  $$ = mm_strdup("for share");
10390 }
10391 |  FOR KEY SHARE
10392  {
10393  $$ = mm_strdup("for key share");
10394 }
10395 ;
10396 
10397 
10398  locked_rels_list:
10399  OF qualified_name_list
10400  {
10401  $$ = cat_str(2,mm_strdup("of"),$2);
10402 }
10403 |
10404  {
10405  $$=EMPTY; }
10406 ;
10407 
10408 
10409  values_clause:
10410  VALUES '(' expr_list ')'
10411  {
10412  $$ = cat_str(3,mm_strdup("values ("),$3,mm_strdup(")"));
10413 }
10414 |  values_clause ',' '(' expr_list ')'
10415  {
10416  $$ = cat_str(4,$1,mm_strdup(", ("),$4,mm_strdup(")"));
10417 }
10418 ;
10419 
10420 
10421  from_clause:
10422  FROM from_list
10423  {
10424  $$ = cat_str(2,mm_strdup("from"),$2);
10425 }
10426 |
10427  {
10428  $$=EMPTY; }
10429 ;
10430 
10431 
10432  from_list:
10433  table_ref
10434  {
10435  $$ = $1;
10436 }
10437 |  from_list ',' table_ref
10438  {
10439  $$ = cat_str(3,$1,mm_strdup(","),$3);
10440 }
10441 ;
10442 
10443 
10444  table_ref:
10445  relation_expr opt_alias_clause
10446  {
10447  $$ = cat_str(2,$1,$2);
10448 }
10449 |  relation_expr opt_alias_clause tablesample_clause
10450  {
10451  $$ = cat_str(3,$1,$2,$3);
10452 }
10453 |  func_table func_alias_clause
10454  {
10455  $$ = cat_str(2,$1,$2);
10456 }
10457 |  LATERAL_P func_table func_alias_clause
10458  {
10459  $$ = cat_str(3,mm_strdup("lateral"),$2,$3);
10460 }
10461 |  xmltable opt_alias_clause
10462  {
10463  $$ = cat_str(2,$1,$2);
10464 }
10465 |  LATERAL_P xmltable opt_alias_clause
10466  {
10467  $$ = cat_str(3,mm_strdup("lateral"),$2,$3);
10468 }
10469 |  select_with_parens opt_alias_clause
10470  {
10471 	if ($2 == NULL)
10472 		mmerror(PARSE_ERROR, ET_ERROR, "subquery in FROM must have an alias");
10473 
10474  $$ = cat_str(2,$1,$2);
10475 }
10476 |  LATERAL_P select_with_parens opt_alias_clause
10477  {
10478 	if ($3 == NULL)
10479 		mmerror(PARSE_ERROR, ET_ERROR, "subquery in FROM must have an alias");
10480 
10481  $$ = cat_str(3,mm_strdup("lateral"),$2,$3);
10482 }
10483 |  joined_table
10484  {
10485  $$ = $1;
10486 }
10487 |  '(' joined_table ')' alias_clause
10488  {
10489  $$ = cat_str(4,mm_strdup("("),$2,mm_strdup(")"),$4);
10490 }
10491 ;
10492 
10493 
10494  joined_table:
10495  '(' joined_table ')'
10496  {
10497  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
10498 }
10499 |  table_ref CROSS JOIN table_ref
10500  {
10501  $$ = cat_str(3,$1,mm_strdup("cross join"),$4);
10502 }
10503 |  table_ref join_type JOIN table_ref join_qual
10504  {
10505  $$ = cat_str(5,$1,$2,mm_strdup("join"),$4,$5);
10506 }
10507 |  table_ref JOIN table_ref join_qual
10508  {
10509  $$ = cat_str(4,$1,mm_strdup("join"),$3,$4);
10510 }
10511 |  table_ref NATURAL join_type JOIN table_ref
10512  {
10513  $$ = cat_str(5,$1,mm_strdup("natural"),$3,mm_strdup("join"),$5);
10514 }
10515 |  table_ref NATURAL JOIN table_ref
10516  {
10517  $$ = cat_str(3,$1,mm_strdup("natural join"),$4);
10518 }
10519 ;
10520 
10521 
10522  alias_clause:
10523  AS ColId '(' name_list ')'
10524  {
10525  $$ = cat_str(5,mm_strdup("as"),$2,mm_strdup("("),$4,mm_strdup(")"));
10526 }
10527 |  AS ColId
10528  {
10529  $$ = cat_str(2,mm_strdup("as"),$2);
10530 }
10531 |  ColId '(' name_list ')'
10532  {
10533  $$ = cat_str(4,$1,mm_strdup("("),$3,mm_strdup(")"));
10534 }
10535 |  ColId
10536  {
10537  $$ = $1;
10538 }
10539 ;
10540 
10541 
10542  opt_alias_clause:
10543  alias_clause
10544  {
10545  $$ = $1;
10546 }
10547 |
10548  {
10549  $$=EMPTY; }
10550 ;
10551 
10552 
10553  func_alias_clause:
10554  alias_clause
10555  {
10556  $$ = $1;
10557 }
10558 |  AS '(' TableFuncElementList ')'
10559  {
10560  $$ = cat_str(3,mm_strdup("as ("),$3,mm_strdup(")"));
10561 }
10562 |  AS ColId '(' TableFuncElementList ')'
10563  {
10564  $$ = cat_str(5,mm_strdup("as"),$2,mm_strdup("("),$4,mm_strdup(")"));
10565 }
10566 |  ColId '(' TableFuncElementList ')'
10567  {
10568  $$ = cat_str(4,$1,mm_strdup("("),$3,mm_strdup(")"));
10569 }
10570 |
10571  {
10572  $$=EMPTY; }
10573 ;
10574 
10575 
10576  join_type:
10577  FULL join_outer
10578  {
10579  $$ = cat_str(2,mm_strdup("full"),$2);
10580 }
10581 |  LEFT join_outer
10582  {
10583  $$ = cat_str(2,mm_strdup("left"),$2);
10584 }
10585 |  RIGHT join_outer
10586  {
10587  $$ = cat_str(2,mm_strdup("right"),$2);
10588 }
10589 |  INNER_P
10590  {
10591  $$ = mm_strdup("inner");
10592 }
10593 ;
10594 
10595 
10596  join_outer:
10597  OUTER_P
10598  {
10599  $$ = mm_strdup("outer");
10600 }
10601 |
10602  {
10603  $$=EMPTY; }
10604 ;
10605 
10606 
10607  join_qual:
10608  USING '(' name_list ')'
10609  {
10610  $$ = cat_str(3,mm_strdup("using ("),$3,mm_strdup(")"));
10611 }
10612 |  ON a_expr
10613  {
10614  $$ = cat_str(2,mm_strdup("on"),$2);
10615 }
10616 ;
10617 
10618 
10619  relation_expr:
10620  qualified_name
10621  {
10622  $$ = $1;
10623 }
10624 |  qualified_name '*'
10625  {
10626  $$ = cat_str(2,$1,mm_strdup("*"));
10627 }
10628 |  ONLY qualified_name
10629  {
10630  $$ = cat_str(2,mm_strdup("only"),$2);
10631 }
10632 |  ONLY '(' qualified_name ')'
10633  {
10634  $$ = cat_str(3,mm_strdup("only ("),$3,mm_strdup(")"));
10635 }
10636 ;
10637 
10638 
10639  relation_expr_list:
10640  relation_expr
10641  {
10642  $$ = $1;
10643 }
10644 |  relation_expr_list ',' relation_expr
10645  {
10646  $$ = cat_str(3,$1,mm_strdup(","),$3);
10647 }
10648 ;
10649 
10650 
10651  relation_expr_opt_alias:
10652  relation_expr %prec UMINUS
10653  {
10654  $$ = $1;
10655 }
10656 |  relation_expr ColId
10657  {
10658  $$ = cat_str(2,$1,$2);
10659 }
10660 |  relation_expr AS ColId
10661  {
10662  $$ = cat_str(3,$1,mm_strdup("as"),$3);
10663 }
10664 ;
10665 
10666 
10667  tablesample_clause:
10668  TABLESAMPLE func_name '(' expr_list ')' opt_repeatable_clause
10669  {
10670  $$ = cat_str(6,mm_strdup("tablesample"),$2,mm_strdup("("),$4,mm_strdup(")"),$6);
10671 }
10672 ;
10673 
10674 
10675  opt_repeatable_clause:
10676  REPEATABLE '(' a_expr ')'
10677  {
10678  $$ = cat_str(3,mm_strdup("repeatable ("),$3,mm_strdup(")"));
10679 }
10680 |
10681  {
10682  $$=EMPTY; }
10683 ;
10684 
10685 
10686  func_table:
10687  func_expr_windowless opt_ordinality
10688  {
10689  $$ = cat_str(2,$1,$2);
10690 }
10691 |  ROWS FROM '(' rowsfrom_list ')' opt_ordinality
10692  {
10693  $$ = cat_str(4,mm_strdup("rows from ("),$4,mm_strdup(")"),$6);
10694 }
10695 ;
10696 
10697 
10698  rowsfrom_item:
10699  func_expr_windowless opt_col_def_list
10700  {
10701  $$ = cat_str(2,$1,$2);
10702 }
10703 ;
10704 
10705 
10706  rowsfrom_list:
10707  rowsfrom_item
10708  {
10709  $$ = $1;
10710 }
10711 |  rowsfrom_list ',' rowsfrom_item
10712  {
10713  $$ = cat_str(3,$1,mm_strdup(","),$3);
10714 }
10715 ;
10716 
10717 
10718  opt_col_def_list:
10719  AS '(' TableFuncElementList ')'
10720  {
10721  $$ = cat_str(3,mm_strdup("as ("),$3,mm_strdup(")"));
10722 }
10723 |
10724  {
10725  $$=EMPTY; }
10726 ;
10727 
10728 
10729  opt_ordinality:
10730  WITH_LA ORDINALITY
10731  {
10732  $$ = mm_strdup("with ordinality");
10733 }
10734 |
10735  {
10736  $$=EMPTY; }
10737 ;
10738 
10739 
10740  where_clause:
10741  WHERE a_expr
10742  {
10743  $$ = cat_str(2,mm_strdup("where"),$2);
10744 }
10745 |
10746  {
10747  $$=EMPTY; }
10748 ;
10749 
10750 
10751  where_or_current_clause:
10752  WHERE a_expr
10753  {
10754  $$ = cat_str(2,mm_strdup("where"),$2);
10755 }
10756 |  WHERE CURRENT_P OF cursor_name
10757 	{
10758 		char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
10759 		$$ = cat_str(2,mm_strdup("where current of"), cursor_marker);
10760 	}
10761 |
10762  {
10763  $$=EMPTY; }
10764 ;
10765 
10766 
10767  OptTableFuncElementList:
10768  TableFuncElementList
10769  {
10770  $$ = $1;
10771 }
10772 |
10773  {
10774  $$=EMPTY; }
10775 ;
10776 
10777 
10778  TableFuncElementList:
10779  TableFuncElement
10780  {
10781  $$ = $1;
10782 }
10783 |  TableFuncElementList ',' TableFuncElement
10784  {
10785  $$ = cat_str(3,$1,mm_strdup(","),$3);
10786 }
10787 ;
10788 
10789 
10790  TableFuncElement:
10791  ColId Typename opt_collate_clause
10792  {
10793  $$ = cat_str(3,$1,$2,$3);
10794 }
10795 ;
10796 
10797 
10798  xmltable:
10799  XMLTABLE '(' c_expr xmlexists_argument COLUMNS xmltable_column_list ')'
10800  {
10801  $$ = cat_str(6,mm_strdup("xmltable ("),$3,$4,mm_strdup("columns"),$6,mm_strdup(")"));
10802 }
10803 |  XMLTABLE '(' XMLNAMESPACES '(' xml_namespace_list ')' ',' c_expr xmlexists_argument COLUMNS xmltable_column_list ')'
10804  {
10805  $$ = cat_str(8,mm_strdup("xmltable ( xmlnamespaces ("),$5,mm_strdup(") ,"),$8,$9,mm_strdup("columns"),$11,mm_strdup(")"));
10806 }
10807 ;
10808 
10809 
10810  xmltable_column_list:
10811  xmltable_column_el
10812  {
10813  $$ = $1;
10814 }
10815 |  xmltable_column_list ',' xmltable_column_el
10816  {
10817  $$ = cat_str(3,$1,mm_strdup(","),$3);
10818 }
10819 ;
10820 
10821 
10822  xmltable_column_el:
10823  ColId Typename
10824  {
10825  $$ = cat_str(2,$1,$2);
10826 }
10827 |  ColId Typename xmltable_column_option_list
10828  {
10829  $$ = cat_str(3,$1,$2,$3);
10830 }
10831 |  ColId FOR ORDINALITY
10832  {
10833  $$ = cat_str(2,$1,mm_strdup("for ordinality"));
10834 }
10835 ;
10836 
10837 
10838  xmltable_column_option_list:
10839  xmltable_column_option_el
10840  {
10841  $$ = $1;
10842 }
10843 |  xmltable_column_option_list xmltable_column_option_el
10844  {
10845  $$ = cat_str(2,$1,$2);
10846 }
10847 ;
10848 
10849 
10850  xmltable_column_option_el:
10851  ecpg_ident b_expr
10852  {
10853  $$ = cat_str(2,$1,$2);
10854 }
10855 |  DEFAULT b_expr
10856  {
10857  $$ = cat_str(2,mm_strdup("default"),$2);
10858 }
10859 |  NOT NULL_P
10860  {
10861  $$ = mm_strdup("not null");
10862 }
10863 |  NULL_P
10864  {
10865  $$ = mm_strdup("null");
10866 }
10867 ;
10868 
10869 
10870  xml_namespace_list:
10871  xml_namespace_el
10872  {
10873  $$ = $1;
10874 }
10875 |  xml_namespace_list ',' xml_namespace_el
10876  {
10877  $$ = cat_str(3,$1,mm_strdup(","),$3);
10878 }
10879 ;
10880 
10881 
10882  xml_namespace_el:
10883  b_expr AS ColLabel
10884  {
10885  $$ = cat_str(3,$1,mm_strdup("as"),$3);
10886 }
10887 |  DEFAULT b_expr
10888  {
10889  $$ = cat_str(2,mm_strdup("default"),$2);
10890 }
10891 ;
10892 
10893 
10894  Typename:
10895  SimpleTypename opt_array_bounds
10896 	{	$$ = cat2_str($1, $2.str); }
10897 |  SETOF SimpleTypename opt_array_bounds
10898 	{	$$ = cat_str(3, mm_strdup("setof"), $2, $3.str); }
10899 |  SimpleTypename ARRAY '[' Iconst ']'
10900  {
10901  $$ = cat_str(4,$1,mm_strdup("array ["),$4,mm_strdup("]"));
10902 }
10903 |  SETOF SimpleTypename ARRAY '[' Iconst ']'
10904  {
10905  $$ = cat_str(5,mm_strdup("setof"),$2,mm_strdup("array ["),$5,mm_strdup("]"));
10906 }
10907 |  SimpleTypename ARRAY
10908  {
10909  $$ = cat_str(2,$1,mm_strdup("array"));
10910 }
10911 |  SETOF SimpleTypename ARRAY
10912  {
10913  $$ = cat_str(3,mm_strdup("setof"),$2,mm_strdup("array"));
10914 }
10915 ;
10916 
10917 
10918  opt_array_bounds:
10919  opt_array_bounds '[' ']'
10920 	{
10921 		$$.index1 = $1.index1;
10922 		$$.index2 = $1.index2;
10923 		if (strcmp($$.index1, "-1") == 0)
10924 			$$.index1 = mm_strdup("0");
10925 		else if (strcmp($1.index2, "-1") == 0)
10926 			$$.index2 = mm_strdup("0");
10927 		$$.str = cat_str(2, $1.str, mm_strdup("[]"));
10928 	}
10929 	| opt_array_bounds '[' Iresult ']'
10930 	{
10931 		$$.index1 = $1.index1;
10932 		$$.index2 = $1.index2;
10933 		if (strcmp($1.index1, "-1") == 0)
10934 			$$.index1 = mm_strdup($3);
10935 		else if (strcmp($1.index2, "-1") == 0)
10936 			$$.index2 = mm_strdup($3);
10937 		$$.str = cat_str(4, $1.str, mm_strdup("["), $3, mm_strdup("]"));
10938 	}
10939 |
10940 	{
10941 		$$.index1 = mm_strdup("-1");
10942 		$$.index2 = mm_strdup("-1");
10943 		$$.str= EMPTY;
10944 	}
10945 ;
10946 
10947 
10948  SimpleTypename:
10949  GenericType
10950  {
10951  $$ = $1;
10952 }
10953 |  Numeric
10954  {
10955  $$ = $1;
10956 }
10957 |  Bit
10958  {
10959  $$ = $1;
10960 }
10961 |  Character
10962  {
10963  $$ = $1;
10964 }
10965 |  ConstDatetime
10966  {
10967  $$ = $1;
10968 }
10969 |  ConstInterval opt_interval
10970  {
10971  $$ = cat_str(2,$1,$2);
10972 }
10973 |  ConstInterval '(' Iconst ')'
10974  {
10975  $$ = cat_str(4,$1,mm_strdup("("),$3,mm_strdup(")"));
10976 }
10977 ;
10978 
10979 
10980  ConstTypename:
10981  Numeric
10982  {
10983  $$ = $1;
10984 }
10985 |  ConstBit
10986  {
10987  $$ = $1;
10988 }
10989 |  ConstCharacter
10990  {
10991  $$ = $1;
10992 }
10993 |  ConstDatetime
10994  {
10995  $$ = $1;
10996 }
10997 ;
10998 
10999 
11000  GenericType:
11001  type_function_name opt_type_modifiers
11002  {
11003  $$ = cat_str(2,$1,$2);
11004 }
11005 |  type_function_name attrs opt_type_modifiers
11006  {
11007  $$ = cat_str(3,$1,$2,$3);
11008 }
11009 ;
11010 
11011 
11012  opt_type_modifiers:
11013  '(' expr_list ')'
11014  {
11015  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
11016 }
11017 |
11018  {
11019  $$=EMPTY; }
11020 ;
11021 
11022 
11023  Numeric:
11024  INT_P
11025  {
11026  $$ = mm_strdup("int");
11027 }
11028 |  INTEGER
11029  {
11030  $$ = mm_strdup("integer");
11031 }
11032 |  SMALLINT
11033  {
11034  $$ = mm_strdup("smallint");
11035 }
11036 |  BIGINT
11037  {
11038  $$ = mm_strdup("bigint");
11039 }
11040 |  REAL
11041  {
11042  $$ = mm_strdup("real");
11043 }
11044 |  FLOAT_P opt_float
11045  {
11046  $$ = cat_str(2,mm_strdup("float"),$2);
11047 }
11048 |  DOUBLE_P PRECISION
11049  {
11050  $$ = mm_strdup("double precision");
11051 }
11052 |  DECIMAL_P opt_type_modifiers
11053  {
11054  $$ = cat_str(2,mm_strdup("decimal"),$2);
11055 }
11056 |  DEC opt_type_modifiers
11057  {
11058  $$ = cat_str(2,mm_strdup("dec"),$2);
11059 }
11060 |  NUMERIC opt_type_modifiers
11061  {
11062  $$ = cat_str(2,mm_strdup("numeric"),$2);
11063 }
11064 |  BOOLEAN_P
11065  {
11066  $$ = mm_strdup("boolean");
11067 }
11068 ;
11069 
11070 
11071  opt_float:
11072  '(' Iconst ')'
11073  {
11074  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
11075 }
11076 |
11077  {
11078  $$=EMPTY; }
11079 ;
11080 
11081 
11082  Bit:
11083  BitWithLength
11084  {
11085  $$ = $1;
11086 }
11087 |  BitWithoutLength
11088  {
11089  $$ = $1;
11090 }
11091 ;
11092 
11093 
11094  ConstBit:
11095  BitWithLength
11096  {
11097  $$ = $1;
11098 }
11099 |  BitWithoutLength
11100  {
11101  $$ = $1;
11102 }
11103 ;
11104 
11105 
11106  BitWithLength:
11107  BIT opt_varying '(' expr_list ')'
11108  {
11109  $$ = cat_str(5,mm_strdup("bit"),$2,mm_strdup("("),$4,mm_strdup(")"));
11110 }
11111 ;
11112 
11113 
11114  BitWithoutLength:
11115  BIT opt_varying
11116  {
11117  $$ = cat_str(2,mm_strdup("bit"),$2);
11118 }
11119 ;
11120 
11121 
11122  Character:
11123  CharacterWithLength
11124  {
11125  $$ = $1;
11126 }
11127 |  CharacterWithoutLength
11128  {
11129  $$ = $1;
11130 }
11131 ;
11132 
11133 
11134  ConstCharacter:
11135  CharacterWithLength
11136  {
11137  $$ = $1;
11138 }
11139 |  CharacterWithoutLength
11140  {
11141  $$ = $1;
11142 }
11143 ;
11144 
11145 
11146  CharacterWithLength:
11147  character '(' Iconst ')'
11148  {
11149  $$ = cat_str(4,$1,mm_strdup("("),$3,mm_strdup(")"));
11150 }
11151 ;
11152 
11153 
11154  CharacterWithoutLength:
11155  character
11156  {
11157  $$ = $1;
11158 }
11159 ;
11160 
11161 
11162  character:
11163  CHARACTER opt_varying
11164  {
11165  $$ = cat_str(2,mm_strdup("character"),$2);
11166 }
11167 |  CHAR_P opt_varying
11168  {
11169  $$ = cat_str(2,mm_strdup("char"),$2);
11170 }
11171 |  VARCHAR
11172  {
11173  $$ = mm_strdup("varchar");
11174 }
11175 |  NATIONAL CHARACTER opt_varying
11176  {
11177  $$ = cat_str(2,mm_strdup("national character"),$3);
11178 }
11179 |  NATIONAL CHAR_P opt_varying
11180  {
11181  $$ = cat_str(2,mm_strdup("national char"),$3);
11182 }
11183 |  NCHAR opt_varying
11184  {
11185  $$ = cat_str(2,mm_strdup("nchar"),$2);
11186 }
11187 ;
11188 
11189 
11190  opt_varying:
11191  VARYING
11192  {
11193  $$ = mm_strdup("varying");
11194 }
11195 |
11196  {
11197  $$=EMPTY; }
11198 ;
11199 
11200 
11201  ConstDatetime:
11202  TIMESTAMP '(' Iconst ')' opt_timezone
11203  {
11204  $$ = cat_str(4,mm_strdup("timestamp ("),$3,mm_strdup(")"),$5);
11205 }
11206 |  TIMESTAMP opt_timezone
11207  {
11208  $$ = cat_str(2,mm_strdup("timestamp"),$2);
11209 }
11210 |  TIME '(' Iconst ')' opt_timezone
11211  {
11212  $$ = cat_str(4,mm_strdup("time ("),$3,mm_strdup(")"),$5);
11213 }
11214 |  TIME opt_timezone
11215  {
11216  $$ = cat_str(2,mm_strdup("time"),$2);
11217 }
11218 ;
11219 
11220 
11221  ConstInterval:
11222  INTERVAL
11223  {
11224  $$ = mm_strdup("interval");
11225 }
11226 ;
11227 
11228 
11229  opt_timezone:
11230  WITH_LA TIME ZONE
11231  {
11232  $$ = mm_strdup("with time zone");
11233 }
11234 |  WITHOUT TIME ZONE
11235  {
11236  $$ = mm_strdup("without time zone");
11237 }
11238 |
11239  {
11240  $$=EMPTY; }
11241 ;
11242 
11243 
11244  opt_interval:
11245  YEAR_P
11246  {
11247  $$ = mm_strdup("year");
11248 }
11249 |  MONTH_P
11250  {
11251  $$ = mm_strdup("month");
11252 }
11253 |  DAY_P
11254  {
11255  $$ = mm_strdup("day");
11256 }
11257 |  HOUR_P
11258  {
11259  $$ = mm_strdup("hour");
11260 }
11261 |  MINUTE_P
11262  {
11263  $$ = mm_strdup("minute");
11264 }
11265 |  interval_second
11266  {
11267  $$ = $1;
11268 }
11269 |  YEAR_P TO MONTH_P
11270  {
11271  $$ = mm_strdup("year to month");
11272 }
11273 |  DAY_P TO HOUR_P
11274  {
11275  $$ = mm_strdup("day to hour");
11276 }
11277 |  DAY_P TO MINUTE_P
11278  {
11279  $$ = mm_strdup("day to minute");
11280 }
11281 |  DAY_P TO interval_second
11282  {
11283  $$ = cat_str(2,mm_strdup("day to"),$3);
11284 }
11285 |  HOUR_P TO MINUTE_P
11286  {
11287  $$ = mm_strdup("hour to minute");
11288 }
11289 |  HOUR_P TO interval_second
11290  {
11291  $$ = cat_str(2,mm_strdup("hour to"),$3);
11292 }
11293 |  MINUTE_P TO interval_second
11294  {
11295  $$ = cat_str(2,mm_strdup("minute to"),$3);
11296 }
11297 |
11298  {
11299  $$=EMPTY; }
11300 ;
11301 
11302 
11303  interval_second:
11304  SECOND_P
11305  {
11306  $$ = mm_strdup("second");
11307 }
11308 |  SECOND_P '(' Iconst ')'
11309  {
11310  $$ = cat_str(3,mm_strdup("second ("),$3,mm_strdup(")"));
11311 }
11312 ;
11313 
11314 
11315  a_expr:
11316  c_expr
11317  {
11318  $$ = $1;
11319 }
11320 |  a_expr TYPECAST Typename
11321  {
11322  $$ = cat_str(3,$1,mm_strdup("::"),$3);
11323 }
11324 |  a_expr COLLATE any_name
11325  {
11326  $$ = cat_str(3,$1,mm_strdup("collate"),$3);
11327 }
11328 |  a_expr AT TIME ZONE a_expr %prec AT
11329  {
11330  $$ = cat_str(3,$1,mm_strdup("at time zone"),$5);
11331 }
11332 |  '+' a_expr %prec UMINUS
11333  {
11334  $$ = cat_str(2,mm_strdup("+"),$2);
11335 }
11336 |  '-' a_expr %prec UMINUS
11337  {
11338  $$ = cat_str(2,mm_strdup("-"),$2);
11339 }
11340 |  a_expr '+' a_expr
11341  {
11342  $$ = cat_str(3,$1,mm_strdup("+"),$3);
11343 }
11344 |  a_expr '-' a_expr
11345  {
11346  $$ = cat_str(3,$1,mm_strdup("-"),$3);
11347 }
11348 |  a_expr '*' a_expr
11349  {
11350  $$ = cat_str(3,$1,mm_strdup("*"),$3);
11351 }
11352 |  a_expr '/' a_expr
11353  {
11354  $$ = cat_str(3,$1,mm_strdup("/"),$3);
11355 }
11356 |  a_expr '%' a_expr
11357  {
11358  $$ = cat_str(3,$1,mm_strdup("%"),$3);
11359 }
11360 |  a_expr '^' a_expr
11361  {
11362  $$ = cat_str(3,$1,mm_strdup("^"),$3);
11363 }
11364 |  a_expr '<' a_expr
11365  {
11366  $$ = cat_str(3,$1,mm_strdup("<"),$3);
11367 }
11368 |  a_expr '>' a_expr
11369  {
11370  $$ = cat_str(3,$1,mm_strdup(">"),$3);
11371 }
11372 |  a_expr '=' a_expr
11373  {
11374  $$ = cat_str(3,$1,mm_strdup("="),$3);
11375 }
11376 |  a_expr LESS_EQUALS a_expr
11377  {
11378  $$ = cat_str(3,$1,mm_strdup("<="),$3);
11379 }
11380 |  a_expr GREATER_EQUALS a_expr
11381  {
11382  $$ = cat_str(3,$1,mm_strdup(">="),$3);
11383 }
11384 |  a_expr NOT_EQUALS a_expr
11385  {
11386  $$ = cat_str(3,$1,mm_strdup("<>"),$3);
11387 }
11388 |  a_expr qual_Op a_expr %prec Op
11389  {
11390  $$ = cat_str(3,$1,$2,$3);
11391 }
11392 |  qual_Op a_expr %prec Op
11393  {
11394  $$ = cat_str(2,$1,$2);
11395 }
11396 |  a_expr qual_Op %prec POSTFIXOP
11397  {
11398  $$ = cat_str(2,$1,$2);
11399 }
11400 |  a_expr AND a_expr
11401  {
11402  $$ = cat_str(3,$1,mm_strdup("and"),$3);
11403 }
11404 |  a_expr OR a_expr
11405  {
11406  $$ = cat_str(3,$1,mm_strdup("or"),$3);
11407 }
11408 |  NOT a_expr
11409  {
11410  $$ = cat_str(2,mm_strdup("not"),$2);
11411 }
11412 |  NOT_LA a_expr %prec NOT
11413  {
11414  $$ = cat_str(2,mm_strdup("not"),$2);
11415 }
11416 |  a_expr LIKE a_expr
11417  {
11418  $$ = cat_str(3,$1,mm_strdup("like"),$3);
11419 }
11420 |  a_expr LIKE a_expr ESCAPE a_expr %prec LIKE
11421  {
11422  $$ = cat_str(5,$1,mm_strdup("like"),$3,mm_strdup("escape"),$5);
11423 }
11424 |  a_expr NOT_LA LIKE a_expr %prec NOT_LA
11425  {
11426  $$ = cat_str(3,$1,mm_strdup("not like"),$4);
11427 }
11428 |  a_expr NOT_LA LIKE a_expr ESCAPE a_expr %prec NOT_LA
11429  {
11430  $$ = cat_str(5,$1,mm_strdup("not like"),$4,mm_strdup("escape"),$6);
11431 }
11432 |  a_expr ILIKE a_expr
11433  {
11434  $$ = cat_str(3,$1,mm_strdup("ilike"),$3);
11435 }
11436 |  a_expr ILIKE a_expr ESCAPE a_expr %prec ILIKE
11437  {
11438  $$ = cat_str(5,$1,mm_strdup("ilike"),$3,mm_strdup("escape"),$5);
11439 }
11440 |  a_expr NOT_LA ILIKE a_expr %prec NOT_LA
11441  {
11442  $$ = cat_str(3,$1,mm_strdup("not ilike"),$4);
11443 }
11444 |  a_expr NOT_LA ILIKE a_expr ESCAPE a_expr %prec NOT_LA
11445  {
11446  $$ = cat_str(5,$1,mm_strdup("not ilike"),$4,mm_strdup("escape"),$6);
11447 }
11448 |  a_expr SIMILAR TO a_expr %prec SIMILAR
11449  {
11450  $$ = cat_str(3,$1,mm_strdup("similar to"),$4);
11451 }
11452 |  a_expr SIMILAR TO a_expr ESCAPE a_expr %prec SIMILAR
11453  {
11454  $$ = cat_str(5,$1,mm_strdup("similar to"),$4,mm_strdup("escape"),$6);
11455 }
11456 |  a_expr NOT_LA SIMILAR TO a_expr %prec NOT_LA
11457  {
11458  $$ = cat_str(3,$1,mm_strdup("not similar to"),$5);
11459 }
11460 |  a_expr NOT_LA SIMILAR TO a_expr ESCAPE a_expr %prec NOT_LA
11461  {
11462  $$ = cat_str(5,$1,mm_strdup("not similar to"),$5,mm_strdup("escape"),$7);
11463 }
11464 |  a_expr IS NULL_P %prec IS
11465  {
11466  $$ = cat_str(2,$1,mm_strdup("is null"));
11467 }
11468 |  a_expr ISNULL
11469  {
11470  $$ = cat_str(2,$1,mm_strdup("isnull"));
11471 }
11472 |  a_expr IS NOT NULL_P %prec IS
11473  {
11474  $$ = cat_str(2,$1,mm_strdup("is not null"));
11475 }
11476 |  a_expr NOTNULL
11477  {
11478  $$ = cat_str(2,$1,mm_strdup("notnull"));
11479 }
11480 |  row OVERLAPS row
11481  {
11482  $$ = cat_str(3,$1,mm_strdup("overlaps"),$3);
11483 }
11484 |  a_expr IS TRUE_P %prec IS
11485  {
11486  $$ = cat_str(2,$1,mm_strdup("is true"));
11487 }
11488 |  a_expr IS NOT TRUE_P %prec IS
11489  {
11490  $$ = cat_str(2,$1,mm_strdup("is not true"));
11491 }
11492 |  a_expr IS FALSE_P %prec IS
11493  {
11494  $$ = cat_str(2,$1,mm_strdup("is false"));
11495 }
11496 |  a_expr IS NOT FALSE_P %prec IS
11497  {
11498  $$ = cat_str(2,$1,mm_strdup("is not false"));
11499 }
11500 |  a_expr IS UNKNOWN %prec IS
11501  {
11502  $$ = cat_str(2,$1,mm_strdup("is unknown"));
11503 }
11504 |  a_expr IS NOT UNKNOWN %prec IS
11505  {
11506  $$ = cat_str(2,$1,mm_strdup("is not unknown"));
11507 }
11508 |  a_expr IS DISTINCT FROM a_expr %prec IS
11509  {
11510  $$ = cat_str(3,$1,mm_strdup("is distinct from"),$5);
11511 }
11512 |  a_expr IS NOT DISTINCT FROM a_expr %prec IS
11513  {
11514  $$ = cat_str(3,$1,mm_strdup("is not distinct from"),$6);
11515 }
11516 |  a_expr IS OF '(' type_list ')' %prec IS
11517  {
11518  $$ = cat_str(4,$1,mm_strdup("is of ("),$5,mm_strdup(")"));
11519 }
11520 |  a_expr IS NOT OF '(' type_list ')' %prec IS
11521  {
11522  $$ = cat_str(4,$1,mm_strdup("is not of ("),$6,mm_strdup(")"));
11523 }
11524 |  a_expr BETWEEN opt_asymmetric b_expr AND a_expr %prec BETWEEN
11525  {
11526  $$ = cat_str(6,$1,mm_strdup("between"),$3,$4,mm_strdup("and"),$6);
11527 }
11528 |  a_expr NOT_LA BETWEEN opt_asymmetric b_expr AND a_expr %prec NOT_LA
11529  {
11530  $$ = cat_str(6,$1,mm_strdup("not between"),$4,$5,mm_strdup("and"),$7);
11531 }
11532 |  a_expr BETWEEN SYMMETRIC b_expr AND a_expr %prec BETWEEN
11533  {
11534  $$ = cat_str(5,$1,mm_strdup("between symmetric"),$4,mm_strdup("and"),$6);
11535 }
11536 |  a_expr NOT_LA BETWEEN SYMMETRIC b_expr AND a_expr %prec NOT_LA
11537  {
11538  $$ = cat_str(5,$1,mm_strdup("not between symmetric"),$5,mm_strdup("and"),$7);
11539 }
11540 |  a_expr IN_P in_expr
11541  {
11542  $$ = cat_str(3,$1,mm_strdup("in"),$3);
11543 }
11544 |  a_expr NOT_LA IN_P in_expr %prec NOT_LA
11545  {
11546  $$ = cat_str(3,$1,mm_strdup("not in"),$4);
11547 }
11548 |  a_expr subquery_Op sub_type select_with_parens %prec Op
11549  {
11550  $$ = cat_str(4,$1,$2,$3,$4);
11551 }
11552 |  a_expr subquery_Op sub_type '(' a_expr ')' %prec Op
11553  {
11554  $$ = cat_str(6,$1,$2,$3,mm_strdup("("),$5,mm_strdup(")"));
11555 }
11556 |  UNIQUE select_with_parens
11557  {
11558 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
11559  $$ = cat_str(2,mm_strdup("unique"),$2);
11560 }
11561 |  a_expr IS DOCUMENT_P %prec IS
11562  {
11563  $$ = cat_str(2,$1,mm_strdup("is document"));
11564 }
11565 |  a_expr IS NOT DOCUMENT_P %prec IS
11566  {
11567  $$ = cat_str(2,$1,mm_strdup("is not document"));
11568 }
11569 |  DEFAULT
11570  {
11571  $$ = mm_strdup("default");
11572 }
11573 ;
11574 
11575 
11576  b_expr:
11577  c_expr
11578  {
11579  $$ = $1;
11580 }
11581 |  b_expr TYPECAST Typename
11582  {
11583  $$ = cat_str(3,$1,mm_strdup("::"),$3);
11584 }
11585 |  '+' b_expr %prec UMINUS
11586  {
11587  $$ = cat_str(2,mm_strdup("+"),$2);
11588 }
11589 |  '-' b_expr %prec UMINUS
11590  {
11591  $$ = cat_str(2,mm_strdup("-"),$2);
11592 }
11593 |  b_expr '+' b_expr
11594  {
11595  $$ = cat_str(3,$1,mm_strdup("+"),$3);
11596 }
11597 |  b_expr '-' b_expr
11598  {
11599  $$ = cat_str(3,$1,mm_strdup("-"),$3);
11600 }
11601 |  b_expr '*' b_expr
11602  {
11603  $$ = cat_str(3,$1,mm_strdup("*"),$3);
11604 }
11605 |  b_expr '/' b_expr
11606  {
11607  $$ = cat_str(3,$1,mm_strdup("/"),$3);
11608 }
11609 |  b_expr '%' b_expr
11610  {
11611  $$ = cat_str(3,$1,mm_strdup("%"),$3);
11612 }
11613 |  b_expr '^' b_expr
11614  {
11615  $$ = cat_str(3,$1,mm_strdup("^"),$3);
11616 }
11617 |  b_expr '<' b_expr
11618  {
11619  $$ = cat_str(3,$1,mm_strdup("<"),$3);
11620 }
11621 |  b_expr '>' b_expr
11622  {
11623  $$ = cat_str(3,$1,mm_strdup(">"),$3);
11624 }
11625 |  b_expr '=' b_expr
11626  {
11627  $$ = cat_str(3,$1,mm_strdup("="),$3);
11628 }
11629 |  b_expr LESS_EQUALS b_expr
11630  {
11631  $$ = cat_str(3,$1,mm_strdup("<="),$3);
11632 }
11633 |  b_expr GREATER_EQUALS b_expr
11634  {
11635  $$ = cat_str(3,$1,mm_strdup(">="),$3);
11636 }
11637 |  b_expr NOT_EQUALS b_expr
11638  {
11639  $$ = cat_str(3,$1,mm_strdup("<>"),$3);
11640 }
11641 |  b_expr qual_Op b_expr %prec Op
11642  {
11643  $$ = cat_str(3,$1,$2,$3);
11644 }
11645 |  qual_Op b_expr %prec Op
11646  {
11647  $$ = cat_str(2,$1,$2);
11648 }
11649 |  b_expr qual_Op %prec POSTFIXOP
11650  {
11651  $$ = cat_str(2,$1,$2);
11652 }
11653 |  b_expr IS DISTINCT FROM b_expr %prec IS
11654  {
11655  $$ = cat_str(3,$1,mm_strdup("is distinct from"),$5);
11656 }
11657 |  b_expr IS NOT DISTINCT FROM b_expr %prec IS
11658  {
11659  $$ = cat_str(3,$1,mm_strdup("is not distinct from"),$6);
11660 }
11661 |  b_expr IS OF '(' type_list ')' %prec IS
11662  {
11663  $$ = cat_str(4,$1,mm_strdup("is of ("),$5,mm_strdup(")"));
11664 }
11665 |  b_expr IS NOT OF '(' type_list ')' %prec IS
11666  {
11667  $$ = cat_str(4,$1,mm_strdup("is not of ("),$6,mm_strdup(")"));
11668 }
11669 |  b_expr IS DOCUMENT_P %prec IS
11670  {
11671  $$ = cat_str(2,$1,mm_strdup("is document"));
11672 }
11673 |  b_expr IS NOT DOCUMENT_P %prec IS
11674  {
11675  $$ = cat_str(2,$1,mm_strdup("is not document"));
11676 }
11677 ;
11678 
11679 
11680  c_expr:
11681  columnref
11682  {
11683  $$ = $1;
11684 }
11685 |  AexprConst
11686  {
11687  $$ = $1;
11688 }
11689 |  ecpg_param opt_indirection
11690  {
11691  $$ = cat_str(2,$1,$2);
11692 }
11693 |  '(' a_expr ')' opt_indirection
11694  {
11695  $$ = cat_str(4,mm_strdup("("),$2,mm_strdup(")"),$4);
11696 }
11697 |  case_expr
11698  {
11699  $$ = $1;
11700 }
11701 |  func_expr
11702  {
11703  $$ = $1;
11704 }
11705 |  select_with_parens %prec UMINUS
11706  {
11707  $$ = $1;
11708 }
11709 |  select_with_parens indirection
11710  {
11711  $$ = cat_str(2,$1,$2);
11712 }
11713 |  EXISTS select_with_parens
11714  {
11715  $$ = cat_str(2,mm_strdup("exists"),$2);
11716 }
11717 |  ARRAY select_with_parens
11718  {
11719  $$ = cat_str(2,mm_strdup("array"),$2);
11720 }
11721 |  ARRAY array_expr
11722  {
11723  $$ = cat_str(2,mm_strdup("array"),$2);
11724 }
11725 |  explicit_row
11726  {
11727  $$ = $1;
11728 }
11729 |  implicit_row
11730  {
11731  $$ = $1;
11732 }
11733 |  GROUPING '(' expr_list ')'
11734  {
11735  $$ = cat_str(3,mm_strdup("grouping ("),$3,mm_strdup(")"));
11736 }
11737 ;
11738 
11739 
11740  func_application:
11741  func_name '(' ')'
11742  {
11743  $$ = cat_str(2,$1,mm_strdup("( )"));
11744 }
11745 |  func_name '(' func_arg_list opt_sort_clause ')'
11746  {
11747  $$ = cat_str(5,$1,mm_strdup("("),$3,$4,mm_strdup(")"));
11748 }
11749 |  func_name '(' VARIADIC func_arg_expr opt_sort_clause ')'
11750  {
11751  $$ = cat_str(5,$1,mm_strdup("( variadic"),$4,$5,mm_strdup(")"));
11752 }
11753 |  func_name '(' func_arg_list ',' VARIADIC func_arg_expr opt_sort_clause ')'
11754  {
11755  $$ = cat_str(7,$1,mm_strdup("("),$3,mm_strdup(", variadic"),$6,$7,mm_strdup(")"));
11756 }
11757 |  func_name '(' ALL func_arg_list opt_sort_clause ')'
11758  {
11759  $$ = cat_str(5,$1,mm_strdup("( all"),$4,$5,mm_strdup(")"));
11760 }
11761 |  func_name '(' DISTINCT func_arg_list opt_sort_clause ')'
11762  {
11763  $$ = cat_str(5,$1,mm_strdup("( distinct"),$4,$5,mm_strdup(")"));
11764 }
11765 |  func_name '(' '*' ')'
11766  {
11767  $$ = cat_str(2,$1,mm_strdup("( * )"));
11768 }
11769 ;
11770 
11771 
11772  func_expr:
11773  func_application within_group_clause filter_clause over_clause
11774  {
11775  $$ = cat_str(4,$1,$2,$3,$4);
11776 }
11777 |  func_expr_common_subexpr
11778  {
11779  $$ = $1;
11780 }
11781 ;
11782 
11783 
11784  func_expr_windowless:
11785  func_application
11786  {
11787  $$ = $1;
11788 }
11789 |  func_expr_common_subexpr
11790  {
11791  $$ = $1;
11792 }
11793 ;
11794 
11795 
11796  func_expr_common_subexpr:
11797  COLLATION FOR '(' a_expr ')'
11798  {
11799  $$ = cat_str(3,mm_strdup("collation for ("),$4,mm_strdup(")"));
11800 }
11801 |  CURRENT_DATE
11802  {
11803  $$ = mm_strdup("current_date");
11804 }
11805 |  CURRENT_TIME
11806  {
11807  $$ = mm_strdup("current_time");
11808 }
11809 |  CURRENT_TIME '(' Iconst ')'
11810  {
11811  $$ = cat_str(3,mm_strdup("current_time ("),$3,mm_strdup(")"));
11812 }
11813 |  CURRENT_TIMESTAMP
11814  {
11815  $$ = mm_strdup("current_timestamp");
11816 }
11817 |  CURRENT_TIMESTAMP '(' Iconst ')'
11818  {
11819  $$ = cat_str(3,mm_strdup("current_timestamp ("),$3,mm_strdup(")"));
11820 }
11821 |  LOCALTIME
11822  {
11823  $$ = mm_strdup("localtime");
11824 }
11825 |  LOCALTIME '(' Iconst ')'
11826  {
11827  $$ = cat_str(3,mm_strdup("localtime ("),$3,mm_strdup(")"));
11828 }
11829 |  LOCALTIMESTAMP
11830  {
11831  $$ = mm_strdup("localtimestamp");
11832 }
11833 |  LOCALTIMESTAMP '(' Iconst ')'
11834  {
11835  $$ = cat_str(3,mm_strdup("localtimestamp ("),$3,mm_strdup(")"));
11836 }
11837 |  CURRENT_ROLE
11838  {
11839  $$ = mm_strdup("current_role");
11840 }
11841 |  CURRENT_USER
11842  {
11843  $$ = mm_strdup("current_user");
11844 }
11845 |  SESSION_USER
11846  {
11847  $$ = mm_strdup("session_user");
11848 }
11849 |  USER
11850  {
11851  $$ = mm_strdup("user");
11852 }
11853 |  CURRENT_CATALOG
11854  {
11855  $$ = mm_strdup("current_catalog");
11856 }
11857 |  CURRENT_SCHEMA
11858  {
11859  $$ = mm_strdup("current_schema");
11860 }
11861 |  CAST '(' a_expr AS Typename ')'
11862  {
11863  $$ = cat_str(5,mm_strdup("cast ("),$3,mm_strdup("as"),$5,mm_strdup(")"));
11864 }
11865 |  EXTRACT '(' extract_list ')'
11866  {
11867  $$ = cat_str(3,mm_strdup("extract ("),$3,mm_strdup(")"));
11868 }
11869 |  OVERLAY '(' overlay_list ')'
11870  {
11871  $$ = cat_str(3,mm_strdup("overlay ("),$3,mm_strdup(")"));
11872 }
11873 |  POSITION '(' position_list ')'
11874  {
11875  $$ = cat_str(3,mm_strdup("position ("),$3,mm_strdup(")"));
11876 }
11877 |  SUBSTRING '(' substr_list ')'
11878  {
11879  $$ = cat_str(3,mm_strdup("substring ("),$3,mm_strdup(")"));
11880 }
11881 |  TREAT '(' a_expr AS Typename ')'
11882  {
11883  $$ = cat_str(5,mm_strdup("treat ("),$3,mm_strdup("as"),$5,mm_strdup(")"));
11884 }
11885 |  TRIM '(' BOTH trim_list ')'
11886  {
11887  $$ = cat_str(3,mm_strdup("trim ( both"),$4,mm_strdup(")"));
11888 }
11889 |  TRIM '(' LEADING trim_list ')'
11890  {
11891  $$ = cat_str(3,mm_strdup("trim ( leading"),$4,mm_strdup(")"));
11892 }
11893 |  TRIM '(' TRAILING trim_list ')'
11894  {
11895  $$ = cat_str(3,mm_strdup("trim ( trailing"),$4,mm_strdup(")"));
11896 }
11897 |  TRIM '(' trim_list ')'
11898  {
11899  $$ = cat_str(3,mm_strdup("trim ("),$3,mm_strdup(")"));
11900 }
11901 |  NULLIF '(' a_expr ',' a_expr ')'
11902  {
11903  $$ = cat_str(5,mm_strdup("nullif ("),$3,mm_strdup(","),$5,mm_strdup(")"));
11904 }
11905 |  COALESCE '(' expr_list ')'
11906  {
11907  $$ = cat_str(3,mm_strdup("coalesce ("),$3,mm_strdup(")"));
11908 }
11909 |  GREATEST '(' expr_list ')'
11910  {
11911  $$ = cat_str(3,mm_strdup("greatest ("),$3,mm_strdup(")"));
11912 }
11913 |  LEAST '(' expr_list ')'
11914  {
11915  $$ = cat_str(3,mm_strdup("least ("),$3,mm_strdup(")"));
11916 }
11917 |  XMLCONCAT '(' expr_list ')'
11918  {
11919  $$ = cat_str(3,mm_strdup("xmlconcat ("),$3,mm_strdup(")"));
11920 }
11921 |  XMLELEMENT '(' NAME_P ColLabel ')'
11922  {
11923  $$ = cat_str(3,mm_strdup("xmlelement ( name"),$4,mm_strdup(")"));
11924 }
11925 |  XMLELEMENT '(' NAME_P ColLabel ',' xml_attributes ')'
11926  {
11927  $$ = cat_str(5,mm_strdup("xmlelement ( name"),$4,mm_strdup(","),$6,mm_strdup(")"));
11928 }
11929 |  XMLELEMENT '(' NAME_P ColLabel ',' expr_list ')'
11930  {
11931  $$ = cat_str(5,mm_strdup("xmlelement ( name"),$4,mm_strdup(","),$6,mm_strdup(")"));
11932 }
11933 |  XMLELEMENT '(' NAME_P ColLabel ',' xml_attributes ',' expr_list ')'
11934  {
11935  $$ = cat_str(7,mm_strdup("xmlelement ( name"),$4,mm_strdup(","),$6,mm_strdup(","),$8,mm_strdup(")"));
11936 }
11937 |  XMLEXISTS '(' c_expr xmlexists_argument ')'
11938  {
11939  $$ = cat_str(4,mm_strdup("xmlexists ("),$3,$4,mm_strdup(")"));
11940 }
11941 |  XMLFOREST '(' xml_attribute_list ')'
11942  {
11943  $$ = cat_str(3,mm_strdup("xmlforest ("),$3,mm_strdup(")"));
11944 }
11945 |  XMLPARSE '(' document_or_content a_expr xml_whitespace_option ')'
11946  {
11947  $$ = cat_str(5,mm_strdup("xmlparse ("),$3,$4,$5,mm_strdup(")"));
11948 }
11949 |  XMLPI '(' NAME_P ColLabel ')'
11950  {
11951  $$ = cat_str(3,mm_strdup("xmlpi ( name"),$4,mm_strdup(")"));
11952 }
11953 |  XMLPI '(' NAME_P ColLabel ',' a_expr ')'
11954  {
11955  $$ = cat_str(5,mm_strdup("xmlpi ( name"),$4,mm_strdup(","),$6,mm_strdup(")"));
11956 }
11957 |  XMLROOT '(' a_expr ',' xml_root_version opt_xml_root_standalone ')'
11958  {
11959  $$ = cat_str(6,mm_strdup("xmlroot ("),$3,mm_strdup(","),$5,$6,mm_strdup(")"));
11960 }
11961 |  XMLSERIALIZE '(' document_or_content a_expr AS SimpleTypename ')'
11962  {
11963  $$ = cat_str(6,mm_strdup("xmlserialize ("),$3,$4,mm_strdup("as"),$6,mm_strdup(")"));
11964 }
11965 ;
11966 
11967 
11968  xml_root_version:
11969  VERSION_P a_expr
11970  {
11971  $$ = cat_str(2,mm_strdup("version"),$2);
11972 }
11973 |  VERSION_P NO VALUE_P
11974  {
11975  $$ = mm_strdup("version no value");
11976 }
11977 ;
11978 
11979 
11980  opt_xml_root_standalone:
11981  ',' STANDALONE_P YES_P
11982  {
11983  $$ = mm_strdup(", standalone yes");
11984 }
11985 |  ',' STANDALONE_P NO
11986  {
11987  $$ = mm_strdup(", standalone no");
11988 }
11989 |  ',' STANDALONE_P NO VALUE_P
11990  {
11991  $$ = mm_strdup(", standalone no value");
11992 }
11993 |
11994  {
11995  $$=EMPTY; }
11996 ;
11997 
11998 
11999  xml_attributes:
12000  XMLATTRIBUTES '(' xml_attribute_list ')'
12001  {
12002  $$ = cat_str(3,mm_strdup("xmlattributes ("),$3,mm_strdup(")"));
12003 }
12004 ;
12005 
12006 
12007  xml_attribute_list:
12008  xml_attribute_el
12009  {
12010  $$ = $1;
12011 }
12012 |  xml_attribute_list ',' xml_attribute_el
12013  {
12014  $$ = cat_str(3,$1,mm_strdup(","),$3);
12015 }
12016 ;
12017 
12018 
12019  xml_attribute_el:
12020  a_expr AS ColLabel
12021  {
12022  $$ = cat_str(3,$1,mm_strdup("as"),$3);
12023 }
12024 |  a_expr
12025  {
12026  $$ = $1;
12027 }
12028 ;
12029 
12030 
12031  document_or_content:
12032  DOCUMENT_P
12033  {
12034  $$ = mm_strdup("document");
12035 }
12036 |  CONTENT_P
12037  {
12038  $$ = mm_strdup("content");
12039 }
12040 ;
12041 
12042 
12043  xml_whitespace_option:
12044  PRESERVE WHITESPACE_P
12045  {
12046  $$ = mm_strdup("preserve whitespace");
12047 }
12048 |  STRIP_P WHITESPACE_P
12049  {
12050  $$ = mm_strdup("strip whitespace");
12051 }
12052 |
12053  {
12054  $$=EMPTY; }
12055 ;
12056 
12057 
12058  xmlexists_argument:
12059  PASSING c_expr
12060  {
12061  $$ = cat_str(2,mm_strdup("passing"),$2);
12062 }
12063 |  PASSING c_expr BY REF
12064  {
12065  $$ = cat_str(3,mm_strdup("passing"),$2,mm_strdup("by ref"));
12066 }
12067 |  PASSING BY REF c_expr
12068  {
12069  $$ = cat_str(2,mm_strdup("passing by ref"),$4);
12070 }
12071 |  PASSING BY REF c_expr BY REF
12072  {
12073  $$ = cat_str(3,mm_strdup("passing by ref"),$4,mm_strdup("by ref"));
12074 }
12075 ;
12076 
12077 
12078  within_group_clause:
12079  WITHIN GROUP_P '(' sort_clause ')'
12080  {
12081  $$ = cat_str(3,mm_strdup("within group ("),$4,mm_strdup(")"));
12082 }
12083 |
12084  {
12085  $$=EMPTY; }
12086 ;
12087 
12088 
12089  filter_clause:
12090  FILTER '(' WHERE a_expr ')'
12091  {
12092  $$ = cat_str(3,mm_strdup("filter ( where"),$4,mm_strdup(")"));
12093 }
12094 |
12095  {
12096  $$=EMPTY; }
12097 ;
12098 
12099 
12100  window_clause:
12101  WINDOW window_definition_list
12102  {
12103  $$ = cat_str(2,mm_strdup("window"),$2);
12104 }
12105 |
12106  {
12107  $$=EMPTY; }
12108 ;
12109 
12110 
12111  window_definition_list:
12112  window_definition
12113  {
12114  $$ = $1;
12115 }
12116 |  window_definition_list ',' window_definition
12117  {
12118  $$ = cat_str(3,$1,mm_strdup(","),$3);
12119 }
12120 ;
12121 
12122 
12123  window_definition:
12124  ColId AS window_specification
12125  {
12126  $$ = cat_str(3,$1,mm_strdup("as"),$3);
12127 }
12128 ;
12129 
12130 
12131  over_clause:
12132  OVER window_specification
12133  {
12134  $$ = cat_str(2,mm_strdup("over"),$2);
12135 }
12136 |  OVER ColId
12137  {
12138  $$ = cat_str(2,mm_strdup("over"),$2);
12139 }
12140 |
12141  {
12142  $$=EMPTY; }
12143 ;
12144 
12145 
12146  window_specification:
12147  '(' opt_existing_window_name opt_partition_clause opt_sort_clause opt_frame_clause ')'
12148  {
12149  $$ = cat_str(6,mm_strdup("("),$2,$3,$4,$5,mm_strdup(")"));
12150 }
12151 ;
12152 
12153 
12154  opt_existing_window_name:
12155  ColId
12156  {
12157  $$ = $1;
12158 }
12159 |  %prec Op
12160  {
12161  $$=EMPTY; }
12162 ;
12163 
12164 
12165  opt_partition_clause:
12166  PARTITION BY expr_list
12167  {
12168  $$ = cat_str(2,mm_strdup("partition by"),$3);
12169 }
12170 |
12171  {
12172  $$=EMPTY; }
12173 ;
12174 
12175 
12176  opt_frame_clause:
12177  RANGE frame_extent
12178  {
12179 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
12180  $$ = cat_str(2,mm_strdup("range"),$2);
12181 }
12182 |  ROWS frame_extent
12183  {
12184  $$ = cat_str(2,mm_strdup("rows"),$2);
12185 }
12186 |
12187  {
12188  $$=EMPTY; }
12189 ;
12190 
12191 
12192  frame_extent:
12193  frame_bound
12194  {
12195  $$ = $1;
12196 }
12197 |  BETWEEN frame_bound AND frame_bound
12198  {
12199  $$ = cat_str(4,mm_strdup("between"),$2,mm_strdup("and"),$4);
12200 }
12201 ;
12202 
12203 
12204  frame_bound:
12205  UNBOUNDED PRECEDING
12206  {
12207  $$ = mm_strdup("unbounded preceding");
12208 }
12209 |  UNBOUNDED FOLLOWING
12210  {
12211  $$ = mm_strdup("unbounded following");
12212 }
12213 |  CURRENT_P ROW
12214  {
12215  $$ = mm_strdup("current row");
12216 }
12217 |  a_expr PRECEDING
12218  {
12219  $$ = cat_str(2,$1,mm_strdup("preceding"));
12220 }
12221 |  a_expr FOLLOWING
12222  {
12223  $$ = cat_str(2,$1,mm_strdup("following"));
12224 }
12225 ;
12226 
12227 
12228  row:
12229  ROW '(' expr_list ')'
12230  {
12231  $$ = cat_str(3,mm_strdup("row ("),$3,mm_strdup(")"));
12232 }
12233 |  ROW '(' ')'
12234  {
12235  $$ = mm_strdup("row ( )");
12236 }
12237 |  '(' expr_list ',' a_expr ')'
12238  {
12239  $$ = cat_str(5,mm_strdup("("),$2,mm_strdup(","),$4,mm_strdup(")"));
12240 }
12241 ;
12242 
12243 
12244  explicit_row:
12245  ROW '(' expr_list ')'
12246  {
12247  $$ = cat_str(3,mm_strdup("row ("),$3,mm_strdup(")"));
12248 }
12249 |  ROW '(' ')'
12250  {
12251  $$ = mm_strdup("row ( )");
12252 }
12253 ;
12254 
12255 
12256  implicit_row:
12257  '(' expr_list ',' a_expr ')'
12258  {
12259  $$ = cat_str(5,mm_strdup("("),$2,mm_strdup(","),$4,mm_strdup(")"));
12260 }
12261 ;
12262 
12263 
12264  sub_type:
12265  ANY
12266  {
12267  $$ = mm_strdup("any");
12268 }
12269 |  SOME
12270  {
12271  $$ = mm_strdup("some");
12272 }
12273 |  ALL
12274  {
12275  $$ = mm_strdup("all");
12276 }
12277 ;
12278 
12279 
12280  all_Op:
12281  Op
12282  {
12283  $$ = $1;
12284 }
12285 |  MathOp
12286  {
12287  $$ = $1;
12288 }
12289 ;
12290 
12291 
12292  MathOp:
12293  '+'
12294  {
12295  $$ = mm_strdup("+");
12296 }
12297 |  '-'
12298  {
12299  $$ = mm_strdup("-");
12300 }
12301 |  '*'
12302  {
12303  $$ = mm_strdup("*");
12304 }
12305 |  '/'
12306  {
12307  $$ = mm_strdup("/");
12308 }
12309 |  '%'
12310  {
12311  $$ = mm_strdup("%");
12312 }
12313 |  '^'
12314  {
12315  $$ = mm_strdup("^");
12316 }
12317 |  '<'
12318  {
12319  $$ = mm_strdup("<");
12320 }
12321 |  '>'
12322  {
12323  $$ = mm_strdup(">");
12324 }
12325 |  '='
12326  {
12327  $$ = mm_strdup("=");
12328 }
12329 |  LESS_EQUALS
12330  {
12331  $$ = mm_strdup("<=");
12332 }
12333 |  GREATER_EQUALS
12334  {
12335  $$ = mm_strdup(">=");
12336 }
12337 |  NOT_EQUALS
12338  {
12339  $$ = mm_strdup("<>");
12340 }
12341 ;
12342 
12343 
12344  qual_Op:
12345  Op
12346  {
12347  $$ = $1;
12348 }
12349 |  OPERATOR '(' any_operator ')'
12350  {
12351  $$ = cat_str(3,mm_strdup("operator ("),$3,mm_strdup(")"));
12352 }
12353 ;
12354 
12355 
12356  qual_all_Op:
12357  all_Op
12358  {
12359  $$ = $1;
12360 }
12361 |  OPERATOR '(' any_operator ')'
12362  {
12363  $$ = cat_str(3,mm_strdup("operator ("),$3,mm_strdup(")"));
12364 }
12365 ;
12366 
12367 
12368  subquery_Op:
12369  all_Op
12370  {
12371  $$ = $1;
12372 }
12373 |  OPERATOR '(' any_operator ')'
12374  {
12375  $$ = cat_str(3,mm_strdup("operator ("),$3,mm_strdup(")"));
12376 }
12377 |  LIKE
12378  {
12379  $$ = mm_strdup("like");
12380 }
12381 |  NOT_LA LIKE
12382  {
12383  $$ = mm_strdup("not like");
12384 }
12385 |  ILIKE
12386  {
12387  $$ = mm_strdup("ilike");
12388 }
12389 |  NOT_LA ILIKE
12390  {
12391  $$ = mm_strdup("not ilike");
12392 }
12393 ;
12394 
12395 
12396  expr_list:
12397  a_expr
12398  {
12399  $$ = $1;
12400 }
12401 |  expr_list ',' a_expr
12402  {
12403  $$ = cat_str(3,$1,mm_strdup(","),$3);
12404 }
12405 ;
12406 
12407 
12408  func_arg_list:
12409  func_arg_expr
12410  {
12411  $$ = $1;
12412 }
12413 |  func_arg_list ',' func_arg_expr
12414  {
12415  $$ = cat_str(3,$1,mm_strdup(","),$3);
12416 }
12417 ;
12418 
12419 
12420  func_arg_expr:
12421  a_expr
12422  {
12423  $$ = $1;
12424 }
12425 |  param_name COLON_EQUALS a_expr
12426  {
12427  $$ = cat_str(3,$1,mm_strdup(":="),$3);
12428 }
12429 |  param_name EQUALS_GREATER a_expr
12430  {
12431  $$ = cat_str(3,$1,mm_strdup("=>"),$3);
12432 }
12433 ;
12434 
12435 
12436  type_list:
12437  Typename
12438  {
12439  $$ = $1;
12440 }
12441 |  type_list ',' Typename
12442  {
12443  $$ = cat_str(3,$1,mm_strdup(","),$3);
12444 }
12445 ;
12446 
12447 
12448  array_expr:
12449  '[' expr_list ']'
12450  {
12451  $$ = cat_str(3,mm_strdup("["),$2,mm_strdup("]"));
12452 }
12453 |  '[' array_expr_list ']'
12454  {
12455  $$ = cat_str(3,mm_strdup("["),$2,mm_strdup("]"));
12456 }
12457 |  '[' ']'
12458  {
12459  $$ = mm_strdup("[ ]");
12460 }
12461 ;
12462 
12463 
12464  array_expr_list:
12465  array_expr
12466  {
12467  $$ = $1;
12468 }
12469 |  array_expr_list ',' array_expr
12470  {
12471  $$ = cat_str(3,$1,mm_strdup(","),$3);
12472 }
12473 ;
12474 
12475 
12476  extract_list:
12477  extract_arg FROM a_expr
12478  {
12479  $$ = cat_str(3,$1,mm_strdup("from"),$3);
12480 }
12481 |
12482  {
12483  $$=EMPTY; }
12484 ;
12485 
12486 
12487  extract_arg:
12488  ecpg_ident
12489  {
12490  $$ = $1;
12491 }
12492 |  YEAR_P
12493  {
12494  $$ = mm_strdup("year");
12495 }
12496 |  MONTH_P
12497  {
12498  $$ = mm_strdup("month");
12499 }
12500 |  DAY_P
12501  {
12502  $$ = mm_strdup("day");
12503 }
12504 |  HOUR_P
12505  {
12506  $$ = mm_strdup("hour");
12507 }
12508 |  MINUTE_P
12509  {
12510  $$ = mm_strdup("minute");
12511 }
12512 |  SECOND_P
12513  {
12514  $$ = mm_strdup("second");
12515 }
12516 |  ecpg_sconst
12517  {
12518  $$ = $1;
12519 }
12520 ;
12521 
12522 
12523  overlay_list:
12524  a_expr overlay_placing substr_from substr_for
12525  {
12526  $$ = cat_str(4,$1,$2,$3,$4);
12527 }
12528 |  a_expr overlay_placing substr_from
12529  {
12530  $$ = cat_str(3,$1,$2,$3);
12531 }
12532 ;
12533 
12534 
12535  overlay_placing:
12536  PLACING a_expr
12537  {
12538  $$ = cat_str(2,mm_strdup("placing"),$2);
12539 }
12540 ;
12541 
12542 
12543  position_list:
12544  b_expr IN_P b_expr
12545  {
12546  $$ = cat_str(3,$1,mm_strdup("in"),$3);
12547 }
12548 |
12549  {
12550  $$=EMPTY; }
12551 ;
12552 
12553 
12554  substr_list:
12555  a_expr substr_from substr_for
12556  {
12557  $$ = cat_str(3,$1,$2,$3);
12558 }
12559 |  a_expr substr_for substr_from
12560  {
12561  $$ = cat_str(3,$1,$2,$3);
12562 }
12563 |  a_expr substr_from
12564  {
12565  $$ = cat_str(2,$1,$2);
12566 }
12567 |  a_expr substr_for
12568  {
12569  $$ = cat_str(2,$1,$2);
12570 }
12571 |  expr_list
12572  {
12573  $$ = $1;
12574 }
12575 |
12576  {
12577  $$=EMPTY; }
12578 ;
12579 
12580 
12581  substr_from:
12582  FROM a_expr
12583  {
12584  $$ = cat_str(2,mm_strdup("from"),$2);
12585 }
12586 ;
12587 
12588 
12589  substr_for:
12590  FOR a_expr
12591  {
12592  $$ = cat_str(2,mm_strdup("for"),$2);
12593 }
12594 ;
12595 
12596 
12597  trim_list:
12598  a_expr FROM expr_list
12599  {
12600  $$ = cat_str(3,$1,mm_strdup("from"),$3);
12601 }
12602 |  FROM expr_list
12603  {
12604  $$ = cat_str(2,mm_strdup("from"),$2);
12605 }
12606 |  expr_list
12607  {
12608  $$ = $1;
12609 }
12610 ;
12611 
12612 
12613  in_expr:
12614  select_with_parens
12615  {
12616  $$ = $1;
12617 }
12618 |  '(' expr_list ')'
12619  {
12620  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
12621 }
12622 ;
12623 
12624 
12625  case_expr:
12626  CASE case_arg when_clause_list case_default END_P
12627  {
12628  $$ = cat_str(5,mm_strdup("case"),$2,$3,$4,mm_strdup("end"));
12629 }
12630 ;
12631 
12632 
12633  when_clause_list:
12634  when_clause
12635  {
12636  $$ = $1;
12637 }
12638 |  when_clause_list when_clause
12639  {
12640  $$ = cat_str(2,$1,$2);
12641 }
12642 ;
12643 
12644 
12645  when_clause:
12646  WHEN a_expr THEN a_expr
12647  {
12648  $$ = cat_str(4,mm_strdup("when"),$2,mm_strdup("then"),$4);
12649 }
12650 ;
12651 
12652 
12653  case_default:
12654  ELSE a_expr
12655  {
12656  $$ = cat_str(2,mm_strdup("else"),$2);
12657 }
12658 |
12659  {
12660  $$=EMPTY; }
12661 ;
12662 
12663 
12664  case_arg:
12665  a_expr
12666  {
12667  $$ = $1;
12668 }
12669 |
12670  {
12671  $$=EMPTY; }
12672 ;
12673 
12674 
12675  columnref:
12676  ColId
12677  {
12678  $$ = $1;
12679 }
12680 |  ColId indirection
12681  {
12682  $$ = cat_str(2,$1,$2);
12683 }
12684 ;
12685 
12686 
12687  indirection_el:
12688  '.' attr_name
12689  {
12690  $$ = cat_str(2,mm_strdup("."),$2);
12691 }
12692 |  '.' '*'
12693  {
12694  $$ = mm_strdup(". *");
12695 }
12696 |  '[' a_expr ']'
12697  {
12698  $$ = cat_str(3,mm_strdup("["),$2,mm_strdup("]"));
12699 }
12700 |  '[' opt_slice_bound ':' opt_slice_bound ']'
12701  {
12702  $$ = cat_str(5,mm_strdup("["),$2,mm_strdup(":"),$4,mm_strdup("]"));
12703 }
12704 ;
12705 
12706 
12707  opt_slice_bound:
12708  a_expr
12709  {
12710  $$ = $1;
12711 }
12712 |
12713  {
12714  $$=EMPTY; }
12715 ;
12716 
12717 
12718  indirection:
12719  indirection_el
12720  {
12721  $$ = $1;
12722 }
12723 |  indirection indirection_el
12724  {
12725  $$ = cat_str(2,$1,$2);
12726 }
12727 ;
12728 
12729 
12730  opt_indirection:
12731 
12732  {
12733  $$=EMPTY; }
12734 |  opt_indirection indirection_el
12735  {
12736  $$ = cat_str(2,$1,$2);
12737 }
12738 ;
12739 
12740 
12741  opt_asymmetric:
12742  ASYMMETRIC
12743  {
12744  $$ = mm_strdup("asymmetric");
12745 }
12746 |
12747  {
12748  $$=EMPTY; }
12749 ;
12750 
12751 
12752  opt_target_list:
12753  target_list
12754  {
12755  $$ = $1;
12756 }
12757 |
12758  {
12759  $$=EMPTY; }
12760 ;
12761 
12762 
12763  target_list:
12764  target_el
12765  {
12766  $$ = $1;
12767 }
12768 |  target_list ',' target_el
12769  {
12770  $$ = cat_str(3,$1,mm_strdup(","),$3);
12771 }
12772 ;
12773 
12774 
12775  target_el:
12776  a_expr AS ColLabel
12777  {
12778  $$ = cat_str(3,$1,mm_strdup("as"),$3);
12779 }
12780 |  a_expr ecpg_ident
12781  {
12782  $$ = cat_str(2,$1,$2);
12783 }
12784 |  a_expr
12785  {
12786  $$ = $1;
12787 }
12788 |  '*'
12789  {
12790  $$ = mm_strdup("*");
12791 }
12792 ;
12793 
12794 
12795  qualified_name_list:
12796  qualified_name
12797  {
12798  $$ = $1;
12799 }
12800 |  qualified_name_list ',' qualified_name
12801  {
12802  $$ = cat_str(3,$1,mm_strdup(","),$3);
12803 }
12804 ;
12805 
12806 
12807  qualified_name:
12808  ColId
12809  {
12810  $$ = $1;
12811 }
12812 |  ColId indirection
12813  {
12814  $$ = cat_str(2,$1,$2);
12815 }
12816 ;
12817 
12818 
12819  name_list:
12820  name
12821  {
12822  $$ = $1;
12823 }
12824 |  name_list ',' name
12825  {
12826  $$ = cat_str(3,$1,mm_strdup(","),$3);
12827 }
12828 ;
12829 
12830 
12831  name:
12832  ColId
12833  {
12834  $$ = $1;
12835 }
12836 ;
12837 
12838 
12839  database_name:
12840  ColId
12841  {
12842  $$ = $1;
12843 }
12844 ;
12845 
12846 
12847  access_method:
12848  ColId
12849  {
12850  $$ = $1;
12851 }
12852 ;
12853 
12854 
12855  attr_name:
12856  ColLabel
12857  {
12858  $$ = $1;
12859 }
12860 ;
12861 
12862 
12863  index_name:
12864  ColId
12865  {
12866  $$ = $1;
12867 }
12868 ;
12869 
12870 
12871  file_name:
12872  ecpg_sconst
12873  {
12874  $$ = $1;
12875 }
12876 ;
12877 
12878 
12879  func_name:
12880  type_function_name
12881  {
12882  $$ = $1;
12883 }
12884 |  ColId indirection
12885  {
12886  $$ = cat_str(2,$1,$2);
12887 }
12888 ;
12889 
12890 
12891  AexprConst:
12892  Iconst
12893  {
12894  $$ = $1;
12895 }
12896 |  ecpg_fconst
12897  {
12898  $$ = $1;
12899 }
12900 |  ecpg_sconst
12901  {
12902  $$ = $1;
12903 }
12904 |  ecpg_bconst
12905  {
12906  $$ = $1;
12907 }
12908 |  XCONST
12909  {
12910  $$ = mm_strdup("xconst");
12911 }
12912 |  func_name ecpg_sconst
12913  {
12914  $$ = cat_str(2,$1,$2);
12915 }
12916 |  func_name '(' func_arg_list opt_sort_clause ')' ecpg_sconst
12917  {
12918  $$ = cat_str(6,$1,mm_strdup("("),$3,$4,mm_strdup(")"),$6);
12919 }
12920 |  ConstTypename ecpg_sconst
12921  {
12922  $$ = cat_str(2,$1,$2);
12923 }
12924 |  ConstInterval ecpg_sconst opt_interval
12925  {
12926  $$ = cat_str(3,$1,$2,$3);
12927 }
12928 |  ConstInterval '(' Iconst ')' ecpg_sconst
12929  {
12930  $$ = cat_str(5,$1,mm_strdup("("),$3,mm_strdup(")"),$5);
12931 }
12932 |  TRUE_P
12933  {
12934  $$ = mm_strdup("true");
12935 }
12936 |  FALSE_P
12937  {
12938  $$ = mm_strdup("false");
12939 }
12940 |  NULL_P
12941  {
12942  $$ = mm_strdup("null");
12943 }
12944 	| civar			{ $$ = $1; }
12945 	| civarind		{ $$ = $1; }
12946 ;
12947 
12948 
12949  Iconst:
12950  ICONST
12951 	{ $$ = make_name(); }
12952 ;
12953 
12954 
12955  SignedIconst:
12956  Iconst
12957  {
12958  $$ = $1;
12959 }
12960 	| civar	{ $$ = $1; }
12961 |  '+' Iconst
12962  {
12963  $$ = cat_str(2,mm_strdup("+"),$2);
12964 }
12965 |  '-' Iconst
12966  {
12967  $$ = cat_str(2,mm_strdup("-"),$2);
12968 }
12969 ;
12970 
12971 
12972  RoleId:
12973  RoleSpec
12974  {
12975  $$ = $1;
12976 }
12977 ;
12978 
12979 
12980  RoleSpec:
12981  NonReservedWord
12982  {
12983  $$ = $1;
12984 }
12985 |  CURRENT_USER
12986  {
12987  $$ = mm_strdup("current_user");
12988 }
12989 |  SESSION_USER
12990  {
12991  $$ = mm_strdup("session_user");
12992 }
12993 ;
12994 
12995 
12996  role_list:
12997  RoleSpec
12998  {
12999  $$ = $1;
13000 }
13001 |  role_list ',' RoleSpec
13002  {
13003  $$ = cat_str(3,$1,mm_strdup(","),$3);
13004 }
13005 ;
13006 
13007 
13008  NonReservedWord:
13009  ecpg_ident
13010  {
13011  $$ = $1;
13012 }
13013 |  unreserved_keyword
13014  {
13015  $$ = $1;
13016 }
13017 |  col_name_keyword
13018  {
13019  $$ = $1;
13020 }
13021 |  type_func_name_keyword
13022  {
13023  $$ = $1;
13024 }
13025 ;
13026 
13027 
13028  unreserved_keyword:
13029  ABORT_P
13030  {
13031  $$ = mm_strdup("abort");
13032 }
13033 |  ABSOLUTE_P
13034  {
13035  $$ = mm_strdup("absolute");
13036 }
13037 |  ACCESS
13038  {
13039  $$ = mm_strdup("access");
13040 }
13041 |  ACTION
13042  {
13043  $$ = mm_strdup("action");
13044 }
13045 |  ADD_P
13046  {
13047  $$ = mm_strdup("add");
13048 }
13049 |  ADMIN
13050  {
13051  $$ = mm_strdup("admin");
13052 }
13053 |  AFTER
13054  {
13055  $$ = mm_strdup("after");
13056 }
13057 |  AGGREGATE
13058  {
13059  $$ = mm_strdup("aggregate");
13060 }
13061 |  ALSO
13062  {
13063  $$ = mm_strdup("also");
13064 }
13065 |  ALTER
13066  {
13067  $$ = mm_strdup("alter");
13068 }
13069 |  ALWAYS
13070  {
13071  $$ = mm_strdup("always");
13072 }
13073 |  ASSERTION
13074  {
13075  $$ = mm_strdup("assertion");
13076 }
13077 |  ASSIGNMENT
13078  {
13079  $$ = mm_strdup("assignment");
13080 }
13081 |  AT
13082  {
13083  $$ = mm_strdup("at");
13084 }
13085 |  ATTACH
13086  {
13087  $$ = mm_strdup("attach");
13088 }
13089 |  ATTRIBUTE
13090  {
13091  $$ = mm_strdup("attribute");
13092 }
13093 |  BACKWARD
13094  {
13095  $$ = mm_strdup("backward");
13096 }
13097 |  BEFORE
13098  {
13099  $$ = mm_strdup("before");
13100 }
13101 |  BEGIN_P
13102  {
13103  $$ = mm_strdup("begin");
13104 }
13105 |  BY
13106  {
13107  $$ = mm_strdup("by");
13108 }
13109 |  CACHE
13110  {
13111  $$ = mm_strdup("cache");
13112 }
13113 |  CALLED
13114  {
13115  $$ = mm_strdup("called");
13116 }
13117 |  CASCADE
13118  {
13119  $$ = mm_strdup("cascade");
13120 }
13121 |  CASCADED
13122  {
13123  $$ = mm_strdup("cascaded");
13124 }
13125 |  CATALOG_P
13126  {
13127  $$ = mm_strdup("catalog");
13128 }
13129 |  CHAIN
13130  {
13131  $$ = mm_strdup("chain");
13132 }
13133 |  CHARACTERISTICS
13134  {
13135  $$ = mm_strdup("characteristics");
13136 }
13137 |  CHECKPOINT
13138  {
13139  $$ = mm_strdup("checkpoint");
13140 }
13141 |  CLASS
13142  {
13143  $$ = mm_strdup("class");
13144 }
13145 |  CLOSE
13146  {
13147  $$ = mm_strdup("close");
13148 }
13149 |  CLUSTER
13150  {
13151  $$ = mm_strdup("cluster");
13152 }
13153 |  COLUMNS
13154  {
13155  $$ = mm_strdup("columns");
13156 }
13157 |  COMMENT
13158  {
13159  $$ = mm_strdup("comment");
13160 }
13161 |  COMMENTS
13162  {
13163  $$ = mm_strdup("comments");
13164 }
13165 |  COMMIT
13166  {
13167  $$ = mm_strdup("commit");
13168 }
13169 |  COMMITTED
13170  {
13171  $$ = mm_strdup("committed");
13172 }
13173 |  CONFIGURATION
13174  {
13175  $$ = mm_strdup("configuration");
13176 }
13177 |  CONFLICT
13178  {
13179  $$ = mm_strdup("conflict");
13180 }
13181 |  CONSTRAINTS
13182  {
13183  $$ = mm_strdup("constraints");
13184 }
13185 |  CONTENT_P
13186  {
13187  $$ = mm_strdup("content");
13188 }
13189 |  CONTINUE_P
13190  {
13191  $$ = mm_strdup("continue");
13192 }
13193 |  CONVERSION_P
13194  {
13195  $$ = mm_strdup("conversion");
13196 }
13197 |  COPY
13198  {
13199  $$ = mm_strdup("copy");
13200 }
13201 |  COST
13202  {
13203  $$ = mm_strdup("cost");
13204 }
13205 |  CSV
13206  {
13207  $$ = mm_strdup("csv");
13208 }
13209 |  CUBE
13210  {
13211  $$ = mm_strdup("cube");
13212 }
13213 |  CURSOR
13214  {
13215  $$ = mm_strdup("cursor");
13216 }
13217 |  CYCLE
13218  {
13219  $$ = mm_strdup("cycle");
13220 }
13221 |  DATA_P
13222  {
13223  $$ = mm_strdup("data");
13224 }
13225 |  DATABASE
13226  {
13227  $$ = mm_strdup("database");
13228 }
13229 |  DEALLOCATE
13230  {
13231  $$ = mm_strdup("deallocate");
13232 }
13233 |  DECLARE
13234  {
13235  $$ = mm_strdup("declare");
13236 }
13237 |  DEFAULTS
13238  {
13239  $$ = mm_strdup("defaults");
13240 }
13241 |  DEFERRED
13242  {
13243  $$ = mm_strdup("deferred");
13244 }
13245 |  DEFINER
13246  {
13247  $$ = mm_strdup("definer");
13248 }
13249 |  DELETE_P
13250  {
13251  $$ = mm_strdup("delete");
13252 }
13253 |  DELIMITER
13254  {
13255  $$ = mm_strdup("delimiter");
13256 }
13257 |  DELIMITERS
13258  {
13259  $$ = mm_strdup("delimiters");
13260 }
13261 |  DEPENDS
13262  {
13263  $$ = mm_strdup("depends");
13264 }
13265 |  DETACH
13266  {
13267  $$ = mm_strdup("detach");
13268 }
13269 |  DICTIONARY
13270  {
13271  $$ = mm_strdup("dictionary");
13272 }
13273 |  DISABLE_P
13274  {
13275  $$ = mm_strdup("disable");
13276 }
13277 |  DISCARD
13278  {
13279  $$ = mm_strdup("discard");
13280 }
13281 |  DOCUMENT_P
13282  {
13283  $$ = mm_strdup("document");
13284 }
13285 |  DOMAIN_P
13286  {
13287  $$ = mm_strdup("domain");
13288 }
13289 |  DOUBLE_P
13290  {
13291  $$ = mm_strdup("double");
13292 }
13293 |  DROP
13294  {
13295  $$ = mm_strdup("drop");
13296 }
13297 |  EACH
13298  {
13299  $$ = mm_strdup("each");
13300 }
13301 |  ENABLE_P
13302  {
13303  $$ = mm_strdup("enable");
13304 }
13305 |  ENCODING
13306  {
13307  $$ = mm_strdup("encoding");
13308 }
13309 |  ENCRYPTED
13310  {
13311  $$ = mm_strdup("encrypted");
13312 }
13313 |  ENUM_P
13314  {
13315  $$ = mm_strdup("enum");
13316 }
13317 |  ESCAPE
13318  {
13319  $$ = mm_strdup("escape");
13320 }
13321 |  EVENT
13322  {
13323  $$ = mm_strdup("event");
13324 }
13325 |  EXCLUDE
13326  {
13327  $$ = mm_strdup("exclude");
13328 }
13329 |  EXCLUDING
13330  {
13331  $$ = mm_strdup("excluding");
13332 }
13333 |  EXCLUSIVE
13334  {
13335  $$ = mm_strdup("exclusive");
13336 }
13337 |  EXECUTE
13338  {
13339  $$ = mm_strdup("execute");
13340 }
13341 |  EXPLAIN
13342  {
13343  $$ = mm_strdup("explain");
13344 }
13345 |  EXTENSION
13346  {
13347  $$ = mm_strdup("extension");
13348 }
13349 |  EXTERNAL
13350  {
13351  $$ = mm_strdup("external");
13352 }
13353 |  FAMILY
13354  {
13355  $$ = mm_strdup("family");
13356 }
13357 |  FILTER
13358  {
13359  $$ = mm_strdup("filter");
13360 }
13361 |  FIRST_P
13362  {
13363  $$ = mm_strdup("first");
13364 }
13365 |  FOLLOWING
13366  {
13367  $$ = mm_strdup("following");
13368 }
13369 |  FORCE
13370  {
13371  $$ = mm_strdup("force");
13372 }
13373 |  FORWARD
13374  {
13375  $$ = mm_strdup("forward");
13376 }
13377 |  FUNCTION
13378  {
13379  $$ = mm_strdup("function");
13380 }
13381 |  FUNCTIONS
13382  {
13383  $$ = mm_strdup("functions");
13384 }
13385 |  GENERATED
13386  {
13387  $$ = mm_strdup("generated");
13388 }
13389 |  GLOBAL
13390  {
13391  $$ = mm_strdup("global");
13392 }
13393 |  GRANTED
13394  {
13395  $$ = mm_strdup("granted");
13396 }
13397 |  HANDLER
13398  {
13399  $$ = mm_strdup("handler");
13400 }
13401 |  HEADER_P
13402  {
13403  $$ = mm_strdup("header");
13404 }
13405 |  HOLD
13406  {
13407  $$ = mm_strdup("hold");
13408 }
13409 |  IDENTITY_P
13410  {
13411  $$ = mm_strdup("identity");
13412 }
13413 |  IF_P
13414  {
13415  $$ = mm_strdup("if");
13416 }
13417 |  IMMEDIATE
13418  {
13419  $$ = mm_strdup("immediate");
13420 }
13421 |  IMMUTABLE
13422  {
13423  $$ = mm_strdup("immutable");
13424 }
13425 |  IMPLICIT_P
13426  {
13427  $$ = mm_strdup("implicit");
13428 }
13429 |  IMPORT_P
13430  {
13431  $$ = mm_strdup("import");
13432 }
13433 |  INCLUDING
13434  {
13435  $$ = mm_strdup("including");
13436 }
13437 |  INCREMENT
13438  {
13439  $$ = mm_strdup("increment");
13440 }
13441 |  INDEX
13442  {
13443  $$ = mm_strdup("index");
13444 }
13445 |  INDEXES
13446  {
13447  $$ = mm_strdup("indexes");
13448 }
13449 |  INHERIT
13450  {
13451  $$ = mm_strdup("inherit");
13452 }
13453 |  INHERITS
13454  {
13455  $$ = mm_strdup("inherits");
13456 }
13457 |  INLINE_P
13458  {
13459  $$ = mm_strdup("inline");
13460 }
13461 |  INSENSITIVE
13462  {
13463  $$ = mm_strdup("insensitive");
13464 }
13465 |  INSERT
13466  {
13467  $$ = mm_strdup("insert");
13468 }
13469 |  INSTEAD
13470  {
13471  $$ = mm_strdup("instead");
13472 }
13473 |  INVOKER
13474  {
13475  $$ = mm_strdup("invoker");
13476 }
13477 |  ISOLATION
13478  {
13479  $$ = mm_strdup("isolation");
13480 }
13481 |  KEY
13482  {
13483  $$ = mm_strdup("key");
13484 }
13485 |  LABEL
13486  {
13487  $$ = mm_strdup("label");
13488 }
13489 |  LANGUAGE
13490  {
13491  $$ = mm_strdup("language");
13492 }
13493 |  LARGE_P
13494  {
13495  $$ = mm_strdup("large");
13496 }
13497 |  LAST_P
13498  {
13499  $$ = mm_strdup("last");
13500 }
13501 |  LEAKPROOF
13502  {
13503  $$ = mm_strdup("leakproof");
13504 }
13505 |  LEVEL
13506  {
13507  $$ = mm_strdup("level");
13508 }
13509 |  LISTEN
13510  {
13511  $$ = mm_strdup("listen");
13512 }
13513 |  LOAD
13514  {
13515  $$ = mm_strdup("load");
13516 }
13517 |  LOCAL
13518  {
13519  $$ = mm_strdup("local");
13520 }
13521 |  LOCATION
13522  {
13523  $$ = mm_strdup("location");
13524 }
13525 |  LOCK_P
13526  {
13527  $$ = mm_strdup("lock");
13528 }
13529 |  LOCKED
13530  {
13531  $$ = mm_strdup("locked");
13532 }
13533 |  LOGGED
13534  {
13535  $$ = mm_strdup("logged");
13536 }
13537 |  MAPPING
13538  {
13539  $$ = mm_strdup("mapping");
13540 }
13541 |  MATCH
13542  {
13543  $$ = mm_strdup("match");
13544 }
13545 |  MATERIALIZED
13546  {
13547  $$ = mm_strdup("materialized");
13548 }
13549 |  MAXVALUE
13550  {
13551  $$ = mm_strdup("maxvalue");
13552 }
13553 |  METHOD
13554  {
13555  $$ = mm_strdup("method");
13556 }
13557 |  MINVALUE
13558  {
13559  $$ = mm_strdup("minvalue");
13560 }
13561 |  MODE
13562  {
13563  $$ = mm_strdup("mode");
13564 }
13565 |  MOVE
13566  {
13567  $$ = mm_strdup("move");
13568 }
13569 |  NAME_P
13570  {
13571  $$ = mm_strdup("name");
13572 }
13573 |  NAMES
13574  {
13575  $$ = mm_strdup("names");
13576 }
13577 |  NEW
13578  {
13579  $$ = mm_strdup("new");
13580 }
13581 |  NEXT
13582  {
13583  $$ = mm_strdup("next");
13584 }
13585 |  NO
13586  {
13587  $$ = mm_strdup("no");
13588 }
13589 |  NOTHING
13590  {
13591  $$ = mm_strdup("nothing");
13592 }
13593 |  NOTIFY
13594  {
13595  $$ = mm_strdup("notify");
13596 }
13597 |  NOWAIT
13598  {
13599  $$ = mm_strdup("nowait");
13600 }
13601 |  NULLS_P
13602  {
13603  $$ = mm_strdup("nulls");
13604 }
13605 |  OBJECT_P
13606  {
13607  $$ = mm_strdup("object");
13608 }
13609 |  OF
13610  {
13611  $$ = mm_strdup("of");
13612 }
13613 |  OFF
13614  {
13615  $$ = mm_strdup("off");
13616 }
13617 |  OIDS
13618  {
13619  $$ = mm_strdup("oids");
13620 }
13621 |  OLD
13622  {
13623  $$ = mm_strdup("old");
13624 }
13625 |  OPERATOR
13626  {
13627  $$ = mm_strdup("operator");
13628 }
13629 |  OPTION
13630  {
13631  $$ = mm_strdup("option");
13632 }
13633 |  OPTIONS
13634  {
13635  $$ = mm_strdup("options");
13636 }
13637 |  ORDINALITY
13638  {
13639  $$ = mm_strdup("ordinality");
13640 }
13641 |  OVER
13642  {
13643  $$ = mm_strdup("over");
13644 }
13645 |  OVERRIDING
13646  {
13647  $$ = mm_strdup("overriding");
13648 }
13649 |  OWNED
13650  {
13651  $$ = mm_strdup("owned");
13652 }
13653 |  OWNER
13654  {
13655  $$ = mm_strdup("owner");
13656 }
13657 |  PARALLEL
13658  {
13659  $$ = mm_strdup("parallel");
13660 }
13661 |  PARSER
13662  {
13663  $$ = mm_strdup("parser");
13664 }
13665 |  PARTIAL
13666  {
13667  $$ = mm_strdup("partial");
13668 }
13669 |  PARTITION
13670  {
13671  $$ = mm_strdup("partition");
13672 }
13673 |  PASSING
13674  {
13675  $$ = mm_strdup("passing");
13676 }
13677 |  PASSWORD
13678  {
13679  $$ = mm_strdup("password");
13680 }
13681 |  PLANS
13682  {
13683  $$ = mm_strdup("plans");
13684 }
13685 |  POLICY
13686  {
13687  $$ = mm_strdup("policy");
13688 }
13689 |  PRECEDING
13690  {
13691  $$ = mm_strdup("preceding");
13692 }
13693 |  PREPARE
13694  {
13695  $$ = mm_strdup("prepare");
13696 }
13697 |  PREPARED
13698  {
13699  $$ = mm_strdup("prepared");
13700 }
13701 |  PRESERVE
13702  {
13703  $$ = mm_strdup("preserve");
13704 }
13705 |  PRIOR
13706  {
13707  $$ = mm_strdup("prior");
13708 }
13709 |  PRIVILEGES
13710  {
13711  $$ = mm_strdup("privileges");
13712 }
13713 |  PROCEDURAL
13714  {
13715  $$ = mm_strdup("procedural");
13716 }
13717 |  PROCEDURE
13718  {
13719  $$ = mm_strdup("procedure");
13720 }
13721 |  PROGRAM
13722  {
13723  $$ = mm_strdup("program");
13724 }
13725 |  PUBLICATION
13726  {
13727  $$ = mm_strdup("publication");
13728 }
13729 |  QUOTE
13730  {
13731  $$ = mm_strdup("quote");
13732 }
13733 |  RANGE
13734  {
13735  $$ = mm_strdup("range");
13736 }
13737 |  READ
13738  {
13739  $$ = mm_strdup("read");
13740 }
13741 |  REASSIGN
13742  {
13743  $$ = mm_strdup("reassign");
13744 }
13745 |  RECHECK
13746  {
13747  $$ = mm_strdup("recheck");
13748 }
13749 |  RECURSIVE
13750  {
13751  $$ = mm_strdup("recursive");
13752 }
13753 |  REF
13754  {
13755  $$ = mm_strdup("ref");
13756 }
13757 |  REFERENCING
13758  {
13759  $$ = mm_strdup("referencing");
13760 }
13761 |  REFRESH
13762  {
13763  $$ = mm_strdup("refresh");
13764 }
13765 |  REINDEX
13766  {
13767  $$ = mm_strdup("reindex");
13768 }
13769 |  RELATIVE_P
13770  {
13771  $$ = mm_strdup("relative");
13772 }
13773 |  RELEASE
13774  {
13775  $$ = mm_strdup("release");
13776 }
13777 |  RENAME
13778  {
13779  $$ = mm_strdup("rename");
13780 }
13781 |  REPEATABLE
13782  {
13783  $$ = mm_strdup("repeatable");
13784 }
13785 |  REPLACE
13786  {
13787  $$ = mm_strdup("replace");
13788 }
13789 |  REPLICA
13790  {
13791  $$ = mm_strdup("replica");
13792 }
13793 |  RESET
13794  {
13795  $$ = mm_strdup("reset");
13796 }
13797 |  RESTART
13798  {
13799  $$ = mm_strdup("restart");
13800 }
13801 |  RESTRICT
13802  {
13803  $$ = mm_strdup("restrict");
13804 }
13805 |  RETURNS
13806  {
13807  $$ = mm_strdup("returns");
13808 }
13809 |  REVOKE
13810  {
13811  $$ = mm_strdup("revoke");
13812 }
13813 |  ROLE
13814  {
13815  $$ = mm_strdup("role");
13816 }
13817 |  ROLLBACK
13818  {
13819  $$ = mm_strdup("rollback");
13820 }
13821 |  ROLLUP
13822  {
13823  $$ = mm_strdup("rollup");
13824 }
13825 |  ROWS
13826  {
13827  $$ = mm_strdup("rows");
13828 }
13829 |  RULE
13830  {
13831  $$ = mm_strdup("rule");
13832 }
13833 |  SAVEPOINT
13834  {
13835  $$ = mm_strdup("savepoint");
13836 }
13837 |  SCHEMA
13838  {
13839  $$ = mm_strdup("schema");
13840 }
13841 |  SCHEMAS
13842  {
13843  $$ = mm_strdup("schemas");
13844 }
13845 |  SCROLL
13846  {
13847  $$ = mm_strdup("scroll");
13848 }
13849 |  SEARCH
13850  {
13851  $$ = mm_strdup("search");
13852 }
13853 |  SECURITY
13854  {
13855  $$ = mm_strdup("security");
13856 }
13857 |  SEQUENCE
13858  {
13859  $$ = mm_strdup("sequence");
13860 }
13861 |  SEQUENCES
13862  {
13863  $$ = mm_strdup("sequences");
13864 }
13865 |  SERIALIZABLE
13866  {
13867  $$ = mm_strdup("serializable");
13868 }
13869 |  SERVER
13870  {
13871  $$ = mm_strdup("server");
13872 }
13873 |  SESSION
13874  {
13875  $$ = mm_strdup("session");
13876 }
13877 |  SET
13878  {
13879  $$ = mm_strdup("set");
13880 }
13881 |  SETS
13882  {
13883  $$ = mm_strdup("sets");
13884 }
13885 |  SHARE
13886  {
13887  $$ = mm_strdup("share");
13888 }
13889 |  SHOW
13890  {
13891  $$ = mm_strdup("show");
13892 }
13893 |  SIMPLE
13894  {
13895  $$ = mm_strdup("simple");
13896 }
13897 |  SKIP
13898  {
13899  $$ = mm_strdup("skip");
13900 }
13901 |  SNAPSHOT
13902  {
13903  $$ = mm_strdup("snapshot");
13904 }
13905 |  SQL_P
13906  {
13907  $$ = mm_strdup("sql");
13908 }
13909 |  STABLE
13910  {
13911  $$ = mm_strdup("stable");
13912 }
13913 |  STANDALONE_P
13914  {
13915  $$ = mm_strdup("standalone");
13916 }
13917 |  START
13918  {
13919  $$ = mm_strdup("start");
13920 }
13921 |  STATEMENT
13922  {
13923  $$ = mm_strdup("statement");
13924 }
13925 |  STATISTICS
13926  {
13927  $$ = mm_strdup("statistics");
13928 }
13929 |  STDIN
13930  {
13931  $$ = mm_strdup("stdin");
13932 }
13933 |  STDOUT
13934  {
13935  $$ = mm_strdup("stdout");
13936 }
13937 |  STORAGE
13938  {
13939  $$ = mm_strdup("storage");
13940 }
13941 |  STRICT_P
13942  {
13943  $$ = mm_strdup("strict");
13944 }
13945 |  STRIP_P
13946  {
13947  $$ = mm_strdup("strip");
13948 }
13949 |  SUBSCRIPTION
13950  {
13951  $$ = mm_strdup("subscription");
13952 }
13953 |  SYSID
13954  {
13955  $$ = mm_strdup("sysid");
13956 }
13957 |  SYSTEM_P
13958  {
13959  $$ = mm_strdup("system");
13960 }
13961 |  TABLES
13962  {
13963  $$ = mm_strdup("tables");
13964 }
13965 |  TABLESPACE
13966  {
13967  $$ = mm_strdup("tablespace");
13968 }
13969 |  TEMP
13970  {
13971  $$ = mm_strdup("temp");
13972 }
13973 |  TEMPLATE
13974  {
13975  $$ = mm_strdup("template");
13976 }
13977 |  TEMPORARY
13978  {
13979  $$ = mm_strdup("temporary");
13980 }
13981 |  TEXT_P
13982  {
13983  $$ = mm_strdup("text");
13984 }
13985 |  TRANSACTION
13986  {
13987  $$ = mm_strdup("transaction");
13988 }
13989 |  TRANSFORM
13990  {
13991  $$ = mm_strdup("transform");
13992 }
13993 |  TRIGGER
13994  {
13995  $$ = mm_strdup("trigger");
13996 }
13997 |  TRUNCATE
13998  {
13999  $$ = mm_strdup("truncate");
14000 }
14001 |  TRUSTED
14002  {
14003  $$ = mm_strdup("trusted");
14004 }
14005 |  TYPE_P
14006  {
14007  $$ = mm_strdup("type");
14008 }
14009 |  TYPES_P
14010  {
14011  $$ = mm_strdup("types");
14012 }
14013 |  UNBOUNDED
14014  {
14015  $$ = mm_strdup("unbounded");
14016 }
14017 |  UNCOMMITTED
14018  {
14019  $$ = mm_strdup("uncommitted");
14020 }
14021 |  UNENCRYPTED
14022  {
14023  $$ = mm_strdup("unencrypted");
14024 }
14025 |  UNKNOWN
14026  {
14027  $$ = mm_strdup("unknown");
14028 }
14029 |  UNLISTEN
14030  {
14031  $$ = mm_strdup("unlisten");
14032 }
14033 |  UNLOGGED
14034  {
14035  $$ = mm_strdup("unlogged");
14036 }
14037 |  UNTIL
14038  {
14039  $$ = mm_strdup("until");
14040 }
14041 |  UPDATE
14042  {
14043  $$ = mm_strdup("update");
14044 }
14045 |  VACUUM
14046  {
14047  $$ = mm_strdup("vacuum");
14048 }
14049 |  VALID
14050  {
14051  $$ = mm_strdup("valid");
14052 }
14053 |  VALIDATE
14054  {
14055  $$ = mm_strdup("validate");
14056 }
14057 |  VALIDATOR
14058  {
14059  $$ = mm_strdup("validator");
14060 }
14061 |  VALUE_P
14062  {
14063  $$ = mm_strdup("value");
14064 }
14065 |  VARYING
14066  {
14067  $$ = mm_strdup("varying");
14068 }
14069 |  VERSION_P
14070  {
14071  $$ = mm_strdup("version");
14072 }
14073 |  VIEW
14074  {
14075  $$ = mm_strdup("view");
14076 }
14077 |  VIEWS
14078  {
14079  $$ = mm_strdup("views");
14080 }
14081 |  VOLATILE
14082  {
14083  $$ = mm_strdup("volatile");
14084 }
14085 |  WHITESPACE_P
14086  {
14087  $$ = mm_strdup("whitespace");
14088 }
14089 |  WITHIN
14090  {
14091  $$ = mm_strdup("within");
14092 }
14093 |  WITHOUT
14094  {
14095  $$ = mm_strdup("without");
14096 }
14097 |  WORK
14098  {
14099  $$ = mm_strdup("work");
14100 }
14101 |  WRAPPER
14102  {
14103  $$ = mm_strdup("wrapper");
14104 }
14105 |  WRITE
14106  {
14107  $$ = mm_strdup("write");
14108 }
14109 |  XML_P
14110  {
14111  $$ = mm_strdup("xml");
14112 }
14113 |  YES_P
14114  {
14115  $$ = mm_strdup("yes");
14116 }
14117 |  ZONE
14118  {
14119  $$ = mm_strdup("zone");
14120 }
14121 ;
14122 
14123 
14124  col_name_keyword:
14125  BETWEEN
14126  {
14127  $$ = mm_strdup("between");
14128 }
14129 |  BIGINT
14130  {
14131  $$ = mm_strdup("bigint");
14132 }
14133 |  BIT
14134  {
14135  $$ = mm_strdup("bit");
14136 }
14137 |  BOOLEAN_P
14138  {
14139  $$ = mm_strdup("boolean");
14140 }
14141 |  CHARACTER
14142  {
14143  $$ = mm_strdup("character");
14144 }
14145 |  COALESCE
14146  {
14147  $$ = mm_strdup("coalesce");
14148 }
14149 |  DEC
14150  {
14151  $$ = mm_strdup("dec");
14152 }
14153 |  DECIMAL_P
14154  {
14155  $$ = mm_strdup("decimal");
14156 }
14157 |  EXISTS
14158  {
14159  $$ = mm_strdup("exists");
14160 }
14161 |  EXTRACT
14162  {
14163  $$ = mm_strdup("extract");
14164 }
14165 |  FLOAT_P
14166  {
14167  $$ = mm_strdup("float");
14168 }
14169 |  GREATEST
14170  {
14171  $$ = mm_strdup("greatest");
14172 }
14173 |  GROUPING
14174  {
14175  $$ = mm_strdup("grouping");
14176 }
14177 |  INOUT
14178  {
14179  $$ = mm_strdup("inout");
14180 }
14181 |  INTEGER
14182  {
14183  $$ = mm_strdup("integer");
14184 }
14185 |  INTERVAL
14186  {
14187  $$ = mm_strdup("interval");
14188 }
14189 |  LEAST
14190  {
14191  $$ = mm_strdup("least");
14192 }
14193 |  NATIONAL
14194  {
14195  $$ = mm_strdup("national");
14196 }
14197 |  NCHAR
14198  {
14199  $$ = mm_strdup("nchar");
14200 }
14201 |  NONE
14202  {
14203  $$ = mm_strdup("none");
14204 }
14205 |  NULLIF
14206  {
14207  $$ = mm_strdup("nullif");
14208 }
14209 |  NUMERIC
14210  {
14211  $$ = mm_strdup("numeric");
14212 }
14213 |  OUT_P
14214  {
14215  $$ = mm_strdup("out");
14216 }
14217 |  OVERLAY
14218  {
14219  $$ = mm_strdup("overlay");
14220 }
14221 |  POSITION
14222  {
14223  $$ = mm_strdup("position");
14224 }
14225 |  PRECISION
14226  {
14227  $$ = mm_strdup("precision");
14228 }
14229 |  REAL
14230  {
14231  $$ = mm_strdup("real");
14232 }
14233 |  ROW
14234  {
14235  $$ = mm_strdup("row");
14236 }
14237 |  SETOF
14238  {
14239  $$ = mm_strdup("setof");
14240 }
14241 |  SMALLINT
14242  {
14243  $$ = mm_strdup("smallint");
14244 }
14245 |  SUBSTRING
14246  {
14247  $$ = mm_strdup("substring");
14248 }
14249 |  TIME
14250  {
14251  $$ = mm_strdup("time");
14252 }
14253 |  TIMESTAMP
14254  {
14255  $$ = mm_strdup("timestamp");
14256 }
14257 |  TREAT
14258  {
14259  $$ = mm_strdup("treat");
14260 }
14261 |  TRIM
14262  {
14263  $$ = mm_strdup("trim");
14264 }
14265 |  VARCHAR
14266  {
14267  $$ = mm_strdup("varchar");
14268 }
14269 |  XMLATTRIBUTES
14270  {
14271  $$ = mm_strdup("xmlattributes");
14272 }
14273 |  XMLCONCAT
14274  {
14275  $$ = mm_strdup("xmlconcat");
14276 }
14277 |  XMLELEMENT
14278  {
14279  $$ = mm_strdup("xmlelement");
14280 }
14281 |  XMLEXISTS
14282  {
14283  $$ = mm_strdup("xmlexists");
14284 }
14285 |  XMLFOREST
14286  {
14287  $$ = mm_strdup("xmlforest");
14288 }
14289 |  XMLNAMESPACES
14290  {
14291  $$ = mm_strdup("xmlnamespaces");
14292 }
14293 |  XMLPARSE
14294  {
14295  $$ = mm_strdup("xmlparse");
14296 }
14297 |  XMLPI
14298  {
14299  $$ = mm_strdup("xmlpi");
14300 }
14301 |  XMLROOT
14302  {
14303  $$ = mm_strdup("xmlroot");
14304 }
14305 |  XMLSERIALIZE
14306  {
14307  $$ = mm_strdup("xmlserialize");
14308 }
14309 |  XMLTABLE
14310  {
14311  $$ = mm_strdup("xmltable");
14312 }
14313 ;
14314 
14315 
14316  type_func_name_keyword:
14317  AUTHORIZATION
14318  {
14319  $$ = mm_strdup("authorization");
14320 }
14321 |  BINARY
14322  {
14323  $$ = mm_strdup("binary");
14324 }
14325 |  COLLATION
14326  {
14327  $$ = mm_strdup("collation");
14328 }
14329 |  CONCURRENTLY
14330  {
14331  $$ = mm_strdup("concurrently");
14332 }
14333 |  CROSS
14334  {
14335  $$ = mm_strdup("cross");
14336 }
14337 |  CURRENT_SCHEMA
14338  {
14339  $$ = mm_strdup("current_schema");
14340 }
14341 |  FREEZE
14342  {
14343  $$ = mm_strdup("freeze");
14344 }
14345 |  FULL
14346  {
14347  $$ = mm_strdup("full");
14348 }
14349 |  ILIKE
14350  {
14351  $$ = mm_strdup("ilike");
14352 }
14353 |  INNER_P
14354  {
14355  $$ = mm_strdup("inner");
14356 }
14357 |  IS
14358  {
14359  $$ = mm_strdup("is");
14360 }
14361 |  ISNULL
14362  {
14363  $$ = mm_strdup("isnull");
14364 }
14365 |  JOIN
14366  {
14367  $$ = mm_strdup("join");
14368 }
14369 |  LEFT
14370  {
14371  $$ = mm_strdup("left");
14372 }
14373 |  LIKE
14374  {
14375  $$ = mm_strdup("like");
14376 }
14377 |  NATURAL
14378  {
14379  $$ = mm_strdup("natural");
14380 }
14381 |  NOTNULL
14382  {
14383  $$ = mm_strdup("notnull");
14384 }
14385 |  OUTER_P
14386  {
14387  $$ = mm_strdup("outer");
14388 }
14389 |  OVERLAPS
14390  {
14391  $$ = mm_strdup("overlaps");
14392 }
14393 |  RIGHT
14394  {
14395  $$ = mm_strdup("right");
14396 }
14397 |  SIMILAR
14398  {
14399  $$ = mm_strdup("similar");
14400 }
14401 |  TABLESAMPLE
14402  {
14403  $$ = mm_strdup("tablesample");
14404 }
14405 |  VERBOSE
14406  {
14407  $$ = mm_strdup("verbose");
14408 }
14409 ;
14410 
14411 
14412  reserved_keyword:
14413  ALL
14414  {
14415  $$ = mm_strdup("all");
14416 }
14417 |  ANALYSE
14418  {
14419  $$ = mm_strdup("analyse");
14420 }
14421 |  ANALYZE
14422  {
14423  $$ = mm_strdup("analyze");
14424 }
14425 |  AND
14426  {
14427  $$ = mm_strdup("and");
14428 }
14429 |  ANY
14430  {
14431  $$ = mm_strdup("any");
14432 }
14433 |  ARRAY
14434  {
14435  $$ = mm_strdup("array");
14436 }
14437 |  AS
14438  {
14439  $$ = mm_strdup("as");
14440 }
14441 |  ASC
14442  {
14443  $$ = mm_strdup("asc");
14444 }
14445 |  ASYMMETRIC
14446  {
14447  $$ = mm_strdup("asymmetric");
14448 }
14449 |  BOTH
14450  {
14451  $$ = mm_strdup("both");
14452 }
14453 |  CASE
14454  {
14455  $$ = mm_strdup("case");
14456 }
14457 |  CAST
14458  {
14459  $$ = mm_strdup("cast");
14460 }
14461 |  CHECK
14462  {
14463  $$ = mm_strdup("check");
14464 }
14465 |  COLLATE
14466  {
14467  $$ = mm_strdup("collate");
14468 }
14469 |  COLUMN
14470  {
14471  $$ = mm_strdup("column");
14472 }
14473 |  CONSTRAINT
14474  {
14475  $$ = mm_strdup("constraint");
14476 }
14477 |  CREATE
14478  {
14479  $$ = mm_strdup("create");
14480 }
14481 |  CURRENT_CATALOG
14482  {
14483  $$ = mm_strdup("current_catalog");
14484 }
14485 |  CURRENT_DATE
14486  {
14487  $$ = mm_strdup("current_date");
14488 }
14489 |  CURRENT_ROLE
14490  {
14491  $$ = mm_strdup("current_role");
14492 }
14493 |  CURRENT_TIME
14494  {
14495  $$ = mm_strdup("current_time");
14496 }
14497 |  CURRENT_TIMESTAMP
14498  {
14499  $$ = mm_strdup("current_timestamp");
14500 }
14501 |  CURRENT_USER
14502  {
14503  $$ = mm_strdup("current_user");
14504 }
14505 |  DEFAULT
14506  {
14507  $$ = mm_strdup("default");
14508 }
14509 |  DEFERRABLE
14510  {
14511  $$ = mm_strdup("deferrable");
14512 }
14513 |  DESC
14514  {
14515  $$ = mm_strdup("desc");
14516 }
14517 |  DISTINCT
14518  {
14519  $$ = mm_strdup("distinct");
14520 }
14521 |  DO
14522  {
14523  $$ = mm_strdup("do");
14524 }
14525 |  ELSE
14526  {
14527  $$ = mm_strdup("else");
14528 }
14529 |  END_P
14530  {
14531  $$ = mm_strdup("end");
14532 }
14533 |  EXCEPT
14534  {
14535  $$ = mm_strdup("except");
14536 }
14537 |  FALSE_P
14538  {
14539  $$ = mm_strdup("false");
14540 }
14541 |  FETCH
14542  {
14543  $$ = mm_strdup("fetch");
14544 }
14545 |  FOR
14546  {
14547  $$ = mm_strdup("for");
14548 }
14549 |  FOREIGN
14550  {
14551  $$ = mm_strdup("foreign");
14552 }
14553 |  FROM
14554  {
14555  $$ = mm_strdup("from");
14556 }
14557 |  GRANT
14558  {
14559  $$ = mm_strdup("grant");
14560 }
14561 |  GROUP_P
14562  {
14563  $$ = mm_strdup("group");
14564 }
14565 |  HAVING
14566  {
14567  $$ = mm_strdup("having");
14568 }
14569 |  IN_P
14570  {
14571  $$ = mm_strdup("in");
14572 }
14573 |  INITIALLY
14574  {
14575  $$ = mm_strdup("initially");
14576 }
14577 |  INTERSECT
14578  {
14579  $$ = mm_strdup("intersect");
14580 }
14581 |  INTO
14582  {
14583  $$ = mm_strdup("into");
14584 }
14585 |  LATERAL_P
14586  {
14587  $$ = mm_strdup("lateral");
14588 }
14589 |  LEADING
14590  {
14591  $$ = mm_strdup("leading");
14592 }
14593 |  LIMIT
14594  {
14595  $$ = mm_strdup("limit");
14596 }
14597 |  LOCALTIME
14598  {
14599  $$ = mm_strdup("localtime");
14600 }
14601 |  LOCALTIMESTAMP
14602  {
14603  $$ = mm_strdup("localtimestamp");
14604 }
14605 |  NOT
14606  {
14607  $$ = mm_strdup("not");
14608 }
14609 |  NULL_P
14610  {
14611  $$ = mm_strdup("null");
14612 }
14613 |  OFFSET
14614  {
14615  $$ = mm_strdup("offset");
14616 }
14617 |  ON
14618  {
14619  $$ = mm_strdup("on");
14620 }
14621 |  ONLY
14622  {
14623  $$ = mm_strdup("only");
14624 }
14625 |  OR
14626  {
14627  $$ = mm_strdup("or");
14628 }
14629 |  ORDER
14630  {
14631  $$ = mm_strdup("order");
14632 }
14633 |  PLACING
14634  {
14635  $$ = mm_strdup("placing");
14636 }
14637 |  PRIMARY
14638  {
14639  $$ = mm_strdup("primary");
14640 }
14641 |  REFERENCES
14642  {
14643  $$ = mm_strdup("references");
14644 }
14645 |  RETURNING
14646  {
14647  $$ = mm_strdup("returning");
14648 }
14649 |  SELECT
14650  {
14651  $$ = mm_strdup("select");
14652 }
14653 |  SESSION_USER
14654  {
14655  $$ = mm_strdup("session_user");
14656 }
14657 |  SOME
14658  {
14659  $$ = mm_strdup("some");
14660 }
14661 |  SYMMETRIC
14662  {
14663  $$ = mm_strdup("symmetric");
14664 }
14665 |  TABLE
14666  {
14667  $$ = mm_strdup("table");
14668 }
14669 |  THEN
14670  {
14671  $$ = mm_strdup("then");
14672 }
14673 |  TRAILING
14674  {
14675  $$ = mm_strdup("trailing");
14676 }
14677 |  TRUE_P
14678  {
14679  $$ = mm_strdup("true");
14680 }
14681 |  UNIQUE
14682  {
14683  $$ = mm_strdup("unique");
14684 }
14685 |  USER
14686  {
14687  $$ = mm_strdup("user");
14688 }
14689 |  USING
14690  {
14691  $$ = mm_strdup("using");
14692 }
14693 |  VARIADIC
14694  {
14695  $$ = mm_strdup("variadic");
14696 }
14697 |  WHEN
14698  {
14699  $$ = mm_strdup("when");
14700 }
14701 |  WHERE
14702  {
14703  $$ = mm_strdup("where");
14704 }
14705 |  WINDOW
14706  {
14707  $$ = mm_strdup("window");
14708 }
14709 |  WITH
14710  {
14711  $$ = mm_strdup("with");
14712 }
14713 ;
14714 
14715 
14716 /* trailer */
14717 /* src/interfaces/ecpg/preproc/ecpg.trailer */
14718 
14719 statements: /*EMPTY*/
14720 				| statements statement
14721 		;
14722 
14723 statement: ecpgstart at stmt ';' { connection = NULL; }
14724 				| ecpgstart stmt ';'
14725 				| ecpgstart ECPGVarDeclaration
14726 				{
14727 					fprintf(base_yyout, "%s", $2);
14728 					free($2);
14729 					output_line_number();
14730 				}
14731 				| ECPGDeclaration
14732 				| c_thing               { fprintf(base_yyout, "%s", $1); free($1); }
14733 				| CPP_LINE              { fprintf(base_yyout, "%s", $1); free($1); }
14734 				| '{'                   { braces_open++; fputs("{", base_yyout); }
14735 				| '}'
14736 		{
14737 			remove_typedefs(braces_open);
14738 			remove_variables(braces_open--);
14739 			if (braces_open == 0)
14740 			{
14741 				free(current_function);
14742 				current_function = NULL;
14743 			}
14744 			fputs("}", base_yyout);
14745 		}
14746 		;
14747 
14748 CreateAsStmt: CREATE OptTemp TABLE create_as_target AS {FoundInto = 0;} SelectStmt opt_with_data
14749 		{
14750 			if (FoundInto == 1)
14751 				mmerror(PARSE_ERROR, ET_ERROR, "CREATE TABLE AS cannot specify INTO");
14752 
14753 			$$ = cat_str(7, mm_strdup("create"), $2, mm_strdup("table"), $4, mm_strdup("as"), $7, $8);
14754 		}
14755                 |  CREATE OptTemp TABLE IF_P NOT EXISTS create_as_target AS {FoundInto = 0;} SelectStmt opt_with_data
14756 		{
14757 			if (FoundInto == 1)
14758 				mmerror(PARSE_ERROR, ET_ERROR, "CREATE TABLE AS cannot specify INTO");
14759 
14760 			$$ = cat_str(7, mm_strdup("create"), $2, mm_strdup("table if not exists"), $7, mm_strdup("as"), $10, $11);
14761 		}
14762 		;
14763 
14764 at: AT connection_object
14765 		{
14766 			connection = $2;
14767 			/*
14768 			 * Do we have a variable as connection target?  Remove the variable
14769 			 * from the variable list or else it will be used twice.
14770 			 */
14771 			if (argsinsert != NULL)
14772 				argsinsert = NULL;
14773 		}
14774 		;
14775 
14776 /*
14777  * the exec sql connect statement: connect to the given database
14778  */
14779 ECPGConnect: SQL_CONNECT TO connection_target opt_connection_name opt_user
14780 			{ $$ = cat_str(5, $3, mm_strdup(","), $5, mm_strdup(","), $4); }
14781 		| SQL_CONNECT TO DEFAULT
14782 			{ $$ = mm_strdup("NULL, NULL, NULL, \"DEFAULT\""); }
14783 		  /* also allow ORACLE syntax */
14784 		| SQL_CONNECT ora_user
14785 			{ $$ = cat_str(3, mm_strdup("NULL,"), $2, mm_strdup(", NULL")); }
14786 		| DATABASE connection_target
14787 			{ $$ = cat2_str($2, mm_strdup(", NULL, NULL, NULL")); }
14788 		;
14789 
14790 connection_target: opt_database_name opt_server opt_port
14791 		{
14792 			/* old style: dbname[@server][:port] */
14793 			if (strlen($2) > 0 && *($2) != '@')
14794 				mmerror(PARSE_ERROR, ET_ERROR, "expected \"@\", found \"%s\"", $2);
14795 
14796 			/* C strings need to be handled differently */
14797 			if ($1[0] == '\"')
14798 				$$ = $1;
14799 			else
14800 				$$ = make3_str(mm_strdup("\""), make3_str($1, $2, $3), mm_strdup("\""));
14801 		}
14802 		|  db_prefix ':' server opt_port '/' opt_database_name opt_options
14803 		{
14804 			/* new style: <tcp|unix>:postgresql://server[:port][/dbname] */
14805 			if (strncmp($1, "unix:postgresql", strlen("unix:postgresql")) != 0 && strncmp($1, "tcp:postgresql", strlen("tcp:postgresql")) != 0)
14806 				mmerror(PARSE_ERROR, ET_ERROR, "only protocols \"tcp\" and \"unix\" and database type \"postgresql\" are supported");
14807 
14808 			if (strncmp($3, "//", strlen("//")) != 0)
14809 				mmerror(PARSE_ERROR, ET_ERROR, "expected \"://\", found \"%s\"", $3);
14810 
14811 			if (strncmp($1, "unix", strlen("unix")) == 0 &&
14812 				strncmp($3 + strlen("//"), "localhost", strlen("localhost")) != 0 &&
14813 				strncmp($3 + strlen("//"), "127.0.0.1", strlen("127.0.0.1")) != 0)
14814 				mmerror(PARSE_ERROR, ET_ERROR, "Unix-domain sockets only work on \"localhost\" but not on \"%s\"", $3 + strlen("//"));
14815 
14816 			$$ = make3_str(make3_str(mm_strdup("\""), $1, mm_strdup(":")), $3, make3_str(make3_str($4, mm_strdup("/"), $6), $7, mm_strdup("\"")));
14817 		}
14818 		| char_variable
14819 		{
14820 			$$ = $1;
14821 		}
14822 		| ecpg_sconst
14823 		{
14824 			/* We can only process double quoted strings not single quotes ones,
14825 			 * so we change the quotes.
14826 			 * Note, that the rule for ecpg_sconst adds these single quotes. */
14827 			$1[0] = '\"';
14828 			$1[strlen($1)-1] = '\"';
14829 			$$ = $1;
14830 		}
14831 		;
14832 
14833 opt_database_name: database_name		{ $$ = $1; }
14834 		| /*EMPTY*/			{ $$ = EMPTY; }
14835 		;
14836 
14837 db_prefix: ecpg_ident cvariable
14838 		{
14839 			if (strcmp($2, "postgresql") != 0 && strcmp($2, "postgres") != 0)
14840 				mmerror(PARSE_ERROR, ET_ERROR, "expected \"postgresql\", found \"%s\"", $2);
14841 
14842 			if (strcmp($1, "tcp") != 0 && strcmp($1, "unix") != 0)
14843 				mmerror(PARSE_ERROR, ET_ERROR, "invalid connection type: %s", $1);
14844 
14845 			$$ = make3_str($1, mm_strdup(":"), $2);
14846 		}
14847 		;
14848 
14849 server: Op server_name
14850 		{
14851 			if (strcmp($1, "@") != 0 && strcmp($1, "//") != 0)
14852 				mmerror(PARSE_ERROR, ET_ERROR, "expected \"@\" or \"://\", found \"%s\"", $1);
14853 
14854 			$$ = make2_str($1, $2);
14855 		}
14856 		;
14857 
14858 opt_server: server			{ $$ = $1; }
14859 		| /*EMPTY*/			{ $$ = EMPTY; }
14860 		;
14861 
14862 server_name: ColId					{ $$ = $1; }
14863 		| ColId '.' server_name		{ $$ = make3_str($1, mm_strdup("."), $3); }
14864 		| IP						{ $$ = make_name(); }
14865 		;
14866 
14867 opt_port: ':' Iconst		{ $$ = make2_str(mm_strdup(":"), $2); }
14868 		| /*EMPTY*/	{ $$ = EMPTY; }
14869 		;
14870 
14871 opt_connection_name: AS connection_object	{ $$ = $2; }
14872 		| /*EMPTY*/			{ $$ = mm_strdup("NULL"); }
14873 		;
14874 
14875 opt_user: USER ora_user		{ $$ = $2; }
14876 		| /*EMPTY*/			{ $$ = mm_strdup("NULL, NULL"); }
14877 		;
14878 
14879 ora_user: user_name
14880 			{ $$ = cat2_str($1, mm_strdup(", NULL")); }
14881 		| user_name '/' user_name
14882 			{ $$ = cat_str(3, $1, mm_strdup(","), $3); }
14883 		| user_name SQL_IDENTIFIED BY user_name
14884 			{ $$ = cat_str(3, $1, mm_strdup(","), $4); }
14885 		| user_name USING user_name
14886 			{ $$ = cat_str(3, $1, mm_strdup(","), $3); }
14887 		;
14888 
14889 user_name: RoleId
14890 		{
14891 			if ($1[0] == '\"')
14892 				$$ = $1;
14893 			else
14894 				$$ = make3_str(mm_strdup("\""), $1, mm_strdup("\""));
14895 		}
14896 		| ecpg_sconst
14897 		{
14898 			if ($1[0] == '\"')
14899 				$$ = $1;
14900 			else
14901 				$$ = make3_str(mm_strdup("\""), $1, mm_strdup("\""));
14902 		}
14903 		| civar
14904 		{
14905 			enum ECPGttype type = argsinsert->variable->type->type;
14906 
14907 			/* if array see what's inside */
14908 			if (type == ECPGt_array)
14909 				type = argsinsert->variable->type->u.element->type;
14910 
14911 			/* handle varchars */
14912 			if (type == ECPGt_varchar)
14913 				$$ = make2_str(mm_strdup(argsinsert->variable->name), mm_strdup(".arr"));
14914 			else
14915 				$$ = mm_strdup(argsinsert->variable->name);
14916 		}
14917 		;
14918 
14919 char_variable: cvariable
14920 		{
14921 			/* check if we have a string variable */
14922 			struct variable *p = find_variable($1);
14923 			enum ECPGttype type = p->type->type;
14924 
14925 			/* If we have just one character this is not a string */
14926 			if (atol(p->type->size) == 1)
14927 					mmerror(PARSE_ERROR, ET_ERROR, "invalid data type");
14928 			else
14929 			{
14930 				/* if array see what's inside */
14931 				if (type == ECPGt_array)
14932 					type = p->type->u.element->type;
14933 
14934 				switch (type)
14935 				{
14936 					case ECPGt_char:
14937 					case ECPGt_unsigned_char:
14938 					case ECPGt_string:
14939 						$$ = $1;
14940 						break;
14941 					case ECPGt_varchar:
14942 						$$ = make2_str($1, mm_strdup(".arr"));
14943 						break;
14944 					default:
14945 						mmerror(PARSE_ERROR, ET_ERROR, "invalid data type");
14946 						$$ = $1;
14947 						break;
14948 				}
14949 			}
14950 		}
14951 		;
14952 
14953 opt_options: Op connect_options
14954 		{
14955 			if (strlen($1) == 0)
14956 				mmerror(PARSE_ERROR, ET_ERROR, "incomplete statement");
14957 
14958 			if (strcmp($1, "?") != 0)
14959 				mmerror(PARSE_ERROR, ET_ERROR, "unrecognized token \"%s\"", $1);
14960 
14961 			$$ = make2_str(mm_strdup("?"), $2);
14962 		}
14963 		| /*EMPTY*/	{ $$ = EMPTY; }
14964 		;
14965 
14966 connect_options:  ColId opt_opt_value
14967 			{
14968 				$$ = make2_str($1, $2);
14969 			}
14970 		| ColId opt_opt_value Op connect_options
14971 			{
14972 				if (strlen($3) == 0)
14973 					mmerror(PARSE_ERROR, ET_ERROR, "incomplete statement");
14974 
14975 				if (strcmp($3, "&") != 0)
14976 					mmerror(PARSE_ERROR, ET_ERROR, "unrecognized token \"%s\"", $3);
14977 
14978 				$$ = cat_str(3, make2_str($1, $2), $3, $4);
14979 			}
14980 		;
14981 
14982 opt_opt_value: /*EMPTY*/
14983 			{ $$ = EMPTY; }
14984 		| '=' Iconst
14985 			{ $$ = make2_str(mm_strdup("="), $2); }
14986 		| '=' ecpg_ident
14987 			{ $$ = make2_str(mm_strdup("="), $2); }
14988 		| '=' civar
14989 			{ $$ = make2_str(mm_strdup("="), $2); }
14990 		;
14991 
14992 prepared_name: name
14993 		{
14994 			if ($1[0] == '\"' && $1[strlen($1)-1] == '\"') /* already quoted? */
14995 				$$ = $1;
14996 			else /* not quoted => convert to lowercase */
14997 			{
14998 				size_t i;
14999 
15000 				for (i = 0; i< strlen($1); i++)
15001 					$1[i] = tolower((unsigned char) $1[i]);
15002 
15003 				$$ = make3_str(mm_strdup("\""), $1, mm_strdup("\""));
15004 			}
15005 		}
15006 		| char_variable { $$ = $1; }
15007 		;
15008 
15009 /*
15010  * Declare a prepared cursor. The syntax is different from the standard
15011  * declare statement, so we create a new rule.
15012  */
15013 ECPGCursorStmt:  DECLARE cursor_name cursor_options CURSOR opt_hold FOR prepared_name
15014 		{
15015 			struct cursor *ptr, *this;
15016 			char *cursor_marker = $2[0] == ':' ? mm_strdup("$0") : mm_strdup($2);
15017 			int (* strcmp_fn)(const char *, const char *) = (($2[0] == ':' || $2[0] == '"') ? strcmp : pg_strcasecmp);
15018 			struct variable *thisquery = (struct variable *)mm_alloc(sizeof(struct variable));
15019 			const char *con = connection ? connection : "NULL";
15020 			char *comment;
15021 
15022 			for (ptr = cur; ptr != NULL; ptr = ptr->next)
15023 			{
15024 				if (strcmp_fn($2, ptr->name) == 0)
15025 				{
15026 					/* re-definition is a bug */
15027 					if ($2[0] == ':')
15028 						mmerror(PARSE_ERROR, ET_ERROR, "using variable \"%s\" in different declare statements is not supported", $2+1);
15029 					else
15030 						mmerror(PARSE_ERROR, ET_ERROR, "cursor \"%s\" is already defined", $2);
15031 				}
15032 			}
15033 
15034 			this = (struct cursor *) mm_alloc(sizeof(struct cursor));
15035 
15036 			/* initial definition */
15037 			this->next = cur;
15038 			this->name = $2;
15039 			this->function = (current_function ? mm_strdup(current_function) : NULL);
15040 			this->connection = connection;
15041 			this->command =  cat_str(6, mm_strdup("declare"), cursor_marker, $3, mm_strdup("cursor"), $5, mm_strdup("for $1"));
15042 			this->argsresult = NULL;
15043 			this->argsresult_oos = NULL;
15044 
15045 			thisquery->type = &ecpg_query;
15046 			thisquery->brace_level = 0;
15047 			thisquery->next = NULL;
15048 			thisquery->name = (char *) mm_alloc(sizeof("ECPGprepared_statement(, , __LINE__)") + strlen(con) + strlen($7));
15049 			sprintf(thisquery->name, "ECPGprepared_statement(%s, %s, __LINE__)", con, $7);
15050 
15051 			this->argsinsert = NULL;
15052 			this->argsinsert_oos = NULL;
15053 			if ($2[0] == ':')
15054 			{
15055 				struct variable *var = find_variable($2 + 1);
15056 				remove_variable_from_list(&argsinsert, var);
15057 				add_variable_to_head(&(this->argsinsert), var, &no_indicator);
15058 			}
15059 			add_variable_to_head(&(this->argsinsert), thisquery, &no_indicator);
15060 
15061 			cur = this;
15062 
15063 			comment = cat_str(3, mm_strdup("/*"), mm_strdup(this->command), mm_strdup("*/"));
15064 
15065 			if ((braces_open > 0) && INFORMIX_MODE) /* we're in a function */
15066 				$$ = cat_str(3, adjust_outofscope_cursor_vars(this),
15067 					mm_strdup("ECPG_informix_reset_sqlca();"),
15068 					comment);
15069 			else
15070 				$$ = cat2_str(adjust_outofscope_cursor_vars(this), comment);
15071 		}
15072 		;
15073 
15074 ECPGExecuteImmediateStmt: EXECUTE IMMEDIATE execstring
15075 			{
15076 			  /* execute immediate means prepare the statement and
15077 			   * immediately execute it */
15078 			  $$ = $3;
15079 			};
15080 /*
15081  * variable declaration outside exec sql declare block
15082  */
15083 ECPGVarDeclaration: single_vt_declaration;
15084 
15085 single_vt_declaration: type_declaration		{ $$ = $1; }
15086 		| var_declaration		{ $$ = $1; }
15087 		;
15088 
15089 precision:	NumericOnly	{ $$ = $1; };
15090 
15091 opt_scale:	',' NumericOnly	{ $$ = $2; }
15092 		| /* EMPTY */	{ $$ = EMPTY; }
15093 		;
15094 
15095 ecpg_interval:	opt_interval	{ $$ = $1; }
15096 		| YEAR_P TO MINUTE_P	{ $$ = mm_strdup("year to minute"); }
15097 		| YEAR_P TO SECOND_P	{ $$ = mm_strdup("year to second"); }
15098 		| DAY_P TO DAY_P		{ $$ = mm_strdup("day to day"); }
15099 		| MONTH_P TO MONTH_P	{ $$ = mm_strdup("month to month"); }
15100 		;
15101 
15102 /*
15103  * variable declaration inside exec sql declare block
15104  */
15105 ECPGDeclaration: sql_startdeclare
15106 		{ fputs("/* exec sql begin declare section */", base_yyout); }
15107 		var_type_declarations sql_enddeclare
15108 		{
15109 			fprintf(base_yyout, "%s/* exec sql end declare section */", $3);
15110 			free($3);
15111 			output_line_number();
15112 		}
15113 		;
15114 
15115 sql_startdeclare: ecpgstart BEGIN_P DECLARE SQL_SECTION ';' {};
15116 
15117 sql_enddeclare: ecpgstart END_P DECLARE SQL_SECTION ';' {};
15118 
15119 var_type_declarations:	/*EMPTY*/			{ $$ = EMPTY; }
15120 		| vt_declarations			{ $$ = $1; }
15121 		;
15122 
15123 vt_declarations:  single_vt_declaration			{ $$ = $1; }
15124 		| CPP_LINE				{ $$ = $1; }
15125 		| vt_declarations single_vt_declaration	{ $$ = cat2_str($1, $2); }
15126 		| vt_declarations CPP_LINE		{ $$ = cat2_str($1, $2); }
15127 		;
15128 
15129 variable_declarations:	var_declaration	{ $$ = $1; }
15130 		| variable_declarations var_declaration	{ $$ = cat2_str($1, $2); }
15131 		;
15132 
15133 type_declaration: S_TYPEDEF
15134 	{
15135 		/* reset this variable so we see if there was */
15136 		/* an initializer specified */
15137 		initializer = 0;
15138 	}
15139 	var_type opt_pointer ECPGColLabelCommon opt_array_bounds ';'
15140 	{
15141 		add_typedef($5, $6.index1, $6.index2, $3.type_enum, $3.type_dimension, $3.type_index, initializer, *$4 ? 1 : 0);
15142 
15143 		fprintf(base_yyout, "typedef %s %s %s %s;\n", $3.type_str, *$4 ? "*" : "", $5, $6.str);
15144 		output_line_number();
15145 		$$ = mm_strdup("");
15146 	};
15147 
15148 var_declaration: storage_declaration
15149 		var_type
15150 		{
15151 			actual_type[struct_level].type_enum = $2.type_enum;
15152 			actual_type[struct_level].type_str = $2.type_str;
15153 			actual_type[struct_level].type_dimension = $2.type_dimension;
15154 			actual_type[struct_level].type_index = $2.type_index;
15155 			actual_type[struct_level].type_sizeof = $2.type_sizeof;
15156 
15157 			actual_startline[struct_level] = hashline_number();
15158 		}
15159 		variable_list ';'
15160 		{
15161 			$$ = cat_str(5, actual_startline[struct_level], $1, $2.type_str, $4, mm_strdup(";\n"));
15162 		}
15163 		| var_type
15164 		{
15165 			actual_type[struct_level].type_enum = $1.type_enum;
15166 			actual_type[struct_level].type_str = $1.type_str;
15167 			actual_type[struct_level].type_dimension = $1.type_dimension;
15168 			actual_type[struct_level].type_index = $1.type_index;
15169 			actual_type[struct_level].type_sizeof = $1.type_sizeof;
15170 
15171 			actual_startline[struct_level] = hashline_number();
15172 		}
15173 		variable_list ';'
15174 		{
15175 			$$ = cat_str(4, actual_startline[struct_level], $1.type_str, $3, mm_strdup(";\n"));
15176 		}
15177 		| struct_union_type_with_symbol ';'
15178 		{
15179 			$$ = cat2_str($1, mm_strdup(";"));
15180 		}
15181 		;
15182 
15183 opt_bit_field:	':' Iconst	{ $$ =cat2_str(mm_strdup(":"), $2); }
15184 		| /* EMPTY */	{ $$ = EMPTY; }
15185 		;
15186 
15187 storage_declaration: storage_clause storage_modifier
15188 			{$$ = cat2_str ($1, $2); }
15189 		| storage_clause		{$$ = $1; }
15190 		| storage_modifier		{$$ = $1; }
15191 		;
15192 
15193 storage_clause : S_EXTERN	{ $$ = mm_strdup("extern"); }
15194 		| S_STATIC			{ $$ = mm_strdup("static"); }
15195 		| S_REGISTER		{ $$ = mm_strdup("register"); }
15196 		| S_AUTO			{ $$ = mm_strdup("auto"); }
15197 		;
15198 
15199 storage_modifier : S_CONST	{ $$ = mm_strdup("const"); }
15200 		| S_VOLATILE		{ $$ = mm_strdup("volatile"); }
15201 		;
15202 
15203 var_type:	simple_type
15204 		{
15205 			$$.type_enum = $1;
15206 			$$.type_str = mm_strdup(ecpg_type_name($1));
15207 			$$.type_dimension = mm_strdup("-1");
15208 			$$.type_index = mm_strdup("-1");
15209 			$$.type_sizeof = NULL;
15210 		}
15211 		| struct_union_type
15212 		{
15213 			$$.type_str = $1;
15214 			$$.type_dimension = mm_strdup("-1");
15215 			$$.type_index = mm_strdup("-1");
15216 
15217 			if (strncmp($1, "struct", sizeof("struct")-1) == 0)
15218 			{
15219 				$$.type_enum = ECPGt_struct;
15220 				$$.type_sizeof = ECPGstruct_sizeof;
15221 			}
15222 			else
15223 			{
15224 				$$.type_enum = ECPGt_union;
15225 				$$.type_sizeof = NULL;
15226 			}
15227 		}
15228 		| enum_type
15229 		{
15230 			$$.type_str = $1;
15231 			$$.type_enum = ECPGt_int;
15232 			$$.type_dimension = mm_strdup("-1");
15233 			$$.type_index = mm_strdup("-1");
15234 			$$.type_sizeof = NULL;
15235 		}
15236 		| ECPGColLabelCommon '(' precision opt_scale ')'
15237 		{
15238 			if (strcmp($1, "numeric") == 0)
15239 			{
15240 				$$.type_enum = ECPGt_numeric;
15241 				$$.type_str = mm_strdup("numeric");
15242 			}
15243 			else if (strcmp($1, "decimal") == 0)
15244 			{
15245 				$$.type_enum = ECPGt_decimal;
15246 				$$.type_str = mm_strdup("decimal");
15247 			}
15248 			else
15249 			{
15250 				mmerror(PARSE_ERROR, ET_ERROR, "only data types numeric and decimal have precision/scale argument");
15251 				$$.type_enum = ECPGt_numeric;
15252 				$$.type_str = mm_strdup("numeric");
15253 			}
15254 
15255 			$$.type_dimension = mm_strdup("-1");
15256 			$$.type_index = mm_strdup("-1");
15257 			$$.type_sizeof = NULL;
15258 		}
15259 		| ECPGColLabelCommon ecpg_interval
15260 		{
15261 			if (strlen($2) != 0 && strcmp ($1, "datetime") != 0 && strcmp ($1, "interval") != 0)
15262 				mmerror (PARSE_ERROR, ET_ERROR, "interval specification not allowed here");
15263 
15264 			/*
15265 			 * Check for type names that the SQL grammar treats as
15266 			 * unreserved keywords
15267 			 */
15268 			if (strcmp($1, "varchar") == 0)
15269 			{
15270 				$$.type_enum = ECPGt_varchar;
15271 				$$.type_str = EMPTY; /*mm_strdup("varchar");*/
15272 				$$.type_dimension = mm_strdup("-1");
15273 				$$.type_index = mm_strdup("-1");
15274 				$$.type_sizeof = NULL;
15275 			}
15276 			else if (strcmp($1, "float") == 0)
15277 			{
15278 				$$.type_enum = ECPGt_float;
15279 				$$.type_str = mm_strdup("float");
15280 				$$.type_dimension = mm_strdup("-1");
15281 				$$.type_index = mm_strdup("-1");
15282 				$$.type_sizeof = NULL;
15283 			}
15284 			else if (strcmp($1, "double") == 0)
15285 			{
15286 				$$.type_enum = ECPGt_double;
15287 				$$.type_str = mm_strdup("double");
15288 				$$.type_dimension = mm_strdup("-1");
15289 				$$.type_index = mm_strdup("-1");
15290 				$$.type_sizeof = NULL;
15291 			}
15292 			else if (strcmp($1, "numeric") == 0)
15293 			{
15294 				$$.type_enum = ECPGt_numeric;
15295 				$$.type_str = mm_strdup("numeric");
15296 				$$.type_dimension = mm_strdup("-1");
15297 				$$.type_index = mm_strdup("-1");
15298 				$$.type_sizeof = NULL;
15299 			}
15300 			else if (strcmp($1, "decimal") == 0)
15301 			{
15302 				$$.type_enum = ECPGt_decimal;
15303 				$$.type_str = mm_strdup("decimal");
15304 				$$.type_dimension = mm_strdup("-1");
15305 				$$.type_index = mm_strdup("-1");
15306 				$$.type_sizeof = NULL;
15307 			}
15308 			else if (strcmp($1, "date") == 0)
15309 			{
15310 				$$.type_enum = ECPGt_date;
15311 				$$.type_str = mm_strdup("date");
15312 				$$.type_dimension = mm_strdup("-1");
15313 				$$.type_index = mm_strdup("-1");
15314 				$$.type_sizeof = NULL;
15315 			}
15316 			else if (strcmp($1, "timestamp") == 0)
15317 			{
15318 				$$.type_enum = ECPGt_timestamp;
15319 				$$.type_str = mm_strdup("timestamp");
15320 				$$.type_dimension = mm_strdup("-1");
15321 				$$.type_index = mm_strdup("-1");
15322 				$$.type_sizeof = NULL;
15323 			}
15324 			else if (strcmp($1, "interval") == 0)
15325 			{
15326 				$$.type_enum = ECPGt_interval;
15327 				$$.type_str = mm_strdup("interval");
15328 				$$.type_dimension = mm_strdup("-1");
15329 				$$.type_index = mm_strdup("-1");
15330 				$$.type_sizeof = NULL;
15331 			}
15332 			else if (strcmp($1, "datetime") == 0)
15333 			{
15334 				$$.type_enum = ECPGt_timestamp;
15335 				$$.type_str = mm_strdup("timestamp");
15336 				$$.type_dimension = mm_strdup("-1");
15337 				$$.type_index = mm_strdup("-1");
15338 				$$.type_sizeof = NULL;
15339 			}
15340 			else if ((strcmp($1, "string") == 0) && INFORMIX_MODE)
15341 			{
15342 				$$.type_enum = ECPGt_string;
15343 				$$.type_str = mm_strdup("char");
15344 				$$.type_dimension = mm_strdup("-1");
15345 				$$.type_index = mm_strdup("-1");
15346 				$$.type_sizeof = NULL;
15347 			}
15348 			else
15349 			{
15350 				/* this is for typedef'ed types */
15351 				struct typedefs *this = get_typedef($1);
15352 
15353 				$$.type_str = (this->type->type_enum == ECPGt_varchar) ? EMPTY : mm_strdup(this->name);
15354 				$$.type_enum = this->type->type_enum;
15355 				$$.type_dimension = this->type->type_dimension;
15356 				$$.type_index = this->type->type_index;
15357 				if (this->type->type_sizeof && strlen(this->type->type_sizeof) != 0)
15358 					$$.type_sizeof = this->type->type_sizeof;
15359 				else
15360 					$$.type_sizeof = cat_str(3, mm_strdup("sizeof("), mm_strdup(this->name), mm_strdup(")"));
15361 
15362 				struct_member_list[struct_level] = ECPGstruct_member_dup(this->struct_member_list);
15363 			}
15364 		}
15365 		| s_struct_union_symbol
15366 		{
15367 			/* this is for named structs/unions */
15368 			char *name;
15369 			struct typedefs *this;
15370 			bool forward = (forward_name != NULL && strcmp($1.symbol, forward_name) == 0 && strcmp($1.su, "struct") == 0);
15371 
15372 			name = cat2_str($1.su, $1.symbol);
15373 			/* Do we have a forward definition? */
15374 			if (!forward)
15375 			{
15376 				/* No */
15377 
15378 				this = get_typedef(name);
15379 				$$.type_str = mm_strdup(this->name);
15380 				$$.type_enum = this->type->type_enum;
15381 				$$.type_dimension = this->type->type_dimension;
15382 				$$.type_index = this->type->type_index;
15383 				$$.type_sizeof = this->type->type_sizeof;
15384 				struct_member_list[struct_level] = ECPGstruct_member_dup(this->struct_member_list);
15385 				free(name);
15386 			}
15387 			else
15388 			{
15389 				$$.type_str = name;
15390 				$$.type_enum = ECPGt_long;
15391 				$$.type_dimension = mm_strdup("-1");
15392 				$$.type_index = mm_strdup("-1");
15393 				$$.type_sizeof = mm_strdup("");
15394 				struct_member_list[struct_level] = NULL;
15395 			}
15396 		}
15397 		;
15398 
15399 enum_type: ENUM_P symbol enum_definition
15400 			{ $$ = cat_str(3, mm_strdup("enum"), $2, $3); }
15401 		| ENUM_P enum_definition
15402 			{ $$ = cat2_str(mm_strdup("enum"), $2); }
15403 		| ENUM_P symbol
15404 			{ $$ = cat2_str(mm_strdup("enum"), $2); }
15405 		;
15406 
15407 enum_definition: '{' c_list '}'
15408 			{ $$ = cat_str(3, mm_strdup("{"), $2, mm_strdup("}")); };
15409 
15410 struct_union_type_with_symbol: s_struct_union_symbol
15411 		{
15412 			struct_member_list[struct_level++] = NULL;
15413 			if (struct_level >= STRUCT_DEPTH)
15414 				 mmerror(PARSE_ERROR, ET_ERROR, "too many levels in nested structure/union definition");
15415 			forward_name = mm_strdup($1.symbol);
15416 		}
15417 		'{' variable_declarations '}'
15418 		{
15419 			struct typedefs *ptr, *this;
15420 			struct this_type su_type;
15421 
15422 			ECPGfree_struct_member(struct_member_list[struct_level]);
15423 			struct_member_list[struct_level] = NULL;
15424 			struct_level--;
15425 			if (strncmp($1.su, "struct", sizeof("struct")-1) == 0)
15426 				su_type.type_enum = ECPGt_struct;
15427 			else
15428 				su_type.type_enum = ECPGt_union;
15429 			su_type.type_str = cat2_str($1.su, $1.symbol);
15430 			free(forward_name);
15431 			forward_name = NULL;
15432 
15433 			/* This is essentially a typedef but needs the keyword struct/union as well.
15434 			 * So we create the typedef for each struct definition with symbol */
15435 			for (ptr = types; ptr != NULL; ptr = ptr->next)
15436 			{
15437 					if (strcmp(su_type.type_str, ptr->name) == 0)
15438 							/* re-definition is a bug */
15439 							mmerror(PARSE_ERROR, ET_ERROR, "type \"%s\" is already defined", su_type.type_str);
15440 			}
15441 
15442 			this = (struct typedefs *) mm_alloc(sizeof(struct typedefs));
15443 
15444 			/* initial definition */
15445 			this->next = types;
15446 			this->name = mm_strdup(su_type.type_str);
15447 			this->brace_level = braces_open;
15448 			this->type = (struct this_type *) mm_alloc(sizeof(struct this_type));
15449 			this->type->type_enum = su_type.type_enum;
15450 			this->type->type_str = mm_strdup(su_type.type_str);
15451 			this->type->type_dimension = mm_strdup("-1"); /* dimension of array */
15452 			this->type->type_index = mm_strdup("-1");	/* length of string */
15453 			this->type->type_sizeof = ECPGstruct_sizeof;
15454 			this->struct_member_list = struct_member_list[struct_level];
15455 
15456 			types = this;
15457 			$$ = cat_str(4, su_type.type_str, mm_strdup("{"), $4, mm_strdup("}"));
15458 		}
15459 		;
15460 
15461 struct_union_type: struct_union_type_with_symbol	{ $$ = $1; }
15462 		| s_struct_union
15463 		{
15464 			struct_member_list[struct_level++] = NULL;
15465 			if (struct_level >= STRUCT_DEPTH)
15466 				 mmerror(PARSE_ERROR, ET_ERROR, "too many levels in nested structure/union definition");
15467 		}
15468 		'{' variable_declarations '}'
15469 		{
15470 			ECPGfree_struct_member(struct_member_list[struct_level]);
15471 			struct_member_list[struct_level] = NULL;
15472 			struct_level--;
15473 			$$ = cat_str(4, $1, mm_strdup("{"), $4, mm_strdup("}"));
15474 		}
15475 		;
15476 
15477 s_struct_union_symbol: SQL_STRUCT symbol
15478 		{
15479 			$$.su = mm_strdup("struct");
15480 			$$.symbol = $2;
15481 			ECPGstruct_sizeof = cat_str(3, mm_strdup("sizeof("), cat2_str(mm_strdup($$.su), mm_strdup($$.symbol)), mm_strdup(")"));
15482 		}
15483 		| UNION symbol
15484 		{
15485 			$$.su = mm_strdup("union");
15486 			$$.symbol = $2;
15487 		}
15488 		;
15489 
15490 s_struct_union: SQL_STRUCT
15491 		{
15492 			ECPGstruct_sizeof = mm_strdup(""); /* This must not be NULL to distinguish from simple types. */
15493 			$$ = mm_strdup("struct");
15494 		}
15495 		| UNION
15496 		{
15497 			$$ = mm_strdup("union");
15498 		}
15499 		;
15500 
15501 simple_type: unsigned_type					{ $$=$1; }
15502 		|	opt_signed signed_type			{ $$=$2; }
15503 		;
15504 
15505 unsigned_type: SQL_UNSIGNED SQL_SHORT		{ $$ = ECPGt_unsigned_short; }
15506 		| SQL_UNSIGNED SQL_SHORT INT_P	{ $$ = ECPGt_unsigned_short; }
15507 		| SQL_UNSIGNED						{ $$ = ECPGt_unsigned_int; }
15508 		| SQL_UNSIGNED INT_P				{ $$ = ECPGt_unsigned_int; }
15509 		| SQL_UNSIGNED SQL_LONG				{ $$ = ECPGt_unsigned_long; }
15510 		| SQL_UNSIGNED SQL_LONG INT_P		{ $$ = ECPGt_unsigned_long; }
15511 		| SQL_UNSIGNED SQL_LONG SQL_LONG
15512 		{
15513 #ifdef HAVE_LONG_LONG_INT
15514 			$$ = ECPGt_unsigned_long_long;
15515 #else
15516 			$$ = ECPGt_unsigned_long;
15517 #endif
15518 		}
15519 		| SQL_UNSIGNED SQL_LONG SQL_LONG INT_P
15520 		{
15521 #ifdef HAVE_LONG_LONG_INT
15522 			$$ = ECPGt_unsigned_long_long;
15523 #else
15524 			$$ = ECPGt_unsigned_long;
15525 #endif
15526 		}
15527 		| SQL_UNSIGNED CHAR_P			{ $$ = ECPGt_unsigned_char; }
15528 		;
15529 
15530 signed_type: SQL_SHORT				{ $$ = ECPGt_short; }
15531 		| SQL_SHORT INT_P			{ $$ = ECPGt_short; }
15532 		| INT_P						{ $$ = ECPGt_int; }
15533 		| SQL_LONG					{ $$ = ECPGt_long; }
15534 		| SQL_LONG INT_P			{ $$ = ECPGt_long; }
15535 		| SQL_LONG SQL_LONG
15536 		{
15537 #ifdef HAVE_LONG_LONG_INT
15538 			$$ = ECPGt_long_long;
15539 #else
15540 			$$ = ECPGt_long;
15541 #endif
15542 		}
15543 		| SQL_LONG SQL_LONG INT_P
15544 		{
15545 #ifdef HAVE_LONG_LONG_INT
15546 			$$ = ECPGt_long_long;
15547 #else
15548 			$$ = ECPGt_long;
15549 #endif
15550 		}
15551 		| SQL_BOOL					{ $$ = ECPGt_bool; }
15552 		| CHAR_P					{ $$ = ECPGt_char; }
15553 		| DOUBLE_P					{ $$ = ECPGt_double; }
15554 		;
15555 
15556 opt_signed: SQL_SIGNED
15557 		|	/* EMPTY */
15558 		;
15559 
15560 variable_list: variable
15561 			{ $$ = $1; }
15562 		| variable_list ',' variable
15563 		{
15564 			if (actual_type[struct_level].type_enum == ECPGt_varchar)
15565 				$$ = cat_str(3, $1, mm_strdup(";"), $3);
15566 			else
15567 				$$ = cat_str(3, $1, mm_strdup(","), $3);
15568 		}
15569 		;
15570 
15571 variable: opt_pointer ECPGColLabel opt_array_bounds opt_bit_field opt_initializer
15572 		{
15573 			struct ECPGtype * type;
15574 			char *dimension = $3.index1;	/* dimension of array */
15575 			char *length = $3.index2;		/* length of string */
15576 			char *dim_str;
15577 			char *vcn;
15578 
15579 			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);
15580 
15581 			switch (actual_type[struct_level].type_enum)
15582 			{
15583 				case ECPGt_struct:
15584 				case ECPGt_union:
15585 					if (atoi(dimension) < 0)
15586 						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);
15587 					else
15588 						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);
15589 
15590 					$$ = cat_str(5, $1, mm_strdup($2), $3.str, $4, $5);
15591 					break;
15592 
15593 				case ECPGt_varchar:
15594 					if (atoi(dimension) < 0)
15595 						type = ECPGmake_simple_type(actual_type[struct_level].type_enum, length, varchar_counter);
15596 					else
15597 						type = ECPGmake_array_type(ECPGmake_simple_type(actual_type[struct_level].type_enum, length, varchar_counter), dimension);
15598 
15599 					if (strcmp(dimension, "0") == 0 || abs(atoi(dimension)) == 1)
15600 							dim_str=mm_strdup("");
15601 					else
15602 							dim_str=cat_str(3, mm_strdup("["), mm_strdup(dimension), mm_strdup("]"));
15603 					/* cannot check for atoi <= 0 because a defined constant will yield 0 here as well */
15604 					if (atoi(length) < 0 || strcmp(length, "0") == 0)
15605 						mmerror(PARSE_ERROR, ET_ERROR, "pointers to varchar are not implemented");
15606 
15607 					/* make sure varchar struct name is unique by adding a unique counter to its definition */
15608 					vcn = (char *) mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
15609 					sprintf(vcn, "%d", varchar_counter);
15610 					if (strcmp(dimension, "0") == 0)
15611 						$$ = 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);
15612 					else
15613 						$$ = 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);
15614 					varchar_counter++;
15615 					break;
15616 
15617 				case ECPGt_char:
15618 				case ECPGt_unsigned_char:
15619 				case ECPGt_string:
15620 					if (atoi(dimension) == -1)
15621 					{
15622 						int i = strlen($5);
15623 
15624 						if (atoi(length) == -1 && i > 0) /* char <var>[] = "string" */
15625 						{
15626 							/* if we have an initializer but no string size set, let's use the initializer's length */
15627 							free(length);
15628 							length = mm_alloc(i+sizeof("sizeof()"));
15629 							sprintf(length, "sizeof(%s)", $5+2);
15630 						}
15631 						type = ECPGmake_simple_type(actual_type[struct_level].type_enum, length, 0);
15632 					}
15633 					else
15634 						type = ECPGmake_array_type(ECPGmake_simple_type(actual_type[struct_level].type_enum, length, 0), dimension);
15635 
15636 					$$ = cat_str(5, $1, mm_strdup($2), $3.str, $4, $5);
15637 					break;
15638 
15639 				default:
15640 					if (atoi(dimension) < 0)
15641 						type = ECPGmake_simple_type(actual_type[struct_level].type_enum, mm_strdup("1"), 0);
15642 					else
15643 						type = ECPGmake_array_type(ECPGmake_simple_type(actual_type[struct_level].type_enum, mm_strdup("1"), 0), dimension);
15644 
15645 					$$ = cat_str(5, $1, mm_strdup($2), $3.str, $4, $5);
15646 					break;
15647 			}
15648 
15649 			if (struct_level == 0)
15650 				new_variable($2, type, braces_open);
15651 			else
15652 				ECPGmake_struct_member($2, type, &(struct_member_list[struct_level - 1]));
15653 
15654 			free($2);
15655 		}
15656 		;
15657 
15658 opt_initializer: /*EMPTY*/
15659 			{ $$ = EMPTY; }
15660 		| '=' c_term
15661 		{
15662 			initializer = 1;
15663 			$$ = cat2_str(mm_strdup("="), $2);
15664 		}
15665 		;
15666 
15667 opt_pointer: /*EMPTY*/				{ $$ = EMPTY; }
15668 		| '*'						{ $$ = mm_strdup("*"); }
15669 		| '*' '*'					{ $$ = mm_strdup("**"); }
15670 		;
15671 
15672 /*
15673  * We try to simulate the correct DECLARE syntax here so we get dynamic SQL
15674  */
15675 ECPGDeclare: DECLARE STATEMENT ecpg_ident
15676 		{
15677 			/* this is only supported for compatibility */
15678 			$$ = cat_str(3, mm_strdup("/* declare statement"), $3, mm_strdup("*/"));
15679 		}
15680 		;
15681 /*
15682  * the exec sql disconnect statement: disconnect from the given database
15683  */
15684 ECPGDisconnect: SQL_DISCONNECT dis_name { $$ = $2; }
15685 		;
15686 
15687 dis_name: connection_object			{ $$ = $1; }
15688 		| CURRENT_P			{ $$ = mm_strdup("\"CURRENT\""); }
15689 		| ALL				{ $$ = mm_strdup("\"ALL\""); }
15690 		| /* EMPTY */			{ $$ = mm_strdup("\"CURRENT\""); }
15691 		;
15692 
15693 connection_object: database_name		{ $$ = make3_str(mm_strdup("\""), $1, mm_strdup("\"")); }
15694 		| DEFAULT			{ $$ = mm_strdup("\"DEFAULT\""); }
15695 		| char_variable			{ $$ = $1; }
15696 		;
15697 
15698 execstring: char_variable
15699 			{ $$ = $1; }
15700 		|	CSTRING
15701 			{ $$ = make3_str(mm_strdup("\""), $1, mm_strdup("\"")); }
15702 		;
15703 
15704 /*
15705  * the exec sql free command to deallocate a previously
15706  * prepared statement
15707  */
15708 ECPGFree:	SQL_FREE cursor_name	{ $$ = $2; }
15709 		| SQL_FREE ALL	{ $$ = mm_strdup("all"); }
15710 		;
15711 
15712 /*
15713  * open is an open cursor, at the moment this has to be removed
15714  */
15715 ECPGOpen: SQL_OPEN cursor_name opt_ecpg_using
15716 		{
15717 			if ($2[0] == ':')
15718 				remove_variable_from_list(&argsinsert, find_variable($2 + 1));
15719 			$$ = $2;
15720 		}
15721 		;
15722 
15723 opt_ecpg_using: /*EMPTY*/	{ $$ = EMPTY; }
15724 		| ecpg_using		{ $$ = $1; }
15725 		;
15726 
15727 ecpg_using:	USING using_list	{ $$ = EMPTY; }
15728 		| using_descriptor		{ $$ = $1; }
15729 		;
15730 
15731 using_descriptor: USING SQL_P SQL_DESCRIPTOR quoted_ident_stringvar
15732 		{
15733 			add_variable_to_head(&argsinsert, descriptor_variable($4,0), &no_indicator);
15734 			$$ = EMPTY;
15735 		}
15736 		| USING SQL_DESCRIPTOR name
15737 		{
15738 			add_variable_to_head(&argsinsert, sqlda_variable($3), &no_indicator);
15739 			$$ = EMPTY;
15740 		}
15741 		;
15742 
15743 into_descriptor: INTO SQL_P SQL_DESCRIPTOR quoted_ident_stringvar
15744 		{
15745 			add_variable_to_head(&argsresult, descriptor_variable($4,1), &no_indicator);
15746 			$$ = EMPTY;
15747 		}
15748 		| INTO SQL_DESCRIPTOR name
15749 		{
15750 			add_variable_to_head(&argsresult, sqlda_variable($3), &no_indicator);
15751 			$$ = EMPTY;
15752 		}
15753 		;
15754 
15755 into_sqlda: INTO name
15756 		{
15757 			add_variable_to_head(&argsresult, sqlda_variable($2), &no_indicator);
15758 			$$ = EMPTY;
15759 		}
15760 		;
15761 
15762 using_list: UsingValue | UsingValue ',' using_list;
15763 
15764 UsingValue: UsingConst
15765 		{
15766 			char *length = mm_alloc(32);
15767 
15768 			sprintf(length, "%d", (int) strlen($1));
15769 			add_variable_to_head(&argsinsert, new_variable($1, ECPGmake_simple_type(ECPGt_const, length, 0), 0), &no_indicator);
15770 		}
15771 		| civar { $$ = EMPTY; }
15772 		| civarind { $$ = EMPTY; }
15773 		;
15774 
15775 UsingConst: Iconst			{ $$ = $1; }
15776 		| '+' Iconst		{ $$ = cat_str(2, mm_strdup("+"), $2); }
15777 		| '-' Iconst		{ $$ = cat_str(2, mm_strdup("-"), $2); }
15778 		| ecpg_fconst		{ $$ = $1; }
15779 		| '+' ecpg_fconst	{ $$ = cat_str(2, mm_strdup("+"), $2); }
15780 		| '-' ecpg_fconst	{ $$ = cat_str(2, mm_strdup("-"), $2); }
15781 		| ecpg_sconst		{ $$ = $1; }
15782 		| ecpg_bconst		{ $$ = $1; }
15783 		| ecpg_xconst		{ $$ = $1; }
15784 		;
15785 
15786 /*
15787  * We accept DESCRIBE [OUTPUT] but do nothing with DESCRIBE INPUT so far.
15788  */
15789 ECPGDescribe: SQL_DESCRIBE INPUT_P prepared_name using_descriptor
15790 	{
15791 		const char *con = connection ? connection : "NULL";
15792 		mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
15793 		$$ = (char *) mm_alloc(sizeof("1, , ") + strlen(con) + strlen($3));
15794 		sprintf($$, "1, %s, %s", con, $3);
15795 	}
15796 	| SQL_DESCRIBE opt_output prepared_name using_descriptor
15797 	{
15798 		const char *con = connection ? connection : "NULL";
15799 		struct variable *var;
15800 
15801 		var = argsinsert->variable;
15802 		remove_variable_from_list(&argsinsert, var);
15803 		add_variable_to_head(&argsresult, var, &no_indicator);
15804 
15805 		$$ = (char *) mm_alloc(sizeof("0, , ") + strlen(con) + strlen($3));
15806 		sprintf($$, "0, %s, %s", con, $3);
15807 	}
15808 	| SQL_DESCRIBE opt_output prepared_name into_descriptor
15809 	{
15810 		const char *con = connection ? connection : "NULL";
15811 		$$ = (char *) mm_alloc(sizeof("0, , ") + strlen(con) + strlen($3));
15812 		sprintf($$, "0, %s, %s", con, $3);
15813 	}
15814 	| SQL_DESCRIBE INPUT_P prepared_name into_sqlda
15815 	{
15816 		const char *con = connection ? connection : "NULL";
15817 		mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
15818 		$$ = (char *) mm_alloc(sizeof("1, , ") + strlen(con) + strlen($3));
15819 		sprintf($$, "1, %s, %s", con, $3);
15820 	}
15821 	| SQL_DESCRIBE opt_output prepared_name into_sqlda
15822 	{
15823 		const char *con = connection ? connection : "NULL";
15824 		$$ = (char *) mm_alloc(sizeof("0, , ") + strlen(con) + strlen($3));
15825 		sprintf($$, "0, %s, %s", con, $3);
15826 	}
15827 	;
15828 
15829 opt_output:	SQL_OUTPUT	{ $$ = mm_strdup("output"); }
15830 	|	/* EMPTY */	{ $$ = EMPTY; }
15831 	;
15832 
15833 /*
15834  * dynamic SQL: descriptor based access
15835  *	originally written by Christof Petig <christof.petig@wtal.de>
15836  *			and Peter Eisentraut <peter.eisentraut@credativ.de>
15837  */
15838 
15839 /*
15840  * allocate a descriptor
15841  */
15842 ECPGAllocateDescr: SQL_ALLOCATE SQL_DESCRIPTOR quoted_ident_stringvar
15843 		{
15844 			add_descriptor($3,connection);
15845 			$$ = $3;
15846 		}
15847 		;
15848 
15849 
15850 /*
15851  * deallocate a descriptor
15852  */
15853 ECPGDeallocateDescr:	DEALLOCATE SQL_DESCRIPTOR quoted_ident_stringvar
15854 		{
15855 			drop_descriptor($3,connection);
15856 			$$ = $3;
15857 		}
15858 		;
15859 
15860 /*
15861  * manipulate a descriptor header
15862  */
15863 
15864 ECPGGetDescriptorHeader: SQL_GET SQL_DESCRIPTOR quoted_ident_stringvar ECPGGetDescHeaderItems
15865 			{  $$ = $3; }
15866 		;
15867 
15868 ECPGGetDescHeaderItems: ECPGGetDescHeaderItem
15869 		| ECPGGetDescHeaderItems ',' ECPGGetDescHeaderItem
15870 		;
15871 
15872 ECPGGetDescHeaderItem: cvariable '=' desc_header_item
15873 			{ push_assignment($1, $3); }
15874 		;
15875 
15876 
15877 ECPGSetDescriptorHeader: SET SQL_DESCRIPTOR quoted_ident_stringvar ECPGSetDescHeaderItems
15878 			{ $$ = $3; }
15879 		;
15880 
15881 ECPGSetDescHeaderItems: ECPGSetDescHeaderItem
15882 		| ECPGSetDescHeaderItems ',' ECPGSetDescHeaderItem
15883 		;
15884 
15885 ECPGSetDescHeaderItem: desc_header_item '=' IntConstVar
15886 		{
15887 			push_assignment($3, $1);
15888 		}
15889 		;
15890 
15891 IntConstVar: Iconst
15892 		{
15893 			char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
15894 
15895 			sprintf(length, "%d", (int) strlen($1));
15896 			new_variable($1, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
15897 			$$ = $1;
15898 		}
15899 		| cvariable
15900 		{
15901 			$$ = $1;
15902 		}
15903 		;
15904 
15905 desc_header_item:	SQL_COUNT			{ $$ = ECPGd_count; }
15906 		;
15907 
15908 /*
15909  * manipulate a descriptor
15910  */
15911 
15912 ECPGGetDescriptor:	SQL_GET SQL_DESCRIPTOR quoted_ident_stringvar VALUE_P IntConstVar ECPGGetDescItems
15913 			{  $$.str = $5; $$.name = $3; }
15914 		;
15915 
15916 ECPGGetDescItems: ECPGGetDescItem
15917 		| ECPGGetDescItems ',' ECPGGetDescItem
15918 		;
15919 
15920 ECPGGetDescItem: cvariable '=' descriptor_item	{ push_assignment($1, $3); };
15921 
15922 
15923 ECPGSetDescriptor:	SET SQL_DESCRIPTOR quoted_ident_stringvar VALUE_P IntConstVar ECPGSetDescItems
15924 			{  $$.str = $5; $$.name = $3; }
15925 		;
15926 
15927 ECPGSetDescItems: ECPGSetDescItem
15928 		| ECPGSetDescItems ',' ECPGSetDescItem
15929 		;
15930 
15931 ECPGSetDescItem: descriptor_item '=' AllConstVar
15932 		{
15933 			push_assignment($3, $1);
15934 		}
15935 		;
15936 
15937 AllConstVar: ecpg_fconst
15938 		{
15939 			char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
15940 
15941 			sprintf(length, "%d", (int) strlen($1));
15942 			new_variable($1, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
15943 			$$ = $1;
15944 		}
15945 
15946 		| IntConstVar
15947 		{
15948 			$$ = $1;
15949 		}
15950 
15951 		| '-' ecpg_fconst
15952 		{
15953 			char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
15954 			char *var = cat2_str(mm_strdup("-"), $2);
15955 
15956 			sprintf(length, "%d", (int) strlen(var));
15957 			new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
15958 			$$ = var;
15959 		}
15960 
15961 		| '-' Iconst
15962 		{
15963 			char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
15964 			char *var = cat2_str(mm_strdup("-"), $2);
15965 
15966 			sprintf(length, "%d", (int) strlen(var));
15967 			new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
15968 			$$ = var;
15969 		}
15970 
15971 		| ecpg_sconst
15972 		{
15973 			char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
15974 			char *var = $1 + 1;
15975 
15976 			var[strlen(var) - 1] = '\0';
15977 			sprintf(length, "%d", (int) strlen(var));
15978 			new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
15979 			$$ = var;
15980 		}
15981 		;
15982 
15983 descriptor_item:	SQL_CARDINALITY			{ $$ = ECPGd_cardinality; }
15984 		| DATA_P				{ $$ = ECPGd_data; }
15985 		| SQL_DATETIME_INTERVAL_CODE		{ $$ = ECPGd_di_code; }
15986 		| SQL_DATETIME_INTERVAL_PRECISION	{ $$ = ECPGd_di_precision; }
15987 		| SQL_INDICATOR				{ $$ = ECPGd_indicator; }
15988 		| SQL_KEY_MEMBER			{ $$ = ECPGd_key_member; }
15989 		| SQL_LENGTH				{ $$ = ECPGd_length; }
15990 		| NAME_P				{ $$ = ECPGd_name; }
15991 		| SQL_NULLABLE				{ $$ = ECPGd_nullable; }
15992 		| SQL_OCTET_LENGTH			{ $$ = ECPGd_octet; }
15993 		| PRECISION				{ $$ = ECPGd_precision; }
15994 		| SQL_RETURNED_LENGTH			{ $$ = ECPGd_length; }
15995 		| SQL_RETURNED_OCTET_LENGTH		{ $$ = ECPGd_ret_octet; }
15996 		| SQL_SCALE				{ $$ = ECPGd_scale; }
15997 		| TYPE_P				{ $$ = ECPGd_type; }
15998 		;
15999 
16000 /*
16001  * set/reset the automatic transaction mode, this needs a different handling
16002  * as the other set commands
16003  */
16004 ECPGSetAutocommit:	SET SQL_AUTOCOMMIT '=' on_off	{ $$ = $4; }
16005 		|  SET SQL_AUTOCOMMIT TO on_off   { $$ = $4; }
16006 		;
16007 
16008 on_off: ON				{ $$ = mm_strdup("on"); }
16009 		| OFF			{ $$ = mm_strdup("off"); }
16010 		;
16011 
16012 /*
16013  * set the actual connection, this needs a different handling as the other
16014  * set commands
16015  */
16016 ECPGSetConnection:	SET CONNECTION TO connection_object { $$ = $4; }
16017 		| SET CONNECTION '=' connection_object { $$ = $4; }
16018 		| SET CONNECTION  connection_object { $$ = $3; }
16019 		;
16020 
16021 /*
16022  * define a new type for embedded SQL
16023  */
16024 ECPGTypedef: TYPE_P
16025 		{
16026 			/* reset this variable so we see if there was */
16027 			/* an initializer specified */
16028 			initializer = 0;
16029 		}
16030 		ECPGColLabelCommon IS var_type opt_array_bounds opt_reference
16031 		{
16032 			add_typedef($3, $6.index1, $6.index2, $5.type_enum, $5.type_dimension, $5.type_index, initializer, *$7 ? 1 : 0);
16033 
16034 			if (auto_create_c == false)
16035 				$$ = 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("*/"));
16036 			else
16037 				$$ = 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(";"));
16038 		}
16039 		;
16040 
16041 opt_reference: SQL_REFERENCE		{ $$ = mm_strdup("reference"); }
16042 		| /*EMPTY*/					{ $$ = EMPTY; }
16043 		;
16044 
16045 /*
16046  * define the type of one variable for embedded SQL
16047  */
16048 ECPGVar: SQL_VAR
16049 		{
16050 			/* reset this variable so we see if there was */
16051 			/* an initializer specified */
16052 			initializer = 0;
16053 		}
16054 		ColLabel IS var_type opt_array_bounds opt_reference
16055 		{
16056 			struct variable *p = find_variable($3);
16057 			char *dimension = $6.index1;
16058 			char *length = $6.index2;
16059 			struct ECPGtype * type;
16060 
16061 			if (($5.type_enum == ECPGt_struct ||
16062 				 $5.type_enum == ECPGt_union) &&
16063 				initializer == 1)
16064 				mmerror(PARSE_ERROR, ET_ERROR, "initializer not allowed in EXEC SQL VAR command");
16065 			else
16066 			{
16067 				adjust_array($5.type_enum, &dimension, &length, $5.type_dimension, $5.type_index, *$7?1:0, false);
16068 
16069 				switch ($5.type_enum)
16070 				{
16071 					case ECPGt_struct:
16072 					case ECPGt_union:
16073 						if (atoi(dimension) < 0)
16074 							type = ECPGmake_struct_type(struct_member_list[struct_level], $5.type_enum, $5.type_str, $5.type_sizeof);
16075 						else
16076 							type = ECPGmake_array_type(ECPGmake_struct_type(struct_member_list[struct_level], $5.type_enum, $5.type_str, $5.type_sizeof), dimension);
16077 						break;
16078 
16079 					case ECPGt_varchar:
16080 						if (atoi(dimension) == -1)
16081 							type = ECPGmake_simple_type($5.type_enum, length, 0);
16082 						else
16083 							type = ECPGmake_array_type(ECPGmake_simple_type($5.type_enum, length, 0), dimension);
16084 						break;
16085 
16086 					case ECPGt_char:
16087 					case ECPGt_unsigned_char:
16088 					case ECPGt_string:
16089 						if (atoi(dimension) == -1)
16090 							type = ECPGmake_simple_type($5.type_enum, length, 0);
16091 						else
16092 							type = ECPGmake_array_type(ECPGmake_simple_type($5.type_enum, length, 0), dimension);
16093 						break;
16094 
16095 					default:
16096 						if (atoi(length) >= 0)
16097 							mmerror(PARSE_ERROR, ET_ERROR, "multidimensional arrays for simple data types are not supported");
16098 
16099 						if (atoi(dimension) < 0)
16100 							type = ECPGmake_simple_type($5.type_enum, mm_strdup("1"), 0);
16101 						else
16102 							type = ECPGmake_array_type(ECPGmake_simple_type($5.type_enum, mm_strdup("1"), 0), dimension);
16103 						break;
16104 				}
16105 
16106 				ECPGfree_type(p->type);
16107 				p->type = type;
16108 			}
16109 
16110 			$$ = 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("*/"));
16111 		}
16112 		;
16113 
16114 /*
16115  * whenever statement: decide what to do in case of error/no data found
16116  * according to SQL standards we lack: SQLSTATE, CONSTRAINT and SQLEXCEPTION
16117  */
16118 ECPGWhenever: SQL_WHENEVER SQL_SQLERROR action
16119 		{
16120 			when_error.code = $<action>3.code;
16121 			when_error.command = $<action>3.command;
16122 			$$ = cat_str(3, mm_strdup("/* exec sql whenever sqlerror "), $3.str, mm_strdup("; */"));
16123 		}
16124 		| SQL_WHENEVER NOT SQL_FOUND action
16125 		{
16126 			when_nf.code = $<action>4.code;
16127 			when_nf.command = $<action>4.command;
16128 			$$ = cat_str(3, mm_strdup("/* exec sql whenever not found "), $4.str, mm_strdup("; */"));
16129 		}
16130 		| SQL_WHENEVER SQL_SQLWARNING action
16131 		{
16132 			when_warn.code = $<action>3.code;
16133 			when_warn.command = $<action>3.command;
16134 			$$ = cat_str(3, mm_strdup("/* exec sql whenever sql_warning "), $3.str, mm_strdup("; */"));
16135 		}
16136 		;
16137 
16138 action : CONTINUE_P
16139 		{
16140 			$<action>$.code = W_NOTHING;
16141 			$<action>$.command = NULL;
16142 			$<action>$.str = mm_strdup("continue");
16143 		}
16144 		| SQL_SQLPRINT
16145 		{
16146 			$<action>$.code = W_SQLPRINT;
16147 			$<action>$.command = NULL;
16148 			$<action>$.str = mm_strdup("sqlprint");
16149 		}
16150 		| SQL_STOP
16151 		{
16152 			$<action>$.code = W_STOP;
16153 			$<action>$.command = NULL;
16154 			$<action>$.str = mm_strdup("stop");
16155 		}
16156 		| SQL_GOTO name
16157 		{
16158 			$<action>$.code = W_GOTO;
16159 			$<action>$.command = mm_strdup($2);
16160 			$<action>$.str = cat2_str(mm_strdup("goto "), $2);
16161 		}
16162 		| SQL_GO TO name
16163 		{
16164 			$<action>$.code = W_GOTO;
16165 			$<action>$.command = mm_strdup($3);
16166 			$<action>$.str = cat2_str(mm_strdup("goto "), $3);
16167 		}
16168 		| DO name '(' c_args ')'
16169 		{
16170 			$<action>$.code = W_DO;
16171 			$<action>$.command = cat_str(4, $2, mm_strdup("("), $4, mm_strdup(")"));
16172 			$<action>$.str = cat2_str(mm_strdup("do"), mm_strdup($<action>$.command));
16173 		}
16174 		| DO SQL_BREAK
16175 		{
16176 			$<action>$.code = W_BREAK;
16177 			$<action>$.command = NULL;
16178 			$<action>$.str = mm_strdup("break");
16179 		}
16180 		| SQL_CALL name '(' c_args ')'
16181 		{
16182 			$<action>$.code = W_DO;
16183 			$<action>$.command = cat_str(4, $2, mm_strdup("("), $4, mm_strdup(")"));
16184 			$<action>$.str = cat2_str(mm_strdup("call"), mm_strdup($<action>$.command));
16185 		}
16186 		| SQL_CALL name
16187 		{
16188 			$<action>$.code = W_DO;
16189 			$<action>$.command = cat2_str($2, mm_strdup("()"));
16190 			$<action>$.str = cat2_str(mm_strdup("call"), mm_strdup($<action>$.command));
16191 		}
16192 		;
16193 
16194 /* some other stuff for ecpg */
16195 
16196 /* additional unreserved keywords */
16197 ECPGKeywords: ECPGKeywords_vanames	{ $$ = $1; }
16198 		| ECPGKeywords_rest	{ $$ = $1; }
16199 		;
16200 
16201 ECPGKeywords_vanames:  SQL_BREAK		{ $$ = mm_strdup("break"); }
16202 		| SQL_CALL						{ $$ = mm_strdup("call"); }
16203 		| SQL_CARDINALITY				{ $$ = mm_strdup("cardinality"); }
16204 		| SQL_COUNT						{ $$ = mm_strdup("count"); }
16205 		| SQL_DATETIME_INTERVAL_CODE	{ $$ = mm_strdup("datetime_interval_code"); }
16206 		| SQL_DATETIME_INTERVAL_PRECISION	{ $$ = mm_strdup("datetime_interval_precision"); }
16207 		| SQL_FOUND						{ $$ = mm_strdup("found"); }
16208 		| SQL_GO						{ $$ = mm_strdup("go"); }
16209 		| SQL_GOTO						{ $$ = mm_strdup("goto"); }
16210 		| SQL_IDENTIFIED				{ $$ = mm_strdup("identified"); }
16211 		| SQL_INDICATOR				{ $$ = mm_strdup("indicator"); }
16212 		| SQL_KEY_MEMBER			{ $$ = mm_strdup("key_member"); }
16213 		| SQL_LENGTH				{ $$ = mm_strdup("length"); }
16214 		| SQL_NULLABLE				{ $$ = mm_strdup("nullable"); }
16215 		| SQL_OCTET_LENGTH			{ $$ = mm_strdup("octet_length"); }
16216 		| SQL_RETURNED_LENGTH		{ $$ = mm_strdup("returned_length"); }
16217 		| SQL_RETURNED_OCTET_LENGTH	{ $$ = mm_strdup("returned_octet_length"); }
16218 		| SQL_SCALE					{ $$ = mm_strdup("scale"); }
16219 		| SQL_SECTION				{ $$ = mm_strdup("section"); }
16220 		| SQL_SQLERROR				{ $$ = mm_strdup("sqlerror"); }
16221 		| SQL_SQLPRINT				{ $$ = mm_strdup("sqlprint"); }
16222 		| SQL_SQLWARNING			{ $$ = mm_strdup("sqlwarning"); }
16223 		| SQL_STOP					{ $$ = mm_strdup("stop"); }
16224 		;
16225 
16226 ECPGKeywords_rest:  SQL_CONNECT		{ $$ = mm_strdup("connect"); }
16227 		| SQL_DESCRIBE				{ $$ = mm_strdup("describe"); }
16228 		| SQL_DISCONNECT			{ $$ = mm_strdup("disconnect"); }
16229 		| SQL_OPEN					{ $$ = mm_strdup("open"); }
16230 		| SQL_VAR					{ $$ = mm_strdup("var"); }
16231 		| SQL_WHENEVER				{ $$ = mm_strdup("whenever"); }
16232 		;
16233 
16234 /* additional keywords that can be SQL type names (but not ECPGColLabels) */
16235 ECPGTypeName:  SQL_BOOL				{ $$ = mm_strdup("bool"); }
16236 		| SQL_LONG					{ $$ = mm_strdup("long"); }
16237 		| SQL_OUTPUT				{ $$ = mm_strdup("output"); }
16238 		| SQL_SHORT					{ $$ = mm_strdup("short"); }
16239 		| SQL_STRUCT				{ $$ = mm_strdup("struct"); }
16240 		| SQL_SIGNED				{ $$ = mm_strdup("signed"); }
16241 		| SQL_UNSIGNED				{ $$ = mm_strdup("unsigned"); }
16242 		;
16243 
16244 symbol: ColLabel					{ $$ = $1; }
16245 		;
16246 
16247 ECPGColId: ecpg_ident				{ $$ = $1; }
16248 		| unreserved_keyword		{ $$ = $1; }
16249 		| col_name_keyword			{ $$ = $1; }
16250 		| ECPGunreserved_interval	{ $$ = $1; }
16251 		| ECPGKeywords				{ $$ = $1; }
16252 		| ECPGCKeywords				{ $$ = $1; }
16253 		| CHAR_P					{ $$ = mm_strdup("char"); }
16254 		| VALUES					{ $$ = mm_strdup("values"); }
16255 		;
16256 
16257 /*
16258  * Name classification hierarchy.
16259  *
16260  * These productions should match those in the core grammar, except that
16261  * we use all_unreserved_keyword instead of unreserved_keyword, and
16262  * where possible include ECPG keywords as well as core keywords.
16263  */
16264 
16265 /* Column identifier --- names that can be column, table, etc names.
16266  */
16267 ColId:	ecpg_ident					{ $$ = $1; }
16268 		| all_unreserved_keyword	{ $$ = $1; }
16269 		| col_name_keyword			{ $$ = $1; }
16270 		| ECPGKeywords				{ $$ = $1; }
16271 		| ECPGCKeywords				{ $$ = $1; }
16272 		| CHAR_P					{ $$ = mm_strdup("char"); }
16273 		| VALUES					{ $$ = mm_strdup("values"); }
16274 		;
16275 
16276 /* Type/function identifier --- names that can be type or function names.
16277  */
16278 type_function_name:	ecpg_ident		{ $$ = $1; }
16279 		| all_unreserved_keyword	{ $$ = $1; }
16280 		| type_func_name_keyword	{ $$ = $1; }
16281 		| ECPGKeywords				{ $$ = $1; }
16282 		| ECPGCKeywords				{ $$ = $1; }
16283 		| ECPGTypeName				{ $$ = $1; }
16284 		;
16285 
16286 /* Column label --- allowed labels in "AS" clauses.
16287  * This presently includes *all* Postgres keywords.
16288  */
16289 ColLabel:  ECPGColLabel				{ $$ = $1; }
16290 		| ECPGTypeName				{ $$ = $1; }
16291 		| CHAR_P					{ $$ = mm_strdup("char"); }
16292 		| CURRENT_P					{ $$ = mm_strdup("current"); }
16293 		| INPUT_P					{ $$ = mm_strdup("input"); }
16294 		| INT_P						{ $$ = mm_strdup("int"); }
16295 		| TO						{ $$ = mm_strdup("to"); }
16296 		| UNION						{ $$ = mm_strdup("union"); }
16297 		| VALUES					{ $$ = mm_strdup("values"); }
16298 		| ECPGCKeywords				{ $$ = $1; }
16299 		| ECPGunreserved_interval	{ $$ = $1; }
16300 		;
16301 
16302 ECPGColLabel:  ECPGColLabelCommon	{ $$ = $1; }
16303 		| unreserved_keyword		{ $$ = $1; }
16304 		| reserved_keyword			{ $$ = $1; }
16305 		| ECPGKeywords_rest			{ $$ = $1; }
16306 		| CONNECTION				{ $$ = mm_strdup("connection"); }
16307 		;
16308 
16309 ECPGColLabelCommon:  ecpg_ident		{ $$ = $1; }
16310 		| col_name_keyword			{ $$ = $1; }
16311 		| type_func_name_keyword	{ $$ = $1; }
16312 		| ECPGKeywords_vanames		{ $$ = $1; }
16313 		;
16314 
16315 ECPGCKeywords: S_AUTO				{ $$ = mm_strdup("auto"); }
16316 		| S_CONST					{ $$ = mm_strdup("const"); }
16317 		| S_EXTERN					{ $$ = mm_strdup("extern"); }
16318 		| S_REGISTER				{ $$ = mm_strdup("register"); }
16319 		| S_STATIC					{ $$ = mm_strdup("static"); }
16320 		| S_TYPEDEF					{ $$ = mm_strdup("typedef"); }
16321 		| S_VOLATILE				{ $$ = mm_strdup("volatile"); }
16322 		;
16323 
16324 /* "Unreserved" keywords --- available for use as any kind of name.
16325  */
16326 
16327 /*
16328  * The following symbols must be excluded from ECPGColLabel and directly
16329  * included into ColLabel to enable C variables to get names from ECPGColLabel:
16330  * DAY_P, HOUR_P, MINUTE_P, MONTH_P, SECOND_P, YEAR_P.
16331  *
16332  * We also have to exclude CONNECTION, CURRENT, and INPUT for various reasons.
16333  * CONNECTION can be added back in all_unreserved_keyword, but CURRENT and
16334  * INPUT are reserved for ecpg purposes.
16335  *
16336  * The mentioned exclusions are done by $replace_line settings in parse.pl.
16337  */
16338 all_unreserved_keyword: unreserved_keyword	{ $$ = $1; }
16339 		| ECPGunreserved_interval			{ $$ = $1; }
16340 		| CONNECTION						{ $$ = mm_strdup("connection"); }
16341 		;
16342 
16343 ECPGunreserved_interval: DAY_P				{ $$ = mm_strdup("day"); }
16344 		| HOUR_P							{ $$ = mm_strdup("hour"); }
16345 		| MINUTE_P							{ $$ = mm_strdup("minute"); }
16346 		| MONTH_P							{ $$ = mm_strdup("month"); }
16347 		| SECOND_P							{ $$ = mm_strdup("second"); }
16348 		| YEAR_P							{ $$ = mm_strdup("year"); }
16349 		;
16350 
16351 
16352 into_list : coutputvariable | into_list ',' coutputvariable
16353 		;
16354 
16355 ecpgstart: SQL_START	{
16356 				reset_variables();
16357 				pacounter = 1;
16358 			}
16359 		;
16360 
16361 c_args: /*EMPTY*/		{ $$ = EMPTY; }
16362 		| c_list		{ $$ = $1; }
16363 		;
16364 
16365 coutputvariable: cvariable indicator
16366 			{ add_variable_to_head(&argsresult, find_variable($1), find_variable($2)); }
16367 		| cvariable
16368 			{ add_variable_to_head(&argsresult, find_variable($1), &no_indicator); }
16369 		;
16370 
16371 
16372 civarind: cvariable indicator
16373 		{
16374 			if (find_variable($2)->type->type == ECPGt_array)
16375 				mmerror(PARSE_ERROR, ET_ERROR, "arrays of indicators are not allowed on input");
16376 
16377 			add_variable_to_head(&argsinsert, find_variable($1), find_variable($2));
16378 			$$ = create_questionmarks($1, false);
16379 		}
16380 		;
16381 
16382 char_civar: char_variable
16383 		{
16384 			char *ptr = strstr($1, ".arr");
16385 
16386 			if (ptr) /* varchar, we need the struct name here, not the struct element */
16387 				*ptr = '\0';
16388 			add_variable_to_head(&argsinsert, find_variable($1), &no_indicator);
16389 			$$ = $1;
16390 		}
16391 		;
16392 
16393 civar: cvariable
16394 		{
16395 			add_variable_to_head(&argsinsert, find_variable($1), &no_indicator);
16396 			$$ = create_questionmarks($1, false);
16397 		}
16398 		;
16399 
16400 indicator: cvariable				{ check_indicator((find_variable($1))->type); $$ = $1; }
16401 		| SQL_INDICATOR cvariable	{ check_indicator((find_variable($2))->type); $$ = $2; }
16402 		| SQL_INDICATOR name		{ check_indicator((find_variable($2))->type); $$ = $2; }
16403 		;
16404 
16405 cvariable:	CVARIABLE
16406 		{
16407 			/* As long as multidimensional arrays are not implemented we have to check for those here */
16408 			char *ptr = $1;
16409 			int brace_open=0, brace = false;
16410 
16411 			for (; *ptr; ptr++)
16412 			{
16413 				switch (*ptr)
16414 				{
16415 					case '[':
16416 							if (brace)
16417 								mmfatal(PARSE_ERROR, "multidimensional arrays for simple data types are not supported");
16418 							brace_open++;
16419 							break;
16420 					case ']':
16421 							brace_open--;
16422 							if (brace_open == 0)
16423 								brace = true;
16424 							break;
16425 					case '\t':
16426 					case ' ':
16427 							break;
16428 					default:
16429 							if (brace_open == 0)
16430 								brace = false;
16431 							break;
16432 				}
16433 			}
16434 			$$ = $1;
16435 		}
16436 		;
16437 
16438 ecpg_param:	PARAM		{ $$ = make_name(); } ;
16439 
16440 ecpg_bconst:	BCONST		{ $$ = make_name(); } ;
16441 
16442 ecpg_fconst:	FCONST		{ $$ = make_name(); } ;
16443 
16444 ecpg_sconst:
16445 		SCONST
16446 		{
16447 			/* could have been input as '' or $$ */
16448 			$$ = (char *)mm_alloc(strlen($1) + 3);
16449 			$$[0]='\'';
16450 			strcpy($$+1, $1);
16451 			$$[strlen($1)+1]='\'';
16452 			$$[strlen($1)+2]='\0';
16453 			free($1);
16454 		}
16455 		| ECONST
16456 		{
16457 			$$ = (char *)mm_alloc(strlen($1) + 4);
16458 			$$[0]='E';
16459 			$$[1]='\'';
16460 			strcpy($$+2, $1);
16461 			$$[strlen($1)+2]='\'';
16462 			$$[strlen($1)+3]='\0';
16463 			free($1);
16464 		}
16465 		| NCONST
16466 		{
16467 			$$ = (char *)mm_alloc(strlen($1) + 4);
16468 			$$[0]='N';
16469 			$$[1]='\'';
16470 			strcpy($$+2, $1);
16471 			$$[strlen($1)+2]='\'';
16472 			$$[strlen($1)+3]='\0';
16473 			free($1);
16474 		}
16475 		| UCONST	{ $$ = $1; }
16476 		| DOLCONST	{ $$ = $1; }
16477 		;
16478 
16479 ecpg_xconst:	XCONST		{ $$ = make_name(); } ;
16480 
16481 ecpg_ident:	IDENT		{ $$ = make_name(); }
16482 		| CSTRING	{ $$ = make3_str(mm_strdup("\""), $1, mm_strdup("\"")); }
16483 		| UIDENT	{ $$ = $1; }
16484 		;
16485 
16486 quoted_ident_stringvar: name
16487 			{ $$ = make3_str(mm_strdup("\""), $1, mm_strdup("\"")); }
16488 		| char_variable
16489 			{ $$ = make3_str(mm_strdup("("), $1, mm_strdup(")")); }
16490 		;
16491 
16492 /*
16493  * C stuff
16494  */
16495 
16496 c_stuff_item: c_anything			{ $$ = $1; }
16497 		| '(' ')'			{ $$ = mm_strdup("()"); }
16498 		| '(' c_stuff ')'
16499 			{ $$ = cat_str(3, mm_strdup("("), $2, mm_strdup(")")); }
16500 		;
16501 
16502 c_stuff: c_stuff_item			{ $$ = $1; }
16503 		| c_stuff c_stuff_item
16504 			{ $$ = cat2_str($1, $2); }
16505 		;
16506 
16507 c_list: c_term				{ $$ = $1; }
16508 		| c_list ',' c_term	{ $$ = cat_str(3, $1, mm_strdup(","), $3); }
16509 		;
16510 
16511 c_term:  c_stuff			{ $$ = $1; }
16512 		| '{' c_list '}'	{ $$ = cat_str(3, mm_strdup("{"), $2, mm_strdup("}")); }
16513 		;
16514 
16515 c_thing:	c_anything		{ $$ = $1; }
16516 		|	'('		{ $$ = mm_strdup("("); }
16517 		|	')'		{ $$ = mm_strdup(")"); }
16518 		|	','		{ $$ = mm_strdup(","); }
16519 		|	';'		{ $$ = mm_strdup(";"); }
16520 		;
16521 
16522 c_anything:  ecpg_ident				{ $$ = $1; }
16523 		| Iconst			{ $$ = $1; }
16524 		| ecpg_fconst			{ $$ = $1; }
16525 		| ecpg_sconst			{ $$ = $1; }
16526 		| '*'				{ $$ = mm_strdup("*"); }
16527 		| '+'				{ $$ = mm_strdup("+"); }
16528 		| '-'				{ $$ = mm_strdup("-"); }
16529 		| '/'				{ $$ = mm_strdup("/"); }
16530 		| '%'				{ $$ = mm_strdup("%"); }
16531 		| NULL_P			{ $$ = mm_strdup("NULL"); }
16532 		| S_ADD				{ $$ = mm_strdup("+="); }
16533 		| S_AND				{ $$ = mm_strdup("&&"); }
16534 		| S_ANYTHING			{ $$ = make_name(); }
16535 		| S_AUTO			{ $$ = mm_strdup("auto"); }
16536 		| S_CONST			{ $$ = mm_strdup("const"); }
16537 		| S_DEC				{ $$ = mm_strdup("--"); }
16538 		| S_DIV				{ $$ = mm_strdup("/="); }
16539 		| S_DOTPOINT			{ $$ = mm_strdup(".*"); }
16540 		| S_EQUAL			{ $$ = mm_strdup("=="); }
16541 		| S_EXTERN			{ $$ = mm_strdup("extern"); }
16542 		| S_INC				{ $$ = mm_strdup("++"); }
16543 		| S_LSHIFT			{ $$ = mm_strdup("<<"); }
16544 		| S_MEMBER			{ $$ = mm_strdup("->"); }
16545 		| S_MEMPOINT			{ $$ = mm_strdup("->*"); }
16546 		| S_MOD				{ $$ = mm_strdup("%="); }
16547 		| S_MUL				{ $$ = mm_strdup("*="); }
16548 		| S_NEQUAL			{ $$ = mm_strdup("!="); }
16549 		| S_OR				{ $$ = mm_strdup("||"); }
16550 		| S_REGISTER			{ $$ = mm_strdup("register"); }
16551 		| S_RSHIFT			{ $$ = mm_strdup(">>"); }
16552 		| S_STATIC			{ $$ = mm_strdup("static"); }
16553 		| S_SUB				{ $$ = mm_strdup("-="); }
16554 		| S_TYPEDEF			{ $$ = mm_strdup("typedef"); }
16555 		| S_VOLATILE			{ $$ = mm_strdup("volatile"); }
16556 		| SQL_BOOL			{ $$ = mm_strdup("bool"); }
16557 		| ENUM_P			{ $$ = mm_strdup("enum"); }
16558 		| HOUR_P			{ $$ = mm_strdup("hour"); }
16559 		| INT_P				{ $$ = mm_strdup("int"); }
16560 		| SQL_LONG			{ $$ = mm_strdup("long"); }
16561 		| MINUTE_P			{ $$ = mm_strdup("minute"); }
16562 		| MONTH_P			{ $$ = mm_strdup("month"); }
16563 		| SECOND_P			{ $$ = mm_strdup("second"); }
16564 		| SQL_SHORT			{ $$ = mm_strdup("short"); }
16565 		| SQL_SIGNED			{ $$ = mm_strdup("signed"); }
16566 		| SQL_STRUCT			{ $$ = mm_strdup("struct"); }
16567 		| SQL_UNSIGNED			{ $$ = mm_strdup("unsigned"); }
16568 		| YEAR_P			{ $$ = mm_strdup("year"); }
16569 		| CHAR_P			{ $$ = mm_strdup("char"); }
16570 		| FLOAT_P			{ $$ = mm_strdup("float"); }
16571 		| TO				{ $$ = mm_strdup("to"); }
16572 		| UNION				{ $$ = mm_strdup("union"); }
16573 		| VARCHAR			{ $$ = mm_strdup("varchar"); }
16574 		| '['				{ $$ = mm_strdup("["); }
16575 		| ']'				{ $$ = mm_strdup("]"); }
16576 		| '='				{ $$ = mm_strdup("="); }
16577 		| ':'				{ $$ = mm_strdup(":"); }
16578 		;
16579 
16580 DeallocateStmt: DEALLOCATE prepared_name                { $$ = $2; }
16581                 | DEALLOCATE PREPARE prepared_name      { $$ = $3; }
16582                 | DEALLOCATE ALL                        { $$ = mm_strdup("all"); }
16583                 | DEALLOCATE PREPARE ALL                { $$ = mm_strdup("all"); }
16584                 ;
16585 
16586 Iresult:        Iconst				{ $$ = $1; }
16587                 | '(' Iresult ')'		{ $$ = cat_str(3, mm_strdup("("), $2, mm_strdup(")")); }
16588                 | Iresult '+' Iresult		{ $$ = cat_str(3, $1, mm_strdup("+"), $3); }
16589                 | Iresult '-' Iresult		{ $$ = cat_str(3, $1, mm_strdup("-"), $3); }
16590                 | Iresult '*' Iresult		{ $$ = cat_str(3, $1, mm_strdup("*"), $3); }
16591                 | Iresult '/' Iresult		{ $$ = cat_str(3, $1, mm_strdup("/"), $3); }
16592                 | Iresult '%' Iresult		{ $$ = cat_str(3, $1, mm_strdup("%"), $3); }
16593                 | ecpg_sconst			{ $$ = $1; }
16594                 | ColId				{ $$ = $1; }
16595 		| ColId '(' var_type ')'        { if (pg_strcasecmp($1, "sizeof") != 0)
16596 							mmerror(PARSE_ERROR, ET_ERROR, "operator not allowed in variable definition");
16597 						  else
16598 							$$ = cat_str(4, $1, mm_strdup("("), $3.type_str, mm_strdup(")"));
16599 						}
16600                 ;
16601 
16602 execute_rest: /* EMPTY */	{ $$ = EMPTY; }
16603 	| ecpg_using opt_ecpg_into  { $$ = EMPTY; }
16604 	| ecpg_into ecpg_using  { $$ = EMPTY; }
16605 	| ecpg_into				{ $$ = EMPTY; }
16606 	;
16607 
16608 ecpg_into: INTO into_list	{ $$ = EMPTY; }
16609 	| into_descriptor		{ $$ = $1; }
16610 	;
16611 
16612 opt_ecpg_into:	/* EMPTY */	{ $$ = EMPTY; }
16613 	| ecpg_into		{ $$ = $1; }
16614 	;
16615 
16616 ecpg_fetch_into: ecpg_into	{ $$ = $1; }
16617 	| using_descriptor
16618 	{
16619 		struct variable *var;
16620 
16621 		var = argsinsert->variable;
16622 		remove_variable_from_list(&argsinsert, var);
16623 		add_variable_to_head(&argsresult, var, &no_indicator);
16624 		$$ = $1;
16625 	}
16626 	;
16627 
16628 opt_ecpg_fetch_into:	/* EMPTY */	{ $$ = EMPTY; }
16629 	| ecpg_fetch_into		{ $$ = $1; }
16630 	;
16631 
16632 %%
16633 
16634 void base_yyerror(const char *error)
16635 {
16636 	/* translator: %s is typically the translation of "syntax error" */
16637 	mmerror(PARSE_ERROR, ET_ERROR, "%s at or near \"%s\"",
16638 			_(error), token_start ? token_start : base_yytext);
16639 }
16640 
parser_init(void)16641 void parser_init(void)
16642 {
16643  /* This function is empty. It only exists for compatibility with the backend parser right now. */
16644 }
16645