提交 1fbb06d2 编写于 作者: M Michael Meskes

Zoltan beautified his hidden-variable-patch for ecpg. This also makes sure we...

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.
上级 b2bddc2f
/*
* functions needed for descriptor handling
*
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/descriptor.c,v 1.33 2010/04/01 08:41:01 meskes Exp $
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/descriptor.c,v 1.34 2010/04/01 10:30:53 meskes Exp $
*
* since descriptor might be either a string constant or a string var
* we need to check for a constant if we expect a constant
......@@ -188,7 +188,7 @@ output_get_descr(char *desc_name, char *index)
break;
}
fprintf(yyout, "%s,", get_dtype(results->value));
ECPGdump_a_type(yyout, v->name, v->type, NULL, NULL, NULL, NULL, make_str("0"), NULL, NULL, v->brace_level, -1);
ECPGdump_a_type(yyout, v->name, v->type, v->brace_level, NULL, NULL, -1, NULL, NULL, make_str("0"), NULL, NULL);
}
drop_assignments();
fputs("ECPGd_EODT);\n", yyout);
......@@ -293,7 +293,7 @@ output_set_descr(char *desc_name, char *index)
case ECPGd_length:
case ECPGd_type:
fprintf(yyout, "%s,", get_dtype(results->value));
ECPGdump_a_type(yyout, v->name, v->type, NULL, NULL, NULL, NULL, make_str("0"), NULL, NULL, v->brace_level, -1);
ECPGdump_a_type(yyout, v->name, v->type, v->brace_level, NULL, NULL, -1, NULL, NULL, make_str("0"), NULL, NULL);
break;
default:
......
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/type.c,v 1.89 2010/04/01 08:41:01 meskes Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/type.c,v 1.90 2010/04/01 10:30:53 meskes Exp $ */
#include "postgres_fe.h"
......@@ -236,12 +236,11 @@ static void ECPGdump_a_struct(FILE *o, const char *name, const char *ind_name, c
struct ECPGtype * type, struct ECPGtype * ind_type, const char *prefix, const char *ind_prefix);
void
ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type,
const char *ind_name, struct ECPGtype * ind_type,
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_siz, const char *struct_sizeof,
const char *ind_struct_sizeof,
const int brace_level, const int ind_brace_level)
const char *ind_struct_sizeof)
{
struct variable *var;
......@@ -251,7 +250,7 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type,
{
char *str;
str = strdup(name);
str = mm_strdup(name);
var = find_variable(str);
free(str);
......@@ -259,20 +258,21 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type,
(var->type->type_name && !type->type_name) ||
(!var->type->type_name && type->type_name) ||
(var->type->type_name && type->type_name && strcmp(var->type->type_name, type->type_name)))
mmerror(PARSE_ERROR, ET_WARNING, "variable (%s) is hidden by a local variable of a different type", name);
mmerror(PARSE_ERROR, ET_FATAL, "variable (%s) is hidden by a local variable of a different type", name);
else if (var->brace_level != brace_level)
mmerror(PARSE_ERROR, ET_WARNING, "variable (%s) is hidden by a local variable", name);
if (ind_name && ind_type && ind_type->type != ECPGt_NO_INDICATOR && ind_brace_level >= 0)
{
str = strdup(ind_name);
str = mm_strdup(ind_name);
var = find_variable(str);
free(str);
if ((var->type->type != ind_type->type) ||
(var->type->type_name && !ind_type->type_name) ||
(!var->type->type_name && ind_type->type_name) ||
(var->type->type_name && ind_type->type_name && strcmp(var->type->type_name, ind_type->type_name)))
mmerror(PARSE_ERROR, ET_WARNING, "indicator variable (%s) is hidden by a local variable of a different type", ind_name);
mmerror(PARSE_ERROR, ET_FATAL, "indicator variable (%s) is hidden by a local variable of a different type", ind_name);
else if (var->brace_level != ind_brace_level)
mmerror(PARSE_ERROR, ET_WARNING, "indicator variable (%s) is hidden by a local variable", ind_name);
}
......@@ -535,12 +535,12 @@ ECPGdump_a_struct(FILE *o, const char *name, const char *ind_name, char *arrsiz,
for (p = type->u.members; p; p = p->next)
{
ECPGdump_a_type(o, p->name, p->type,
ECPGdump_a_type(o, p->name, p->type, -1,
(ind_p != NULL) ? ind_p->name : NULL,
(ind_p != NULL) ? ind_p->type : NULL,
-1,
prefix, ind_prefix, arrsiz, type->struct_sizeof,
(ind_p != NULL) ? ind_type->struct_sizeof : NULL,
-1, -1);
(ind_p != NULL) ? ind_type->struct_sizeof : NULL);
if (ind_p != NULL && ind_p != &struct_no_indicator)
ind_p = ind_p->next;
}
......
/*
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/type.h,v 1.55 2010/04/01 08:41:01 meskes Exp $
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/type.h,v 1.56 2010/04/01 10:30:53 meskes Exp $
*/
#ifndef _ECPG_PREPROC_TYPE_H
#define _ECPG_PREPROC_TYPE_H
......@@ -55,10 +55,10 @@ void ECPGfree_type(struct ECPGtype *);
size is the maxsize in case it is a varchar. Otherwise it is the size of
the variable (required to do array fetches of structs).
*/
void ECPGdump_a_type(FILE *, const char *, struct ECPGtype *,
const char *, struct ECPGtype *, const char *,
const char *, char *, const char *, const char *,
const int, const int);
void ECPGdump_a_type(FILE *, const char *, struct ECPGtype *, const int,
const char *, struct ECPGtype *, const int,
const char *, const char *, char *,
const char *, const char *);
/* A simple struct to keep a variable and its type. */
struct ECPGtemp_type
......
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/variable.c,v 1.55 2010/04/01 08:41:01 meskes Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/variable.c,v 1.56 2010/04/01 10:30:53 meskes Exp $ */
#include "postgres_fe.h"
......@@ -22,7 +22,7 @@ new_variable(const char *name, struct ECPGtype * type, int brace_level)
}
static struct variable *
find_struct_member(const char *name, char *str, struct ECPGstruct_member * members, int brace_level)
find_struct_member(char *name, char *str, struct ECPGstruct_member * members, int brace_level)
{
char *next = strpbrk(++str, ".-["),
*end,
......@@ -444,10 +444,9 @@ dump_variables(struct arguments * list, int mode)
dump_variables(list->next, mode);
/* Then the current element and its indicator */
ECPGdump_a_type(yyout, list->variable->name, list->variable->type,
list->indicator->name, list->indicator->type,
NULL, NULL, make_str("0"), NULL, NULL,
list->variable->brace_level, list->indicator->brace_level);
ECPGdump_a_type(yyout, list->variable->name, list->variable->type, list->variable->brace_level,
list->indicator->name, list->indicator->type, list->indicator->brace_level,
NULL, NULL, make_str("0"), NULL, NULL);
/* Then release the list element. */
if (mode != 0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册