PostgreSQL Source Code git master
type.c
Go to the documentation of this file.
1/* src/interfaces/ecpg/preproc/type.c */
2
3#include "postgres_fe.h"
4
5#include "preproc_extern.h"
6
7#define indicator_set ind_type != NULL && ind_type->type != ECPGt_NO_INDICATOR
8
9static struct ECPGstruct_member struct_no_indicator = {"no_indicator", &ecpg_no_indicator, NULL};
10
11/* duplicate memberlist */
12struct ECPGstruct_member *
14{
15 struct ECPGstruct_member *new = NULL;
16
17 while (rm)
18 {
19 struct ECPGtype *type;
20
21 switch (rm->type->type)
22 {
23 case ECPGt_struct:
24 case ECPGt_union:
26 break;
27 case ECPGt_array:
28
29 /*
30 * if this array does contain a struct again, we have to
31 * create the struct too
32 */
33 if (rm->type->u.element->type == ECPGt_struct || rm->type->u.element->type == ECPGt_union)
35 else
37 break;
38 default:
40 break;
41 }
42
44
45 rm = rm->next;
46 }
47
48 return new;
49}
50
51/* The NAME argument is copied. The type argument is preserved as a pointer. */
52void
54{
55 struct ECPGstruct_member *ptr,
56 *ne =
57 (struct ECPGstruct_member *) mm_alloc(sizeof(struct ECPGstruct_member));
58
59 ne->name = mm_strdup(name);
60 ne->type = type;
61 ne->next = NULL;
62
63 for (ptr = *start; ptr && ptr->next; ptr = ptr->next);
64
65 if (ptr)
66 ptr->next = ne;
67 else
68 *start = ne;
69}
70
71struct ECPGtype *
73{
74 struct ECPGtype *ne = (struct ECPGtype *) mm_alloc(sizeof(struct ECPGtype));
75
76 ne->type = type;
77 ne->type_name = NULL;
78 ne->size = mm_strdup(size);
79 ne->u.element = NULL;
80 ne->struct_sizeof = NULL;
81 ne->counter = counter; /* only needed for varchar and bytea */
82
83 return ne;
84}
85
86struct ECPGtype *
88{
90
91 ne->u.element = type;
92
93 return ne;
94}
95
96struct ECPGtype *
98 const char *type_name, const char *struct_sizeof)
99{
100 struct ECPGtype *ne = ECPGmake_simple_type(type, "1", 0);
101
105
106 return ne;
107}
108
109static const char *
111{
112 switch (type)
113 {
114 case ECPGt_char:
115 return "ECPGt_char";
116 break;
118 return "ECPGt_unsigned_char";
119 break;
120 case ECPGt_short:
121 return "ECPGt_short";
122 break;
124 return "ECPGt_unsigned_short";
125 break;
126 case ECPGt_int:
127 return "ECPGt_int";
128 break;
130 return "ECPGt_unsigned_int";
131 break;
132 case ECPGt_long:
133 return "ECPGt_long";
134 break;
136 return "ECPGt_unsigned_long";
137 break;
138 case ECPGt_long_long:
139 return "ECPGt_long_long";
140 break;
142 return "ECPGt_unsigned_long_long";
143 break;
144 case ECPGt_float:
145 return "ECPGt_float";
146 break;
147 case ECPGt_double:
148 return "ECPGt_double";
149 break;
150 case ECPGt_bool:
151 return "ECPGt_bool";
152 break;
153 case ECPGt_varchar:
154 return "ECPGt_varchar";
155 case ECPGt_bytea:
156 return "ECPGt_bytea";
157 case ECPGt_NO_INDICATOR: /* no indicator */
158 return "ECPGt_NO_INDICATOR";
159 break;
160 case ECPGt_char_variable: /* string that should not be quoted */
161 return "ECPGt_char_variable";
162 break;
163 case ECPGt_const: /* constant string quoted */
164 return "ECPGt_const";
165 break;
166 case ECPGt_decimal:
167 return "ECPGt_decimal";
168 break;
169 case ECPGt_numeric:
170 return "ECPGt_numeric";
171 break;
172 case ECPGt_interval:
173 return "ECPGt_interval";
174 break;
175 case ECPGt_descriptor:
176 return "ECPGt_descriptor";
177 break;
178 case ECPGt_sqlda:
179 return "ECPGt_sqlda";
180 break;
181 case ECPGt_date:
182 return "ECPGt_date";
183 break;
184 case ECPGt_timestamp:
185 return "ECPGt_timestamp";
186 break;
187 case ECPGt_string:
188 return "ECPGt_string";
189 break;
190 default:
191 mmerror(PARSE_ERROR, ET_ERROR, "unrecognized variable type code %d", type);
192 }
193
194 return NULL;
195}
196
197/* Dump a type.
198 The type is dumped as:
199 type-tag <comma> - enum ECPGttype
200 reference-to-variable <comma> - char *
201 size <comma> - long size of this field (if varchar)
202 arrsize <comma> - long number of elements in the arr
203 offset <comma> - offset to the next element
204 Where:
205 type-tag is one of the simple types or varchar.
206 reference-to-variable can be a reference to a struct element.
207 arrsize is the size of the array in case of array fetches. Otherwise 0.
208 size is the maxsize in case it is a varchar. Otherwise it is the size of
209 the variable (required to do array fetches of structs).
210 */
211static void ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype type,
212 char *varcharsize,
213 char *arrsize, const char *size, const char *prefix, int counter);
214static void ECPGdump_a_struct(FILE *o, const char *name, const char *ind_name, char *arrsize,
215 struct ECPGtype *type, struct ECPGtype *ind_type, const char *prefix, const char *ind_prefix);
216
217void
218ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype *type, const int brace_level,
219 const char *ind_name, struct ECPGtype *ind_type, const int ind_brace_level,
220 const char *prefix, const char *ind_prefix,
221 char *arr_str_size, const char *struct_sizeof,
222 const char *ind_struct_sizeof)
223{
224 struct variable *var;
225
226 if (type->type != ECPGt_descriptor && type->type != ECPGt_sqlda &&
227 type->type != ECPGt_char_variable && type->type != ECPGt_const &&
228 brace_level >= 0)
229 {
230 char *str;
231
232 str = mm_strdup(name);
233 var = find_variable(str);
234 free(str);
235
236 if ((var->type->type != type->type) ||
237 (var->type->type_name && !type->type_name) ||
238 (!var->type->type_name && type->type_name) ||
239 (var->type->type_name && type->type_name && strcmp(var->type->type_name, type->type_name) != 0))
240 mmerror(PARSE_ERROR, ET_ERROR, "variable \"%s\" is hidden by a local variable of a different type", name);
241 else if (var->brace_level != brace_level)
242 mmerror(PARSE_ERROR, ET_WARNING, "variable \"%s\" is hidden by a local variable", name);
243
244 if (ind_name && ind_type && ind_type->type != ECPGt_NO_INDICATOR && ind_brace_level >= 0)
245 {
246 str = mm_strdup(ind_name);
247 var = find_variable(str);
248 free(str);
249
250 if ((var->type->type != ind_type->type) ||
251 (var->type->type_name && !ind_type->type_name) ||
252 (!var->type->type_name && ind_type->type_name) ||
253 (var->type->type_name && ind_type->type_name && strcmp(var->type->type_name, ind_type->type_name) != 0))
254 mmerror(PARSE_ERROR, ET_ERROR, "indicator variable \"%s\" is hidden by a local variable of a different type", ind_name);
255 else if (var->brace_level != ind_brace_level)
256 mmerror(PARSE_ERROR, ET_WARNING, "indicator variable \"%s\" is hidden by a local variable", ind_name);
257 }
258 }
259
260 switch (type->type)
261 {
262 case ECPGt_array:
263 if (indicator_set && ind_type->type != ECPGt_array)
264 mmfatal(INDICATOR_NOT_ARRAY, "indicator for array/pointer has to be array/pointer");
265 switch (type->u.element->type)
266 {
267 case ECPGt_array:
268 mmerror(PARSE_ERROR, ET_ERROR, "nested arrays are not supported (except strings)"); /* array of array */
269 break;
270 case ECPGt_struct:
271 case ECPGt_union:
273 ind_name,
274 type->size,
275 type->u.element,
276 (ind_type == NULL) ? NULL : ((ind_type->type == ECPGt_NO_INDICATOR) ? ind_type : ind_type->u.element),
277 prefix, ind_prefix);
278 break;
279 default:
280 if (!IS_SIMPLE_TYPE(type->u.element->type))
281 base_yyerror("internal error: unknown datatype, please report this to <" PACKAGE_BUGREPORT ">");
282
284 type->u.element->type,
285 type->u.element->size, type->size, struct_sizeof ? struct_sizeof : NULL,
286 prefix, type->u.element->counter);
287
288 if (ind_type != NULL)
289 {
290 if (ind_type->type == ECPGt_NO_INDICATOR)
291 {
292 char *str_neg_one = mm_strdup("-1");
293
294 ECPGdump_a_simple(o, ind_name, ind_type->type, ind_type->size, str_neg_one, NULL, ind_prefix, 0);
295 free(str_neg_one);
296 }
297 else
298 {
299 ECPGdump_a_simple(o, ind_name, ind_type->u.element->type,
300 ind_type->u.element->size, ind_type->size, NULL, ind_prefix, 0);
301 }
302 }
303 }
304 break;
305 case ECPGt_struct:
306 {
307 char *str_one = mm_strdup("1");
308
309 if (indicator_set && ind_type->type != ECPGt_struct)
310 mmfatal(INDICATOR_NOT_STRUCT, "indicator for struct has to be a struct");
311
312 ECPGdump_a_struct(o, name, ind_name, str_one, type, ind_type, prefix, ind_prefix);
313 free(str_one);
314 }
315 break;
316 case ECPGt_union: /* cannot dump a complete union */
317 base_yyerror("type of union has to be specified");
318 break;
320 {
321 /*
322 * Allocate for each, as there are code-paths where the values
323 * get stomped on.
324 */
325 char *str_varchar_one = mm_strdup("1");
326 char *str_arr_one = mm_strdup("1");
327 char *str_neg_one = mm_strdup("-1");
328
329 if (indicator_set && (ind_type->type == ECPGt_struct || ind_type->type == ECPGt_array))
330 mmfatal(INDICATOR_NOT_SIMPLE, "indicator for simple data type has to be simple");
331
332 ECPGdump_a_simple(o, name, type->type, str_varchar_one, (arr_str_size && strcmp(arr_str_size, "0") != 0) ? arr_str_size : str_arr_one, struct_sizeof, prefix, 0);
333 if (ind_type != NULL)
334 ECPGdump_a_simple(o, ind_name, ind_type->type, ind_type->size, (arr_str_size && strcmp(arr_str_size, "0") != 0) ? arr_str_size : str_neg_one, ind_struct_sizeof, ind_prefix, 0);
335
336 free(str_varchar_one);
337 free(str_arr_one);
338 free(str_neg_one);
339 }
340 break;
341 case ECPGt_descriptor:
342 {
343 /*
344 * Allocate for each, as there are code-paths where the values
345 * get stomped on.
346 */
347 char *str_neg_one = mm_strdup("-1");
348 char *ind_type_neg_one = mm_strdup("-1");
349
350 if (indicator_set && (ind_type->type == ECPGt_struct || ind_type->type == ECPGt_array))
351 mmfatal(INDICATOR_NOT_SIMPLE, "indicator for simple data type has to be simple");
352
353 ECPGdump_a_simple(o, name, type->type, NULL, str_neg_one, NULL, prefix, 0);
354 if (ind_type != NULL)
355 ECPGdump_a_simple(o, ind_name, ind_type->type, ind_type->size, ind_type_neg_one, NULL, ind_prefix, 0);
356
357 free(str_neg_one);
358 free(ind_type_neg_one);
359 }
360 break;
361 default:
362 {
363 /*
364 * Allocate for each, as there are code-paths where the values
365 * get stomped on.
366 */
367 char *str_neg_one = mm_strdup("-1");
368 char *ind_type_neg_one = mm_strdup("-1");
369
370 if (indicator_set && (ind_type->type == ECPGt_struct || ind_type->type == ECPGt_array))
371 mmfatal(INDICATOR_NOT_SIMPLE, "indicator for simple data type has to be simple");
372
373 ECPGdump_a_simple(o, name, type->type, type->size, (arr_str_size && strcmp(arr_str_size, "0") != 0) ? arr_str_size : str_neg_one, struct_sizeof, prefix, type->counter);
374 if (ind_type != NULL)
375 ECPGdump_a_simple(o, ind_name, ind_type->type, ind_type->size, (arr_str_size && strcmp(arr_str_size, "0") != 0) ? arr_str_size : ind_type_neg_one, ind_struct_sizeof, ind_prefix, 0);
376
377 free(str_neg_one);
378 free(ind_type_neg_one);
379 }
380 break;
381 }
382}
383
384
385/* If size is NULL, then the offset is 0, if not use size as a
386 string, it represents the offset needed if we are in an array of structs. */
387static void
388ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype type,
389 char *varcharsize,
390 char *arrsize,
391 const char *size,
392 const char *prefix,
393 int counter)
394{
396 fprintf(o, "\n\tECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ");
397 else if (type == ECPGt_descriptor)
398 /* remember that name here already contains quotes (if needed) */
399 fprintf(o, "\n\tECPGt_descriptor, %s, 1L, 1L, 1L, ", name);
400 else if (type == ECPGt_sqlda)
401 fprintf(o, "\n\tECPGt_sqlda, &%s, 0L, 0L, 0L, ", name);
402 else
403 {
404 char *variable = (char *) mm_alloc(strlen(name) + ((prefix == NULL) ? 0 : strlen(prefix)) + 4);
405 char *offset = (char *) mm_alloc(strlen(name) + strlen("sizeof(struct varchar_)") + 1 + strlen(varcharsize) + sizeof(int) * CHAR_BIT * 10 / 3);
406 char *struct_name;
407
408 switch (type)
409 {
410 /*
411 * we have to use the & operator except for arrays and
412 * pointers
413 */
414
415 case ECPGt_varchar:
416 case ECPGt_bytea:
417
418 /*
419 * we have to use the pointer except for arrays with given
420 * bounds
421 */
422 if (((atoi(arrsize) > 0) ||
423 (atoi(arrsize) == 0 && strcmp(arrsize, "0") != 0)) &&
424 size == NULL)
425 sprintf(variable, "(%s%s)", prefix ? prefix : "", name);
426 else
427 sprintf(variable, "&(%s%s)", prefix ? prefix : "", name);
428
429 /*
430 * If we created a varchar structure automatically, counter is
431 * greater than 0.
432 */
433 if (type == ECPGt_varchar)
434 struct_name = "struct varchar";
435 else
436 struct_name = "struct bytea";
437
438 if (counter)
439 sprintf(offset, "sizeof(%s_%d)", struct_name, counter);
440 else
441 sprintf(offset, "sizeof(%s)", struct_name);
442 break;
443 case ECPGt_char:
446 case ECPGt_string:
447 {
448 char *sizeof_name = "char";
449
450 /*
451 * we have to use the pointer except for arrays with given
452 * bounds, ecpglib will distinguish between * and []
453 */
454 if ((atoi(varcharsize) > 1 ||
455 (atoi(arrsize) > 0) ||
456 (atoi(varcharsize) == 0 && strcmp(varcharsize, "0") != 0) ||
457 (atoi(arrsize) == 0 && strcmp(arrsize, "0") != 0))
458 && size == NULL)
459 {
460 sprintf(variable, "(%s%s)", prefix ? prefix : "", name);
461 if ((type == ECPGt_char || type == ECPGt_unsigned_char) &&
462 strcmp(varcharsize, "0") == 0)
463 {
464 /*
465 * If this is an array of char *, the offset would
466 * be sizeof(char *) and not sizeof(char).
467 */
468 sizeof_name = "char *";
469 }
470 }
471 else
472 sprintf(variable, "&(%s%s)", prefix ? prefix : "", name);
473
474 sprintf(offset, "(%s)*sizeof(%s)", strcmp(varcharsize, "0") == 0 ? "1" : varcharsize, sizeof_name);
475 break;
476 }
477 case ECPGt_numeric:
478
479 /*
480 * we have to use a pointer here
481 */
482 sprintf(variable, "&(%s%s)", prefix ? prefix : "", name);
483 sprintf(offset, "sizeof(numeric)");
484 break;
485 case ECPGt_interval:
486
487 /*
488 * we have to use a pointer here
489 */
490 sprintf(variable, "&(%s%s)", prefix ? prefix : "", name);
491 sprintf(offset, "sizeof(interval)");
492 break;
493 case ECPGt_date:
494
495 /*
496 * we have to use a pointer and translate the variable type
497 */
498 sprintf(variable, "&(%s%s)", prefix ? prefix : "", name);
499 sprintf(offset, "sizeof(date)");
500 break;
501 case ECPGt_timestamp:
502
503 /*
504 * we have to use a pointer and translate the variable type
505 */
506 sprintf(variable, "&(%s%s)", prefix ? prefix : "", name);
507 sprintf(offset, "sizeof(timestamp)");
508 break;
509 case ECPGt_const:
510
511 /*
512 * just dump the const as string
513 */
514 sprintf(variable, "\"%s\"", name);
515 sprintf(offset, "strlen(\"%s\")", name);
516 break;
517 default:
518
519 /*
520 * we have to use the pointer except for arrays with given
521 * bounds
522 */
523 if (((atoi(arrsize) > 0) ||
524 (atoi(arrsize) == 0 && strcmp(arrsize, "0") != 0)) &&
525 size == NULL)
526 sprintf(variable, "(%s%s)", prefix ? prefix : "", name);
527 else
528 sprintf(variable, "&(%s%s)", prefix ? prefix : "", name);
529
530 sprintf(offset, "sizeof(%s)", ecpg_type_name(type));
531 break;
532 }
533
534 /*
535 * Array size would be -1 for addresses of members within structure,
536 * when pointer to structure is being dumped.
537 */
538 if (atoi(arrsize) < 0 && !size)
539 strcpy(arrsize, "1");
540
541 /*
542 * If size i.e. the size of structure of which this variable is part
543 * of, that gives the offset to the next element, if required
544 */
545 if (size == NULL || strlen(size) == 0)
546 fprintf(o, "\n\t%s,%s,(long)%s,(long)%s,%s, ", get_type(type), variable, varcharsize, arrsize, offset);
547 else
548 fprintf(o, "\n\t%s,%s,(long)%s,(long)%s,%s, ", get_type(type), variable, varcharsize, arrsize, size);
549
550 free(variable);
551 free(offset);
552 }
553}
554
555
556/* Penetrate a struct and dump the contents. */
557static void
558ECPGdump_a_struct(FILE *o, const char *name, const char *ind_name, char *arrsize, struct ECPGtype *type, struct ECPGtype *ind_type, const char *prefix, const char *ind_prefix)
559{
560 /*
561 * If offset is NULL, then this is the first recursive level. If not then
562 * we are in a struct and the offset is used as offset.
563 */
564 struct ECPGstruct_member *p,
565 *ind_p = NULL;
566 char *pbuf = (char *) mm_alloc(strlen(name) + ((prefix == NULL) ? 0 : strlen(prefix)) + 3);
567 char *ind_pbuf = (char *) mm_alloc(strlen(ind_name) + ((ind_prefix == NULL) ? 0 : strlen(ind_prefix)) + 3);
568
569 if (atoi(arrsize) == 1)
570 sprintf(pbuf, "%s%s.", prefix ? prefix : "", name);
571 else
572 sprintf(pbuf, "%s%s->", prefix ? prefix : "", name);
573
574 prefix = pbuf;
575
576 if (ind_type == &ecpg_no_indicator)
577 ind_p = &struct_no_indicator;
578 else if (ind_type != NULL)
579 {
580 if (atoi(arrsize) == 1)
581 sprintf(ind_pbuf, "%s%s.", ind_prefix ? ind_prefix : "", ind_name);
582 else
583 sprintf(ind_pbuf, "%s%s->", ind_prefix ? ind_prefix : "", ind_name);
584
585 ind_prefix = ind_pbuf;
586 ind_p = ind_type->u.members;
587 }
588
589 for (p = type->u.members; p; p = p->next)
590 {
591 ECPGdump_a_type(o, p->name, p->type, -1,
592 (ind_p != NULL) ? ind_p->name : NULL,
593 (ind_p != NULL) ? ind_p->type : NULL,
594 -1,
595 prefix, ind_prefix, arrsize, type->struct_sizeof,
596 (ind_p != NULL) ? ind_type->struct_sizeof : NULL);
597 if (ind_p != NULL && ind_p != &struct_no_indicator)
598 {
599 ind_p = ind_p->next;
600 if (ind_p == NULL && p->next != NULL)
601 {
602 mmerror(PARSE_ERROR, ET_WARNING, "indicator struct \"%s\" has too few members", ind_name);
603 ind_p = &struct_no_indicator;
604 }
605 }
606 }
607
608 if (ind_type != NULL && ind_p != NULL && ind_p != &struct_no_indicator)
609 {
610 mmerror(PARSE_ERROR, ET_WARNING, "indicator struct \"%s\" has too many members", ind_name);
611 }
612
613 free(pbuf);
614 free(ind_pbuf);
615}
616
617void
619{
620 while (rm)
621 {
622 struct ECPGstruct_member *p = rm;
623
624 rm = rm->next;
625 free(p->name);
627 free(p);
628 }
629}
630
631void
633{
634 if (!IS_SIMPLE_TYPE(type->type))
635 {
636 switch (type->type)
637 {
638 case ECPGt_array:
639 switch (type->u.element->type)
640 {
641 case ECPGt_array:
642 base_yyerror("internal error: found multidimensional array\n");
643 break;
644 case ECPGt_struct:
645 case ECPGt_union:
646 /* Array of structs. */
647 ECPGfree_type(type->u.element);
648 break;
649 default:
650 if (!IS_SIMPLE_TYPE(type->u.element->type))
651 base_yyerror("internal error: unknown datatype, please report this to <" PACKAGE_BUGREPORT ">");
652
653 ECPGfree_type(type->u.element);
654 }
655 break;
656 case ECPGt_struct:
657 case ECPGt_union:
658 ECPGfree_struct_member(type->u.members);
659 break;
660 default:
661 mmerror(PARSE_ERROR, ET_ERROR, "unrecognized variable type code %d", type->type);
662 break;
663 }
664 }
665 free(type->type_name);
666 free(type->size);
667 free(type->struct_sizeof);
668 free(type);
669}
670
671const char *
673{
674 switch (type)
675 {
676 case ECPGd_count:
677 return "ECPGd_count";
678 break;
679 case ECPGd_data:
680 return "ECPGd_data";
681 break;
682 case ECPGd_di_code:
683 return "ECPGd_di_code";
684 break;
686 return "ECPGd_di_precision";
687 break;
688 case ECPGd_indicator:
689 return "ECPGd_indicator";
690 break;
691 case ECPGd_key_member:
692 return "ECPGd_key_member";
693 break;
694 case ECPGd_length:
695 return "ECPGd_length";
696 break;
697 case ECPGd_name:
698 return "ECPGd_name";
699 break;
700 case ECPGd_nullable:
701 return "ECPGd_nullable";
702 break;
703 case ECPGd_octet:
704 return "ECPGd_octet";
705 break;
706 case ECPGd_precision:
707 return "ECPGd_precision";
708 break;
709 case ECPGd_ret_length:
710 return "ECPGd_ret_length";
711 case ECPGd_ret_octet:
712 return "ECPGd_ret_octet";
713 break;
714 case ECPGd_scale:
715 return "ECPGd_scale";
716 break;
717 case ECPGd_type:
718 return "ECPGd_type";
719 break;
721 return "ECPGd_cardinality";
722 default:
723 mmerror(PARSE_ERROR, ET_ERROR, "unrecognized descriptor item code %d", type);
724 }
725
726 return NULL;
727}
#define fprintf(file, fmt, msg)
Definition: cubescan.l:21
const char * ecpg_type_name(enum ECPGttype typ)
Definition: typename.c:17
ECPGttype
Definition: ecpgtype.h:42
@ ECPGt_float
Definition: ecpgtype.h:47
@ ECPGt_long_long
Definition: ecpgtype.h:45
@ ECPGt_sqlda
Definition: ecpgtype.h:66
@ ECPGt_short
Definition: ecpgtype.h:43
@ ECPGt_decimal
Definition: ecpgtype.h:51
@ ECPGt_char_variable
Definition: ecpgtype.h:60
@ ECPGt_bytea
Definition: ecpgtype.h:67
@ ECPGt_numeric
Definition: ecpgtype.h:49
@ ECPGt_union
Definition: ecpgtype.h:58
@ ECPGt_varchar
Definition: ecpgtype.h:48
@ ECPGt_struct
Definition: ecpgtype.h:57
@ ECPGt_timestamp
Definition: ecpgtype.h:54
@ ECPGt_unsigned_short
Definition: ecpgtype.h:43
@ ECPGt_int
Definition: ecpgtype.h:44
@ ECPGt_long
Definition: ecpgtype.h:44
@ ECPGt_unsigned_char
Definition: ecpgtype.h:43
@ ECPGt_double
Definition: ecpgtype.h:47
@ ECPGt_array
Definition: ecpgtype.h:56
@ ECPGt_NO_INDICATOR
Definition: ecpgtype.h:64
@ ECPGt_date
Definition: ecpgtype.h:53
@ ECPGt_interval
Definition: ecpgtype.h:55
@ ECPGt_unsigned_long
Definition: ecpgtype.h:44
@ ECPGt_const
Definition: ecpgtype.h:61
@ ECPGt_bool
Definition: ecpgtype.h:46
@ ECPGt_unsigned_long_long
Definition: ecpgtype.h:45
@ ECPGt_unsigned_int
Definition: ecpgtype.h:44
@ ECPGt_descriptor
Definition: ecpgtype.h:59
@ ECPGt_char
Definition: ecpgtype.h:43
@ ECPGt_string
Definition: ecpgtype.h:65
#define IS_SIMPLE_TYPE(type)
Definition: ecpgtype.h:92
ECPGdtype
Definition: ecpgtype.h:72
@ ECPGd_scale
Definition: ecpgtype.h:86
@ ECPGd_precision
Definition: ecpgtype.h:83
@ ECPGd_length
Definition: ecpgtype.h:79
@ ECPGd_nullable
Definition: ecpgtype.h:81
@ ECPGd_di_precision
Definition: ecpgtype.h:76
@ ECPGd_type
Definition: ecpgtype.h:87
@ ECPGd_cardinality
Definition: ecpgtype.h:89
@ ECPGd_indicator
Definition: ecpgtype.h:77
@ ECPGd_ret_length
Definition: ecpgtype.h:84
@ ECPGd_di_code
Definition: ecpgtype.h:75
@ ECPGd_count
Definition: ecpgtype.h:73
@ ECPGd_name
Definition: ecpgtype.h:80
@ ECPGd_key_member
Definition: ecpgtype.h:78
@ ECPGd_octet
Definition: ecpgtype.h:82
@ ECPGd_ret_octet
Definition: ecpgtype.h:85
@ ECPGd_data
Definition: ecpgtype.h:74
return str start
const char * str
#define free(a)
Definition: header.h:65
#define sprintf
Definition: port.h:240
char * mm_strdup(const char *string)
Definition: util.c:97
void base_yyerror(const char *error)
void mmerror(int error_code, enum errortype type, const char *error,...) pg_attribute_printf(3
#define INDICATOR_NOT_SIMPLE
void * mm_alloc(size_t size)
Definition: util.c:85
void void mmfatal(int error_code, const char *error,...) pg_attribute_printf(2
#define PARSE_ERROR
#define INDICATOR_NOT_STRUCT
struct ECPGtype ecpg_no_indicator
#define INDICATOR_NOT_ARRAY
struct variable * find_variable(const char *name)
Definition: variable.c:193
static pg_noinline void Size size
Definition: slab.c:607
char * name
Definition: type.h:12
struct ECPGtype * type
Definition: type.h:13
struct ECPGstruct_member * next
Definition: type.h:14
Definition: type.h:18
union ECPGtype::@166 u
char * type_name
Definition: type.h:20
char * struct_sizeof
Definition: type.h:24
enum ECPGttype type
Definition: type.h:19
struct ECPGstruct_member * members
Definition: type.h:30
char * size
Definition: type.h:22
struct ECPGtype * element
Definition: type.h:28
int counter
Definition: type.h:32
long varcharsize
enum ECPGttype type
int brace_level
Definition: type.h:193
enum ECPGttype ind_type
static void ECPGdump_a_struct(FILE *o, const char *name, const char *ind_name, char *arrsize, struct ECPGtype *type, struct ECPGtype *ind_type, const char *prefix, const char *ind_prefix)
Definition: type.c:558
void ECPGmake_struct_member(const char *name, struct ECPGtype *type, struct ECPGstruct_member **start)
Definition: type.c:53
static void ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype type, char *varcharsize, char *arrsize, const char *size, const char *prefix, int counter)
Definition: type.c:388
struct ECPGtype * ECPGmake_simple_type(enum ECPGttype type, const char *size, int counter)
Definition: type.c:72
const char * get_dtype(enum ECPGdtype type)
Definition: type.c:672
static const char * get_type(enum ECPGttype type)
Definition: type.c:110
void ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype *type, const int brace_level, const char *ind_name, struct ECPGtype *ind_type, const int ind_brace_level, const char *prefix, const char *ind_prefix, char *arr_str_size, const char *struct_sizeof, const char *ind_struct_sizeof)
Definition: type.c:218
void ECPGfree_struct_member(struct ECPGstruct_member *rm)
Definition: type.c:618
struct ECPGstruct_member * ECPGstruct_member_dup(struct ECPGstruct_member *rm)
Definition: type.c:13
void ECPGfree_type(struct ECPGtype *type)
Definition: type.c:632
static struct ECPGstruct_member struct_no_indicator
Definition: type.c:9
struct ECPGtype * ECPGmake_array_type(struct ECPGtype *type, const char *size)
Definition: type.c:87
struct ECPGtype * ECPGmake_struct_type(struct ECPGstruct_member *rm, enum ECPGttype type, const char *type_name, const char *struct_sizeof)
Definition: type.c:97
#define indicator_set
Definition: type.c:7
@ ET_WARNING
Definition: type.h:220
@ ET_ERROR
Definition: type.h:220
const char * type
const char * name