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> AlterUserStmt
636 %type <str> AlterUserSetStmt
637 %type <str> DropRoleStmt
638 %type <str> DropUserStmt
639 %type <str> CreateGroupStmt
640 %type <str> AlterGroupStmt
641 %type <str> add_drop
642 %type <str> DropGroupStmt
643 %type <str> CreateSchemaStmt
644 %type <str> OptSchemaName
645 %type <str> OptSchemaEltList
646 %type <str> schema_stmt
647 %type <str> VariableSetStmt
648 %type <str> set_rest
649 %type <str> generic_set
650 %type <str> set_rest_more
651 %type <str> var_name
652 %type <str> var_list
653 %type <str> var_value
654 %type <str> iso_level
655 %type <str> opt_boolean_or_string
656 %type <str> zone_value
657 %type <str> opt_encoding
658 %type <str> NonReservedWord_or_Sconst
659 %type <str> VariableResetStmt
660 %type <str> reset_rest
661 %type <str> generic_reset
662 %type <str> SetResetClause
663 %type <str> FunctionSetResetClause
664 %type <str> VariableShowStmt
665 %type <str> ConstraintsSetStmt
666 %type <str> constraints_set_list
667 %type <str> constraints_set_mode
668 %type <str> CheckPointStmt
669 %type <str> DiscardStmt
670 %type <str> AlterTableStmt
671 %type <str> alter_table_cmds
672 %type <str> alter_table_cmd
673 %type <str> alter_column_default
674 %type <str> opt_drop_behavior
675 %type <str> opt_collate_clause
676 %type <str> alter_using
677 %type <str> replica_identity
678 %type <str> reloptions
679 %type <str> opt_reloptions
680 %type <str> reloption_list
681 %type <str> reloption_elem
682 %type <str> AlterCompositeTypeStmt
683 %type <str> alter_type_cmds
684 %type <str> alter_type_cmd
685 %type <str> ClosePortalStmt
686 %type <str> CopyStmt
687 %type <str> copy_from
688 %type <str> opt_program
689 %type <str> copy_file_name
690 %type <str> copy_options
691 %type <str> copy_opt_list
692 %type <str> copy_opt_item
693 %type <str> opt_binary
694 %type <str> opt_oids
695 %type <str> copy_delimiter
696 %type <str> opt_using
697 %type <str> copy_generic_opt_list
698 %type <str> copy_generic_opt_elem
699 %type <str> copy_generic_opt_arg
700 %type <str> copy_generic_opt_arg_list
701 %type <str> copy_generic_opt_arg_list_item
702 %type <str> CreateStmt
703 %type <str> OptTemp
704 %type <str> OptTableElementList
705 %type <str> OptTypedTableElementList
706 %type <str> TableElementList
707 %type <str> TypedTableElementList
708 %type <str> TableElement
709 %type <str> TypedTableElement
710 %type <str> columnDef
711 %type <str> columnOptions
712 %type <str> ColQualList
713 %type <str> ColConstraint
714 %type <str> ColConstraintElem
715 %type <str> ConstraintAttr
716 %type <str> TableLikeClause
717 %type <str> TableLikeOptionList
718 %type <str> TableLikeOption
719 %type <str> TableConstraint
720 %type <str> ConstraintElem
721 %type <str> opt_no_inherit
722 %type <str> opt_column_list
723 %type <str> columnList
724 %type <str> columnElem
725 %type <str> key_match
726 %type <str> ExclusionConstraintList
727 %type <str> ExclusionConstraintElem
728 %type <str> ExclusionWhereClause
729 %type <str> key_actions
730 %type <str> key_update
731 %type <str> key_delete
732 %type <str> key_action
733 %type <str> OptInherit
734 %type <str> OptWith
735 %type <str> OnCommitOption
736 %type <str> OptTableSpace
737 %type <str> OptConsTableSpace
738 %type <str> ExistingIndex
739 %type <str> create_as_target
740 %type <str> opt_with_data
741 %type <str> CreateMatViewStmt
742 %type <str> create_mv_target
743 %type <str> OptNoLog
744 %type <str> RefreshMatViewStmt
745 %type <str> CreateSeqStmt
746 %type <str> AlterSeqStmt
747 %type <str> OptSeqOptList
748 %type <str> SeqOptList
749 %type <str> SeqOptElem
750 %type <str> opt_by
751 %type <str> NumericOnly
752 %type <str> NumericOnly_list
753 %type <str> CreatePLangStmt
754 %type <str> opt_trusted
755 %type <str> handler_name
756 %type <str> opt_inline_handler
757 %type <str> validator_clause
758 %type <str> opt_validator
759 %type <str> DropPLangStmt
760 %type <str> opt_procedural
761 %type <str> CreateTableSpaceStmt
762 %type <str> OptTableSpaceOwner
763 %type <str> DropTableSpaceStmt
764 %type <str> CreateExtensionStmt
765 %type <str> create_extension_opt_list
766 %type <str> create_extension_opt_item
767 %type <str> AlterExtensionStmt
768 %type <str> alter_extension_opt_list
769 %type <str> alter_extension_opt_item
770 %type <str> AlterExtensionContentsStmt
771 %type <str> CreateFdwStmt
772 %type <str> fdw_option
773 %type <str> fdw_options
774 %type <str> opt_fdw_options
775 %type <str> DropFdwStmt
776 %type <str> AlterFdwStmt
777 %type <str> create_generic_options
778 %type <str> generic_option_list
779 %type <str> alter_generic_options
780 %type <str> alter_generic_option_list
781 %type <str> alter_generic_option_elem
782 %type <str> generic_option_elem
783 %type <str> generic_option_name
784 %type <str> generic_option_arg
785 %type <str> CreateForeignServerStmt
786 %type <str> opt_type
787 %type <str> foreign_server_version
788 %type <str> opt_foreign_server_version
789 %type <str> DropForeignServerStmt
790 %type <str> AlterForeignServerStmt
791 %type <str> CreateForeignTableStmt
792 %type <str> AlterForeignTableStmt
793 %type <str> ImportForeignSchemaStmt
794 %type <str> import_qualification_type
795 %type <str> import_qualification
796 %type <str> CreateUserMappingStmt
797 %type <str> auth_ident
798 %type <str> DropUserMappingStmt
799 %type <str> AlterUserMappingStmt
800 %type <str> CreatePolicyStmt
801 %type <str> AlterPolicyStmt
802 %type <str> DropPolicyStmt
803 %type <str> RowSecurityOptionalExpr
804 %type <str> RowSecurityOptionalWithCheck
805 %type <str> RowSecurityDefaultToRole
806 %type <str> RowSecurityOptionalToRole
807 %type <str> RowSecurityDefaultForCmd
808 %type <str> row_security_cmd
809 %type <str> CreateAmStmt
810 %type <str> CreateTrigStmt
811 %type <str> TriggerActionTime
812 %type <str> TriggerEvents
813 %type <str> TriggerOneEvent
814 %type <str> TriggerForSpec
815 %type <str> TriggerForOptEach
816 %type <str> TriggerForType
817 %type <str> TriggerWhen
818 %type <str> TriggerFuncArgs
819 %type <str> TriggerFuncArg
820 %type <str> OptConstrFromTable
821 %type <str> ConstraintAttributeSpec
822 %type <str> ConstraintAttributeElem
823 %type <str> DropTrigStmt
824 %type <str> CreateEventTrigStmt
825 %type <str> event_trigger_when_list
826 %type <str> event_trigger_when_item
827 %type <str> event_trigger_value_list
828 %type <str> AlterEventTrigStmt
829 %type <str> enable_trigger
830 %type <str> CreateAssertStmt
831 %type <str> DropAssertStmt
832 %type <str> DefineStmt
833 %type <str> definition
834 %type <str> def_list
835 %type <str> def_elem
836 %type <str> def_arg
837 %type <str> old_aggr_definition
838 %type <str> old_aggr_list
839 %type <str> old_aggr_elem
840 %type <str> opt_enum_val_list
841 %type <str> enum_val_list
842 %type <str> AlterEnumStmt
843 %type <str> opt_if_not_exists
844 %type <str> CreateOpClassStmt
845 %type <str> opclass_item_list
846 %type <str> opclass_item
847 %type <str> opt_default
848 %type <str> opt_opfamily
849 %type <str> opclass_purpose
850 %type <str> opt_recheck
851 %type <str> CreateOpFamilyStmt
852 %type <str> AlterOpFamilyStmt
853 %type <str> opclass_drop_list
854 %type <str> opclass_drop
855 %type <str> DropOpClassStmt
856 %type <str> DropOpFamilyStmt
857 %type <str> DropOwnedStmt
858 %type <str> ReassignOwnedStmt
859 %type <str> DropStmt
860 %type <str> drop_type
861 %type <str> any_name_list
862 %type <str> any_name
863 %type <str> attrs
864 %type <str> type_name_list
865 %type <str> TruncateStmt
866 %type <str> opt_restart_seqs
867 %type <str> CommentStmt
868 %type <str> comment_type
869 %type <str> comment_text
870 %type <str> SecLabelStmt
871 %type <str> opt_provider
872 %type <str> security_label_type
873 %type <str> security_label
874 %type <str> FetchStmt
875 %type <str> fetch_args
876 %type <str> from_in
877 %type <str> opt_from_in
878 %type <str> GrantStmt
879 %type <str> RevokeStmt
880 %type <str> privileges
881 %type <str> privilege_list
882 %type <str> privilege
883 %type <str> privilege_target
884 %type <str> grantee_list
885 %type <str> grantee
886 %type <str> opt_grant_grant_option
887 %type <str> function_with_argtypes_list
888 %type <str> function_with_argtypes
889 %type <str> GrantRoleStmt
890 %type <str> RevokeRoleStmt
891 %type <str> opt_grant_admin_option
892 %type <str> opt_granted_by
893 %type <str> AlterDefaultPrivilegesStmt
894 %type <str> DefACLOptionList
895 %type <str> DefACLOption
896 %type <str> DefACLAction
897 %type <str> defacl_privilege_target
898 %type <str> IndexStmt
899 %type <str> opt_unique
900 %type <str> opt_concurrently
901 %type <str> opt_index_name
902 %type <str> access_method_clause
903 %type <str> index_params
904 %type <str> index_elem
905 %type <str> opt_collate
906 %type <str> opt_class
907 %type <str> opt_asc_desc
908 %type <str> opt_nulls_order
909 %type <str> CreateFunctionStmt
910 %type <str> opt_or_replace
911 %type <str> func_args
912 %type <str> func_args_list
913 %type <str> func_args_with_defaults
914 %type <str> func_args_with_defaults_list
915 %type <str> func_arg
916 %type <str> arg_class
917 %type <str> param_name
918 %type <str> func_return
919 %type <str> func_type
920 %type <str> func_arg_with_default
921 %type <str> aggr_arg
922 %type <str> aggr_args
923 %type <str> aggr_args_list
924 %type <str> createfunc_opt_list
925 %type <str> common_func_opt_item
926 %type <str> createfunc_opt_item
927 %type <str> func_as
928 %type <str> transform_type_list
929 %type <str> opt_definition
930 %type <str> table_func_column
931 %type <str> table_func_column_list
932 %type <str> AlterFunctionStmt
933 %type <str> alterfunc_opt_list
934 %type <str> opt_restrict
935 %type <str> RemoveFuncStmt
936 %type <str> RemoveAggrStmt
937 %type <str> RemoveOperStmt
938 %type <str> oper_argtypes
939 %type <str> any_operator
940 %type <str> DoStmt
941 %type <str> dostmt_opt_list
942 %type <str> dostmt_opt_item
943 %type <str> CreateCastStmt
944 %type <str> cast_context
945 %type <str> DropCastStmt
946 %type <str> opt_if_exists
947 %type <str> CreateTransformStmt
948 %type <str> transform_element_list
949 %type <str> DropTransformStmt
950 %type <str> ReindexStmt
951 %type <str> reindex_target_type
952 %type <str> reindex_target_multitable
953 %type <str> reindex_option_list
954 %type <str> reindex_option_elem
955 %type <str> AlterTblSpcStmt
956 %type <str> RenameStmt
957 %type <str> opt_column
958 %type <str> opt_set_data
959 %type <str> AlterObjectDependsStmt
960 %type <str> AlterObjectSchemaStmt
961 %type <str> AlterOperatorStmt
962 %type <str> operator_def_list
963 %type <str> operator_def_elem
964 %type <str> AlterOwnerStmt
965 %type <str> RuleStmt
966 %type <str> RuleActionList
967 %type <str> RuleActionMulti
968 %type <str> RuleActionStmt
969 %type <str> RuleActionStmtOrEmpty
970 %type <str> event
971 %type <str> opt_instead
972 %type <str> DropRuleStmt
973 %type <str> NotifyStmt
974 %type <str> notify_payload
975 %type <str> ListenStmt
976 %type <str> UnlistenStmt
977 %type <str> TransactionStmt
978 %type <str> opt_transaction
979 %type <str> transaction_mode_item
980 %type <str> transaction_mode_list
981 %type <str> transaction_mode_list_or_empty
982 %type <str> ViewStmt
983 %type <str> opt_check_option
984 %type <str> LoadStmt
985 %type <str> CreatedbStmt
986 %type <str> createdb_opt_list
987 %type <str> createdb_opt_items
988 %type <str> createdb_opt_item
989 %type <str> createdb_opt_name
990 %type <str> opt_equal
991 %type <str> AlterDatabaseStmt
992 %type <str> AlterDatabaseSetStmt
993 %type <str> DropdbStmt
994 %type <str> AlterSystemStmt
995 %type <str> CreateDomainStmt
996 %type <str> AlterDomainStmt
997 %type <str> opt_as
998 %type <str> AlterTSDictionaryStmt
999 %type <str> AlterTSConfigurationStmt
1000 %type <str> any_with
1001 %type <str> CreateConversionStmt
1002 %type <str> ClusterStmt
1003 %type <str> cluster_index_specification
1004 %type <str> VacuumStmt
1005 %type <str> vacuum_option_list
1006 %type <str> vacuum_option_elem
1007 %type <str> AnalyzeStmt
1008 %type <str> analyze_keyword
1009 %type <str> opt_verbose
1010 %type <str> opt_full
1011 %type <str> opt_freeze
1012 %type <str> opt_name_list
1013 %type <str> ExplainStmt
1014 %type <str> ExplainableStmt
1015 %type <str> explain_option_list
1016 %type <str> explain_option_elem
1017 %type <str> explain_option_name
1018 %type <str> explain_option_arg
1019 %type <prep> PrepareStmt
1020 %type <str> prep_type_clause
1021 %type <str> PreparableStmt
1022 %type <str> ExecuteStmt
1023 %type <str> execute_param_clause
1024 %type <str> InsertStmt
1025 %type <str> insert_target
1026 %type <str> insert_rest
1027 %type <str> insert_column_list
1028 %type <str> insert_column_item
1029 %type <str> opt_on_conflict
1030 %type <str> opt_conf_expr
1031 %type <str> returning_clause
1032 %type <str> DeleteStmt
1033 %type <str> using_clause
1034 %type <str> LockStmt
1035 %type <str> opt_lock
1036 %type <str> lock_type
1037 %type <str> opt_nowait
1038 %type <str> opt_nowait_or_skip
1039 %type <str> UpdateStmt
1040 %type <str> set_clause_list
1041 %type <str> set_clause
1042 %type <str> single_set_clause
1043 %type <str> multiple_set_clause
1044 %type <str> set_target
1045 %type <str> set_target_list
1046 %type <str> DeclareCursorStmt
1047 %type <str> cursor_name
1048 %type <str> cursor_options
1049 %type <str> opt_hold
1050 %type <str> SelectStmt
1051 %type <str> select_with_parens
1052 %type <str> select_no_parens
1053 %type <str> select_clause
1054 %type <str> simple_select
1055 %type <str> with_clause
1056 %type <str> cte_list
1057 %type <str> common_table_expr
1058 %type <str> opt_with_clause
1059 %type <str> into_clause
1060 %type <str> OptTempTableName
1061 %type <str> opt_table
1062 %type <str> all_or_distinct
1063 %type <str> distinct_clause
1064 %type <str> opt_all_clause
1065 %type <str> opt_sort_clause
1066 %type <str> sort_clause
1067 %type <str> sortby_list
1068 %type <str> sortby
1069 %type <str> select_limit
1070 %type <str> opt_select_limit
1071 %type <str> limit_clause
1072 %type <str> offset_clause
1073 %type <str> select_limit_value
1074 %type <str> select_offset_value
1075 %type <str> select_fetch_first_value
1076 %type <str> I_or_F_const
1077 %type <str> row_or_rows
1078 %type <str> first_or_next
1079 %type <str> group_clause
1080 %type <str> group_by_list
1081 %type <str> group_by_item
1082 %type <str> empty_grouping_set
1083 %type <str> rollup_clause
1084 %type <str> cube_clause
1085 %type <str> grouping_sets_clause
1086 %type <str> having_clause
1087 %type <str> for_locking_clause
1088 %type <str> opt_for_locking_clause
1089 %type <str> for_locking_items
1090 %type <str> for_locking_item
1091 %type <str> for_locking_strength
1092 %type <str> locked_rels_list
1093 %type <str> values_clause
1094 %type <str> from_clause
1095 %type <str> from_list
1096 %type <str> table_ref
1097 %type <str> joined_table
1098 %type <str> alias_clause
1099 %type <str> opt_alias_clause
1100 %type <str> func_alias_clause
1101 %type <str> join_type
1102 %type <str> join_outer
1103 %type <str> join_qual
1104 %type <str> relation_expr
1105 %type <str> relation_expr_list
1106 %type <str> relation_expr_opt_alias
1107 %type <str> tablesample_clause
1108 %type <str> opt_repeatable_clause
1109 %type <str> func_table
1110 %type <str> rowsfrom_item
1111 %type <str> rowsfrom_list
1112 %type <str> opt_col_def_list
1113 %type <str> opt_ordinality
1114 %type <str> where_clause
1115 %type <str> where_or_current_clause
1116 %type <str> OptTableFuncElementList
1117 %type <str> TableFuncElementList
1118 %type <str> TableFuncElement
1119 %type <str> Typename
1120 %type <index> opt_array_bounds
1121 %type <str> SimpleTypename
1122 %type <str> ConstTypename
1123 %type <str> GenericType
1124 %type <str> opt_type_modifiers
1125 %type <str> Numeric
1126 %type <str> opt_float
1127 %type <str> Bit
1128 %type <str> ConstBit
1129 %type <str> BitWithLength
1130 %type <str> BitWithoutLength
1131 %type <str> Character
1132 %type <str> ConstCharacter
1133 %type <str> CharacterWithLength
1134 %type <str> CharacterWithoutLength
1135 %type <str> character
1136 %type <str> opt_varying
1137 %type <str> opt_charset
1138 %type <str> ConstDatetime
1139 %type <str> ConstInterval
1140 %type <str> opt_timezone
1141 %type <str> opt_interval
1142 %type <str> interval_second
1143 %type <str> a_expr
1144 %type <str> b_expr
1145 %type <str> c_expr
1146 %type <str> func_application
1147 %type <str> func_expr
1148 %type <str> func_expr_windowless
1149 %type <str> func_expr_common_subexpr
1150 %type <str> xml_root_version
1151 %type <str> opt_xml_root_standalone
1152 %type <str> xml_attributes
1153 %type <str> xml_attribute_list
1154 %type <str> xml_attribute_el
1155 %type <str> document_or_content
1156 %type <str> xml_whitespace_option
1157 %type <str> xmlexists_argument
1158 %type <str> within_group_clause
1159 %type <str> filter_clause
1160 %type <str> window_clause
1161 %type <str> window_definition_list
1162 %type <str> window_definition
1163 %type <str> over_clause
1164 %type <str> window_specification
1165 %type <str> opt_existing_window_name
1166 %type <str> opt_partition_clause
1167 %type <str> opt_frame_clause
1168 %type <str> frame_extent
1169 %type <str> frame_bound
1170 %type <str> row
1171 %type <str> explicit_row
1172 %type <str> implicit_row
1173 %type <str> sub_type
1174 %type <str> all_Op
1175 %type <str> MathOp
1176 %type <str> qual_Op
1177 %type <str> qual_all_Op
1178 %type <str> subquery_Op
1179 %type <str> expr_list
1180 %type <str> func_arg_list
1181 %type <str> func_arg_expr
1182 %type <str> type_list
1183 %type <str> array_expr
1184 %type <str> array_expr_list
1185 %type <str> extract_list
1186 %type <str> extract_arg
1187 %type <str> overlay_list
1188 %type <str> overlay_placing
1189 %type <str> position_list
1190 %type <str> substr_list
1191 %type <str> substr_from
1192 %type <str> substr_for
1193 %type <str> trim_list
1194 %type <str> in_expr
1195 %type <str> case_expr
1196 %type <str> when_clause_list
1197 %type <str> when_clause
1198 %type <str> case_default
1199 %type <str> case_arg
1200 %type <str> columnref
1201 %type <str> indirection_el
1202 %type <str> opt_slice_bound
1203 %type <str> indirection
1204 %type <str> opt_indirection
1205 %type <str> opt_asymmetric
1206 %type <str> ctext_expr
1207 %type <str> ctext_expr_list
1208 %type <str> ctext_row
1209 %type <str> opt_target_list
1210 %type <str> target_list
1211 %type <str> target_el
1212 %type <str> qualified_name_list
1213 %type <str> qualified_name
1214 %type <str> name_list
1215 %type <str> name
1216 %type <str> database_name
1217 %type <str> access_method
1218 %type <str> attr_name
1219 %type <str> index_name
1220 %type <str> file_name
1221 %type <str> func_name
1222 %type <str> AexprConst
1223 %type <str> Iconst
1224 %type <str> SignedIconst
1225 %type <str> RoleId
1226 %type <str> RoleSpec
1227 %type <str> role_list
1228 %type <str> NonReservedWord
1229 %type <str> unreserved_keyword
1230 %type <str> col_name_keyword
1231 %type <str> type_func_name_keyword
1232 %type <str> reserved_keyword
1233 /* ecpgtype */
1234 /* src/interfaces/ecpg/preproc/ecpg.type */
1235 %type <str> ECPGAllocateDescr
1236 %type <str> ECPGCKeywords
1237 %type <str> ECPGColId
1238 %type <str> ECPGColLabel
1239 %type <str> ECPGColLabelCommon
1240 %type <str> ECPGConnect
1241 %type <str> ECPGCursorStmt
1242 %type <str> ECPGDeallocateDescr
1243 %type <str> ECPGDeclaration
1244 %type <str> ECPGDeclare
1245 %type <str> ECPGDescribe
1246 %type <str> ECPGDisconnect
1247 %type <str> ECPGExecuteImmediateStmt
1248 %type <str> ECPGFree
1249 %type <str> ECPGGetDescHeaderItem
1250 %type <str> ECPGGetDescItem
1251 %type <str> ECPGGetDescriptorHeader
1252 %type <str> ECPGKeywords
1253 %type <str> ECPGKeywords_rest
1254 %type <str> ECPGKeywords_vanames
1255 %type <str> ECPGOpen
1256 %type <str> ECPGSetAutocommit
1257 %type <str> ECPGSetConnection
1258 %type <str> ECPGSetDescHeaderItem
1259 %type <str> ECPGSetDescItem
1260 %type <str> ECPGSetDescriptorHeader
1261 %type <str> ECPGTypeName
1262 %type <str> ECPGTypedef
1263 %type <str> ECPGVar
1264 %type <str> ECPGVarDeclaration
1265 %type <str> ECPGWhenever
1266 %type <str> ECPGunreserved_interval
1267 %type <str> UsingConst
1268 %type <str> UsingValue
1269 %type <str> all_unreserved_keyword
1270 %type <str> c_anything
1271 %type <str> c_args
1272 %type <str> c_list
1273 %type <str> c_stuff
1274 %type <str> c_stuff_item
1275 %type <str> c_term
1276 %type <str> c_thing
1277 %type <str> char_variable
1278 %type <str> char_civar
1279 %type <str> civar
1280 %type <str> civarind
1281 %type <str> ColId
1282 %type <str> ColLabel
1283 %type <str> connect_options
1284 %type <str> connection_object
1285 %type <str> connection_target
1286 %type <str> coutputvariable
1287 %type <str> cvariable
1288 %type <str> db_prefix
1289 %type <str> CreateAsStmt
1290 %type <str> DeallocateStmt
1291 %type <str> dis_name
1292 %type <str> ecpg_bconst
1293 %type <str> ecpg_fconst
1294 %type <str> ecpg_ident
1295 %type <str> ecpg_interval
1296 %type <str> ecpg_into
1297 %type <str> ecpg_fetch_into
1298 %type <str> ecpg_param
1299 %type <str> ecpg_sconst
1300 %type <str> ecpg_using
1301 %type <str> ecpg_xconst
1302 %type <str> enum_definition
1303 %type <str> enum_type
1304 %type <str> execstring
1305 %type <str> execute_rest
1306 %type <str> indicator
1307 %type <str> into_descriptor
1308 %type <str> into_sqlda
1309 %type <str> Iresult
1310 %type <str> on_off
1311 %type <str> opt_bit_field
1312 %type <str> opt_connection_name
1313 %type <str> opt_database_name
1314 %type <str> opt_ecpg_into
1315 %type <str> opt_ecpg_fetch_into
1316 %type <str> opt_ecpg_using
1317 %type <str> opt_initializer
1318 %type <str> opt_options
1319 %type <str> opt_output
1320 %type <str> opt_pointer
1321 %type <str> opt_port
1322 %type <str> opt_reference
1323 %type <str> opt_scale
1324 %type <str> opt_server
1325 %type <str> opt_user
1326 %type <str> opt_opt_value
1327 %type <str> ora_user
1328 %type <str> precision
1329 %type <str> prepared_name
1330 %type <str> quoted_ident_stringvar
1331 %type <str> s_struct_union
1332 %type <str> server
1333 %type <str> server_name
1334 %type <str> single_vt_declaration
1335 %type <str> storage_clause
1336 %type <str> storage_declaration
1337 %type <str> storage_modifier
1338 %type <str> struct_union_type
1339 %type <str> struct_union_type_with_symbol
1340 %type <str> symbol
1341 %type <str> type_declaration
1342 %type <str> type_function_name
1343 %type <str> user_name
1344 %type <str> using_descriptor
1345 %type <str> var_declaration
1346 %type <str> var_type_declarations
1347 %type <str> variable
1348 %type <str> variable_declarations
1349 %type <str> variable_list
1350 %type <str> vt_declarations
1351 
1352 %type <str> Op
1353 %type <str> IntConstVar
1354 %type <str> AllConstVar
1355 %type <str> CSTRING
1356 %type <str> CPP_LINE
1357 %type <str> CVARIABLE
1358 %type <str> DOLCONST
1359 %type <str> ECONST
1360 %type <str> NCONST
1361 %type <str> SCONST
1362 %type <str> UCONST
1363 %type <str> UIDENT
1364 
1365 %type  <struct_union> s_struct_union_symbol
1366 
1367 %type  <descriptor> ECPGGetDescriptor
1368 %type  <descriptor> ECPGSetDescriptor
1369 
1370 %type  <type_enum> simple_type
1371 %type  <type_enum> signed_type
1372 %type  <type_enum> unsigned_type
1373 
1374 %type  <dtype_enum> descriptor_item
1375 %type  <dtype_enum> desc_header_item
1376 
1377 %type  <type>   var_type
1378 
1379 %type  <action> action
1380 /* orig_tokens */
1381  %token IDENT FCONST SCONST BCONST XCONST Op
1382  %token ICONST PARAM
1383  %token TYPECAST DOT_DOT COLON_EQUALS EQUALS_GREATER
1384  %token LESS_EQUALS GREATER_EQUALS NOT_EQUALS
1385 
1386 
1387 
1388 
1389 
1390 
1391 
1392 
1393 
1394  %token ABORT_P ABSOLUTE_P ACCESS ACTION ADD_P ADMIN AFTER
1395  AGGREGATE ALL ALSO ALTER ALWAYS ANALYSE ANALYZE AND ANY ARRAY AS ASC
1396  ASSERTION ASSIGNMENT ASYMMETRIC AT ATTRIBUTE AUTHORIZATION
1397 
1398  BACKWARD BEFORE BEGIN_P BETWEEN BIGINT BINARY BIT
1399  BOOLEAN_P BOTH BY
1400 
1401  CACHE CALLED CASCADE CASCADED CASE CAST CATALOG_P CHAIN CHAR_P
1402  CHARACTER CHARACTERISTICS CHECK CHECKPOINT CLASS CLOSE
1403  CLUSTER COALESCE COLLATE COLLATION COLUMN COMMENT COMMENTS COMMIT
1404  COMMITTED CONCURRENTLY CONFIGURATION CONFLICT CONNECTION CONSTRAINT
1405  CONSTRAINTS CONTENT_P CONTINUE_P CONVERSION_P COPY COST CREATE
1406  CROSS CSV CUBE CURRENT_P
1407  CURRENT_CATALOG CURRENT_DATE CURRENT_ROLE CURRENT_SCHEMA
1408  CURRENT_TIME CURRENT_TIMESTAMP CURRENT_USER CURSOR CYCLE
1409 
1410  DATA_P DATABASE DAY_P DEALLOCATE DEC DECIMAL_P DECLARE DEFAULT DEFAULTS
1411  DEFERRABLE DEFERRED DEFINER DELETE_P DELIMITER DELIMITERS DEPENDS DESC
1412  DICTIONARY DISABLE_P DISCARD DISTINCT DO DOCUMENT_P DOMAIN_P DOUBLE_P DROP
1413 
1414  EACH ELSE ENABLE_P ENCODING ENCRYPTED END_P ENUM_P ESCAPE EVENT EXCEPT
1415  EXCLUDE EXCLUDING EXCLUSIVE EXECUTE EXISTS EXPLAIN
1416  EXTENSION EXTERNAL EXTRACT
1417 
1418  FALSE_P FAMILY FETCH FILTER FIRST_P FLOAT_P FOLLOWING FOR
1419  FORCE FOREIGN FORWARD FREEZE FROM FULL FUNCTION FUNCTIONS
1420 
1421  GLOBAL GRANT GRANTED GREATEST GROUP_P GROUPING
1422 
1423  HANDLER HAVING HEADER_P HOLD HOUR_P
1424 
1425  IDENTITY_P IF_P ILIKE IMMEDIATE IMMUTABLE IMPLICIT_P IMPORT_P IN_P
1426  INCLUDING INCREMENT INDEX INDEXES INHERIT INHERITS INITIALLY INLINE_P
1427  INNER_P INOUT INPUT_P INSENSITIVE INSERT INSTEAD INT_P INTEGER
1428  INTERSECT INTERVAL INTO INVOKER IS ISNULL ISOLATION
1429 
1430  JOIN
1431 
1432  KEY
1433 
1434  LABEL LANGUAGE LARGE_P LAST_P LATERAL_P
1435  LEADING LEAKPROOF LEAST LEFT LEVEL LIKE LIMIT LISTEN LOAD LOCAL
1436  LOCALTIME LOCALTIMESTAMP LOCATION LOCK_P LOCKED LOGGED
1437 
1438  MAPPING MATCH MATERIALIZED MAXVALUE METHOD MINUTE_P MINVALUE MODE MONTH_P MOVE
1439 
1440  NAME_P NAMES NATIONAL NATURAL NCHAR NEXT NO NONE
1441  NOT NOTHING NOTIFY NOTNULL NOWAIT NULL_P NULLIF
1442  NULLS_P NUMERIC
1443 
1444  OBJECT_P OF OFF OFFSET OIDS ON ONLY OPERATOR OPTION OPTIONS OR
1445  ORDER ORDINALITY OUT_P OUTER_P OVER OVERLAPS OVERLAY OWNED OWNER
1446 
1447  PARALLEL PARSER PARTIAL PARTITION PASSING PASSWORD PLACING PLANS POLICY
1448  POSITION PRECEDING PRECISION PRESERVE PREPARE PREPARED PRIMARY
1449  PRIOR PRIVILEGES PROCEDURAL PROCEDURE PROGRAM
1450 
1451  QUOTE
1452 
1453  RANGE READ REAL REASSIGN RECHECK RECURSIVE REF REFERENCES REFRESH REINDEX
1454  RELATIVE_P RELEASE RENAME REPEATABLE REPLACE REPLICA
1455  RESET RESTART RESTRICT RETURNING RETURNS REVOKE RIGHT ROLE ROLLBACK ROLLUP
1456  ROW ROWS RULE
1457 
1458  SAVEPOINT SCHEMA SCROLL SEARCH SECOND_P SECURITY SELECT SEQUENCE SEQUENCES
1459  SERIALIZABLE SERVER SESSION SESSION_USER SET SETS SETOF SHARE SHOW
1460  SIMILAR SIMPLE SKIP SMALLINT SNAPSHOT SOME SQL_P STABLE STANDALONE_P START
1461  STATEMENT STATISTICS STDIN STDOUT STORAGE STRICT_P STRIP_P SUBSTRING
1462  SYMMETRIC SYSID SYSTEM_P
1463 
1464  TABLE TABLES TABLESAMPLE TABLESPACE TEMP TEMPLATE TEMPORARY TEXT_P THEN
1465  TIME TIMESTAMP TO TRAILING TRANSACTION TRANSFORM TREAT TRIGGER TRIM TRUE_P
1466  TRUNCATE TRUSTED TYPE_P TYPES_P
1467 
1468  UNBOUNDED UNCOMMITTED UNENCRYPTED UNION UNIQUE UNKNOWN UNLISTEN UNLOGGED
1469  UNTIL UPDATE USER USING
1470 
1471  VACUUM VALID VALIDATE VALIDATOR VALUE_P VALUES VARCHAR VARIADIC VARYING
1472  VERBOSE VERSION_P VIEW VIEWS VOLATILE
1473 
1474  WHEN WHERE WHITESPACE_P WINDOW WITH WITHIN WITHOUT WORK WRAPPER WRITE
1475 
1476  XML_P XMLATTRIBUTES XMLCONCAT XMLELEMENT XMLEXISTS XMLFOREST XMLPARSE
1477  XMLPI XMLROOT XMLSERIALIZE
1478 
1479  YEAR_P YES_P
1480 
1481  ZONE
1482 
1483 
1484 
1485 
1486 
1487 
1488 
1489 
1490 
1491 
1492 
1493  %token NOT_LA NULLS_LA WITH_LA
1494 
1495 
1496 
1497  %nonassoc SET
1498  %left UNION EXCEPT
1499  %left INTERSECT
1500  %left OR
1501  %left AND
1502  %right NOT
1503  %nonassoc IS ISNULL NOTNULL
1504  %nonassoc '<' '>' '=' LESS_EQUALS GREATER_EQUALS NOT_EQUALS
1505  %nonassoc BETWEEN IN_P LIKE ILIKE SIMILAR NOT_LA
1506  %nonassoc ESCAPE
1507  %left POSTFIXOP
1508 
1509 
1510 
1511 
1512 
1513 
1514 
1515 
1516 
1517 
1518 
1519 
1520 
1521 
1522 
1523 
1524 
1525 
1526 
1527 
1528 
1529 
1530 
1531 
1532 
1533  %nonassoc UNBOUNDED
1534  %nonassoc IDENT
1535 %nonassoc CSTRING
1536 %nonassoc UIDENT NULL_P PARTITION RANGE ROWS PRECEDING FOLLOWING CUBE ROLLUP
1537  %left Op OPERATOR
1538  %left '+' '-'
1539  %left '*' '/' '%'
1540  %left '^'
1541 
1542  %left AT
1543  %left COLLATE
1544  %right UMINUS
1545  %left '[' ']'
1546  %left '(' ')'
1547  %left TYPECAST
1548  %left '.'
1549 
1550 
1551 
1552 
1553 
1554 
1555 
1556  %left JOIN CROSS LEFT FULL RIGHT INNER_P NATURAL
1557 
1558  %right PRESERVE STRIP_P
1559 
1560 %%
1561 prog: statements;
1562 /* rules */
1563  stmt:
1564  AlterEventTrigStmt
1565  { output_statement($1, 0, ECPGst_normal); }
1566 |  AlterDatabaseStmt
1567  { output_statement($1, 0, ECPGst_normal); }
1568 |  AlterDatabaseSetStmt
1569  { output_statement($1, 0, ECPGst_normal); }
1570 |  AlterDefaultPrivilegesStmt
1571  { output_statement($1, 0, ECPGst_normal); }
1572 |  AlterDomainStmt
1573  { output_statement($1, 0, ECPGst_normal); }
1574 |  AlterEnumStmt
1575  { output_statement($1, 0, ECPGst_normal); }
1576 |  AlterExtensionStmt
1577  { output_statement($1, 0, ECPGst_normal); }
1578 |  AlterExtensionContentsStmt
1579  { output_statement($1, 0, ECPGst_normal); }
1580 |  AlterFdwStmt
1581  { output_statement($1, 0, ECPGst_normal); }
1582 |  AlterForeignServerStmt
1583  { output_statement($1, 0, ECPGst_normal); }
1584 |  AlterForeignTableStmt
1585  { output_statement($1, 0, ECPGst_normal); }
1586 |  AlterFunctionStmt
1587  { output_statement($1, 0, ECPGst_normal); }
1588 |  AlterGroupStmt
1589  { output_statement($1, 0, ECPGst_normal); }
1590 |  AlterObjectDependsStmt
1591  { output_statement($1, 0, ECPGst_normal); }
1592 |  AlterObjectSchemaStmt
1593  { output_statement($1, 0, ECPGst_normal); }
1594 |  AlterOwnerStmt
1595  { output_statement($1, 0, ECPGst_normal); }
1596 |  AlterOperatorStmt
1597  { output_statement($1, 0, ECPGst_normal); }
1598 |  AlterPolicyStmt
1599  { output_statement($1, 0, ECPGst_normal); }
1600 |  AlterSeqStmt
1601  { output_statement($1, 0, ECPGst_normal); }
1602 |  AlterSystemStmt
1603  { output_statement($1, 0, ECPGst_normal); }
1604 |  AlterTableStmt
1605  { output_statement($1, 0, ECPGst_normal); }
1606 |  AlterTblSpcStmt
1607  { output_statement($1, 0, ECPGst_normal); }
1608 |  AlterCompositeTypeStmt
1609  { output_statement($1, 0, ECPGst_normal); }
1610 |  AlterRoleSetStmt
1611  { output_statement($1, 0, ECPGst_normal); }
1612 |  AlterRoleStmt
1613  { output_statement($1, 0, ECPGst_normal); }
1614 |  AlterTSConfigurationStmt
1615  { output_statement($1, 0, ECPGst_normal); }
1616 |  AlterTSDictionaryStmt
1617  { output_statement($1, 0, ECPGst_normal); }
1618 |  AlterUserMappingStmt
1619  { output_statement($1, 0, ECPGst_normal); }
1620 |  AlterUserSetStmt
1621  { output_statement($1, 0, ECPGst_normal); }
1622 |  AlterUserStmt
1623  { output_statement($1, 0, ECPGst_normal); }
1624 |  AnalyzeStmt
1625  { output_statement($1, 0, ECPGst_normal); }
1626 |  CheckPointStmt
1627  { output_statement($1, 0, ECPGst_normal); }
1628 |  ClosePortalStmt
1629 	{
1630 		if (INFORMIX_MODE)
1631 		{
1632 			if (pg_strcasecmp($1+strlen("close "), "database") == 0)
1633 			{
1634 				if (connection)
1635 					mmerror(PARSE_ERROR, ET_ERROR, "AT option not allowed in CLOSE DATABASE statement");
1636 
1637 				fprintf(base_yyout, "{ ECPGdisconnect(__LINE__, \"CURRENT\");");
1638 				whenever_action(2);
1639 				free($1);
1640 				break;
1641 			}
1642 		}
1643 
1644 		output_statement($1, 0, ECPGst_normal);
1645 	}
1646 |  ClusterStmt
1647  { output_statement($1, 0, ECPGst_normal); }
1648 |  CommentStmt
1649  { output_statement($1, 0, ECPGst_normal); }
1650 |  ConstraintsSetStmt
1651  { output_statement($1, 0, ECPGst_normal); }
1652 |  CopyStmt
1653  { output_statement($1, 0, ECPGst_normal); }
1654 |  CreateAmStmt
1655  { output_statement($1, 0, ECPGst_normal); }
1656 |  CreateAsStmt
1657  { output_statement($1, 0, ECPGst_normal); }
1658 |  CreateAssertStmt
1659  { output_statement($1, 0, ECPGst_normal); }
1660 |  CreateCastStmt
1661  { output_statement($1, 0, ECPGst_normal); }
1662 |  CreateConversionStmt
1663  { output_statement($1, 0, ECPGst_normal); }
1664 |  CreateDomainStmt
1665  { output_statement($1, 0, ECPGst_normal); }
1666 |  CreateExtensionStmt
1667  { output_statement($1, 0, ECPGst_normal); }
1668 |  CreateFdwStmt
1669  { output_statement($1, 0, ECPGst_normal); }
1670 |  CreateForeignServerStmt
1671  { output_statement($1, 0, ECPGst_normal); }
1672 |  CreateForeignTableStmt
1673  { output_statement($1, 0, ECPGst_normal); }
1674 |  CreateFunctionStmt
1675  { output_statement($1, 0, ECPGst_normal); }
1676 |  CreateGroupStmt
1677  { output_statement($1, 0, ECPGst_normal); }
1678 |  CreateMatViewStmt
1679  { output_statement($1, 0, ECPGst_normal); }
1680 |  CreateOpClassStmt
1681  { output_statement($1, 0, ECPGst_normal); }
1682 |  CreateOpFamilyStmt
1683  { output_statement($1, 0, ECPGst_normal); }
1684 |  AlterOpFamilyStmt
1685  { output_statement($1, 0, ECPGst_normal); }
1686 |  CreatePolicyStmt
1687  { output_statement($1, 0, ECPGst_normal); }
1688 |  CreatePLangStmt
1689  { output_statement($1, 0, ECPGst_normal); }
1690 |  CreateSchemaStmt
1691  { output_statement($1, 0, ECPGst_normal); }
1692 |  CreateSeqStmt
1693  { output_statement($1, 0, ECPGst_normal); }
1694 |  CreateStmt
1695  { output_statement($1, 0, ECPGst_normal); }
1696 |  CreateTableSpaceStmt
1697  { output_statement($1, 0, ECPGst_normal); }
1698 |  CreateTransformStmt
1699  { output_statement($1, 0, ECPGst_normal); }
1700 |  CreateTrigStmt
1701  { output_statement($1, 0, ECPGst_normal); }
1702 |  CreateEventTrigStmt
1703  { output_statement($1, 0, ECPGst_normal); }
1704 |  CreateRoleStmt
1705  { output_statement($1, 0, ECPGst_normal); }
1706 |  CreateUserStmt
1707  { output_statement($1, 0, ECPGst_normal); }
1708 |  CreateUserMappingStmt
1709  { output_statement($1, 0, ECPGst_normal); }
1710 |  CreatedbStmt
1711  { output_statement($1, 0, ECPGst_normal); }
1712 |  DeallocateStmt
1713 	{
1714 		output_deallocate_prepare_statement($1);
1715 	}
1716 |  DeclareCursorStmt
1717 	{ output_simple_statement($1); }
1718 |  DefineStmt
1719  { output_statement($1, 0, ECPGst_normal); }
1720 |  DeleteStmt
1721 	{ output_statement($1, 1, ECPGst_prepnormal); }
1722 |  DiscardStmt
1723 	{ output_statement($1, 1, ECPGst_normal); }
1724 |  DoStmt
1725  { output_statement($1, 0, ECPGst_normal); }
1726 |  DropAssertStmt
1727  { output_statement($1, 0, ECPGst_normal); }
1728 |  DropCastStmt
1729  { output_statement($1, 0, ECPGst_normal); }
1730 |  DropFdwStmt
1731  { output_statement($1, 0, ECPGst_normal); }
1732 |  DropForeignServerStmt
1733  { output_statement($1, 0, ECPGst_normal); }
1734 |  DropGroupStmt
1735  { output_statement($1, 0, ECPGst_normal); }
1736 |  DropOpClassStmt
1737  { output_statement($1, 0, ECPGst_normal); }
1738 |  DropOpFamilyStmt
1739  { output_statement($1, 0, ECPGst_normal); }
1740 |  DropOwnedStmt
1741  { output_statement($1, 0, ECPGst_normal); }
1742 |  DropPolicyStmt
1743  { output_statement($1, 0, ECPGst_normal); }
1744 |  DropPLangStmt
1745  { output_statement($1, 0, ECPGst_normal); }
1746 |  DropRuleStmt
1747  { output_statement($1, 0, ECPGst_normal); }
1748 |  DropStmt
1749  { output_statement($1, 0, ECPGst_normal); }
1750 |  DropTableSpaceStmt
1751  { output_statement($1, 0, ECPGst_normal); }
1752 |  DropTransformStmt
1753  { output_statement($1, 0, ECPGst_normal); }
1754 |  DropTrigStmt
1755  { output_statement($1, 0, ECPGst_normal); }
1756 |  DropRoleStmt
1757  { output_statement($1, 0, ECPGst_normal); }
1758 |  DropUserStmt
1759  { output_statement($1, 0, ECPGst_normal); }
1760 |  DropUserMappingStmt
1761  { output_statement($1, 0, ECPGst_normal); }
1762 |  DropdbStmt
1763  { output_statement($1, 0, ECPGst_normal); }
1764 |  ExecuteStmt
1765 	{ output_statement($1, 1, ECPGst_execute); }
1766 |  ExplainStmt
1767  { output_statement($1, 0, ECPGst_normal); }
1768 |  FetchStmt
1769 	{ output_statement($1, 1, ECPGst_normal); }
1770 |  GrantStmt
1771  { output_statement($1, 0, ECPGst_normal); }
1772 |  GrantRoleStmt
1773  { output_statement($1, 0, ECPGst_normal); }
1774 |  ImportForeignSchemaStmt
1775  { output_statement($1, 0, ECPGst_normal); }
1776 |  IndexStmt
1777  { output_statement($1, 0, ECPGst_normal); }
1778 |  InsertStmt
1779 	{ output_statement($1, 1, ECPGst_prepnormal); }
1780 |  ListenStmt
1781  { output_statement($1, 0, ECPGst_normal); }
1782 |  RefreshMatViewStmt
1783  { output_statement($1, 0, ECPGst_normal); }
1784 |  LoadStmt
1785  { output_statement($1, 0, ECPGst_normal); }
1786 |  LockStmt
1787  { output_statement($1, 0, ECPGst_normal); }
1788 |  NotifyStmt
1789  { output_statement($1, 0, ECPGst_normal); }
1790 |  PrepareStmt
1791 	{
1792 		if ($1.type == NULL || strlen($1.type) == 0)
1793 			output_prepare_statement($1.name, $1.stmt);
1794 		else
1795 			output_statement(cat_str(5, mm_strdup("prepare"), $1.name, $1.type, mm_strdup("as"), $1.stmt), 0, ECPGst_normal);
1796 	}
1797 |  ReassignOwnedStmt
1798  { output_statement($1, 0, ECPGst_normal); }
1799 |  ReindexStmt
1800  { output_statement($1, 0, ECPGst_normal); }
1801 |  RemoveAggrStmt
1802  { output_statement($1, 0, ECPGst_normal); }
1803 |  RemoveFuncStmt
1804  { output_statement($1, 0, ECPGst_normal); }
1805 |  RemoveOperStmt
1806  { output_statement($1, 0, ECPGst_normal); }
1807 |  RenameStmt
1808  { output_statement($1, 0, ECPGst_normal); }
1809 |  RevokeStmt
1810  { output_statement($1, 0, ECPGst_normal); }
1811 |  RevokeRoleStmt
1812  { output_statement($1, 0, ECPGst_normal); }
1813 |  RuleStmt
1814  { output_statement($1, 0, ECPGst_normal); }
1815 |  SecLabelStmt
1816  { output_statement($1, 0, ECPGst_normal); }
1817 |  SelectStmt
1818 	{ output_statement($1, 1, ECPGst_prepnormal); }
1819 |  TransactionStmt
1820 	{
1821 		fprintf(base_yyout, "{ ECPGtrans(__LINE__, %s, \"%s\");", connection ? connection : "NULL", $1);
1822 		whenever_action(2);
1823 		free($1);
1824 	}
1825 |  TruncateStmt
1826  { output_statement($1, 0, ECPGst_normal); }
1827 |  UnlistenStmt
1828  { output_statement($1, 0, ECPGst_normal); }
1829 |  UpdateStmt
1830 	{ output_statement($1, 1, ECPGst_prepnormal); }
1831 |  VacuumStmt
1832  { output_statement($1, 0, ECPGst_normal); }
1833 |  VariableResetStmt
1834  { output_statement($1, 0, ECPGst_normal); }
1835 |  VariableSetStmt
1836  { output_statement($1, 0, ECPGst_normal); }
1837 |  VariableShowStmt
1838  { output_statement($1, 0, ECPGst_normal); }
1839 |  ViewStmt
1840  { output_statement($1, 0, ECPGst_normal); }
1841 	| ECPGAllocateDescr
1842 	{
1843 		fprintf(base_yyout,"ECPGallocate_desc(__LINE__, %s);",$1);
1844 		whenever_action(0);
1845 		free($1);
1846 	}
1847 	| ECPGConnect
1848 	{
1849 		if (connection)
1850 			mmerror(PARSE_ERROR, ET_ERROR, "AT option not allowed in CONNECT statement");
1851 
1852 		fprintf(base_yyout, "{ ECPGconnect(__LINE__, %d, %s, %d); ", compat, $1, autocommit);
1853 		reset_variables();
1854 		whenever_action(2);
1855 		free($1);
1856 	}
1857 	| ECPGCursorStmt
1858 	{
1859 		output_simple_statement($1);
1860 	}
1861 	| ECPGDeallocateDescr
1862 	{
1863 		fprintf(base_yyout,"ECPGdeallocate_desc(__LINE__, %s);",$1);
1864 		whenever_action(0);
1865 		free($1);
1866 	}
1867 	| ECPGDeclare
1868 	{
1869 		output_simple_statement($1);
1870 	}
1871 	| ECPGDescribe
1872 	{
1873 		fprintf(base_yyout, "{ ECPGdescribe(__LINE__, %d, %s,", compat, $1);
1874 		dump_variables(argsresult, 1);
1875 		fputs("ECPGt_EORT);", base_yyout);
1876 		fprintf(base_yyout, "}");
1877 		output_line_number();
1878 
1879 		free($1);
1880 	}
1881 	| ECPGDisconnect
1882 	{
1883 		if (connection)
1884 			mmerror(PARSE_ERROR, ET_ERROR, "AT option not allowed in DISCONNECT statement");
1885 
1886 		fprintf(base_yyout, "{ ECPGdisconnect(__LINE__, %s);",
1887 				$1 ? $1 : "\"CURRENT\"");
1888 		whenever_action(2);
1889 		free($1);
1890 	}
1891 	| ECPGExecuteImmediateStmt	{ output_statement($1, 0, ECPGst_exec_immediate); }
1892 	| ECPGFree
1893 	{
1894 		const char *con = connection ? connection : "NULL";
1895 
1896 		if (strcmp($1, "all") == 0)
1897 			fprintf(base_yyout, "{ ECPGdeallocate_all(__LINE__, %d, %s);", compat, con);
1898 		else if ($1[0] == ':')
1899 			fprintf(base_yyout, "{ ECPGdeallocate(__LINE__, %d, %s, %s);", compat, con, $1+1);
1900 		else
1901 			fprintf(base_yyout, "{ ECPGdeallocate(__LINE__, %d, %s, \"%s\");", compat, con, $1);
1902 
1903 		whenever_action(2);
1904 		free($1);
1905 	}
1906 	| ECPGGetDescriptor
1907 	{
1908 		lookup_descriptor($1.name, connection);
1909 		output_get_descr($1.name, $1.str);
1910 		free($1.name);
1911 		free($1.str);
1912 	}
1913 	| ECPGGetDescriptorHeader
1914 	{
1915 		lookup_descriptor($1, connection);
1916 		output_get_descr_header($1);
1917 		free($1);
1918 	}
1919 	| ECPGOpen
1920 	{
1921 		struct cursor *ptr;
1922 
1923 		if ((ptr = add_additional_variables($1, true)) != NULL)
1924 		{
1925 			connection = ptr->connection ? mm_strdup(ptr->connection) : NULL;
1926 			output_statement(mm_strdup(ptr->command), 0, ECPGst_normal);
1927 			ptr->opened = true;
1928 		}
1929 	}
1930 	| ECPGSetAutocommit
1931 	{
1932 		fprintf(base_yyout, "{ ECPGsetcommit(__LINE__, \"%s\", %s);", $1, connection ? connection : "NULL");
1933 		whenever_action(2);
1934 		free($1);
1935 	}
1936 	| ECPGSetConnection
1937 	{
1938 		if (connection)
1939 			mmerror(PARSE_ERROR, ET_ERROR, "AT option not allowed in SET CONNECTION statement");
1940 
1941 		fprintf(base_yyout, "{ ECPGsetconn(__LINE__, %s);", $1);
1942 		whenever_action(2);
1943 		free($1);
1944 	}
1945 	| ECPGSetDescriptor
1946 	{
1947 		lookup_descriptor($1.name, connection);
1948 		output_set_descr($1.name, $1.str);
1949 		free($1.name);
1950 		free($1.str);
1951 	}
1952 	| ECPGSetDescriptorHeader
1953 	{
1954 		lookup_descriptor($1, connection);
1955 		output_set_descr_header($1);
1956 		free($1);
1957 	}
1958 	| ECPGTypedef
1959 	{
1960 		if (connection)
1961 			mmerror(PARSE_ERROR, ET_ERROR, "AT option not allowed in TYPE statement");
1962 
1963 		fprintf(base_yyout, "%s", $1);
1964 		free($1);
1965 		output_line_number();
1966 	}
1967 	| ECPGVar
1968 	{
1969 		if (connection)
1970 			mmerror(PARSE_ERROR, ET_ERROR, "AT option not allowed in VAR statement");
1971 
1972 		output_simple_statement($1);
1973 	}
1974 	| ECPGWhenever
1975 	{
1976 		if (connection)
1977 			mmerror(PARSE_ERROR, ET_ERROR, "AT option not allowed in WHENEVER statement");
1978 
1979 		output_simple_statement($1);
1980 	}
1981 |
1982  { $$ = NULL; }
1983 ;
1984 
1985 
1986  CreateRoleStmt:
1987  CREATE ROLE RoleId opt_with OptRoleList
1988  {
1989  $$ = cat_str(4,mm_strdup("create role"),$3,$4,$5);
1990 }
1991 ;
1992 
1993 
1994  opt_with:
1995  WITH
1996  {
1997  $$ = mm_strdup("with");
1998 }
1999 |  WITH_LA
2000  {
2001  $$ = mm_strdup("with");
2002 }
2003 |
2004  {
2005  $$=EMPTY; }
2006 ;
2007 
2008 
2009  OptRoleList:
2010  OptRoleList CreateOptRoleElem
2011  {
2012  $$ = cat_str(2,$1,$2);
2013 }
2014 |
2015  {
2016  $$=EMPTY; }
2017 ;
2018 
2019 
2020  AlterOptRoleList:
2021  AlterOptRoleList AlterOptRoleElem
2022  {
2023  $$ = cat_str(2,$1,$2);
2024 }
2025 |
2026  {
2027  $$=EMPTY; }
2028 ;
2029 
2030 
2031  AlterOptRoleElem:
2032  PASSWORD ecpg_sconst
2033  {
2034  $$ = cat_str(2,mm_strdup("password"),$2);
2035 }
2036 |  PASSWORD NULL_P
2037  {
2038  $$ = mm_strdup("password null");
2039 }
2040 |  ENCRYPTED PASSWORD ecpg_sconst
2041  {
2042  $$ = cat_str(2,mm_strdup("encrypted password"),$3);
2043 }
2044 |  UNENCRYPTED PASSWORD ecpg_sconst
2045  {
2046  $$ = cat_str(2,mm_strdup("unencrypted password"),$3);
2047 }
2048 |  INHERIT
2049  {
2050  $$ = mm_strdup("inherit");
2051 }
2052 |  CONNECTION LIMIT SignedIconst
2053  {
2054  $$ = cat_str(2,mm_strdup("connection limit"),$3);
2055 }
2056 |  VALID UNTIL ecpg_sconst
2057  {
2058  $$ = cat_str(2,mm_strdup("valid until"),$3);
2059 }
2060 |  USER role_list
2061  {
2062  $$ = cat_str(2,mm_strdup("user"),$2);
2063 }
2064 |  ecpg_ident
2065  {
2066  $$ = $1;
2067 }
2068 ;
2069 
2070 
2071  CreateOptRoleElem:
2072  AlterOptRoleElem
2073  {
2074  $$ = $1;
2075 }
2076 |  SYSID Iconst
2077  {
2078  $$ = cat_str(2,mm_strdup("sysid"),$2);
2079 }
2080 |  ADMIN role_list
2081  {
2082  $$ = cat_str(2,mm_strdup("admin"),$2);
2083 }
2084 |  ROLE role_list
2085  {
2086  $$ = cat_str(2,mm_strdup("role"),$2);
2087 }
2088 |  IN_P ROLE role_list
2089  {
2090  $$ = cat_str(2,mm_strdup("in role"),$3);
2091 }
2092 |  IN_P GROUP_P role_list
2093  {
2094  $$ = cat_str(2,mm_strdup("in group"),$3);
2095 }
2096 ;
2097 
2098 
2099  CreateUserStmt:
2100  CREATE USER RoleId opt_with OptRoleList
2101  {
2102  $$ = cat_str(4,mm_strdup("create user"),$3,$4,$5);
2103 }
2104 ;
2105 
2106 
2107  AlterRoleStmt:
2108  ALTER ROLE RoleSpec opt_with AlterOptRoleList
2109  {
2110  $$ = cat_str(4,mm_strdup("alter role"),$3,$4,$5);
2111 }
2112 ;
2113 
2114 
2115  opt_in_database:
2116 
2117  {
2118  $$=EMPTY; }
2119 |  IN_P DATABASE database_name
2120  {
2121  $$ = cat_str(2,mm_strdup("in database"),$3);
2122 }
2123 ;
2124 
2125 
2126  AlterRoleSetStmt:
2127  ALTER ROLE RoleSpec opt_in_database SetResetClause
2128  {
2129  $$ = cat_str(4,mm_strdup("alter role"),$3,$4,$5);
2130 }
2131 |  ALTER ROLE ALL opt_in_database SetResetClause
2132  {
2133  $$ = cat_str(3,mm_strdup("alter role all"),$4,$5);
2134 }
2135 ;
2136 
2137 
2138  AlterUserStmt:
2139  ALTER USER RoleSpec opt_with AlterOptRoleList
2140  {
2141  $$ = cat_str(4,mm_strdup("alter user"),$3,$4,$5);
2142 }
2143 ;
2144 
2145 
2146  AlterUserSetStmt:
2147  ALTER USER RoleSpec opt_in_database SetResetClause
2148  {
2149  $$ = cat_str(4,mm_strdup("alter user"),$3,$4,$5);
2150 }
2151 |  ALTER USER ALL opt_in_database SetResetClause
2152  {
2153  $$ = cat_str(3,mm_strdup("alter user all"),$4,$5);
2154 }
2155 ;
2156 
2157 
2158  DropRoleStmt:
2159  DROP ROLE role_list
2160  {
2161  $$ = cat_str(2,mm_strdup("drop role"),$3);
2162 }
2163 |  DROP ROLE IF_P EXISTS role_list
2164  {
2165  $$ = cat_str(2,mm_strdup("drop role if exists"),$5);
2166 }
2167 ;
2168 
2169 
2170  DropUserStmt:
2171  DROP USER role_list
2172  {
2173  $$ = cat_str(2,mm_strdup("drop user"),$3);
2174 }
2175 |  DROP USER IF_P EXISTS role_list
2176  {
2177  $$ = cat_str(2,mm_strdup("drop user if exists"),$5);
2178 }
2179 ;
2180 
2181 
2182  CreateGroupStmt:
2183  CREATE GROUP_P RoleId opt_with OptRoleList
2184  {
2185  $$ = cat_str(4,mm_strdup("create group"),$3,$4,$5);
2186 }
2187 ;
2188 
2189 
2190  AlterGroupStmt:
2191  ALTER GROUP_P RoleSpec add_drop USER role_list
2192  {
2193  $$ = cat_str(5,mm_strdup("alter group"),$3,$4,mm_strdup("user"),$6);
2194 }
2195 ;
2196 
2197 
2198  add_drop:
2199  ADD_P
2200  {
2201  $$ = mm_strdup("add");
2202 }
2203 |  DROP
2204  {
2205  $$ = mm_strdup("drop");
2206 }
2207 ;
2208 
2209 
2210  DropGroupStmt:
2211  DROP GROUP_P role_list
2212  {
2213  $$ = cat_str(2,mm_strdup("drop group"),$3);
2214 }
2215 |  DROP GROUP_P IF_P EXISTS role_list
2216  {
2217  $$ = cat_str(2,mm_strdup("drop group if exists"),$5);
2218 }
2219 ;
2220 
2221 
2222  CreateSchemaStmt:
2223  CREATE SCHEMA OptSchemaName AUTHORIZATION RoleSpec OptSchemaEltList
2224  {
2225  $$ = cat_str(5,mm_strdup("create schema"),$3,mm_strdup("authorization"),$5,$6);
2226 }
2227 |  CREATE SCHEMA ColId OptSchemaEltList
2228  {
2229  $$ = cat_str(3,mm_strdup("create schema"),$3,$4);
2230 }
2231 |  CREATE SCHEMA IF_P NOT EXISTS OptSchemaName AUTHORIZATION RoleSpec OptSchemaEltList
2232  {
2233 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
2234  $$ = cat_str(5,mm_strdup("create schema if not exists"),$6,mm_strdup("authorization"),$8,$9);
2235 }
2236 |  CREATE SCHEMA IF_P NOT EXISTS ColId OptSchemaEltList
2237  {
2238 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
2239  $$ = cat_str(3,mm_strdup("create schema if not exists"),$6,$7);
2240 }
2241 ;
2242 
2243 
2244  OptSchemaName:
2245  ColId
2246  {
2247  $$ = $1;
2248 }
2249 |
2250  {
2251  $$=EMPTY; }
2252 ;
2253 
2254 
2255  OptSchemaEltList:
2256  OptSchemaEltList schema_stmt
2257  {
2258  $$ = cat_str(2,$1,$2);
2259 }
2260 |
2261  {
2262  $$=EMPTY; }
2263 ;
2264 
2265 
2266  schema_stmt:
2267  CreateStmt
2268  {
2269  $$ = $1;
2270 }
2271 |  IndexStmt
2272  {
2273  $$ = $1;
2274 }
2275 |  CreateSeqStmt
2276  {
2277  $$ = $1;
2278 }
2279 |  CreateTrigStmt
2280  {
2281  $$ = $1;
2282 }
2283 |  GrantStmt
2284  {
2285  $$ = $1;
2286 }
2287 |  ViewStmt
2288  {
2289  $$ = $1;
2290 }
2291 ;
2292 
2293 
2294  VariableSetStmt:
2295  SET set_rest
2296  {
2297  $$ = cat_str(2,mm_strdup("set"),$2);
2298 }
2299 |  SET LOCAL set_rest
2300  {
2301  $$ = cat_str(2,mm_strdup("set local"),$3);
2302 }
2303 |  SET SESSION set_rest
2304  {
2305  $$ = cat_str(2,mm_strdup("set session"),$3);
2306 }
2307 ;
2308 
2309 
2310  set_rest:
2311  TRANSACTION transaction_mode_list
2312  {
2313  $$ = cat_str(2,mm_strdup("transaction"),$2);
2314 }
2315 |  SESSION CHARACTERISTICS AS TRANSACTION transaction_mode_list
2316  {
2317  $$ = cat_str(2,mm_strdup("session characteristics as transaction"),$5);
2318 }
2319 |  set_rest_more
2320  {
2321  $$ = $1;
2322 }
2323 ;
2324 
2325 
2326  generic_set:
2327  var_name TO var_list
2328  {
2329  $$ = cat_str(3,$1,mm_strdup("to"),$3);
2330 }
2331 |  var_name '=' var_list
2332  {
2333  $$ = cat_str(3,$1,mm_strdup("="),$3);
2334 }
2335 |  var_name TO DEFAULT
2336  {
2337  $$ = cat_str(2,$1,mm_strdup("to default"));
2338 }
2339 |  var_name '=' DEFAULT
2340  {
2341  $$ = cat_str(2,$1,mm_strdup("= default"));
2342 }
2343 ;
2344 
2345 
2346  set_rest_more:
2347  generic_set
2348  {
2349  $$ = $1;
2350 }
2351 |  var_name FROM CURRENT_P
2352  {
2353  $$ = cat_str(2,$1,mm_strdup("from current"));
2354 }
2355 |  TIME ZONE zone_value
2356  {
2357  $$ = cat_str(2,mm_strdup("time zone"),$3);
2358 }
2359 |  CATALOG_P ecpg_sconst
2360  {
2361 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
2362  $$ = cat_str(2,mm_strdup("catalog"),$2);
2363 }
2364 |  SCHEMA ecpg_sconst
2365  {
2366  $$ = cat_str(2,mm_strdup("schema"),$2);
2367 }
2368 |  NAMES opt_encoding
2369  {
2370  $$ = cat_str(2,mm_strdup("names"),$2);
2371 }
2372 |  ROLE NonReservedWord_or_Sconst
2373  {
2374  $$ = cat_str(2,mm_strdup("role"),$2);
2375 }
2376 |  SESSION AUTHORIZATION NonReservedWord_or_Sconst
2377  {
2378  $$ = cat_str(2,mm_strdup("session authorization"),$3);
2379 }
2380 |  SESSION AUTHORIZATION DEFAULT
2381  {
2382  $$ = mm_strdup("session authorization default");
2383 }
2384 |  XML_P OPTION document_or_content
2385  {
2386  $$ = cat_str(2,mm_strdup("xml option"),$3);
2387 }
2388 |  TRANSACTION SNAPSHOT ecpg_sconst
2389  {
2390  $$ = cat_str(2,mm_strdup("transaction snapshot"),$3);
2391 }
2392 ;
2393 
2394 
2395  var_name:
2396 ECPGColId
2397  {
2398  $$ = $1;
2399 }
2400 |  var_name '.' ColId
2401  {
2402  $$ = cat_str(3,$1,mm_strdup("."),$3);
2403 }
2404 ;
2405 
2406 
2407  var_list:
2408  var_value
2409  {
2410  $$ = $1;
2411 }
2412 |  var_list ',' var_value
2413  {
2414  $$ = cat_str(3,$1,mm_strdup(","),$3);
2415 }
2416 ;
2417 
2418 
2419  var_value:
2420  opt_boolean_or_string
2421  {
2422  $$ = $1;
2423 }
2424 |  NumericOnly
2425  {
2426 		if ($1[0] == '$')
2427 		{
2428 			free($1);
2429 			$1 = mm_strdup("$0");
2430 		}
2431 
2432  $$ = $1;
2433 }
2434 ;
2435 
2436 
2437  iso_level:
2438  READ UNCOMMITTED
2439  {
2440  $$ = mm_strdup("read uncommitted");
2441 }
2442 |  READ COMMITTED
2443  {
2444  $$ = mm_strdup("read committed");
2445 }
2446 |  REPEATABLE READ
2447  {
2448  $$ = mm_strdup("repeatable read");
2449 }
2450 |  SERIALIZABLE
2451  {
2452  $$ = mm_strdup("serializable");
2453 }
2454 ;
2455 
2456 
2457  opt_boolean_or_string:
2458  TRUE_P
2459  {
2460  $$ = mm_strdup("true");
2461 }
2462 |  FALSE_P
2463  {
2464  $$ = mm_strdup("false");
2465 }
2466 |  ON
2467  {
2468  $$ = mm_strdup("on");
2469 }
2470 |  NonReservedWord_or_Sconst
2471  {
2472  $$ = $1;
2473 }
2474 ;
2475 
2476 
2477  zone_value:
2478  ecpg_sconst
2479  {
2480  $$ = $1;
2481 }
2482 |  ecpg_ident
2483  {
2484  $$ = $1;
2485 }
2486 |  ConstInterval ecpg_sconst opt_interval
2487  {
2488  $$ = cat_str(3,$1,$2,$3);
2489 }
2490 |  ConstInterval '(' Iconst ')' ecpg_sconst
2491  {
2492  $$ = cat_str(5,$1,mm_strdup("("),$3,mm_strdup(")"),$5);
2493 }
2494 |  NumericOnly
2495  {
2496  $$ = $1;
2497 }
2498 |  DEFAULT
2499  {
2500  $$ = mm_strdup("default");
2501 }
2502 |  LOCAL
2503  {
2504  $$ = mm_strdup("local");
2505 }
2506 ;
2507 
2508 
2509  opt_encoding:
2510  ecpg_sconst
2511  {
2512  $$ = $1;
2513 }
2514 |  DEFAULT
2515  {
2516  $$ = mm_strdup("default");
2517 }
2518 |
2519  {
2520  $$=EMPTY; }
2521 ;
2522 
2523 
2524  NonReservedWord_or_Sconst:
2525  NonReservedWord
2526  {
2527  $$ = $1;
2528 }
2529 |  ecpg_sconst
2530  {
2531  $$ = $1;
2532 }
2533 ;
2534 
2535 
2536  VariableResetStmt:
2537  RESET reset_rest
2538  {
2539  $$ = cat_str(2,mm_strdup("reset"),$2);
2540 }
2541 ;
2542 
2543 
2544  reset_rest:
2545  generic_reset
2546  {
2547  $$ = $1;
2548 }
2549 |  TIME ZONE
2550  {
2551  $$ = mm_strdup("time zone");
2552 }
2553 |  TRANSACTION ISOLATION LEVEL
2554  {
2555  $$ = mm_strdup("transaction isolation level");
2556 }
2557 |  SESSION AUTHORIZATION
2558  {
2559  $$ = mm_strdup("session authorization");
2560 }
2561 ;
2562 
2563 
2564  generic_reset:
2565  var_name
2566  {
2567  $$ = $1;
2568 }
2569 |  ALL
2570  {
2571  $$ = mm_strdup("all");
2572 }
2573 ;
2574 
2575 
2576  SetResetClause:
2577  SET set_rest
2578  {
2579  $$ = cat_str(2,mm_strdup("set"),$2);
2580 }
2581 |  VariableResetStmt
2582  {
2583  $$ = $1;
2584 }
2585 ;
2586 
2587 
2588  FunctionSetResetClause:
2589  SET set_rest_more
2590  {
2591  $$ = cat_str(2,mm_strdup("set"),$2);
2592 }
2593 |  VariableResetStmt
2594  {
2595  $$ = $1;
2596 }
2597 ;
2598 
2599 
2600  VariableShowStmt:
2601 SHOW var_name ecpg_into
2602  {
2603  $$ = cat_str(2,mm_strdup("show"),$2);
2604 }
2605 | SHOW TIME ZONE ecpg_into
2606  {
2607  $$ = mm_strdup("show time zone");
2608 }
2609 | SHOW TRANSACTION ISOLATION LEVEL ecpg_into
2610  {
2611  $$ = mm_strdup("show transaction isolation level");
2612 }
2613 | SHOW SESSION AUTHORIZATION ecpg_into
2614  {
2615  $$ = mm_strdup("show session authorization");
2616 }
2617 |  SHOW ALL
2618 	{
2619 		mmerror(PARSE_ERROR, ET_ERROR, "SHOW ALL is not implemented");
2620 		$$ = EMPTY;
2621 	}
2622 ;
2623 
2624 
2625  ConstraintsSetStmt:
2626  SET CONSTRAINTS constraints_set_list constraints_set_mode
2627  {
2628  $$ = cat_str(3,mm_strdup("set constraints"),$3,$4);
2629 }
2630 ;
2631 
2632 
2633  constraints_set_list:
2634  ALL
2635  {
2636  $$ = mm_strdup("all");
2637 }
2638 |  qualified_name_list
2639  {
2640  $$ = $1;
2641 }
2642 ;
2643 
2644 
2645  constraints_set_mode:
2646  DEFERRED
2647  {
2648  $$ = mm_strdup("deferred");
2649 }
2650 |  IMMEDIATE
2651  {
2652  $$ = mm_strdup("immediate");
2653 }
2654 ;
2655 
2656 
2657  CheckPointStmt:
2658  CHECKPOINT
2659  {
2660  $$ = mm_strdup("checkpoint");
2661 }
2662 ;
2663 
2664 
2665  DiscardStmt:
2666  DISCARD ALL
2667  {
2668  $$ = mm_strdup("discard all");
2669 }
2670 |  DISCARD TEMP
2671  {
2672  $$ = mm_strdup("discard temp");
2673 }
2674 |  DISCARD TEMPORARY
2675  {
2676  $$ = mm_strdup("discard temporary");
2677 }
2678 |  DISCARD PLANS
2679  {
2680  $$ = mm_strdup("discard plans");
2681 }
2682 |  DISCARD SEQUENCES
2683  {
2684  $$ = mm_strdup("discard sequences");
2685 }
2686 ;
2687 
2688 
2689  AlterTableStmt:
2690  ALTER TABLE relation_expr alter_table_cmds
2691  {
2692  $$ = cat_str(3,mm_strdup("alter table"),$3,$4);
2693 }
2694 |  ALTER TABLE IF_P EXISTS relation_expr alter_table_cmds
2695  {
2696  $$ = cat_str(3,mm_strdup("alter table if exists"),$5,$6);
2697 }
2698 |  ALTER TABLE ALL IN_P TABLESPACE name SET TABLESPACE name opt_nowait
2699  {
2700  $$ = cat_str(5,mm_strdup("alter table all in tablespace"),$6,mm_strdup("set tablespace"),$9,$10);
2701 }
2702 |  ALTER TABLE ALL IN_P TABLESPACE name OWNED BY role_list SET TABLESPACE name opt_nowait
2703  {
2704  $$ = cat_str(7,mm_strdup("alter table all in tablespace"),$6,mm_strdup("owned by"),$9,mm_strdup("set tablespace"),$12,$13);
2705 }
2706 |  ALTER INDEX qualified_name alter_table_cmds
2707  {
2708  $$ = cat_str(3,mm_strdup("alter index"),$3,$4);
2709 }
2710 |  ALTER INDEX IF_P EXISTS qualified_name alter_table_cmds
2711  {
2712  $$ = cat_str(3,mm_strdup("alter index if exists"),$5,$6);
2713 }
2714 |  ALTER INDEX ALL IN_P TABLESPACE name SET TABLESPACE name opt_nowait
2715  {
2716  $$ = cat_str(5,mm_strdup("alter index all in tablespace"),$6,mm_strdup("set tablespace"),$9,$10);
2717 }
2718 |  ALTER INDEX ALL IN_P TABLESPACE name OWNED BY role_list SET TABLESPACE name opt_nowait
2719  {
2720  $$ = cat_str(7,mm_strdup("alter index all in tablespace"),$6,mm_strdup("owned by"),$9,mm_strdup("set tablespace"),$12,$13);
2721 }
2722 |  ALTER SEQUENCE qualified_name alter_table_cmds
2723  {
2724  $$ = cat_str(3,mm_strdup("alter sequence"),$3,$4);
2725 }
2726 |  ALTER SEQUENCE IF_P EXISTS qualified_name alter_table_cmds
2727  {
2728  $$ = cat_str(3,mm_strdup("alter sequence if exists"),$5,$6);
2729 }
2730 |  ALTER VIEW qualified_name alter_table_cmds
2731  {
2732  $$ = cat_str(3,mm_strdup("alter view"),$3,$4);
2733 }
2734 |  ALTER VIEW IF_P EXISTS qualified_name alter_table_cmds
2735  {
2736  $$ = cat_str(3,mm_strdup("alter view if exists"),$5,$6);
2737 }
2738 |  ALTER MATERIALIZED VIEW qualified_name alter_table_cmds
2739  {
2740  $$ = cat_str(3,mm_strdup("alter materialized view"),$4,$5);
2741 }
2742 |  ALTER MATERIALIZED VIEW IF_P EXISTS qualified_name alter_table_cmds
2743  {
2744  $$ = cat_str(3,mm_strdup("alter materialized view if exists"),$6,$7);
2745 }
2746 |  ALTER MATERIALIZED VIEW ALL IN_P TABLESPACE name SET TABLESPACE name opt_nowait
2747  {
2748  $$ = cat_str(5,mm_strdup("alter materialized view all in tablespace"),$7,mm_strdup("set tablespace"),$10,$11);
2749 }
2750 |  ALTER MATERIALIZED VIEW ALL IN_P TABLESPACE name OWNED BY role_list SET TABLESPACE name opt_nowait
2751  {
2752  $$ = cat_str(7,mm_strdup("alter materialized view all in tablespace"),$7,mm_strdup("owned by"),$10,mm_strdup("set tablespace"),$13,$14);
2753 }
2754 ;
2755 
2756 
2757  alter_table_cmds:
2758  alter_table_cmd
2759  {
2760  $$ = $1;
2761 }
2762 |  alter_table_cmds ',' alter_table_cmd
2763  {
2764  $$ = cat_str(3,$1,mm_strdup(","),$3);
2765 }
2766 ;
2767 
2768 
2769  alter_table_cmd:
2770  ADD_P columnDef
2771  {
2772  $$ = cat_str(2,mm_strdup("add"),$2);
2773 }
2774 |  ADD_P IF_P NOT EXISTS columnDef
2775  {
2776  $$ = cat_str(2,mm_strdup("add if not exists"),$5);
2777 }
2778 |  ADD_P COLUMN columnDef
2779  {
2780  $$ = cat_str(2,mm_strdup("add column"),$3);
2781 }
2782 |  ADD_P COLUMN IF_P NOT EXISTS columnDef
2783  {
2784  $$ = cat_str(2,mm_strdup("add column if not exists"),$6);
2785 }
2786 |  ALTER opt_column ColId alter_column_default
2787  {
2788  $$ = cat_str(4,mm_strdup("alter"),$2,$3,$4);
2789 }
2790 |  ALTER opt_column ColId DROP NOT NULL_P
2791  {
2792  $$ = cat_str(4,mm_strdup("alter"),$2,$3,mm_strdup("drop not null"));
2793 }
2794 |  ALTER opt_column ColId SET NOT NULL_P
2795  {
2796  $$ = cat_str(4,mm_strdup("alter"),$2,$3,mm_strdup("set not null"));
2797 }
2798 |  ALTER opt_column ColId SET STATISTICS SignedIconst
2799  {
2800  $$ = cat_str(5,mm_strdup("alter"),$2,$3,mm_strdup("set statistics"),$6);
2801 }
2802 |  ALTER opt_column ColId SET reloptions
2803  {
2804  $$ = cat_str(5,mm_strdup("alter"),$2,$3,mm_strdup("set"),$5);
2805 }
2806 |  ALTER opt_column ColId RESET reloptions
2807  {
2808  $$ = cat_str(5,mm_strdup("alter"),$2,$3,mm_strdup("reset"),$5);
2809 }
2810 |  ALTER opt_column ColId SET STORAGE ColId
2811  {
2812  $$ = cat_str(5,mm_strdup("alter"),$2,$3,mm_strdup("set storage"),$6);
2813 }
2814 |  DROP opt_column IF_P EXISTS ColId opt_drop_behavior
2815  {
2816  $$ = cat_str(5,mm_strdup("drop"),$2,mm_strdup("if exists"),$5,$6);
2817 }
2818 |  DROP opt_column ColId opt_drop_behavior
2819  {
2820  $$ = cat_str(4,mm_strdup("drop"),$2,$3,$4);
2821 }
2822 |  ALTER opt_column ColId opt_set_data TYPE_P Typename opt_collate_clause alter_using
2823  {
2824  $$ = cat_str(8,mm_strdup("alter"),$2,$3,$4,mm_strdup("type"),$6,$7,$8);
2825 }
2826 |  ALTER opt_column ColId alter_generic_options
2827  {
2828  $$ = cat_str(4,mm_strdup("alter"),$2,$3,$4);
2829 }
2830 |  ADD_P TableConstraint
2831  {
2832  $$ = cat_str(2,mm_strdup("add"),$2);
2833 }
2834 |  ALTER CONSTRAINT name ConstraintAttributeSpec
2835  {
2836  $$ = cat_str(3,mm_strdup("alter constraint"),$3,$4);
2837 }
2838 |  VALIDATE CONSTRAINT name
2839  {
2840  $$ = cat_str(2,mm_strdup("validate constraint"),$3);
2841 }
2842 |  DROP CONSTRAINT IF_P EXISTS name opt_drop_behavior
2843  {
2844  $$ = cat_str(3,mm_strdup("drop constraint if exists"),$5,$6);
2845 }
2846 |  DROP CONSTRAINT name opt_drop_behavior
2847  {
2848  $$ = cat_str(3,mm_strdup("drop constraint"),$3,$4);
2849 }
2850 |  SET WITH OIDS
2851  {
2852  $$ = mm_strdup("set with oids");
2853 }
2854 |  SET WITHOUT OIDS
2855  {
2856  $$ = mm_strdup("set without oids");
2857 }
2858 |  CLUSTER ON name
2859  {
2860  $$ = cat_str(2,mm_strdup("cluster on"),$3);
2861 }
2862 |  SET WITHOUT CLUSTER
2863  {
2864  $$ = mm_strdup("set without cluster");
2865 }
2866 |  SET LOGGED
2867  {
2868  $$ = mm_strdup("set logged");
2869 }
2870 |  SET UNLOGGED
2871  {
2872  $$ = mm_strdup("set unlogged");
2873 }
2874 |  ENABLE_P TRIGGER name
2875  {
2876  $$ = cat_str(2,mm_strdup("enable trigger"),$3);
2877 }
2878 |  ENABLE_P ALWAYS TRIGGER name
2879  {
2880  $$ = cat_str(2,mm_strdup("enable always trigger"),$4);
2881 }
2882 |  ENABLE_P REPLICA TRIGGER name
2883  {
2884  $$ = cat_str(2,mm_strdup("enable replica trigger"),$4);
2885 }
2886 |  ENABLE_P TRIGGER ALL
2887  {
2888  $$ = mm_strdup("enable trigger all");
2889 }
2890 |  ENABLE_P TRIGGER USER
2891  {
2892  $$ = mm_strdup("enable trigger user");
2893 }
2894 |  DISABLE_P TRIGGER name
2895  {
2896  $$ = cat_str(2,mm_strdup("disable trigger"),$3);
2897 }
2898 |  DISABLE_P TRIGGER ALL
2899  {
2900  $$ = mm_strdup("disable trigger all");
2901 }
2902 |  DISABLE_P TRIGGER USER
2903  {
2904  $$ = mm_strdup("disable trigger user");
2905 }
2906 |  ENABLE_P RULE name
2907  {
2908  $$ = cat_str(2,mm_strdup("enable rule"),$3);
2909 }
2910 |  ENABLE_P ALWAYS RULE name
2911  {
2912  $$ = cat_str(2,mm_strdup("enable always rule"),$4);
2913 }
2914 |  ENABLE_P REPLICA RULE name
2915  {
2916  $$ = cat_str(2,mm_strdup("enable replica rule"),$4);
2917 }
2918 |  DISABLE_P RULE name
2919  {
2920  $$ = cat_str(2,mm_strdup("disable rule"),$3);
2921 }
2922 |  INHERIT qualified_name
2923  {
2924  $$ = cat_str(2,mm_strdup("inherit"),$2);
2925 }
2926 |  NO INHERIT qualified_name
2927  {
2928  $$ = cat_str(2,mm_strdup("no inherit"),$3);
2929 }
2930 |  OF any_name
2931  {
2932  $$ = cat_str(2,mm_strdup("of"),$2);
2933 }
2934 |  NOT OF
2935  {
2936  $$ = mm_strdup("not of");
2937 }
2938 |  OWNER TO RoleSpec
2939  {
2940  $$ = cat_str(2,mm_strdup("owner to"),$3);
2941 }
2942 |  SET TABLESPACE name
2943  {
2944  $$ = cat_str(2,mm_strdup("set tablespace"),$3);
2945 }
2946 |  SET reloptions
2947  {
2948  $$ = cat_str(2,mm_strdup("set"),$2);
2949 }
2950 |  RESET reloptions
2951  {
2952  $$ = cat_str(2,mm_strdup("reset"),$2);
2953 }
2954 |  REPLICA IDENTITY_P replica_identity
2955  {
2956  $$ = cat_str(2,mm_strdup("replica identity"),$3);
2957 }
2958 |  ENABLE_P ROW LEVEL SECURITY
2959  {
2960  $$ = mm_strdup("enable row level security");
2961 }
2962 |  DISABLE_P ROW LEVEL SECURITY
2963  {
2964  $$ = mm_strdup("disable row level security");
2965 }
2966 |  FORCE ROW LEVEL SECURITY
2967  {
2968  $$ = mm_strdup("force row level security");
2969 }
2970 |  NO FORCE ROW LEVEL SECURITY
2971  {
2972  $$ = mm_strdup("no force row level security");
2973 }
2974 |  alter_generic_options
2975  {
2976  $$ = $1;
2977 }
2978 ;
2979 
2980 
2981  alter_column_default:
2982  SET DEFAULT a_expr
2983  {
2984  $$ = cat_str(2,mm_strdup("set default"),$3);
2985 }
2986 |  DROP DEFAULT
2987  {
2988  $$ = mm_strdup("drop default");
2989 }
2990 ;
2991 
2992 
2993  opt_drop_behavior:
2994  CASCADE
2995  {
2996  $$ = mm_strdup("cascade");
2997 }
2998 |  RESTRICT
2999  {
3000  $$ = mm_strdup("restrict");
3001 }
3002 |
3003  {
3004  $$=EMPTY; }
3005 ;
3006 
3007 
3008  opt_collate_clause:
3009  COLLATE any_name
3010  {
3011  $$ = cat_str(2,mm_strdup("collate"),$2);
3012 }
3013 |
3014  {
3015  $$=EMPTY; }
3016 ;
3017 
3018 
3019  alter_using:
3020  USING a_expr
3021  {
3022  $$ = cat_str(2,mm_strdup("using"),$2);
3023 }
3024 |
3025  {
3026  $$=EMPTY; }
3027 ;
3028 
3029 
3030  replica_identity:
3031  NOTHING
3032  {
3033  $$ = mm_strdup("nothing");
3034 }
3035 |  FULL
3036  {
3037  $$ = mm_strdup("full");
3038 }
3039 |  DEFAULT
3040  {
3041  $$ = mm_strdup("default");
3042 }
3043 |  USING INDEX name
3044  {
3045  $$ = cat_str(2,mm_strdup("using index"),$3);
3046 }
3047 ;
3048 
3049 
3050  reloptions:
3051  '(' reloption_list ')'
3052  {
3053  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
3054 }
3055 ;
3056 
3057 
3058  opt_reloptions:
3059  WITH reloptions
3060  {
3061  $$ = cat_str(2,mm_strdup("with"),$2);
3062 }
3063 |
3064  {
3065  $$=EMPTY; }
3066 ;
3067 
3068 
3069  reloption_list:
3070  reloption_elem
3071  {
3072  $$ = $1;
3073 }
3074 |  reloption_list ',' reloption_elem
3075  {
3076  $$ = cat_str(3,$1,mm_strdup(","),$3);
3077 }
3078 ;
3079 
3080 
3081  reloption_elem:
3082  ColLabel '=' def_arg
3083  {
3084  $$ = cat_str(3,$1,mm_strdup("="),$3);
3085 }
3086 |  ColLabel
3087  {
3088  $$ = $1;
3089 }
3090 |  ColLabel '.' ColLabel '=' def_arg
3091  {
3092  $$ = cat_str(5,$1,mm_strdup("."),$3,mm_strdup("="),$5);
3093 }
3094 |  ColLabel '.' ColLabel
3095  {
3096  $$ = cat_str(3,$1,mm_strdup("."),$3);
3097 }
3098 ;
3099 
3100 
3101  AlterCompositeTypeStmt:
3102  ALTER TYPE_P any_name alter_type_cmds
3103  {
3104  $$ = cat_str(3,mm_strdup("alter type"),$3,$4);
3105 }
3106 ;
3107 
3108 
3109  alter_type_cmds:
3110  alter_type_cmd
3111  {
3112  $$ = $1;
3113 }
3114 |  alter_type_cmds ',' alter_type_cmd
3115  {
3116  $$ = cat_str(3,$1,mm_strdup(","),$3);
3117 }
3118 ;
3119 
3120 
3121  alter_type_cmd:
3122  ADD_P ATTRIBUTE TableFuncElement opt_drop_behavior
3123  {
3124  $$ = cat_str(3,mm_strdup("add attribute"),$3,$4);
3125 }
3126 |  DROP ATTRIBUTE IF_P EXISTS ColId opt_drop_behavior
3127  {
3128  $$ = cat_str(3,mm_strdup("drop attribute if exists"),$5,$6);
3129 }
3130 |  DROP ATTRIBUTE ColId opt_drop_behavior
3131  {
3132  $$ = cat_str(3,mm_strdup("drop attribute"),$3,$4);
3133 }
3134 |  ALTER ATTRIBUTE ColId opt_set_data TYPE_P Typename opt_collate_clause opt_drop_behavior
3135  {
3136  $$ = cat_str(7,mm_strdup("alter attribute"),$3,$4,mm_strdup("type"),$6,$7,$8);
3137 }
3138 ;
3139 
3140 
3141  ClosePortalStmt:
3142  CLOSE cursor_name
3143 	{
3144 		char *cursor_marker = $2[0] == ':' ? mm_strdup("$0") : $2;
3145 		$$ = cat2_str(mm_strdup("close"), cursor_marker);
3146 	}
3147 |  CLOSE ALL
3148  {
3149  $$ = mm_strdup("close all");
3150 }
3151 ;
3152 
3153 
3154  CopyStmt:
3155  COPY opt_binary qualified_name opt_column_list opt_oids copy_from opt_program copy_file_name copy_delimiter opt_with copy_options
3156  {
3157 			if (strcmp($6, "from") == 0 &&
3158 			   (strcmp($7, "stdin") == 0 || strcmp($7, "stdout") == 0))
3159 				mmerror(PARSE_ERROR, ET_WARNING, "COPY FROM STDIN is not implemented");
3160 
3161  $$ = cat_str(11,mm_strdup("copy"),$2,$3,$4,$5,$6,$7,$8,$9,$10,$11);
3162 }
3163 |  COPY '(' PreparableStmt ')' TO opt_program copy_file_name opt_with copy_options
3164  {
3165  $$ = cat_str(7,mm_strdup("copy ("),$3,mm_strdup(") to"),$6,$7,$8,$9);
3166 }
3167 ;
3168 
3169 
3170  copy_from:
3171  FROM
3172  {
3173  $$ = mm_strdup("from");
3174 }
3175 |  TO
3176  {
3177  $$ = mm_strdup("to");
3178 }
3179 ;
3180 
3181 
3182  opt_program:
3183  PROGRAM
3184  {
3185  $$ = mm_strdup("program");
3186 }
3187 |
3188  {
3189  $$=EMPTY; }
3190 ;
3191 
3192 
3193  copy_file_name:
3194  ecpg_sconst
3195  {
3196  $$ = $1;
3197 }
3198 |  STDIN
3199  {
3200  $$ = mm_strdup("stdin");
3201 }
3202 |  STDOUT
3203  {
3204  $$ = mm_strdup("stdout");
3205 }
3206 ;
3207 
3208 
3209  copy_options:
3210  copy_opt_list
3211  {
3212  $$ = $1;
3213 }
3214 |  '(' copy_generic_opt_list ')'
3215  {
3216  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
3217 }
3218 ;
3219 
3220 
3221  copy_opt_list:
3222  copy_opt_list copy_opt_item
3223  {
3224  $$ = cat_str(2,$1,$2);
3225 }
3226 |
3227  {
3228  $$=EMPTY; }
3229 ;
3230 
3231 
3232  copy_opt_item:
3233  BINARY
3234  {
3235  $$ = mm_strdup("binary");
3236 }
3237 |  OIDS
3238  {
3239  $$ = mm_strdup("oids");
3240 }
3241 |  FREEZE
3242  {
3243  $$ = mm_strdup("freeze");
3244 }
3245 |  DELIMITER opt_as ecpg_sconst
3246  {
3247  $$ = cat_str(3,mm_strdup("delimiter"),$2,$3);
3248 }
3249 |  NULL_P opt_as ecpg_sconst
3250  {
3251  $$ = cat_str(3,mm_strdup("null"),$2,$3);
3252 }
3253 |  CSV
3254  {
3255  $$ = mm_strdup("csv");
3256 }
3257 |  HEADER_P
3258  {
3259  $$ = mm_strdup("header");
3260 }
3261 |  QUOTE opt_as ecpg_sconst
3262  {
3263  $$ = cat_str(3,mm_strdup("quote"),$2,$3);
3264 }
3265 |  ESCAPE opt_as ecpg_sconst
3266  {
3267  $$ = cat_str(3,mm_strdup("escape"),$2,$3);
3268 }
3269 |  FORCE QUOTE columnList
3270  {
3271  $$ = cat_str(2,mm_strdup("force quote"),$3);
3272 }
3273 |  FORCE QUOTE '*'
3274  {
3275  $$ = mm_strdup("force quote *");
3276 }
3277 |  FORCE NOT NULL_P columnList
3278  {
3279  $$ = cat_str(2,mm_strdup("force not null"),$4);
3280 }
3281 |  FORCE NULL_P columnList
3282  {
3283  $$ = cat_str(2,mm_strdup("force null"),$3);
3284 }
3285 |  ENCODING ecpg_sconst
3286  {
3287  $$ = cat_str(2,mm_strdup("encoding"),$2);
3288 }
3289 ;
3290 
3291 
3292  opt_binary:
3293  BINARY
3294  {
3295  $$ = mm_strdup("binary");
3296 }
3297 |
3298  {
3299  $$=EMPTY; }
3300 ;
3301 
3302 
3303  opt_oids:
3304  WITH OIDS
3305  {
3306  $$ = mm_strdup("with oids");
3307 }
3308 |
3309  {
3310  $$=EMPTY; }
3311 ;
3312 
3313 
3314  copy_delimiter:
3315  opt_using DELIMITERS ecpg_sconst
3316  {
3317  $$ = cat_str(3,$1,mm_strdup("delimiters"),$3);
3318 }
3319 |
3320  {
3321  $$=EMPTY; }
3322 ;
3323 
3324 
3325  opt_using:
3326  USING
3327  {
3328  $$ = mm_strdup("using");
3329 }
3330 |
3331  {
3332  $$=EMPTY; }
3333 ;
3334 
3335 
3336  copy_generic_opt_list:
3337  copy_generic_opt_elem
3338  {
3339  $$ = $1;
3340 }
3341 |  copy_generic_opt_list ',' copy_generic_opt_elem
3342  {
3343  $$ = cat_str(3,$1,mm_strdup(","),$3);
3344 }
3345 ;
3346 
3347 
3348  copy_generic_opt_elem:
3349  ColLabel copy_generic_opt_arg
3350  {
3351  $$ = cat_str(2,$1,$2);
3352 }
3353 ;
3354 
3355 
3356  copy_generic_opt_arg:
3357  opt_boolean_or_string
3358  {
3359  $$ = $1;
3360 }
3361 |  NumericOnly
3362  {
3363  $$ = $1;
3364 }
3365 |  '*'
3366  {
3367  $$ = mm_strdup("*");
3368 }
3369 |  '(' copy_generic_opt_arg_list ')'
3370  {
3371  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
3372 }
3373 |
3374  {
3375  $$=EMPTY; }
3376 ;
3377 
3378 
3379  copy_generic_opt_arg_list:
3380  copy_generic_opt_arg_list_item
3381  {
3382  $$ = $1;
3383 }
3384 |  copy_generic_opt_arg_list ',' copy_generic_opt_arg_list_item
3385  {
3386  $$ = cat_str(3,$1,mm_strdup(","),$3);
3387 }
3388 ;
3389 
3390 
3391  copy_generic_opt_arg_list_item:
3392  opt_boolean_or_string
3393  {
3394  $$ = $1;
3395 }
3396 ;
3397 
3398 
3399  CreateStmt:
3400  CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')' OptInherit OptWith OnCommitOption OptTableSpace
3401  {
3402  $$ = cat_str(11,mm_strdup("create"),$2,mm_strdup("table"),$4,mm_strdup("("),$6,mm_strdup(")"),$8,$9,$10,$11);
3403 }
3404 |  CREATE OptTemp TABLE IF_P NOT EXISTS qualified_name '(' OptTableElementList ')' OptInherit OptWith OnCommitOption OptTableSpace
3405  {
3406  $$ = cat_str(11,mm_strdup("create"),$2,mm_strdup("table if not exists"),$7,mm_strdup("("),$9,mm_strdup(")"),$11,$12,$13,$14);
3407 }
3408 |  CREATE OptTemp TABLE qualified_name OF any_name OptTypedTableElementList OptWith OnCommitOption OptTableSpace
3409  {
3410  $$ = cat_str(10,mm_strdup("create"),$2,mm_strdup("table"),$4,mm_strdup("of"),$6,$7,$8,$9,$10);
3411 }
3412 |  CREATE OptTemp TABLE IF_P NOT EXISTS qualified_name OF any_name OptTypedTableElementList OptWith OnCommitOption OptTableSpace
3413  {
3414  $$ = cat_str(10,mm_strdup("create"),$2,mm_strdup("table if not exists"),$7,mm_strdup("of"),$9,$10,$11,$12,$13);
3415 }
3416 ;
3417 
3418 
3419  OptTemp:
3420  TEMPORARY
3421  {
3422  $$ = mm_strdup("temporary");
3423 }
3424 |  TEMP
3425  {
3426  $$ = mm_strdup("temp");
3427 }
3428 |  LOCAL TEMPORARY
3429  {
3430  $$ = mm_strdup("local temporary");
3431 }
3432 |  LOCAL TEMP
3433  {
3434  $$ = mm_strdup("local temp");
3435 }
3436 |  GLOBAL TEMPORARY
3437  {
3438  $$ = mm_strdup("global temporary");
3439 }
3440 |  GLOBAL TEMP
3441  {
3442  $$ = mm_strdup("global temp");
3443 }
3444 |  UNLOGGED
3445  {
3446  $$ = mm_strdup("unlogged");
3447 }
3448 |
3449  {
3450  $$=EMPTY; }
3451 ;
3452 
3453 
3454  OptTableElementList:
3455  TableElementList
3456  {
3457  $$ = $1;
3458 }
3459 |
3460  {
3461  $$=EMPTY; }
3462 ;
3463 
3464 
3465  OptTypedTableElementList:
3466  '(' TypedTableElementList ')'
3467  {
3468  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
3469 }
3470 |
3471  {
3472  $$=EMPTY; }
3473 ;
3474 
3475 
3476  TableElementList:
3477  TableElement
3478  {
3479  $$ = $1;
3480 }
3481 |  TableElementList ',' TableElement
3482  {
3483  $$ = cat_str(3,$1,mm_strdup(","),$3);
3484 }
3485 ;
3486 
3487 
3488  TypedTableElementList:
3489  TypedTableElement
3490  {
3491  $$ = $1;
3492 }
3493 |  TypedTableElementList ',' TypedTableElement
3494  {
3495  $$ = cat_str(3,$1,mm_strdup(","),$3);
3496 }
3497 ;
3498 
3499 
3500  TableElement:
3501  columnDef
3502  {
3503  $$ = $1;
3504 }
3505 |  TableLikeClause
3506  {
3507  $$ = $1;
3508 }
3509 |  TableConstraint
3510  {
3511  $$ = $1;
3512 }
3513 ;
3514 
3515 
3516  TypedTableElement:
3517  columnOptions
3518  {
3519  $$ = $1;
3520 }
3521 |  TableConstraint
3522  {
3523  $$ = $1;
3524 }
3525 ;
3526 
3527 
3528  columnDef:
3529  ColId Typename create_generic_options ColQualList
3530  {
3531  $$ = cat_str(4,$1,$2,$3,$4);
3532 }
3533 ;
3534 
3535 
3536  columnOptions:
3537  ColId WITH OPTIONS ColQualList
3538  {
3539  $$ = cat_str(3,$1,mm_strdup("with options"),$4);
3540 }
3541 ;
3542 
3543 
3544  ColQualList:
3545  ColQualList ColConstraint
3546  {
3547  $$ = cat_str(2,$1,$2);
3548 }
3549 |
3550  {
3551  $$=EMPTY; }
3552 ;
3553 
3554 
3555  ColConstraint:
3556  CONSTRAINT name ColConstraintElem
3557  {
3558  $$ = cat_str(3,mm_strdup("constraint"),$2,$3);
3559 }
3560 |  ColConstraintElem
3561  {
3562  $$ = $1;
3563 }
3564 |  ConstraintAttr
3565  {
3566  $$ = $1;
3567 }
3568 |  COLLATE any_name
3569  {
3570  $$ = cat_str(2,mm_strdup("collate"),$2);
3571 }
3572 ;
3573 
3574 
3575  ColConstraintElem:
3576  NOT NULL_P
3577  {
3578  $$ = mm_strdup("not null");
3579 }
3580 |  NULL_P
3581  {
3582  $$ = mm_strdup("null");
3583 }
3584 |  UNIQUE opt_definition OptConsTableSpace
3585  {
3586  $$ = cat_str(3,mm_strdup("unique"),$2,$3);
3587 }
3588 |  PRIMARY KEY opt_definition OptConsTableSpace
3589  {
3590  $$ = cat_str(3,mm_strdup("primary key"),$3,$4);
3591 }
3592 |  CHECK '(' a_expr ')' opt_no_inherit
3593  {
3594  $$ = cat_str(4,mm_strdup("check ("),$3,mm_strdup(")"),$5);
3595 }
3596 |  DEFAULT b_expr
3597  {
3598  $$ = cat_str(2,mm_strdup("default"),$2);
3599 }
3600 |  REFERENCES qualified_name opt_column_list key_match key_actions
3601  {
3602  $$ = cat_str(5,mm_strdup("references"),$2,$3,$4,$5);
3603 }
3604 ;
3605 
3606 
3607  ConstraintAttr:
3608  DEFERRABLE
3609  {
3610  $$ = mm_strdup("deferrable");
3611 }
3612 |  NOT DEFERRABLE
3613  {
3614  $$ = mm_strdup("not deferrable");
3615 }
3616 |  INITIALLY DEFERRED
3617  {
3618  $$ = mm_strdup("initially deferred");
3619 }
3620 |  INITIALLY IMMEDIATE
3621  {
3622  $$ = mm_strdup("initially immediate");
3623 }
3624 ;
3625 
3626 
3627  TableLikeClause:
3628  LIKE qualified_name TableLikeOptionList
3629  {
3630  $$ = cat_str(3,mm_strdup("like"),$2,$3);
3631 }
3632 ;
3633 
3634 
3635  TableLikeOptionList:
3636  TableLikeOptionList INCLUDING TableLikeOption
3637  {
3638  $$ = cat_str(3,$1,mm_strdup("including"),$3);
3639 }
3640 |  TableLikeOptionList EXCLUDING TableLikeOption
3641  {
3642  $$ = cat_str(3,$1,mm_strdup("excluding"),$3);
3643 }
3644 |
3645  {
3646  $$=EMPTY; }
3647 ;
3648 
3649 
3650  TableLikeOption:
3651  DEFAULTS
3652  {
3653  $$ = mm_strdup("defaults");
3654 }
3655 |  CONSTRAINTS
3656  {
3657  $$ = mm_strdup("constraints");
3658 }
3659 |  INDEXES
3660  {
3661  $$ = mm_strdup("indexes");
3662 }
3663 |  STORAGE
3664  {
3665  $$ = mm_strdup("storage");
3666 }
3667 |  COMMENTS
3668  {
3669  $$ = mm_strdup("comments");
3670 }
3671 |  ALL
3672  {
3673  $$ = mm_strdup("all");
3674 }
3675 ;
3676 
3677 
3678  TableConstraint:
3679  CONSTRAINT name ConstraintElem
3680  {
3681  $$ = cat_str(3,mm_strdup("constraint"),$2,$3);
3682 }
3683 |  ConstraintElem
3684  {
3685  $$ = $1;
3686 }
3687 ;
3688 
3689 
3690  ConstraintElem:
3691  CHECK '(' a_expr ')' ConstraintAttributeSpec
3692  {
3693  $$ = cat_str(4,mm_strdup("check ("),$3,mm_strdup(")"),$5);
3694 }
3695 |  UNIQUE '(' columnList ')' opt_definition OptConsTableSpace ConstraintAttributeSpec
3696  {
3697  $$ = cat_str(6,mm_strdup("unique ("),$3,mm_strdup(")"),$5,$6,$7);
3698 }
3699 |  UNIQUE ExistingIndex ConstraintAttributeSpec
3700  {
3701  $$ = cat_str(3,mm_strdup("unique"),$2,$3);
3702 }
3703 |  PRIMARY KEY '(' columnList ')' opt_definition OptConsTableSpace ConstraintAttributeSpec
3704  {
3705  $$ = cat_str(6,mm_strdup("primary key ("),$4,mm_strdup(")"),$6,$7,$8);
3706 }
3707 |  PRIMARY KEY ExistingIndex ConstraintAttributeSpec
3708  {
3709  $$ = cat_str(3,mm_strdup("primary key"),$3,$4);
3710 }
3711 |  EXCLUDE access_method_clause '(' ExclusionConstraintList ')' opt_definition OptConsTableSpace ExclusionWhereClause ConstraintAttributeSpec
3712  {
3713  $$ = cat_str(9,mm_strdup("exclude"),$2,mm_strdup("("),$4,mm_strdup(")"),$6,$7,$8,$9);
3714 }
3715 |  FOREIGN KEY '(' columnList ')' REFERENCES qualified_name opt_column_list key_match key_actions ConstraintAttributeSpec
3716  {
3717  $$ = cat_str(8,mm_strdup("foreign key ("),$4,mm_strdup(") references"),$7,$8,$9,$10,$11);
3718 }
3719 ;
3720 
3721 
3722  opt_no_inherit:
3723  NO INHERIT
3724  {
3725  $$ = mm_strdup("no inherit");
3726 }
3727 |
3728  {
3729  $$=EMPTY; }
3730 ;
3731 
3732 
3733  opt_column_list:
3734  '(' columnList ')'
3735  {
3736  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
3737 }
3738 |
3739  {
3740  $$=EMPTY; }
3741 ;
3742 
3743 
3744  columnList:
3745  columnElem
3746  {
3747  $$ = $1;
3748 }
3749 |  columnList ',' columnElem
3750  {
3751  $$ = cat_str(3,$1,mm_strdup(","),$3);
3752 }
3753 ;
3754 
3755 
3756  columnElem:
3757  ColId
3758  {
3759  $$ = $1;
3760 }
3761 ;
3762 
3763 
3764  key_match:
3765  MATCH FULL
3766  {
3767  $$ = mm_strdup("match full");
3768 }
3769 |  MATCH PARTIAL
3770  {
3771 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
3772  $$ = mm_strdup("match partial");
3773 }
3774 |  MATCH SIMPLE
3775  {
3776  $$ = mm_strdup("match simple");
3777 }
3778 |
3779  {
3780  $$=EMPTY; }
3781 ;
3782 
3783 
3784  ExclusionConstraintList:
3785  ExclusionConstraintElem
3786  {
3787  $$ = $1;
3788 }
3789 |  ExclusionConstraintList ',' ExclusionConstraintElem
3790  {
3791  $$ = cat_str(3,$1,mm_strdup(","),$3);
3792 }
3793 ;
3794 
3795 
3796  ExclusionConstraintElem:
3797  index_elem WITH any_operator
3798  {
3799  $$ = cat_str(3,$1,mm_strdup("with"),$3);
3800 }
3801 |  index_elem WITH OPERATOR '(' any_operator ')'
3802  {
3803  $$ = cat_str(4,$1,mm_strdup("with operator ("),$5,mm_strdup(")"));
3804 }
3805 ;
3806 
3807 
3808  ExclusionWhereClause:
3809  WHERE '(' a_expr ')'
3810  {
3811  $$ = cat_str(3,mm_strdup("where ("),$3,mm_strdup(")"));
3812 }
3813 |
3814  {
3815  $$=EMPTY; }
3816 ;
3817 
3818 
3819  key_actions:
3820  key_update
3821  {
3822  $$ = $1;
3823 }
3824 |  key_delete
3825  {
3826  $$ = $1;
3827 }
3828 |  key_update key_delete
3829  {
3830  $$ = cat_str(2,$1,$2);
3831 }
3832 |  key_delete key_update
3833  {
3834  $$ = cat_str(2,$1,$2);
3835 }
3836 |
3837  {
3838  $$=EMPTY; }
3839 ;
3840 
3841 
3842  key_update:
3843  ON UPDATE key_action
3844  {
3845  $$ = cat_str(2,mm_strdup("on update"),$3);
3846 }
3847 ;
3848 
3849 
3850  key_delete:
3851  ON DELETE_P key_action
3852  {
3853  $$ = cat_str(2,mm_strdup("on delete"),$3);
3854 }
3855 ;
3856 
3857 
3858  key_action:
3859  NO ACTION
3860  {
3861  $$ = mm_strdup("no action");
3862 }
3863 |  RESTRICT
3864  {
3865  $$ = mm_strdup("restrict");
3866 }
3867 |  CASCADE
3868  {
3869  $$ = mm_strdup("cascade");
3870 }
3871 |  SET NULL_P
3872  {
3873  $$ = mm_strdup("set null");
3874 }
3875 |  SET DEFAULT
3876  {
3877  $$ = mm_strdup("set default");
3878 }
3879 ;
3880 
3881 
3882  OptInherit:
3883  INHERITS '(' qualified_name_list ')'
3884  {
3885  $$ = cat_str(3,mm_strdup("inherits ("),$3,mm_strdup(")"));
3886 }
3887 |
3888  {
3889  $$=EMPTY; }
3890 ;
3891 
3892 
3893  OptWith:
3894  WITH reloptions
3895  {
3896  $$ = cat_str(2,mm_strdup("with"),$2);
3897 }
3898 |  WITH OIDS
3899  {
3900  $$ = mm_strdup("with oids");
3901 }
3902 |  WITHOUT OIDS
3903  {
3904  $$ = mm_strdup("without oids");
3905 }
3906 |
3907  {
3908  $$=EMPTY; }
3909 ;
3910 
3911 
3912  OnCommitOption:
3913  ON COMMIT DROP
3914  {
3915  $$ = mm_strdup("on commit drop");
3916 }
3917 |  ON COMMIT DELETE_P ROWS
3918  {
3919  $$ = mm_strdup("on commit delete rows");
3920 }
3921 |  ON COMMIT PRESERVE ROWS
3922  {
3923  $$ = mm_strdup("on commit preserve rows");
3924 }
3925 |
3926  {
3927  $$=EMPTY; }
3928 ;
3929 
3930 
3931  OptTableSpace:
3932  TABLESPACE name
3933  {
3934  $$ = cat_str(2,mm_strdup("tablespace"),$2);
3935 }
3936 |
3937  {
3938  $$=EMPTY; }
3939 ;
3940 
3941 
3942  OptConsTableSpace:
3943  USING INDEX TABLESPACE name
3944  {
3945  $$ = cat_str(2,mm_strdup("using index tablespace"),$4);
3946 }
3947 |
3948  {
3949  $$=EMPTY; }
3950 ;
3951 
3952 
3953  ExistingIndex:
3954  USING INDEX index_name
3955  {
3956  $$ = cat_str(2,mm_strdup("using index"),$3);
3957 }
3958 ;
3959 
3960 
3961  create_as_target:
3962  qualified_name opt_column_list OptWith OnCommitOption OptTableSpace
3963  {
3964  $$ = cat_str(5,$1,$2,$3,$4,$5);
3965 }
3966 ;
3967 
3968 
3969  opt_with_data:
3970  WITH DATA_P
3971  {
3972  $$ = mm_strdup("with data");
3973 }
3974 |  WITH NO DATA_P
3975  {
3976  $$ = mm_strdup("with no data");
3977 }
3978 |
3979  {
3980  $$=EMPTY; }
3981 ;
3982 
3983 
3984  CreateMatViewStmt:
3985  CREATE OptNoLog MATERIALIZED VIEW create_mv_target AS SelectStmt opt_with_data
3986  {
3987  $$ = cat_str(7,mm_strdup("create"),$2,mm_strdup("materialized view"),$5,mm_strdup("as"),$7,$8);
3988 }
3989 |  CREATE OptNoLog MATERIALIZED VIEW IF_P NOT EXISTS create_mv_target AS SelectStmt opt_with_data
3990  {
3991  $$ = cat_str(7,mm_strdup("create"),$2,mm_strdup("materialized view if not exists"),$8,mm_strdup("as"),$10,$11);
3992 }
3993 ;
3994 
3995 
3996  create_mv_target:
3997  qualified_name opt_column_list opt_reloptions OptTableSpace
3998  {
3999  $$ = cat_str(4,$1,$2,$3,$4);
4000 }
4001 ;
4002 
4003 
4004  OptNoLog:
4005  UNLOGGED
4006  {
4007  $$ = mm_strdup("unlogged");
4008 }
4009 |
4010  {
4011  $$=EMPTY; }
4012 ;
4013 
4014 
4015  RefreshMatViewStmt:
4016  REFRESH MATERIALIZED VIEW opt_concurrently qualified_name opt_with_data
4017  {
4018  $$ = cat_str(4,mm_strdup("refresh materialized view"),$4,$5,$6);
4019 }
4020 ;
4021 
4022 
4023  CreateSeqStmt:
4024  CREATE OptTemp SEQUENCE qualified_name OptSeqOptList
4025  {
4026  $$ = cat_str(5,mm_strdup("create"),$2,mm_strdup("sequence"),$4,$5);
4027 }
4028 |  CREATE OptTemp SEQUENCE IF_P NOT EXISTS qualified_name OptSeqOptList
4029  {
4030  $$ = cat_str(5,mm_strdup("create"),$2,mm_strdup("sequence if not exists"),$7,$8);
4031 }
4032 ;
4033 
4034 
4035  AlterSeqStmt:
4036  ALTER SEQUENCE qualified_name SeqOptList
4037  {
4038  $$ = cat_str(3,mm_strdup("alter sequence"),$3,$4);
4039 }
4040 |  ALTER SEQUENCE IF_P EXISTS qualified_name SeqOptList
4041  {
4042  $$ = cat_str(3,mm_strdup("alter sequence if exists"),$5,$6);
4043 }
4044 ;
4045 
4046 
4047  OptSeqOptList:
4048  SeqOptList
4049  {
4050  $$ = $1;
4051 }
4052 |
4053  {
4054  $$=EMPTY; }
4055 ;
4056 
4057 
4058  SeqOptList:
4059  SeqOptElem
4060  {
4061  $$ = $1;
4062 }
4063 |  SeqOptList SeqOptElem
4064  {
4065  $$ = cat_str(2,$1,$2);
4066 }
4067 ;
4068 
4069 
4070  SeqOptElem:
4071  CACHE NumericOnly
4072  {
4073  $$ = cat_str(2,mm_strdup("cache"),$2);
4074 }
4075 |  CYCLE
4076  {
4077  $$ = mm_strdup("cycle");
4078 }
4079 |  NO CYCLE
4080  {
4081  $$ = mm_strdup("no cycle");
4082 }
4083 |  INCREMENT opt_by NumericOnly
4084  {
4085  $$ = cat_str(3,mm_strdup("increment"),$2,$3);
4086 }
4087 |  MAXVALUE NumericOnly
4088  {
4089  $$ = cat_str(2,mm_strdup("maxvalue"),$2);
4090 }
4091 |  MINVALUE NumericOnly
4092  {
4093  $$ = cat_str(2,mm_strdup("minvalue"),$2);
4094 }
4095 |  NO MAXVALUE
4096  {
4097  $$ = mm_strdup("no maxvalue");
4098 }
4099 |  NO MINVALUE
4100  {
4101  $$ = mm_strdup("no minvalue");
4102 }
4103 |  OWNED BY any_name
4104  {
4105  $$ = cat_str(2,mm_strdup("owned by"),$3);
4106 }
4107 |  START opt_with NumericOnly
4108  {
4109  $$ = cat_str(3,mm_strdup("start"),$2,$3);
4110 }
4111 |  RESTART
4112  {
4113  $$ = mm_strdup("restart");
4114 }
4115 |  RESTART opt_with NumericOnly
4116  {
4117  $$ = cat_str(3,mm_strdup("restart"),$2,$3);
4118 }
4119 ;
4120 
4121 
4122  opt_by:
4123  BY
4124  {
4125  $$ = mm_strdup("by");
4126 }
4127 |
4128  {
4129  $$=EMPTY; }
4130 ;
4131 
4132 
4133  NumericOnly:
4134  ecpg_fconst
4135  {
4136  $$ = $1;
4137 }
4138 |  '+' ecpg_fconst
4139  {
4140  $$ = cat_str(2,mm_strdup("+"),$2);
4141 }
4142 |  '-' ecpg_fconst
4143  {
4144  $$ = cat_str(2,mm_strdup("-"),$2);
4145 }
4146 |  SignedIconst
4147  {
4148  $$ = $1;
4149 }
4150 ;
4151 
4152 
4153  NumericOnly_list:
4154  NumericOnly
4155  {
4156  $$ = $1;
4157 }
4158 |  NumericOnly_list ',' NumericOnly
4159  {
4160  $$ = cat_str(3,$1,mm_strdup(","),$3);
4161 }
4162 ;
4163 
4164 
4165  CreatePLangStmt:
4166  CREATE opt_or_replace opt_trusted opt_procedural LANGUAGE NonReservedWord_or_Sconst
4167  {
4168  $$ = cat_str(6,mm_strdup("create"),$2,$3,$4,mm_strdup("language"),$6);
4169 }
4170 |  CREATE opt_or_replace opt_trusted opt_procedural LANGUAGE NonReservedWord_or_Sconst HANDLER handler_name opt_inline_handler opt_validator
4171  {
4172  $$ = cat_str(10,mm_strdup("create"),$2,$3,$4,mm_strdup("language"),$6,mm_strdup("handler"),$8,$9,$10);
4173 }
4174 ;
4175 
4176 
4177  opt_trusted:
4178  TRUSTED
4179  {
4180  $$ = mm_strdup("trusted");
4181 }
4182 |
4183  {
4184  $$=EMPTY; }
4185 ;
4186 
4187 
4188  handler_name:
4189  name
4190  {
4191  $$ = $1;
4192 }
4193 |  name attrs
4194  {
4195  $$ = cat_str(2,$1,$2);
4196 }
4197 ;
4198 
4199 
4200  opt_inline_handler:
4201  INLINE_P handler_name
4202  {
4203  $$ = cat_str(2,mm_strdup("inline"),$2);
4204 }
4205 |
4206  {
4207  $$=EMPTY; }
4208 ;
4209 
4210 
4211  validator_clause:
4212  VALIDATOR handler_name
4213  {
4214  $$ = cat_str(2,mm_strdup("validator"),$2);
4215 }
4216 |  NO VALIDATOR
4217  {
4218  $$ = mm_strdup("no validator");
4219 }
4220 ;
4221 
4222 
4223  opt_validator:
4224  validator_clause
4225  {
4226  $$ = $1;
4227 }
4228 |
4229  {
4230  $$=EMPTY; }
4231 ;
4232 
4233 
4234  DropPLangStmt:
4235  DROP opt_procedural LANGUAGE NonReservedWord_or_Sconst opt_drop_behavior
4236  {
4237  $$ = cat_str(5,mm_strdup("drop"),$2,mm_strdup("language"),$4,$5);
4238 }
4239 |  DROP opt_procedural LANGUAGE IF_P EXISTS NonReservedWord_or_Sconst opt_drop_behavior
4240  {
4241  $$ = cat_str(5,mm_strdup("drop"),$2,mm_strdup("language if exists"),$6,$7);
4242 }
4243 ;
4244 
4245 
4246  opt_procedural:
4247  PROCEDURAL
4248  {
4249  $$ = mm_strdup("procedural");
4250 }
4251 |
4252  {
4253  $$=EMPTY; }
4254 ;
4255 
4256 
4257  CreateTableSpaceStmt:
4258  CREATE TABLESPACE name OptTableSpaceOwner LOCATION ecpg_sconst opt_reloptions
4259  {
4260  $$ = cat_str(6,mm_strdup("create tablespace"),$3,$4,mm_strdup("location"),$6,$7);
4261 }
4262 ;
4263 
4264 
4265  OptTableSpaceOwner:
4266  OWNER RoleSpec
4267  {
4268  $$ = cat_str(2,mm_strdup("owner"),$2);
4269 }
4270 |
4271  {
4272  $$=EMPTY; }
4273 ;
4274 
4275 
4276  DropTableSpaceStmt:
4277  DROP TABLESPACE name
4278  {
4279  $$ = cat_str(2,mm_strdup("drop tablespace"),$3);
4280 }
4281 |  DROP TABLESPACE IF_P EXISTS name
4282  {
4283  $$ = cat_str(2,mm_strdup("drop tablespace if exists"),$5);
4284 }
4285 ;
4286 
4287 
4288  CreateExtensionStmt:
4289  CREATE EXTENSION name opt_with create_extension_opt_list
4290  {
4291  $$ = cat_str(4,mm_strdup("create extension"),$3,$4,$5);
4292 }
4293 |  CREATE EXTENSION IF_P NOT EXISTS name opt_with create_extension_opt_list
4294  {
4295  $$ = cat_str(4,mm_strdup("create extension if not exists"),$6,$7,$8);
4296 }
4297 ;
4298 
4299 
4300  create_extension_opt_list:
4301  create_extension_opt_list create_extension_opt_item
4302  {
4303  $$ = cat_str(2,$1,$2);
4304 }
4305 |
4306  {
4307  $$=EMPTY; }
4308 ;
4309 
4310 
4311  create_extension_opt_item:
4312  SCHEMA name
4313  {
4314  $$ = cat_str(2,mm_strdup("schema"),$2);
4315 }
4316 |  VERSION_P NonReservedWord_or_Sconst
4317  {
4318  $$ = cat_str(2,mm_strdup("version"),$2);
4319 }
4320 |  FROM NonReservedWord_or_Sconst
4321  {
4322  $$ = cat_str(2,mm_strdup("from"),$2);
4323 }
4324 |  CASCADE
4325  {
4326  $$ = mm_strdup("cascade");
4327 }
4328 ;
4329 
4330 
4331  AlterExtensionStmt:
4332  ALTER EXTENSION name UPDATE alter_extension_opt_list
4333  {
4334  $$ = cat_str(4,mm_strdup("alter extension"),$3,mm_strdup("update"),$5);
4335 }
4336 ;
4337 
4338 
4339  alter_extension_opt_list:
4340  alter_extension_opt_list alter_extension_opt_item
4341  {
4342  $$ = cat_str(2,$1,$2);
4343 }
4344 |
4345  {
4346  $$=EMPTY; }
4347 ;
4348 
4349 
4350  alter_extension_opt_item:
4351  TO NonReservedWord_or_Sconst
4352  {
4353  $$ = cat_str(2,mm_strdup("to"),$2);
4354 }
4355 ;
4356 
4357 
4358  AlterExtensionContentsStmt:
4359  ALTER EXTENSION name add_drop ACCESS METHOD name
4360  {
4361  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("access method"),$7);
4362 }
4363 |  ALTER EXTENSION name add_drop AGGREGATE func_name aggr_args
4364  {
4365  $$ = cat_str(6,mm_strdup("alter extension"),$3,$4,mm_strdup("aggregate"),$6,$7);
4366 }
4367 |  ALTER EXTENSION name add_drop CAST '(' Typename AS Typename ')'
4368  {
4369  $$ = cat_str(8,mm_strdup("alter extension"),$3,$4,mm_strdup("cast ("),$7,mm_strdup("as"),$9,mm_strdup(")"));
4370 }
4371 |  ALTER EXTENSION name add_drop COLLATION any_name
4372  {
4373  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("collation"),$6);
4374 }
4375 |  ALTER EXTENSION name add_drop CONVERSION_P any_name
4376  {
4377  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("conversion"),$6);
4378 }
4379 |  ALTER EXTENSION name add_drop DOMAIN_P Typename
4380  {
4381  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("domain"),$6);
4382 }
4383 |  ALTER EXTENSION name add_drop FUNCTION function_with_argtypes
4384  {
4385  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("function"),$6);
4386 }
4387 |  ALTER EXTENSION name add_drop opt_procedural LANGUAGE name
4388  {
4389  $$ = cat_str(6,mm_strdup("alter extension"),$3,$4,$5,mm_strdup("language"),$7);
4390 }
4391 |  ALTER EXTENSION name add_drop OPERATOR any_operator oper_argtypes
4392  {
4393  $$ = cat_str(6,mm_strdup("alter extension"),$3,$4,mm_strdup("operator"),$6,$7);
4394 }
4395 |  ALTER EXTENSION name add_drop OPERATOR CLASS any_name USING access_method
4396  {
4397  $$ = cat_str(7,mm_strdup("alter extension"),$3,$4,mm_strdup("operator class"),$7,mm_strdup("using"),$9);
4398 }
4399 |  ALTER EXTENSION name add_drop OPERATOR FAMILY any_name USING access_method
4400  {
4401  $$ = cat_str(7,mm_strdup("alter extension"),$3,$4,mm_strdup("operator family"),$7,mm_strdup("using"),$9);
4402 }
4403 |  ALTER EXTENSION name add_drop SCHEMA name
4404  {
4405  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("schema"),$6);
4406 }
4407 |  ALTER EXTENSION name add_drop EVENT TRIGGER name
4408  {
4409  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("event trigger"),$7);
4410 }
4411 |  ALTER EXTENSION name add_drop TABLE any_name
4412  {
4413  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("table"),$6);
4414 }
4415 |  ALTER EXTENSION name add_drop TEXT_P SEARCH PARSER any_name
4416  {
4417  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("text search parser"),$8);
4418 }
4419 |  ALTER EXTENSION name add_drop TEXT_P SEARCH DICTIONARY any_name
4420  {
4421  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("text search dictionary"),$8);
4422 }
4423 |  ALTER EXTENSION name add_drop TEXT_P SEARCH TEMPLATE any_name
4424  {
4425  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("text search template"),$8);
4426 }
4427 |  ALTER EXTENSION name add_drop TEXT_P SEARCH CONFIGURATION any_name
4428  {
4429  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("text search configuration"),$8);
4430 }
4431 |  ALTER EXTENSION name add_drop SEQUENCE any_name
4432  {
4433  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("sequence"),$6);
4434 }
4435 |  ALTER EXTENSION name add_drop VIEW any_name
4436  {
4437  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("view"),$6);
4438 }
4439 |  ALTER EXTENSION name add_drop MATERIALIZED VIEW any_name
4440  {
4441  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("materialized view"),$7);
4442 }
4443 |  ALTER EXTENSION name add_drop FOREIGN TABLE any_name
4444  {
4445  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("foreign table"),$7);
4446 }
4447 |  ALTER EXTENSION name add_drop FOREIGN DATA_P WRAPPER name
4448  {
4449  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("foreign data wrapper"),$8);
4450 }
4451 |  ALTER EXTENSION name add_drop SERVER name
4452  {
4453  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("server"),$6);
4454 }
4455 |  ALTER EXTENSION name add_drop TRANSFORM FOR Typename LANGUAGE name
4456  {
4457  $$ = cat_str(7,mm_strdup("alter extension"),$3,$4,mm_strdup("transform for"),$7,mm_strdup("language"),$9);
4458 }
4459 |  ALTER EXTENSION name add_drop TYPE_P Typename
4460  {
4461  $$ = cat_str(5,mm_strdup("alter extension"),$3,$4,mm_strdup("type"),$6);
4462 }
4463 ;
4464 
4465 
4466  CreateFdwStmt:
4467  CREATE FOREIGN DATA_P WRAPPER name opt_fdw_options create_generic_options
4468  {
4469  $$ = cat_str(4,mm_strdup("create foreign data wrapper"),$5,$6,$7);
4470 }
4471 ;
4472 
4473 
4474  fdw_option:
4475  HANDLER handler_name
4476  {
4477  $$ = cat_str(2,mm_strdup("handler"),$2);
4478 }
4479 |  NO HANDLER
4480  {
4481  $$ = mm_strdup("no handler");
4482 }
4483 |  VALIDATOR handler_name
4484  {
4485  $$ = cat_str(2,mm_strdup("validator"),$2);
4486 }
4487 |  NO VALIDATOR
4488  {
4489  $$ = mm_strdup("no validator");
4490 }
4491 ;
4492 
4493 
4494  fdw_options:
4495  fdw_option
4496  {
4497  $$ = $1;
4498 }
4499 |  fdw_options fdw_option
4500  {
4501  $$ = cat_str(2,$1,$2);
4502 }
4503 ;
4504 
4505 
4506  opt_fdw_options:
4507  fdw_options
4508  {
4509  $$ = $1;
4510 }
4511 |
4512  {
4513  $$=EMPTY; }
4514 ;
4515 
4516 
4517  DropFdwStmt:
4518  DROP FOREIGN DATA_P WRAPPER name opt_drop_behavior
4519  {
4520  $$ = cat_str(3,mm_strdup("drop foreign data wrapper"),$5,$6);
4521 }
4522 |  DROP FOREIGN DATA_P WRAPPER IF_P EXISTS name opt_drop_behavior
4523  {
4524  $$ = cat_str(3,mm_strdup("drop foreign data wrapper if exists"),$7,$8);
4525 }
4526 ;
4527 
4528 
4529  AlterFdwStmt:
4530  ALTER FOREIGN DATA_P WRAPPER name opt_fdw_options alter_generic_options
4531  {
4532  $$ = cat_str(4,mm_strdup("alter foreign data wrapper"),$5,$6,$7);
4533 }
4534 |  ALTER FOREIGN DATA_P WRAPPER name fdw_options
4535  {
4536  $$ = cat_str(3,mm_strdup("alter foreign data wrapper"),$5,$6);
4537 }
4538 ;
4539 
4540 
4541  create_generic_options:
4542  OPTIONS '(' generic_option_list ')'
4543  {
4544  $$ = cat_str(3,mm_strdup("options ("),$3,mm_strdup(")"));
4545 }
4546 |
4547  {
4548  $$=EMPTY; }
4549 ;
4550 
4551 
4552  generic_option_list:
4553  generic_option_elem
4554  {
4555  $$ = $1;
4556 }
4557 |  generic_option_list ',' generic_option_elem
4558  {
4559  $$ = cat_str(3,$1,mm_strdup(","),$3);
4560 }
4561 ;
4562 
4563 
4564  alter_generic_options:
4565  OPTIONS '(' alter_generic_option_list ')'
4566  {
4567  $$ = cat_str(3,mm_strdup("options ("),$3,mm_strdup(")"));
4568 }
4569 ;
4570 
4571 
4572  alter_generic_option_list:
4573  alter_generic_option_elem
4574  {
4575  $$ = $1;
4576 }
4577 |  alter_generic_option_list ',' alter_generic_option_elem
4578  {
4579  $$ = cat_str(3,$1,mm_strdup(","),$3);
4580 }
4581 ;
4582 
4583 
4584  alter_generic_option_elem:
4585  generic_option_elem
4586  {
4587  $$ = $1;
4588 }
4589 |  SET generic_option_elem
4590  {
4591  $$ = cat_str(2,mm_strdup("set"),$2);
4592 }
4593 |  ADD_P generic_option_elem
4594  {
4595  $$ = cat_str(2,mm_strdup("add"),$2);
4596 }
4597 |  DROP generic_option_name
4598  {
4599  $$ = cat_str(2,mm_strdup("drop"),$2);
4600 }
4601 ;
4602 
4603 
4604  generic_option_elem:
4605  generic_option_name generic_option_arg
4606  {
4607  $$ = cat_str(2,$1,$2);
4608 }
4609 ;
4610 
4611 
4612  generic_option_name:
4613  ColLabel
4614  {
4615  $$ = $1;
4616 }
4617 ;
4618 
4619 
4620  generic_option_arg:
4621  ecpg_sconst
4622  {
4623  $$ = $1;
4624 }
4625 ;
4626 
4627 
4628  CreateForeignServerStmt:
4629  CREATE SERVER name opt_type opt_foreign_server_version FOREIGN DATA_P WRAPPER name create_generic_options
4630  {
4631  $$ = cat_str(7,mm_strdup("create server"),$3,$4,$5,mm_strdup("foreign data wrapper"),$9,$10);
4632 }
4633 ;
4634 
4635 
4636  opt_type:
4637  TYPE_P ecpg_sconst
4638  {
4639  $$ = cat_str(2,mm_strdup("type"),$2);
4640 }
4641 |
4642  {
4643  $$=EMPTY; }
4644 ;
4645 
4646 
4647  foreign_server_version:
4648  VERSION_P ecpg_sconst
4649  {
4650  $$ = cat_str(2,mm_strdup("version"),$2);
4651 }
4652 |  VERSION_P NULL_P
4653  {
4654  $$ = mm_strdup("version null");
4655 }
4656 ;
4657 
4658 
4659  opt_foreign_server_version:
4660  foreign_server_version
4661  {
4662  $$ = $1;
4663 }
4664 |
4665  {
4666  $$=EMPTY; }
4667 ;
4668 
4669 
4670  DropForeignServerStmt:
4671  DROP SERVER name opt_drop_behavior
4672  {
4673  $$ = cat_str(3,mm_strdup("drop server"),$3,$4);
4674 }
4675 |  DROP SERVER IF_P EXISTS name opt_drop_behavior
4676  {
4677  $$ = cat_str(3,mm_strdup("drop server if exists"),$5,$6);
4678 }
4679 ;
4680 
4681 
4682  AlterForeignServerStmt:
4683  ALTER SERVER name foreign_server_version alter_generic_options
4684  {
4685  $$ = cat_str(4,mm_strdup("alter server"),$3,$4,$5);
4686 }
4687 |  ALTER SERVER name foreign_server_version
4688  {
4689  $$ = cat_str(3,mm_strdup("alter server"),$3,$4);
4690 }
4691 |  ALTER SERVER name alter_generic_options
4692  {
4693  $$ = cat_str(3,mm_strdup("alter server"),$3,$4);
4694 }
4695 ;
4696 
4697 
4698  CreateForeignTableStmt:
4699  CREATE FOREIGN TABLE qualified_name '(' OptTableElementList ')' OptInherit SERVER name create_generic_options
4700  {
4701  $$ = cat_str(9,mm_strdup("create foreign table"),$4,mm_strdup("("),$6,mm_strdup(")"),$8,mm_strdup("server"),$10,$11);
4702 }
4703 |  CREATE FOREIGN TABLE IF_P NOT EXISTS qualified_name '(' OptTableElementList ')' OptInherit SERVER name create_generic_options
4704  {
4705  $$ = cat_str(9,mm_strdup("create foreign table if not exists"),$7,mm_strdup("("),$9,mm_strdup(")"),$11,mm_strdup("server"),$13,$14);
4706 }
4707 ;
4708 
4709 
4710  AlterForeignTableStmt:
4711  ALTER FOREIGN TABLE relation_expr alter_table_cmds
4712  {
4713  $$ = cat_str(3,mm_strdup("alter foreign table"),$4,$5);
4714 }
4715 |  ALTER FOREIGN TABLE IF_P EXISTS relation_expr alter_table_cmds
4716  {
4717  $$ = cat_str(3,mm_strdup("alter foreign table if exists"),$6,$7);
4718 }
4719 ;
4720 
4721 
4722  ImportForeignSchemaStmt:
4723  IMPORT_P FOREIGN SCHEMA name import_qualification FROM SERVER name INTO name create_generic_options
4724  {
4725  $$ = cat_str(8,mm_strdup("import foreign schema"),$4,$5,mm_strdup("from server"),$8,mm_strdup("into"),$10,$11);
4726 }
4727 ;
4728 
4729 
4730  import_qualification_type:
4731  LIMIT TO
4732  {
4733  $$ = mm_strdup("limit to");
4734 }
4735 |  EXCEPT
4736  {
4737  $$ = mm_strdup("except");
4738 }
4739 ;
4740 
4741 
4742  import_qualification:
4743  import_qualification_type '(' relation_expr_list ')'
4744  {
4745  $$ = cat_str(4,$1,mm_strdup("("),$3,mm_strdup(")"));
4746 }
4747 |
4748  {
4749  $$=EMPTY; }
4750 ;
4751 
4752 
4753  CreateUserMappingStmt:
4754  CREATE USER MAPPING FOR auth_ident SERVER name create_generic_options
4755  {
4756  $$ = cat_str(5,mm_strdup("create user mapping for"),$5,mm_strdup("server"),$7,$8);
4757 }
4758 ;
4759 
4760 
4761  auth_ident:
4762  RoleSpec
4763  {
4764  $$ = $1;
4765 }
4766 |  USER
4767  {
4768  $$ = mm_strdup("user");
4769 }
4770 ;
4771 
4772 
4773  DropUserMappingStmt:
4774  DROP USER MAPPING FOR auth_ident SERVER name
4775  {
4776  $$ = cat_str(4,mm_strdup("drop user mapping for"),$5,mm_strdup("server"),$7);
4777 }
4778 |  DROP USER MAPPING IF_P EXISTS FOR auth_ident SERVER name
4779  {
4780  $$ = cat_str(4,mm_strdup("drop user mapping if exists for"),$7,mm_strdup("server"),$9);
4781 }
4782 ;
4783 
4784 
4785  AlterUserMappingStmt:
4786  ALTER USER MAPPING FOR auth_ident SERVER name alter_generic_options
4787  {
4788  $$ = cat_str(5,mm_strdup("alter user mapping for"),$5,mm_strdup("server"),$7,$8);
4789 }
4790 ;
4791 
4792 
4793  CreatePolicyStmt:
4794  CREATE POLICY name ON qualified_name RowSecurityDefaultForCmd RowSecurityDefaultToRole RowSecurityOptionalExpr RowSecurityOptionalWithCheck
4795  {
4796  $$ = cat_str(8,mm_strdup("create policy"),$3,mm_strdup("on"),$5,$6,$7,$8,$9);
4797 }
4798 ;
4799 
4800 
4801  AlterPolicyStmt:
4802  ALTER POLICY name ON qualified_name RowSecurityOptionalToRole RowSecurityOptionalExpr RowSecurityOptionalWithCheck
4803  {
4804  $$ = cat_str(7,mm_strdup("alter policy"),$3,mm_strdup("on"),$5,$6,$7,$8);
4805 }
4806 ;
4807 
4808 
4809  DropPolicyStmt:
4810  DROP POLICY name ON any_name opt_drop_behavior
4811  {
4812  $$ = cat_str(5,mm_strdup("drop policy"),$3,mm_strdup("on"),$5,$6);
4813 }
4814 |  DROP POLICY IF_P EXISTS name ON any_name opt_drop_behavior
4815  {
4816  $$ = cat_str(5,mm_strdup("drop policy if exists"),$5,mm_strdup("on"),$7,$8);
4817 }
4818 ;
4819 
4820 
4821  RowSecurityOptionalExpr:
4822  USING '(' a_expr ')'
4823  {
4824  $$ = cat_str(3,mm_strdup("using ("),$3,mm_strdup(")"));
4825 }
4826 |
4827  {
4828  $$=EMPTY; }
4829 ;
4830 
4831 
4832  RowSecurityOptionalWithCheck:
4833  WITH CHECK '(' a_expr ')'
4834  {
4835  $$ = cat_str(3,mm_strdup("with check ("),$4,mm_strdup(")"));
4836 }
4837 |
4838  {
4839  $$=EMPTY; }
4840 ;
4841 
4842 
4843  RowSecurityDefaultToRole:
4844  TO role_list
4845  {
4846  $$ = cat_str(2,mm_strdup("to"),$2);
4847 }
4848 |
4849  {
4850  $$=EMPTY; }
4851 ;
4852 
4853 
4854  RowSecurityOptionalToRole:
4855  TO role_list
4856  {
4857  $$ = cat_str(2,mm_strdup("to"),$2);
4858 }
4859 |
4860  {
4861  $$=EMPTY; }
4862 ;
4863 
4864 
4865  RowSecurityDefaultForCmd:
4866  FOR row_security_cmd
4867  {
4868  $$ = cat_str(2,mm_strdup("for"),$2);
4869 }
4870 |
4871  {
4872  $$=EMPTY; }
4873 ;
4874 
4875 
4876  row_security_cmd:
4877  ALL
4878  {
4879  $$ = mm_strdup("all");
4880 }
4881 |  SELECT
4882  {
4883  $$ = mm_strdup("select");
4884 }
4885 |  INSERT
4886  {
4887  $$ = mm_strdup("insert");
4888 }
4889 |  UPDATE
4890  {
4891  $$ = mm_strdup("update");
4892 }
4893 |  DELETE_P
4894  {
4895  $$ = mm_strdup("delete");
4896 }
4897 ;
4898 
4899 
4900  CreateAmStmt:
4901  CREATE ACCESS METHOD name TYPE_P INDEX HANDLER handler_name
4902  {
4903  $$ = cat_str(4,mm_strdup("create access method"),$4,mm_strdup("type index handler"),$8);
4904 }
4905 ;
4906 
4907 
4908  CreateTrigStmt:
4909  CREATE TRIGGER name TriggerActionTime TriggerEvents ON qualified_name TriggerForSpec TriggerWhen EXECUTE PROCEDURE func_name '(' TriggerFuncArgs ')'
4910  {
4911  $$ = cat_str(13,mm_strdup("create trigger"),$3,$4,$5,mm_strdup("on"),$7,$8,$9,mm_strdup("execute procedure"),$12,mm_strdup("("),$14,mm_strdup(")"));
4912 }
4913 |  CREATE CONSTRAINT TRIGGER name AFTER TriggerEvents ON qualified_name OptConstrFromTable ConstraintAttributeSpec FOR EACH ROW TriggerWhen EXECUTE PROCEDURE func_name '(' TriggerFuncArgs ')'
4914  {
4915  $$ = 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(")"));
4916 }
4917 ;
4918 
4919 
4920  TriggerActionTime:
4921  BEFORE
4922  {
4923  $$ = mm_strdup("before");
4924 }
4925 |  AFTER
4926  {
4927  $$ = mm_strdup("after");
4928 }
4929 |  INSTEAD OF
4930  {
4931  $$ = mm_strdup("instead of");
4932 }
4933 ;
4934 
4935 
4936  TriggerEvents:
4937  TriggerOneEvent
4938  {
4939  $$ = $1;
4940 }
4941 |  TriggerEvents OR TriggerOneEvent
4942  {
4943  $$ = cat_str(3,$1,mm_strdup("or"),$3);
4944 }
4945 ;
4946 
4947 
4948  TriggerOneEvent:
4949  INSERT
4950  {
4951  $$ = mm_strdup("insert");
4952 }
4953 |  DELETE_P
4954  {
4955  $$ = mm_strdup("delete");
4956 }
4957 |  UPDATE
4958  {
4959  $$ = mm_strdup("update");
4960 }
4961 |  UPDATE OF columnList
4962  {
4963  $$ = cat_str(2,mm_strdup("update of"),$3);
4964 }
4965 |  TRUNCATE
4966  {
4967  $$ = mm_strdup("truncate");
4968 }
4969 ;
4970 
4971 
4972  TriggerForSpec:
4973  FOR TriggerForOptEach TriggerForType
4974  {
4975  $$ = cat_str(3,mm_strdup("for"),$2,$3);
4976 }
4977 |
4978  {
4979  $$=EMPTY; }
4980 ;
4981 
4982 
4983  TriggerForOptEach:
4984  EACH
4985  {
4986  $$ = mm_strdup("each");
4987 }
4988 |
4989  {
4990  $$=EMPTY; }
4991 ;
4992 
4993 
4994  TriggerForType:
4995  ROW
4996  {
4997  $$ = mm_strdup("row");
4998 }
4999 |  STATEMENT
5000  {
5001  $$ = mm_strdup("statement");
5002 }
5003 ;
5004 
5005 
5006  TriggerWhen:
5007  WHEN '(' a_expr ')'
5008  {
5009  $$ = cat_str(3,mm_strdup("when ("),$3,mm_strdup(")"));
5010 }
5011 |
5012  {
5013  $$=EMPTY; }
5014 ;
5015 
5016 
5017  TriggerFuncArgs:
5018  TriggerFuncArg
5019  {
5020  $$ = $1;
5021 }
5022 |  TriggerFuncArgs ',' TriggerFuncArg
5023  {
5024  $$ = cat_str(3,$1,mm_strdup(","),$3);
5025 }
5026 |
5027  {
5028  $$=EMPTY; }
5029 ;
5030 
5031 
5032  TriggerFuncArg:
5033  Iconst
5034  {
5035  $$ = $1;
5036 }
5037 |  ecpg_fconst
5038  {
5039  $$ = $1;
5040 }
5041 |  ecpg_sconst
5042  {
5043  $$ = $1;
5044 }
5045 |  ColLabel
5046  {
5047  $$ = $1;
5048 }
5049 ;
5050 
5051 
5052  OptConstrFromTable:
5053  FROM qualified_name
5054  {
5055  $$ = cat_str(2,mm_strdup("from"),$2);
5056 }
5057 |
5058  {
5059  $$=EMPTY; }
5060 ;
5061 
5062 
5063  ConstraintAttributeSpec:
5064 
5065  {
5066  $$=EMPTY; }
5067 |  ConstraintAttributeSpec ConstraintAttributeElem
5068  {
5069  $$ = cat_str(2,$1,$2);
5070 }
5071 ;
5072 
5073 
5074  ConstraintAttributeElem:
5075  NOT DEFERRABLE
5076  {
5077  $$ = mm_strdup("not deferrable");
5078 }
5079 |  DEFERRABLE
5080  {
5081  $$ = mm_strdup("deferrable");
5082 }
5083 |  INITIALLY IMMEDIATE
5084  {
5085  $$ = mm_strdup("initially immediate");
5086 }
5087 |  INITIALLY DEFERRED
5088  {
5089  $$ = mm_strdup("initially deferred");
5090 }
5091 |  NOT VALID
5092  {
5093  $$ = mm_strdup("not valid");
5094 }
5095 |  NO INHERIT
5096  {
5097  $$ = mm_strdup("no inherit");
5098 }
5099 ;
5100 
5101 
5102  DropTrigStmt:
5103  DROP TRIGGER name ON any_name opt_drop_behavior
5104  {
5105  $$ = cat_str(5,mm_strdup("drop trigger"),$3,mm_strdup("on"),$5,$6);
5106 }
5107 |  DROP TRIGGER IF_P EXISTS name ON any_name opt_drop_behavior
5108  {
5109  $$ = cat_str(5,mm_strdup("drop trigger if exists"),$5,mm_strdup("on"),$7,$8);
5110 }
5111 ;
5112 
5113 
5114  CreateEventTrigStmt:
5115  CREATE EVENT TRIGGER name ON ColLabel EXECUTE PROCEDURE func_name '(' ')'
5116  {
5117  $$ = cat_str(7,mm_strdup("create event trigger"),$4,mm_strdup("on"),$6,mm_strdup("execute procedure"),$9,mm_strdup("( )"));
5118 }
5119 |  CREATE EVENT TRIGGER name ON ColLabel WHEN event_trigger_when_list EXECUTE PROCEDURE func_name '(' ')'
5120  {
5121  $$ = cat_str(9,mm_strdup("create event trigger"),$4,mm_strdup("on"),$6,mm_strdup("when"),$8,mm_strdup("execute procedure"),$11,mm_strdup("( )"));
5122 }
5123 ;
5124 
5125 
5126  event_trigger_when_list:
5127  event_trigger_when_item
5128  {
5129  $$ = $1;
5130 }
5131 |  event_trigger_when_list AND event_trigger_when_item
5132  {
5133  $$ = cat_str(3,$1,mm_strdup("and"),$3);
5134 }
5135 ;
5136 
5137 
5138  event_trigger_when_item:
5139  ColId IN_P '(' event_trigger_value_list ')'
5140  {
5141  $$ = cat_str(4,$1,mm_strdup("in ("),$4,mm_strdup(")"));
5142 }
5143 ;
5144 
5145 
5146  event_trigger_value_list:
5147  SCONST
5148  {
5149  $$ = mm_strdup("sconst");
5150 }
5151 |  event_trigger_value_list ',' SCONST
5152  {
5153  $$ = cat_str(2,$1,mm_strdup(", sconst"));
5154 }
5155 ;
5156 
5157 
5158  AlterEventTrigStmt:
5159  ALTER EVENT TRIGGER name enable_trigger
5160  {
5161  $$ = cat_str(3,mm_strdup("alter event trigger"),$4,$5);
5162 }
5163 ;
5164 
5165 
5166  enable_trigger:
5167  ENABLE_P
5168  {
5169  $$ = mm_strdup("enable");
5170 }
5171 |  ENABLE_P REPLICA
5172  {
5173  $$ = mm_strdup("enable replica");
5174 }
5175 |  ENABLE_P ALWAYS
5176  {
5177  $$ = mm_strdup("enable always");
5178 }
5179 |  DISABLE_P
5180  {
5181  $$ = mm_strdup("disable");
5182 }
5183 ;
5184 
5185 
5186  CreateAssertStmt:
5187  CREATE ASSERTION name CHECK '(' a_expr ')' ConstraintAttributeSpec
5188  {
5189 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
5190  $$ = cat_str(6,mm_strdup("create assertion"),$3,mm_strdup("check ("),$6,mm_strdup(")"),$8);
5191 }
5192 ;
5193 
5194 
5195  DropAssertStmt:
5196  DROP ASSERTION name opt_drop_behavior
5197  {
5198 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
5199  $$ = cat_str(3,mm_strdup("drop assertion"),$3,$4);
5200 }
5201 ;
5202 
5203 
5204  DefineStmt:
5205  CREATE AGGREGATE func_name aggr_args definition
5206  {
5207  $$ = cat_str(4,mm_strdup("create aggregate"),$3,$4,$5);
5208 }
5209 |  CREATE AGGREGATE func_name old_aggr_definition
5210  {
5211  $$ = cat_str(3,mm_strdup("create aggregate"),$3,$4);
5212 }
5213 |  CREATE OPERATOR any_operator definition
5214  {
5215  $$ = cat_str(3,mm_strdup("create operator"),$3,$4);
5216 }
5217 |  CREATE TYPE_P any_name definition
5218  {
5219  $$ = cat_str(3,mm_strdup("create type"),$3,$4);
5220 }
5221 |  CREATE TYPE_P any_name
5222  {
5223  $$ = cat_str(2,mm_strdup("create type"),$3);
5224 }
5225 |  CREATE TYPE_P any_name AS '(' OptTableFuncElementList ')'
5226  {
5227  $$ = cat_str(5,mm_strdup("create type"),$3,mm_strdup("as ("),$6,mm_strdup(")"));
5228 }
5229 |  CREATE TYPE_P any_name AS ENUM_P '(' opt_enum_val_list ')'
5230  {
5231  $$ = cat_str(5,mm_strdup("create type"),$3,mm_strdup("as enum ("),$7,mm_strdup(")"));
5232 }
5233 |  CREATE TYPE_P any_name AS RANGE definition
5234  {
5235  $$ = cat_str(4,mm_strdup("create type"),$3,mm_strdup("as range"),$6);
5236 }
5237 |  CREATE TEXT_P SEARCH PARSER any_name definition
5238  {
5239  $$ = cat_str(3,mm_strdup("create text search parser"),$5,$6);
5240 }
5241 |  CREATE TEXT_P SEARCH DICTIONARY any_name definition
5242  {
5243  $$ = cat_str(3,mm_strdup("create text search dictionary"),$5,$6);
5244 }
5245 |  CREATE TEXT_P SEARCH TEMPLATE any_name definition
5246  {
5247  $$ = cat_str(3,mm_strdup("create text search template"),$5,$6);
5248 }
5249 |  CREATE TEXT_P SEARCH CONFIGURATION any_name definition
5250  {
5251  $$ = cat_str(3,mm_strdup("create text search configuration"),$5,$6);
5252 }
5253 |  CREATE COLLATION any_name definition
5254  {
5255  $$ = cat_str(3,mm_strdup("create collation"),$3,$4);
5256 }
5257 |  CREATE COLLATION any_name FROM any_name
5258  {
5259  $$ = cat_str(4,mm_strdup("create collation"),$3,mm_strdup("from"),$5);
5260 }
5261 ;
5262 
5263 
5264  definition:
5265  '(' def_list ')'
5266  {
5267  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
5268 }
5269 ;
5270 
5271 
5272  def_list:
5273  def_elem
5274  {
5275  $$ = $1;
5276 }
5277 |  def_list ',' def_elem
5278  {
5279  $$ = cat_str(3,$1,mm_strdup(","),$3);
5280 }
5281 ;
5282 
5283 
5284  def_elem:
5285  ColLabel '=' def_arg
5286  {
5287  $$ = cat_str(3,$1,mm_strdup("="),$3);
5288 }
5289 |  ColLabel
5290  {
5291  $$ = $1;
5292 }
5293 ;
5294 
5295 
5296  def_arg:
5297  func_type
5298  {
5299  $$ = $1;
5300 }
5301 |  reserved_keyword
5302  {
5303  $$ = $1;
5304 }
5305 |  qual_all_Op
5306  {
5307  $$ = $1;
5308 }
5309 |  NumericOnly
5310  {
5311  $$ = $1;
5312 }
5313 |  ecpg_sconst
5314  {
5315  $$ = $1;
5316 }
5317 ;
5318 
5319 
5320  old_aggr_definition:
5321  '(' old_aggr_list ')'
5322  {
5323  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
5324 }
5325 ;
5326 
5327 
5328  old_aggr_list:
5329  old_aggr_elem
5330  {
5331  $$ = $1;
5332 }
5333 |  old_aggr_list ',' old_aggr_elem
5334  {
5335  $$ = cat_str(3,$1,mm_strdup(","),$3);
5336 }
5337 ;
5338 
5339 
5340  old_aggr_elem:
5341  ecpg_ident '=' def_arg
5342  {
5343  $$ = cat_str(3,$1,mm_strdup("="),$3);
5344 }
5345 ;
5346 
5347 
5348  opt_enum_val_list:
5349  enum_val_list
5350  {
5351  $$ = $1;
5352 }
5353 |
5354  {
5355  $$=EMPTY; }
5356 ;
5357 
5358 
5359  enum_val_list:
5360  ecpg_sconst
5361  {
5362  $$ = $1;
5363 }
5364 |  enum_val_list ',' ecpg_sconst
5365  {
5366  $$ = cat_str(3,$1,mm_strdup(","),$3);
5367 }
5368 ;
5369 
5370 
5371  AlterEnumStmt:
5372  ALTER TYPE_P any_name ADD_P VALUE_P opt_if_not_exists ecpg_sconst
5373  {
5374  $$ = cat_str(5,mm_strdup("alter type"),$3,mm_strdup("add value"),$6,$7);
5375 }
5376 |  ALTER TYPE_P any_name ADD_P VALUE_P opt_if_not_exists ecpg_sconst BEFORE ecpg_sconst
5377  {
5378  $$ = cat_str(7,mm_strdup("alter type"),$3,mm_strdup("add value"),$6,$7,mm_strdup("before"),$9);
5379 }
5380 |  ALTER TYPE_P any_name ADD_P VALUE_P opt_if_not_exists ecpg_sconst AFTER ecpg_sconst
5381  {
5382  $$ = cat_str(7,mm_strdup("alter type"),$3,mm_strdup("add value"),$6,$7,mm_strdup("after"),$9);
5383 }
5384 ;
5385 
5386 
5387  opt_if_not_exists:
5388  IF_P NOT EXISTS
5389  {
5390  $$ = mm_strdup("if not exists");
5391 }
5392 |
5393  {
5394  $$=EMPTY; }
5395 ;
5396 
5397 
5398  CreateOpClassStmt:
5399  CREATE OPERATOR CLASS any_name opt_default FOR TYPE_P Typename USING access_method opt_opfamily AS opclass_item_list
5400  {
5401  $$ = cat_str(10,mm_strdup("create operator class"),$4,$5,mm_strdup("for type"),$8,mm_strdup("using"),$10,$11,mm_strdup("as"),$13);
5402 }
5403 ;
5404 
5405 
5406  opclass_item_list:
5407  opclass_item
5408  {
5409  $$ = $1;
5410 }
5411 |  opclass_item_list ',' opclass_item
5412  {
5413  $$ = cat_str(3,$1,mm_strdup(","),$3);
5414 }
5415 ;
5416 
5417 
5418  opclass_item:
5419  OPERATOR Iconst any_operator opclass_purpose opt_recheck
5420  {
5421  $$ = cat_str(5,mm_strdup("operator"),$2,$3,$4,$5);
5422 }
5423 |  OPERATOR Iconst any_operator oper_argtypes opclass_purpose opt_recheck
5424  {
5425  $$ = cat_str(6,mm_strdup("operator"),$2,$3,$4,$5,$6);
5426 }
5427 |  FUNCTION Iconst func_name func_args
5428  {
5429  $$ = cat_str(4,mm_strdup("function"),$2,$3,$4);
5430 }
5431 |  FUNCTION Iconst '(' type_list ')' func_name func_args
5432  {
5433  $$ = cat_str(7,mm_strdup("function"),$2,mm_strdup("("),$4,mm_strdup(")"),$6,$7);
5434 }
5435 |  STORAGE Typename
5436  {
5437  $$ = cat_str(2,mm_strdup("storage"),$2);
5438 }
5439 ;
5440 
5441 
5442  opt_default:
5443  DEFAULT
5444  {
5445  $$ = mm_strdup("default");
5446 }
5447 |
5448  {
5449  $$=EMPTY; }
5450 ;
5451 
5452 
5453  opt_opfamily:
5454  FAMILY any_name
5455  {
5456  $$ = cat_str(2,mm_strdup("family"),$2);
5457 }
5458 |
5459  {
5460  $$=EMPTY; }
5461 ;
5462 
5463 
5464  opclass_purpose:
5465  FOR SEARCH
5466  {
5467  $$ = mm_strdup("for search");
5468 }
5469 |  FOR ORDER BY any_name
5470  {
5471  $$ = cat_str(2,mm_strdup("for order by"),$4);
5472 }
5473 |
5474  {
5475  $$=EMPTY; }
5476 ;
5477 
5478 
5479  opt_recheck:
5480  RECHECK
5481  {
5482 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
5483  $$ = mm_strdup("recheck");
5484 }
5485 |
5486  {
5487  $$=EMPTY; }
5488 ;
5489 
5490 
5491  CreateOpFamilyStmt:
5492  CREATE OPERATOR FAMILY any_name USING access_method
5493  {
5494  $$ = cat_str(4,mm_strdup("create operator family"),$4,mm_strdup("using"),$6);
5495 }
5496 ;
5497 
5498 
5499  AlterOpFamilyStmt:
5500  ALTER OPERATOR FAMILY any_name USING access_method ADD_P opclass_item_list
5501  {
5502  $$ = cat_str(6,mm_strdup("alter operator family"),$4,mm_strdup("using"),$6,mm_strdup("add"),$8);
5503 }
5504 |  ALTER OPERATOR FAMILY any_name USING access_method DROP opclass_drop_list
5505  {
5506  $$ = cat_str(6,mm_strdup("alter operator family"),$4,mm_strdup("using"),$6,mm_strdup("drop"),$8);
5507 }
5508 ;
5509 
5510 
5511  opclass_drop_list:
5512  opclass_drop
5513  {
5514  $$ = $1;
5515 }
5516 |  opclass_drop_list ',' opclass_drop
5517  {
5518  $$ = cat_str(3,$1,mm_strdup(","),$3);
5519 }
5520 ;
5521 
5522 
5523  opclass_drop:
5524  OPERATOR Iconst '(' type_list ')'
5525  {
5526  $$ = cat_str(5,mm_strdup("operator"),$2,mm_strdup("("),$4,mm_strdup(")"));
5527 }
5528 |  FUNCTION Iconst '(' type_list ')'
5529  {
5530  $$ = cat_str(5,mm_strdup("function"),$2,mm_strdup("("),$4,mm_strdup(")"));
5531 }
5532 ;
5533 
5534 
5535  DropOpClassStmt:
5536  DROP OPERATOR CLASS any_name USING access_method opt_drop_behavior
5537  {
5538  $$ = cat_str(5,mm_strdup("drop operator class"),$4,mm_strdup("using"),$6,$7);
5539 }
5540 |  DROP OPERATOR CLASS IF_P EXISTS any_name USING access_method opt_drop_behavior
5541  {
5542  $$ = cat_str(5,mm_strdup("drop operator class if exists"),$6,mm_strdup("using"),$8,$9);
5543 }
5544 ;
5545 
5546 
5547  DropOpFamilyStmt:
5548  DROP OPERATOR FAMILY any_name USING access_method opt_drop_behavior
5549  {
5550  $$ = cat_str(5,mm_strdup("drop operator family"),$4,mm_strdup("using"),$6,$7);
5551 }
5552 |  DROP OPERATOR FAMILY IF_P EXISTS any_name USING access_method opt_drop_behavior
5553  {
5554  $$ = cat_str(5,mm_strdup("drop operator family if exists"),$6,mm_strdup("using"),$8,$9);
5555 }
5556 ;
5557 
5558 
5559  DropOwnedStmt:
5560  DROP OWNED BY role_list opt_drop_behavior
5561  {
5562  $$ = cat_str(3,mm_strdup("drop owned by"),$4,$5);
5563 }
5564 ;
5565 
5566 
5567  ReassignOwnedStmt:
5568  REASSIGN OWNED BY role_list TO RoleSpec
5569  {
5570  $$ = cat_str(4,mm_strdup("reassign owned by"),$4,mm_strdup("to"),$6);
5571 }
5572 ;
5573 
5574 
5575  DropStmt:
5576  DROP drop_type IF_P EXISTS any_name_list opt_drop_behavior
5577  {
5578  $$ = cat_str(5,mm_strdup("drop"),$2,mm_strdup("if exists"),$5,$6);
5579 }
5580 |  DROP drop_type any_name_list opt_drop_behavior
5581  {
5582  $$ = cat_str(4,mm_strdup("drop"),$2,$3,$4);
5583 }
5584 |  DROP TYPE_P type_name_list opt_drop_behavior
5585  {
5586  $$ = cat_str(3,mm_strdup("drop type"),$3,$4);
5587 }
5588 |  DROP TYPE_P IF_P EXISTS type_name_list opt_drop_behavior
5589  {
5590  $$ = cat_str(3,mm_strdup("drop type if exists"),$5,$6);
5591 }
5592 |  DROP DOMAIN_P type_name_list opt_drop_behavior
5593  {
5594  $$ = cat_str(3,mm_strdup("drop domain"),$3,$4);
5595 }
5596 |  DROP DOMAIN_P IF_P EXISTS type_name_list opt_drop_behavior
5597  {
5598  $$ = cat_str(3,mm_strdup("drop domain if exists"),$5,$6);
5599 }
5600 |  DROP INDEX CONCURRENTLY any_name_list opt_drop_behavior
5601  {
5602  $$ = cat_str(3,mm_strdup("drop index concurrently"),$4,$5);
5603 }
5604 |  DROP INDEX CONCURRENTLY IF_P EXISTS any_name_list opt_drop_behavior
5605  {
5606  $$ = cat_str(3,mm_strdup("drop index concurrently if exists"),$6,$7);
5607 }
5608 ;
5609 
5610 
5611  drop_type:
5612  TABLE
5613  {
5614  $$ = mm_strdup("table");
5615 }
5616 |  SEQUENCE
5617  {
5618  $$ = mm_strdup("sequence");
5619 }
5620 |  VIEW
5621  {
5622  $$ = mm_strdup("view");
5623 }
5624 |  MATERIALIZED VIEW
5625  {
5626  $$ = mm_strdup("materialized view");
5627 }
5628 |  INDEX
5629  {
5630  $$ = mm_strdup("index");
5631 }
5632 |  FOREIGN TABLE
5633  {
5634  $$ = mm_strdup("foreign table");
5635 }
5636 |  ACCESS METHOD
5637  {
5638  $$ = mm_strdup("access method");
5639 }
5640 |  EVENT TRIGGER
5641  {
5642  $$ = mm_strdup("event trigger");
5643 }
5644 |  COLLATION
5645  {
5646  $$ = mm_strdup("collation");
5647 }
5648 |  CONVERSION_P
5649  {
5650  $$ = mm_strdup("conversion");
5651 }
5652 |  SCHEMA
5653  {
5654  $$ = mm_strdup("schema");
5655 }
5656 |  EXTENSION
5657  {
5658  $$ = mm_strdup("extension");
5659 }
5660 |  TEXT_P SEARCH PARSER
5661  {
5662  $$ = mm_strdup("text search parser");
5663 }
5664 |  TEXT_P SEARCH DICTIONARY
5665  {
5666  $$ = mm_strdup("text search dictionary");
5667 }
5668 |  TEXT_P SEARCH TEMPLATE
5669  {
5670  $$ = mm_strdup("text search template");
5671 }
5672 |  TEXT_P SEARCH CONFIGURATION
5673  {
5674  $$ = mm_strdup("text search configuration");
5675 }
5676 ;
5677 
5678 
5679  any_name_list:
5680  any_name
5681  {
5682  $$ = $1;
5683 }
5684 |  any_name_list ',' any_name
5685  {
5686  $$ = cat_str(3,$1,mm_strdup(","),$3);
5687 }
5688 ;
5689 
5690 
5691  any_name:
5692  ColId
5693  {
5694  $$ = $1;
5695 }
5696 |  ColId attrs
5697  {
5698  $$ = cat_str(2,$1,$2);
5699 }
5700 ;
5701 
5702 
5703  attrs:
5704  '.' attr_name
5705  {
5706  $$ = cat_str(2,mm_strdup("."),$2);
5707 }
5708 |  attrs '.' attr_name
5709  {
5710  $$ = cat_str(3,$1,mm_strdup("."),$3);
5711 }
5712 ;
5713 
5714 
5715  type_name_list:
5716  Typename
5717  {
5718  $$ = $1;
5719 }
5720 |  type_name_list ',' Typename
5721  {
5722  $$ = cat_str(3,$1,mm_strdup(","),$3);
5723 }
5724 ;
5725 
5726 
5727  TruncateStmt:
5728  TRUNCATE opt_table relation_expr_list opt_restart_seqs opt_drop_behavior
5729  {
5730  $$ = cat_str(5,mm_strdup("truncate"),$2,$3,$4,$5);
5731 }
5732 ;
5733 
5734 
5735  opt_restart_seqs:
5736  CONTINUE_P IDENTITY_P
5737  {
5738  $$ = mm_strdup("continue identity");
5739 }
5740 |  RESTART IDENTITY_P
5741  {
5742  $$ = mm_strdup("restart identity");
5743 }
5744 |
5745  {
5746  $$=EMPTY; }
5747 ;
5748 
5749 
5750  CommentStmt:
5751  COMMENT ON comment_type any_name IS comment_text
5752  {
5753  $$ = cat_str(5,mm_strdup("comment on"),$3,$4,mm_strdup("is"),$6);
5754 }
5755 |  COMMENT ON TYPE_P Typename IS comment_text
5756  {
5757  $$ = cat_str(4,mm_strdup("comment on type"),$4,mm_strdup("is"),$6);
5758 }
5759 |  COMMENT ON DOMAIN_P Typename IS comment_text
5760  {
5761  $$ = cat_str(4,mm_strdup("comment on domain"),$4,mm_strdup("is"),$6);
5762 }
5763 |  COMMENT ON AGGREGATE func_name aggr_args IS comment_text
5764  {
5765  $$ = cat_str(5,mm_strdup("comment on aggregate"),$4,$5,mm_strdup("is"),$7);
5766 }
5767 |  COMMENT ON FUNCTION func_name func_args IS comment_text
5768  {
5769  $$ = cat_str(5,mm_strdup("comment on function"),$4,$5,mm_strdup("is"),$7);
5770 }
5771 |  COMMENT ON OPERATOR any_operator oper_argtypes IS comment_text
5772  {
5773  $$ = cat_str(5,mm_strdup("comment on operator"),$4,$5,mm_strdup("is"),$7);
5774 }
5775 |  COMMENT ON CONSTRAINT name ON any_name IS comment_text
5776  {
5777  $$ = cat_str(6,mm_strdup("comment on constraint"),$4,mm_strdup("on"),$6,mm_strdup("is"),$8);
5778 }
5779 |  COMMENT ON CONSTRAINT name ON DOMAIN_P any_name IS comment_text
5780  {
5781  $$ = cat_str(6,mm_strdup("comment on constraint"),$4,mm_strdup("on domain"),$7,mm_strdup("is"),$9);
5782 }
5783 |  COMMENT ON POLICY name ON any_name IS comment_text
5784  {
5785  $$ = cat_str(6,mm_strdup("comment on policy"),$4,mm_strdup("on"),$6,mm_strdup("is"),$8);
5786 }
5787 |  COMMENT ON RULE name ON any_name IS comment_text
5788  {
5789  $$ = cat_str(6,mm_strdup("comment on rule"),$4,mm_strdup("on"),$6,mm_strdup("is"),$8);
5790 }
5791 |  COMMENT ON RULE name IS comment_text
5792  {
5793  $$ = cat_str(4,mm_strdup("comment on rule"),$4,mm_strdup("is"),$6);
5794 }
5795 |  COMMENT ON TRANSFORM FOR Typename LANGUAGE name IS comment_text
5796  {
5797  $$ = cat_str(6,mm_strdup("comment on transform for"),$5,mm_strdup("language"),$7,mm_strdup("is"),$9);
5798 }
5799 |  COMMENT ON TRIGGER name ON any_name IS comment_text
5800  {
5801  $$ = cat_str(6,mm_strdup("comment on trigger"),$4,mm_strdup("on"),$6,mm_strdup("is"),$8);
5802 }
5803 |  COMMENT ON OPERATOR CLASS any_name USING access_method IS comment_text
5804  {
5805  $$ = cat_str(6,mm_strdup("comment on operator class"),$5,mm_strdup("using"),$7,mm_strdup("is"),$9);
5806 }
5807 |  COMMENT ON OPERATOR FAMILY any_name USING access_method IS comment_text
5808  {
5809  $$ = cat_str(6,mm_strdup("comment on operator family"),$5,mm_strdup("using"),$7,mm_strdup("is"),$9);
5810 }
5811 |  COMMENT ON LARGE_P OBJECT_P NumericOnly IS comment_text
5812  {
5813  $$ = cat_str(4,mm_strdup("comment on large object"),$5,mm_strdup("is"),$7);
5814 }
5815 |  COMMENT ON CAST '(' Typename AS Typename ')' IS comment_text
5816  {
5817  $$ = cat_str(6,mm_strdup("comment on cast ("),$5,mm_strdup("as"),$7,mm_strdup(") is"),$10);
5818 }
5819 |  COMMENT ON opt_procedural LANGUAGE any_name IS comment_text
5820  {
5821  $$ = cat_str(6,mm_strdup("comment on"),$3,mm_strdup("language"),$5,mm_strdup("is"),$7);
5822 }
5823 ;
5824 
5825 
5826  comment_type:
5827  ACCESS METHOD
5828  {
5829  $$ = mm_strdup("access method");
5830 }
5831 |  COLUMN
5832  {
5833  $$ = mm_strdup("column");
5834 }
5835 |  DATABASE
5836  {
5837  $$ = mm_strdup("database");
5838 }
5839 |  SCHEMA
5840  {
5841  $$ = mm_strdup("schema");
5842 }
5843 |  INDEX
5844  {
5845  $$ = mm_strdup("index");
5846 }
5847 |  SEQUENCE
5848  {
5849  $$ = mm_strdup("sequence");
5850 }
5851 |  TABLE
5852  {
5853  $$ = mm_strdup("table");
5854 }
5855 |  VIEW
5856  {
5857  $$ = mm_strdup("view");
5858 }
5859 |  MATERIALIZED VIEW
5860  {
5861  $$ = mm_strdup("materialized view");
5862 }
5863 |  COLLATION
5864  {
5865  $$ = mm_strdup("collation");
5866 }
5867 |  CONVERSION_P
5868  {
5869  $$ = mm_strdup("conversion");
5870 }
5871 |  TABLESPACE
5872  {
5873  $$ = mm_strdup("tablespace");
5874 }
5875 |  EXTENSION
5876  {
5877  $$ = mm_strdup("extension");
5878 }
5879 |  ROLE
5880  {
5881  $$ = mm_strdup("role");
5882 }
5883 |  FOREIGN TABLE
5884  {
5885  $$ = mm_strdup("foreign table");
5886 }
5887 |  SERVER
5888  {
5889  $$ = mm_strdup("server");
5890 }
5891 |  FOREIGN DATA_P WRAPPER
5892  {
5893  $$ = mm_strdup("foreign data wrapper");
5894 }
5895 |  EVENT TRIGGER
5896  {
5897  $$ = mm_strdup("event trigger");
5898 }
5899 |  TEXT_P SEARCH CONFIGURATION
5900  {
5901  $$ = mm_strdup("text search configuration");
5902 }
5903 |  TEXT_P SEARCH DICTIONARY
5904  {
5905  $$ = mm_strdup("text search dictionary");
5906 }
5907 |  TEXT_P SEARCH PARSER
5908  {
5909  $$ = mm_strdup("text search parser");
5910 }
5911 |  TEXT_P SEARCH TEMPLATE
5912  {
5913  $$ = mm_strdup("text search template");
5914 }
5915 ;
5916 
5917 
5918  comment_text:
5919  ecpg_sconst
5920  {
5921  $$ = $1;
5922 }
5923 |  NULL_P
5924  {
5925  $$ = mm_strdup("null");
5926 }
5927 ;
5928 
5929 
5930  SecLabelStmt:
5931  SECURITY LABEL opt_provider ON security_label_type any_name IS security_label
5932  {
5933  $$ = cat_str(7,mm_strdup("security label"),$3,mm_strdup("on"),$5,$6,mm_strdup("is"),$8);
5934 }
5935 |  SECURITY LABEL opt_provider ON TYPE_P Typename IS security_label
5936  {
5937  $$ = cat_str(6,mm_strdup("security label"),$3,mm_strdup("on type"),$6,mm_strdup("is"),$8);
5938 }
5939 |  SECURITY LABEL opt_provider ON DOMAIN_P Typename IS security_label
5940  {
5941  $$ = cat_str(6,mm_strdup("security label"),$3,mm_strdup("on domain"),$6,mm_strdup("is"),$8);
5942 }
5943 |  SECURITY LABEL opt_provider ON AGGREGATE func_name aggr_args IS security_label
5944  {
5945  $$ = cat_str(7,mm_strdup("security label"),$3,mm_strdup("on aggregate"),$6,$7,mm_strdup("is"),$9);
5946 }
5947 |  SECURITY LABEL opt_provider ON FUNCTION func_name func_args IS security_label
5948  {
5949  $$ = cat_str(7,mm_strdup("security label"),$3,mm_strdup("on function"),$6,$7,mm_strdup("is"),$9);
5950 }
5951 |  SECURITY LABEL opt_provider ON LARGE_P OBJECT_P NumericOnly IS security_label
5952  {
5953  $$ = cat_str(6,mm_strdup("security label"),$3,mm_strdup("on large object"),$7,mm_strdup("is"),$9);
5954 }
5955 |  SECURITY LABEL opt_provider ON opt_procedural LANGUAGE any_name IS security_label
5956  {
5957  $$ = cat_str(8,mm_strdup("security label"),$3,mm_strdup("on"),$5,mm_strdup("language"),$7,mm_strdup("is"),$9);
5958 }
5959 ;
5960 
5961 
5962  opt_provider:
5963  FOR NonReservedWord_or_Sconst
5964  {
5965  $$ = cat_str(2,mm_strdup("for"),$2);
5966 }
5967 |
5968  {
5969  $$=EMPTY; }
5970 ;
5971 
5972 
5973  security_label_type:
5974  COLUMN
5975  {
5976  $$ = mm_strdup("column");
5977 }
5978 |  DATABASE
5979  {
5980  $$ = mm_strdup("database");
5981 }
5982 |  EVENT TRIGGER
5983  {
5984  $$ = mm_strdup("event trigger");
5985 }
5986 |  FOREIGN TABLE
5987  {
5988  $$ = mm_strdup("foreign table");
5989 }
5990 |  SCHEMA
5991  {
5992  $$ = mm_strdup("schema");
5993 }
5994 |  SEQUENCE
5995  {
5996  $$ = mm_strdup("sequence");
5997 }
5998 |  TABLE
5999  {
6000  $$ = mm_strdup("table");
6001 }
6002 |  ROLE
6003  {
6004  $$ = mm_strdup("role");
6005 }
6006 |  TABLESPACE
6007  {
6008  $$ = mm_strdup("tablespace");
6009 }
6010 |  VIEW
6011  {
6012  $$ = mm_strdup("view");
6013 }
6014 |  MATERIALIZED VIEW
6015  {
6016  $$ = mm_strdup("materialized view");
6017 }
6018 ;
6019 
6020 
6021  security_label:
6022  ecpg_sconst
6023  {
6024  $$ = $1;
6025 }
6026 |  NULL_P
6027  {
6028  $$ = mm_strdup("null");
6029 }
6030 ;
6031 
6032 
6033  FetchStmt:
6034  FETCH fetch_args
6035  {
6036  $$ = cat_str(2,mm_strdup("fetch"),$2);
6037 }
6038 |  MOVE fetch_args
6039  {
6040  $$ = cat_str(2,mm_strdup("move"),$2);
6041 }
6042 	| FETCH fetch_args ecpg_fetch_into
6043 	{
6044 		$$ = cat2_str(mm_strdup("fetch"), $2);
6045 	}
6046 	| FETCH FORWARD cursor_name opt_ecpg_fetch_into
6047 	{
6048 		char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
6049 		add_additional_variables($3, false);
6050 		$$ = cat_str(2, mm_strdup("fetch forward"), cursor_marker);
6051 	}
6052 	| FETCH FORWARD from_in cursor_name opt_ecpg_fetch_into
6053 	{
6054 		char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
6055 		add_additional_variables($4, false);
6056 		$$ = cat_str(2, mm_strdup("fetch forward from"), cursor_marker);
6057 	}
6058 	| FETCH BACKWARD cursor_name opt_ecpg_fetch_into
6059 	{
6060 		char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
6061 		add_additional_variables($3, false);
6062 		$$ = cat_str(2, mm_strdup("fetch backward"), cursor_marker);
6063 	}
6064 	| FETCH BACKWARD from_in cursor_name opt_ecpg_fetch_into
6065 	{
6066 		char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
6067 		add_additional_variables($4, false);
6068 		$$ = cat_str(2, mm_strdup("fetch backward from"), cursor_marker);
6069 	}
6070 	| MOVE FORWARD cursor_name
6071 	{
6072 		char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
6073 		add_additional_variables($3, false);
6074 		$$ = cat_str(2, mm_strdup("move forward"), cursor_marker);
6075 	}
6076 	| MOVE FORWARD from_in cursor_name
6077 	{
6078 		char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
6079 		add_additional_variables($4, false);
6080 		$$ = cat_str(2, mm_strdup("move forward from"), cursor_marker);
6081 	}
6082 	| MOVE BACKWARD cursor_name
6083 	{
6084 		char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
6085 		add_additional_variables($3, false);
6086 		$$ = cat_str(2, mm_strdup("move backward"), cursor_marker);
6087 	}
6088 	| MOVE BACKWARD from_in cursor_name
6089 	{
6090 		char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
6091 		add_additional_variables($4, false);
6092 		$$ = cat_str(2, mm_strdup("move backward from"), cursor_marker);
6093 	}
6094 ;
6095 
6096 
6097  fetch_args:
6098  cursor_name
6099  {
6100 		add_additional_variables($1, false);
6101 		if ($1[0] == ':')
6102 		{
6103 			free($1);
6104 			$1 = mm_strdup("$0");
6105 		}
6106 
6107  $$ = $1;
6108 }
6109 |  from_in cursor_name
6110  {
6111 		add_additional_variables($2, false);
6112 		if ($2[0] == ':')
6113 		{
6114 			free($2);
6115 			$2 = mm_strdup("$0");
6116 		}
6117 
6118  $$ = cat_str(2,$1,$2);
6119 }
6120 |  NEXT opt_from_in cursor_name
6121  {
6122 		add_additional_variables($3, false);
6123 		if ($3[0] == ':')
6124 		{
6125 			free($3);
6126 			$3 = mm_strdup("$0");
6127 		}
6128 
6129  $$ = cat_str(3,mm_strdup("next"),$2,$3);
6130 }
6131 |  PRIOR opt_from_in cursor_name
6132  {
6133 		add_additional_variables($3, false);
6134 		if ($3[0] == ':')
6135 		{
6136 			free($3);
6137 			$3 = mm_strdup("$0");
6138 		}
6139 
6140  $$ = cat_str(3,mm_strdup("prior"),$2,$3);
6141 }
6142 |  FIRST_P opt_from_in cursor_name
6143  {
6144 		add_additional_variables($3, false);
6145 		if ($3[0] == ':')
6146 		{
6147 			free($3);
6148 			$3 = mm_strdup("$0");
6149 		}
6150 
6151  $$ = cat_str(3,mm_strdup("first"),$2,$3);
6152 }
6153 |  LAST_P opt_from_in cursor_name
6154  {
6155 		add_additional_variables($3, false);
6156 		if ($3[0] == ':')
6157 		{
6158 			free($3);
6159 			$3 = mm_strdup("$0");
6160 		}
6161 
6162  $$ = cat_str(3,mm_strdup("last"),$2,$3);
6163 }
6164 |  ABSOLUTE_P SignedIconst opt_from_in cursor_name
6165  {
6166 		add_additional_variables($4, false);
6167 		if ($4[0] == ':')
6168 		{
6169 			free($4);
6170 			$4 = mm_strdup("$0");
6171 		}
6172 		if ($2[0] == '$')
6173 		{
6174 			free($2);
6175 			$2 = mm_strdup("$0");
6176 		}
6177 
6178  $$ = cat_str(4,mm_strdup("absolute"),$2,$3,$4);
6179 }
6180 |  RELATIVE_P SignedIconst opt_from_in cursor_name
6181  {
6182 		add_additional_variables($4, false);
6183 		if ($4[0] == ':')
6184 		{
6185 			free($4);
6186 			$4 = mm_strdup("$0");
6187 		}
6188 		if ($2[0] == '$')
6189 		{
6190 			free($2);
6191 			$2 = mm_strdup("$0");
6192 		}
6193 
6194  $$ = cat_str(4,mm_strdup("relative"),$2,$3,$4);
6195 }
6196 |  SignedIconst opt_from_in cursor_name
6197  {
6198 		add_additional_variables($3, false);
6199 		if ($3[0] == ':')
6200 		{
6201 			free($3);
6202 			$3 = mm_strdup("$0");
6203 		}
6204 		if ($1[0] == '$')
6205 		{
6206 			free($1);
6207 			$1 = mm_strdup("$0");
6208 		}
6209 
6210  $$ = cat_str(3,$1,$2,$3);
6211 }
6212 |  ALL opt_from_in cursor_name
6213  {
6214 		add_additional_variables($3, false);
6215 		if ($3[0] == ':')
6216 		{
6217 			free($3);
6218 			$3 = mm_strdup("$0");
6219 		}
6220 
6221  $$ = cat_str(3,mm_strdup("all"),$2,$3);
6222 }
6223 |  FORWARD SignedIconst opt_from_in cursor_name
6224  {
6225 		add_additional_variables($4, false);
6226 		if ($4[0] == ':')
6227 		{
6228 			free($4);
6229 			$4 = mm_strdup("$0");
6230 		}
6231 		if ($2[0] == '$')
6232 		{
6233 			free($2);
6234 			$2 = mm_strdup("$0");
6235 		}
6236 
6237  $$ = cat_str(4,mm_strdup("forward"),$2,$3,$4);
6238 }
6239 |  FORWARD ALL opt_from_in cursor_name
6240  {
6241 		add_additional_variables($4, false);
6242 		if ($4[0] == ':')
6243 		{
6244 			free($4);
6245 			$4 = mm_strdup("$0");
6246 		}
6247 
6248  $$ = cat_str(3,mm_strdup("forward all"),$3,$4);
6249 }
6250 |  BACKWARD SignedIconst opt_from_in cursor_name
6251  {
6252 		add_additional_variables($4, false);
6253 		if ($4[0] == ':')
6254 		{
6255 			free($4);
6256 			$4 = mm_strdup("$0");
6257 		}
6258 		if ($2[0] == '$')
6259 		{
6260 			free($2);
6261 			$2 = mm_strdup("$0");
6262 		}
6263 
6264  $$ = cat_str(4,mm_strdup("backward"),$2,$3,$4);
6265 }
6266 |  BACKWARD ALL opt_from_in cursor_name
6267  {
6268 		add_additional_variables($4, false);
6269 		if ($4[0] == ':')
6270 		{
6271 			free($4);
6272 			$4 = mm_strdup("$0");
6273 		}
6274 
6275  $$ = cat_str(3,mm_strdup("backward all"),$3,$4);
6276 }
6277 ;
6278 
6279 
6280  from_in:
6281  FROM
6282  {
6283  $$ = mm_strdup("from");
6284 }
6285 |  IN_P
6286  {
6287  $$ = mm_strdup("in");
6288 }
6289 ;
6290 
6291 
6292  opt_from_in:
6293  from_in
6294  {
6295  $$ = $1;
6296 }
6297 |
6298  {
6299  $$=EMPTY; }
6300 ;
6301 
6302 
6303  GrantStmt:
6304  GRANT privileges ON privilege_target TO grantee_list opt_grant_grant_option
6305  {
6306  $$ = cat_str(7,mm_strdup("grant"),$2,mm_strdup("on"),$4,mm_strdup("to"),$6,$7);
6307 }
6308 ;
6309 
6310 
6311  RevokeStmt:
6312  REVOKE privileges ON privilege_target FROM grantee_list opt_drop_behavior
6313  {
6314  $$ = cat_str(7,mm_strdup("revoke"),$2,mm_strdup("on"),$4,mm_strdup("from"),$6,$7);
6315 }
6316 |  REVOKE GRANT OPTION FOR privileges ON privilege_target FROM grantee_list opt_drop_behavior
6317  {
6318  $$ = cat_str(7,mm_strdup("revoke grant option for"),$5,mm_strdup("on"),$7,mm_strdup("from"),$9,$10);
6319 }
6320 ;
6321 
6322 
6323  privileges:
6324  privilege_list
6325  {
6326  $$ = $1;
6327 }
6328 |  ALL
6329  {
6330  $$ = mm_strdup("all");
6331 }
6332 |  ALL PRIVILEGES
6333  {
6334  $$ = mm_strdup("all privileges");
6335 }
6336 |  ALL '(' columnList ')'
6337  {
6338  $$ = cat_str(3,mm_strdup("all ("),$3,mm_strdup(")"));
6339 }
6340 |  ALL PRIVILEGES '(' columnList ')'
6341  {
6342  $$ = cat_str(3,mm_strdup("all privileges ("),$4,mm_strdup(")"));
6343 }
6344 ;
6345 
6346 
6347  privilege_list:
6348  privilege
6349  {
6350  $$ = $1;
6351 }
6352 |  privilege_list ',' privilege
6353  {
6354  $$ = cat_str(3,$1,mm_strdup(","),$3);
6355 }
6356 ;
6357 
6358 
6359  privilege:
6360  SELECT opt_column_list
6361  {
6362  $$ = cat_str(2,mm_strdup("select"),$2);
6363 }
6364 |  REFERENCES opt_column_list
6365  {
6366  $$ = cat_str(2,mm_strdup("references"),$2);
6367 }
6368 |  CREATE opt_column_list
6369  {
6370  $$ = cat_str(2,mm_strdup("create"),$2);
6371 }
6372 |  ColId opt_column_list
6373  {
6374  $$ = cat_str(2,$1,$2);
6375 }
6376 ;
6377 
6378 
6379  privilege_target:
6380  qualified_name_list
6381  {
6382  $$ = $1;
6383 }
6384 |  TABLE qualified_name_list
6385  {
6386  $$ = cat_str(2,mm_strdup("table"),$2);
6387 }
6388 |  SEQUENCE qualified_name_list
6389  {
6390  $$ = cat_str(2,mm_strdup("sequence"),$2);
6391 }
6392 |  FOREIGN DATA_P WRAPPER name_list
6393  {
6394  $$ = cat_str(2,mm_strdup("foreign data wrapper"),$4);
6395 }
6396 |  FOREIGN SERVER name_list
6397  {
6398  $$ = cat_str(2,mm_strdup("foreign server"),$3);
6399 }
6400 |  FUNCTION function_with_argtypes_list
6401  {
6402  $$ = cat_str(2,mm_strdup("function"),$2);
6403 }
6404 |  DATABASE name_list
6405  {
6406  $$ = cat_str(2,mm_strdup("database"),$2);
6407 }
6408 |  DOMAIN_P any_name_list
6409  {
6410  $$ = cat_str(2,mm_strdup("domain"),$2);
6411 }
6412 |  LANGUAGE name_list
6413  {
6414  $$ = cat_str(2,mm_strdup("language"),$2);
6415 }
6416 |  LARGE_P OBJECT_P NumericOnly_list
6417  {
6418  $$ = cat_str(2,mm_strdup("large object"),$3);
6419 }
6420 |  SCHEMA name_list
6421  {
6422  $$ = cat_str(2,mm_strdup("schema"),$2);
6423 }
6424 |  TABLESPACE name_list
6425  {
6426  $$ = cat_str(2,mm_strdup("tablespace"),$2);
6427 }
6428 |  TYPE_P any_name_list
6429  {
6430  $$ = cat_str(2,mm_strdup("type"),$2);
6431 }
6432 |  ALL TABLES IN_P SCHEMA name_list
6433  {
6434  $$ = cat_str(2,mm_strdup("all tables in schema"),$5);
6435 }
6436 |  ALL SEQUENCES IN_P SCHEMA name_list
6437  {
6438  $$ = cat_str(2,mm_strdup("all sequences in schema"),$5);
6439 }
6440 |  ALL FUNCTIONS IN_P SCHEMA name_list
6441  {
6442  $$ = cat_str(2,mm_strdup("all functions in schema"),$5);
6443 }
6444 ;
6445 
6446 
6447  grantee_list:
6448  grantee
6449  {
6450  $$ = $1;
6451 }
6452 |  grantee_list ',' grantee
6453  {
6454  $$ = cat_str(3,$1,mm_strdup(","),$3);
6455 }
6456 ;
6457 
6458 
6459  grantee:
6460  RoleSpec
6461  {
6462  $$ = $1;
6463 }
6464 |  GROUP_P RoleSpec
6465  {
6466  $$ = cat_str(2,mm_strdup("group"),$2);
6467 }
6468 ;
6469 
6470 
6471  opt_grant_grant_option:
6472  WITH GRANT OPTION
6473  {
6474  $$ = mm_strdup("with grant option");
6475 }
6476 |
6477  {
6478  $$=EMPTY; }
6479 ;
6480 
6481 
6482  function_with_argtypes_list:
6483  function_with_argtypes
6484  {
6485  $$ = $1;
6486 }
6487 |  function_with_argtypes_list ',' function_with_argtypes
6488  {
6489  $$ = cat_str(3,$1,mm_strdup(","),$3);
6490 }
6491 ;
6492 
6493 
6494  function_with_argtypes:
6495  func_name func_args
6496  {
6497  $$ = cat_str(2,$1,$2);
6498 }
6499 ;
6500 
6501 
6502  GrantRoleStmt:
6503  GRANT privilege_list TO role_list opt_grant_admin_option opt_granted_by
6504  {
6505  $$ = cat_str(6,mm_strdup("grant"),$2,mm_strdup("to"),$4,$5,$6);
6506 }
6507 ;
6508 
6509 
6510  RevokeRoleStmt:
6511  REVOKE privilege_list FROM role_list opt_granted_by opt_drop_behavior
6512  {
6513  $$ = cat_str(6,mm_strdup("revoke"),$2,mm_strdup("from"),$4,$5,$6);
6514 }
6515 |  REVOKE ADMIN OPTION FOR privilege_list FROM role_list opt_granted_by opt_drop_behavior
6516  {
6517  $$ = cat_str(6,mm_strdup("revoke admin option for"),$5,mm_strdup("from"),$7,$8,$9);
6518 }
6519 ;
6520 
6521 
6522  opt_grant_admin_option:
6523  WITH ADMIN OPTION
6524  {
6525  $$ = mm_strdup("with admin option");
6526 }
6527 |
6528  {
6529  $$=EMPTY; }
6530 ;
6531 
6532 
6533  opt_granted_by:
6534  GRANTED BY RoleSpec
6535  {
6536  $$ = cat_str(2,mm_strdup("granted by"),$3);
6537 }
6538 |
6539  {
6540  $$=EMPTY; }
6541 ;
6542 
6543 
6544  AlterDefaultPrivilegesStmt:
6545  ALTER DEFAULT PRIVILEGES DefACLOptionList DefACLAction
6546  {
6547  $$ = cat_str(3,mm_strdup("alter default privileges"),$4,$5);
6548 }
6549 ;
6550 
6551 
6552  DefACLOptionList:
6553  DefACLOptionList DefACLOption
6554  {
6555  $$ = cat_str(2,$1,$2);
6556 }
6557 |
6558  {
6559  $$=EMPTY; }
6560 ;
6561 
6562 
6563  DefACLOption:
6564  IN_P SCHEMA name_list
6565  {
6566  $$ = cat_str(2,mm_strdup("in schema"),$3);
6567 }
6568 |  FOR ROLE role_list
6569  {
6570  $$ = cat_str(2,mm_strdup("for role"),$3);
6571 }
6572 |  FOR USER role_list
6573  {
6574  $$ = cat_str(2,mm_strdup("for user"),$3);
6575 }
6576 ;
6577 
6578 
6579  DefACLAction:
6580  GRANT privileges ON defacl_privilege_target TO grantee_list opt_grant_grant_option
6581  {
6582  $$ = cat_str(7,mm_strdup("grant"),$2,mm_strdup("on"),$4,mm_strdup("to"),$6,$7);
6583 }
6584 |  REVOKE privileges ON defacl_privilege_target FROM grantee_list opt_drop_behavior
6585  {
6586  $$ = cat_str(7,mm_strdup("revoke"),$2,mm_strdup("on"),$4,mm_strdup("from"),$6,$7);
6587 }
6588 |  REVOKE GRANT OPTION FOR privileges ON defacl_privilege_target FROM grantee_list opt_drop_behavior
6589  {
6590  $$ = cat_str(7,mm_strdup("revoke grant option for"),$5,mm_strdup("on"),$7,mm_strdup("from"),$9,$10);
6591 }
6592 ;
6593 
6594 
6595  defacl_privilege_target:
6596  TABLES
6597  {
6598  $$ = mm_strdup("tables");
6599 }
6600 |  FUNCTIONS
6601  {
6602  $$ = mm_strdup("functions");
6603 }
6604 |  SEQUENCES
6605  {
6606  $$ = mm_strdup("sequences");
6607 }
6608 |  TYPES_P
6609  {
6610  $$ = mm_strdup("types");
6611 }
6612 ;
6613 
6614 
6615  IndexStmt:
6616  CREATE opt_unique INDEX opt_concurrently opt_index_name ON qualified_name access_method_clause '(' index_params ')' opt_reloptions OptTableSpace where_clause
6617  {
6618  $$ = 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);
6619 }
6620 |  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
6621  {
6622  $$ = 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);
6623 }
6624 ;
6625 
6626 
6627  opt_unique:
6628  UNIQUE
6629  {
6630  $$ = mm_strdup("unique");
6631 }
6632 |
6633  {
6634  $$=EMPTY; }
6635 ;
6636 
6637 
6638  opt_concurrently:
6639  CONCURRENTLY
6640  {
6641  $$ = mm_strdup("concurrently");
6642 }
6643 |
6644  {
6645  $$=EMPTY; }
6646 ;
6647 
6648 
6649  opt_index_name:
6650  index_name
6651  {
6652  $$ = $1;
6653 }
6654 |
6655  {
6656  $$=EMPTY; }
6657 ;
6658 
6659 
6660  access_method_clause:
6661  USING access_method
6662  {
6663  $$ = cat_str(2,mm_strdup("using"),$2);
6664 }
6665 |
6666  {
6667  $$=EMPTY; }
6668 ;
6669 
6670 
6671  index_params:
6672  index_elem
6673  {
6674  $$ = $1;
6675 }
6676 |  index_params ',' index_elem
6677  {
6678  $$ = cat_str(3,$1,mm_strdup(","),$3);
6679 }
6680 ;
6681 
6682 
6683  index_elem:
6684  ColId opt_collate opt_class opt_asc_desc opt_nulls_order
6685  {
6686  $$ = cat_str(5,$1,$2,$3,$4,$5);
6687 }
6688 |  func_expr_windowless opt_collate opt_class opt_asc_desc opt_nulls_order
6689  {
6690  $$ = cat_str(5,$1,$2,$3,$4,$5);
6691 }
6692 |  '(' a_expr ')' opt_collate opt_class opt_asc_desc opt_nulls_order
6693  {
6694  $$ = cat_str(7,mm_strdup("("),$2,mm_strdup(")"),$4,$5,$6,$7);
6695 }
6696 ;
6697 
6698 
6699  opt_collate:
6700  COLLATE any_name
6701  {
6702  $$ = cat_str(2,mm_strdup("collate"),$2);
6703 }
6704 |
6705  {
6706  $$=EMPTY; }
6707 ;
6708 
6709 
6710  opt_class:
6711  any_name
6712  {
6713  $$ = $1;
6714 }
6715 |
6716  {
6717  $$=EMPTY; }
6718 ;
6719 
6720 
6721  opt_asc_desc:
6722  ASC
6723  {
6724  $$ = mm_strdup("asc");
6725 }
6726 |  DESC
6727  {
6728  $$ = mm_strdup("desc");
6729 }
6730 |
6731  {
6732  $$=EMPTY; }
6733 ;
6734 
6735 
6736  opt_nulls_order:
6737  NULLS_LA FIRST_P
6738  {
6739  $$ = mm_strdup("nulls first");
6740 }
6741 |  NULLS_LA LAST_P
6742  {
6743  $$ = mm_strdup("nulls last");
6744 }
6745 |
6746  {
6747  $$=EMPTY; }
6748 ;
6749 
6750 
6751  CreateFunctionStmt:
6752  CREATE opt_or_replace FUNCTION func_name func_args_with_defaults RETURNS func_return createfunc_opt_list opt_definition
6753  {
6754  $$ = cat_str(9,mm_strdup("create"),$2,mm_strdup("function"),$4,$5,mm_strdup("returns"),$7,$8,$9);
6755 }
6756 |  CREATE opt_or_replace FUNCTION func_name func_args_with_defaults RETURNS TABLE '(' table_func_column_list ')' createfunc_opt_list opt_definition
6757  {
6758  $$ = cat_str(10,mm_strdup("create"),$2,mm_strdup("function"),$4,$5,mm_strdup("returns table ("),$9,mm_strdup(")"),$11,$12);
6759 }
6760 |  CREATE opt_or_replace FUNCTION func_name func_args_with_defaults createfunc_opt_list opt_definition
6761  {
6762  $$ = cat_str(7,mm_strdup("create"),$2,mm_strdup("function"),$4,$5,$6,$7);
6763 }
6764 ;
6765 
6766 
6767  opt_or_replace:
6768  OR REPLACE
6769  {
6770  $$ = mm_strdup("or replace");
6771 }
6772 |
6773  {
6774  $$=EMPTY; }
6775 ;
6776 
6777 
6778  func_args:
6779  '(' func_args_list ')'
6780  {
6781  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
6782 }
6783 |  '(' ')'
6784  {
6785  $$ = mm_strdup("( )");
6786 }
6787 ;
6788 
6789 
6790  func_args_list:
6791  func_arg
6792  {
6793  $$ = $1;
6794 }
6795 |  func_args_list ',' func_arg
6796  {
6797  $$ = cat_str(3,$1,mm_strdup(","),$3);
6798 }
6799 ;
6800 
6801 
6802  func_args_with_defaults:
6803  '(' func_args_with_defaults_list ')'
6804  {
6805  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
6806 }
6807 |  '(' ')'
6808  {
6809  $$ = mm_strdup("( )");
6810 }
6811 ;
6812 
6813 
6814  func_args_with_defaults_list:
6815  func_arg_with_default
6816  {
6817  $$ = $1;
6818 }
6819 |  func_args_with_defaults_list ',' func_arg_with_default
6820  {
6821  $$ = cat_str(3,$1,mm_strdup(","),$3);
6822 }
6823 ;
6824 
6825 
6826  func_arg:
6827  arg_class param_name func_type
6828  {
6829  $$ = cat_str(3,$1,$2,$3);
6830 }
6831 |  param_name arg_class func_type
6832  {
6833  $$ = cat_str(3,$1,$2,$3);
6834 }
6835 |  param_name func_type
6836  {
6837  $$ = cat_str(2,$1,$2);
6838 }
6839 |  arg_class func_type
6840  {
6841  $$ = cat_str(2,$1,$2);
6842 }
6843 |  func_type
6844  {
6845  $$ = $1;
6846 }
6847 ;
6848 
6849 
6850  arg_class:
6851  IN_P
6852  {
6853  $$ = mm_strdup("in");
6854 }
6855 |  OUT_P
6856  {
6857  $$ = mm_strdup("out");
6858 }
6859 |  INOUT
6860  {
6861  $$ = mm_strdup("inout");
6862 }
6863 |  IN_P OUT_P
6864  {
6865  $$ = mm_strdup("in out");
6866 }
6867 |  VARIADIC
6868  {
6869  $$ = mm_strdup("variadic");
6870 }
6871 ;
6872 
6873 
6874  param_name:
6875  type_function_name
6876  {
6877  $$ = $1;
6878 }
6879 ;
6880 
6881 
6882  func_return:
6883  func_type
6884  {
6885  $$ = $1;
6886 }
6887 ;
6888 
6889 
6890  func_type:
6891  Typename
6892  {
6893  $$ = $1;
6894 }
6895 |  type_function_name attrs '%' TYPE_P
6896  {
6897  $$ = cat_str(3,$1,$2,mm_strdup("% type"));
6898 }
6899 |  SETOF type_function_name attrs '%' TYPE_P
6900  {
6901  $$ = cat_str(4,mm_strdup("setof"),$2,$3,mm_strdup("% type"));
6902 }
6903 ;
6904 
6905 
6906  func_arg_with_default:
6907  func_arg
6908  {
6909  $$ = $1;
6910 }
6911 |  func_arg DEFAULT a_expr
6912  {
6913  $$ = cat_str(3,$1,mm_strdup("default"),$3);
6914 }
6915 |  func_arg '=' a_expr
6916  {
6917  $$ = cat_str(3,$1,mm_strdup("="),$3);
6918 }
6919 ;
6920 
6921 
6922  aggr_arg:
6923  func_arg
6924  {
6925 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
6926  $$ = $1;
6927 }
6928 ;
6929 
6930 
6931  aggr_args:
6932  '(' '*' ')'
6933  {
6934  $$ = mm_strdup("( * )");
6935 }
6936 |  '(' aggr_args_list ')'
6937  {
6938  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
6939 }
6940 |  '(' ORDER BY aggr_args_list ')'
6941  {
6942  $$ = cat_str(3,mm_strdup("( order by"),$4,mm_strdup(")"));
6943 }
6944 |  '(' aggr_args_list ORDER BY aggr_args_list ')'
6945  {
6946  $$ = cat_str(5,mm_strdup("("),$2,mm_strdup("order by"),$5,mm_strdup(")"));
6947 }
6948 ;
6949 
6950 
6951  aggr_args_list:
6952  aggr_arg
6953  {
6954  $$ = $1;
6955 }
6956 |  aggr_args_list ',' aggr_arg
6957  {
6958  $$ = cat_str(3,$1,mm_strdup(","),$3);
6959 }
6960 ;
6961 
6962 
6963  createfunc_opt_list:
6964  createfunc_opt_item
6965  {
6966  $$ = $1;
6967 }
6968 |  createfunc_opt_list createfunc_opt_item
6969  {
6970  $$ = cat_str(2,$1,$2);
6971 }
6972 ;
6973 
6974 
6975  common_func_opt_item:
6976  CALLED ON NULL_P INPUT_P
6977  {
6978  $$ = mm_strdup("called on null input");
6979 }
6980 |  RETURNS NULL_P ON NULL_P INPUT_P
6981  {
6982  $$ = mm_strdup("returns null on null input");
6983 }
6984 |  STRICT_P
6985  {
6986  $$ = mm_strdup("strict");
6987 }
6988 |  IMMUTABLE
6989  {
6990  $$ = mm_strdup("immutable");
6991 }
6992 |  STABLE
6993  {
6994  $$ = mm_strdup("stable");
6995 }
6996 |  VOLATILE
6997  {
6998  $$ = mm_strdup("volatile");
6999 }
7000 |  EXTERNAL SECURITY DEFINER
7001  {
7002  $$ = mm_strdup("external security definer");
7003 }
7004 |  EXTERNAL SECURITY INVOKER
7005  {
7006  $$ = mm_strdup("external security invoker");
7007 }
7008 |  SECURITY DEFINER
7009  {
7010  $$ = mm_strdup("security definer");
7011 }
7012 |  SECURITY INVOKER
7013  {
7014  $$ = mm_strdup("security invoker");
7015 }
7016 |  LEAKPROOF
7017  {
7018  $$ = mm_strdup("leakproof");
7019 }
7020 |  NOT LEAKPROOF
7021  {
7022  $$ = mm_strdup("not leakproof");
7023 }
7024 |  COST NumericOnly
7025  {
7026  $$ = cat_str(2,mm_strdup("cost"),$2);
7027 }
7028 |  ROWS NumericOnly
7029  {
7030  $$ = cat_str(2,mm_strdup("rows"),$2);
7031 }
7032 |  FunctionSetResetClause
7033  {
7034  $$ = $1;
7035 }
7036 |  PARALLEL ColId
7037  {
7038  $$ = cat_str(2,mm_strdup("parallel"),$2);
7039 }
7040 ;
7041 
7042 
7043  createfunc_opt_item:
7044  AS func_as
7045  {
7046  $$ = cat_str(2,mm_strdup("as"),$2);
7047 }
7048 |  LANGUAGE NonReservedWord_or_Sconst
7049  {
7050  $$ = cat_str(2,mm_strdup("language"),$2);
7051 }
7052 |  TRANSFORM transform_type_list
7053  {
7054  $$ = cat_str(2,mm_strdup("transform"),$2);
7055 }
7056 |  WINDOW
7057  {
7058  $$ = mm_strdup("window");
7059 }
7060 |  common_func_opt_item
7061  {
7062  $$ = $1;
7063 }
7064 ;
7065 
7066 
7067  func_as:
7068  ecpg_sconst
7069  {
7070  $$ = $1;
7071 }
7072 |  ecpg_sconst ',' ecpg_sconst
7073  {
7074  $$ = cat_str(3,$1,mm_strdup(","),$3);
7075 }
7076 ;
7077 
7078 
7079  transform_type_list:
7080  FOR TYPE_P Typename
7081  {
7082  $$ = cat_str(2,mm_strdup("for type"),$3);
7083 }
7084 |  transform_type_list ',' FOR TYPE_P Typename
7085  {
7086  $$ = cat_str(3,$1,mm_strdup(", for type"),$5);
7087 }
7088 ;
7089 
7090 
7091  opt_definition:
7092  WITH definition
7093  {
7094  $$ = cat_str(2,mm_strdup("with"),$2);
7095 }
7096 |
7097  {
7098  $$=EMPTY; }
7099 ;
7100 
7101 
7102  table_func_column:
7103  param_name func_type
7104  {
7105  $$ = cat_str(2,$1,$2);
7106 }
7107 ;
7108 
7109 
7110  table_func_column_list:
7111  table_func_column
7112  {
7113  $$ = $1;
7114 }
7115 |  table_func_column_list ',' table_func_column
7116  {
7117  $$ = cat_str(3,$1,mm_strdup(","),$3);
7118 }
7119 ;
7120 
7121 
7122  AlterFunctionStmt:
7123  ALTER FUNCTION function_with_argtypes alterfunc_opt_list opt_restrict
7124  {
7125  $$ = cat_str(4,mm_strdup("alter function"),$3,$4,$5);
7126 }
7127 ;
7128 
7129 
7130  alterfunc_opt_list:
7131  common_func_opt_item
7132  {
7133  $$ = $1;
7134 }
7135 |  alterfunc_opt_list common_func_opt_item
7136  {
7137  $$ = cat_str(2,$1,$2);
7138 }
7139 ;
7140 
7141 
7142  opt_restrict:
7143  RESTRICT
7144  {
7145  $$ = mm_strdup("restrict");
7146 }
7147 |
7148  {
7149  $$=EMPTY; }
7150 ;
7151 
7152 
7153  RemoveFuncStmt:
7154  DROP FUNCTION func_name func_args opt_drop_behavior
7155  {
7156  $$ = cat_str(4,mm_strdup("drop function"),$3,$4,$5);
7157 }
7158 |  DROP FUNCTION IF_P EXISTS func_name func_args opt_drop_behavior
7159  {
7160  $$ = cat_str(4,mm_strdup("drop function if exists"),$5,$6,$7);
7161 }
7162 ;
7163 
7164 
7165  RemoveAggrStmt:
7166  DROP AGGREGATE func_name aggr_args opt_drop_behavior
7167  {
7168  $$ = cat_str(4,mm_strdup("drop aggregate"),$3,$4,$5);
7169 }
7170 |  DROP AGGREGATE IF_P EXISTS func_name aggr_args opt_drop_behavior
7171  {
7172  $$ = cat_str(4,mm_strdup("drop aggregate if exists"),$5,$6,$7);
7173 }
7174 ;
7175 
7176 
7177  RemoveOperStmt:
7178  DROP OPERATOR any_operator oper_argtypes opt_drop_behavior
7179  {
7180  $$ = cat_str(4,mm_strdup("drop operator"),$3,$4,$5);
7181 }
7182 |  DROP OPERATOR IF_P EXISTS any_operator oper_argtypes opt_drop_behavior
7183  {
7184  $$ = cat_str(4,mm_strdup("drop operator if exists"),$5,$6,$7);
7185 }
7186 ;
7187 
7188 
7189  oper_argtypes:
7190  '(' Typename ')'
7191  {
7192  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
7193 }
7194 |  '(' Typename ',' Typename ')'
7195  {
7196  $$ = cat_str(5,mm_strdup("("),$2,mm_strdup(","),$4,mm_strdup(")"));
7197 }
7198 |  '(' NONE ',' Typename ')'
7199  {
7200  $$ = cat_str(3,mm_strdup("( none ,"),$4,mm_strdup(")"));
7201 }
7202 |  '(' Typename ',' NONE ')'
7203  {
7204  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(", none )"));
7205 }
7206 ;
7207 
7208 
7209  any_operator:
7210  all_Op
7211  {
7212  $$ = $1;
7213 }
7214 |  ColId '.' any_operator
7215  {
7216  $$ = cat_str(3,$1,mm_strdup("."),$3);
7217 }
7218 ;
7219 
7220 
7221  DoStmt:
7222  DO dostmt_opt_list
7223  {
7224  $$ = cat_str(2,mm_strdup("do"),$2);
7225 }
7226 ;
7227 
7228 
7229  dostmt_opt_list:
7230  dostmt_opt_item
7231  {
7232  $$ = $1;
7233 }
7234 |  dostmt_opt_list dostmt_opt_item
7235  {
7236  $$ = cat_str(2,$1,$2);
7237 }
7238 ;
7239 
7240 
7241  dostmt_opt_item:
7242  ecpg_sconst
7243  {
7244  $$ = $1;
7245 }
7246 |  LANGUAGE NonReservedWord_or_Sconst
7247  {
7248  $$ = cat_str(2,mm_strdup("language"),$2);
7249 }
7250 ;
7251 
7252 
7253  CreateCastStmt:
7254  CREATE CAST '(' Typename AS Typename ')' WITH FUNCTION function_with_argtypes cast_context
7255  {
7256  $$ = cat_str(7,mm_strdup("create cast ("),$4,mm_strdup("as"),$6,mm_strdup(") with function"),$10,$11);
7257 }
7258 |  CREATE CAST '(' Typename AS Typename ')' WITHOUT FUNCTION cast_context
7259  {
7260  $$ = cat_str(6,mm_strdup("create cast ("),$4,mm_strdup("as"),$6,mm_strdup(") without function"),$10);
7261 }
7262 |  CREATE CAST '(' Typename AS Typename ')' WITH INOUT cast_context
7263  {
7264  $$ = cat_str(6,mm_strdup("create cast ("),$4,mm_strdup("as"),$6,mm_strdup(") with inout"),$10);
7265 }
7266 ;
7267 
7268 
7269  cast_context:
7270  AS IMPLICIT_P
7271  {
7272  $$ = mm_strdup("as implicit");
7273 }
7274 |  AS ASSIGNMENT
7275  {
7276  $$ = mm_strdup("as assignment");
7277 }
7278 |
7279  {
7280  $$=EMPTY; }
7281 ;
7282 
7283 
7284  DropCastStmt:
7285  DROP CAST opt_if_exists '(' Typename AS Typename ')' opt_drop_behavior
7286  {
7287  $$ = cat_str(8,mm_strdup("drop cast"),$3,mm_strdup("("),$5,mm_strdup("as"),$7,mm_strdup(")"),$9);
7288 }
7289 ;
7290 
7291 
7292  opt_if_exists:
7293  IF_P EXISTS
7294  {
7295  $$ = mm_strdup("if exists");
7296 }
7297 |
7298  {
7299  $$=EMPTY; }
7300 ;
7301 
7302 
7303  CreateTransformStmt:
7304  CREATE opt_or_replace TRANSFORM FOR Typename LANGUAGE name '(' transform_element_list ')'
7305  {
7306  $$ = cat_str(9,mm_strdup("create"),$2,mm_strdup("transform for"),$5,mm_strdup("language"),$7,mm_strdup("("),$9,mm_strdup(")"));
7307 }
7308 ;
7309 
7310 
7311  transform_element_list:
7312  FROM SQL_P WITH FUNCTION function_with_argtypes ',' TO SQL_P WITH FUNCTION function_with_argtypes
7313  {
7314  $$ = cat_str(4,mm_strdup("from sql with function"),$5,mm_strdup(", to sql with function"),$11);
7315 }
7316 |  TO SQL_P WITH FUNCTION function_with_argtypes ',' FROM SQL_P WITH FUNCTION function_with_argtypes
7317  {
7318  $$ = cat_str(4,mm_strdup("to sql with function"),$5,mm_strdup(", from sql with function"),$11);
7319 }
7320 |  FROM SQL_P WITH FUNCTION function_with_argtypes
7321  {
7322  $$ = cat_str(2,mm_strdup("from sql with function"),$5);
7323 }
7324 |  TO SQL_P WITH FUNCTION function_with_argtypes
7325  {
7326  $$ = cat_str(2,mm_strdup("to sql with function"),$5);
7327 }
7328 ;
7329 
7330 
7331  DropTransformStmt:
7332  DROP TRANSFORM opt_if_exists FOR Typename LANGUAGE name opt_drop_behavior
7333  {
7334  $$ = cat_str(7,mm_strdup("drop transform"),$3,mm_strdup("for"),$5,mm_strdup("language"),$7,$8);
7335 }
7336 ;
7337 
7338 
7339  ReindexStmt:
7340  REINDEX reindex_target_type qualified_name
7341  {
7342  $$ = cat_str(3,mm_strdup("reindex"),$2,$3);
7343 }
7344 |  REINDEX reindex_target_multitable name
7345  {
7346  $$ = cat_str(3,mm_strdup("reindex"),$2,$3);
7347 }
7348 |  REINDEX '(' reindex_option_list ')' reindex_target_type qualified_name
7349  {
7350  $$ = cat_str(5,mm_strdup("reindex ("),$3,mm_strdup(")"),$5,$6);
7351 }
7352 |  REINDEX '(' reindex_option_list ')' reindex_target_multitable name
7353  {
7354  $$ = cat_str(5,mm_strdup("reindex ("),$3,mm_strdup(")"),$5,$6);
7355 }
7356 ;
7357 
7358 
7359  reindex_target_type:
7360  INDEX
7361  {
7362  $$ = mm_strdup("index");
7363 }
7364 |  TABLE
7365  {
7366  $$ = mm_strdup("table");
7367 }
7368 ;
7369 
7370 
7371  reindex_target_multitable:
7372  SCHEMA
7373  {
7374  $$ = mm_strdup("schema");
7375 }
7376 |  SYSTEM_P
7377  {
7378  $$ = mm_strdup("system");
7379 }
7380 |  DATABASE
7381  {
7382  $$ = mm_strdup("database");
7383 }
7384 ;
7385 
7386 
7387  reindex_option_list:
7388  reindex_option_elem
7389  {
7390  $$ = $1;
7391 }
7392 |  reindex_option_list ',' reindex_option_elem
7393  {
7394  $$ = cat_str(3,$1,mm_strdup(","),$3);
7395 }
7396 ;
7397 
7398 
7399  reindex_option_elem:
7400  VERBOSE
7401  {
7402  $$ = mm_strdup("verbose");
7403 }
7404 ;
7405 
7406 
7407  AlterTblSpcStmt:
7408  ALTER TABLESPACE name SET reloptions
7409  {
7410  $$ = cat_str(4,mm_strdup("alter tablespace"),$3,mm_strdup("set"),$5);
7411 }
7412 |  ALTER TABLESPACE name RESET reloptions
7413  {
7414  $$ = cat_str(4,mm_strdup("alter tablespace"),$3,mm_strdup("reset"),$5);
7415 }
7416 ;
7417 
7418 
7419  RenameStmt:
7420  ALTER AGGREGATE func_name aggr_args RENAME TO name
7421  {
7422  $$ = cat_str(5,mm_strdup("alter aggregate"),$3,$4,mm_strdup("rename to"),$7);
7423 }
7424 |  ALTER COLLATION any_name RENAME TO name
7425  {
7426  $$ = cat_str(4,mm_strdup("alter collation"),$3,mm_strdup("rename to"),$6);
7427 }
7428 |  ALTER CONVERSION_P any_name RENAME TO name
7429  {
7430  $$ = cat_str(4,mm_strdup("alter conversion"),$3,mm_strdup("rename to"),$6);
7431 }
7432 |  ALTER DATABASE database_name RENAME TO database_name
7433  {
7434  $$ = cat_str(4,mm_strdup("alter database"),$3,mm_strdup("rename to"),$6);
7435 }
7436 |  ALTER DOMAIN_P any_name RENAME TO name
7437  {
7438  $$ = cat_str(4,mm_strdup("alter domain"),$3,mm_strdup("rename to"),$6);
7439 }
7440 |  ALTER DOMAIN_P any_name RENAME CONSTRAINT name TO name
7441  {
7442  $$ = cat_str(6,mm_strdup("alter domain"),$3,mm_strdup("rename constraint"),$6,mm_strdup("to"),$8);
7443 }
7444 |  ALTER FOREIGN DATA_P WRAPPER name RENAME TO name
7445  {
7446  $$ = cat_str(4,mm_strdup("alter foreign data wrapper"),$5,mm_strdup("rename to"),$8);
7447 }
7448 |  ALTER FUNCTION function_with_argtypes RENAME TO name
7449  {
7450  $$ = cat_str(4,mm_strdup("alter function"),$3,mm_strdup("rename to"),$6);
7451 }
7452 |  ALTER GROUP_P RoleId RENAME TO RoleId
7453  {
7454  $$ = cat_str(4,mm_strdup("alter group"),$3,mm_strdup("rename to"),$6);
7455 }
7456 |  ALTER opt_procedural LANGUAGE name RENAME TO name
7457  {
7458  $$ = cat_str(6,mm_strdup("alter"),$2,mm_strdup("language"),$4,mm_strdup("rename to"),$7);
7459 }
7460 |  ALTER OPERATOR CLASS any_name USING access_method RENAME TO name
7461  {
7462  $$ = cat_str(6,mm_strdup("alter operator class"),$4,mm_strdup("using"),$6,mm_strdup("rename to"),$9);
7463 }
7464 |  ALTER OPERATOR FAMILY any_name USING access_method RENAME TO name
7465  {
7466  $$ = cat_str(6,mm_strdup("alter operator family"),$4,mm_strdup("using"),$6,mm_strdup("rename to"),$9);
7467 }
7468 |  ALTER POLICY name ON qualified_name RENAME TO name
7469  {
7470  $$ = cat_str(6,mm_strdup("alter policy"),$3,mm_strdup("on"),$5,mm_strdup("rename to"),$8);
7471 }
7472 |  ALTER POLICY IF_P EXISTS name ON qualified_name RENAME TO name
7473  {
7474  $$ = cat_str(6,mm_strdup("alter policy if exists"),$5,mm_strdup("on"),$7,mm_strdup("rename to"),$10);
7475 }
7476 |  ALTER SCHEMA name RENAME TO name
7477  {
7478  $$ = cat_str(4,mm_strdup("alter schema"),$3,mm_strdup("rename to"),$6);
7479 }
7480 |  ALTER SERVER name RENAME TO name
7481  {
7482  $$ = cat_str(4,mm_strdup("alter server"),$3,mm_strdup("rename to"),$6);
7483 }
7484 |  ALTER TABLE relation_expr RENAME TO name
7485  {
7486  $$ = cat_str(4,mm_strdup("alter table"),$3,mm_strdup("rename to"),$6);
7487 }
7488 |  ALTER TABLE IF_P EXISTS relation_expr RENAME TO name
7489  {
7490  $$ = cat_str(4,mm_strdup("alter table if exists"),$5,mm_strdup("rename to"),$8);
7491 }
7492 |  ALTER SEQUENCE qualified_name RENAME TO name
7493  {
7494  $$ = cat_str(4,mm_strdup("alter sequence"),$3,mm_strdup("rename to"),$6);
7495 }
7496 |  ALTER SEQUENCE IF_P EXISTS qualified_name RENAME TO name
7497  {
7498  $$ = cat_str(4,mm_strdup("alter sequence if exists"),$5,mm_strdup("rename to"),$8);
7499 }
7500 |  ALTER VIEW qualified_name RENAME TO name
7501  {
7502  $$ = cat_str(4,mm_strdup("alter view"),$3,mm_strdup("rename to"),$6);
7503 }
7504 |  ALTER VIEW IF_P EXISTS qualified_name RENAME TO name
7505  {
7506  $$ = cat_str(4,mm_strdup("alter view if exists"),$5,mm_strdup("rename to"),$8);
7507 }
7508 |  ALTER MATERIALIZED VIEW qualified_name RENAME TO name
7509  {
7510  $$ = cat_str(4,mm_strdup("alter materialized view"),$4,mm_strdup("rename to"),$7);
7511 }
7512 |  ALTER MATERIALIZED VIEW IF_P EXISTS qualified_name RENAME TO name
7513  {
7514  $$ = cat_str(4,mm_strdup("alter materialized view if exists"),$6,mm_strdup("rename to"),$9);
7515 }
7516 |  ALTER INDEX qualified_name RENAME TO name
7517  {
7518  $$ = cat_str(4,mm_strdup("alter index"),$3,mm_strdup("rename to"),$6);
7519 }
7520 |  ALTER INDEX IF_P EXISTS qualified_name RENAME TO name
7521  {
7522  $$ = cat_str(4,mm_strdup("alter index if exists"),$5,mm_strdup("rename to"),$8);
7523 }
7524 |  ALTER FOREIGN TABLE relation_expr RENAME TO name
7525  {
7526  $$ = cat_str(4,mm_strdup("alter foreign table"),$4,mm_strdup("rename to"),$7);
7527 }
7528 |  ALTER FOREIGN TABLE IF_P EXISTS relation_expr RENAME TO name
7529  {
7530  $$ = cat_str(4,mm_strdup("alter foreign table if exists"),$6,mm_strdup("rename to"),$9);
7531 }
7532 |  ALTER TABLE relation_expr RENAME opt_column name TO name
7533  {
7534  $$ = cat_str(7,mm_strdup("alter table"),$3,mm_strdup("rename"),$5,$6,mm_strdup("to"),$8);
7535 }
7536 |  ALTER TABLE IF_P EXISTS relation_expr RENAME opt_column name TO name
7537  {
7538  $$ = cat_str(7,mm_strdup("alter table if exists"),$5,mm_strdup("rename"),$7,$8,mm_strdup("to"),$10);
7539 }
7540 |  ALTER MATERIALIZED VIEW qualified_name RENAME opt_column name TO name
7541  {
7542  $$ = cat_str(7,mm_strdup("alter materialized view"),$4,mm_strdup("rename"),$6,$7,mm_strdup("to"),$9);
7543 }
7544 |  ALTER MATERIALIZED VIEW IF_P EXISTS qualified_name RENAME opt_column name TO name
7545  {
7546  $$ = cat_str(7,mm_strdup("alter materialized view if exists"),$6,mm_strdup("rename"),$8,$9,mm_strdup("to"),$11);
7547 }
7548 |  ALTER TABLE relation_expr RENAME CONSTRAINT name TO name
7549  {
7550  $$ = cat_str(6,mm_strdup("alter table"),$3,mm_strdup("rename constraint"),$6,mm_strdup("to"),$8);
7551 }
7552 |  ALTER TABLE IF_P EXISTS relation_expr RENAME CONSTRAINT name TO name
7553  {
7554  $$ = cat_str(6,mm_strdup("alter table if exists"),$5,mm_strdup("rename constraint"),$8,mm_strdup("to"),$10);
7555 }
7556 |  ALTER FOREIGN TABLE relation_expr RENAME opt_column name TO name
7557  {
7558  $$ = cat_str(7,mm_strdup("alter foreign table"),$4,mm_strdup("rename"),$6,$7,mm_strdup("to"),$9);
7559 }
7560 |  ALTER FOREIGN TABLE IF_P EXISTS relation_expr RENAME opt_column name TO name
7561  {
7562  $$ = cat_str(7,mm_strdup("alter foreign table if exists"),$6,mm_strdup("rename"),$8,$9,mm_strdup("to"),$11);
7563 }
7564 |  ALTER RULE name ON qualified_name RENAME TO name
7565  {
7566  $$ = cat_str(6,mm_strdup("alter rule"),$3,mm_strdup("on"),$5,mm_strdup("rename to"),$8);
7567 }
7568 |  ALTER TRIGGER name ON qualified_name RENAME TO name
7569  {
7570  $$ = cat_str(6,mm_strdup("alter trigger"),$3,mm_strdup("on"),$5,mm_strdup("rename to"),$8);
7571 }
7572 |  ALTER EVENT TRIGGER name RENAME TO name
7573  {
7574  $$ = cat_str(4,mm_strdup("alter event trigger"),$4,mm_strdup("rename to"),$7);
7575 }
7576 |  ALTER ROLE RoleId RENAME TO RoleId
7577  {
7578  $$ = cat_str(4,mm_strdup("alter role"),$3,mm_strdup("rename to"),$6);
7579 }
7580 |  ALTER USER RoleId RENAME TO RoleId
7581  {
7582  $$ = cat_str(4,mm_strdup("alter user"),$3,mm_strdup("rename to"),$6);
7583 }
7584 |  ALTER TABLESPACE name RENAME TO name
7585  {
7586  $$ = cat_str(4,mm_strdup("alter tablespace"),$3,mm_strdup("rename to"),$6);
7587 }
7588 |  ALTER TEXT_P SEARCH PARSER any_name RENAME TO name
7589  {
7590  $$ = cat_str(4,mm_strdup("alter text search parser"),$5,mm_strdup("rename to"),$8);
7591 }
7592 |  ALTER TEXT_P SEARCH DICTIONARY any_name RENAME TO name
7593  {
7594  $$ = cat_str(4,mm_strdup("alter text search dictionary"),$5,mm_strdup("rename to"),$8);
7595 }
7596 |  ALTER TEXT_P SEARCH TEMPLATE any_name RENAME TO name
7597  {
7598  $$ = cat_str(4,mm_strdup("alter text search template"),$5,mm_strdup("rename to"),$8);
7599 }
7600 |  ALTER TEXT_P SEARCH CONFIGURATION any_name RENAME TO name
7601  {
7602  $$ = cat_str(4,mm_strdup("alter text search configuration"),$5,mm_strdup("rename to"),$8);
7603 }
7604 |  ALTER TYPE_P any_name RENAME TO name
7605  {
7606  $$ = cat_str(4,mm_strdup("alter type"),$3,mm_strdup("rename to"),$6);
7607 }
7608 |  ALTER TYPE_P any_name RENAME ATTRIBUTE name TO name opt_drop_behavior
7609  {
7610  $$ = cat_str(7,mm_strdup("alter type"),$3,mm_strdup("rename attribute"),$6,mm_strdup("to"),$8,$9);
7611 }
7612 ;
7613 
7614 
7615  opt_column:
7616  COLUMN
7617  {
7618  $$ = mm_strdup("column");
7619 }
7620 |
7621  {
7622  $$=EMPTY; }
7623 ;
7624 
7625 
7626  opt_set_data:
7627  SET DATA_P
7628  {
7629  $$ = mm_strdup("set data");
7630 }
7631 |
7632  {
7633  $$=EMPTY; }
7634 ;
7635 
7636 
7637  AlterObjectDependsStmt:
7638  ALTER FUNCTION function_with_argtypes DEPENDS ON EXTENSION name
7639  {
7640  $$ = cat_str(4,mm_strdup("alter function"),$3,mm_strdup("depends on extension"),$7);
7641 }
7642 |  ALTER TRIGGER name ON qualified_name DEPENDS ON EXTENSION name
7643  {
7644  $$ = cat_str(6,mm_strdup("alter trigger"),$3,mm_strdup("on"),$5,mm_strdup("depends on extension"),$9);
7645 }
7646 |  ALTER MATERIALIZED VIEW qualified_name DEPENDS ON EXTENSION name
7647  {
7648  $$ = cat_str(4,mm_strdup("alter materialized view"),$4,mm_strdup("depends on extension"),$8);
7649 }
7650 |  ALTER INDEX qualified_name DEPENDS ON EXTENSION name
7651  {
7652  $$ = cat_str(4,mm_strdup("alter index"),$3,mm_strdup("depends on extension"),$7);
7653 }
7654 ;
7655 
7656 
7657  AlterObjectSchemaStmt:
7658  ALTER AGGREGATE func_name aggr_args SET SCHEMA name
7659  {
7660  $$ = cat_str(5,mm_strdup("alter aggregate"),$3,$4,mm_strdup("set schema"),$7);
7661 }
7662 |  ALTER COLLATION any_name SET SCHEMA name
7663  {
7664  $$ = cat_str(4,mm_strdup("alter collation"),$3,mm_strdup("set schema"),$6);
7665 }
7666 |  ALTER CONVERSION_P any_name SET SCHEMA name
7667  {
7668  $$ = cat_str(4,mm_strdup("alter conversion"),$3,mm_strdup("set schema"),$6);
7669 }
7670 |  ALTER DOMAIN_P any_name SET SCHEMA name
7671  {
7672  $$ = cat_str(4,mm_strdup("alter domain"),$3,mm_strdup("set schema"),$6);
7673 }
7674 |  ALTER EXTENSION any_name SET SCHEMA name
7675  {
7676  $$ = cat_str(4,mm_strdup("alter extension"),$3,mm_strdup("set schema"),$6);
7677 }
7678 |  ALTER FUNCTION function_with_argtypes SET SCHEMA name
7679  {
7680  $$ = cat_str(4,mm_strdup("alter function"),$3,mm_strdup("set schema"),$6);
7681 }
7682 |  ALTER OPERATOR any_operator oper_argtypes SET SCHEMA name
7683  {
7684  $$ = cat_str(5,mm_strdup("alter operator"),$3,$4,mm_strdup("set schema"),$7);
7685 }
7686 |  ALTER OPERATOR CLASS any_name USING access_method SET SCHEMA name
7687  {
7688  $$ = cat_str(6,mm_strdup("alter operator class"),$4,mm_strdup("using"),$6,mm_strdup("set schema"),$9);
7689 }
7690 |  ALTER OPERATOR FAMILY any_name USING access_method SET SCHEMA name
7691  {
7692  $$ = cat_str(6,mm_strdup("alter operator family"),$4,mm_strdup("using"),$6,mm_strdup("set schema"),$9);
7693 }
7694 |  ALTER TABLE relation_expr SET SCHEMA name
7695  {
7696  $$ = cat_str(4,mm_strdup("alter table"),$3,mm_strdup("set schema"),$6);
7697 }
7698 |  ALTER TABLE IF_P EXISTS relation_expr SET SCHEMA name
7699  {
7700  $$ = cat_str(4,mm_strdup("alter table if exists"),$5,mm_strdup("set schema"),$8);
7701 }
7702 |  ALTER TEXT_P SEARCH PARSER any_name SET SCHEMA name
7703  {
7704  $$ = cat_str(4,mm_strdup("alter text search parser"),$5,mm_strdup("set schema"),$8);
7705 }
7706 |  ALTER TEXT_P SEARCH DICTIONARY any_name SET SCHEMA name
7707  {
7708  $$ = cat_str(4,mm_strdup("alter text search dictionary"),$5,mm_strdup("set schema"),$8);
7709 }
7710 |  ALTER TEXT_P SEARCH TEMPLATE any_name SET SCHEMA name
7711  {
7712  $$ = cat_str(4,mm_strdup("alter text search template"),$5,mm_strdup("set schema"),$8);
7713 }
7714 |  ALTER TEXT_P SEARCH CONFIGURATION any_name SET SCHEMA name
7715  {
7716  $$ = cat_str(4,mm_strdup("alter text search configuration"),$5,mm_strdup("set schema"),$8);
7717 }
7718 |  ALTER SEQUENCE qualified_name SET SCHEMA name
7719  {
7720  $$ = cat_str(4,mm_strdup("alter sequence"),$3,mm_strdup("set schema"),$6);
7721 }
7722 |  ALTER SEQUENCE IF_P EXISTS qualified_name SET SCHEMA name
7723  {
7724  $$ = cat_str(4,mm_strdup("alter sequence if exists"),$5,mm_strdup("set schema"),$8);
7725 }
7726 |  ALTER VIEW qualified_name SET SCHEMA name
7727  {
7728  $$ = cat_str(4,mm_strdup("alter view"),$3,mm_strdup("set schema"),$6);
7729 }
7730 |  ALTER VIEW IF_P EXISTS qualified_name SET SCHEMA name
7731  {
7732  $$ = cat_str(4,mm_strdup("alter view if exists"),$5,mm_strdup("set schema"),$8);
7733 }
7734 |  ALTER MATERIALIZED VIEW qualified_name SET SCHEMA name
7735  {
7736  $$ = cat_str(4,mm_strdup("alter materialized view"),$4,mm_strdup("set schema"),$7);
7737 }
7738 |  ALTER MATERIALIZED VIEW IF_P EXISTS qualified_name SET SCHEMA name
7739  {
7740  $$ = cat_str(4,mm_strdup("alter materialized view if exists"),$6,mm_strdup("set schema"),$9);
7741 }
7742 |  ALTER FOREIGN TABLE relation_expr SET SCHEMA name
7743  {
7744  $$ = cat_str(4,mm_strdup("alter foreign table"),$4,mm_strdup("set schema"),$7);
7745 }
7746 |  ALTER FOREIGN TABLE IF_P EXISTS relation_expr SET SCHEMA name
7747  {
7748  $$ = cat_str(4,mm_strdup("alter foreign table if exists"),$6,mm_strdup("set schema"),$9);
7749 }
7750 |  ALTER TYPE_P any_name SET SCHEMA name
7751  {
7752  $$ = cat_str(4,mm_strdup("alter type"),$3,mm_strdup("set schema"),$6);
7753 }
7754 ;
7755 
7756 
7757  AlterOperatorStmt:
7758  ALTER OPERATOR any_operator oper_argtypes SET '(' operator_def_list ')'
7759  {
7760  $$ = cat_str(6,mm_strdup("alter operator"),$3,$4,mm_strdup("set ("),$7,mm_strdup(")"));
7761 }
7762 ;
7763 
7764 
7765  operator_def_list:
7766  operator_def_elem
7767  {
7768  $$ = $1;
7769 }
7770 |  operator_def_list ',' operator_def_elem
7771  {
7772  $$ = cat_str(3,$1,mm_strdup(","),$3);
7773 }
7774 ;
7775 
7776 
7777  operator_def_elem:
7778  ColLabel '=' NONE
7779  {
7780  $$ = cat_str(2,$1,mm_strdup("= none"));
7781 }
7782 |  ColLabel '=' def_arg
7783  {
7784  $$ = cat_str(3,$1,mm_strdup("="),$3);
7785 }
7786 ;
7787 
7788 
7789  AlterOwnerStmt:
7790  ALTER AGGREGATE func_name aggr_args OWNER TO RoleSpec
7791  {
7792  $$ = cat_str(5,mm_strdup("alter aggregate"),$3,$4,mm_strdup("owner to"),$7);
7793 }
7794 |  ALTER COLLATION any_name OWNER TO RoleSpec
7795  {
7796  $$ = cat_str(4,mm_strdup("alter collation"),$3,mm_strdup("owner to"),$6);
7797 }
7798 |  ALTER CONVERSION_P any_name OWNER TO RoleSpec
7799  {
7800  $$ = cat_str(4,mm_strdup("alter conversion"),$3,mm_strdup("owner to"),$6);
7801 }
7802 |  ALTER DATABASE database_name OWNER TO RoleSpec
7803  {
7804  $$ = cat_str(4,mm_strdup("alter database"),$3,mm_strdup("owner to"),$6);
7805 }
7806 |  ALTER DOMAIN_P any_name OWNER TO RoleSpec
7807  {
7808  $$ = cat_str(4,mm_strdup("alter domain"),$3,mm_strdup("owner to"),$6);
7809 }
7810 |  ALTER FUNCTION function_with_argtypes OWNER TO RoleSpec
7811  {
7812  $$ = cat_str(4,mm_strdup("alter function"),$3,mm_strdup("owner to"),$6);
7813 }
7814 |  ALTER opt_procedural LANGUAGE name OWNER TO RoleSpec
7815  {
7816  $$ = cat_str(6,mm_strdup("alter"),$2,mm_strdup("language"),$4,mm_strdup("owner to"),$7);
7817 }
7818 |  ALTER LARGE_P OBJECT_P NumericOnly OWNER TO RoleSpec
7819  {
7820  $$ = cat_str(4,mm_strdup("alter large object"),$4,mm_strdup("owner to"),$7);
7821 }
7822 |  ALTER OPERATOR any_operator oper_argtypes OWNER TO RoleSpec
7823  {
7824  $$ = cat_str(5,mm_strdup("alter operator"),$3,$4,mm_strdup("owner to"),$7);
7825 }
7826 |  ALTER OPERATOR CLASS any_name USING access_method OWNER TO RoleSpec
7827  {
7828  $$ = cat_str(6,mm_strdup("alter operator class"),$4,mm_strdup("using"),$6,mm_strdup("owner to"),$9);
7829 }
7830 |  ALTER OPERATOR FAMILY any_name USING access_method OWNER TO RoleSpec
7831  {
7832  $$ = cat_str(6,mm_strdup("alter operator family"),$4,mm_strdup("using"),$6,mm_strdup("owner to"),$9);
7833 }
7834 |  ALTER SCHEMA name OWNER TO RoleSpec
7835  {
7836  $$ = cat_str(4,mm_strdup("alter schema"),$3,mm_strdup("owner to"),$6);
7837 }
7838 |  ALTER TYPE_P any_name OWNER TO RoleSpec
7839  {
7840  $$ = cat_str(4,mm_strdup("alter type"),$3,mm_strdup("owner to"),$6);
7841 }
7842 |  ALTER TABLESPACE name OWNER TO RoleSpec
7843  {
7844  $$ = cat_str(4,mm_strdup("alter tablespace"),$3,mm_strdup("owner to"),$6);
7845 }
7846 |  ALTER TEXT_P SEARCH DICTIONARY any_name OWNER TO RoleSpec
7847  {
7848  $$ = cat_str(4,mm_strdup("alter text search dictionary"),$5,mm_strdup("owner to"),$8);
7849 }
7850 |  ALTER TEXT_P SEARCH CONFIGURATION any_name OWNER TO RoleSpec
7851  {
7852  $$ = cat_str(4,mm_strdup("alter text search configuration"),$5,mm_strdup("owner to"),$8);
7853 }
7854 |  ALTER FOREIGN DATA_P WRAPPER name OWNER TO RoleSpec
7855  {
7856  $$ = cat_str(4,mm_strdup("alter foreign data wrapper"),$5,mm_strdup("owner to"),$8);
7857 }
7858 |  ALTER SERVER name OWNER TO RoleSpec
7859  {
7860  $$ = cat_str(4,mm_strdup("alter server"),$3,mm_strdup("owner to"),$6);
7861 }
7862 |  ALTER EVENT TRIGGER name OWNER TO RoleSpec
7863  {
7864  $$ = cat_str(4,mm_strdup("alter event trigger"),$4,mm_strdup("owner to"),$7);
7865 }
7866 ;
7867 
7868 
7869  RuleStmt:
7870  CREATE opt_or_replace RULE name AS ON event TO qualified_name where_clause DO opt_instead RuleActionList
7871  {
7872  $$ = 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);
7873 }
7874 ;
7875 
7876 
7877  RuleActionList:
7878  NOTHING
7879  {
7880  $$ = mm_strdup("nothing");
7881 }
7882 |  RuleActionStmt
7883  {
7884  $$ = $1;
7885 }
7886 |  '(' RuleActionMulti ')'
7887  {
7888  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
7889 }
7890 ;
7891 
7892 
7893  RuleActionMulti:
7894  RuleActionMulti ';' RuleActionStmtOrEmpty
7895  {
7896  $$ = cat_str(3,$1,mm_strdup(";"),$3);
7897 }
7898 |  RuleActionStmtOrEmpty
7899  {
7900  $$ = $1;
7901 }
7902 ;
7903 
7904 
7905  RuleActionStmt:
7906  SelectStmt
7907  {
7908  $$ = $1;
7909 }
7910 |  InsertStmt
7911  {
7912  $$ = $1;
7913 }
7914 |  UpdateStmt
7915  {
7916  $$ = $1;
7917 }
7918 |  DeleteStmt
7919  {
7920  $$ = $1;
7921 }
7922 |  NotifyStmt
7923  {
7924  $$ = $1;
7925 }
7926 ;
7927 
7928 
7929  RuleActionStmtOrEmpty:
7930  RuleActionStmt
7931  {
7932  $$ = $1;
7933 }
7934 |
7935  {
7936  $$=EMPTY; }
7937 ;
7938 
7939 
7940  event:
7941  SELECT
7942  {
7943  $$ = mm_strdup("select");
7944 }
7945 |  UPDATE
7946  {
7947  $$ = mm_strdup("update");
7948 }
7949 |  DELETE_P
7950  {
7951  $$ = mm_strdup("delete");
7952 }
7953 |  INSERT
7954  {
7955  $$ = mm_strdup("insert");
7956 }
7957 ;
7958 
7959 
7960  opt_instead:
7961  INSTEAD
7962  {
7963  $$ = mm_strdup("instead");
7964 }
7965 |  ALSO
7966  {
7967  $$ = mm_strdup("also");
7968 }
7969 |
7970  {
7971  $$=EMPTY; }
7972 ;
7973 
7974 
7975  DropRuleStmt:
7976  DROP RULE name ON any_name opt_drop_behavior
7977  {
7978  $$ = cat_str(5,mm_strdup("drop rule"),$3,mm_strdup("on"),$5,$6);
7979 }
7980 |  DROP RULE IF_P EXISTS name ON any_name opt_drop_behavior
7981  {
7982  $$ = cat_str(5,mm_strdup("drop rule if exists"),$5,mm_strdup("on"),$7,$8);
7983 }
7984 ;
7985 
7986 
7987  NotifyStmt:
7988  NOTIFY ColId notify_payload
7989  {
7990  $$ = cat_str(3,mm_strdup("notify"),$2,$3);
7991 }
7992 ;
7993 
7994 
7995  notify_payload:
7996  ',' ecpg_sconst
7997  {
7998  $$ = cat_str(2,mm_strdup(","),$2);
7999 }
8000 |
8001  {
8002  $$=EMPTY; }
8003 ;
8004 
8005 
8006  ListenStmt:
8007  LISTEN ColId
8008  {
8009  $$ = cat_str(2,mm_strdup("listen"),$2);
8010 }
8011 ;
8012 
8013 
8014  UnlistenStmt:
8015  UNLISTEN ColId
8016  {
8017  $$ = cat_str(2,mm_strdup("unlisten"),$2);
8018 }
8019 |  UNLISTEN '*'
8020  {
8021  $$ = mm_strdup("unlisten *");
8022 }
8023 ;
8024 
8025 
8026  TransactionStmt:
8027  ABORT_P opt_transaction
8028  {
8029  $$ = cat_str(2,mm_strdup("abort"),$2);
8030 }
8031 |  BEGIN_P opt_transaction transaction_mode_list_or_empty
8032  {
8033  $$ = cat_str(3,mm_strdup("begin"),$2,$3);
8034 }
8035 |  START TRANSACTION transaction_mode_list_or_empty
8036  {
8037  $$ = cat_str(2,mm_strdup("start transaction"),$3);
8038 }
8039 |  COMMIT opt_transaction
8040  {
8041  $$ = cat_str(2,mm_strdup("commit"),$2);
8042 }
8043 |  END_P opt_transaction
8044  {
8045  $$ = cat_str(2,mm_strdup("end"),$2);
8046 }
8047 |  ROLLBACK opt_transaction
8048  {
8049  $$ = cat_str(2,mm_strdup("rollback"),$2);
8050 }
8051 |  SAVEPOINT ColId
8052  {
8053  $$ = cat_str(2,mm_strdup("savepoint"),$2);
8054 }
8055 |  RELEASE SAVEPOINT ColId
8056  {
8057  $$ = cat_str(2,mm_strdup("release savepoint"),$3);
8058 }
8059 |  RELEASE ColId
8060  {
8061  $$ = cat_str(2,mm_strdup("release"),$2);
8062 }
8063 |  ROLLBACK opt_transaction TO SAVEPOINT ColId
8064  {
8065  $$ = cat_str(4,mm_strdup("rollback"),$2,mm_strdup("to savepoint"),$5);
8066 }
8067 |  ROLLBACK opt_transaction TO ColId
8068  {
8069  $$ = cat_str(4,mm_strdup("rollback"),$2,mm_strdup("to"),$4);
8070 }
8071 |  PREPARE TRANSACTION ecpg_sconst
8072  {
8073  $$ = cat_str(2,mm_strdup("prepare transaction"),$3);
8074 }
8075 |  COMMIT PREPARED ecpg_sconst
8076  {
8077  $$ = cat_str(2,mm_strdup("commit prepared"),$3);
8078 }
8079 |  ROLLBACK PREPARED ecpg_sconst
8080  {
8081  $$ = cat_str(2,mm_strdup("rollback prepared"),$3);
8082 }
8083 ;
8084 
8085 
8086  opt_transaction:
8087  WORK
8088  {
8089  $$ = mm_strdup("work");
8090 }
8091 |  TRANSACTION
8092  {
8093  $$ = mm_strdup("transaction");
8094 }
8095 |
8096  {
8097  $$=EMPTY; }
8098 ;
8099 
8100 
8101  transaction_mode_item:
8102  ISOLATION LEVEL iso_level
8103  {
8104  $$ = cat_str(2,mm_strdup("isolation level"),$3);
8105 }
8106 |  READ ONLY
8107  {
8108  $$ = mm_strdup("read only");
8109 }
8110 |  READ WRITE
8111  {
8112  $$ = mm_strdup("read write");
8113 }
8114 |  DEFERRABLE
8115  {
8116  $$ = mm_strdup("deferrable");
8117 }
8118 |  NOT DEFERRABLE
8119  {
8120  $$ = mm_strdup("not deferrable");
8121 }
8122 ;
8123 
8124 
8125  transaction_mode_list:
8126  transaction_mode_item
8127  {
8128  $$ = $1;
8129 }
8130 |  transaction_mode_list ',' transaction_mode_item
8131  {
8132  $$ = cat_str(3,$1,mm_strdup(","),$3);
8133 }
8134 |  transaction_mode_list transaction_mode_item
8135  {
8136  $$ = cat_str(2,$1,$2);
8137 }
8138 ;
8139 
8140 
8141  transaction_mode_list_or_empty:
8142  transaction_mode_list
8143  {
8144  $$ = $1;
8145 }
8146 |
8147  {
8148  $$=EMPTY; }
8149 ;
8150 
8151 
8152  ViewStmt:
8153  CREATE OptTemp VIEW qualified_name opt_column_list opt_reloptions AS SelectStmt opt_check_option
8154  {
8155  $$ = cat_str(9,mm_strdup("create"),$2,mm_strdup("view"),$4,$5,$6,mm_strdup("as"),$8,$9);
8156 }
8157 |  CREATE OR REPLACE OptTemp VIEW qualified_name opt_column_list opt_reloptions AS SelectStmt opt_check_option
8158  {
8159  $$ = cat_str(9,mm_strdup("create or replace"),$4,mm_strdup("view"),$6,$7,$8,mm_strdup("as"),$10,$11);
8160 }
8161 |  CREATE OptTemp RECURSIVE VIEW qualified_name '(' columnList ')' opt_reloptions AS SelectStmt opt_check_option
8162  {
8163 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
8164  $$ = cat_str(11,mm_strdup("create"),$2,mm_strdup("recursive view"),$5,mm_strdup("("),$7,mm_strdup(")"),$9,mm_strdup("as"),$11,$12);
8165 }
8166 |  CREATE OR REPLACE OptTemp RECURSIVE VIEW qualified_name '(' columnList ')' opt_reloptions AS SelectStmt opt_check_option
8167  {
8168 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
8169  $$ = 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);
8170 }
8171 ;
8172 
8173 
8174  opt_check_option:
8175  WITH CHECK OPTION
8176  {
8177  $$ = mm_strdup("with check option");
8178 }
8179 |  WITH CASCADED CHECK OPTION
8180  {
8181  $$ = mm_strdup("with cascaded check option");
8182 }
8183 |  WITH LOCAL CHECK OPTION
8184  {
8185  $$ = mm_strdup("with local check option");
8186 }
8187 |
8188  {
8189  $$=EMPTY; }
8190 ;
8191 
8192 
8193  LoadStmt:
8194  LOAD file_name
8195  {
8196  $$ = cat_str(2,mm_strdup("load"),$2);
8197 }
8198 ;
8199 
8200 
8201  CreatedbStmt:
8202  CREATE DATABASE database_name opt_with createdb_opt_list
8203  {
8204  $$ = cat_str(4,mm_strdup("create database"),$3,$4,$5);
8205 }
8206 ;
8207 
8208 
8209  createdb_opt_list:
8210  createdb_opt_items
8211  {
8212  $$ = $1;
8213 }
8214 |
8215  {
8216  $$=EMPTY; }
8217 ;
8218 
8219 
8220  createdb_opt_items:
8221  createdb_opt_item
8222  {
8223  $$ = $1;
8224 }
8225 |  createdb_opt_items createdb_opt_item
8226  {
8227  $$ = cat_str(2,$1,$2);
8228 }
8229 ;
8230 
8231 
8232  createdb_opt_item:
8233  createdb_opt_name opt_equal SignedIconst
8234  {
8235  $$ = cat_str(3,$1,$2,$3);
8236 }
8237 |  createdb_opt_name opt_equal opt_boolean_or_string
8238  {
8239  $$ = cat_str(3,$1,$2,$3);
8240 }
8241 |  createdb_opt_name opt_equal DEFAULT
8242  {
8243  $$ = cat_str(3,$1,$2,mm_strdup("default"));
8244 }
8245 ;
8246 
8247 
8248  createdb_opt_name:
8249  ecpg_ident
8250  {
8251  $$ = $1;
8252 }
8253 |  CONNECTION LIMIT
8254  {
8255  $$ = mm_strdup("connection limit");
8256 }
8257 |  ENCODING
8258  {
8259  $$ = mm_strdup("encoding");
8260 }
8261 |  LOCATION
8262  {
8263  $$ = mm_strdup("location");
8264 }
8265 |  OWNER
8266  {
8267  $$ = mm_strdup("owner");
8268 }
8269 |  TABLESPACE
8270  {
8271  $$ = mm_strdup("tablespace");
8272 }
8273 |  TEMPLATE
8274  {
8275  $$ = mm_strdup("template");
8276 }
8277 ;
8278 
8279 
8280  opt_equal:
8281  '='
8282  {
8283  $$ = mm_strdup("=");
8284 }
8285 |
8286  {
8287  $$=EMPTY; }
8288 ;
8289 
8290 
8291  AlterDatabaseStmt:
8292  ALTER DATABASE database_name WITH createdb_opt_list
8293  {
8294  $$ = cat_str(4,mm_strdup("alter database"),$3,mm_strdup("with"),$5);
8295 }
8296 |  ALTER DATABASE database_name createdb_opt_list
8297  {
8298  $$ = cat_str(3,mm_strdup("alter database"),$3,$4);
8299 }
8300 |  ALTER DATABASE database_name SET TABLESPACE name
8301  {
8302  $$ = cat_str(4,mm_strdup("alter database"),$3,mm_strdup("set tablespace"),$6);
8303 }
8304 ;
8305 
8306 
8307  AlterDatabaseSetStmt:
8308  ALTER DATABASE database_name SetResetClause
8309  {
8310  $$ = cat_str(3,mm_strdup("alter database"),$3,$4);
8311 }
8312 ;
8313 
8314 
8315  DropdbStmt:
8316  DROP DATABASE database_name
8317  {
8318  $$ = cat_str(2,mm_strdup("drop database"),$3);
8319 }
8320 |  DROP DATABASE IF_P EXISTS database_name
8321  {
8322  $$ = cat_str(2,mm_strdup("drop database if exists"),$5);
8323 }
8324 ;
8325 
8326 
8327  AlterSystemStmt:
8328  ALTER SYSTEM_P SET generic_set
8329  {
8330  $$ = cat_str(2,mm_strdup("alter system set"),$4);
8331 }
8332 |  ALTER SYSTEM_P RESET generic_reset
8333  {
8334  $$ = cat_str(2,mm_strdup("alter system reset"),$4);
8335 }
8336 ;
8337 
8338 
8339  CreateDomainStmt:
8340  CREATE DOMAIN_P any_name opt_as Typename ColQualList
8341  {
8342  $$ = cat_str(5,mm_strdup("create domain"),$3,$4,$5,$6);
8343 }
8344 ;
8345 
8346 
8347  AlterDomainStmt:
8348  ALTER DOMAIN_P any_name alter_column_default
8349  {
8350  $$ = cat_str(3,mm_strdup("alter domain"),$3,$4);
8351 }
8352 |  ALTER DOMAIN_P any_name DROP NOT NULL_P
8353  {
8354  $$ = cat_str(3,mm_strdup("alter domain"),$3,mm_strdup("drop not null"));
8355 }
8356 |  ALTER DOMAIN_P any_name SET NOT NULL_P
8357  {
8358  $$ = cat_str(3,mm_strdup("alter domain"),$3,mm_strdup("set not null"));
8359 }
8360 |  ALTER DOMAIN_P any_name ADD_P TableConstraint
8361  {
8362  $$ = cat_str(4,mm_strdup("alter domain"),$3,mm_strdup("add"),$5);
8363 }
8364 |  ALTER DOMAIN_P any_name DROP CONSTRAINT name opt_drop_behavior
8365  {
8366  $$ = cat_str(5,mm_strdup("alter domain"),$3,mm_strdup("drop constraint"),$6,$7);
8367 }
8368 |  ALTER DOMAIN_P any_name DROP CONSTRAINT IF_P EXISTS name opt_drop_behavior
8369  {
8370  $$ = cat_str(5,mm_strdup("alter domain"),$3,mm_strdup("drop constraint if exists"),$8,$9);
8371 }
8372 |  ALTER DOMAIN_P any_name VALIDATE CONSTRAINT name
8373  {
8374  $$ = cat_str(4,mm_strdup("alter domain"),$3,mm_strdup("validate constraint"),$6);
8375 }
8376 ;
8377 
8378 
8379  opt_as:
8380  AS
8381  {
8382  $$ = mm_strdup("as");
8383 }
8384 |
8385  {
8386  $$=EMPTY; }
8387 ;
8388 
8389 
8390  AlterTSDictionaryStmt:
8391  ALTER TEXT_P SEARCH DICTIONARY any_name definition
8392  {
8393  $$ = cat_str(3,mm_strdup("alter text search dictionary"),$5,$6);
8394 }
8395 ;
8396 
8397 
8398  AlterTSConfigurationStmt:
8399  ALTER TEXT_P SEARCH CONFIGURATION any_name ADD_P MAPPING FOR name_list any_with any_name_list
8400  {
8401  $$ = cat_str(6,mm_strdup("alter text search configuration"),$5,mm_strdup("add mapping for"),$9,$10,$11);
8402 }
8403 |  ALTER TEXT_P SEARCH CONFIGURATION any_name ALTER MAPPING FOR name_list any_with any_name_list
8404  {
8405  $$ = cat_str(6,mm_strdup("alter text search configuration"),$5,mm_strdup("alter mapping for"),$9,$10,$11);
8406 }
8407 |  ALTER TEXT_P SEARCH CONFIGURATION any_name ALTER MAPPING REPLACE any_name any_with any_name
8408  {
8409  $$ = cat_str(6,mm_strdup("alter text search configuration"),$5,mm_strdup("alter mapping replace"),$9,$10,$11);
8410 }
8411 |  ALTER TEXT_P SEARCH CONFIGURATION any_name ALTER MAPPING FOR name_list REPLACE any_name any_with any_name
8412  {
8413  $$ = cat_str(8,mm_strdup("alter text search configuration"),$5,mm_strdup("alter mapping for"),$9,mm_strdup("replace"),$11,$12,$13);
8414 }
8415 |  ALTER TEXT_P SEARCH CONFIGURATION any_name DROP MAPPING FOR name_list
8416  {
8417  $$ = cat_str(4,mm_strdup("alter text search configuration"),$5,mm_strdup("drop mapping for"),$9);
8418 }
8419 |  ALTER TEXT_P SEARCH CONFIGURATION any_name DROP MAPPING IF_P EXISTS FOR name_list
8420  {
8421  $$ = cat_str(4,mm_strdup("alter text search configuration"),$5,mm_strdup("drop mapping if exists for"),$11);
8422 }
8423 ;
8424 
8425 
8426  any_with:
8427  WITH
8428  {
8429  $$ = mm_strdup("with");
8430 }
8431 |  WITH_LA
8432  {
8433  $$ = mm_strdup("with");
8434 }
8435 ;
8436 
8437 
8438  CreateConversionStmt:
8439  CREATE opt_default CONVERSION_P any_name FOR ecpg_sconst TO ecpg_sconst FROM any_name
8440  {
8441  $$ = cat_str(10,mm_strdup("create"),$2,mm_strdup("conversion"),$4,mm_strdup("for"),$6,mm_strdup("to"),$8,mm_strdup("from"),$10);
8442 }
8443 ;
8444 
8445 
8446  ClusterStmt:
8447  CLUSTER opt_verbose qualified_name cluster_index_specification
8448  {
8449  $$ = cat_str(4,mm_strdup("cluster"),$2,$3,$4);
8450 }
8451 |  CLUSTER opt_verbose
8452  {
8453  $$ = cat_str(2,mm_strdup("cluster"),$2);
8454 }
8455 |  CLUSTER opt_verbose index_name ON qualified_name
8456  {
8457  $$ = cat_str(5,mm_strdup("cluster"),$2,$3,mm_strdup("on"),$5);
8458 }
8459 ;
8460 
8461 
8462  cluster_index_specification:
8463  USING index_name
8464  {
8465  $$ = cat_str(2,mm_strdup("using"),$2);
8466 }
8467 |
8468  {
8469  $$=EMPTY; }
8470 ;
8471 
8472 
8473  VacuumStmt:
8474  VACUUM opt_full opt_freeze opt_verbose
8475  {
8476  $$ = cat_str(4,mm_strdup("vacuum"),$2,$3,$4);
8477 }
8478 |  VACUUM opt_full opt_freeze opt_verbose qualified_name
8479  {
8480  $$ = cat_str(5,mm_strdup("vacuum"),$2,$3,$4,$5);
8481 }
8482 |  VACUUM opt_full opt_freeze opt_verbose AnalyzeStmt
8483  {
8484  $$ = cat_str(5,mm_strdup("vacuum"),$2,$3,$4,$5);
8485 }
8486 |  VACUUM '(' vacuum_option_list ')'
8487  {
8488  $$ = cat_str(3,mm_strdup("vacuum ("),$3,mm_strdup(")"));
8489 }
8490 |  VACUUM '(' vacuum_option_list ')' qualified_name opt_name_list
8491  {
8492  $$ = cat_str(5,mm_strdup("vacuum ("),$3,mm_strdup(")"),$5,$6);
8493 }
8494 ;
8495 
8496 
8497  vacuum_option_list:
8498  vacuum_option_elem
8499  {
8500  $$ = $1;
8501 }
8502 |  vacuum_option_list ',' vacuum_option_elem
8503  {
8504  $$ = cat_str(3,$1,mm_strdup(","),$3);
8505 }
8506 ;
8507 
8508 
8509  vacuum_option_elem:
8510  analyze_keyword
8511  {
8512  $$ = $1;
8513 }
8514 |  VERBOSE
8515  {
8516  $$ = mm_strdup("verbose");
8517 }
8518 |  FREEZE
8519  {
8520  $$ = mm_strdup("freeze");
8521 }
8522 |  FULL
8523  {
8524  $$ = mm_strdup("full");
8525 }
8526 |  ecpg_ident
8527  {
8528  $$ = $1;
8529 }
8530 ;
8531 
8532 
8533  AnalyzeStmt:
8534  analyze_keyword opt_verbose
8535  {
8536  $$ = cat_str(2,$1,$2);
8537 }
8538 |  analyze_keyword opt_verbose qualified_name opt_name_list
8539  {
8540  $$ = cat_str(4,$1,$2,$3,$4);
8541 }
8542 ;
8543 
8544 
8545  analyze_keyword:
8546  ANALYZE
8547  {
8548  $$ = mm_strdup("analyze");
8549 }
8550 |  ANALYSE
8551  {
8552  $$ = mm_strdup("analyse");
8553 }
8554 ;
8555 
8556 
8557  opt_verbose:
8558  VERBOSE
8559  {
8560  $$ = mm_strdup("verbose");
8561 }
8562 |
8563  {
8564  $$=EMPTY; }
8565 ;
8566 
8567 
8568  opt_full:
8569  FULL
8570  {
8571  $$ = mm_strdup("full");
8572 }
8573 |
8574  {
8575  $$=EMPTY; }
8576 ;
8577 
8578 
8579  opt_freeze:
8580  FREEZE
8581  {
8582  $$ = mm_strdup("freeze");
8583 }
8584 |
8585  {
8586  $$=EMPTY; }
8587 ;
8588 
8589 
8590  opt_name_list:
8591  '(' name_list ')'
8592  {
8593  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
8594 }
8595 |
8596  {
8597  $$=EMPTY; }
8598 ;
8599 
8600 
8601  ExplainStmt:
8602  EXPLAIN ExplainableStmt
8603  {
8604  $$ = cat_str(2,mm_strdup("explain"),$2);
8605 }
8606 |  EXPLAIN analyze_keyword opt_verbose ExplainableStmt
8607  {
8608  $$ = cat_str(4,mm_strdup("explain"),$2,$3,$4);
8609 }
8610 |  EXPLAIN VERBOSE ExplainableStmt
8611  {
8612  $$ = cat_str(2,mm_strdup("explain verbose"),$3);
8613 }
8614 |  EXPLAIN '(' explain_option_list ')' ExplainableStmt
8615  {
8616  $$ = cat_str(4,mm_strdup("explain ("),$3,mm_strdup(")"),$5);
8617 }
8618 ;
8619 
8620 
8621  ExplainableStmt:
8622  SelectStmt
8623  {
8624  $$ = $1;
8625 }
8626 |  InsertStmt
8627  {
8628  $$ = $1;
8629 }
8630 |  UpdateStmt
8631  {
8632  $$ = $1;
8633 }
8634 |  DeleteStmt
8635  {
8636  $$ = $1;
8637 }
8638 |  DeclareCursorStmt
8639  {
8640  $$ = $1;
8641 }
8642 |  CreateAsStmt
8643  {
8644  $$ = $1;
8645 }
8646 |  CreateMatViewStmt
8647  {
8648  $$ = $1;
8649 }
8650 |  RefreshMatViewStmt
8651  {
8652  $$ = $1;
8653 }
8654 |  ExecuteStmt
8655  {
8656  $$ = $1;
8657 }
8658 ;
8659 
8660 
8661  explain_option_list:
8662  explain_option_elem
8663  {
8664  $$ = $1;
8665 }
8666 |  explain_option_list ',' explain_option_elem
8667  {
8668  $$ = cat_str(3,$1,mm_strdup(","),$3);
8669 }
8670 ;
8671 
8672 
8673  explain_option_elem:
8674  explain_option_name explain_option_arg
8675  {
8676  $$ = cat_str(2,$1,$2);
8677 }
8678 ;
8679 
8680 
8681  explain_option_name:
8682  NonReservedWord
8683  {
8684  $$ = $1;
8685 }
8686 |  analyze_keyword
8687  {
8688  $$ = $1;
8689 }
8690 ;
8691 
8692 
8693  explain_option_arg:
8694  opt_boolean_or_string
8695  {
8696  $$ = $1;
8697 }
8698 |  NumericOnly
8699  {
8700  $$ = $1;
8701 }
8702 |
8703  {
8704  $$=EMPTY; }
8705 ;
8706 
8707 
8708  PrepareStmt:
8709 PREPARE prepared_name prep_type_clause AS PreparableStmt
8710 	{
8711 		$$.name = $2;
8712 		$$.type = $3;
8713 		$$.stmt = cat_str(3, mm_strdup("\""), $5, mm_strdup("\""));
8714 	}
8715 	| PREPARE prepared_name FROM execstring
8716 	{
8717 		$$.name = $2;
8718 		$$.type = NULL;
8719 		$$.stmt = $4;
8720 	}
8721 ;
8722 
8723 
8724  prep_type_clause:
8725  '(' type_list ')'
8726  {
8727  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
8728 }
8729 |
8730  {
8731  $$=EMPTY; }
8732 ;
8733 
8734 
8735  PreparableStmt:
8736  SelectStmt
8737  {
8738  $$ = $1;
8739 }
8740 |  InsertStmt
8741  {
8742  $$ = $1;
8743 }
8744 |  UpdateStmt
8745  {
8746  $$ = $1;
8747 }
8748 |  DeleteStmt
8749  {
8750  $$ = $1;
8751 }
8752 ;
8753 
8754 
8755  ExecuteStmt:
8756 EXECUTE prepared_name execute_param_clause execute_rest
8757 	{ $$ = $2; }
8758 |  CREATE OptTemp TABLE create_as_target AS EXECUTE name execute_param_clause opt_with_data
8759  {
8760  $$ = cat_str(8,mm_strdup("create"),$2,mm_strdup("table"),$4,mm_strdup("as execute"),$7,$8,$9);
8761 }
8762 |  CREATE OptTemp TABLE IF_P NOT EXISTS create_as_target AS EXECUTE name execute_param_clause opt_with_data
8763  {
8764  $$ = cat_str(8,mm_strdup("create"),$2,mm_strdup("table if not exists"),$7,mm_strdup("as execute"),$10,$11,$12);
8765 }
8766 ;
8767 
8768 
8769  execute_param_clause:
8770  '(' expr_list ')'
8771  {
8772  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
8773 }
8774 |
8775  {
8776  $$=EMPTY; }
8777 ;
8778 
8779 
8780  InsertStmt:
8781  opt_with_clause INSERT INTO insert_target insert_rest opt_on_conflict returning_clause
8782  {
8783  $$ = cat_str(6,$1,mm_strdup("insert into"),$4,$5,$6,$7);
8784 }
8785 ;
8786 
8787 
8788  insert_target:
8789  qualified_name
8790  {
8791  $$ = $1;
8792 }
8793 |  qualified_name AS ColId
8794  {
8795  $$ = cat_str(3,$1,mm_strdup("as"),$3);
8796 }
8797 ;
8798 
8799 
8800  insert_rest:
8801  SelectStmt
8802  {
8803  $$ = $1;
8804 }
8805 |  '(' insert_column_list ')' SelectStmt
8806  {
8807  $$ = cat_str(4,mm_strdup("("),$2,mm_strdup(")"),$4);
8808 }
8809 |  DEFAULT VALUES
8810  {
8811  $$ = mm_strdup("default values");
8812 }
8813 ;
8814 
8815 
8816  insert_column_list:
8817  insert_column_item
8818  {
8819  $$ = $1;
8820 }
8821 |  insert_column_list ',' insert_column_item
8822  {
8823  $$ = cat_str(3,$1,mm_strdup(","),$3);
8824 }
8825 ;
8826 
8827 
8828  insert_column_item:
8829  ColId opt_indirection
8830  {
8831  $$ = cat_str(2,$1,$2);
8832 }
8833 ;
8834 
8835 
8836  opt_on_conflict:
8837  ON CONFLICT opt_conf_expr DO UPDATE SET set_clause_list where_clause
8838  {
8839  $$ = cat_str(5,mm_strdup("on conflict"),$3,mm_strdup("do update set"),$7,$8);
8840 }
8841 |  ON CONFLICT opt_conf_expr DO NOTHING
8842  {
8843  $$ = cat_str(3,mm_strdup("on conflict"),$3,mm_strdup("do nothing"));
8844 }
8845 |
8846  {
8847  $$=EMPTY; }
8848 ;
8849 
8850 
8851  opt_conf_expr:
8852  '(' index_params ')' where_clause
8853  {
8854  $$ = cat_str(4,mm_strdup("("),$2,mm_strdup(")"),$4);
8855 }
8856 |  ON CONSTRAINT name
8857  {
8858  $$ = cat_str(2,mm_strdup("on constraint"),$3);
8859 }
8860 |
8861  {
8862  $$=EMPTY; }
8863 ;
8864 
8865 
8866  returning_clause:
8867 RETURNING target_list opt_ecpg_into
8868  {
8869  $$ = cat_str(2,mm_strdup("returning"),$2);
8870 }
8871 |
8872  {
8873  $$=EMPTY; }
8874 ;
8875 
8876 
8877  DeleteStmt:
8878  opt_with_clause DELETE_P FROM relation_expr_opt_alias using_clause where_or_current_clause returning_clause
8879  {
8880  $$ = cat_str(6,$1,mm_strdup("delete from"),$4,$5,$6,$7);
8881 }
8882 ;
8883 
8884 
8885  using_clause:
8886  USING from_list
8887  {
8888  $$ = cat_str(2,mm_strdup("using"),$2);
8889 }
8890 |
8891  {
8892  $$=EMPTY; }
8893 ;
8894 
8895 
8896  LockStmt:
8897  LOCK_P opt_table relation_expr_list opt_lock opt_nowait
8898  {
8899  $$ = cat_str(5,mm_strdup("lock"),$2,$3,$4,$5);
8900 }
8901 ;
8902 
8903 
8904  opt_lock:
8905  IN_P lock_type MODE
8906  {
8907  $$ = cat_str(3,mm_strdup("in"),$2,mm_strdup("mode"));
8908 }
8909 |
8910  {
8911  $$=EMPTY; }
8912 ;
8913 
8914 
8915  lock_type:
8916  ACCESS SHARE
8917  {
8918  $$ = mm_strdup("access share");
8919 }
8920 |  ROW SHARE
8921  {
8922  $$ = mm_strdup("row share");
8923 }
8924 |  ROW EXCLUSIVE
8925  {
8926  $$ = mm_strdup("row exclusive");
8927 }
8928 |  SHARE UPDATE EXCLUSIVE
8929  {
8930  $$ = mm_strdup("share update exclusive");
8931 }
8932 |  SHARE
8933  {
8934  $$ = mm_strdup("share");
8935 }
8936 |  SHARE ROW EXCLUSIVE
8937  {
8938  $$ = mm_strdup("share row exclusive");
8939 }
8940 |  EXCLUSIVE
8941  {
8942  $$ = mm_strdup("exclusive");
8943 }
8944 |  ACCESS EXCLUSIVE
8945  {
8946  $$ = mm_strdup("access exclusive");
8947 }
8948 ;
8949 
8950 
8951  opt_nowait:
8952  NOWAIT
8953  {
8954  $$ = mm_strdup("nowait");
8955 }
8956 |
8957  {
8958  $$=EMPTY; }
8959 ;
8960 
8961 
8962  opt_nowait_or_skip:
8963  NOWAIT
8964  {
8965  $$ = mm_strdup("nowait");
8966 }
8967 |  SKIP LOCKED
8968  {
8969  $$ = mm_strdup("skip locked");
8970 }
8971 |
8972  {
8973  $$=EMPTY; }
8974 ;
8975 
8976 
8977  UpdateStmt:
8978  opt_with_clause UPDATE relation_expr_opt_alias SET set_clause_list from_clause where_or_current_clause returning_clause
8979  {
8980  $$ = cat_str(8,$1,mm_strdup("update"),$3,mm_strdup("set"),$5,$6,$7,$8);
8981 }
8982 ;
8983 
8984 
8985  set_clause_list:
8986  set_clause
8987  {
8988  $$ = $1;
8989 }
8990 |  set_clause_list ',' set_clause
8991  {
8992  $$ = cat_str(3,$1,mm_strdup(","),$3);
8993 }
8994 ;
8995 
8996 
8997  set_clause:
8998  single_set_clause
8999  {
9000  $$ = $1;
9001 }
9002 |  multiple_set_clause
9003  {
9004  $$ = $1;
9005 }
9006 ;
9007 
9008 
9009  single_set_clause:
9010  set_target '=' ctext_expr
9011  {
9012  $$ = cat_str(3,$1,mm_strdup("="),$3);
9013 }
9014 ;
9015 
9016 
9017  multiple_set_clause:
9018  '(' set_target_list ')' '=' ctext_row
9019  {
9020  $$ = cat_str(4,mm_strdup("("),$2,mm_strdup(") ="),$5);
9021 }
9022 |  '(' set_target_list ')' '=' select_with_parens
9023  {
9024  $$ = cat_str(4,mm_strdup("("),$2,mm_strdup(") ="),$5);
9025 }
9026 ;
9027 
9028 
9029  set_target:
9030  ColId opt_indirection
9031  {
9032  $$ = cat_str(2,$1,$2);
9033 }
9034 ;
9035 
9036 
9037  set_target_list:
9038  set_target
9039  {
9040  $$ = $1;
9041 }
9042 |  set_target_list ',' set_target
9043  {
9044  $$ = cat_str(3,$1,mm_strdup(","),$3);
9045 }
9046 ;
9047 
9048 
9049  DeclareCursorStmt:
9050  DECLARE cursor_name cursor_options CURSOR opt_hold FOR SelectStmt
9051 	{
9052 		struct cursor *ptr, *this;
9053 		char *cursor_marker = $2[0] == ':' ? mm_strdup("$0") : mm_strdup($2);
9054 		char *comment, *c1, *c2;
9055 		int (* strcmp_fn)(const char *, const char *) = (($2[0] == ':' || $2[0] == '"') ? strcmp : pg_strcasecmp);
9056 
9057 		for (ptr = cur; ptr != NULL; ptr = ptr->next)
9058 		{
9059 			if (strcmp_fn($2, ptr->name) == 0)
9060 			{
9061 				if ($2[0] == ':')
9062 					mmerror(PARSE_ERROR, ET_ERROR, "using variable \"%s\" in different declare statements is not supported", $2+1);
9063 				else
9064 					mmerror(PARSE_ERROR, ET_ERROR, "cursor \"%s\" is already defined", $2);
9065 			}
9066 		}
9067 
9068 		this = (struct cursor *) mm_alloc(sizeof(struct cursor));
9069 
9070 		this->next = cur;
9071 		this->name = $2;
9072 		this->function = (current_function ? mm_strdup(current_function) : NULL);
9073 		this->connection = connection;
9074 		this->opened = false;
9075 		this->command =  cat_str(7, mm_strdup("declare"), cursor_marker, $3, mm_strdup("cursor"), $5, mm_strdup("for"), $7);
9076 		this->argsinsert = argsinsert;
9077 		this->argsinsert_oos = NULL;
9078 		this->argsresult = argsresult;
9079 		this->argsresult_oos = NULL;
9080 		argsinsert = argsresult = NULL;
9081 		cur = this;
9082 
9083 		c1 = mm_strdup(this->command);
9084 		if ((c2 = strstr(c1, "*/")) != NULL)
9085 		{
9086 			/* We put this text into a comment, so we better remove [*][/]. */
9087 			c2[0] = '.';
9088 			c2[1] = '.';
9089 		}
9090 		comment = cat_str(3, mm_strdup("/*"), c1, mm_strdup("*/"));
9091 
9092 		if ((braces_open > 0) && INFORMIX_MODE) /* we're in a function */
9093 			$$ = cat_str(3, adjust_outofscope_cursor_vars(this),
9094 				mm_strdup("ECPG_informix_reset_sqlca();"),
9095 				comment);
9096 		else
9097 			$$ = cat2_str(adjust_outofscope_cursor_vars(this), comment);
9098 	}
9099 ;
9100 
9101 
9102  cursor_name:
9103  name
9104  {
9105  $$ = $1;
9106 }
9107 	| char_civar
9108 		{
9109 			char *curname = mm_alloc(strlen($1) + 2);
9110 			sprintf(curname, ":%s", $1);
9111 			free($1);
9112 			$1 = curname;
9113 			$$ = $1;
9114 		}
9115 ;
9116 
9117 
9118  cursor_options:
9119 
9120  {
9121  $$=EMPTY; }
9122 |  cursor_options NO SCROLL
9123  {
9124  $$ = cat_str(2,$1,mm_strdup("no scroll"));
9125 }
9126 |  cursor_options SCROLL
9127  {
9128  $$ = cat_str(2,$1,mm_strdup("scroll"));
9129 }
9130 |  cursor_options BINARY
9131  {
9132  $$ = cat_str(2,$1,mm_strdup("binary"));
9133 }
9134 |  cursor_options INSENSITIVE
9135  {
9136  $$ = cat_str(2,$1,mm_strdup("insensitive"));
9137 }
9138 ;
9139 
9140 
9141  opt_hold:
9142 
9143 	{
9144 		if (compat == ECPG_COMPAT_INFORMIX_SE && autocommit)
9145 			$$ = mm_strdup("with hold");
9146 		else
9147 			$$ = EMPTY;
9148 	}
9149 |  WITH HOLD
9150  {
9151  $$ = mm_strdup("with hold");
9152 }
9153 |  WITHOUT HOLD
9154  {
9155  $$ = mm_strdup("without hold");
9156 }
9157 ;
9158 
9159 
9160  SelectStmt:
9161  select_no_parens %prec UMINUS
9162  {
9163  $$ = $1;
9164 }
9165 |  select_with_parens %prec UMINUS
9166  {
9167  $$ = $1;
9168 }
9169 ;
9170 
9171 
9172  select_with_parens:
9173  '(' select_no_parens ')'
9174  {
9175  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
9176 }
9177 |  '(' select_with_parens ')'
9178  {
9179  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
9180 }
9181 ;
9182 
9183 
9184  select_no_parens:
9185  simple_select
9186  {
9187  $$ = $1;
9188 }
9189 |  select_clause sort_clause
9190  {
9191  $$ = cat_str(2,$1,$2);
9192 }
9193 |  select_clause opt_sort_clause for_locking_clause opt_select_limit
9194  {
9195  $$ = cat_str(4,$1,$2,$3,$4);
9196 }
9197 |  select_clause opt_sort_clause select_limit opt_for_locking_clause
9198  {
9199  $$ = cat_str(4,$1,$2,$3,$4);
9200 }
9201 |  with_clause select_clause
9202  {
9203  $$ = cat_str(2,$1,$2);
9204 }
9205 |  with_clause select_clause sort_clause
9206  {
9207  $$ = cat_str(3,$1,$2,$3);
9208 }
9209 |  with_clause select_clause opt_sort_clause for_locking_clause opt_select_limit
9210  {
9211  $$ = cat_str(5,$1,$2,$3,$4,$5);
9212 }
9213 |  with_clause select_clause opt_sort_clause select_limit opt_for_locking_clause
9214  {
9215  $$ = cat_str(5,$1,$2,$3,$4,$5);
9216 }
9217 ;
9218 
9219 
9220  select_clause:
9221  simple_select
9222  {
9223  $$ = $1;
9224 }
9225 |  select_with_parens
9226  {
9227  $$ = $1;
9228 }
9229 ;
9230 
9231 
9232  simple_select:
9233  SELECT opt_all_clause opt_target_list into_clause from_clause where_clause group_clause having_clause window_clause
9234  {
9235  $$ = cat_str(9,mm_strdup("select"),$2,$3,$4,$5,$6,$7,$8,$9);
9236 }
9237 |  SELECT distinct_clause target_list into_clause from_clause where_clause group_clause having_clause window_clause
9238  {
9239  $$ = cat_str(9,mm_strdup("select"),$2,$3,$4,$5,$6,$7,$8,$9);
9240 }
9241 |  values_clause
9242  {
9243  $$ = $1;
9244 }
9245 |  TABLE relation_expr
9246  {
9247  $$ = cat_str(2,mm_strdup("table"),$2);
9248 }
9249 |  select_clause UNION all_or_distinct select_clause
9250  {
9251  $$ = cat_str(4,$1,mm_strdup("union"),$3,$4);
9252 }
9253 |  select_clause INTERSECT all_or_distinct select_clause
9254  {
9255  $$ = cat_str(4,$1,mm_strdup("intersect"),$3,$4);
9256 }
9257 |  select_clause EXCEPT all_or_distinct select_clause
9258  {
9259  $$ = cat_str(4,$1,mm_strdup("except"),$3,$4);
9260 }
9261 ;
9262 
9263 
9264  with_clause:
9265  WITH cte_list
9266  {
9267  $$ = cat_str(2,mm_strdup("with"),$2);
9268 }
9269 |  WITH_LA cte_list
9270  {
9271  $$ = cat_str(2,mm_strdup("with"),$2);
9272 }
9273 |  WITH RECURSIVE cte_list
9274  {
9275  $$ = cat_str(2,mm_strdup("with recursive"),$3);
9276 }
9277 ;
9278 
9279 
9280  cte_list:
9281  common_table_expr
9282  {
9283  $$ = $1;
9284 }
9285 |  cte_list ',' common_table_expr
9286  {
9287  $$ = cat_str(3,$1,mm_strdup(","),$3);
9288 }
9289 ;
9290 
9291 
9292  common_table_expr:
9293  name opt_name_list AS '(' PreparableStmt ')'
9294  {
9295  $$ = cat_str(5,$1,$2,mm_strdup("as ("),$5,mm_strdup(")"));
9296 }
9297 ;
9298 
9299 
9300  opt_with_clause:
9301  with_clause
9302  {
9303  $$ = $1;
9304 }
9305 |
9306  {
9307  $$=EMPTY; }
9308 ;
9309 
9310 
9311  into_clause:
9312  INTO OptTempTableName
9313 					{
9314 						FoundInto = 1;
9315 						$$= cat2_str(mm_strdup("into"), $2);
9316 					}
9317 	| ecpg_into { $$ = EMPTY; }
9318 |
9319  {
9320  $$=EMPTY; }
9321 ;
9322 
9323 
9324  OptTempTableName:
9325  TEMPORARY opt_table qualified_name
9326  {
9327  $$ = cat_str(3,mm_strdup("temporary"),$2,$3);
9328 }
9329 |  TEMP opt_table qualified_name
9330  {
9331  $$ = cat_str(3,mm_strdup("temp"),$2,$3);
9332 }
9333 |  LOCAL TEMPORARY opt_table qualified_name
9334  {
9335  $$ = cat_str(3,mm_strdup("local temporary"),$3,$4);
9336 }
9337 |  LOCAL TEMP opt_table qualified_name
9338  {
9339  $$ = cat_str(3,mm_strdup("local temp"),$3,$4);
9340 }
9341 |  GLOBAL TEMPORARY opt_table qualified_name
9342  {
9343  $$ = cat_str(3,mm_strdup("global temporary"),$3,$4);
9344 }
9345 |  GLOBAL TEMP opt_table qualified_name
9346  {
9347  $$ = cat_str(3,mm_strdup("global temp"),$3,$4);
9348 }
9349 |  UNLOGGED opt_table qualified_name
9350  {
9351  $$ = cat_str(3,mm_strdup("unlogged"),$2,$3);
9352 }
9353 |  TABLE qualified_name
9354  {
9355  $$ = cat_str(2,mm_strdup("table"),$2);
9356 }
9357 |  qualified_name
9358  {
9359  $$ = $1;
9360 }
9361 ;
9362 
9363 
9364  opt_table:
9365  TABLE
9366  {
9367  $$ = mm_strdup("table");
9368 }
9369 |
9370  {
9371  $$=EMPTY; }
9372 ;
9373 
9374 
9375  all_or_distinct:
9376  ALL
9377  {
9378  $$ = mm_strdup("all");
9379 }
9380 |  DISTINCT
9381  {
9382  $$ = mm_strdup("distinct");
9383 }
9384 |
9385  {
9386  $$=EMPTY; }
9387 ;
9388 
9389 
9390  distinct_clause:
9391  DISTINCT
9392  {
9393  $$ = mm_strdup("distinct");
9394 }
9395 |  DISTINCT ON '(' expr_list ')'
9396  {
9397  $$ = cat_str(3,mm_strdup("distinct on ("),$4,mm_strdup(")"));
9398 }
9399 ;
9400 
9401 
9402  opt_all_clause:
9403  ALL
9404  {
9405  $$ = mm_strdup("all");
9406 }
9407 |
9408  {
9409  $$=EMPTY; }
9410 ;
9411 
9412 
9413  opt_sort_clause:
9414  sort_clause
9415  {
9416  $$ = $1;
9417 }
9418 |
9419  {
9420  $$=EMPTY; }
9421 ;
9422 
9423 
9424  sort_clause:
9425  ORDER BY sortby_list
9426  {
9427  $$ = cat_str(2,mm_strdup("order by"),$3);
9428 }
9429 ;
9430 
9431 
9432  sortby_list:
9433  sortby
9434  {
9435  $$ = $1;
9436 }
9437 |  sortby_list ',' sortby
9438  {
9439  $$ = cat_str(3,$1,mm_strdup(","),$3);
9440 }
9441 ;
9442 
9443 
9444  sortby:
9445  a_expr USING qual_all_Op opt_nulls_order
9446  {
9447  $$ = cat_str(4,$1,mm_strdup("using"),$3,$4);
9448 }
9449 |  a_expr opt_asc_desc opt_nulls_order
9450  {
9451  $$ = cat_str(3,$1,$2,$3);
9452 }
9453 ;
9454 
9455 
9456  select_limit:
9457  limit_clause offset_clause
9458  {
9459  $$ = cat_str(2,$1,$2);
9460 }
9461 |  offset_clause limit_clause
9462  {
9463  $$ = cat_str(2,$1,$2);
9464 }
9465 |  limit_clause
9466  {
9467  $$ = $1;
9468 }
9469 |  offset_clause
9470  {
9471  $$ = $1;
9472 }
9473 ;
9474 
9475 
9476  opt_select_limit:
9477  select_limit
9478  {
9479  $$ = $1;
9480 }
9481 |
9482  {
9483  $$=EMPTY; }
9484 ;
9485 
9486 
9487  limit_clause:
9488  LIMIT select_limit_value
9489  {
9490  $$ = cat_str(2,mm_strdup("limit"),$2);
9491 }
9492 |  LIMIT select_limit_value ',' select_offset_value
9493 	{
9494 		mmerror(PARSE_ERROR, ET_WARNING, "no longer supported LIMIT #,# syntax passed to server");
9495 		$$ = cat_str(4, mm_strdup("limit"), $2, mm_strdup(","), $4);
9496 	}
9497 |  FETCH first_or_next select_fetch_first_value row_or_rows ONLY
9498  {
9499  $$ = cat_str(5,mm_strdup("fetch"),$2,$3,$4,mm_strdup("only"));
9500 }
9501 |  FETCH first_or_next row_or_rows ONLY
9502  {
9503  $$ = cat_str(4,mm_strdup("fetch"),$2,$3,mm_strdup("only"));
9504 }
9505 ;
9506 
9507 
9508  offset_clause:
9509  OFFSET select_offset_value
9510  {
9511  $$ = cat_str(2,mm_strdup("offset"),$2);
9512 }
9513 |  OFFSET select_fetch_first_value row_or_rows
9514  {
9515  $$ = cat_str(3,mm_strdup("offset"),$2,$3);
9516 }
9517 ;
9518 
9519 
9520  select_limit_value:
9521  a_expr
9522  {
9523  $$ = $1;
9524 }
9525 |  ALL
9526  {
9527  $$ = mm_strdup("all");
9528 }
9529 ;
9530 
9531 
9532  select_offset_value:
9533  a_expr
9534  {
9535  $$ = $1;
9536 }
9537 ;
9538 
9539 
9540  select_fetch_first_value:
9541  c_expr
9542  {
9543  $$ = $1;
9544 }
9545 |  '+' I_or_F_const
9546  {
9547  $$ = cat_str(2,mm_strdup("+"),$2);
9548 }
9549 |  '-' I_or_F_const
9550  {
9551  $$ = cat_str(2,mm_strdup("-"),$2);
9552 }
9553 ;
9554 
9555 
9556  I_or_F_const:
9557  Iconst
9558  {
9559  $$ = $1;
9560 }
9561 |  ecpg_fconst
9562  {
9563  $$ = $1;
9564 }
9565 ;
9566 
9567 
9568  row_or_rows:
9569  ROW
9570  {
9571  $$ = mm_strdup("row");
9572 }
9573 |  ROWS
9574  {
9575  $$ = mm_strdup("rows");
9576 }
9577 ;
9578 
9579 
9580  first_or_next:
9581  FIRST_P
9582  {
9583  $$ = mm_strdup("first");
9584 }
9585 |  NEXT
9586  {
9587  $$ = mm_strdup("next");
9588 }
9589 ;
9590 
9591 
9592  group_clause:
9593  GROUP_P BY group_by_list
9594  {
9595  $$ = cat_str(2,mm_strdup("group by"),$3);
9596 }
9597 |
9598  {
9599  $$=EMPTY; }
9600 ;
9601 
9602 
9603  group_by_list:
9604  group_by_item
9605  {
9606  $$ = $1;
9607 }
9608 |  group_by_list ',' group_by_item
9609  {
9610  $$ = cat_str(3,$1,mm_strdup(","),$3);
9611 }
9612 ;
9613 
9614 
9615  group_by_item:
9616  a_expr
9617  {
9618  $$ = $1;
9619 }
9620 |  empty_grouping_set
9621  {
9622  $$ = $1;
9623 }
9624 |  cube_clause
9625  {
9626  $$ = $1;
9627 }
9628 |  rollup_clause
9629  {
9630  $$ = $1;
9631 }
9632 |  grouping_sets_clause
9633  {
9634  $$ = $1;
9635 }
9636 ;
9637 
9638 
9639  empty_grouping_set:
9640  '(' ')'
9641  {
9642  $$ = mm_strdup("( )");
9643 }
9644 ;
9645 
9646 
9647  rollup_clause:
9648  ROLLUP '(' expr_list ')'
9649  {
9650  $$ = cat_str(3,mm_strdup("rollup ("),$3,mm_strdup(")"));
9651 }
9652 ;
9653 
9654 
9655  cube_clause:
9656  CUBE '(' expr_list ')'
9657  {
9658  $$ = cat_str(3,mm_strdup("cube ("),$3,mm_strdup(")"));
9659 }
9660 ;
9661 
9662 
9663  grouping_sets_clause:
9664  GROUPING SETS '(' group_by_list ')'
9665  {
9666  $$ = cat_str(3,mm_strdup("grouping sets ("),$4,mm_strdup(")"));
9667 }
9668 ;
9669 
9670 
9671  having_clause:
9672  HAVING a_expr
9673  {
9674  $$ = cat_str(2,mm_strdup("having"),$2);
9675 }
9676 |
9677  {
9678  $$=EMPTY; }
9679 ;
9680 
9681 
9682  for_locking_clause:
9683  for_locking_items
9684  {
9685  $$ = $1;
9686 }
9687 |  FOR READ ONLY
9688  {
9689  $$ = mm_strdup("for read only");
9690 }
9691 ;
9692 
9693 
9694  opt_for_locking_clause:
9695  for_locking_clause
9696  {
9697  $$ = $1;
9698 }
9699 |
9700  {
9701  $$=EMPTY; }
9702 ;
9703 
9704 
9705  for_locking_items:
9706  for_locking_item
9707  {
9708  $$ = $1;
9709 }
9710 |  for_locking_items for_locking_item
9711  {
9712  $$ = cat_str(2,$1,$2);
9713 }
9714 ;
9715 
9716 
9717  for_locking_item:
9718  for_locking_strength locked_rels_list opt_nowait_or_skip
9719  {
9720  $$ = cat_str(3,$1,$2,$3);
9721 }
9722 ;
9723 
9724 
9725  for_locking_strength:
9726  FOR UPDATE
9727  {
9728  $$ = mm_strdup("for update");
9729 }
9730 |  FOR NO KEY UPDATE
9731  {
9732  $$ = mm_strdup("for no key update");
9733 }
9734 |  FOR SHARE
9735  {
9736  $$ = mm_strdup("for share");
9737 }
9738 |  FOR KEY SHARE
9739  {
9740  $$ = mm_strdup("for key share");
9741 }
9742 ;
9743 
9744 
9745  locked_rels_list:
9746  OF qualified_name_list
9747  {
9748  $$ = cat_str(2,mm_strdup("of"),$2);
9749 }
9750 |
9751  {
9752  $$=EMPTY; }
9753 ;
9754 
9755 
9756  values_clause:
9757  VALUES ctext_row
9758  {
9759  $$ = cat_str(2,mm_strdup("values"),$2);
9760 }
9761 |  values_clause ',' ctext_row
9762  {
9763  $$ = cat_str(3,$1,mm_strdup(","),$3);
9764 }
9765 ;
9766 
9767 
9768  from_clause:
9769  FROM from_list
9770  {
9771  $$ = cat_str(2,mm_strdup("from"),$2);
9772 }
9773 |
9774  {
9775  $$=EMPTY; }
9776 ;
9777 
9778 
9779  from_list:
9780  table_ref
9781  {
9782  $$ = $1;
9783 }
9784 |  from_list ',' table_ref
9785  {
9786  $$ = cat_str(3,$1,mm_strdup(","),$3);
9787 }
9788 ;
9789 
9790 
9791  table_ref:
9792  relation_expr opt_alias_clause
9793  {
9794  $$ = cat_str(2,$1,$2);
9795 }
9796 |  relation_expr opt_alias_clause tablesample_clause
9797  {
9798  $$ = cat_str(3,$1,$2,$3);
9799 }
9800 |  func_table func_alias_clause
9801  {
9802  $$ = cat_str(2,$1,$2);
9803 }
9804 |  LATERAL_P func_table func_alias_clause
9805  {
9806  $$ = cat_str(3,mm_strdup("lateral"),$2,$3);
9807 }
9808 |  select_with_parens opt_alias_clause
9809  {
9810 	if ($2 == NULL)
9811 		mmerror(PARSE_ERROR, ET_ERROR, "subquery in FROM must have an alias");
9812 
9813  $$ = cat_str(2,$1,$2);
9814 }
9815 |  LATERAL_P select_with_parens opt_alias_clause
9816  {
9817 	if ($3 == NULL)
9818 		mmerror(PARSE_ERROR, ET_ERROR, "subquery in FROM must have an alias");
9819 
9820  $$ = cat_str(3,mm_strdup("lateral"),$2,$3);
9821 }
9822 |  joined_table
9823  {
9824  $$ = $1;
9825 }
9826 |  '(' joined_table ')' alias_clause
9827  {
9828  $$ = cat_str(4,mm_strdup("("),$2,mm_strdup(")"),$4);
9829 }
9830 ;
9831 
9832 
9833  joined_table:
9834  '(' joined_table ')'
9835  {
9836  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
9837 }
9838 |  table_ref CROSS JOIN table_ref
9839  {
9840  $$ = cat_str(3,$1,mm_strdup("cross join"),$4);
9841 }
9842 |  table_ref join_type JOIN table_ref join_qual
9843  {
9844  $$ = cat_str(5,$1,$2,mm_strdup("join"),$4,$5);
9845 }
9846 |  table_ref JOIN table_ref join_qual
9847  {
9848  $$ = cat_str(4,$1,mm_strdup("join"),$3,$4);
9849 }
9850 |  table_ref NATURAL join_type JOIN table_ref
9851  {
9852  $$ = cat_str(5,$1,mm_strdup("natural"),$3,mm_strdup("join"),$5);
9853 }
9854 |  table_ref NATURAL JOIN table_ref
9855  {
9856  $$ = cat_str(3,$1,mm_strdup("natural join"),$4);
9857 }
9858 ;
9859 
9860 
9861  alias_clause:
9862  AS ColId '(' name_list ')'
9863  {
9864  $$ = cat_str(5,mm_strdup("as"),$2,mm_strdup("("),$4,mm_strdup(")"));
9865 }
9866 |  AS ColId
9867  {
9868  $$ = cat_str(2,mm_strdup("as"),$2);
9869 }
9870 |  ColId '(' name_list ')'
9871  {
9872  $$ = cat_str(4,$1,mm_strdup("("),$3,mm_strdup(")"));
9873 }
9874 |  ColId
9875  {
9876  $$ = $1;
9877 }
9878 ;
9879 
9880 
9881  opt_alias_clause:
9882  alias_clause
9883  {
9884  $$ = $1;
9885 }
9886 |
9887  {
9888  $$=EMPTY; }
9889 ;
9890 
9891 
9892  func_alias_clause:
9893  alias_clause
9894  {
9895  $$ = $1;
9896 }
9897 |  AS '(' TableFuncElementList ')'
9898  {
9899  $$ = cat_str(3,mm_strdup("as ("),$3,mm_strdup(")"));
9900 }
9901 |  AS ColId '(' TableFuncElementList ')'
9902  {
9903  $$ = cat_str(5,mm_strdup("as"),$2,mm_strdup("("),$4,mm_strdup(")"));
9904 }
9905 |  ColId '(' TableFuncElementList ')'
9906  {
9907  $$ = cat_str(4,$1,mm_strdup("("),$3,mm_strdup(")"));
9908 }
9909 |
9910  {
9911  $$=EMPTY; }
9912 ;
9913 
9914 
9915  join_type:
9916  FULL join_outer
9917  {
9918  $$ = cat_str(2,mm_strdup("full"),$2);
9919 }
9920 |  LEFT join_outer
9921  {
9922  $$ = cat_str(2,mm_strdup("left"),$2);
9923 }
9924 |  RIGHT join_outer
9925  {
9926  $$ = cat_str(2,mm_strdup("right"),$2);
9927 }
9928 |  INNER_P
9929  {
9930  $$ = mm_strdup("inner");
9931 }
9932 ;
9933 
9934 
9935  join_outer:
9936  OUTER_P
9937  {
9938  $$ = mm_strdup("outer");
9939 }
9940 |
9941  {
9942  $$=EMPTY; }
9943 ;
9944 
9945 
9946  join_qual:
9947  USING '(' name_list ')'
9948  {
9949  $$ = cat_str(3,mm_strdup("using ("),$3,mm_strdup(")"));
9950 }
9951 |  ON a_expr
9952  {
9953  $$ = cat_str(2,mm_strdup("on"),$2);
9954 }
9955 ;
9956 
9957 
9958  relation_expr:
9959  qualified_name
9960  {
9961  $$ = $1;
9962 }
9963 |  qualified_name '*'
9964  {
9965  $$ = cat_str(2,$1,mm_strdup("*"));
9966 }
9967 |  ONLY qualified_name
9968  {
9969  $$ = cat_str(2,mm_strdup("only"),$2);
9970 }
9971 |  ONLY '(' qualified_name ')'
9972  {
9973  $$ = cat_str(3,mm_strdup("only ("),$3,mm_strdup(")"));
9974 }
9975 ;
9976 
9977 
9978  relation_expr_list:
9979  relation_expr
9980  {
9981  $$ = $1;
9982 }
9983 |  relation_expr_list ',' relation_expr
9984  {
9985  $$ = cat_str(3,$1,mm_strdup(","),$3);
9986 }
9987 ;
9988 
9989 
9990  relation_expr_opt_alias:
9991  relation_expr %prec UMINUS
9992  {
9993  $$ = $1;
9994 }
9995 |  relation_expr ColId
9996  {
9997  $$ = cat_str(2,$1,$2);
9998 }
9999 |  relation_expr AS ColId
10000  {
10001  $$ = cat_str(3,$1,mm_strdup("as"),$3);
10002 }
10003 ;
10004 
10005 
10006  tablesample_clause:
10007  TABLESAMPLE func_name '(' expr_list ')' opt_repeatable_clause
10008  {
10009  $$ = cat_str(6,mm_strdup("tablesample"),$2,mm_strdup("("),$4,mm_strdup(")"),$6);
10010 }
10011 ;
10012 
10013 
10014  opt_repeatable_clause:
10015  REPEATABLE '(' a_expr ')'
10016  {
10017  $$ = cat_str(3,mm_strdup("repeatable ("),$3,mm_strdup(")"));
10018 }
10019 |
10020  {
10021  $$=EMPTY; }
10022 ;
10023 
10024 
10025  func_table:
10026  func_expr_windowless opt_ordinality
10027  {
10028  $$ = cat_str(2,$1,$2);
10029 }
10030 |  ROWS FROM '(' rowsfrom_list ')' opt_ordinality
10031  {
10032  $$ = cat_str(4,mm_strdup("rows from ("),$4,mm_strdup(")"),$6);
10033 }
10034 ;
10035 
10036 
10037  rowsfrom_item:
10038  func_expr_windowless opt_col_def_list
10039  {
10040  $$ = cat_str(2,$1,$2);
10041 }
10042 ;
10043 
10044 
10045  rowsfrom_list:
10046  rowsfrom_item
10047  {
10048  $$ = $1;
10049 }
10050 |  rowsfrom_list ',' rowsfrom_item
10051  {
10052  $$ = cat_str(3,$1,mm_strdup(","),$3);
10053 }
10054 ;
10055 
10056 
10057  opt_col_def_list:
10058  AS '(' TableFuncElementList ')'
10059  {
10060  $$ = cat_str(3,mm_strdup("as ("),$3,mm_strdup(")"));
10061 }
10062 |
10063  {
10064  $$=EMPTY; }
10065 ;
10066 
10067 
10068  opt_ordinality:
10069  WITH_LA ORDINALITY
10070  {
10071  $$ = mm_strdup("with ordinality");
10072 }
10073 |
10074  {
10075  $$=EMPTY; }
10076 ;
10077 
10078 
10079  where_clause:
10080  WHERE a_expr
10081  {
10082  $$ = cat_str(2,mm_strdup("where"),$2);
10083 }
10084 |
10085  {
10086  $$=EMPTY; }
10087 ;
10088 
10089 
10090  where_or_current_clause:
10091  WHERE a_expr
10092  {
10093  $$ = cat_str(2,mm_strdup("where"),$2);
10094 }
10095 |  WHERE CURRENT_P OF cursor_name
10096 	{
10097 		char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
10098 		$$ = cat_str(2,mm_strdup("where current of"), cursor_marker);
10099 	}
10100 |
10101  {
10102  $$=EMPTY; }
10103 ;
10104 
10105 
10106  OptTableFuncElementList:
10107  TableFuncElementList
10108  {
10109  $$ = $1;
10110 }
10111 |
10112  {
10113  $$=EMPTY; }
10114 ;
10115 
10116 
10117  TableFuncElementList:
10118  TableFuncElement
10119  {
10120  $$ = $1;
10121 }
10122 |  TableFuncElementList ',' TableFuncElement
10123  {
10124  $$ = cat_str(3,$1,mm_strdup(","),$3);
10125 }
10126 ;
10127 
10128 
10129  TableFuncElement:
10130  ColId Typename opt_collate_clause
10131  {
10132  $$ = cat_str(3,$1,$2,$3);
10133 }
10134 ;
10135 
10136 
10137  Typename:
10138  SimpleTypename opt_array_bounds
10139 	{	$$ = cat2_str($1, $2.str); }
10140 |  SETOF SimpleTypename opt_array_bounds
10141 	{	$$ = cat_str(3, mm_strdup("setof"), $2, $3.str); }
10142 |  SimpleTypename ARRAY '[' Iconst ']'
10143  {
10144  $$ = cat_str(4,$1,mm_strdup("array ["),$4,mm_strdup("]"));
10145 }
10146 |  SETOF SimpleTypename ARRAY '[' Iconst ']'
10147  {
10148  $$ = cat_str(5,mm_strdup("setof"),$2,mm_strdup("array ["),$5,mm_strdup("]"));
10149 }
10150 |  SimpleTypename ARRAY
10151  {
10152  $$ = cat_str(2,$1,mm_strdup("array"));
10153 }
10154 |  SETOF SimpleTypename ARRAY
10155  {
10156  $$ = cat_str(3,mm_strdup("setof"),$2,mm_strdup("array"));
10157 }
10158 ;
10159 
10160 
10161  opt_array_bounds:
10162  opt_array_bounds '[' ']'
10163 	{
10164 		$$.index1 = $1.index1;
10165 		$$.index2 = $1.index2;
10166 		if (strcmp($$.index1, "-1") == 0)
10167 			$$.index1 = mm_strdup("0");
10168 		else if (strcmp($1.index2, "-1") == 0)
10169 			$$.index2 = mm_strdup("0");
10170 		$$.str = cat_str(2, $1.str, mm_strdup("[]"));
10171 	}
10172 	| opt_array_bounds '[' Iresult ']'
10173 	{
10174 		$$.index1 = $1.index1;
10175 		$$.index2 = $1.index2;
10176 		if (strcmp($1.index1, "-1") == 0)
10177 			$$.index1 = mm_strdup($3);
10178 		else if (strcmp($1.index2, "-1") == 0)
10179 			$$.index2 = mm_strdup($3);
10180 		$$.str = cat_str(4, $1.str, mm_strdup("["), $3, mm_strdup("]"));
10181 	}
10182 |
10183 	{
10184 		$$.index1 = mm_strdup("-1");
10185 		$$.index2 = mm_strdup("-1");
10186 		$$.str= EMPTY;
10187 	}
10188 ;
10189 
10190 
10191  SimpleTypename:
10192  GenericType
10193  {
10194  $$ = $1;
10195 }
10196 |  Numeric
10197  {
10198  $$ = $1;
10199 }
10200 |  Bit
10201  {
10202  $$ = $1;
10203 }
10204 |  Character
10205  {
10206  $$ = $1;
10207 }
10208 |  ConstDatetime
10209  {
10210  $$ = $1;
10211 }
10212 |  ConstInterval opt_interval
10213  {
10214  $$ = cat_str(2,$1,$2);
10215 }
10216 |  ConstInterval '(' Iconst ')'
10217  {
10218  $$ = cat_str(4,$1,mm_strdup("("),$3,mm_strdup(")"));
10219 }
10220 ;
10221 
10222 
10223  ConstTypename:
10224  Numeric
10225  {
10226  $$ = $1;
10227 }
10228 |  ConstBit
10229  {
10230  $$ = $1;
10231 }
10232 |  ConstCharacter
10233  {
10234  $$ = $1;
10235 }
10236 |  ConstDatetime
10237  {
10238  $$ = $1;
10239 }
10240 ;
10241 
10242 
10243  GenericType:
10244  type_function_name opt_type_modifiers
10245  {
10246  $$ = cat_str(2,$1,$2);
10247 }
10248 |  type_function_name attrs opt_type_modifiers
10249  {
10250  $$ = cat_str(3,$1,$2,$3);
10251 }
10252 ;
10253 
10254 
10255  opt_type_modifiers:
10256  '(' expr_list ')'
10257  {
10258  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
10259 }
10260 |
10261  {
10262  $$=EMPTY; }
10263 ;
10264 
10265 
10266  Numeric:
10267  INT_P
10268  {
10269  $$ = mm_strdup("int");
10270 }
10271 |  INTEGER
10272  {
10273  $$ = mm_strdup("integer");
10274 }
10275 |  SMALLINT
10276  {
10277  $$ = mm_strdup("smallint");
10278 }
10279 |  BIGINT
10280  {
10281  $$ = mm_strdup("bigint");
10282 }
10283 |  REAL
10284  {
10285  $$ = mm_strdup("real");
10286 }
10287 |  FLOAT_P opt_float
10288  {
10289  $$ = cat_str(2,mm_strdup("float"),$2);
10290 }
10291 |  DOUBLE_P PRECISION
10292  {
10293  $$ = mm_strdup("double precision");
10294 }
10295 |  DECIMAL_P opt_type_modifiers
10296  {
10297  $$ = cat_str(2,mm_strdup("decimal"),$2);
10298 }
10299 |  DEC opt_type_modifiers
10300  {
10301  $$ = cat_str(2,mm_strdup("dec"),$2);
10302 }
10303 |  NUMERIC opt_type_modifiers
10304  {
10305  $$ = cat_str(2,mm_strdup("numeric"),$2);
10306 }
10307 |  BOOLEAN_P
10308  {
10309  $$ = mm_strdup("boolean");
10310 }
10311 ;
10312 
10313 
10314  opt_float:
10315  '(' Iconst ')'
10316  {
10317  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
10318 }
10319 |
10320  {
10321  $$=EMPTY; }
10322 ;
10323 
10324 
10325  Bit:
10326  BitWithLength
10327  {
10328  $$ = $1;
10329 }
10330 |  BitWithoutLength
10331  {
10332  $$ = $1;
10333 }
10334 ;
10335 
10336 
10337  ConstBit:
10338  BitWithLength
10339  {
10340  $$ = $1;
10341 }
10342 |  BitWithoutLength
10343  {
10344  $$ = $1;
10345 }
10346 ;
10347 
10348 
10349  BitWithLength:
10350  BIT opt_varying '(' expr_list ')'
10351  {
10352  $$ = cat_str(5,mm_strdup("bit"),$2,mm_strdup("("),$4,mm_strdup(")"));
10353 }
10354 ;
10355 
10356 
10357  BitWithoutLength:
10358  BIT opt_varying
10359  {
10360  $$ = cat_str(2,mm_strdup("bit"),$2);
10361 }
10362 ;
10363 
10364 
10365  Character:
10366  CharacterWithLength
10367  {
10368  $$ = $1;
10369 }
10370 |  CharacterWithoutLength
10371  {
10372  $$ = $1;
10373 }
10374 ;
10375 
10376 
10377  ConstCharacter:
10378  CharacterWithLength
10379  {
10380  $$ = $1;
10381 }
10382 |  CharacterWithoutLength
10383  {
10384  $$ = $1;
10385 }
10386 ;
10387 
10388 
10389  CharacterWithLength:
10390  character '(' Iconst ')' opt_charset
10391  {
10392  $$ = cat_str(5,$1,mm_strdup("("),$3,mm_strdup(")"),$5);
10393 }
10394 ;
10395 
10396 
10397  CharacterWithoutLength:
10398  character opt_charset
10399  {
10400  $$ = cat_str(2,$1,$2);
10401 }
10402 ;
10403 
10404 
10405  character:
10406  CHARACTER opt_varying
10407  {
10408  $$ = cat_str(2,mm_strdup("character"),$2);
10409 }
10410 |  CHAR_P opt_varying
10411  {
10412  $$ = cat_str(2,mm_strdup("char"),$2);
10413 }
10414 |  VARCHAR
10415  {
10416  $$ = mm_strdup("varchar");
10417 }
10418 |  NATIONAL CHARACTER opt_varying
10419  {
10420  $$ = cat_str(2,mm_strdup("national character"),$3);
10421 }
10422 |  NATIONAL CHAR_P opt_varying
10423  {
10424  $$ = cat_str(2,mm_strdup("national char"),$3);
10425 }
10426 |  NCHAR opt_varying
10427  {
10428  $$ = cat_str(2,mm_strdup("nchar"),$2);
10429 }
10430 ;
10431 
10432 
10433  opt_varying:
10434  VARYING
10435  {
10436  $$ = mm_strdup("varying");
10437 }
10438 |
10439  {
10440  $$=EMPTY; }
10441 ;
10442 
10443 
10444  opt_charset:
10445  CHARACTER SET ColId
10446  {
10447  $$ = cat_str(2,mm_strdup("character set"),$3);
10448 }
10449 |
10450  {
10451  $$=EMPTY; }
10452 ;
10453 
10454 
10455  ConstDatetime:
10456  TIMESTAMP '(' Iconst ')' opt_timezone
10457  {
10458  $$ = cat_str(4,mm_strdup("timestamp ("),$3,mm_strdup(")"),$5);
10459 }
10460 |  TIMESTAMP opt_timezone
10461  {
10462  $$ = cat_str(2,mm_strdup("timestamp"),$2);
10463 }
10464 |  TIME '(' Iconst ')' opt_timezone
10465  {
10466  $$ = cat_str(4,mm_strdup("time ("),$3,mm_strdup(")"),$5);
10467 }
10468 |  TIME opt_timezone
10469  {
10470  $$ = cat_str(2,mm_strdup("time"),$2);
10471 }
10472 ;
10473 
10474 
10475  ConstInterval:
10476  INTERVAL
10477  {
10478  $$ = mm_strdup("interval");
10479 }
10480 ;
10481 
10482 
10483  opt_timezone:
10484  WITH_LA TIME ZONE
10485  {
10486  $$ = mm_strdup("with time zone");
10487 }
10488 |  WITHOUT TIME ZONE
10489  {
10490  $$ = mm_strdup("without time zone");
10491 }
10492 |
10493  {
10494  $$=EMPTY; }
10495 ;
10496 
10497 
10498  opt_interval:
10499  YEAR_P
10500  {
10501  $$ = mm_strdup("year");
10502 }
10503 |  MONTH_P
10504  {
10505  $$ = mm_strdup("month");
10506 }
10507 |  DAY_P
10508  {
10509  $$ = mm_strdup("day");
10510 }
10511 |  HOUR_P
10512  {
10513  $$ = mm_strdup("hour");
10514 }
10515 |  MINUTE_P
10516  {
10517  $$ = mm_strdup("minute");
10518 }
10519 |  interval_second
10520  {
10521  $$ = $1;
10522 }
10523 |  YEAR_P TO MONTH_P
10524  {
10525  $$ = mm_strdup("year to month");
10526 }
10527 |  DAY_P TO HOUR_P
10528  {
10529  $$ = mm_strdup("day to hour");
10530 }
10531 |  DAY_P TO MINUTE_P
10532  {
10533  $$ = mm_strdup("day to minute");
10534 }
10535 |  DAY_P TO interval_second
10536  {
10537  $$ = cat_str(2,mm_strdup("day to"),$3);
10538 }
10539 |  HOUR_P TO MINUTE_P
10540  {
10541  $$ = mm_strdup("hour to minute");
10542 }
10543 |  HOUR_P TO interval_second
10544  {
10545  $$ = cat_str(2,mm_strdup("hour to"),$3);
10546 }
10547 |  MINUTE_P TO interval_second
10548  {
10549  $$ = cat_str(2,mm_strdup("minute to"),$3);
10550 }
10551 |
10552  {
10553  $$=EMPTY; }
10554 ;
10555 
10556 
10557  interval_second:
10558  SECOND_P
10559  {
10560  $$ = mm_strdup("second");
10561 }
10562 |  SECOND_P '(' Iconst ')'
10563  {
10564  $$ = cat_str(3,mm_strdup("second ("),$3,mm_strdup(")"));
10565 }
10566 ;
10567 
10568 
10569  a_expr:
10570  c_expr
10571  {
10572  $$ = $1;
10573 }
10574 |  a_expr TYPECAST Typename
10575  {
10576  $$ = cat_str(3,$1,mm_strdup("::"),$3);
10577 }
10578 |  a_expr COLLATE any_name
10579  {
10580  $$ = cat_str(3,$1,mm_strdup("collate"),$3);
10581 }
10582 |  a_expr AT TIME ZONE a_expr %prec AT
10583  {
10584  $$ = cat_str(3,$1,mm_strdup("at time zone"),$5);
10585 }
10586 |  '+' a_expr %prec UMINUS
10587  {
10588  $$ = cat_str(2,mm_strdup("+"),$2);
10589 }
10590 |  '-' a_expr %prec UMINUS
10591  {
10592  $$ = cat_str(2,mm_strdup("-"),$2);
10593 }
10594 |  a_expr '+' a_expr
10595  {
10596  $$ = cat_str(3,$1,mm_strdup("+"),$3);
10597 }
10598 |  a_expr '-' a_expr
10599  {
10600  $$ = cat_str(3,$1,mm_strdup("-"),$3);
10601 }
10602 |  a_expr '*' a_expr
10603  {
10604  $$ = cat_str(3,$1,mm_strdup("*"),$3);
10605 }
10606 |  a_expr '/' a_expr
10607  {
10608  $$ = cat_str(3,$1,mm_strdup("/"),$3);
10609 }
10610 |  a_expr '%' a_expr
10611  {
10612  $$ = cat_str(3,$1,mm_strdup("%"),$3);
10613 }
10614 |  a_expr '^' a_expr
10615  {
10616  $$ = cat_str(3,$1,mm_strdup("^"),$3);
10617 }
10618 |  a_expr '<' a_expr
10619  {
10620  $$ = cat_str(3,$1,mm_strdup("<"),$3);
10621 }
10622 |  a_expr '>' a_expr
10623  {
10624  $$ = cat_str(3,$1,mm_strdup(">"),$3);
10625 }
10626 |  a_expr '=' a_expr
10627  {
10628  $$ = cat_str(3,$1,mm_strdup("="),$3);
10629 }
10630 |  a_expr LESS_EQUALS a_expr
10631  {
10632  $$ = cat_str(3,$1,mm_strdup("<="),$3);
10633 }
10634 |  a_expr GREATER_EQUALS a_expr
10635  {
10636  $$ = cat_str(3,$1,mm_strdup(">="),$3);
10637 }
10638 |  a_expr NOT_EQUALS a_expr
10639  {
10640  $$ = cat_str(3,$1,mm_strdup("<>"),$3);
10641 }
10642 |  a_expr qual_Op a_expr %prec Op
10643  {
10644  $$ = cat_str(3,$1,$2,$3);
10645 }
10646 |  qual_Op a_expr %prec Op
10647  {
10648  $$ = cat_str(2,$1,$2);
10649 }
10650 |  a_expr qual_Op %prec POSTFIXOP
10651  {
10652  $$ = cat_str(2,$1,$2);
10653 }
10654 |  a_expr AND a_expr
10655  {
10656  $$ = cat_str(3,$1,mm_strdup("and"),$3);
10657 }
10658 |  a_expr OR a_expr
10659  {
10660  $$ = cat_str(3,$1,mm_strdup("or"),$3);
10661 }
10662 |  NOT a_expr
10663  {
10664  $$ = cat_str(2,mm_strdup("not"),$2);
10665 }
10666 |  NOT_LA a_expr %prec NOT
10667  {
10668  $$ = cat_str(2,mm_strdup("not"),$2);
10669 }
10670 |  a_expr LIKE a_expr
10671  {
10672  $$ = cat_str(3,$1,mm_strdup("like"),$3);
10673 }
10674 |  a_expr LIKE a_expr ESCAPE a_expr %prec LIKE
10675  {
10676  $$ = cat_str(5,$1,mm_strdup("like"),$3,mm_strdup("escape"),$5);
10677 }
10678 |  a_expr NOT_LA LIKE a_expr %prec NOT_LA
10679  {
10680  $$ = cat_str(3,$1,mm_strdup("not like"),$4);
10681 }
10682 |  a_expr NOT_LA LIKE a_expr ESCAPE a_expr %prec NOT_LA
10683  {
10684  $$ = cat_str(5,$1,mm_strdup("not like"),$4,mm_strdup("escape"),$6);
10685 }
10686 |  a_expr ILIKE a_expr
10687  {
10688  $$ = cat_str(3,$1,mm_strdup("ilike"),$3);
10689 }
10690 |  a_expr ILIKE a_expr ESCAPE a_expr %prec ILIKE
10691  {
10692  $$ = cat_str(5,$1,mm_strdup("ilike"),$3,mm_strdup("escape"),$5);
10693 }
10694 |  a_expr NOT_LA ILIKE a_expr %prec NOT_LA
10695  {
10696  $$ = cat_str(3,$1,mm_strdup("not ilike"),$4);
10697 }
10698 |  a_expr NOT_LA ILIKE a_expr ESCAPE a_expr %prec NOT_LA
10699  {
10700  $$ = cat_str(5,$1,mm_strdup("not ilike"),$4,mm_strdup("escape"),$6);
10701 }
10702 |  a_expr SIMILAR TO a_expr %prec SIMILAR
10703  {
10704  $$ = cat_str(3,$1,mm_strdup("similar to"),$4);
10705 }
10706 |  a_expr SIMILAR TO a_expr ESCAPE a_expr %prec SIMILAR
10707  {
10708  $$ = cat_str(5,$1,mm_strdup("similar to"),$4,mm_strdup("escape"),$6);
10709 }
10710 |  a_expr NOT_LA SIMILAR TO a_expr %prec NOT_LA
10711  {
10712  $$ = cat_str(3,$1,mm_strdup("not similar to"),$5);
10713 }
10714 |  a_expr NOT_LA SIMILAR TO a_expr ESCAPE a_expr %prec NOT_LA
10715  {
10716  $$ = cat_str(5,$1,mm_strdup("not similar to"),$5,mm_strdup("escape"),$7);
10717 }
10718 |  a_expr IS NULL_P %prec IS
10719  {
10720  $$ = cat_str(2,$1,mm_strdup("is null"));
10721 }
10722 |  a_expr ISNULL
10723  {
10724  $$ = cat_str(2,$1,mm_strdup("isnull"));
10725 }
10726 |  a_expr IS NOT NULL_P %prec IS
10727  {
10728  $$ = cat_str(2,$1,mm_strdup("is not null"));
10729 }
10730 |  a_expr NOTNULL
10731  {
10732  $$ = cat_str(2,$1,mm_strdup("notnull"));
10733 }
10734 |  row OVERLAPS row
10735  {
10736  $$ = cat_str(3,$1,mm_strdup("overlaps"),$3);
10737 }
10738 |  a_expr IS TRUE_P %prec IS
10739  {
10740  $$ = cat_str(2,$1,mm_strdup("is true"));
10741 }
10742 |  a_expr IS NOT TRUE_P %prec IS
10743  {
10744  $$ = cat_str(2,$1,mm_strdup("is not true"));
10745 }
10746 |  a_expr IS FALSE_P %prec IS
10747  {
10748  $$ = cat_str(2,$1,mm_strdup("is false"));
10749 }
10750 |  a_expr IS NOT FALSE_P %prec IS
10751  {
10752  $$ = cat_str(2,$1,mm_strdup("is not false"));
10753 }
10754 |  a_expr IS UNKNOWN %prec IS
10755  {
10756  $$ = cat_str(2,$1,mm_strdup("is unknown"));
10757 }
10758 |  a_expr IS NOT UNKNOWN %prec IS
10759  {
10760  $$ = cat_str(2,$1,mm_strdup("is not unknown"));
10761 }
10762 |  a_expr IS DISTINCT FROM a_expr %prec IS
10763  {
10764  $$ = cat_str(3,$1,mm_strdup("is distinct from"),$5);
10765 }
10766 |  a_expr IS NOT DISTINCT FROM a_expr %prec IS
10767  {
10768  $$ = cat_str(3,$1,mm_strdup("is not distinct from"),$6);
10769 }
10770 |  a_expr IS OF '(' type_list ')' %prec IS
10771  {
10772  $$ = cat_str(4,$1,mm_strdup("is of ("),$5,mm_strdup(")"));
10773 }
10774 |  a_expr IS NOT OF '(' type_list ')' %prec IS
10775  {
10776  $$ = cat_str(4,$1,mm_strdup("is not of ("),$6,mm_strdup(")"));
10777 }
10778 |  a_expr BETWEEN opt_asymmetric b_expr AND a_expr %prec BETWEEN
10779  {
10780  $$ = cat_str(6,$1,mm_strdup("between"),$3,$4,mm_strdup("and"),$6);
10781 }
10782 |  a_expr NOT_LA BETWEEN opt_asymmetric b_expr AND a_expr %prec NOT_LA
10783  {
10784  $$ = cat_str(6,$1,mm_strdup("not between"),$4,$5,mm_strdup("and"),$7);
10785 }
10786 |  a_expr BETWEEN SYMMETRIC b_expr AND a_expr %prec BETWEEN
10787  {
10788  $$ = cat_str(5,$1,mm_strdup("between symmetric"),$4,mm_strdup("and"),$6);
10789 }
10790 |  a_expr NOT_LA BETWEEN SYMMETRIC b_expr AND a_expr %prec NOT_LA
10791  {
10792  $$ = cat_str(5,$1,mm_strdup("not between symmetric"),$5,mm_strdup("and"),$7);
10793 }
10794 |  a_expr IN_P in_expr
10795  {
10796  $$ = cat_str(3,$1,mm_strdup("in"),$3);
10797 }
10798 |  a_expr NOT_LA IN_P in_expr %prec NOT_LA
10799  {
10800  $$ = cat_str(3,$1,mm_strdup("not in"),$4);
10801 }
10802 |  a_expr subquery_Op sub_type select_with_parens %prec Op
10803  {
10804  $$ = cat_str(4,$1,$2,$3,$4);
10805 }
10806 |  a_expr subquery_Op sub_type '(' a_expr ')' %prec Op
10807  {
10808  $$ = cat_str(6,$1,$2,$3,mm_strdup("("),$5,mm_strdup(")"));
10809 }
10810 |  UNIQUE select_with_parens
10811  {
10812 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
10813  $$ = cat_str(2,mm_strdup("unique"),$2);
10814 }
10815 |  a_expr IS DOCUMENT_P %prec IS
10816  {
10817  $$ = cat_str(2,$1,mm_strdup("is document"));
10818 }
10819 |  a_expr IS NOT DOCUMENT_P %prec IS
10820  {
10821  $$ = cat_str(2,$1,mm_strdup("is not document"));
10822 }
10823 ;
10824 
10825 
10826  b_expr:
10827  c_expr
10828  {
10829  $$ = $1;
10830 }
10831 |  b_expr TYPECAST Typename
10832  {
10833  $$ = cat_str(3,$1,mm_strdup("::"),$3);
10834 }
10835 |  '+' b_expr %prec UMINUS
10836  {
10837  $$ = cat_str(2,mm_strdup("+"),$2);
10838 }
10839 |  '-' b_expr %prec UMINUS
10840  {
10841  $$ = cat_str(2,mm_strdup("-"),$2);
10842 }
10843 |  b_expr '+' b_expr
10844  {
10845  $$ = cat_str(3,$1,mm_strdup("+"),$3);
10846 }
10847 |  b_expr '-' b_expr
10848  {
10849  $$ = cat_str(3,$1,mm_strdup("-"),$3);
10850 }
10851 |  b_expr '*' b_expr
10852  {
10853  $$ = cat_str(3,$1,mm_strdup("*"),$3);
10854 }
10855 |  b_expr '/' b_expr
10856  {
10857  $$ = cat_str(3,$1,mm_strdup("/"),$3);
10858 }
10859 |  b_expr '%' b_expr
10860  {
10861  $$ = cat_str(3,$1,mm_strdup("%"),$3);
10862 }
10863 |  b_expr '^' b_expr
10864  {
10865  $$ = cat_str(3,$1,mm_strdup("^"),$3);
10866 }
10867 |  b_expr '<' b_expr
10868  {
10869  $$ = cat_str(3,$1,mm_strdup("<"),$3);
10870 }
10871 |  b_expr '>' b_expr
10872  {
10873  $$ = cat_str(3,$1,mm_strdup(">"),$3);
10874 }
10875 |  b_expr '=' b_expr
10876  {
10877  $$ = cat_str(3,$1,mm_strdup("="),$3);
10878 }
10879 |  b_expr LESS_EQUALS b_expr
10880  {
10881  $$ = cat_str(3,$1,mm_strdup("<="),$3);
10882 }
10883 |  b_expr GREATER_EQUALS b_expr
10884  {
10885  $$ = cat_str(3,$1,mm_strdup(">="),$3);
10886 }
10887 |  b_expr NOT_EQUALS b_expr
10888  {
10889  $$ = cat_str(3,$1,mm_strdup("<>"),$3);
10890 }
10891 |  b_expr qual_Op b_expr %prec Op
10892  {
10893  $$ = cat_str(3,$1,$2,$3);
10894 }
10895 |  qual_Op b_expr %prec Op
10896  {
10897  $$ = cat_str(2,$1,$2);
10898 }
10899 |  b_expr qual_Op %prec POSTFIXOP
10900  {
10901  $$ = cat_str(2,$1,$2);
10902 }
10903 |  b_expr IS DISTINCT FROM b_expr %prec IS
10904  {
10905  $$ = cat_str(3,$1,mm_strdup("is distinct from"),$5);
10906 }
10907 |  b_expr IS NOT DISTINCT FROM b_expr %prec IS
10908  {
10909  $$ = cat_str(3,$1,mm_strdup("is not distinct from"),$6);
10910 }
10911 |  b_expr IS OF '(' type_list ')' %prec IS
10912  {
10913  $$ = cat_str(4,$1,mm_strdup("is of ("),$5,mm_strdup(")"));
10914 }
10915 |  b_expr IS NOT OF '(' type_list ')' %prec IS
10916  {
10917  $$ = cat_str(4,$1,mm_strdup("is not of ("),$6,mm_strdup(")"));
10918 }
10919 |  b_expr IS DOCUMENT_P %prec IS
10920  {
10921  $$ = cat_str(2,$1,mm_strdup("is document"));
10922 }
10923 |  b_expr IS NOT DOCUMENT_P %prec IS
10924  {
10925  $$ = cat_str(2,$1,mm_strdup("is not document"));
10926 }
10927 ;
10928 
10929 
10930  c_expr:
10931  columnref
10932  {
10933  $$ = $1;
10934 }
10935 |  AexprConst
10936  {
10937  $$ = $1;
10938 }
10939 |  ecpg_param opt_indirection
10940  {
10941  $$ = cat_str(2,$1,$2);
10942 }
10943 |  '(' a_expr ')' opt_indirection
10944  {
10945  $$ = cat_str(4,mm_strdup("("),$2,mm_strdup(")"),$4);
10946 }
10947 |  case_expr
10948  {
10949  $$ = $1;
10950 }
10951 |  func_expr
10952  {
10953  $$ = $1;
10954 }
10955 |  select_with_parens %prec UMINUS
10956  {
10957  $$ = $1;
10958 }
10959 |  select_with_parens indirection
10960  {
10961  $$ = cat_str(2,$1,$2);
10962 }
10963 |  EXISTS select_with_parens
10964  {
10965  $$ = cat_str(2,mm_strdup("exists"),$2);
10966 }
10967 |  ARRAY select_with_parens
10968  {
10969  $$ = cat_str(2,mm_strdup("array"),$2);
10970 }
10971 |  ARRAY array_expr
10972  {
10973  $$ = cat_str(2,mm_strdup("array"),$2);
10974 }
10975 |  explicit_row
10976  {
10977  $$ = $1;
10978 }
10979 |  implicit_row
10980  {
10981  $$ = $1;
10982 }
10983 |  GROUPING '(' expr_list ')'
10984  {
10985  $$ = cat_str(3,mm_strdup("grouping ("),$3,mm_strdup(")"));
10986 }
10987 ;
10988 
10989 
10990  func_application:
10991  func_name '(' ')'
10992  {
10993  $$ = cat_str(2,$1,mm_strdup("( )"));
10994 }
10995 |  func_name '(' func_arg_list opt_sort_clause ')'
10996  {
10997  $$ = cat_str(5,$1,mm_strdup("("),$3,$4,mm_strdup(")"));
10998 }
10999 |  func_name '(' VARIADIC func_arg_expr opt_sort_clause ')'
11000  {
11001  $$ = cat_str(5,$1,mm_strdup("( variadic"),$4,$5,mm_strdup(")"));
11002 }
11003 |  func_name '(' func_arg_list ',' VARIADIC func_arg_expr opt_sort_clause ')'
11004  {
11005  $$ = cat_str(7,$1,mm_strdup("("),$3,mm_strdup(", variadic"),$6,$7,mm_strdup(")"));
11006 }
11007 |  func_name '(' ALL func_arg_list opt_sort_clause ')'
11008  {
11009  $$ = cat_str(5,$1,mm_strdup("( all"),$4,$5,mm_strdup(")"));
11010 }
11011 |  func_name '(' DISTINCT func_arg_list opt_sort_clause ')'
11012  {
11013  $$ = cat_str(5,$1,mm_strdup("( distinct"),$4,$5,mm_strdup(")"));
11014 }
11015 |  func_name '(' '*' ')'
11016  {
11017  $$ = cat_str(2,$1,mm_strdup("( * )"));
11018 }
11019 ;
11020 
11021 
11022  func_expr:
11023  func_application within_group_clause filter_clause over_clause
11024  {
11025  $$ = cat_str(4,$1,$2,$3,$4);
11026 }
11027 |  func_expr_common_subexpr
11028  {
11029  $$ = $1;
11030 }
11031 ;
11032 
11033 
11034  func_expr_windowless:
11035  func_application
11036  {
11037  $$ = $1;
11038 }
11039 |  func_expr_common_subexpr
11040  {
11041  $$ = $1;
11042 }
11043 ;
11044 
11045 
11046  func_expr_common_subexpr:
11047  COLLATION FOR '(' a_expr ')'
11048  {
11049  $$ = cat_str(3,mm_strdup("collation for ("),$4,mm_strdup(")"));
11050 }
11051 |  CURRENT_DATE
11052  {
11053  $$ = mm_strdup("current_date");
11054 }
11055 |  CURRENT_TIME
11056  {
11057  $$ = mm_strdup("current_time");
11058 }
11059 |  CURRENT_TIME '(' Iconst ')'
11060  {
11061  $$ = cat_str(3,mm_strdup("current_time ("),$3,mm_strdup(")"));
11062 }
11063 |  CURRENT_TIMESTAMP
11064  {
11065  $$ = mm_strdup("current_timestamp");
11066 }
11067 |  CURRENT_TIMESTAMP '(' Iconst ')'
11068  {
11069  $$ = cat_str(3,mm_strdup("current_timestamp ("),$3,mm_strdup(")"));
11070 }
11071 |  LOCALTIME
11072  {
11073  $$ = mm_strdup("localtime");
11074 }
11075 |  LOCALTIME '(' Iconst ')'
11076  {
11077  $$ = cat_str(3,mm_strdup("localtime ("),$3,mm_strdup(")"));
11078 }
11079 |  LOCALTIMESTAMP
11080  {
11081  $$ = mm_strdup("localtimestamp");
11082 }
11083 |  LOCALTIMESTAMP '(' Iconst ')'
11084  {
11085  $$ = cat_str(3,mm_strdup("localtimestamp ("),$3,mm_strdup(")"));
11086 }
11087 |  CURRENT_ROLE
11088  {
11089  $$ = mm_strdup("current_role");
11090 }
11091 |  CURRENT_USER
11092  {
11093  $$ = mm_strdup("current_user");
11094 }
11095 |  SESSION_USER
11096  {
11097  $$ = mm_strdup("session_user");
11098 }
11099 |  USER
11100  {
11101  $$ = mm_strdup("user");
11102 }
11103 |  CURRENT_CATALOG
11104  {
11105  $$ = mm_strdup("current_catalog");
11106 }
11107 |  CURRENT_SCHEMA
11108  {
11109  $$ = mm_strdup("current_schema");
11110 }
11111 |  CAST '(' a_expr AS Typename ')'
11112  {
11113  $$ = cat_str(5,mm_strdup("cast ("),$3,mm_strdup("as"),$5,mm_strdup(")"));
11114 }
11115 |  EXTRACT '(' extract_list ')'
11116  {
11117  $$ = cat_str(3,mm_strdup("extract ("),$3,mm_strdup(")"));
11118 }
11119 |  OVERLAY '(' overlay_list ')'
11120  {
11121  $$ = cat_str(3,mm_strdup("overlay ("),$3,mm_strdup(")"));
11122 }
11123 |  POSITION '(' position_list ')'
11124  {
11125  $$ = cat_str(3,mm_strdup("position ("),$3,mm_strdup(")"));
11126 }
11127 |  SUBSTRING '(' substr_list ')'
11128  {
11129  $$ = cat_str(3,mm_strdup("substring ("),$3,mm_strdup(")"));
11130 }
11131 |  TREAT '(' a_expr AS Typename ')'
11132  {
11133  $$ = cat_str(5,mm_strdup("treat ("),$3,mm_strdup("as"),$5,mm_strdup(")"));
11134 }
11135 |  TRIM '(' BOTH trim_list ')'
11136  {
11137  $$ = cat_str(3,mm_strdup("trim ( both"),$4,mm_strdup(")"));
11138 }
11139 |  TRIM '(' LEADING trim_list ')'
11140  {
11141  $$ = cat_str(3,mm_strdup("trim ( leading"),$4,mm_strdup(")"));
11142 }
11143 |  TRIM '(' TRAILING trim_list ')'
11144  {
11145  $$ = cat_str(3,mm_strdup("trim ( trailing"),$4,mm_strdup(")"));
11146 }
11147 |  TRIM '(' trim_list ')'
11148  {
11149  $$ = cat_str(3,mm_strdup("trim ("),$3,mm_strdup(")"));
11150 }
11151 |  NULLIF '(' a_expr ',' a_expr ')'
11152  {
11153  $$ = cat_str(5,mm_strdup("nullif ("),$3,mm_strdup(","),$5,mm_strdup(")"));
11154 }
11155 |  COALESCE '(' expr_list ')'
11156  {
11157  $$ = cat_str(3,mm_strdup("coalesce ("),$3,mm_strdup(")"));
11158 }
11159 |  GREATEST '(' expr_list ')'
11160  {
11161  $$ = cat_str(3,mm_strdup("greatest ("),$3,mm_strdup(")"));
11162 }
11163 |  LEAST '(' expr_list ')'
11164  {
11165  $$ = cat_str(3,mm_strdup("least ("),$3,mm_strdup(")"));
11166 }
11167 |  XMLCONCAT '(' expr_list ')'
11168  {
11169  $$ = cat_str(3,mm_strdup("xmlconcat ("),$3,mm_strdup(")"));
11170 }
11171 |  XMLELEMENT '(' NAME_P ColLabel ')'
11172  {
11173  $$ = cat_str(3,mm_strdup("xmlelement ( name"),$4,mm_strdup(")"));
11174 }
11175 |  XMLELEMENT '(' NAME_P ColLabel ',' xml_attributes ')'
11176  {
11177  $$ = cat_str(5,mm_strdup("xmlelement ( name"),$4,mm_strdup(","),$6,mm_strdup(")"));
11178 }
11179 |  XMLELEMENT '(' NAME_P ColLabel ',' expr_list ')'
11180  {
11181  $$ = cat_str(5,mm_strdup("xmlelement ( name"),$4,mm_strdup(","),$6,mm_strdup(")"));
11182 }
11183 |  XMLELEMENT '(' NAME_P ColLabel ',' xml_attributes ',' expr_list ')'
11184  {
11185  $$ = cat_str(7,mm_strdup("xmlelement ( name"),$4,mm_strdup(","),$6,mm_strdup(","),$8,mm_strdup(")"));
11186 }
11187 |  XMLEXISTS '(' c_expr xmlexists_argument ')'
11188  {
11189  $$ = cat_str(4,mm_strdup("xmlexists ("),$3,$4,mm_strdup(")"));
11190 }
11191 |  XMLFOREST '(' xml_attribute_list ')'
11192  {
11193  $$ = cat_str(3,mm_strdup("xmlforest ("),$3,mm_strdup(")"));
11194 }
11195 |  XMLPARSE '(' document_or_content a_expr xml_whitespace_option ')'
11196  {
11197  $$ = cat_str(5,mm_strdup("xmlparse ("),$3,$4,$5,mm_strdup(")"));
11198 }
11199 |  XMLPI '(' NAME_P ColLabel ')'
11200  {
11201  $$ = cat_str(3,mm_strdup("xmlpi ( name"),$4,mm_strdup(")"));
11202 }
11203 |  XMLPI '(' NAME_P ColLabel ',' a_expr ')'
11204  {
11205  $$ = cat_str(5,mm_strdup("xmlpi ( name"),$4,mm_strdup(","),$6,mm_strdup(")"));
11206 }
11207 |  XMLROOT '(' a_expr ',' xml_root_version opt_xml_root_standalone ')'
11208  {
11209  $$ = cat_str(6,mm_strdup("xmlroot ("),$3,mm_strdup(","),$5,$6,mm_strdup(")"));
11210 }
11211 |  XMLSERIALIZE '(' document_or_content a_expr AS SimpleTypename ')'
11212  {
11213  $$ = cat_str(6,mm_strdup("xmlserialize ("),$3,$4,mm_strdup("as"),$6,mm_strdup(")"));
11214 }
11215 ;
11216 
11217 
11218  xml_root_version:
11219  VERSION_P a_expr
11220  {
11221  $$ = cat_str(2,mm_strdup("version"),$2);
11222 }
11223 |  VERSION_P NO VALUE_P
11224  {
11225  $$ = mm_strdup("version no value");
11226 }
11227 ;
11228 
11229 
11230  opt_xml_root_standalone:
11231  ',' STANDALONE_P YES_P
11232  {
11233  $$ = mm_strdup(", standalone yes");
11234 }
11235 |  ',' STANDALONE_P NO
11236  {
11237  $$ = mm_strdup(", standalone no");
11238 }
11239 |  ',' STANDALONE_P NO VALUE_P
11240  {
11241  $$ = mm_strdup(", standalone no value");
11242 }
11243 |
11244  {
11245  $$=EMPTY; }
11246 ;
11247 
11248 
11249  xml_attributes:
11250  XMLATTRIBUTES '(' xml_attribute_list ')'
11251  {
11252  $$ = cat_str(3,mm_strdup("xmlattributes ("),$3,mm_strdup(")"));
11253 }
11254 ;
11255 
11256 
11257  xml_attribute_list:
11258  xml_attribute_el
11259  {
11260  $$ = $1;
11261 }
11262 |  xml_attribute_list ',' xml_attribute_el
11263  {
11264  $$ = cat_str(3,$1,mm_strdup(","),$3);
11265 }
11266 ;
11267 
11268 
11269  xml_attribute_el:
11270  a_expr AS ColLabel
11271  {
11272  $$ = cat_str(3,$1,mm_strdup("as"),$3);
11273 }
11274 |  a_expr
11275  {
11276  $$ = $1;
11277 }
11278 ;
11279 
11280 
11281  document_or_content:
11282  DOCUMENT_P
11283  {
11284  $$ = mm_strdup("document");
11285 }
11286 |  CONTENT_P
11287  {
11288  $$ = mm_strdup("content");
11289 }
11290 ;
11291 
11292 
11293  xml_whitespace_option:
11294  PRESERVE WHITESPACE_P
11295  {
11296  $$ = mm_strdup("preserve whitespace");
11297 }
11298 |  STRIP_P WHITESPACE_P
11299  {
11300  $$ = mm_strdup("strip whitespace");
11301 }
11302 |
11303  {
11304  $$=EMPTY; }
11305 ;
11306 
11307 
11308  xmlexists_argument:
11309  PASSING c_expr
11310  {
11311  $$ = cat_str(2,mm_strdup("passing"),$2);
11312 }
11313 |  PASSING c_expr BY REF
11314  {
11315  $$ = cat_str(3,mm_strdup("passing"),$2,mm_strdup("by ref"));
11316 }
11317 |  PASSING BY REF c_expr
11318  {
11319  $$ = cat_str(2,mm_strdup("passing by ref"),$4);
11320 }
11321 |  PASSING BY REF c_expr BY REF
11322  {
11323  $$ = cat_str(3,mm_strdup("passing by ref"),$4,mm_strdup("by ref"));
11324 }
11325 ;
11326 
11327 
11328  within_group_clause:
11329  WITHIN GROUP_P '(' sort_clause ')'
11330  {
11331  $$ = cat_str(3,mm_strdup("within group ("),$4,mm_strdup(")"));
11332 }
11333 |
11334  {
11335  $$=EMPTY; }
11336 ;
11337 
11338 
11339  filter_clause:
11340  FILTER '(' WHERE a_expr ')'
11341  {
11342  $$ = cat_str(3,mm_strdup("filter ( where"),$4,mm_strdup(")"));
11343 }
11344 |
11345  {
11346  $$=EMPTY; }
11347 ;
11348 
11349 
11350  window_clause:
11351  WINDOW window_definition_list
11352  {
11353  $$ = cat_str(2,mm_strdup("window"),$2);
11354 }
11355 |
11356  {
11357  $$=EMPTY; }
11358 ;
11359 
11360 
11361  window_definition_list:
11362  window_definition
11363  {
11364  $$ = $1;
11365 }
11366 |  window_definition_list ',' window_definition
11367  {
11368  $$ = cat_str(3,$1,mm_strdup(","),$3);
11369 }
11370 ;
11371 
11372 
11373  window_definition:
11374  ColId AS window_specification
11375  {
11376  $$ = cat_str(3,$1,mm_strdup("as"),$3);
11377 }
11378 ;
11379 
11380 
11381  over_clause:
11382  OVER window_specification
11383  {
11384  $$ = cat_str(2,mm_strdup("over"),$2);
11385 }
11386 |  OVER ColId
11387  {
11388  $$ = cat_str(2,mm_strdup("over"),$2);
11389 }
11390 |
11391  {
11392  $$=EMPTY; }
11393 ;
11394 
11395 
11396  window_specification:
11397  '(' opt_existing_window_name opt_partition_clause opt_sort_clause opt_frame_clause ')'
11398  {
11399  $$ = cat_str(6,mm_strdup("("),$2,$3,$4,$5,mm_strdup(")"));
11400 }
11401 ;
11402 
11403 
11404  opt_existing_window_name:
11405  ColId
11406  {
11407  $$ = $1;
11408 }
11409 |  %prec Op
11410  {
11411  $$=EMPTY; }
11412 ;
11413 
11414 
11415  opt_partition_clause:
11416  PARTITION BY expr_list
11417  {
11418  $$ = cat_str(2,mm_strdup("partition by"),$3);
11419 }
11420 |
11421  {
11422  $$=EMPTY; }
11423 ;
11424 
11425 
11426  opt_frame_clause:
11427  RANGE frame_extent
11428  {
11429 mmerror(PARSE_ERROR, ET_WARNING, "unsupported feature will be passed to server");
11430  $$ = cat_str(2,mm_strdup("range"),$2);
11431 }
11432 |  ROWS frame_extent
11433  {
11434  $$ = cat_str(2,mm_strdup("rows"),$2);
11435 }
11436 |
11437  {
11438  $$=EMPTY; }
11439 ;
11440 
11441 
11442  frame_extent:
11443  frame_bound
11444  {
11445  $$ = $1;
11446 }
11447 |  BETWEEN frame_bound AND frame_bound
11448  {
11449  $$ = cat_str(4,mm_strdup("between"),$2,mm_strdup("and"),$4);
11450 }
11451 ;
11452 
11453 
11454  frame_bound:
11455  UNBOUNDED PRECEDING
11456  {
11457  $$ = mm_strdup("unbounded preceding");
11458 }
11459 |  UNBOUNDED FOLLOWING
11460  {
11461  $$ = mm_strdup("unbounded following");
11462 }
11463 |  CURRENT_P ROW
11464  {
11465  $$ = mm_strdup("current row");
11466 }
11467 |  a_expr PRECEDING
11468  {
11469  $$ = cat_str(2,$1,mm_strdup("preceding"));
11470 }
11471 |  a_expr FOLLOWING
11472  {
11473  $$ = cat_str(2,$1,mm_strdup("following"));
11474 }
11475 ;
11476 
11477 
11478  row:
11479  ROW '(' expr_list ')'
11480  {
11481  $$ = cat_str(3,mm_strdup("row ("),$3,mm_strdup(")"));
11482 }
11483 |  ROW '(' ')'
11484  {
11485  $$ = mm_strdup("row ( )");
11486 }
11487 |  '(' expr_list ',' a_expr ')'
11488  {
11489  $$ = cat_str(5,mm_strdup("("),$2,mm_strdup(","),$4,mm_strdup(")"));
11490 }
11491 ;
11492 
11493 
11494  explicit_row:
11495  ROW '(' expr_list ')'
11496  {
11497  $$ = cat_str(3,mm_strdup("row ("),$3,mm_strdup(")"));
11498 }
11499 |  ROW '(' ')'
11500  {
11501  $$ = mm_strdup("row ( )");
11502 }
11503 ;
11504 
11505 
11506  implicit_row:
11507  '(' expr_list ',' a_expr ')'
11508  {
11509  $$ = cat_str(5,mm_strdup("("),$2,mm_strdup(","),$4,mm_strdup(")"));
11510 }
11511 ;
11512 
11513 
11514  sub_type:
11515  ANY
11516  {
11517  $$ = mm_strdup("any");
11518 }
11519 |  SOME
11520  {
11521  $$ = mm_strdup("some");
11522 }
11523 |  ALL
11524  {
11525  $$ = mm_strdup("all");
11526 }
11527 ;
11528 
11529 
11530  all_Op:
11531  Op
11532  {
11533  $$ = $1;
11534 }
11535 |  MathOp
11536  {
11537  $$ = $1;
11538 }
11539 ;
11540 
11541 
11542  MathOp:
11543  '+'
11544  {
11545  $$ = mm_strdup("+");
11546 }
11547 |  '-'
11548  {
11549  $$ = mm_strdup("-");
11550 }
11551 |  '*'
11552  {
11553  $$ = mm_strdup("*");
11554 }
11555 |  '/'
11556  {
11557  $$ = mm_strdup("/");
11558 }
11559 |  '%'
11560  {
11561  $$ = mm_strdup("%");
11562 }
11563 |  '^'
11564  {
11565  $$ = mm_strdup("^");
11566 }
11567 |  '<'
11568  {
11569  $$ = mm_strdup("<");
11570 }
11571 |  '>'
11572  {
11573  $$ = mm_strdup(">");
11574 }
11575 |  '='
11576  {
11577  $$ = mm_strdup("=");
11578 }
11579 |  LESS_EQUALS
11580  {
11581  $$ = mm_strdup("<=");
11582 }
11583 |  GREATER_EQUALS
11584  {
11585  $$ = mm_strdup(">=");
11586 }
11587 |  NOT_EQUALS
11588  {
11589  $$ = mm_strdup("<>");
11590 }
11591 ;
11592 
11593 
11594  qual_Op:
11595  Op
11596  {
11597  $$ = $1;
11598 }
11599 |  OPERATOR '(' any_operator ')'
11600  {
11601  $$ = cat_str(3,mm_strdup("operator ("),$3,mm_strdup(")"));
11602 }
11603 ;
11604 
11605 
11606  qual_all_Op:
11607  all_Op
11608  {
11609  $$ = $1;
11610 }
11611 |  OPERATOR '(' any_operator ')'
11612  {
11613  $$ = cat_str(3,mm_strdup("operator ("),$3,mm_strdup(")"));
11614 }
11615 ;
11616 
11617 
11618  subquery_Op:
11619  all_Op
11620  {
11621  $$ = $1;
11622 }
11623 |  OPERATOR '(' any_operator ')'
11624  {
11625  $$ = cat_str(3,mm_strdup("operator ("),$3,mm_strdup(")"));
11626 }
11627 |  LIKE
11628  {
11629  $$ = mm_strdup("like");
11630 }
11631 |  NOT_LA LIKE
11632  {
11633  $$ = mm_strdup("not like");
11634 }
11635 |  ILIKE
11636  {
11637  $$ = mm_strdup("ilike");
11638 }
11639 |  NOT_LA ILIKE
11640  {
11641  $$ = mm_strdup("not ilike");
11642 }
11643 ;
11644 
11645 
11646  expr_list:
11647  a_expr
11648  {
11649  $$ = $1;
11650 }
11651 |  expr_list ',' a_expr
11652  {
11653  $$ = cat_str(3,$1,mm_strdup(","),$3);
11654 }
11655 ;
11656 
11657 
11658  func_arg_list:
11659  func_arg_expr
11660  {
11661  $$ = $1;
11662 }
11663 |  func_arg_list ',' func_arg_expr
11664  {
11665  $$ = cat_str(3,$1,mm_strdup(","),$3);
11666 }
11667 ;
11668 
11669 
11670  func_arg_expr:
11671  a_expr
11672  {
11673  $$ = $1;
11674 }
11675 |  param_name COLON_EQUALS a_expr
11676  {
11677  $$ = cat_str(3,$1,mm_strdup(":="),$3);
11678 }
11679 |  param_name EQUALS_GREATER a_expr
11680  {
11681  $$ = cat_str(3,$1,mm_strdup("=>"),$3);
11682 }
11683 ;
11684 
11685 
11686  type_list:
11687  Typename
11688  {
11689  $$ = $1;
11690 }
11691 |  type_list ',' Typename
11692  {
11693  $$ = cat_str(3,$1,mm_strdup(","),$3);
11694 }
11695 ;
11696 
11697 
11698  array_expr:
11699  '[' expr_list ']'
11700  {
11701  $$ = cat_str(3,mm_strdup("["),$2,mm_strdup("]"));
11702 }
11703 |  '[' array_expr_list ']'
11704  {
11705  $$ = cat_str(3,mm_strdup("["),$2,mm_strdup("]"));
11706 }
11707 |  '[' ']'
11708  {
11709  $$ = mm_strdup("[ ]");
11710 }
11711 ;
11712 
11713 
11714  array_expr_list:
11715  array_expr
11716  {
11717  $$ = $1;
11718 }
11719 |  array_expr_list ',' array_expr
11720  {
11721  $$ = cat_str(3,$1,mm_strdup(","),$3);
11722 }
11723 ;
11724 
11725 
11726  extract_list:
11727  extract_arg FROM a_expr
11728  {
11729  $$ = cat_str(3,$1,mm_strdup("from"),$3);
11730 }
11731 |
11732  {
11733  $$=EMPTY; }
11734 ;
11735 
11736 
11737  extract_arg:
11738  ecpg_ident
11739  {
11740  $$ = $1;
11741 }
11742 |  YEAR_P
11743  {
11744  $$ = mm_strdup("year");
11745 }
11746 |  MONTH_P
11747  {
11748  $$ = mm_strdup("month");
11749 }
11750 |  DAY_P
11751  {
11752  $$ = mm_strdup("day");
11753 }
11754 |  HOUR_P
11755  {
11756  $$ = mm_strdup("hour");
11757 }
11758 |  MINUTE_P
11759  {
11760  $$ = mm_strdup("minute");
11761 }
11762 |  SECOND_P
11763  {
11764  $$ = mm_strdup("second");
11765 }
11766 |  ecpg_sconst
11767  {
11768  $$ = $1;
11769 }
11770 ;
11771 
11772 
11773  overlay_list:
11774  a_expr overlay_placing substr_from substr_for
11775  {
11776  $$ = cat_str(4,$1,$2,$3,$4);
11777 }
11778 |  a_expr overlay_placing substr_from
11779  {
11780  $$ = cat_str(3,$1,$2,$3);
11781 }
11782 ;
11783 
11784 
11785  overlay_placing:
11786  PLACING a_expr
11787  {
11788  $$ = cat_str(2,mm_strdup("placing"),$2);
11789 }
11790 ;
11791 
11792 
11793  position_list:
11794  b_expr IN_P b_expr
11795  {
11796  $$ = cat_str(3,$1,mm_strdup("in"),$3);
11797 }
11798 |
11799  {
11800  $$=EMPTY; }
11801 ;
11802 
11803 
11804  substr_list:
11805  a_expr substr_from substr_for
11806  {
11807  $$ = cat_str(3,$1,$2,$3);
11808 }
11809 |  a_expr substr_for substr_from
11810  {
11811  $$ = cat_str(3,$1,$2,$3);
11812 }
11813 |  a_expr substr_from
11814  {
11815  $$ = cat_str(2,$1,$2);
11816 }
11817 |  a_expr substr_for
11818  {
11819  $$ = cat_str(2,$1,$2);
11820 }
11821 |  expr_list
11822  {
11823  $$ = $1;
11824 }
11825 |
11826  {
11827  $$=EMPTY; }
11828 ;
11829 
11830 
11831  substr_from:
11832  FROM a_expr
11833  {
11834  $$ = cat_str(2,mm_strdup("from"),$2);
11835 }
11836 ;
11837 
11838 
11839  substr_for:
11840  FOR a_expr
11841  {
11842  $$ = cat_str(2,mm_strdup("for"),$2);
11843 }
11844 ;
11845 
11846 
11847  trim_list:
11848  a_expr FROM expr_list
11849  {
11850  $$ = cat_str(3,$1,mm_strdup("from"),$3);
11851 }
11852 |  FROM expr_list
11853  {
11854  $$ = cat_str(2,mm_strdup("from"),$2);
11855 }
11856 |  expr_list
11857  {
11858  $$ = $1;
11859 }
11860 ;
11861 
11862 
11863  in_expr:
11864  select_with_parens
11865  {
11866  $$ = $1;
11867 }
11868 |  '(' expr_list ')'
11869  {
11870  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
11871 }
11872 ;
11873 
11874 
11875  case_expr:
11876  CASE case_arg when_clause_list case_default END_P
11877  {
11878  $$ = cat_str(5,mm_strdup("case"),$2,$3,$4,mm_strdup("end"));
11879 }
11880 ;
11881 
11882 
11883  when_clause_list:
11884  when_clause
11885  {
11886  $$ = $1;
11887 }
11888 |  when_clause_list when_clause
11889  {
11890  $$ = cat_str(2,$1,$2);
11891 }
11892 ;
11893 
11894 
11895  when_clause:
11896  WHEN a_expr THEN a_expr
11897  {
11898  $$ = cat_str(4,mm_strdup("when"),$2,mm_strdup("then"),$4);
11899 }
11900 ;
11901 
11902 
11903  case_default:
11904  ELSE a_expr
11905  {
11906  $$ = cat_str(2,mm_strdup("else"),$2);
11907 }
11908 |
11909  {
11910  $$=EMPTY; }
11911 ;
11912 
11913 
11914  case_arg:
11915  a_expr
11916  {
11917  $$ = $1;
11918 }
11919 |
11920  {
11921  $$=EMPTY; }
11922 ;
11923 
11924 
11925  columnref:
11926  ColId
11927  {
11928  $$ = $1;
11929 }
11930 |  ColId indirection
11931  {
11932  $$ = cat_str(2,$1,$2);
11933 }
11934 ;
11935 
11936 
11937  indirection_el:
11938  '.' attr_name
11939  {
11940  $$ = cat_str(2,mm_strdup("."),$2);
11941 }
11942 |  '.' '*'
11943  {
11944  $$ = mm_strdup(". *");
11945 }
11946 |  '[' a_expr ']'
11947  {
11948  $$ = cat_str(3,mm_strdup("["),$2,mm_strdup("]"));
11949 }
11950 |  '[' opt_slice_bound ':' opt_slice_bound ']'
11951  {
11952  $$ = cat_str(5,mm_strdup("["),$2,mm_strdup(":"),$4,mm_strdup("]"));
11953 }
11954 ;
11955 
11956 
11957  opt_slice_bound:
11958  a_expr
11959  {
11960  $$ = $1;
11961 }
11962 |
11963  {
11964  $$=EMPTY; }
11965 ;
11966 
11967 
11968  indirection:
11969  indirection_el
11970  {
11971  $$ = $1;
11972 }
11973 |  indirection indirection_el
11974  {
11975  $$ = cat_str(2,$1,$2);
11976 }
11977 ;
11978 
11979 
11980  opt_indirection:
11981 
11982  {
11983  $$=EMPTY; }
11984 |  opt_indirection indirection_el
11985  {
11986  $$ = cat_str(2,$1,$2);
11987 }
11988 ;
11989 
11990 
11991  opt_asymmetric:
11992  ASYMMETRIC
11993  {
11994  $$ = mm_strdup("asymmetric");
11995 }
11996 |
11997  {
11998  $$=EMPTY; }
11999 ;
12000 
12001 
12002  ctext_expr:
12003  a_expr
12004  {
12005  $$ = $1;
12006 }
12007 |  DEFAULT
12008  {
12009  $$ = mm_strdup("default");
12010 }
12011 ;
12012 
12013 
12014  ctext_expr_list:
12015  ctext_expr
12016  {
12017  $$ = $1;
12018 }
12019 |  ctext_expr_list ',' ctext_expr
12020  {
12021  $$ = cat_str(3,$1,mm_strdup(","),$3);
12022 }
12023 ;
12024 
12025 
12026  ctext_row:
12027  '(' ctext_expr_list ')'
12028  {
12029  $$ = cat_str(3,mm_strdup("("),$2,mm_strdup(")"));
12030 }
12031 ;
12032 
12033 
12034  opt_target_list:
12035  target_list
12036  {
12037  $$ = $1;
12038 }
12039 |
12040  {
12041  $$=EMPTY; }
12042 ;
12043 
12044 
12045  target_list:
12046  target_el
12047  {
12048  $$ = $1;
12049 }
12050 |  target_list ',' target_el
12051  {
12052  $$ = cat_str(3,$1,mm_strdup(","),$3);
12053 }
12054 ;
12055 
12056 
12057  target_el:
12058  a_expr AS ColLabel
12059  {
12060  $$ = cat_str(3,$1,mm_strdup("as"),$3);
12061 }
12062 |  a_expr ecpg_ident
12063  {
12064  $$ = cat_str(2,$1,$2);
12065 }
12066 |  a_expr
12067  {
12068  $$ = $1;
12069 }
12070 |  '*'
12071  {
12072  $$ = mm_strdup("*");
12073 }
12074 ;
12075 
12076 
12077  qualified_name_list:
12078  qualified_name
12079  {
12080  $$ = $1;
12081 }
12082 |  qualified_name_list ',' qualified_name
12083  {
12084  $$ = cat_str(3,$1,mm_strdup(","),$3);
12085 }
12086 ;
12087 
12088 
12089  qualified_name:
12090  ColId
12091  {
12092  $$ = $1;
12093 }
12094 |  ColId indirection
12095  {
12096  $$ = cat_str(2,$1,$2);
12097 }
12098 ;
12099 
12100 
12101  name_list:
12102  name
12103  {
12104  $$ = $1;
12105 }
12106 |  name_list ',' name
12107  {
12108  $$ = cat_str(3,$1,mm_strdup(","),$3);
12109 }
12110 ;
12111 
12112 
12113  name:
12114  ColId
12115  {
12116  $$ = $1;
12117 }
12118 ;
12119 
12120 
12121  database_name:
12122  ColId
12123  {
12124  $$ = $1;
12125 }
12126 ;
12127 
12128 
12129  access_method:
12130  ColId
12131  {
12132  $$ = $1;
12133 }
12134 ;
12135 
12136 
12137  attr_name:
12138  ColLabel
12139  {
12140  $$ = $1;
12141 }
12142 ;
12143 
12144 
12145  index_name:
12146  ColId
12147  {
12148  $$ = $1;
12149 }
12150 ;
12151 
12152 
12153  file_name:
12154  ecpg_sconst
12155  {
12156  $$ = $1;
12157 }
12158 ;
12159 
12160 
12161  func_name:
12162  type_function_name
12163  {
12164  $$ = $1;
12165 }
12166 |  ColId indirection
12167  {
12168  $$ = cat_str(2,$1,$2);
12169 }
12170 ;
12171 
12172 
12173  AexprConst:
12174  Iconst
12175  {
12176  $$ = $1;
12177 }
12178 |  ecpg_fconst
12179  {
12180  $$ = $1;
12181 }
12182 |  ecpg_sconst
12183  {
12184  $$ = $1;
12185 }
12186 |  ecpg_bconst
12187  {
12188  $$ = $1;
12189 }
12190 |  XCONST
12191  {
12192  $$ = mm_strdup("xconst");
12193 }
12194 |  func_name ecpg_sconst
12195  {
12196  $$ = cat_str(2,$1,$2);
12197 }
12198 |  func_name '(' func_arg_list opt_sort_clause ')' ecpg_sconst
12199  {
12200  $$ = cat_str(6,$1,mm_strdup("("),$3,$4,mm_strdup(")"),$6);
12201 }
12202 |  ConstTypename ecpg_sconst
12203  {
12204  $$ = cat_str(2,$1,$2);
12205 }
12206 |  ConstInterval ecpg_sconst opt_interval
12207  {
12208  $$ = cat_str(3,$1,$2,$3);
12209 }
12210 |  ConstInterval '(' Iconst ')' ecpg_sconst
12211  {
12212  $$ = cat_str(5,$1,mm_strdup("("),$3,mm_strdup(")"),$5);
12213 }
12214 |  TRUE_P
12215  {
12216  $$ = mm_strdup("true");
12217 }
12218 |  FALSE_P
12219  {
12220  $$ = mm_strdup("false");
12221 }
12222 |  NULL_P
12223  {
12224  $$ = mm_strdup("null");
12225 }
12226 	| civar			{ $$ = $1; }
12227 	| civarind		{ $$ = $1; }
12228 ;
12229 
12230 
12231  Iconst:
12232  ICONST
12233 	{ $$ = make_name(); }
12234 ;
12235 
12236 
12237  SignedIconst:
12238  Iconst
12239  {
12240  $$ = $1;
12241 }
12242 	| civar	{ $$ = $1; }
12243 |  '+' Iconst
12244  {
12245  $$ = cat_str(2,mm_strdup("+"),$2);
12246 }
12247 |  '-' Iconst
12248  {
12249  $$ = cat_str(2,mm_strdup("-"),$2);
12250 }
12251 ;
12252 
12253 
12254  RoleId:
12255  RoleSpec
12256  {
12257  $$ = $1;
12258 }
12259 ;
12260 
12261 
12262  RoleSpec:
12263  NonReservedWord
12264  {
12265  $$ = $1;
12266 }
12267 |  CURRENT_USER
12268  {
12269  $$ = mm_strdup("current_user");
12270 }
12271 |  SESSION_USER
12272  {
12273  $$ = mm_strdup("session_user");
12274 }
12275 ;
12276 
12277 
12278  role_list:
12279  RoleSpec
12280  {
12281  $$ = $1;
12282 }
12283 |  role_list ',' RoleSpec
12284  {
12285  $$ = cat_str(3,$1,mm_strdup(","),$3);
12286 }
12287 ;
12288 
12289 
12290  NonReservedWord:
12291  ecpg_ident
12292  {
12293  $$ = $1;
12294 }
12295 |  unreserved_keyword
12296  {
12297  $$ = $1;
12298 }
12299 |  col_name_keyword
12300  {
12301  $$ = $1;
12302 }
12303 |  type_func_name_keyword
12304  {
12305  $$ = $1;
12306 }
12307 ;
12308 
12309 
12310  unreserved_keyword:
12311  ABORT_P
12312  {
12313  $$ = mm_strdup("abort");
12314 }
12315 |  ABSOLUTE_P
12316  {
12317  $$ = mm_strdup("absolute");
12318 }
12319 |  ACCESS
12320  {
12321  $$ = mm_strdup("access");
12322 }
12323 |  ACTION
12324  {
12325  $$ = mm_strdup("action");
12326 }
12327 |  ADD_P
12328  {
12329  $$ = mm_strdup("add");
12330 }
12331 |  ADMIN
12332  {
12333  $$ = mm_strdup("admin");
12334 }
12335 |  AFTER
12336  {
12337  $$ = mm_strdup("after");
12338 }
12339 |  AGGREGATE
12340  {
12341  $$ = mm_strdup("aggregate");
12342 }
12343 |  ALSO
12344  {
12345  $$ = mm_strdup("also");
12346 }
12347 |  ALTER
12348  {
12349  $$ = mm_strdup("alter");
12350 }
12351 |  ALWAYS
12352  {
12353  $$ = mm_strdup("always");
12354 }
12355 |  ASSERTION
12356  {
12357  $$ = mm_strdup("assertion");
12358 }
12359 |  ASSIGNMENT
12360  {
12361  $$ = mm_strdup("assignment");
12362 }
12363 |  AT
12364  {
12365  $$ = mm_strdup("at");
12366 }
12367 |  ATTRIBUTE
12368  {
12369  $$ = mm_strdup("attribute");
12370 }
12371 |  BACKWARD
12372  {
12373  $$ = mm_strdup("backward");
12374 }
12375 |  BEFORE
12376  {
12377  $$ = mm_strdup("before");
12378 }
12379 |  BEGIN_P
12380  {
12381  $$ = mm_strdup("begin");
12382 }
12383 |  BY
12384  {
12385  $$ = mm_strdup("by");
12386 }
12387 |  CACHE
12388  {
12389  $$ = mm_strdup("cache");
12390 }
12391 |  CALLED
12392  {
12393  $$ = mm_strdup("called");
12394 }
12395 |  CASCADE
12396  {
12397  $$ = mm_strdup("cascade");
12398 }
12399 |  CASCADED
12400  {
12401  $$ = mm_strdup("cascaded");
12402 }
12403 |  CATALOG_P
12404  {
12405  $$ = mm_strdup("catalog");
12406 }
12407 |  CHAIN
12408  {
12409  $$ = mm_strdup("chain");
12410 }
12411 |  CHARACTERISTICS
12412  {
12413  $$ = mm_strdup("characteristics");
12414 }
12415 |  CHECKPOINT
12416  {
12417  $$ = mm_strdup("checkpoint");
12418 }
12419 |  CLASS
12420  {
12421  $$ = mm_strdup("class");
12422 }
12423 |  CLOSE
12424  {
12425  $$ = mm_strdup("close");
12426 }
12427 |  CLUSTER
12428  {
12429  $$ = mm_strdup("cluster");
12430 }
12431 |  COMMENT
12432  {
12433  $$ = mm_strdup("comment");
12434 }
12435 |  COMMENTS
12436  {
12437  $$ = mm_strdup("comments");
12438 }
12439 |  COMMIT
12440  {
12441  $$ = mm_strdup("commit");
12442 }
12443 |  COMMITTED
12444  {
12445  $$ = mm_strdup("committed");
12446 }
12447 |  CONFIGURATION
12448  {
12449  $$ = mm_strdup("configuration");
12450 }
12451 |  CONFLICT
12452  {
12453  $$ = mm_strdup("conflict");
12454 }
12455 |  CONSTRAINTS
12456  {
12457  $$ = mm_strdup("constraints");
12458 }
12459 |  CONTENT_P
12460  {
12461  $$ = mm_strdup("content");
12462 }
12463 |  CONTINUE_P
12464  {
12465  $$ = mm_strdup("continue");
12466 }
12467 |  CONVERSION_P
12468  {
12469  $$ = mm_strdup("conversion");
12470 }
12471 |  COPY
12472  {
12473  $$ = mm_strdup("copy");
12474 }
12475 |  COST
12476  {
12477  $$ = mm_strdup("cost");
12478 }
12479 |  CSV
12480  {
12481  $$ = mm_strdup("csv");
12482 }
12483 |  CUBE
12484  {
12485  $$ = mm_strdup("cube");
12486 }
12487 |  CURSOR
12488  {
12489  $$ = mm_strdup("cursor");
12490 }
12491 |  CYCLE
12492  {
12493  $$ = mm_strdup("cycle");
12494 }
12495 |  DATA_P
12496  {
12497  $$ = mm_strdup("data");
12498 }
12499 |  DATABASE
12500  {
12501  $$ = mm_strdup("database");
12502 }
12503 |  DEALLOCATE
12504  {
12505  $$ = mm_strdup("deallocate");
12506 }
12507 |  DECLARE
12508  {
12509  $$ = mm_strdup("declare");
12510 }
12511 |  DEFAULTS
12512  {
12513  $$ = mm_strdup("defaults");
12514 }
12515 |  DEFERRED
12516  {
12517  $$ = mm_strdup("deferred");
12518 }
12519 |  DEFINER
12520  {
12521  $$ = mm_strdup("definer");
12522 }
12523 |  DELETE_P
12524  {
12525  $$ = mm_strdup("delete");
12526 }
12527 |  DELIMITER
12528  {
12529  $$ = mm_strdup("delimiter");
12530 }
12531 |  DELIMITERS
12532  {
12533  $$ = mm_strdup("delimiters");
12534 }
12535 |  DEPENDS
12536  {
12537  $$ = mm_strdup("depends");
12538 }
12539 |  DICTIONARY
12540  {
12541  $$ = mm_strdup("dictionary");
12542 }
12543 |  DISABLE_P
12544  {
12545  $$ = mm_strdup("disable");
12546 }
12547 |  DISCARD
12548  {
12549  $$ = mm_strdup("discard");
12550 }
12551 |  DOCUMENT_P
12552  {
12553  $$ = mm_strdup("document");
12554 }
12555 |  DOMAIN_P
12556  {
12557  $$ = mm_strdup("domain");
12558 }
12559 |  DOUBLE_P
12560  {
12561  $$ = mm_strdup("double");
12562 }
12563 |  DROP
12564  {
12565  $$ = mm_strdup("drop");
12566 }
12567 |  EACH
12568  {
12569  $$ = mm_strdup("each");
12570 }
12571 |  ENABLE_P
12572  {
12573  $$ = mm_strdup("enable");
12574 }
12575 |  ENCODING
12576  {
12577  $$ = mm_strdup("encoding");
12578 }
12579 |  ENCRYPTED
12580  {
12581  $$ = mm_strdup("encrypted");
12582 }
12583 |  ENUM_P
12584  {
12585  $$ = mm_strdup("enum");
12586 }
12587 |  ESCAPE
12588  {
12589  $$ = mm_strdup("escape");
12590 }
12591 |  EVENT
12592  {
12593  $$ = mm_strdup("event");
12594 }
12595 |  EXCLUDE
12596  {
12597  $$ = mm_strdup("exclude");
12598 }
12599 |  EXCLUDING
12600  {
12601  $$ = mm_strdup("excluding");
12602 }
12603 |  EXCLUSIVE
12604  {
12605  $$ = mm_strdup("exclusive");
12606 }
12607 |  EXECUTE
12608  {
12609  $$ = mm_strdup("execute");
12610 }
12611 |  EXPLAIN
12612  {
12613  $$ = mm_strdup("explain");
12614 }
12615 |  EXTENSION
12616  {
12617  $$ = mm_strdup("extension");
12618 }
12619 |  EXTERNAL
12620  {
12621  $$ = mm_strdup("external");
12622 }
12623 |  FAMILY
12624  {
12625  $$ = mm_strdup("family");
12626 }
12627 |  FILTER
12628  {
12629  $$ = mm_strdup("filter");
12630 }
12631 |  FIRST_P
12632  {
12633  $$ = mm_strdup("first");
12634 }
12635 |  FOLLOWING
12636  {
12637  $$ = mm_strdup("following");
12638 }
12639 |  FORCE
12640  {
12641  $$ = mm_strdup("force");
12642 }
12643 |  FORWARD
12644  {
12645  $$ = mm_strdup("forward");
12646 }
12647 |  FUNCTION
12648  {
12649  $$ = mm_strdup("function");
12650 }
12651 |  FUNCTIONS
12652  {
12653  $$ = mm_strdup("functions");
12654 }
12655 |  GLOBAL
12656  {
12657  $$ = mm_strdup("global");
12658 }
12659 |  GRANTED
12660  {
12661  $$ = mm_strdup("granted");
12662 }
12663 |  HANDLER
12664  {
12665  $$ = mm_strdup("handler");
12666 }
12667 |  HEADER_P
12668  {
12669  $$ = mm_strdup("header");
12670 }
12671 |  HOLD
12672  {
12673  $$ = mm_strdup("hold");
12674 }
12675 |  IDENTITY_P
12676  {
12677  $$ = mm_strdup("identity");
12678 }
12679 |  IF_P
12680  {
12681  $$ = mm_strdup("if");
12682 }
12683 |  IMMEDIATE
12684  {
12685  $$ = mm_strdup("immediate");
12686 }
12687 |  IMMUTABLE
12688  {
12689  $$ = mm_strdup("immutable");
12690 }
12691 |  IMPLICIT_P
12692  {
12693  $$ = mm_strdup("implicit");
12694 }
12695 |  IMPORT_P
12696  {
12697  $$ = mm_strdup("import");
12698 }
12699 |  INCLUDING
12700  {
12701  $$ = mm_strdup("including");
12702 }
12703 |  INCREMENT
12704  {
12705  $$ = mm_strdup("increment");
12706 }
12707 |  INDEX
12708  {
12709  $$ = mm_strdup("index");
12710 }
12711 |  INDEXES
12712  {
12713  $$ = mm_strdup("indexes");
12714 }
12715 |  INHERIT
12716  {
12717  $$ = mm_strdup("inherit");
12718 }
12719 |  INHERITS
12720  {
12721  $$ = mm_strdup("inherits");
12722 }
12723 |  INLINE_P
12724  {
12725  $$ = mm_strdup("inline");
12726 }
12727 |  INSENSITIVE
12728  {
12729  $$ = mm_strdup("insensitive");
12730 }
12731 |  INSERT
12732  {
12733  $$ = mm_strdup("insert");
12734 }
12735 |  INSTEAD
12736  {
12737  $$ = mm_strdup("instead");
12738 }
12739 |  INVOKER
12740  {
12741  $$ = mm_strdup("invoker");
12742 }
12743 |  ISOLATION
12744  {
12745  $$ = mm_strdup("isolation");
12746 }
12747 |  KEY
12748  {
12749  $$ = mm_strdup("key");
12750 }
12751 |  LABEL
12752  {
12753  $$ = mm_strdup("label");
12754 }
12755 |  LANGUAGE
12756  {
12757  $$ = mm_strdup("language");
12758 }
12759 |  LARGE_P
12760  {
12761  $$ = mm_strdup("large");
12762 }
12763 |  LAST_P
12764  {
12765  $$ = mm_strdup("last");
12766 }
12767 |  LEAKPROOF
12768  {
12769  $$ = mm_strdup("leakproof");
12770 }
12771 |  LEVEL
12772  {
12773  $$ = mm_strdup("level");
12774 }
12775 |  LISTEN
12776  {
12777  $$ = mm_strdup("listen");
12778 }
12779 |  LOAD
12780  {
12781  $$ = mm_strdup("load");
12782 }
12783 |  LOCAL
12784  {
12785  $$ = mm_strdup("local");
12786 }
12787 |  LOCATION
12788  {
12789  $$ = mm_strdup("location");
12790 }
12791 |  LOCK_P
12792  {
12793  $$ = mm_strdup("lock");
12794 }
12795 |  LOCKED
12796  {
12797  $$ = mm_strdup("locked");
12798 }
12799 |  LOGGED
12800  {
12801  $$ = mm_strdup("logged");
12802 }
12803 |  MAPPING
12804  {
12805  $$ = mm_strdup("mapping");
12806 }
12807 |  MATCH
12808  {
12809  $$ = mm_strdup("match");
12810 }
12811 |  MATERIALIZED
12812  {
12813  $$ = mm_strdup("materialized");
12814 }
12815 |  MAXVALUE
12816  {
12817  $$ = mm_strdup("maxvalue");
12818 }
12819 |  METHOD
12820  {
12821  $$ = mm_strdup("method");
12822 }
12823 |  MINVALUE
12824  {
12825  $$ = mm_strdup("minvalue");
12826 }
12827 |  MODE
12828  {
12829  $$ = mm_strdup("mode");
12830 }
12831 |  MOVE
12832  {
12833  $$ = mm_strdup("move");
12834 }
12835 |  NAME_P
12836  {
12837  $$ = mm_strdup("name");
12838 }
12839 |  NAMES
12840  {
12841  $$ = mm_strdup("names");
12842 }
12843 |  NEXT
12844  {
12845  $$ = mm_strdup("next");
12846 }
12847 |  NO
12848  {
12849  $$ = mm_strdup("no");
12850 }
12851 |  NOTHING
12852  {
12853  $$ = mm_strdup("nothing");
12854 }
12855 |  NOTIFY
12856  {
12857  $$ = mm_strdup("notify");
12858 }
12859 |  NOWAIT
12860  {
12861  $$ = mm_strdup("nowait");
12862 }
12863 |  NULLS_P
12864  {
12865  $$ = mm_strdup("nulls");
12866 }
12867 |  OBJECT_P
12868  {
12869  $$ = mm_strdup("object");
12870 }
12871 |  OF
12872  {
12873  $$ = mm_strdup("of");
12874 }
12875 |  OFF
12876  {
12877  $$ = mm_strdup("off");
12878 }
12879 |  OIDS
12880  {
12881  $$ = mm_strdup("oids");
12882 }
12883 |  OPERATOR
12884  {
12885  $$ = mm_strdup("operator");
12886 }
12887 |  OPTION
12888  {
12889  $$ = mm_strdup("option");
12890 }
12891 |  OPTIONS
12892  {
12893  $$ = mm_strdup("options");
12894 }
12895 |  ORDINALITY
12896  {
12897  $$ = mm_strdup("ordinality");
12898 }
12899 |  OVER
12900  {
12901  $$ = mm_strdup("over");
12902 }
12903 |  OWNED
12904  {
12905  $$ = mm_strdup("owned");
12906 }
12907 |  OWNER
12908  {
12909  $$ = mm_strdup("owner");
12910 }
12911 |  PARALLEL
12912  {
12913  $$ = mm_strdup("parallel");
12914 }
12915 |  PARSER
12916  {
12917  $$ = mm_strdup("parser");
12918 }
12919 |  PARTIAL
12920  {
12921  $$ = mm_strdup("partial");
12922 }
12923 |  PARTITION
12924  {
12925  $$ = mm_strdup("partition");
12926 }
12927 |  PASSING
12928  {
12929  $$ = mm_strdup("passing");
12930 }
12931 |  PASSWORD
12932  {
12933  $$ = mm_strdup("password");
12934 }
12935 |  PLANS
12936  {
12937  $$ = mm_strdup("plans");
12938 }
12939 |  POLICY
12940  {
12941  $$ = mm_strdup("policy");
12942 }
12943 |  PRECEDING
12944  {
12945  $$ = mm_strdup("preceding");
12946 }
12947 |  PREPARE
12948  {
12949  $$ = mm_strdup("prepare");
12950 }
12951 |  PREPARED
12952  {
12953  $$ = mm_strdup("prepared");
12954 }
12955 |  PRESERVE
12956  {
12957  $$ = mm_strdup("preserve");
12958 }
12959 |  PRIOR
12960  {
12961  $$ = mm_strdup("prior");
12962 }
12963 |  PRIVILEGES
12964  {
12965  $$ = mm_strdup("privileges");
12966 }
12967 |  PROCEDURAL
12968  {
12969  $$ = mm_strdup("procedural");
12970 }
12971 |  PROCEDURE
12972  {
12973  $$ = mm_strdup("procedure");
12974 }
12975 |  PROGRAM
12976  {
12977  $$ = mm_strdup("program");
12978 }
12979 |  QUOTE
12980  {
12981  $$ = mm_strdup("quote");
12982 }
12983 |  RANGE
12984  {
12985  $$ = mm_strdup("range");
12986 }
12987 |  READ
12988  {
12989  $$ = mm_strdup("read");
12990 }
12991 |  REASSIGN
12992  {
12993  $$ = mm_strdup("reassign");
12994 }
12995 |  RECHECK
12996  {
12997  $$ = mm_strdup("recheck");
12998 }
12999 |  RECURSIVE
13000  {
13001  $$ = mm_strdup("recursive");
13002 }
13003 |  REF
13004  {
13005  $$ = mm_strdup("ref");
13006 }
13007 |  REFRESH
13008  {
13009  $$ = mm_strdup("refresh");
13010 }
13011 |  REINDEX
13012  {
13013  $$ = mm_strdup("reindex");
13014 }
13015 |  RELATIVE_P
13016  {
13017  $$ = mm_strdup("relative");
13018 }
13019 |  RELEASE
13020  {
13021  $$ = mm_strdup("release");
13022 }
13023 |  RENAME
13024  {
13025  $$ = mm_strdup("rename");
13026 }
13027 |  REPEATABLE
13028  {
13029  $$ = mm_strdup("repeatable");
13030 }
13031 |  REPLACE
13032  {
13033  $$ = mm_strdup("replace");
13034 }
13035 |  REPLICA
13036  {
13037  $$ = mm_strdup("replica");
13038 }
13039 |  RESET
13040  {
13041  $$ = mm_strdup("reset");
13042 }
13043 |  RESTART
13044  {
13045  $$ = mm_strdup("restart");
13046 }
13047 |  RESTRICT
13048  {
13049  $$ = mm_strdup("restrict");
13050 }
13051 |  RETURNS
13052  {
13053  $$ = mm_strdup("returns");
13054 }
13055 |  REVOKE
13056  {
13057  $$ = mm_strdup("revoke");
13058 }
13059 |  ROLE
13060  {
13061  $$ = mm_strdup("role");
13062 }
13063 |  ROLLBACK
13064  {
13065  $$ = mm_strdup("rollback");
13066 }
13067 |  ROLLUP
13068  {
13069  $$ = mm_strdup("rollup");
13070 }
13071 |  ROWS
13072  {
13073  $$ = mm_strdup("rows");
13074 }
13075 |  RULE
13076  {
13077  $$ = mm_strdup("rule");
13078 }
13079 |  SAVEPOINT
13080  {
13081  $$ = mm_strdup("savepoint");
13082 }
13083 |  SCHEMA
13084  {
13085  $$ = mm_strdup("schema");
13086 }
13087 |  SCROLL
13088  {
13089  $$ = mm_strdup("scroll");
13090 }
13091 |  SEARCH
13092  {
13093  $$ = mm_strdup("search");
13094 }
13095 |  SECURITY
13096  {
13097  $$ = mm_strdup("security");
13098 }
13099 |  SEQUENCE
13100  {
13101  $$ = mm_strdup("sequence");
13102 }
13103 |  SEQUENCES
13104  {
13105  $$ = mm_strdup("sequences");
13106 }
13107 |  SERIALIZABLE
13108  {
13109  $$ = mm_strdup("serializable");
13110 }
13111 |  SERVER
13112  {
13113  $$ = mm_strdup("server");
13114 }
13115 |  SESSION
13116  {
13117  $$ = mm_strdup("session");
13118 }
13119 |  SET
13120  {
13121  $$ = mm_strdup("set");
13122 }
13123 |  SETS
13124  {
13125  $$ = mm_strdup("sets");
13126 }
13127 |  SHARE
13128  {
13129  $$ = mm_strdup("share");
13130 }
13131 |  SHOW
13132  {
13133  $$ = mm_strdup("show");
13134 }
13135 |  SIMPLE
13136  {
13137  $$ = mm_strdup("simple");
13138 }
13139 |  SKIP
13140  {
13141  $$ = mm_strdup("skip");
13142 }
13143 |  SNAPSHOT
13144  {
13145  $$ = mm_strdup("snapshot");
13146 }
13147 |  SQL_P
13148  {
13149  $$ = mm_strdup("sql");
13150 }
13151 |  STABLE
13152  {
13153  $$ = mm_strdup("stable");
13154 }
13155 |  STANDALONE_P
13156  {
13157  $$ = mm_strdup("standalone");
13158 }
13159 |  START
13160  {
13161  $$ = mm_strdup("start");
13162 }
13163 |  STATEMENT
13164  {
13165  $$ = mm_strdup("statement");
13166 }
13167 |  STATISTICS
13168  {
13169  $$ = mm_strdup("statistics");
13170 }
13171 |  STDIN
13172  {
13173  $$ = mm_strdup("stdin");
13174 }
13175 |  STDOUT
13176  {
13177  $$ = mm_strdup("stdout");
13178 }
13179 |  STORAGE
13180  {
13181  $$ = mm_strdup("storage");
13182 }
13183 |  STRICT_P
13184  {
13185  $$ = mm_strdup("strict");
13186 }
13187 |  STRIP_P
13188  {
13189  $$ = mm_strdup("strip");
13190 }
13191 |  SYSID
13192  {
13193  $$ = mm_strdup("sysid");
13194 }
13195 |  SYSTEM_P
13196  {
13197  $$ = mm_strdup("system");
13198 }
13199 |  TABLES
13200  {
13201  $$ = mm_strdup("tables");
13202 }
13203 |  TABLESPACE
13204  {
13205  $$ = mm_strdup("tablespace");
13206 }
13207 |  TEMP
13208  {
13209  $$ = mm_strdup("temp");
13210 }
13211 |  TEMPLATE
13212  {
13213  $$ = mm_strdup("template");
13214 }
13215 |  TEMPORARY
13216  {
13217  $$ = mm_strdup("temporary");
13218 }
13219 |  TEXT_P
13220  {
13221  $$ = mm_strdup("text");
13222 }
13223 |  TRANSACTION
13224  {
13225  $$ = mm_strdup("transaction");
13226 }
13227 |  TRANSFORM
13228  {
13229  $$ = mm_strdup("transform");
13230 }
13231 |  TRIGGER
13232  {
13233  $$ = mm_strdup("trigger");
13234 }
13235 |  TRUNCATE
13236  {
13237  $$ = mm_strdup("truncate");
13238 }
13239 |  TRUSTED
13240  {
13241  $$ = mm_strdup("trusted");
13242 }
13243 |  TYPE_P
13244  {
13245  $$ = mm_strdup("type");
13246 }
13247 |  TYPES_P
13248  {
13249  $$ = mm_strdup("types");
13250 }
13251 |  UNBOUNDED
13252  {
13253  $$ = mm_strdup("unbounded");
13254 }
13255 |  UNCOMMITTED
13256  {
13257  $$ = mm_strdup("uncommitted");
13258 }
13259 |  UNENCRYPTED
13260  {
13261  $$ = mm_strdup("unencrypted");
13262 }
13263 |  UNKNOWN
13264  {
13265  $$ = mm_strdup("unknown");
13266 }
13267 |  UNLISTEN
13268  {
13269  $$ = mm_strdup("unlisten");
13270 }
13271 |  UNLOGGED
13272  {
13273  $$ = mm_strdup("unlogged");
13274 }
13275 |  UNTIL
13276  {
13277  $$ = mm_strdup("until");
13278 }
13279 |  UPDATE
13280  {
13281  $$ = mm_strdup("update");
13282 }
13283 |  VACUUM
13284  {
13285  $$ = mm_strdup("vacuum");
13286 }
13287 |  VALID
13288  {
13289  $$ = mm_strdup("valid");
13290 }
13291 |  VALIDATE
13292  {
13293  $$ = mm_strdup("validate");
13294 }
13295 |  VALIDATOR
13296  {
13297  $$ = mm_strdup("validator");
13298 }
13299 |  VALUE_P
13300  {
13301  $$ = mm_strdup("value");
13302 }
13303 |  VARYING
13304  {
13305  $$ = mm_strdup("varying");
13306 }
13307 |  VERSION_P
13308  {
13309  $$ = mm_strdup("version");
13310 }
13311 |  VIEW
13312  {
13313  $$ = mm_strdup("view");
13314 }
13315 |  VIEWS
13316  {
13317  $$ = mm_strdup("views");
13318 }
13319 |  VOLATILE
13320  {
13321  $$ = mm_strdup("volatile");
13322 }
13323 |  WHITESPACE_P
13324  {
13325  $$ = mm_strdup("whitespace");
13326 }
13327 |  WITHIN
13328  {
13329  $$ = mm_strdup("within");
13330 }
13331 |  WITHOUT
13332  {
13333  $$ = mm_strdup("without");
13334 }
13335 |  WORK
13336  {
13337  $$ = mm_strdup("work");
13338 }
13339 |  WRAPPER
13340  {
13341  $$ = mm_strdup("wrapper");
13342 }
13343 |  WRITE
13344  {
13345  $$ = mm_strdup("write");
13346 }
13347 |  XML_P
13348  {
13349  $$ = mm_strdup("xml");
13350 }
13351 |  YES_P
13352  {
13353  $$ = mm_strdup("yes");
13354 }
13355 |  ZONE
13356  {
13357  $$ = mm_strdup("zone");
13358 }
13359 ;
13360 
13361 
13362  col_name_keyword:
13363  BETWEEN
13364  {
13365  $$ = mm_strdup("between");
13366 }
13367 |  BIGINT
13368  {
13369  $$ = mm_strdup("bigint");
13370 }
13371 |  BIT
13372  {
13373  $$ = mm_strdup("bit");
13374 }
13375 |  BOOLEAN_P
13376  {
13377  $$ = mm_strdup("boolean");
13378 }
13379 |  CHARACTER
13380  {
13381  $$ = mm_strdup("character");
13382 }
13383 |  COALESCE
13384  {
13385  $$ = mm_strdup("coalesce");
13386 }
13387 |  DEC
13388  {
13389  $$ = mm_strdup("dec");
13390 }
13391 |  DECIMAL_P
13392  {
13393  $$ = mm_strdup("decimal");
13394 }
13395 |  EXISTS
13396  {
13397  $$ = mm_strdup("exists");
13398 }
13399 |  EXTRACT
13400  {
13401  $$ = mm_strdup("extract");
13402 }
13403 |  FLOAT_P
13404  {
13405  $$ = mm_strdup("float");
13406 }
13407 |  GREATEST
13408  {
13409  $$ = mm_strdup("greatest");
13410 }
13411 |  GROUPING
13412  {
13413  $$ = mm_strdup("grouping");
13414 }
13415 |  INOUT
13416  {
13417  $$ = mm_strdup("inout");
13418 }
13419 |  INTEGER
13420  {
13421  $$ = mm_strdup("integer");
13422 }
13423 |  INTERVAL
13424  {
13425  $$ = mm_strdup("interval");
13426 }
13427 |  LEAST
13428  {
13429  $$ = mm_strdup("least");
13430 }
13431 |  NATIONAL
13432  {
13433  $$ = mm_strdup("national");
13434 }
13435 |  NCHAR
13436  {
13437  $$ = mm_strdup("nchar");
13438 }
13439 |  NONE
13440  {
13441  $$ = mm_strdup("none");
13442 }
13443 |  NULLIF
13444  {
13445  $$ = mm_strdup("nullif");
13446 }
13447 |  NUMERIC
13448  {
13449  $$ = mm_strdup("numeric");
13450 }
13451 |  OUT_P
13452  {
13453  $$ = mm_strdup("out");
13454 }
13455 |  OVERLAY
13456  {
13457  $$ = mm_strdup("overlay");
13458 }
13459 |  POSITION
13460  {
13461  $$ = mm_strdup("position");
13462 }
13463 |  PRECISION
13464  {
13465  $$ = mm_strdup("precision");
13466 }
13467 |  REAL
13468  {
13469  $$ = mm_strdup("real");
13470 }
13471 |  ROW
13472  {
13473  $$ = mm_strdup("row");
13474 }
13475 |  SETOF
13476  {
13477  $$ = mm_strdup("setof");
13478 }
13479 |  SMALLINT
13480  {
13481  $$ = mm_strdup("smallint");
13482 }
13483 |  SUBSTRING
13484  {
13485  $$ = mm_strdup("substring");
13486 }
13487 |  TIME
13488  {
13489  $$ = mm_strdup("time");
13490 }
13491 |  TIMESTAMP
13492  {
13493  $$ = mm_strdup("timestamp");
13494 }
13495 |  TREAT
13496  {
13497  $$ = mm_strdup("treat");
13498 }
13499 |  TRIM
13500  {
13501  $$ = mm_strdup("trim");
13502 }
13503 |  VARCHAR
13504  {
13505  $$ = mm_strdup("varchar");
13506 }
13507 |  XMLATTRIBUTES
13508  {
13509  $$ = mm_strdup("xmlattributes");
13510 }
13511 |  XMLCONCAT
13512  {
13513  $$ = mm_strdup("xmlconcat");
13514 }
13515 |  XMLELEMENT
13516  {
13517  $$ = mm_strdup("xmlelement");
13518 }
13519 |  XMLEXISTS
13520  {
13521  $$ = mm_strdup("xmlexists");
13522 }
13523 |  XMLFOREST
13524  {
13525  $$ = mm_strdup("xmlforest");
13526 }
13527 |  XMLPARSE
13528  {
13529  $$ = mm_strdup("xmlparse");
13530 }
13531 |  XMLPI
13532  {
13533  $$ = mm_strdup("xmlpi");
13534 }
13535 |  XMLROOT
13536  {
13537  $$ = mm_strdup("xmlroot");
13538 }
13539 |  XMLSERIALIZE
13540  {
13541  $$ = mm_strdup("xmlserialize");
13542 }
13543 ;
13544 
13545 
13546  type_func_name_keyword:
13547  AUTHORIZATION
13548  {
13549  $$ = mm_strdup("authorization");
13550 }
13551 |  BINARY
13552  {
13553  $$ = mm_strdup("binary");
13554 }
13555 |  COLLATION
13556  {
13557  $$ = mm_strdup("collation");
13558 }
13559 |  CONCURRENTLY
13560  {
13561  $$ = mm_strdup("concurrently");
13562 }
13563 |  CROSS
13564  {
13565  $$ = mm_strdup("cross");
13566 }
13567 |  CURRENT_SCHEMA
13568  {
13569  $$ = mm_strdup("current_schema");
13570 }
13571 |  FREEZE
13572  {
13573  $$ = mm_strdup("freeze");
13574 }
13575 |  FULL
13576  {
13577  $$ = mm_strdup("full");
13578 }
13579 |  ILIKE
13580  {
13581  $$ = mm_strdup("ilike");
13582 }
13583 |  INNER_P
13584  {
13585  $$ = mm_strdup("inner");
13586 }
13587 |  IS
13588  {
13589  $$ = mm_strdup("is");
13590 }
13591 |  ISNULL
13592  {
13593  $$ = mm_strdup("isnull");
13594 }
13595 |  JOIN
13596  {
13597  $$ = mm_strdup("join");
13598 }
13599 |  LEFT
13600  {
13601  $$ = mm_strdup("left");
13602 }
13603 |  LIKE
13604  {
13605  $$ = mm_strdup("like");
13606 }
13607 |  NATURAL
13608  {
13609  $$ = mm_strdup("natural");
13610 }
13611 |  NOTNULL
13612  {
13613  $$ = mm_strdup("notnull");
13614 }
13615 |  OUTER_P
13616  {
13617  $$ = mm_strdup("outer");
13618 }
13619 |  OVERLAPS
13620  {
13621  $$ = mm_strdup("overlaps");
13622 }
13623 |  RIGHT
13624  {
13625  $$ = mm_strdup("right");
13626 }
13627 |  SIMILAR
13628  {
13629  $$ = mm_strdup("similar");
13630 }
13631 |  TABLESAMPLE
13632  {
13633  $$ = mm_strdup("tablesample");
13634 }
13635 |  VERBOSE
13636  {
13637  $$ = mm_strdup("verbose");
13638 }
13639 ;
13640 
13641 
13642  reserved_keyword:
13643  ALL
13644  {
13645  $$ = mm_strdup("all");
13646 }
13647 |  ANALYSE
13648  {
13649  $$ = mm_strdup("analyse");
13650 }
13651 |  ANALYZE
13652  {
13653  $$ = mm_strdup("analyze");
13654 }
13655 |  AND
13656  {
13657  $$ = mm_strdup("and");
13658 }
13659 |  ANY
13660  {
13661  $$ = mm_strdup("any");
13662 }
13663 |  ARRAY
13664  {
13665  $$ = mm_strdup("array");
13666 }
13667 |  AS
13668  {
13669  $$ = mm_strdup("as");
13670 }
13671 |  ASC
13672  {
13673  $$ = mm_strdup("asc");
13674 }
13675 |  ASYMMETRIC
13676  {
13677  $$ = mm_strdup("asymmetric");
13678 }
13679 |  BOTH
13680  {
13681  $$ = mm_strdup("both");
13682 }
13683 |  CASE
13684  {
13685  $$ = mm_strdup("case");
13686 }
13687 |  CAST
13688  {
13689  $$ = mm_strdup("cast");
13690 }
13691 |  CHECK
13692  {
13693  $$ = mm_strdup("check");
13694 }
13695 |  COLLATE
13696  {
13697  $$ = mm_strdup("collate");
13698 }
13699 |  COLUMN
13700  {
13701  $$ = mm_strdup("column");
13702 }
13703 |  CONSTRAINT
13704  {
13705  $$ = mm_strdup("constraint");
13706 }
13707 |  CREATE
13708  {
13709  $$ = mm_strdup("create");
13710 }
13711 |  CURRENT_CATALOG
13712  {
13713  $$ = mm_strdup("current_catalog");
13714 }
13715 |  CURRENT_DATE
13716  {
13717  $$ = mm_strdup("current_date");
13718 }
13719 |  CURRENT_ROLE
13720  {
13721  $$ = mm_strdup("current_role");
13722 }
13723 |  CURRENT_TIME
13724  {
13725  $$ = mm_strdup("current_time");
13726 }
13727 |  CURRENT_TIMESTAMP
13728  {
13729  $$ = mm_strdup("current_timestamp");
13730 }
13731 |  CURRENT_USER
13732  {
13733  $$ = mm_strdup("current_user");
13734 }
13735 |  DEFAULT
13736  {
13737  $$ = mm_strdup("default");
13738 }
13739 |  DEFERRABLE
13740  {
13741  $$ = mm_strdup("deferrable");
13742 }
13743 |  DESC
13744  {
13745  $$ = mm_strdup("desc");
13746 }
13747 |  DISTINCT
13748  {
13749  $$ = mm_strdup("distinct");
13750 }
13751 |  DO
13752  {
13753  $$ = mm_strdup("do");
13754 }
13755 |  ELSE
13756  {
13757  $$ = mm_strdup("else");
13758 }
13759 |  END_P
13760  {
13761  $$ = mm_strdup("end");
13762 }
13763 |  EXCEPT
13764  {
13765  $$ = mm_strdup("except");
13766 }
13767 |  FALSE_P
13768  {
13769  $$ = mm_strdup("false");
13770 }
13771 |  FETCH
13772  {
13773  $$ = mm_strdup("fetch");
13774 }
13775 |  FOR
13776  {
13777  $$ = mm_strdup("for");
13778 }
13779 |  FOREIGN
13780  {
13781  $$ = mm_strdup("foreign");
13782 }
13783 |  FROM
13784  {
13785  $$ = mm_strdup("from");
13786 }
13787 |  GRANT
13788  {
13789  $$ = mm_strdup("grant");
13790 }
13791 |  GROUP_P
13792  {
13793  $$ = mm_strdup("group");
13794 }
13795 |  HAVING
13796  {
13797  $$ = mm_strdup("having");
13798 }
13799 |  IN_P
13800  {
13801  $$ = mm_strdup("in");
13802 }
13803 |  INITIALLY
13804  {
13805  $$ = mm_strdup("initially");
13806 }
13807 |  INTERSECT
13808  {
13809  $$ = mm_strdup("intersect");
13810 }
13811 |  INTO
13812  {
13813  $$ = mm_strdup("into");
13814 }
13815 |  LATERAL_P
13816  {
13817  $$ = mm_strdup("lateral");
13818 }
13819 |  LEADING
13820  {
13821  $$ = mm_strdup("leading");
13822 }
13823 |  LIMIT
13824  {
13825  $$ = mm_strdup("limit");
13826 }
13827 |  LOCALTIME
13828  {
13829  $$ = mm_strdup("localtime");
13830 }
13831 |  LOCALTIMESTAMP
13832  {
13833  $$ = mm_strdup("localtimestamp");
13834 }
13835 |  NOT
13836  {
13837  $$ = mm_strdup("not");
13838 }
13839 |  NULL_P
13840  {
13841  $$ = mm_strdup("null");
13842 }
13843 |  OFFSET
13844  {
13845  $$ = mm_strdup("offset");
13846 }
13847 |  ON
13848  {
13849  $$ = mm_strdup("on");
13850 }
13851 |  ONLY
13852  {
13853  $$ = mm_strdup("only");
13854 }
13855 |  OR
13856  {
13857  $$ = mm_strdup("or");
13858 }
13859 |  ORDER
13860  {
13861  $$ = mm_strdup("order");
13862 }
13863 |  PLACING
13864  {
13865  $$ = mm_strdup("placing");
13866 }
13867 |  PRIMARY
13868  {
13869  $$ = mm_strdup("primary");
13870 }
13871 |  REFERENCES
13872  {
13873  $$ = mm_strdup("references");
13874 }
13875 |  RETURNING
13876  {
13877  $$ = mm_strdup("returning");
13878 }
13879 |  SELECT
13880  {
13881  $$ = mm_strdup("select");
13882 }
13883 |  SESSION_USER
13884  {
13885  $$ = mm_strdup("session_user");
13886 }
13887 |  SOME
13888  {
13889  $$ = mm_strdup("some");
13890 }
13891 |  SYMMETRIC
13892  {
13893  $$ = mm_strdup("symmetric");
13894 }
13895 |  TABLE
13896  {
13897  $$ = mm_strdup("table");
13898 }
13899 |  THEN
13900  {
13901  $$ = mm_strdup("then");
13902 }
13903 |  TRAILING
13904  {
13905  $$ = mm_strdup("trailing");
13906 }
13907 |  TRUE_P
13908  {
13909  $$ = mm_strdup("true");
13910 }
13911 |  UNIQUE
13912  {
13913  $$ = mm_strdup("unique");
13914 }
13915 |  USER
13916  {
13917  $$ = mm_strdup("user");
13918 }
13919 |  USING
13920  {
13921  $$ = mm_strdup("using");
13922 }
13923 |  VARIADIC
13924  {
13925  $$ = mm_strdup("variadic");
13926 }
13927 |  WHEN
13928  {
13929  $$ = mm_strdup("when");
13930 }
13931 |  WHERE
13932  {
13933  $$ = mm_strdup("where");
13934 }
13935 |  WINDOW
13936  {
13937  $$ = mm_strdup("window");
13938 }
13939 |  WITH
13940  {
13941  $$ = mm_strdup("with");
13942 }
13943 ;
13944 
13945 
13946 /* trailer */
13947 /* src/interfaces/ecpg/preproc/ecpg.trailer */
13948 
13949 statements: /*EMPTY*/
13950 				| statements statement
13951 		;
13952 
13953 statement: ecpgstart at stmt ';' { connection = NULL; }
13954 				| ecpgstart stmt ';'
13955 				| ecpgstart ECPGVarDeclaration
13956 				{
13957 					fprintf(base_yyout, "%s", $2);
13958 					free($2);
13959 					output_line_number();
13960 				}
13961 				| ECPGDeclaration
13962 				| c_thing               { fprintf(base_yyout, "%s", $1); free($1); }
13963 				| CPP_LINE              { fprintf(base_yyout, "%s", $1); free($1); }
13964 				| '{'                   { braces_open++; fputs("{", base_yyout); }
13965 				| '}'
13966 		{
13967 			remove_typedefs(braces_open);
13968 			remove_variables(braces_open--);
13969 			if (braces_open == 0)
13970 			{
13971 				free(current_function);
13972 				current_function = NULL;
13973 			}
13974 			fputs("}", base_yyout);
13975 		}
13976 		;
13977 
13978 CreateAsStmt: CREATE OptTemp TABLE create_as_target AS {FoundInto = 0;} SelectStmt opt_with_data
13979 		{
13980 			if (FoundInto == 1)
13981 				mmerror(PARSE_ERROR, ET_ERROR, "CREATE TABLE AS cannot specify INTO");
13982 
13983 			$$ = cat_str(7, mm_strdup("create"), $2, mm_strdup("table"), $4, mm_strdup("as"), $7, $8);
13984 		}
13985                 |  CREATE OptTemp TABLE IF_P NOT EXISTS create_as_target AS {FoundInto = 0;} SelectStmt opt_with_data
13986 		{
13987 			if (FoundInto == 1)
13988 				mmerror(PARSE_ERROR, ET_ERROR, "CREATE TABLE AS cannot specify INTO");
13989 
13990 			$$ = cat_str(7, mm_strdup("create"), $2, mm_strdup("table if not exists"), $7, mm_strdup("as"), $10, $11);
13991 		}
13992 		;
13993 
13994 at: AT connection_object
13995 		{
13996 			connection = $2;
13997 			/*
13998 			 * Do we have a variable as connection target?  Remove the variable
13999 			 * from the variable list or else it will be used twice.
14000 			 */
14001 			if (argsinsert != NULL)
14002 				argsinsert = NULL;
14003 		}
14004 		;
14005 
14006 /*
14007  * the exec sql connect statement: connect to the given database
14008  */
14009 ECPGConnect: SQL_CONNECT TO connection_target opt_connection_name opt_user
14010 			{ $$ = cat_str(5, $3, mm_strdup(","), $5, mm_strdup(","), $4); }
14011 		| SQL_CONNECT TO DEFAULT
14012 			{ $$ = mm_strdup("NULL, NULL, NULL, \"DEFAULT\""); }
14013 		  /* also allow ORACLE syntax */
14014 		| SQL_CONNECT ora_user
14015 			{ $$ = cat_str(3, mm_strdup("NULL,"), $2, mm_strdup(", NULL")); }
14016 		| DATABASE connection_target
14017 			{ $$ = cat2_str($2, mm_strdup(", NULL, NULL, NULL")); }
14018 		;
14019 
14020 connection_target: opt_database_name opt_server opt_port
14021 		{
14022 			/* old style: dbname[@server][:port] */
14023 			if (strlen($2) > 0 && *($2) != '@')
14024 				mmerror(PARSE_ERROR, ET_ERROR, "expected \"@\", found \"%s\"", $2);
14025 
14026 			/* C strings need to be handled differently */
14027 			if ($1[0] == '\"')
14028 				$$ = $1;
14029 			else
14030 				$$ = make3_str(mm_strdup("\""), make3_str($1, $2, $3), mm_strdup("\""));
14031 		}
14032 		|  db_prefix ':' server opt_port '/' opt_database_name opt_options
14033 		{
14034 			/* new style: <tcp|unix>:postgresql://server[:port][/dbname] */
14035 			if (strncmp($1, "unix:postgresql", strlen("unix:postgresql")) != 0 && strncmp($1, "tcp:postgresql", strlen("tcp:postgresql")) != 0)
14036 				mmerror(PARSE_ERROR, ET_ERROR, "only protocols \"tcp\" and \"unix\" and database type \"postgresql\" are supported");
14037 
14038 			if (strncmp($3, "//", strlen("//")) != 0)
14039 				mmerror(PARSE_ERROR, ET_ERROR, "expected \"://\", found \"%s\"", $3);
14040 
14041 			if (strncmp($1, "unix", strlen("unix")) == 0 &&
14042 				strncmp($3 + strlen("//"), "localhost", strlen("localhost")) != 0 &&
14043 				strncmp($3 + strlen("//"), "127.0.0.1", strlen("127.0.0.1")) != 0)
14044 				mmerror(PARSE_ERROR, ET_ERROR, "Unix-domain sockets only work on \"localhost\" but not on \"%s\"", $3 + strlen("//"));
14045 
14046 			$$ = make3_str(make3_str(mm_strdup("\""), $1, mm_strdup(":")), $3, make3_str(make3_str($4, mm_strdup("/"), $6), $7, mm_strdup("\"")));
14047 		}
14048 		| char_variable
14049 		{
14050 			$$ = $1;
14051 		}
14052 		| ecpg_sconst
14053 		{
14054 			/* We can only process double quoted strings not single quotes ones,
14055 			 * so we change the quotes.
14056 			 * Note, that the rule for ecpg_sconst adds these single quotes. */
14057 			$1[0] = '\"';
14058 			$1[strlen($1)-1] = '\"';
14059 			$$ = $1;
14060 		}
14061 		;
14062 
14063 opt_database_name: database_name		{ $$ = $1; }
14064 		| /*EMPTY*/			{ $$ = EMPTY; }
14065 		;
14066 
14067 db_prefix: ecpg_ident cvariable
14068 		{
14069 			if (strcmp($2, "postgresql") != 0 && strcmp($2, "postgres") != 0)
14070 				mmerror(PARSE_ERROR, ET_ERROR, "expected \"postgresql\", found \"%s\"", $2);
14071 
14072 			if (strcmp($1, "tcp") != 0 && strcmp($1, "unix") != 0)
14073 				mmerror(PARSE_ERROR, ET_ERROR, "invalid connection type: %s", $1);
14074 
14075 			$$ = make3_str($1, mm_strdup(":"), $2);
14076 		}
14077 		;
14078 
14079 server: Op server_name
14080 		{
14081 			if (strcmp($1, "@") != 0 && strcmp($1, "//") != 0)
14082 				mmerror(PARSE_ERROR, ET_ERROR, "expected \"@\" or \"://\", found \"%s\"", $1);
14083 
14084 			$$ = make2_str($1, $2);
14085 		}
14086 		;
14087 
14088 opt_server: server			{ $$ = $1; }
14089 		| /*EMPTY*/			{ $$ = EMPTY; }
14090 		;
14091 
14092 server_name: ColId					{ $$ = $1; }
14093 		| ColId '.' server_name		{ $$ = make3_str($1, mm_strdup("."), $3); }
14094 		| IP						{ $$ = make_name(); }
14095 		;
14096 
14097 opt_port: ':' Iconst		{ $$ = make2_str(mm_strdup(":"), $2); }
14098 		| /*EMPTY*/	{ $$ = EMPTY; }
14099 		;
14100 
14101 opt_connection_name: AS connection_object	{ $$ = $2; }
14102 		| /*EMPTY*/			{ $$ = mm_strdup("NULL"); }
14103 		;
14104 
14105 opt_user: USER ora_user		{ $$ = $2; }
14106 		| /*EMPTY*/			{ $$ = mm_strdup("NULL, NULL"); }
14107 		;
14108 
14109 ora_user: user_name
14110 			{ $$ = cat2_str($1, mm_strdup(", NULL")); }
14111 		| user_name '/' user_name
14112 			{ $$ = cat_str(3, $1, mm_strdup(","), $3); }
14113 		| user_name SQL_IDENTIFIED BY user_name
14114 			{ $$ = cat_str(3, $1, mm_strdup(","), $4); }
14115 		| user_name USING user_name
14116 			{ $$ = cat_str(3, $1, mm_strdup(","), $3); }
14117 		;
14118 
14119 user_name: RoleId
14120 		{
14121 			if ($1[0] == '\"')
14122 				$$ = $1;
14123 			else
14124 				$$ = make3_str(mm_strdup("\""), $1, mm_strdup("\""));
14125 		}
14126 		| ecpg_sconst
14127 		{
14128 			if ($1[0] == '\"')
14129 				$$ = $1;
14130 			else
14131 				$$ = make3_str(mm_strdup("\""), $1, mm_strdup("\""));
14132 		}
14133 		| civar
14134 		{
14135 			enum ECPGttype type = argsinsert->variable->type->type;
14136 
14137 			/* if array see what's inside */
14138 			if (type == ECPGt_array)
14139 				type = argsinsert->variable->type->u.element->type;
14140 
14141 			/* handle varchars */
14142 			if (type == ECPGt_varchar)
14143 				$$ = make2_str(mm_strdup(argsinsert->variable->name), mm_strdup(".arr"));
14144 			else
14145 				$$ = mm_strdup(argsinsert->variable->name);
14146 		}
14147 		;
14148 
14149 char_variable: cvariable
14150 		{
14151 			/* check if we have a string variable */
14152 			struct variable *p = find_variable($1);
14153 			enum ECPGttype type = p->type->type;
14154 
14155 			/* If we have just one character this is not a string */
14156 			if (atol(p->type->size) == 1)
14157 					mmerror(PARSE_ERROR, ET_ERROR, "invalid data type");
14158 			else
14159 			{
14160 				/* if array see what's inside */
14161 				if (type == ECPGt_array)
14162 					type = p->type->u.element->type;
14163 
14164 				switch (type)
14165 				{
14166 					case ECPGt_char:
14167 					case ECPGt_unsigned_char:
14168 					case ECPGt_string:
14169 						$$ = $1;
14170 						break;
14171 					case ECPGt_varchar:
14172 						$$ = make2_str($1, mm_strdup(".arr"));
14173 						break;
14174 					default:
14175 						mmerror(PARSE_ERROR, ET_ERROR, "invalid data type");
14176 						$$ = $1;
14177 						break;
14178 				}
14179 			}
14180 		}
14181 		;
14182 
14183 opt_options: Op connect_options
14184 		{
14185 			if (strlen($1) == 0)
14186 				mmerror(PARSE_ERROR, ET_ERROR, "incomplete statement");
14187 
14188 			if (strcmp($1, "?") != 0)
14189 				mmerror(PARSE_ERROR, ET_ERROR, "unrecognized token \"%s\"", $1);
14190 
14191 			$$ = make2_str(mm_strdup("?"), $2);
14192 		}
14193 		| /*EMPTY*/	{ $$ = EMPTY; }
14194 		;
14195 
14196 connect_options:  ColId opt_opt_value
14197 			{
14198 				$$ = make2_str($1, $2);
14199 			}
14200 		| ColId opt_opt_value Op connect_options
14201 			{
14202 				if (strlen($3) == 0)
14203 					mmerror(PARSE_ERROR, ET_ERROR, "incomplete statement");
14204 
14205 				if (strcmp($3, "&") != 0)
14206 					mmerror(PARSE_ERROR, ET_ERROR, "unrecognized token \"%s\"", $3);
14207 
14208 				$$ = cat_str(3, make2_str($1, $2), $3, $4);
14209 			}
14210 		;
14211 
14212 opt_opt_value: /*EMPTY*/
14213 			{ $$ = EMPTY; }
14214 		| '=' Iconst
14215 			{ $$ = make2_str(mm_strdup("="), $2); }
14216 		| '=' ecpg_ident
14217 			{ $$ = make2_str(mm_strdup("="), $2); }
14218 		| '=' civar
14219 			{ $$ = make2_str(mm_strdup("="), $2); }
14220 		;
14221 
14222 prepared_name: name
14223 		{
14224 			if ($1[0] == '\"' && $1[strlen($1)-1] == '\"') /* already quoted? */
14225 				$$ = $1;
14226 			else /* not quoted => convert to lowercase */
14227 			{
14228 				size_t i;
14229 
14230 				for (i = 0; i< strlen($1); i++)
14231 					$1[i] = tolower((unsigned char) $1[i]);
14232 
14233 				$$ = make3_str(mm_strdup("\""), $1, mm_strdup("\""));
14234 			}
14235 		}
14236 		| char_variable { $$ = $1; }
14237 		;
14238 
14239 /*
14240  * Declare a prepared cursor. The syntax is different from the standard
14241  * declare statement, so we create a new rule.
14242  */
14243 ECPGCursorStmt:  DECLARE cursor_name cursor_options CURSOR opt_hold FOR prepared_name
14244 		{
14245 			struct cursor *ptr, *this;
14246 			char *cursor_marker = $2[0] == ':' ? mm_strdup("$0") : mm_strdup($2);
14247 			int (* strcmp_fn)(const char *, const char *) = (($2[0] == ':' || $2[0] == '"') ? strcmp : pg_strcasecmp);
14248 			struct variable *thisquery = (struct variable *)mm_alloc(sizeof(struct variable));
14249 			const char *con = connection ? connection : "NULL";
14250 			char *comment;
14251 
14252 			for (ptr = cur; ptr != NULL; ptr = ptr->next)
14253 			{
14254 				if (strcmp_fn($2, ptr->name) == 0)
14255 				{
14256 					/* re-definition is a bug */
14257 					if ($2[0] == ':')
14258 						mmerror(PARSE_ERROR, ET_ERROR, "using variable \"%s\" in different declare statements is not supported", $2+1);
14259 					else
14260 						mmerror(PARSE_ERROR, ET_ERROR, "cursor \"%s\" is already defined", $2);
14261 				}
14262 			}
14263 
14264 			this = (struct cursor *) mm_alloc(sizeof(struct cursor));
14265 
14266 			/* initial definition */
14267 			this->next = cur;
14268 			this->name = $2;
14269 			this->function = (current_function ? mm_strdup(current_function) : NULL);
14270 			this->connection = connection;
14271 			this->command =  cat_str(6, mm_strdup("declare"), cursor_marker, $3, mm_strdup("cursor"), $5, mm_strdup("for $1"));
14272 			this->argsresult = NULL;
14273 			this->argsresult_oos = NULL;
14274 
14275 			thisquery->type = &ecpg_query;
14276 			thisquery->brace_level = 0;
14277 			thisquery->next = NULL;
14278 			thisquery->name = (char *) mm_alloc(sizeof("ECPGprepared_statement(, , __LINE__)") + strlen(con) + strlen($7));
14279 			sprintf(thisquery->name, "ECPGprepared_statement(%s, %s, __LINE__)", con, $7);
14280 
14281 			this->argsinsert = NULL;
14282 			this->argsinsert_oos = NULL;
14283 			if ($2[0] == ':')
14284 			{
14285 				struct variable *var = find_variable($2 + 1);
14286 				remove_variable_from_list(&argsinsert, var);
14287 				add_variable_to_head(&(this->argsinsert), var, &no_indicator);
14288 			}
14289 			add_variable_to_head(&(this->argsinsert), thisquery, &no_indicator);
14290 
14291 			cur = this;
14292 
14293 			comment = cat_str(3, mm_strdup("/*"), mm_strdup(this->command), mm_strdup("*/"));
14294 
14295 			if ((braces_open > 0) && INFORMIX_MODE) /* we're in a function */
14296 				$$ = cat_str(3, adjust_outofscope_cursor_vars(this),
14297 					mm_strdup("ECPG_informix_reset_sqlca();"),
14298 					comment);
14299 			else
14300 				$$ = cat2_str(adjust_outofscope_cursor_vars(this), comment);
14301 		}
14302 		;
14303 
14304 ECPGExecuteImmediateStmt: EXECUTE IMMEDIATE execstring
14305 			{
14306 			  /* execute immediate means prepare the statement and
14307 			   * immediately execute it */
14308 			  $$ = $3;
14309 			};
14310 /*
14311  * variable declaration outside exec sql declare block
14312  */
14313 ECPGVarDeclaration: single_vt_declaration;
14314 
14315 single_vt_declaration: type_declaration		{ $$ = $1; }
14316 		| var_declaration		{ $$ = $1; }
14317 		;
14318 
14319 precision:	NumericOnly	{ $$ = $1; };
14320 
14321 opt_scale:	',' NumericOnly	{ $$ = $2; }
14322 		| /* EMPTY */	{ $$ = EMPTY; }
14323 		;
14324 
14325 ecpg_interval:	opt_interval	{ $$ = $1; }
14326 		| YEAR_P TO MINUTE_P	{ $$ = mm_strdup("year to minute"); }
14327 		| YEAR_P TO SECOND_P	{ $$ = mm_strdup("year to second"); }
14328 		| DAY_P TO DAY_P		{ $$ = mm_strdup("day to day"); }
14329 		| MONTH_P TO MONTH_P	{ $$ = mm_strdup("month to month"); }
14330 		;
14331 
14332 /*
14333  * variable declaration inside exec sql declare block
14334  */
14335 ECPGDeclaration: sql_startdeclare
14336 		{ fputs("/* exec sql begin declare section */", base_yyout); }
14337 		var_type_declarations sql_enddeclare
14338 		{
14339 			fprintf(base_yyout, "%s/* exec sql end declare section */", $3);
14340 			free($3);
14341 			output_line_number();
14342 		}
14343 		;
14344 
14345 sql_startdeclare: ecpgstart BEGIN_P DECLARE SQL_SECTION ';' {};
14346 
14347 sql_enddeclare: ecpgstart END_P DECLARE SQL_SECTION ';' {};
14348 
14349 var_type_declarations:	/*EMPTY*/			{ $$ = EMPTY; }
14350 		| vt_declarations			{ $$ = $1; }
14351 		;
14352 
14353 vt_declarations:  single_vt_declaration			{ $$ = $1; }
14354 		| CPP_LINE				{ $$ = $1; }
14355 		| vt_declarations single_vt_declaration	{ $$ = cat2_str($1, $2); }
14356 		| vt_declarations CPP_LINE		{ $$ = cat2_str($1, $2); }
14357 		;
14358 
14359 variable_declarations:	var_declaration	{ $$ = $1; }
14360 		| variable_declarations var_declaration	{ $$ = cat2_str($1, $2); }
14361 		;
14362 
14363 type_declaration: S_TYPEDEF
14364 	{
14365 		/* reset this variable so we see if there was */
14366 		/* an initializer specified */
14367 		initializer = 0;
14368 	}
14369 	var_type opt_pointer ECPGColLabelCommon opt_array_bounds ';'
14370 	{
14371 		add_typedef($5, $6.index1, $6.index2, $3.type_enum, $3.type_dimension, $3.type_index, initializer, *$4 ? 1 : 0);
14372 
14373 		fprintf(base_yyout, "typedef %s %s %s %s;\n", $3.type_str, *$4 ? "*" : "", $5, $6.str);
14374 		output_line_number();
14375 		$$ = mm_strdup("");
14376 	};
14377 
14378 var_declaration: storage_declaration
14379 		var_type
14380 		{
14381 			actual_type[struct_level].type_enum = $2.type_enum;
14382 			actual_type[struct_level].type_str = $2.type_str;
14383 			actual_type[struct_level].type_dimension = $2.type_dimension;
14384 			actual_type[struct_level].type_index = $2.type_index;
14385 			actual_type[struct_level].type_sizeof = $2.type_sizeof;
14386 
14387 			actual_startline[struct_level] = hashline_number();
14388 		}
14389 		variable_list ';'
14390 		{
14391 			$$ = cat_str(5, actual_startline[struct_level], $1, $2.type_str, $4, mm_strdup(";\n"));
14392 		}
14393 		| var_type
14394 		{
14395 			actual_type[struct_level].type_enum = $1.type_enum;
14396 			actual_type[struct_level].type_str = $1.type_str;
14397 			actual_type[struct_level].type_dimension = $1.type_dimension;
14398 			actual_type[struct_level].type_index = $1.type_index;
14399 			actual_type[struct_level].type_sizeof = $1.type_sizeof;
14400 
14401 			actual_startline[struct_level] = hashline_number();
14402 		}
14403 		variable_list ';'
14404 		{
14405 			$$ = cat_str(4, actual_startline[struct_level], $1.type_str, $3, mm_strdup(";\n"));
14406 		}
14407 		| struct_union_type_with_symbol ';'
14408 		{
14409 			$$ = cat2_str($1, mm_strdup(";"));
14410 		}
14411 		;
14412 
14413 opt_bit_field:	':' Iconst	{ $$ =cat2_str(mm_strdup(":"), $2); }
14414 		| /* EMPTY */	{ $$ = EMPTY; }
14415 		;
14416 
14417 storage_declaration: storage_clause storage_modifier
14418 			{$$ = cat2_str ($1, $2); }
14419 		| storage_clause		{$$ = $1; }
14420 		| storage_modifier		{$$ = $1; }
14421 		;
14422 
14423 storage_clause : S_EXTERN	{ $$ = mm_strdup("extern"); }
14424 		| S_STATIC			{ $$ = mm_strdup("static"); }
14425 		| S_REGISTER		{ $$ = mm_strdup("register"); }
14426 		| S_AUTO			{ $$ = mm_strdup("auto"); }
14427 		;
14428 
14429 storage_modifier : S_CONST	{ $$ = mm_strdup("const"); }
14430 		| S_VOLATILE		{ $$ = mm_strdup("volatile"); }
14431 		;
14432 
14433 var_type:	simple_type
14434 		{
14435 			$$.type_enum = $1;
14436 			$$.type_str = mm_strdup(ecpg_type_name($1));
14437 			$$.type_dimension = mm_strdup("-1");
14438 			$$.type_index = mm_strdup("-1");
14439 			$$.type_sizeof = NULL;
14440 		}
14441 		| struct_union_type
14442 		{
14443 			$$.type_str = $1;
14444 			$$.type_dimension = mm_strdup("-1");
14445 			$$.type_index = mm_strdup("-1");
14446 
14447 			if (strncmp($1, "struct", sizeof("struct")-1) == 0)
14448 			{
14449 				$$.type_enum = ECPGt_struct;
14450 				$$.type_sizeof = ECPGstruct_sizeof;
14451 			}
14452 			else
14453 			{
14454 				$$.type_enum = ECPGt_union;
14455 				$$.type_sizeof = NULL;
14456 			}
14457 		}
14458 		| enum_type
14459 		{
14460 			$$.type_str = $1;
14461 			$$.type_enum = ECPGt_int;
14462 			$$.type_dimension = mm_strdup("-1");
14463 			$$.type_index = mm_strdup("-1");
14464 			$$.type_sizeof = NULL;
14465 		}
14466 		| ECPGColLabelCommon '(' precision opt_scale ')'
14467 		{
14468 			if (strcmp($1, "numeric") == 0)
14469 			{
14470 				$$.type_enum = ECPGt_numeric;
14471 				$$.type_str = mm_strdup("numeric");
14472 			}
14473 			else if (strcmp($1, "decimal") == 0)
14474 			{
14475 				$$.type_enum = ECPGt_decimal;
14476 				$$.type_str = mm_strdup("decimal");
14477 			}
14478 			else
14479 			{
14480 				mmerror(PARSE_ERROR, ET_ERROR, "only data types numeric and decimal have precision/scale argument");
14481 				$$.type_enum = ECPGt_numeric;
14482 				$$.type_str = mm_strdup("numeric");
14483 			}
14484 
14485 			$$.type_dimension = mm_strdup("-1");
14486 			$$.type_index = mm_strdup("-1");
14487 			$$.type_sizeof = NULL;
14488 		}
14489 		| ECPGColLabelCommon ecpg_interval
14490 		{
14491 			if (strlen($2) != 0 && strcmp ($1, "datetime") != 0 && strcmp ($1, "interval") != 0)
14492 				mmerror (PARSE_ERROR, ET_ERROR, "interval specification not allowed here");
14493 
14494 			/*
14495 			 * Check for type names that the SQL grammar treats as
14496 			 * unreserved keywords
14497 			 */
14498 			if (strcmp($1, "varchar") == 0)
14499 			{
14500 				$$.type_enum = ECPGt_varchar;
14501 				$$.type_str = EMPTY; /*mm_strdup("varchar");*/
14502 				$$.type_dimension = mm_strdup("-1");
14503 				$$.type_index = mm_strdup("-1");
14504 				$$.type_sizeof = NULL;
14505 			}
14506 			else if (strcmp($1, "float") == 0)
14507 			{
14508 				$$.type_enum = ECPGt_float;
14509 				$$.type_str = mm_strdup("float");
14510 				$$.type_dimension = mm_strdup("-1");
14511 				$$.type_index = mm_strdup("-1");
14512 				$$.type_sizeof = NULL;
14513 			}
14514 			else if (strcmp($1, "double") == 0)
14515 			{
14516 				$$.type_enum = ECPGt_double;
14517 				$$.type_str = mm_strdup("double");
14518 				$$.type_dimension = mm_strdup("-1");
14519 				$$.type_index = mm_strdup("-1");
14520 				$$.type_sizeof = NULL;
14521 			}
14522 			else if (strcmp($1, "numeric") == 0)
14523 			{
14524 				$$.type_enum = ECPGt_numeric;
14525 				$$.type_str = mm_strdup("numeric");
14526 				$$.type_dimension = mm_strdup("-1");
14527 				$$.type_index = mm_strdup("-1");
14528 				$$.type_sizeof = NULL;
14529 			}
14530 			else if (strcmp($1, "decimal") == 0)
14531 			{
14532 				$$.type_enum = ECPGt_decimal;
14533 				$$.type_str = mm_strdup("decimal");
14534 				$$.type_dimension = mm_strdup("-1");
14535 				$$.type_index = mm_strdup("-1");
14536 				$$.type_sizeof = NULL;
14537 			}
14538 			else if (strcmp($1, "date") == 0)
14539 			{
14540 				$$.type_enum = ECPGt_date;
14541 				$$.type_str = mm_strdup("date");
14542 				$$.type_dimension = mm_strdup("-1");
14543 				$$.type_index = mm_strdup("-1");
14544 				$$.type_sizeof = NULL;
14545 			}
14546 			else if (strcmp($1, "timestamp") == 0)
14547 			{
14548 				$$.type_enum = ECPGt_timestamp;
14549 				$$.type_str = mm_strdup("timestamp");
14550 				$$.type_dimension = mm_strdup("-1");
14551 				$$.type_index = mm_strdup("-1");
14552 				$$.type_sizeof = NULL;
14553 			}
14554 			else if (strcmp($1, "interval") == 0)
14555 			{
14556 				$$.type_enum = ECPGt_interval;
14557 				$$.type_str = mm_strdup("interval");
14558 				$$.type_dimension = mm_strdup("-1");
14559 				$$.type_index = mm_strdup("-1");
14560 				$$.type_sizeof = NULL;
14561 			}
14562 			else if (strcmp($1, "datetime") == 0)
14563 			{
14564 				$$.type_enum = ECPGt_timestamp;
14565 				$$.type_str = mm_strdup("timestamp");
14566 				$$.type_dimension = mm_strdup("-1");
14567 				$$.type_index = mm_strdup("-1");
14568 				$$.type_sizeof = NULL;
14569 			}
14570 			else if ((strcmp($1, "string") == 0) && INFORMIX_MODE)
14571 			{
14572 				$$.type_enum = ECPGt_string;
14573 				$$.type_str = mm_strdup("char");
14574 				$$.type_dimension = mm_strdup("-1");
14575 				$$.type_index = mm_strdup("-1");
14576 				$$.type_sizeof = NULL;
14577 			}
14578 			else
14579 			{
14580 				/* this is for typedef'ed types */
14581 				struct typedefs *this = get_typedef($1);
14582 
14583 				$$.type_str = (this->type->type_enum == ECPGt_varchar) ? EMPTY : mm_strdup(this->name);
14584 				$$.type_enum = this->type->type_enum;
14585 				$$.type_dimension = this->type->type_dimension;
14586 				$$.type_index = this->type->type_index;
14587 				if (this->type->type_sizeof && strlen(this->type->type_sizeof) != 0)
14588 					$$.type_sizeof = this->type->type_sizeof;
14589 				else
14590 					$$.type_sizeof = cat_str(3, mm_strdup("sizeof("), mm_strdup(this->name), mm_strdup(")"));
14591 
14592 				struct_member_list[struct_level] = ECPGstruct_member_dup(this->struct_member_list);
14593 			}
14594 		}
14595 		| s_struct_union_symbol
14596 		{
14597 			/* this is for named structs/unions */
14598 			char *name;
14599 			struct typedefs *this;
14600 			bool forward = (forward_name != NULL && strcmp($1.symbol, forward_name) == 0 && strcmp($1.su, "struct") == 0);
14601 
14602 			name = cat2_str($1.su, $1.symbol);
14603 			/* Do we have a forward definition? */
14604 			if (!forward)
14605 			{
14606 				/* No */
14607 
14608 				this = get_typedef(name);
14609 				$$.type_str = mm_strdup(this->name);
14610 				$$.type_enum = this->type->type_enum;
14611 				$$.type_dimension = this->type->type_dimension;
14612 				$$.type_index = this->type->type_index;
14613 				$$.type_sizeof = this->type->type_sizeof;
14614 				struct_member_list[struct_level] = ECPGstruct_member_dup(this->struct_member_list);
14615 				free(name);
14616 			}
14617 			else
14618 			{
14619 				$$.type_str = name;
14620 				$$.type_enum = ECPGt_long;
14621 				$$.type_dimension = mm_strdup("-1");
14622 				$$.type_index = mm_strdup("-1");
14623 				$$.type_sizeof = mm_strdup("");
14624 				struct_member_list[struct_level] = NULL;
14625 			}
14626 		}
14627 		;
14628 
14629 enum_type: ENUM_P symbol enum_definition
14630 			{ $$ = cat_str(3, mm_strdup("enum"), $2, $3); }
14631 		| ENUM_P enum_definition
14632 			{ $$ = cat2_str(mm_strdup("enum"), $2); }
14633 		| ENUM_P symbol
14634 			{ $$ = cat2_str(mm_strdup("enum"), $2); }
14635 		;
14636 
14637 enum_definition: '{' c_list '}'
14638 			{ $$ = cat_str(3, mm_strdup("{"), $2, mm_strdup("}")); };
14639 
14640 struct_union_type_with_symbol: s_struct_union_symbol
14641 		{
14642 			struct_member_list[struct_level++] = NULL;
14643 			if (struct_level >= STRUCT_DEPTH)
14644 				 mmerror(PARSE_ERROR, ET_ERROR, "too many levels in nested structure/union definition");
14645 			forward_name = mm_strdup($1.symbol);
14646 		}
14647 		'{' variable_declarations '}'
14648 		{
14649 			struct typedefs *ptr, *this;
14650 			struct this_type su_type;
14651 
14652 			ECPGfree_struct_member(struct_member_list[struct_level]);
14653 			struct_member_list[struct_level] = NULL;
14654 			struct_level--;
14655 			if (strncmp($1.su, "struct", sizeof("struct")-1) == 0)
14656 				su_type.type_enum = ECPGt_struct;
14657 			else
14658 				su_type.type_enum = ECPGt_union;
14659 			su_type.type_str = cat2_str($1.su, $1.symbol);
14660 			free(forward_name);
14661 			forward_name = NULL;
14662 
14663 			/* This is essentially a typedef but needs the keyword struct/union as well.
14664 			 * So we create the typedef for each struct definition with symbol */
14665 			for (ptr = types; ptr != NULL; ptr = ptr->next)
14666 			{
14667 					if (strcmp(su_type.type_str, ptr->name) == 0)
14668 							/* re-definition is a bug */
14669 							mmerror(PARSE_ERROR, ET_ERROR, "type \"%s\" is already defined", su_type.type_str);
14670 			}
14671 
14672 			this = (struct typedefs *) mm_alloc(sizeof(struct typedefs));
14673 
14674 			/* initial definition */
14675 			this->next = types;
14676 			this->name = mm_strdup(su_type.type_str);
14677 			this->brace_level = braces_open;
14678 			this->type = (struct this_type *) mm_alloc(sizeof(struct this_type));
14679 			this->type->type_enum = su_type.type_enum;
14680 			this->type->type_str = mm_strdup(su_type.type_str);
14681 			this->type->type_dimension = mm_strdup("-1"); /* dimension of array */
14682 			this->type->type_index = mm_strdup("-1");	/* length of string */
14683 			this->type->type_sizeof = ECPGstruct_sizeof;
14684 			this->struct_member_list = struct_member_list[struct_level];
14685 
14686 			types = this;
14687 			$$ = cat_str(4, su_type.type_str, mm_strdup("{"), $4, mm_strdup("}"));
14688 		}
14689 		;
14690 
14691 struct_union_type: struct_union_type_with_symbol	{ $$ = $1; }
14692 		| s_struct_union
14693 		{
14694 			struct_member_list[struct_level++] = NULL;
14695 			if (struct_level >= STRUCT_DEPTH)
14696 				 mmerror(PARSE_ERROR, ET_ERROR, "too many levels in nested structure/union definition");
14697 		}
14698 		'{' variable_declarations '}'
14699 		{
14700 			ECPGfree_struct_member(struct_member_list[struct_level]);
14701 			struct_member_list[struct_level] = NULL;
14702 			struct_level--;
14703 			$$ = cat_str(4, $1, mm_strdup("{"), $4, mm_strdup("}"));
14704 		}
14705 		;
14706 
14707 s_struct_union_symbol: SQL_STRUCT symbol
14708 		{
14709 			$$.su = mm_strdup("struct");
14710 			$$.symbol = $2;
14711 			ECPGstruct_sizeof = cat_str(3, mm_strdup("sizeof("), cat2_str(mm_strdup($$.su), mm_strdup($$.symbol)), mm_strdup(")"));
14712 		}
14713 		| UNION symbol
14714 		{
14715 			$$.su = mm_strdup("union");
14716 			$$.symbol = $2;
14717 		}
14718 		;
14719 
14720 s_struct_union: SQL_STRUCT
14721 		{
14722 			ECPGstruct_sizeof = mm_strdup(""); /* This must not be NULL to distinguish from simple types. */
14723 			$$ = mm_strdup("struct");
14724 		}
14725 		| UNION
14726 		{
14727 			$$ = mm_strdup("union");
14728 		}
14729 		;
14730 
14731 simple_type: unsigned_type					{ $$=$1; }
14732 		|	opt_signed signed_type			{ $$=$2; }
14733 		;
14734 
14735 unsigned_type: SQL_UNSIGNED SQL_SHORT		{ $$ = ECPGt_unsigned_short; }
14736 		| SQL_UNSIGNED SQL_SHORT INT_P	{ $$ = ECPGt_unsigned_short; }
14737 		| SQL_UNSIGNED						{ $$ = ECPGt_unsigned_int; }
14738 		| SQL_UNSIGNED INT_P				{ $$ = ECPGt_unsigned_int; }
14739 		| SQL_UNSIGNED SQL_LONG				{ $$ = ECPGt_unsigned_long; }
14740 		| SQL_UNSIGNED SQL_LONG INT_P		{ $$ = ECPGt_unsigned_long; }
14741 		| SQL_UNSIGNED SQL_LONG SQL_LONG
14742 		{
14743 #ifdef HAVE_LONG_LONG_INT
14744 			$$ = ECPGt_unsigned_long_long;
14745 #else
14746 			$$ = ECPGt_unsigned_long;
14747 #endif
14748 		}
14749 		| SQL_UNSIGNED SQL_LONG SQL_LONG INT_P
14750 		{
14751 #ifdef HAVE_LONG_LONG_INT
14752 			$$ = ECPGt_unsigned_long_long;
14753 #else
14754 			$$ = ECPGt_unsigned_long;
14755 #endif
14756 		}
14757 		| SQL_UNSIGNED CHAR_P			{ $$ = ECPGt_unsigned_char; }
14758 		;
14759 
14760 signed_type: SQL_SHORT				{ $$ = ECPGt_short; }
14761 		| SQL_SHORT INT_P			{ $$ = ECPGt_short; }
14762 		| INT_P						{ $$ = ECPGt_int; }
14763 		| SQL_LONG					{ $$ = ECPGt_long; }
14764 		| SQL_LONG INT_P			{ $$ = ECPGt_long; }
14765 		| SQL_LONG SQL_LONG
14766 		{
14767 #ifdef HAVE_LONG_LONG_INT
14768 			$$ = ECPGt_long_long;
14769 #else
14770 			$$ = ECPGt_long;
14771 #endif
14772 		}
14773 		| SQL_LONG SQL_LONG INT_P
14774 		{
14775 #ifdef HAVE_LONG_LONG_INT
14776 			$$ = ECPGt_long_long;
14777 #else
14778 			$$ = ECPGt_long;
14779 #endif
14780 		}
14781 		| SQL_BOOL					{ $$ = ECPGt_bool; }
14782 		| CHAR_P					{ $$ = ECPGt_char; }
14783 		| DOUBLE_P					{ $$ = ECPGt_double; }
14784 		;
14785 
14786 opt_signed: SQL_SIGNED
14787 		|	/* EMPTY */
14788 		;
14789 
14790 variable_list: variable
14791 			{ $$ = $1; }
14792 		| variable_list ',' variable
14793 		{
14794 			if (actual_type[struct_level].type_enum == ECPGt_varchar)
14795 				$$ = cat_str(3, $1, mm_strdup(";"), $3);
14796 			else
14797 				$$ = cat_str(3, $1, mm_strdup(","), $3);
14798 		}
14799 		;
14800 
14801 variable: opt_pointer ECPGColLabel opt_array_bounds opt_bit_field opt_initializer
14802 		{
14803 			struct ECPGtype * type;
14804 			char *dimension = $3.index1;	/* dimension of array */
14805 			char *length = $3.index2;		/* length of string */
14806 			char *dim_str;
14807 			char *vcn;
14808 
14809 			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);
14810 
14811 			switch (actual_type[struct_level].type_enum)
14812 			{
14813 				case ECPGt_struct:
14814 				case ECPGt_union:
14815 					if (atoi(dimension) < 0)
14816 						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);
14817 					else
14818 						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);
14819 
14820 					$$ = cat_str(5, $1, mm_strdup($2), $3.str, $4, $5);
14821 					break;
14822 
14823 				case ECPGt_varchar:
14824 					if (atoi(dimension) < 0)
14825 						type = ECPGmake_simple_type(actual_type[struct_level].type_enum, length, varchar_counter);
14826 					else
14827 						type = ECPGmake_array_type(ECPGmake_simple_type(actual_type[struct_level].type_enum, length, varchar_counter), dimension);
14828 
14829 					if (strcmp(dimension, "0") == 0 || abs(atoi(dimension)) == 1)
14830 							dim_str=mm_strdup("");
14831 					else
14832 							dim_str=cat_str(3, mm_strdup("["), mm_strdup(dimension), mm_strdup("]"));
14833 					/* cannot check for atoi <= 0 because a defined constant will yield 0 here as well */
14834 					if (atoi(length) < 0 || strcmp(length, "0") == 0)
14835 						mmerror(PARSE_ERROR, ET_ERROR, "pointers to varchar are not implemented");
14836 
14837 					/* make sure varchar struct name is unique by adding a unique counter to its definition */
14838 					vcn = (char *) mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
14839 					sprintf(vcn, "%d", varchar_counter);
14840 					if (strcmp(dimension, "0") == 0)
14841 						$$ = 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);
14842 					else
14843 						$$ = 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);
14844 					varchar_counter++;
14845 					break;
14846 
14847 				case ECPGt_char:
14848 				case ECPGt_unsigned_char:
14849 				case ECPGt_string:
14850 					if (atoi(dimension) == -1)
14851 					{
14852 						int i = strlen($5);
14853 
14854 						if (atoi(length) == -1 && i > 0) /* char <var>[] = "string" */
14855 						{
14856 							/* if we have an initializer but no string size set, let's use the initializer's length */
14857 							free(length);
14858 							length = mm_alloc(i+sizeof("sizeof()"));
14859 							sprintf(length, "sizeof(%s)", $5+2);
14860 						}
14861 						type = ECPGmake_simple_type(actual_type[struct_level].type_enum, length, 0);
14862 					}
14863 					else
14864 						type = ECPGmake_array_type(ECPGmake_simple_type(actual_type[struct_level].type_enum, length, 0), dimension);
14865 
14866 					$$ = cat_str(5, $1, mm_strdup($2), $3.str, $4, $5);
14867 					break;
14868 
14869 				default:
14870 					if (atoi(dimension) < 0)
14871 						type = ECPGmake_simple_type(actual_type[struct_level].type_enum, mm_strdup("1"), 0);
14872 					else
14873 						type = ECPGmake_array_type(ECPGmake_simple_type(actual_type[struct_level].type_enum, mm_strdup("1"), 0), dimension);
14874 
14875 					$$ = cat_str(5, $1, mm_strdup($2), $3.str, $4, $5);
14876 					break;
14877 			}
14878 
14879 			if (struct_level == 0)
14880 				new_variable($2, type, braces_open);
14881 			else
14882 				ECPGmake_struct_member($2, type, &(struct_member_list[struct_level - 1]));
14883 
14884 			free($2);
14885 		}
14886 		;
14887 
14888 opt_initializer: /*EMPTY*/
14889 			{ $$ = EMPTY; }
14890 		| '=' c_term
14891 		{
14892 			initializer = 1;
14893 			$$ = cat2_str(mm_strdup("="), $2);
14894 		}
14895 		;
14896 
14897 opt_pointer: /*EMPTY*/				{ $$ = EMPTY; }
14898 		| '*'						{ $$ = mm_strdup("*"); }
14899 		| '*' '*'					{ $$ = mm_strdup("**"); }
14900 		;
14901 
14902 /*
14903  * We try to simulate the correct DECLARE syntax here so we get dynamic SQL
14904  */
14905 ECPGDeclare: DECLARE STATEMENT ecpg_ident
14906 		{
14907 			/* this is only supported for compatibility */
14908 			$$ = cat_str(3, mm_strdup("/* declare statement"), $3, mm_strdup("*/"));
14909 		}
14910 		;
14911 /*
14912  * the exec sql disconnect statement: disconnect from the given database
14913  */
14914 ECPGDisconnect: SQL_DISCONNECT dis_name { $$ = $2; }
14915 		;
14916 
14917 dis_name: connection_object			{ $$ = $1; }
14918 		| CURRENT_P			{ $$ = mm_strdup("\"CURRENT\""); }
14919 		| ALL				{ $$ = mm_strdup("\"ALL\""); }
14920 		| /* EMPTY */			{ $$ = mm_strdup("\"CURRENT\""); }
14921 		;
14922 
14923 connection_object: database_name		{ $$ = make3_str(mm_strdup("\""), $1, mm_strdup("\"")); }
14924 		| DEFAULT			{ $$ = mm_strdup("\"DEFAULT\""); }
14925 		| char_variable			{ $$ = $1; }
14926 		;
14927 
14928 execstring: char_variable
14929 			{ $$ = $1; }
14930 		|	CSTRING
14931 			{ $$ = make3_str(mm_strdup("\""), $1, mm_strdup("\"")); }
14932 		;
14933 
14934 /*
14935  * the exec sql free command to deallocate a previously
14936  * prepared statement
14937  */
14938 ECPGFree:	SQL_FREE cursor_name	{ $$ = $2; }
14939 		| SQL_FREE ALL	{ $$ = mm_strdup("all"); }
14940 		;
14941 
14942 /*
14943  * open is an open cursor, at the moment this has to be removed
14944  */
14945 ECPGOpen: SQL_OPEN cursor_name opt_ecpg_using
14946 		{
14947 			if ($2[0] == ':')
14948 				remove_variable_from_list(&argsinsert, find_variable($2 + 1));
14949 			$$ = $2;
14950 		}
14951 		;
14952 
14953 opt_ecpg_using: /*EMPTY*/	{ $$ = EMPTY; }
14954 		| ecpg_using		{ $$ = $1; }
14955 		;
14956 
14957 ecpg_using:	USING using_list	{ $$ = EMPTY; }
14958 		| using_descriptor		{ $$ = $1; }
14959 		;
14960 
14961 using_descriptor: USING SQL_P SQL_DESCRIPTOR quoted_ident_stringvar
14962 		{
14963 			add_variable_to_head(&argsinsert, descriptor_variable($4,0), &no_indicator);
14964 			$$ = EMPTY;
14965 		}
14966 		| USING SQL_DESCRIPTOR name
14967 		{
14968 			add_variable_to_head(&argsinsert, sqlda_variable($3), &no_indicator);
14969 			$$ = EMPTY;
14970 		}
14971 		;
14972 
14973 into_descriptor: INTO SQL_P SQL_DESCRIPTOR quoted_ident_stringvar
14974 		{
14975 			add_variable_to_head(&argsresult, descriptor_variable($4,1), &no_indicator);
14976 			$$ = EMPTY;
14977 		}
14978 		| INTO SQL_DESCRIPTOR name
14979 		{
14980 			add_variable_to_head(&argsresult, sqlda_variable($3), &no_indicator);
14981 			$$ = EMPTY;
14982 		}
14983 		;
14984 
14985 into_sqlda: INTO name
14986 		{
14987 			add_variable_to_head(&argsresult, sqlda_variable($2), &no_indicator);
14988 			$$ = EMPTY;
14989 		}
14990 		;
14991 
14992 using_list: UsingValue | UsingValue ',' using_list;
14993 
14994 UsingValue: UsingConst
14995 		{
14996 			char *length = mm_alloc(32);
14997 
14998 			sprintf(length, "%d", (int) strlen($1));
14999 			add_variable_to_head(&argsinsert, new_variable($1, ECPGmake_simple_type(ECPGt_const, length, 0), 0), &no_indicator);
15000 		}
15001 		| civar { $$ = EMPTY; }
15002 		| civarind { $$ = EMPTY; }
15003 		;
15004 
15005 UsingConst: Iconst			{ $$ = $1; }
15006 		| '+' Iconst		{ $$ = cat_str(2, mm_strdup("+"), $2); }
15007 		| '-' Iconst		{ $$ = cat_str(2, mm_strdup("-"), $2); }
15008 		| ecpg_fconst		{ $$ = $1; }
15009 		| '+' ecpg_fconst	{ $$ = cat_str(2, mm_strdup("+"), $2); }
15010 		| '-' ecpg_fconst	{ $$ = cat_str(2, mm_strdup("-"), $2); }
15011 		| ecpg_sconst		{ $$ = $1; }
15012 		| ecpg_bconst		{ $$ = $1; }
15013 		| ecpg_xconst		{ $$ = $1; }
15014 		;
15015 
15016 /*
15017  * We accept DESCRIBE [OUTPUT] but do nothing with DESCRIBE INPUT so far.
15018  */
15019 ECPGDescribe: SQL_DESCRIBE INPUT_P prepared_name using_descriptor
15020 	{
15021 		const char *con = connection ? connection : "NULL";
15022 		mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
15023 		$$ = (char *) mm_alloc(sizeof("1, , ") + strlen(con) + strlen($3));
15024 		sprintf($$, "1, %s, %s", con, $3);
15025 	}
15026 	| SQL_DESCRIBE opt_output prepared_name using_descriptor
15027 	{
15028 		const char *con = connection ? connection : "NULL";
15029 		struct variable *var;
15030 
15031 		var = argsinsert->variable;
15032 		remove_variable_from_list(&argsinsert, var);
15033 		add_variable_to_head(&argsresult, var, &no_indicator);
15034 
15035 		$$ = (char *) mm_alloc(sizeof("0, , ") + strlen(con) + strlen($3));
15036 		sprintf($$, "0, %s, %s", con, $3);
15037 	}
15038 	| SQL_DESCRIBE opt_output prepared_name into_descriptor
15039 	{
15040 		const char *con = connection ? connection : "NULL";
15041 		$$ = (char *) mm_alloc(sizeof("0, , ") + strlen(con) + strlen($3));
15042 		sprintf($$, "0, %s, %s", con, $3);
15043 	}
15044 	| SQL_DESCRIBE INPUT_P prepared_name into_sqlda
15045 	{
15046 		const char *con = connection ? connection : "NULL";
15047 		mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
15048 		$$ = (char *) mm_alloc(sizeof("1, , ") + strlen(con) + strlen($3));
15049 		sprintf($$, "1, %s, %s", con, $3);
15050 	}
15051 	| SQL_DESCRIBE opt_output prepared_name into_sqlda
15052 	{
15053 		const char *con = connection ? connection : "NULL";
15054 		$$ = (char *) mm_alloc(sizeof("0, , ") + strlen(con) + strlen($3));
15055 		sprintf($$, "0, %s, %s", con, $3);
15056 	}
15057 	;
15058 
15059 opt_output:	SQL_OUTPUT	{ $$ = mm_strdup("output"); }
15060 	|	/* EMPTY */	{ $$ = EMPTY; }
15061 	;
15062 
15063 /*
15064  * dynamic SQL: descriptor based access
15065  *	originally written by Christof Petig <christof.petig@wtal.de>
15066  *			and Peter Eisentraut <peter.eisentraut@credativ.de>
15067  */
15068 
15069 /*
15070  * allocate a descriptor
15071  */
15072 ECPGAllocateDescr: SQL_ALLOCATE SQL_DESCRIPTOR quoted_ident_stringvar
15073 		{
15074 			add_descriptor($3,connection);
15075 			$$ = $3;
15076 		}
15077 		;
15078 
15079 
15080 /*
15081  * deallocate a descriptor
15082  */
15083 ECPGDeallocateDescr:	DEALLOCATE SQL_DESCRIPTOR quoted_ident_stringvar
15084 		{
15085 			drop_descriptor($3,connection);
15086 			$$ = $3;
15087 		}
15088 		;
15089 
15090 /*
15091  * manipulate a descriptor header
15092  */
15093 
15094 ECPGGetDescriptorHeader: SQL_GET SQL_DESCRIPTOR quoted_ident_stringvar ECPGGetDescHeaderItems
15095 			{  $$ = $3; }
15096 		;
15097 
15098 ECPGGetDescHeaderItems: ECPGGetDescHeaderItem
15099 		| ECPGGetDescHeaderItems ',' ECPGGetDescHeaderItem
15100 		;
15101 
15102 ECPGGetDescHeaderItem: cvariable '=' desc_header_item
15103 			{ push_assignment($1, $3); }
15104 		;
15105 
15106 
15107 ECPGSetDescriptorHeader: SET SQL_DESCRIPTOR quoted_ident_stringvar ECPGSetDescHeaderItems
15108 			{ $$ = $3; }
15109 		;
15110 
15111 ECPGSetDescHeaderItems: ECPGSetDescHeaderItem
15112 		| ECPGSetDescHeaderItems ',' ECPGSetDescHeaderItem
15113 		;
15114 
15115 ECPGSetDescHeaderItem: desc_header_item '=' IntConstVar
15116 		{
15117 			push_assignment($3, $1);
15118 		}
15119 		;
15120 
15121 IntConstVar: Iconst
15122 		{
15123 			char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
15124 
15125 			sprintf(length, "%d", (int) strlen($1));
15126 			new_variable($1, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
15127 			$$ = $1;
15128 		}
15129 		| cvariable
15130 		{
15131 			$$ = $1;
15132 		}
15133 		;
15134 
15135 desc_header_item:	SQL_COUNT			{ $$ = ECPGd_count; }
15136 		;
15137 
15138 /*
15139  * manipulate a descriptor
15140  */
15141 
15142 ECPGGetDescriptor:	SQL_GET SQL_DESCRIPTOR quoted_ident_stringvar VALUE_P IntConstVar ECPGGetDescItems
15143 			{  $$.str = $5; $$.name = $3; }
15144 		;
15145 
15146 ECPGGetDescItems: ECPGGetDescItem
15147 		| ECPGGetDescItems ',' ECPGGetDescItem
15148 		;
15149 
15150 ECPGGetDescItem: cvariable '=' descriptor_item	{ push_assignment($1, $3); };
15151 
15152 
15153 ECPGSetDescriptor:	SET SQL_DESCRIPTOR quoted_ident_stringvar VALUE_P IntConstVar ECPGSetDescItems
15154 			{  $$.str = $5; $$.name = $3; }
15155 		;
15156 
15157 ECPGSetDescItems: ECPGSetDescItem
15158 		| ECPGSetDescItems ',' ECPGSetDescItem
15159 		;
15160 
15161 ECPGSetDescItem: descriptor_item '=' AllConstVar
15162 		{
15163 			push_assignment($3, $1);
15164 		}
15165 		;
15166 
15167 AllConstVar: ecpg_fconst
15168 		{
15169 			char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
15170 
15171 			sprintf(length, "%d", (int) strlen($1));
15172 			new_variable($1, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
15173 			$$ = $1;
15174 		}
15175 
15176 		| IntConstVar
15177 		{
15178 			$$ = $1;
15179 		}
15180 
15181 		| '-' ecpg_fconst
15182 		{
15183 			char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
15184 			char *var = cat2_str(mm_strdup("-"), $2);
15185 
15186 			sprintf(length, "%d", (int) strlen(var));
15187 			new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
15188 			$$ = var;
15189 		}
15190 
15191 		| '-' Iconst
15192 		{
15193 			char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
15194 			char *var = cat2_str(mm_strdup("-"), $2);
15195 
15196 			sprintf(length, "%d", (int) strlen(var));
15197 			new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
15198 			$$ = var;
15199 		}
15200 
15201 		| ecpg_sconst
15202 		{
15203 			char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
15204 			char *var = $1 + 1;
15205 
15206 			var[strlen(var) - 1] = '\0';
15207 			sprintf(length, "%d", (int) strlen(var));
15208 			new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
15209 			$$ = var;
15210 		}
15211 		;
15212 
15213 descriptor_item:	SQL_CARDINALITY			{ $$ = ECPGd_cardinality; }
15214 		| DATA_P				{ $$ = ECPGd_data; }
15215 		| SQL_DATETIME_INTERVAL_CODE		{ $$ = ECPGd_di_code; }
15216 		| SQL_DATETIME_INTERVAL_PRECISION	{ $$ = ECPGd_di_precision; }
15217 		| SQL_INDICATOR				{ $$ = ECPGd_indicator; }
15218 		| SQL_KEY_MEMBER			{ $$ = ECPGd_key_member; }
15219 		| SQL_LENGTH				{ $$ = ECPGd_length; }
15220 		| NAME_P				{ $$ = ECPGd_name; }
15221 		| SQL_NULLABLE				{ $$ = ECPGd_nullable; }
15222 		| SQL_OCTET_LENGTH			{ $$ = ECPGd_octet; }
15223 		| PRECISION				{ $$ = ECPGd_precision; }
15224 		| SQL_RETURNED_LENGTH			{ $$ = ECPGd_length; }
15225 		| SQL_RETURNED_OCTET_LENGTH		{ $$ = ECPGd_ret_octet; }
15226 		| SQL_SCALE				{ $$ = ECPGd_scale; }
15227 		| TYPE_P				{ $$ = ECPGd_type; }
15228 		;
15229 
15230 /*
15231  * set/reset the automatic transaction mode, this needs a different handling
15232  * as the other set commands
15233  */
15234 ECPGSetAutocommit:	SET SQL_AUTOCOMMIT '=' on_off	{ $$ = $4; }
15235 		|  SET SQL_AUTOCOMMIT TO on_off   { $$ = $4; }
15236 		;
15237 
15238 on_off: ON				{ $$ = mm_strdup("on"); }
15239 		| OFF			{ $$ = mm_strdup("off"); }
15240 		;
15241 
15242 /*
15243  * set the actual connection, this needs a different handling as the other
15244  * set commands
15245  */
15246 ECPGSetConnection:	SET CONNECTION TO connection_object { $$ = $4; }
15247 		| SET CONNECTION '=' connection_object { $$ = $4; }
15248 		| SET CONNECTION  connection_object { $$ = $3; }
15249 		;
15250 
15251 /*
15252  * define a new type for embedded SQL
15253  */
15254 ECPGTypedef: TYPE_P
15255 		{
15256 			/* reset this variable so we see if there was */
15257 			/* an initializer specified */
15258 			initializer = 0;
15259 		}
15260 		ECPGColLabelCommon IS var_type opt_array_bounds opt_reference
15261 		{
15262 			add_typedef($3, $6.index1, $6.index2, $5.type_enum, $5.type_dimension, $5.type_index, initializer, *$7 ? 1 : 0);
15263 
15264 			if (auto_create_c == false)
15265 				$$ = 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("*/"));
15266 			else
15267 				$$ = 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(";"));
15268 		}
15269 		;
15270 
15271 opt_reference: SQL_REFERENCE		{ $$ = mm_strdup("reference"); }
15272 		| /*EMPTY*/					{ $$ = EMPTY; }
15273 		;
15274 
15275 /*
15276  * define the type of one variable for embedded SQL
15277  */
15278 ECPGVar: SQL_VAR
15279 		{
15280 			/* reset this variable so we see if there was */
15281 			/* an initializer specified */
15282 			initializer = 0;
15283 		}
15284 		ColLabel IS var_type opt_array_bounds opt_reference
15285 		{
15286 			struct variable *p = find_variable($3);
15287 			char *dimension = $6.index1;
15288 			char *length = $6.index2;
15289 			struct ECPGtype * type;
15290 
15291 			if (($5.type_enum == ECPGt_struct ||
15292 				 $5.type_enum == ECPGt_union) &&
15293 				initializer == 1)
15294 				mmerror(PARSE_ERROR, ET_ERROR, "initializer not allowed in EXEC SQL VAR command");
15295 			else
15296 			{
15297 				adjust_array($5.type_enum, &dimension, &length, $5.type_dimension, $5.type_index, *$7?1:0, false);
15298 
15299 				switch ($5.type_enum)
15300 				{
15301 					case ECPGt_struct:
15302 					case ECPGt_union:
15303 						if (atoi(dimension) < 0)
15304 							type = ECPGmake_struct_type(struct_member_list[struct_level], $5.type_enum, $5.type_str, $5.type_sizeof);
15305 						else
15306 							type = ECPGmake_array_type(ECPGmake_struct_type(struct_member_list[struct_level], $5.type_enum, $5.type_str, $5.type_sizeof), dimension);
15307 						break;
15308 
15309 					case ECPGt_varchar:
15310 						if (atoi(dimension) == -1)
15311 							type = ECPGmake_simple_type($5.type_enum, length, 0);
15312 						else
15313 							type = ECPGmake_array_type(ECPGmake_simple_type($5.type_enum, length, 0), dimension);
15314 						break;
15315 
15316 					case ECPGt_char:
15317 					case ECPGt_unsigned_char:
15318 					case ECPGt_string:
15319 						if (atoi(dimension) == -1)
15320 							type = ECPGmake_simple_type($5.type_enum, length, 0);
15321 						else
15322 							type = ECPGmake_array_type(ECPGmake_simple_type($5.type_enum, length, 0), dimension);
15323 						break;
15324 
15325 					default:
15326 						if (atoi(length) >= 0)
15327 							mmerror(PARSE_ERROR, ET_ERROR, "multidimensional arrays for simple data types are not supported");
15328 
15329 						if (atoi(dimension) < 0)
15330 							type = ECPGmake_simple_type($5.type_enum, mm_strdup("1"), 0);
15331 						else
15332 							type = ECPGmake_array_type(ECPGmake_simple_type($5.type_enum, mm_strdup("1"), 0), dimension);
15333 						break;
15334 				}
15335 
15336 				ECPGfree_type(p->type);
15337 				p->type = type;
15338 			}
15339 
15340 			$$ = 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("*/"));
15341 		}
15342 		;
15343 
15344 /*
15345  * whenever statement: decide what to do in case of error/no data found
15346  * according to SQL standards we lack: SQLSTATE, CONSTRAINT and SQLEXCEPTION
15347  */
15348 ECPGWhenever: SQL_WHENEVER SQL_SQLERROR action
15349 		{
15350 			when_error.code = $<action>3.code;
15351 			when_error.command = $<action>3.command;
15352 			$$ = cat_str(3, mm_strdup("/* exec sql whenever sqlerror "), $3.str, mm_strdup("; */"));
15353 		}
15354 		| SQL_WHENEVER NOT SQL_FOUND action
15355 		{
15356 			when_nf.code = $<action>4.code;
15357 			when_nf.command = $<action>4.command;
15358 			$$ = cat_str(3, mm_strdup("/* exec sql whenever not found "), $4.str, mm_strdup("; */"));
15359 		}
15360 		| SQL_WHENEVER SQL_SQLWARNING action
15361 		{
15362 			when_warn.code = $<action>3.code;
15363 			when_warn.command = $<action>3.command;
15364 			$$ = cat_str(3, mm_strdup("/* exec sql whenever sql_warning "), $3.str, mm_strdup("; */"));
15365 		}
15366 		;
15367 
15368 action : CONTINUE_P
15369 		{
15370 			$<action>$.code = W_NOTHING;
15371 			$<action>$.command = NULL;
15372 			$<action>$.str = mm_strdup("continue");
15373 		}
15374 		| SQL_SQLPRINT
15375 		{
15376 			$<action>$.code = W_SQLPRINT;
15377 			$<action>$.command = NULL;
15378 			$<action>$.str = mm_strdup("sqlprint");
15379 		}
15380 		| SQL_STOP
15381 		{
15382 			$<action>$.code = W_STOP;
15383 			$<action>$.command = NULL;
15384 			$<action>$.str = mm_strdup("stop");
15385 		}
15386 		| SQL_GOTO name
15387 		{
15388 			$<action>$.code = W_GOTO;
15389 			$<action>$.command = mm_strdup($2);
15390 			$<action>$.str = cat2_str(mm_strdup("goto "), $2);
15391 		}
15392 		| SQL_GO TO name
15393 		{
15394 			$<action>$.code = W_GOTO;
15395 			$<action>$.command = mm_strdup($3);
15396 			$<action>$.str = cat2_str(mm_strdup("goto "), $3);
15397 		}
15398 		| DO name '(' c_args ')'
15399 		{
15400 			$<action>$.code = W_DO;
15401 			$<action>$.command = cat_str(4, $2, mm_strdup("("), $4, mm_strdup(")"));
15402 			$<action>$.str = cat2_str(mm_strdup("do"), mm_strdup($<action>$.command));
15403 		}
15404 		| DO SQL_BREAK
15405 		{
15406 			$<action>$.code = W_BREAK;
15407 			$<action>$.command = NULL;
15408 			$<action>$.str = mm_strdup("break");
15409 		}
15410 		| SQL_CALL name '(' c_args ')'
15411 		{
15412 			$<action>$.code = W_DO;
15413 			$<action>$.command = cat_str(4, $2, mm_strdup("("), $4, mm_strdup(")"));
15414 			$<action>$.str = cat2_str(mm_strdup("call"), mm_strdup($<action>$.command));
15415 		}
15416 		| SQL_CALL name
15417 		{
15418 			$<action>$.code = W_DO;
15419 			$<action>$.command = cat2_str($2, mm_strdup("()"));
15420 			$<action>$.str = cat2_str(mm_strdup("call"), mm_strdup($<action>$.command));
15421 		}
15422 		;
15423 
15424 /* some other stuff for ecpg */
15425 
15426 /* additional unreserved keywords */
15427 ECPGKeywords: ECPGKeywords_vanames	{ $$ = $1; }
15428 		| ECPGKeywords_rest	{ $$ = $1; }
15429 		;
15430 
15431 ECPGKeywords_vanames:  SQL_BREAK		{ $$ = mm_strdup("break"); }
15432 		| SQL_CALL						{ $$ = mm_strdup("call"); }
15433 		| SQL_CARDINALITY				{ $$ = mm_strdup("cardinality"); }
15434 		| SQL_COUNT						{ $$ = mm_strdup("count"); }
15435 		| SQL_DATETIME_INTERVAL_CODE	{ $$ = mm_strdup("datetime_interval_code"); }
15436 		| SQL_DATETIME_INTERVAL_PRECISION	{ $$ = mm_strdup("datetime_interval_precision"); }
15437 		| SQL_FOUND						{ $$ = mm_strdup("found"); }
15438 		| SQL_GO						{ $$ = mm_strdup("go"); }
15439 		| SQL_GOTO						{ $$ = mm_strdup("goto"); }
15440 		| SQL_IDENTIFIED				{ $$ = mm_strdup("identified"); }
15441 		| SQL_INDICATOR				{ $$ = mm_strdup("indicator"); }
15442 		| SQL_KEY_MEMBER			{ $$ = mm_strdup("key_member"); }
15443 		| SQL_LENGTH				{ $$ = mm_strdup("length"); }
15444 		| SQL_NULLABLE				{ $$ = mm_strdup("nullable"); }
15445 		| SQL_OCTET_LENGTH			{ $$ = mm_strdup("octet_length"); }
15446 		| SQL_RETURNED_LENGTH		{ $$ = mm_strdup("returned_length"); }
15447 		| SQL_RETURNED_OCTET_LENGTH	{ $$ = mm_strdup("returned_octet_length"); }
15448 		| SQL_SCALE					{ $$ = mm_strdup("scale"); }
15449 		| SQL_SECTION				{ $$ = mm_strdup("section"); }
15450 		| SQL_SQLERROR				{ $$ = mm_strdup("sqlerror"); }
15451 		| SQL_SQLPRINT				{ $$ = mm_strdup("sqlprint"); }
15452 		| SQL_SQLWARNING			{ $$ = mm_strdup("sqlwarning"); }
15453 		| SQL_STOP					{ $$ = mm_strdup("stop"); }
15454 		;
15455 
15456 ECPGKeywords_rest:  SQL_CONNECT		{ $$ = mm_strdup("connect"); }
15457 		| SQL_DESCRIBE				{ $$ = mm_strdup("describe"); }
15458 		| SQL_DISCONNECT			{ $$ = mm_strdup("disconnect"); }
15459 		| SQL_OPEN					{ $$ = mm_strdup("open"); }
15460 		| SQL_VAR					{ $$ = mm_strdup("var"); }
15461 		| SQL_WHENEVER				{ $$ = mm_strdup("whenever"); }
15462 		;
15463 
15464 /* additional keywords that can be SQL type names (but not ECPGColLabels) */
15465 ECPGTypeName:  SQL_BOOL				{ $$ = mm_strdup("bool"); }
15466 		| SQL_LONG					{ $$ = mm_strdup("long"); }
15467 		| SQL_OUTPUT				{ $$ = mm_strdup("output"); }
15468 		| SQL_SHORT					{ $$ = mm_strdup("short"); }
15469 		| SQL_STRUCT				{ $$ = mm_strdup("struct"); }
15470 		| SQL_SIGNED				{ $$ = mm_strdup("signed"); }
15471 		| SQL_UNSIGNED				{ $$ = mm_strdup("unsigned"); }
15472 		;
15473 
15474 symbol: ColLabel					{ $$ = $1; }
15475 		;
15476 
15477 ECPGColId: ecpg_ident				{ $$ = $1; }
15478 		| unreserved_keyword		{ $$ = $1; }
15479 		| col_name_keyword			{ $$ = $1; }
15480 		| ECPGunreserved_interval	{ $$ = $1; }
15481 		| ECPGKeywords				{ $$ = $1; }
15482 		| ECPGCKeywords				{ $$ = $1; }
15483 		| CHAR_P					{ $$ = mm_strdup("char"); }
15484 		| VALUES					{ $$ = mm_strdup("values"); }
15485 		;
15486 
15487 /*
15488  * Name classification hierarchy.
15489  *
15490  * These productions should match those in the core grammar, except that
15491  * we use all_unreserved_keyword instead of unreserved_keyword, and
15492  * where possible include ECPG keywords as well as core keywords.
15493  */
15494 
15495 /* Column identifier --- names that can be column, table, etc names.
15496  */
15497 ColId:	ecpg_ident					{ $$ = $1; }
15498 		| all_unreserved_keyword	{ $$ = $1; }
15499 		| col_name_keyword			{ $$ = $1; }
15500 		| ECPGKeywords				{ $$ = $1; }
15501 		| ECPGCKeywords				{ $$ = $1; }
15502 		| CHAR_P					{ $$ = mm_strdup("char"); }
15503 		| VALUES					{ $$ = mm_strdup("values"); }
15504 		;
15505 
15506 /* Type/function identifier --- names that can be type or function names.
15507  */
15508 type_function_name:	ecpg_ident		{ $$ = $1; }
15509 		| all_unreserved_keyword	{ $$ = $1; }
15510 		| type_func_name_keyword	{ $$ = $1; }
15511 		| ECPGKeywords				{ $$ = $1; }
15512 		| ECPGCKeywords				{ $$ = $1; }
15513 		| ECPGTypeName				{ $$ = $1; }
15514 		;
15515 
15516 /* Column label --- allowed labels in "AS" clauses.
15517  * This presently includes *all* Postgres keywords.
15518  */
15519 ColLabel:  ECPGColLabel				{ $$ = $1; }
15520 		| ECPGTypeName				{ $$ = $1; }
15521 		| CHAR_P					{ $$ = mm_strdup("char"); }
15522 		| CURRENT_P					{ $$ = mm_strdup("current"); }
15523 		| INPUT_P					{ $$ = mm_strdup("input"); }
15524 		| INT_P						{ $$ = mm_strdup("int"); }
15525 		| TO						{ $$ = mm_strdup("to"); }
15526 		| UNION						{ $$ = mm_strdup("union"); }
15527 		| VALUES					{ $$ = mm_strdup("values"); }
15528 		| ECPGCKeywords				{ $$ = $1; }
15529 		| ECPGunreserved_interval	{ $$ = $1; }
15530 		;
15531 
15532 ECPGColLabel:  ECPGColLabelCommon	{ $$ = $1; }
15533 		| unreserved_keyword		{ $$ = $1; }
15534 		| reserved_keyword			{ $$ = $1; }
15535 		| ECPGKeywords_rest			{ $$ = $1; }
15536 		| CONNECTION				{ $$ = mm_strdup("connection"); }
15537 		;
15538 
15539 ECPGColLabelCommon:  ecpg_ident		{ $$ = $1; }
15540 		| col_name_keyword			{ $$ = $1; }
15541 		| type_func_name_keyword	{ $$ = $1; }
15542 		| ECPGKeywords_vanames		{ $$ = $1; }
15543 		;
15544 
15545 ECPGCKeywords: S_AUTO				{ $$ = mm_strdup("auto"); }
15546 		| S_CONST					{ $$ = mm_strdup("const"); }
15547 		| S_EXTERN					{ $$ = mm_strdup("extern"); }
15548 		| S_REGISTER				{ $$ = mm_strdup("register"); }
15549 		| S_STATIC					{ $$ = mm_strdup("static"); }
15550 		| S_TYPEDEF					{ $$ = mm_strdup("typedef"); }
15551 		| S_VOLATILE				{ $$ = mm_strdup("volatile"); }
15552 		;
15553 
15554 /* "Unreserved" keywords --- available for use as any kind of name.
15555  */
15556 
15557 /*
15558  * The following symbols must be excluded from ECPGColLabel and directly
15559  * included into ColLabel to enable C variables to get names from ECPGColLabel:
15560  * DAY_P, HOUR_P, MINUTE_P, MONTH_P, SECOND_P, YEAR_P.
15561  *
15562  * We also have to exclude CONNECTION, CURRENT, and INPUT for various reasons.
15563  * CONNECTION can be added back in all_unreserved_keyword, but CURRENT and
15564  * INPUT are reserved for ecpg purposes.
15565  *
15566  * The mentioned exclusions are done by $replace_line settings in parse.pl.
15567  */
15568 all_unreserved_keyword: unreserved_keyword	{ $$ = $1; }
15569 		| ECPGunreserved_interval			{ $$ = $1; }
15570 		| CONNECTION						{ $$ = mm_strdup("connection"); }
15571 		;
15572 
15573 ECPGunreserved_interval: DAY_P				{ $$ = mm_strdup("day"); }
15574 		| HOUR_P							{ $$ = mm_strdup("hour"); }
15575 		| MINUTE_P							{ $$ = mm_strdup("minute"); }
15576 		| MONTH_P							{ $$ = mm_strdup("month"); }
15577 		| SECOND_P							{ $$ = mm_strdup("second"); }
15578 		| YEAR_P							{ $$ = mm_strdup("year"); }
15579 		;
15580 
15581 
15582 into_list : coutputvariable | into_list ',' coutputvariable
15583 		;
15584 
15585 ecpgstart: SQL_START	{
15586 				reset_variables();
15587 				pacounter = 1;
15588 			}
15589 		;
15590 
15591 c_args: /*EMPTY*/		{ $$ = EMPTY; }
15592 		| c_list		{ $$ = $1; }
15593 		;
15594 
15595 coutputvariable: cvariable indicator
15596 			{ add_variable_to_head(&argsresult, find_variable($1), find_variable($2)); }
15597 		| cvariable
15598 			{ add_variable_to_head(&argsresult, find_variable($1), &no_indicator); }
15599 		;
15600 
15601 
15602 civarind: cvariable indicator
15603 		{
15604 			if (find_variable($2)->type->type == ECPGt_array)
15605 				mmerror(PARSE_ERROR, ET_ERROR, "arrays of indicators are not allowed on input");
15606 
15607 			add_variable_to_head(&argsinsert, find_variable($1), find_variable($2));
15608 			$$ = create_questionmarks($1, false);
15609 		}
15610 		;
15611 
15612 char_civar: char_variable
15613 		{
15614 			char *ptr = strstr($1, ".arr");
15615 
15616 			if (ptr) /* varchar, we need the struct name here, not the struct element */
15617 				*ptr = '\0';
15618 			add_variable_to_head(&argsinsert, find_variable($1), &no_indicator);
15619 			$$ = $1;
15620 		}
15621 		;
15622 
15623 civar: cvariable
15624 		{
15625 			add_variable_to_head(&argsinsert, find_variable($1), &no_indicator);
15626 			$$ = create_questionmarks($1, false);
15627 		}
15628 		;
15629 
15630 indicator: cvariable				{ check_indicator((find_variable($1))->type); $$ = $1; }
15631 		| SQL_INDICATOR cvariable	{ check_indicator((find_variable($2))->type); $$ = $2; }
15632 		| SQL_INDICATOR name		{ check_indicator((find_variable($2))->type); $$ = $2; }
15633 		;
15634 
15635 cvariable:	CVARIABLE
15636 		{
15637 			/* As long as multidimensional arrays are not implemented we have to check for those here */
15638 			char *ptr = $1;
15639 			int brace_open=0, brace = false;
15640 
15641 			for (; *ptr; ptr++)
15642 			{
15643 				switch (*ptr)
15644 				{
15645 					case '[':
15646 							if (brace)
15647 								mmfatal(PARSE_ERROR, "multidimensional arrays for simple data types are not supported");
15648 							brace_open++;
15649 							break;
15650 					case ']':
15651 							brace_open--;
15652 							if (brace_open == 0)
15653 								brace = true;
15654 							break;
15655 					case '\t':
15656 					case ' ':
15657 							break;
15658 					default:
15659 							if (brace_open == 0)
15660 								brace = false;
15661 							break;
15662 				}
15663 			}
15664 			$$ = $1;
15665 		}
15666 		;
15667 
15668 ecpg_param:	PARAM		{ $$ = make_name(); } ;
15669 
15670 ecpg_bconst:	BCONST		{ $$ = make_name(); } ;
15671 
15672 ecpg_fconst:	FCONST		{ $$ = make_name(); } ;
15673 
15674 ecpg_sconst:
15675 		SCONST
15676 		{
15677 			/* could have been input as '' or $$ */
15678 			$$ = (char *)mm_alloc(strlen($1) + 3);
15679 			$$[0]='\'';
15680 			strcpy($$+1, $1);
15681 			$$[strlen($1)+1]='\'';
15682 			$$[strlen($1)+2]='\0';
15683 			free($1);
15684 		}
15685 		| ECONST
15686 		{
15687 			$$ = (char *)mm_alloc(strlen($1) + 4);
15688 			$$[0]='E';
15689 			$$[1]='\'';
15690 			strcpy($$+2, $1);
15691 			$$[strlen($1)+2]='\'';
15692 			$$[strlen($1)+3]='\0';
15693 			free($1);
15694 		}
15695 		| NCONST
15696 		{
15697 			$$ = (char *)mm_alloc(strlen($1) + 4);
15698 			$$[0]='N';
15699 			$$[1]='\'';
15700 			strcpy($$+2, $1);
15701 			$$[strlen($1)+2]='\'';
15702 			$$[strlen($1)+3]='\0';
15703 			free($1);
15704 		}
15705 		| UCONST	{ $$ = $1; }
15706 		| DOLCONST	{ $$ = $1; }
15707 		;
15708 
15709 ecpg_xconst:	XCONST		{ $$ = make_name(); } ;
15710 
15711 ecpg_ident:	IDENT		{ $$ = make_name(); }
15712 		| CSTRING	{ $$ = make3_str(mm_strdup("\""), $1, mm_strdup("\"")); }
15713 		| UIDENT	{ $$ = $1; }
15714 		;
15715 
15716 quoted_ident_stringvar: name
15717 			{ $$ = make3_str(mm_strdup("\""), $1, mm_strdup("\"")); }
15718 		| char_variable
15719 			{ $$ = make3_str(mm_strdup("("), $1, mm_strdup(")")); }
15720 		;
15721 
15722 /*
15723  * C stuff
15724  */
15725 
15726 c_stuff_item: c_anything			{ $$ = $1; }
15727 		| '(' ')'			{ $$ = mm_strdup("()"); }
15728 		| '(' c_stuff ')'
15729 			{ $$ = cat_str(3, mm_strdup("("), $2, mm_strdup(")")); }
15730 		;
15731 
15732 c_stuff: c_stuff_item			{ $$ = $1; }
15733 		| c_stuff c_stuff_item
15734 			{ $$ = cat2_str($1, $2); }
15735 		;
15736 
15737 c_list: c_term				{ $$ = $1; }
15738 		| c_list ',' c_term	{ $$ = cat_str(3, $1, mm_strdup(","), $3); }
15739 		;
15740 
15741 c_term:  c_stuff			{ $$ = $1; }
15742 		| '{' c_list '}'	{ $$ = cat_str(3, mm_strdup("{"), $2, mm_strdup("}")); }
15743 		;
15744 
15745 c_thing:	c_anything		{ $$ = $1; }
15746 		|	'('		{ $$ = mm_strdup("("); }
15747 		|	')'		{ $$ = mm_strdup(")"); }
15748 		|	','		{ $$ = mm_strdup(","); }
15749 		|	';'		{ $$ = mm_strdup(";"); }
15750 		;
15751 
15752 c_anything:  ecpg_ident				{ $$ = $1; }
15753 		| Iconst			{ $$ = $1; }
15754 		| ecpg_fconst			{ $$ = $1; }
15755 		| ecpg_sconst			{ $$ = $1; }
15756 		| '*'				{ $$ = mm_strdup("*"); }
15757 		| '+'				{ $$ = mm_strdup("+"); }
15758 		| '-'				{ $$ = mm_strdup("-"); }
15759 		| '/'				{ $$ = mm_strdup("/"); }
15760 		| '%'				{ $$ = mm_strdup("%"); }
15761 		| NULL_P			{ $$ = mm_strdup("NULL"); }
15762 		| S_ADD				{ $$ = mm_strdup("+="); }
15763 		| S_AND				{ $$ = mm_strdup("&&"); }
15764 		| S_ANYTHING			{ $$ = make_name(); }
15765 		| S_AUTO			{ $$ = mm_strdup("auto"); }
15766 		| S_CONST			{ $$ = mm_strdup("const"); }
15767 		| S_DEC				{ $$ = mm_strdup("--"); }
15768 		| S_DIV				{ $$ = mm_strdup("/="); }
15769 		| S_DOTPOINT			{ $$ = mm_strdup(".*"); }
15770 		| S_EQUAL			{ $$ = mm_strdup("=="); }
15771 		| S_EXTERN			{ $$ = mm_strdup("extern"); }
15772 		| S_INC				{ $$ = mm_strdup("++"); }
15773 		| S_LSHIFT			{ $$ = mm_strdup("<<"); }
15774 		| S_MEMBER			{ $$ = mm_strdup("->"); }
15775 		| S_MEMPOINT			{ $$ = mm_strdup("->*"); }
15776 		| S_MOD				{ $$ = mm_strdup("%="); }
15777 		| S_MUL				{ $$ = mm_strdup("*="); }
15778 		| S_NEQUAL			{ $$ = mm_strdup("!="); }
15779 		| S_OR				{ $$ = mm_strdup("||"); }
15780 		| S_REGISTER			{ $$ = mm_strdup("register"); }
15781 		| S_RSHIFT			{ $$ = mm_strdup(">>"); }
15782 		| S_STATIC			{ $$ = mm_strdup("static"); }
15783 		| S_SUB				{ $$ = mm_strdup("-="); }
15784 		| S_TYPEDEF			{ $$ = mm_strdup("typedef"); }
15785 		| S_VOLATILE			{ $$ = mm_strdup("volatile"); }
15786 		| SQL_BOOL			{ $$ = mm_strdup("bool"); }
15787 		| ENUM_P			{ $$ = mm_strdup("enum"); }
15788 		| HOUR_P			{ $$ = mm_strdup("hour"); }
15789 		| INT_P				{ $$ = mm_strdup("int"); }
15790 		| SQL_LONG			{ $$ = mm_strdup("long"); }
15791 		| MINUTE_P			{ $$ = mm_strdup("minute"); }
15792 		| MONTH_P			{ $$ = mm_strdup("month"); }
15793 		| SECOND_P			{ $$ = mm_strdup("second"); }
15794 		| SQL_SHORT			{ $$ = mm_strdup("short"); }
15795 		| SQL_SIGNED			{ $$ = mm_strdup("signed"); }
15796 		| SQL_STRUCT			{ $$ = mm_strdup("struct"); }
15797 		| SQL_UNSIGNED			{ $$ = mm_strdup("unsigned"); }
15798 		| YEAR_P			{ $$ = mm_strdup("year"); }
15799 		| CHAR_P			{ $$ = mm_strdup("char"); }
15800 		| FLOAT_P			{ $$ = mm_strdup("float"); }
15801 		| TO				{ $$ = mm_strdup("to"); }
15802 		| UNION				{ $$ = mm_strdup("union"); }
15803 		| VARCHAR			{ $$ = mm_strdup("varchar"); }
15804 		| '['				{ $$ = mm_strdup("["); }
15805 		| ']'				{ $$ = mm_strdup("]"); }
15806 		| '='				{ $$ = mm_strdup("="); }
15807 		| ':'				{ $$ = mm_strdup(":"); }
15808 		;
15809 
15810 DeallocateStmt: DEALLOCATE prepared_name                { $$ = $2; }
15811                 | DEALLOCATE PREPARE prepared_name      { $$ = $3; }
15812                 | DEALLOCATE ALL                        { $$ = mm_strdup("all"); }
15813                 | DEALLOCATE PREPARE ALL                { $$ = mm_strdup("all"); }
15814                 ;
15815 
15816 Iresult:        Iconst				{ $$ = $1; }
15817                 | '(' Iresult ')'		{ $$ = cat_str(3, mm_strdup("("), $2, mm_strdup(")")); }
15818                 | Iresult '+' Iresult		{ $$ = cat_str(3, $1, mm_strdup("+"), $3); }
15819                 | Iresult '-' Iresult		{ $$ = cat_str(3, $1, mm_strdup("-"), $3); }
15820                 | Iresult '*' Iresult		{ $$ = cat_str(3, $1, mm_strdup("*"), $3); }
15821                 | Iresult '/' Iresult		{ $$ = cat_str(3, $1, mm_strdup("/"), $3); }
15822                 | Iresult '%' Iresult		{ $$ = cat_str(3, $1, mm_strdup("%"), $3); }
15823                 | ecpg_sconst			{ $$ = $1; }
15824                 | ColId				{ $$ = $1; }
15825 		| ColId '(' var_type ')'        { if (pg_strcasecmp($1, "sizeof") != 0)
15826 							mmerror(PARSE_ERROR, ET_ERROR, "operator not allowed in variable definition");
15827 						  else
15828 							$$ = cat_str(4, $1, mm_strdup("("), $3.type_str, mm_strdup(")"));
15829 						}
15830                 ;
15831 
15832 execute_rest: /* EMPTY */	{ $$ = EMPTY; }
15833 	| ecpg_using opt_ecpg_into  { $$ = EMPTY; }
15834 	| ecpg_into ecpg_using  { $$ = EMPTY; }
15835 	| ecpg_into				{ $$ = EMPTY; }
15836 	;
15837 
15838 ecpg_into: INTO into_list	{ $$ = EMPTY; }
15839 	| into_descriptor		{ $$ = $1; }
15840 	;
15841 
15842 opt_ecpg_into:	/* EMPTY */	{ $$ = EMPTY; }
15843 	| ecpg_into		{ $$ = $1; }
15844 	;
15845 
15846 ecpg_fetch_into: ecpg_into	{ $$ = $1; }
15847 	| using_descriptor
15848 	{
15849 		struct variable *var;
15850 
15851 		var = argsinsert->variable;
15852 		remove_variable_from_list(&argsinsert, var);
15853 		add_variable_to_head(&argsresult, var, &no_indicator);
15854 		$$ = $1;
15855 	}
15856 	;
15857 
15858 opt_ecpg_fetch_into:	/* EMPTY */	{ $$ = EMPTY; }
15859 	| ecpg_fetch_into		{ $$ = $1; }
15860 	;
15861 
15862 %%
15863 
15864 void base_yyerror(const char *error)
15865 {
15866 	/* translator: %s is typically the translation of "syntax error" */
15867 	mmerror(PARSE_ERROR, ET_ERROR, "%s at or near \"%s\"",
15868 			_(error), token_start ? token_start : base_yytext);
15869 }
15870 
parser_init(void)15871 void parser_init(void)
15872 {
15873  /* This function is empty. It only exists for compatibility with the backend parser right now. */
15874 }
15875