Skip to content

Commit 1fbb06d

Browse files
author
Michael Meskes
committed
Zoltan beautified his hidden-variable-patch for ecpg. This also makes sure we get an error message instead of a warning if the variable have different types.
1 parent b2bddc2 commit 1fbb06d

File tree

4 files changed

+25
-26
lines changed

4 files changed

+25
-26
lines changed

src/interfaces/ecpg/preproc/descriptor.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* functions needed for descriptor handling
33
*
4-
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/descriptor.c,v 1.33 2010/04/01 08:41:01 meskes Exp $
4+
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/descriptor.c,v 1.34 2010/04/01 10:30:53 meskes Exp $
55
*
66
* since descriptor might be either a string constant or a string var
77
* we need to check for a constant if we expect a constant
@@ -188,7 +188,7 @@ output_get_descr(char *desc_name, char *index)
188188
break;
189189
}
190190
fprintf(yyout, "%s,", get_dtype(results->value));
191-
ECPGdump_a_type(yyout, v->name, v->type, NULL, NULL, NULL, NULL, make_str("0"), NULL, NULL, v->brace_level, -1);
191+
ECPGdump_a_type(yyout, v->name, v->type, v->brace_level, NULL, NULL, -1, NULL, NULL, make_str("0"), NULL, NULL);
192192
}
193193
drop_assignments();
194194
fputs("ECPGd_EODT);\n", yyout);
@@ -293,7 +293,7 @@ output_set_descr(char *desc_name, char *index)
293293
case ECPGd_length:
294294
case ECPGd_type:
295295
fprintf(yyout, "%s,", get_dtype(results->value));
296-
ECPGdump_a_type(yyout, v->name, v->type, NULL, NULL, NULL, NULL, make_str("0"), NULL, NULL, v->brace_level, -1);
296+
ECPGdump_a_type(yyout, v->name, v->type, v->brace_level, NULL, NULL, -1, NULL, NULL, make_str("0"), NULL, NULL);
297297
break;
298298

299299
default:

src/interfaces/ecpg/preproc/type.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/type.c,v 1.89 2010/04/01 08:41:01 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/type.c,v 1.90 2010/04/01 10:30:53 meskes Exp $ */
22

33
#include "postgres_fe.h"
44

@@ -236,12 +236,11 @@ static void ECPGdump_a_struct(FILE *o, const char *name, const char *ind_name, c
236236
struct ECPGtype * type, struct ECPGtype * ind_type, const char *prefix, const char *ind_prefix);
237237

