1998-02-05 16:46:43 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
1998-02-17 02:48:12 +01:00
|
|
|
#include <stdlib.h>
|
1998-02-05 16:46:43 +01:00
|
|
|
|
1998-02-27 13:59:33 +01:00
|
|
|
#include "extern.h"
|
1998-02-05 16:46:43 +01:00
|
|
|
|
1998-02-17 02:48:12 +01:00
|
|
|
/* malloc + error check */
|
1998-02-26 05:46:47 +01:00
|
|
|
void *
|
|
|
|
mm_alloc(size_t size)
|
1998-02-17 02:48:12 +01:00
|
|
|
{
|
1998-02-26 05:46:47 +01:00
|
|
|
void *ptr = malloc(size);
|
1998-02-17 02:48:12 +01:00
|
|
|
|
1998-02-26 05:46:47 +01:00
|
|
|
if (ptr == NULL)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Out of memory\n");
|
1998-05-06 15:03:47 +02:00
|
|
|
exit(OUT_OF_MEMORY);
|
1998-02-26 05:46:47 +01:00
|
|
|
}
|
1998-02-17 02:48:12 +01:00
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return ptr;
|
1998-02-17 02:48:12 +01:00
|
|
|
}
|
|
|
|
|
1998-10-03 04:33:51 +02:00
|
|
|
/* strdup + error check */
|
|
|
|
char *
|
|
|
|
mm_strdup(const char *string)
|
|
|
|
{
|
|
|
|
char *new = strdup(string);
|
|
|
|
|
|
|
|
if (new == NULL)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Out of memory\n");
|
|
|
|
exit(OUT_OF_MEMORY);
|
|
|
|
}
|
|
|
|
|
|
|
|
return new;
|
|
|
|
}
|
|
|
|
|
1998-05-06 15:03:47 +02:00
|
|
|
/* duplicate memberlist */
|
1999-02-20 08:01:08 +01:00
|
|
|
struct ECPGstruct_member *
|
|
|
|
ECPGstruct_member_dup(struct ECPGstruct_member * rm)
|
1998-05-06 15:03:47 +02:00
|
|
|
{
|
1998-09-01 06:40:42 +02:00
|
|
|
struct ECPGstruct_member *new = NULL;
|
|
|
|
|
|
|
|
while (rm)
|
|
|
|
{
|
|
|
|
struct ECPGtype *type;
|
|
|
|
|
|
|
|
switch (rm->typ->typ)
|
|
|
|
{
|
|
|
|
case ECPGt_struct:
|
1999-02-28 08:25:34 +01:00
|
|
|
case ECPGt_union:
|
|
|
|
type = ECPGmake_struct_type(rm->typ->u.members, rm->typ->typ);
|
1998-09-01 06:40:42 +02:00
|
|
|
break;
|
|
|
|
case ECPGt_array:
|
|
|
|
type = ECPGmake_array_type(ECPGmake_simple_type(rm->typ->u.element->typ, rm->typ->u.element->size), rm->typ->size);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
type = ECPGmake_simple_type(rm->typ->typ, rm->typ->size);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ECPGmake_struct_member(rm->name, type, &new);
|
|
|
|
|
|
|
|
rm = rm->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (new);
|
1998-05-06 15:03:47 +02:00
|
|
|
}
|
1998-02-05 16:46:43 +01:00
|
|
|
|
|
|
|
/* The NAME argument is copied. The type argument is preserved as a pointer. */
|
1998-05-26 15:43:55 +02:00
|
|
|
void
|
1998-04-27 16:35:58 +02:00
|
|
|
ECPGmake_struct_member(char *name, struct ECPGtype * type, struct ECPGstruct_member ** start)
|
1998-02-05 16:46:43 +01:00
|
|
|
{
|
1998-04-27 16:35:58 +02:00
|
|
|
struct ECPGstruct_member *ptr,
|
1999-02-20 08:01:08 +01:00
|
|
|
*ne =
|
|
|
|
(struct ECPGstruct_member *) mm_alloc(sizeof(struct ECPGstruct_member));
|
1998-02-17 02:48:12 +01:00
|
|
|
|
1998-02-26 05:46:47 +01:00
|
|
|
ne->name = strdup(name);
|
|
|
|
ne->typ = type;
|
|
|
|
ne->next = NULL;
|
1998-02-05 16:46:43 +01:00
|
|
|
|
1998-02-26 05:46:47 +01:00
|
|
|
for (ptr = *start; ptr && ptr->next; ptr = ptr->next);
|
1998-02-05 16:46:43 +01:00
|
|
|
|
1998-02-26 05:46:47 +01:00
|
|
|
if (ptr)
|
|
|
|
ptr->next = ne;
|
|
|
|
else
|
|
|
|
*start = ne;
|
1998-02-05 16:46:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
struct ECPGtype *
|
1998-02-24 16:52:13 +01:00
|
|
|
ECPGmake_simple_type(enum ECPGttype typ, long siz)
|
1998-02-05 16:46:43 +01:00
|
|
|
{
|
1998-02-26 05:46:47 +01:00
|
|
|
struct ECPGtype *ne = (struct ECPGtype *) mm_alloc(sizeof(struct ECPGtype));
|
1998-02-05 16:46:43 +01:00
|
|
|
|
1998-02-26 05:46:47 +01:00
|
|
|
ne->typ = typ;
|
|
|
|
ne->size = siz;
|
|
|
|
ne->u.element = 0;
|
1998-02-05 16:46:43 +01:00
|
|
|
|
1998-02-26 05:46:47 +01:00
|
|
|
return ne;
|
1998-02-05 16:46:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
struct ECPGtype *
|
1998-02-26 05:46:47 +01:00
|
|
|
ECPGmake_array_type(struct ECPGtype * typ, long siz)
|
1998-02-05 16:46:43 +01:00
|
|
|
{
|
1998-02-26 05:46:47 +01:00
|
|
|
struct ECPGtype *ne = ECPGmake_simple_type(ECPGt_array, siz);
|
1998-02-05 16:46:43 +01:00
|
|
|
|
1998-02-26 05:46:47 +01:00
|
|
|
ne->u.element = typ;
|
1998-02-05 16:46:43 +01:00
|
|
|
|
1998-02-26 05:46:47 +01:00
|
|
|
return ne;
|
1998-02-05 16:46:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
struct ECPGtype *
|
1999-02-28 08:25:34 +01:00
|
|
|
ECPGmake_struct_type(struct ECPGstruct_member * rm, enum ECPGttype type)
|
1998-02-05 16:46:43 +01:00
|
|
|
{
|
1999-02-28 08:25:34 +01:00
|
|
|
struct ECPGtype *ne = ECPGmake_simple_type(type, 1);
|
1998-02-05 16:46:43 +01:00
|
|
|
|
1999-02-20 08:01:08 +01:00
|
|
|
ne->u.members = ECPGstruct_member_dup(rm);
|
1998-02-05 16:46:43 +01:00
|
|
|
|
1998-02-26 05:46:47 +01:00
|
|
|
return ne;
|
1998-02-05 16:46:43 +01:00
|
|
|
}
|
|
|
|
|
1998-09-01 06:40:42 +02:00
|
|
|
static const char *
|
|
|
|
get_type(enum ECPGttype typ)
|
1998-05-06 15:03:47 +02:00
|
|
|
{
|
1998-09-01 06:40:42 +02:00
|
|
|
switch (typ)
|
|
|
|
{
|
2000-01-18 14:03:49 +01:00
|
|
|
case ECPGt_char:
|
1998-09-01 06:40:42 +02:00
|
|
|
return ("ECPGt_char");
|
|
|
|
break;
|
|
|
|
case ECPGt_unsigned_char:
|
|
|
|
return ("ECPGt_unsigned_char");
|
|
|
|
break;
|
|
|
|
case ECPGt_short:
|
|
|
|
return ("ECPGt_short");
|
|
|
|
break;
|
|
|
|
case ECPGt_unsigned_short:
|
|
|
|
return ("ECPGt_unsigned_short");
|
|
|
|
break;
|
|
|
|
case ECPGt_int:
|
|
|
|
return ("ECPGt_int");
|
|
|
|
break;
|
|
|
|
case ECPGt_unsigned_int:
|
|
|
|
return ("ECPGt_unsigned_int");
|
|
|
|
break;
|
|
|
|
case ECPGt_long:
|
|
|
|
return ("ECPGt_long");
|
|
|
|
break;
|
|
|
|
case ECPGt_unsigned_long:
|
|
|
|
return ("ECPGt_unsigned_int");
|
|
|
|
break;
|
|
|
|
case ECPGt_float:
|
|
|
|
return ("ECPGt_float");
|
|
|
|
break;
|
|
|
|
case ECPGt_double:
|
|
|
|
return ("ECPGt_double");
|
|
|
|
break;
|
|
|
|
case ECPGt_bool:
|
|
|
|
return ("ECPGt_bool");
|
|
|
|
break;
|
|
|
|
case ECPGt_varchar:
|
|
|
|
return ("ECPGt_varchar");
|
|
|
|
case ECPGt_NO_INDICATOR: /* no indicator */
|
|
|
|
return ("ECPGt_NO_INDICATOR");
|
|
|
|
break;
|
1999-05-25 18:15:34 +02:00
|
|
|
case ECPGt_char_variable: /* string that should not be
|
|
|
|
* quoted */
|
1999-02-20 08:01:08 +01:00
|
|
|
return ("ECPGt_char_variable");
|
|
|
|
break;
|
1998-09-01 06:40:42 +02:00
|
|
|
default:
|
1999-02-23 13:57:03 +01:00
|
|
|
sprintf(errortext, "illegal variable type %d\n", typ);
|
|
|
|
yyerror(errortext);
|
1998-09-01 06:40:42 +02:00
|
|
|
}
|
1999-05-25 18:15:34 +02:00
|
|
|
|
1999-02-28 08:25:34 +01:00
|
|
|
return NULL;
|
1998-05-06 15:03:47 +02:00
|
|
|
}
|
1998-02-05 16:46:43 +01:00
|
|
|
|
|
|
|
/* Dump a type.
|
|
|
|
The type is dumped as:
|
1998-02-26 05:46:47 +01:00
|
|
|
type-tag <comma> - enum ECPGttype
|
1998-02-17 02:48:12 +01:00
|
|
|
reference-to-variable <comma> - void *
|
1998-02-26 05:46:47 +01:00
|
|
|
size <comma> - long size of this field (if varchar)
|
|
|
|
arrsize <comma> - long number of elements in the arr
|
|
|
|
offset <comma> - offset to the next element
|
1998-02-05 16:46:43 +01:00
|
|
|
Where:
|
|
|
|
type-tag is one of the simple types or varchar.
|
|
|
|
reference-to-variable can be a reference to a struct element.
|
|
|
|
arrsize is the size of the array in case of array fetches. Otherwise 0.
|
|
|
|
size is the maxsize in case it is a varchar. Otherwise it is the size of
|
1998-04-27 16:35:58 +02:00
|
|
|
the variable (required to do array fetches of structs).
|
1998-02-05 16:46:43 +01:00
|
|
|
*/
|
1998-09-01 06:40:42 +02:00
|
|
|
static void ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype typ,
|
1998-02-26 05:46:47 +01:00
|
|
|
long varcharsize,
|
|
|
|
long arrsiz, const char *siz, const char *prefix);
|
1998-09-01 06:40:42 +02:00
|
|
|
static void ECPGdump_a_struct(FILE *o, const char *name, const char *ind_name, long arrsiz,
|
|
|
|
struct ECPGtype * typ, struct ECPGtype * ind_typ, const char *offset, const char *prefix, const char *ind_prefix);
|
1998-02-05 16:46:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
void
|
1998-04-21 15:23:24 +02:00
|
|
|
ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * typ, const char *ind_name, struct ECPGtype * ind_typ, const char *prefix, const char *ind_prefix)
|
1998-02-05 16:46:43 +01:00
|
|
|
{
|
1998-04-24 14:10:20 +02:00
|
|
|
if (ind_typ == NULL)
|
|
|
|
{
|
|
|
|
ind_typ = &ecpg_no_indicator;
|
|
|
|
ind_name = "no_indicator";
|
|
|
|
}
|
1998-09-01 06:40:42 +02:00
|
|
|
|
|
|
|
switch (typ->typ)
|
|
|
|
{
|
|
|
|
case ECPGt_array:
|
1999-02-28 08:25:34 +01:00
|
|
|
switch (typ->u.element->typ)
|
1998-09-01 06:40:42 +02:00
|
|
|
{
|
1999-02-28 08:25:34 +01:00
|
|
|
case ECPGt_array:
|
1999-05-25 18:15:34 +02:00
|
|
|
yyerror("No nested arrays allowed (except strings)"); /* array of array */
|
1999-02-28 08:25:34 +01:00
|
|
|
break;
|
|
|
|
case ECPGt_struct:
|
|
|
|
case ECPGt_union:
|
1999-05-25 18:15:34 +02:00
|
|
|
ECPGdump_a_struct(o, name, ind_name, typ->size, typ->u.element, ind_typ->u.element, NULL, prefix, ind_prefix);
|
1999-02-28 08:25:34 +01:00
|
|
|
break;
|
1999-05-25 18:15:34 +02:00
|
|
|
default:
|
1999-02-28 08:25:34 +01:00
|
|
|
if (!IS_SIMPLE_TYPE(typ->u.element->typ))
|
|
|
|
yyerror("Internal error: unknown datatype, please inform pgsql-bugs@postgresql.org");
|
1999-05-25 18:15:34 +02:00
|
|
|
|
1999-02-28 08:25:34 +01:00
|
|
|
ECPGdump_a_simple(o, name, typ->u.element->typ,
|
1998-09-01 06:40:42 +02:00
|
|
|
typ->u.element->size, typ->size, NULL, prefix);
|
1999-02-28 08:25:34 +01:00
|
|
|
if (ind_typ->typ == ECPGt_NO_INDICATOR)
|
|
|
|
ECPGdump_a_simple(o, ind_name, ind_typ->typ, ind_typ->size, -1, NULL, ind_prefix);
|
|
|
|
else
|
1999-02-20 08:01:08 +01:00
|
|
|
{
|
1999-02-28 08:25:34 +01:00
|
|
|
if (ind_typ->typ != ECPGt_array)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Indicator for an array has to be array too.\n");
|
1999-05-25 18:15:34 +02:00
|
|
|
exit(INDICATOR_NOT_ARRAY);
|
|
|
|
}
|
1999-02-28 08:25:34 +01:00
|
|
|
ECPGdump_a_simple(o, ind_name, ind_typ->u.element->typ,
|
1999-05-25 18:15:34 +02:00
|
|
|
ind_typ->u.element->size, ind_typ->size, NULL, prefix);
|
1999-02-28 08:25:34 +01:00
|
|
|
}
|
1998-09-01 06:40:42 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ECPGt_struct:
|
|
|
|
ECPGdump_a_struct(o, name, ind_name, 1, typ, ind_typ, NULL, prefix, ind_prefix);
|
|
|
|
break;
|
1999-05-25 18:15:34 +02:00
|
|
|
case ECPGt_union: /* cannot dump a complete union */
|
1999-02-28 08:25:34 +01:00
|
|
|
yyerror("Type of union has to be specified");
|
|
|
|
break;
|
|
|
|
case ECPGt_char_variable:
|
|
|
|
ECPGdump_a_simple(o, name, typ->typ, 1, 1, NULL, prefix);
|
|
|
|
ECPGdump_a_simple(o, ind_name, ind_typ->typ, ind_typ->size, -1, NULL, ind_prefix);
|
|
|
|
break;
|
1998-09-01 06:40:42 +02:00
|
|
|
default:
|
|
|
|
ECPGdump_a_simple(o, name, typ->typ, typ->size, -1, NULL, prefix);
|
|
|
|
ECPGdump_a_simple(o, ind_name, ind_typ->typ, ind_typ->size, -1, NULL, ind_prefix);
|
|
|
|
break;
|
1998-02-26 05:46:47 +01:00
|
|
|
}
|
1998-02-05 16:46:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* If siz is NULL, then the offset is 0, if not use siz as a
|
1998-04-27 16:35:58 +02:00
|
|
|
string, it represents the offset needed if we are in an array of structs. */
|
1998-05-18 18:05:05 +02:00
|
|
|
static void
|
1998-02-17 02:48:12 +01:00
|
|
|
ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype typ,
|
1998-02-26 05:46:47 +01:00
|
|
|
long varcharsize,
|
1998-05-06 15:03:47 +02:00
|
|
|
long arrsize,
|
1998-02-26 05:46:47 +01:00
|
|
|
const char *siz,
|
1998-04-21 15:23:24 +02:00
|
|
|
const char *prefix
|
1998-09-01 06:40:42 +02:00
|
|
|
)
|
1998-02-05 16:46:43 +01:00
|
|
|
{
|
1998-09-01 06:40:42 +02:00
|
|
|
if (typ == ECPGt_NO_INDICATOR)
|
|
|
|
fprintf(o, "\n\tECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ");
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char *variable = (char *) mm_alloc(strlen(name) + ((prefix == NULL) ? 0 : strlen(prefix)) + 4);
|
|
|
|
char *offset = (char *) mm_alloc(strlen(name) + strlen("sizeof(struct varchar_)") + 1);
|
|
|
|
|
1999-02-28 08:25:34 +01:00
|
|
|
/* we have to use the pointer except for arrays with given bounds */
|
|
|
|
if (arrsize > 0)
|
1998-09-01 06:40:42 +02:00
|
|
|
sprintf(variable, "(%s%s)", prefix ? prefix : "", name);
|
|
|
|
else
|
|
|
|
sprintf(variable, "&(%s%s)", prefix ? prefix : "", name);
|
|
|
|
|
|
|
|
switch (typ)
|
|
|
|
{
|
|
|
|
case ECPGt_varchar:
|
|
|
|
sprintf(offset, "sizeof(struct varchar_%s)", name);
|
|
|
|
break;
|
|
|
|
case ECPGt_char:
|
|
|
|
case ECPGt_unsigned_char:
|
1999-02-20 08:01:08 +01:00
|
|
|
case ECPGt_char_variable:
|
1999-02-28 08:25:34 +01:00
|
|
|
sprintf(offset, "%ld*sizeof(char)", varcharsize == 0 ? 1 : varcharsize);
|
1998-09-01 06:40:42 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
sprintf(offset, "sizeof(%s)", ECPGtype_name(typ));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (arrsize < 0)
|
|
|
|
arrsize = 1;
|
|
|
|
|
|
|
|
if (siz == NULL)
|
|
|
|
fprintf(o, "\n\t%s,%s,%ldL,%ldL,%s, ", get_type(typ), variable, varcharsize, arrsize, offset);
|
|
|
|
else
|
|
|
|
fprintf(o, "\n\t%s,%s,%ldL,%ldL,%s, ", get_type(typ), variable, varcharsize, arrsize, siz);
|
|
|
|
|
|
|
|
free(variable);
|
|
|
|
free(offset);
|
1998-02-26 05:46:47 +01:00
|
|
|
}
|
1998-02-05 16:46:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-04-27 16:35:58 +02:00
|
|
|
/* Penetrate a struct and dump the contents. */
|
1998-05-18 18:05:05 +02:00
|
|
|
static void
|
1998-09-01 06:40:42 +02:00
|
|
|
ECPGdump_a_struct(FILE *o, const char *name, const char *ind_name, long arrsiz, struct ECPGtype * typ, struct ECPGtype * ind_typ, const char *offsetarg, const char *prefix, const char *ind_prefix)
|
1998-02-05 16:46:43 +01:00
|
|
|
{
|
1998-02-26 05:46:47 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If offset is NULL, then this is the first recursive level. If not
|
1998-04-27 16:35:58 +02:00
|
|
|
* then we are in a struct in a struct and the offset is used as
|
1998-02-26 05:46:47 +01:00
|
|
|
* offset.
|
|
|
|
*/
|
1998-09-01 06:40:42 +02:00
|
|
|
struct ECPGstruct_member *p,
|
|
|
|
*ind_p = NULL;
|
1998-02-26 05:46:47 +01:00
|
|
|
char obuf[BUFSIZ];
|
1998-09-01 06:40:42 +02:00
|
|
|
char pbuf[BUFSIZ],
|
|
|
|
ind_pbuf[BUFSIZ];
|
1998-02-26 05:46:47 +01:00
|
|
|
const char *offset;
|
|
|
|
|
|
|
|
if (offsetarg == NULL)
|
|
|
|
{
|
|
|
|
sprintf(obuf, "sizeof(%s)", name);
|
|
|
|
offset = obuf;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
offset = offsetarg;
|
|
|
|
|
|
|
|
sprintf(pbuf, "%s%s.", prefix ? prefix : "", name);
|
|
|
|
prefix = pbuf;
|
1998-09-01 06:40:42 +02:00
|
|
|
|
1998-04-21 15:23:24 +02:00
|
|
|
sprintf(ind_pbuf, "%s%s.", ind_prefix ? ind_prefix : "", ind_name);
|
|
|
|
ind_prefix = ind_pbuf;
|
1998-02-26 05:46:47 +01:00
|
|
|
|
1998-09-01 06:40:42 +02:00
|
|
|
if (ind_typ != NULL)
|
|
|
|
ind_p = ind_typ->u.members;
|
1998-04-24 14:10:20 +02:00
|
|
|
for (p = typ->u.members; p; p = p->next)
|
1998-02-26 05:46:47 +01:00
|
|
|
{
|
1998-04-24 14:10:20 +02:00
|
|
|
ECPGdump_a_type(o, p->name, p->typ, (ind_p != NULL) ? ind_p->name : NULL, (ind_p != NULL) ? ind_p->typ : NULL, prefix, ind_prefix);
|
1998-09-01 06:40:42 +02:00
|
|
|
if (ind_p != NULL)
|
|
|
|
ind_p = ind_p->next;
|
1998-02-26 05:46:47 +01:00
|
|
|
}
|
1998-02-05 16:46:43 +01:00
|
|
|
}
|
|
|
|
|
1998-05-06 15:03:47 +02:00
|
|
|
void
|
1998-04-27 16:35:58 +02:00
|
|
|
ECPGfree_struct_member(struct ECPGstruct_member * rm)
|
1998-02-05 16:46:43 +01:00
|
|
|
{
|
1998-09-01 06:40:42 +02:00
|
|
|
while (rm)
|
|
|
|
{
|
|
|
|
struct ECPGstruct_member *p = rm;
|
|
|
|
|
|
|
|
rm = rm->next;
|
|
|
|
free(p->name);
|
|
|
|
free(p->typ);
|
|
|
|
free(p);
|
|
|
|
}
|
1998-05-06 15:03:47 +02:00
|
|
|
}
|
1998-02-05 16:46:43 +01:00
|
|
|
|
|
|
|
void
|
1998-02-26 05:46:47 +01:00
|
|
|
ECPGfree_type(struct ECPGtype * typ)
|
1998-02-05 16:46:43 +01:00
|
|
|
{
|
1998-02-26 05:46:47 +01:00
|
|
|
if (!IS_SIMPLE_TYPE(typ->typ))
|
|
|
|
{
|
1999-05-25 18:15:34 +02:00
|
|
|
switch (typ->typ)
|
1998-02-26 05:46:47 +01:00
|
|
|
{
|
2000-01-18 14:03:49 +01:00
|
|
|
case ECPGt_array:
|
1999-02-28 08:25:34 +01:00
|
|
|
switch (typ->u.element->typ)
|
|
|
|
{
|
2000-01-18 14:03:49 +01:00
|
|
|
case ECPGt_array:
|
1999-02-28 08:25:34 +01:00
|
|
|
yyerror("internal error, found multi-dimensional array\n");
|
|
|
|
break;
|
|
|
|
case ECPGt_struct:
|
|
|
|
case ECPGt_union:
|
|
|
|
/* Array of structs. */
|
|
|
|
ECPGfree_struct_member(typ->u.element->u.members);
|
2000-01-18 14:03:49 +01:00
|
|
|
free(typ->u.element);
|
1999-02-28 08:25:34 +01:00
|
|
|
break;
|
1999-05-25 18:15:34 +02:00
|
|
|
default:
|
1999-02-28 08:25:34 +01:00
|
|
|
if (!IS_SIMPLE_TYPE(typ->u.element->typ))
|
|
|
|
yyerror("Internal error: unknown datatype, please inform pgsql-bugs@postgresql.org");
|
|
|
|
|
|
|
|
free(typ->u.element);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ECPGt_struct:
|
|
|
|
case ECPGt_union:
|
|
|
|
ECPGfree_struct_member(typ->u.members);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
sprintf(errortext, "illegal variable type %d\n", typ->typ);
|
1999-02-23 13:57:03 +01:00
|
|
|
yyerror(errortext);
|
1999-02-28 08:25:34 +01:00
|
|
|
break;
|
1999-02-23 13:57:03 +01:00
|
|
|
}
|
1998-02-26 05:46:47 +01:00
|
|
|
}
|
|
|
|
free(typ);
|
1998-02-05 16:46:43 +01:00
|
|
|
}
|