|
1 |
| -/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/type.c,v 1.88 2010/03/09 11:09:45 meskes Exp $ */ |
| 1 | +/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/type.c,v 1.89 2010/04/01 08:41:01 meskes Exp $ */ |
2 | 2 |
|
3 | 3 | #include"postgres_fe.h"
|
4 | 4 |
|
@@ -54,7 +54,7 @@ ECPGstruct_member_dup(struct ECPGstruct_member * rm)
|
54 | 54 | * if this array does contain a struct again, we have to
|
55 | 55 | * create the struct too
|
56 | 56 | */
|
57 |
| -if (rm->type->u.element->type==ECPGt_struct) |
| 57 | +if (rm->type->u.element->type==ECPGt_struct||rm->type->u.element->type==ECPGt_union) |
58 | 58 | type=ECPGmake_struct_type(rm->type->u.element->u.members,rm->type->u.element->type,rm->type->u.element->type_name,rm->type->u.element->struct_sizeof);
|
59 | 59 | else
|
60 | 60 | type=ECPGmake_array_type(ECPGmake_simple_type(rm->type->u.element->type,rm->type->u.element->size,rm->type->u.element->counter),rm->type->size);
|
@@ -240,8 +240,44 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type,
|
240 | 240 | constchar*ind_name,structECPGtype*ind_type,
|
241 | 241 | constchar*prefix,constchar*ind_prefix,
|
242 | 242 | char*arr_str_siz,constchar*struct_sizeof,
|
243 |
| -constchar*ind_struct_sizeof) |
| 243 | +constchar*ind_struct_sizeof, |
| 244 | +constintbrace_level,constintind_brace_level) |
244 | 245 | {
|
| 246 | +structvariable*var; |
| 247 | + |
| 248 | +if (type->type!=ECPGt_descriptor&&type->type!=ECPGt_sqlda&& |
| 249 | +type->type!=ECPGt_char_variable&& |
| 250 | +brace_level >=0) |
| 251 | +{ |
| 252 | +char*str; |
| 253 | + |
| 254 | +str=strdup(name); |
| 255 | +var=find_variable(str); |
| 256 | +free(str); |
| 257 | + |
| 258 | +if ((var->type->type!=type->type)|| |
| 259 | +(var->type->type_name&& !type->type_name)|| |
| 260 | +(!var->type->type_name&&type->type_name)|| |
| 261 | +(var->type->type_name&&type->type_name&&strcmp(var->type->type_name,type->type_name))) |
| 262 | +mmerror(PARSE_ERROR,ET_WARNING,"variable (%s) is hidden by a local variable of a different type",name); |
| 263 | +elseif (var->brace_level!=brace_level) |
| 264 | +mmerror(PARSE_ERROR,ET_WARNING,"variable (%s) is hidden by a local variable",name); |
| 265 | + |
| 266 | +if (ind_name&&ind_type&&ind_type->type!=ECPGt_NO_INDICATOR&&ind_brace_level >=0) |
| 267 | +{ |
| 268 | +str=strdup(ind_name); |
| 269 | +var=find_variable(str); |
| 270 | +free(str); |
| 271 | +if ((var->type->type!=ind_type->type)|| |
| 272 | +(var->type->type_name&& !ind_type->type_name)|| |
| 273 | +(!var->type->type_name&&ind_type->type_name)|| |
| 274 | +(var->type->type_name&&ind_type->type_name&&strcmp(var->type->type_name,ind_type->type_name))) |
| 275 | +mmerror(PARSE_ERROR,ET_WARNING,"indicator variable (%s) is hidden by a local variable of a different type",ind_name); |
| 276 | +elseif (var->brace_level!=ind_brace_level) |
| 277 | +mmerror(PARSE_ERROR,ET_WARNING,"indicator variable (%s) is hidden by a local variable",ind_name); |
| 278 | +} |
| 279 | +} |
| 280 | + |
245 | 281 | switch (type->type)
|
246 | 282 | {
|
247 | 283 | caseECPGt_array:
|
@@ -503,7 +539,8 @@ ECPGdump_a_struct(FILE *o, const char *name, const char *ind_name, char *arrsiz,
|
503 | 539 | (ind_p!=NULL) ?ind_p->name :NULL,
|
504 | 540 | (ind_p!=NULL) ?ind_p->type :NULL,
|
505 | 541 | prefix,ind_prefix,arrsiz,type->struct_sizeof,
|
506 |
| -(ind_p!=NULL) ?ind_type->struct_sizeof :NULL); |
| 542 | +(ind_p!=NULL) ?ind_type->struct_sizeof :NULL, |
| 543 | +-1,-1); |
507 | 544 | if (ind_p!=NULL&&ind_p!=&struct_no_indicator)
|
508 | 545 | ind_p=ind_p->next;
|
509 | 546 | }
|
|