238238
void
239-
ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type,
240-
const char *ind_name, struct ECPGtype * ind_type,
239+
ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type, const int brace_level,
240+
const char *ind_name, struct ECPGtype * ind_type, const int ind_brace_level,
241241
const char *prefix, const char *ind_prefix,
242242
char *arr_str_siz, const char *struct_sizeof,
243-
const char *ind_struct_sizeof,
244-
const int brace_level, const int ind_brace_level)
243+
const char *ind_struct_sizeof)
245244
{
246245
struct variable *var;
247246

@@ -251,28 +250,29 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type,
251250
{
252251
char *str;
253252

254-
str = strdup(name);
253+
str = mm_strdup(name);
255254
var = find_variable(str);
256255
free(str);
257256

258257
if ((var->type->type != type->type) ||
259258
(var->type->type_name && !type->type_name) ||
260259
(!var->type->type_name && type->type_name) ||
261260
(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);
261+
mmerror(PARSE_ERROR, ET_FATAL, "variable (%s) is hidden by a local variable of a different type", name);
263262
else if (var->brace_level != brace_level)
264263
mmerror(PARSE_ERROR, ET_WARNING, "variable (%s) is hidden by a local variable", name);
265264

266265
if (ind_name && ind_type && ind_type->type != ECPGt_NO_INDICATOR && ind_brace_level >= 0)
267266
{
268-
str = strdup(ind_name);
267+
str = mm_strdup(ind_name);
269268
var = find_variable(str);
270269
free(str);
270+
271271
if ((var->type->type != ind_type->type) ||
272272
(var->type->type_name && !ind_type->type_name) ||
273273
(!var->type->type_name && ind_type->type_name) ||
274274
(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);
275+
mmerror(PARSE_ERROR, ET_FATAL, "indicator variable (%s) is hidden by a local variable of a different type", ind_name);
276276
else if (var->brace_level != ind_brace_level)
277277
mmerror(PARSE_ERROR, ET_WARNING, "indicator variable (%s) is hidden by a local variable", ind_name);
278278
}
@@ -535,12 +535,12 @@ ECPGdump_a_struct(FILE *o, const char *name, const char *ind_name, char *arrsiz,
535535

536536
for (p = type->u.members; p; p = p->next)
537537
{
538-
ECPGdump_a_type(o, p->name, p->type,
538+
ECPGdump_a_type(o, p->name, p->type, -1,
539539
(ind_p != NULL) ? ind_p->name : NULL,
540540
(ind_p != NULL) ? ind_p->type : NULL,
541+
-1,
541542
prefix, ind_prefix, arrsiz, type->struct_sizeof,
542-
(ind_p != NULL) ? ind_type->struct_sizeof : NULL,
543-
-1, -1);
543+
(ind_p != NULL) ? ind_type->struct_sizeof : NULL);
544544
if (ind_p != NULL && ind_p != &struct_no_indicator)
545545
ind_p = ind_p->next;
546546
}

src/interfaces/ecpg/preproc/type.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/type.h,v 1.55 2010/04/01 08:41:01 meskes Exp $
2+
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/type.h,v 1.56 2010/04/01 10:30:53 meskes Exp $
33
*/
44
#ifndef _ECPG_PREPROC_TYPE_H
55
#define _ECPG_PREPROC_TYPE_H
@@ -55,10 +55,10 @@ void ECPGfree_type(struct ECPGtype *);
5555
size is the maxsize in case it is a varchar. Otherwise it is the size of
5656
the variable (required to do array fetches of structs).
5757
*/
58-
void ECPGdump_a_type(FILE *, const char *, struct ECPGtype *,
59-
const char *, struct ECPGtype *, const char *,
60-
const char *, char *, const char *, const char *,
61-
const int, const int);
58+
void ECPGdump_a_type(FILE *, const char *, struct ECPGtype *, const int,
59+
const char *, struct ECPGtype *, const int,
60+
const char *, const char *, char *,
61+
const char *, const char *);
6262

6363
/* A simple struct to keep a variable and its type. */
6464
struct ECPGtemp_type

src/interfaces/ecpg/preproc/variable.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/variable.c,v 1.55 2010/04/01 08:41:01 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/variable.c,v 1.56 2010/04/01 10:30:53 meskes Exp $ */
22

33
#include "postgres_fe.h"
44

@@ -22,7 +22,7 @@ new_variable(const char *name, struct ECPGtype * type, int brace_level)
2222
}
2323

2424
static struct variable *
25-
find_struct_member(const char *name, char *str, struct ECPGstruct_member * members, int brace_level)
25+
find_struct_member(char *name, char *str, struct ECPGstruct_member * members, int brace_level)
2626
{
2727
char *next = strpbrk(++str, ".-["),
2828
*end,
@@ -444,10 +444,9 @@ dump_variables(struct arguments * list, int mode)
444444
dump_variables(list->next, mode);
445445

446446
/* Then the current element and its indicator */
447-
ECPGdump_a_type(yyout, list->variable->name, list->variable->type,
448-
list->indicator->name, list->indicator->type,
449-
NULL, NULL, make_str("0"), NULL, NULL,
450-
list->variable->brace_level, list->indicator->brace_level);
447+
ECPGdump_a_type(yyout, list->variable->name, list->variable->type, list->variable->brace_level,
448+
list->indicator->name, list->indicator->type, list->indicator->brace_level,
449+
NULL, NULL, make_str("0"), NULL, NULL);
451450

452451
/* Then release the list element. */
453452
if (mode != 0)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy