From 7138a1e5fc034640afe1c570b426b325389377f4 Mon Sep 17 00:00:00 2001 From: Michael Meskes Date: Sun, 13 Jan 2002 08:52:09 +0000 Subject: [PATCH] - Fixed variable handling for struct members. - Removed check for array input. An attribut might store the complete array. --- src/interfaces/ecpg/ChangeLog | 6 ++++++ src/interfaces/ecpg/lib/execute.c | 11 ++++++----- src/interfaces/ecpg/preproc/extern.h | 2 +- src/interfaces/ecpg/preproc/preproc.y | 2 +- src/interfaces/ecpg/preproc/variable.c | 20 ++++++++++---------- src/interfaces/ecpg/test/test1.pgc | 2 -- 6 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/interfaces/ecpg/ChangeLog b/src/interfaces/ecpg/ChangeLog index 70ad65acf7..da687ae1ab 100644 --- a/src/interfaces/ecpg/ChangeLog +++ b/src/interfaces/ecpg/ChangeLog @@ -1201,5 +1201,11 @@ Fri Jan 11 15:43:39 CET 2002 - clear sqlca on : [de]allocate descriptor & get descriptor and set sqlca.sqlerrd[2] accordingly (Christof). + +Sat Jan 12 22:04:02 CET 2002 + + - Fixed variable handling for struct members. + - Removed check for array input. An attribut might store the + complete array. - Set ecpg version to 2.9.0. - Set library version to 3.3.0. diff --git a/src/interfaces/ecpg/lib/execute.c b/src/interfaces/ecpg/lib/execute.c index dba99a1bd6..33941a7f89 100644 --- a/src/interfaces/ecpg/lib/execute.c +++ b/src/interfaces/ecpg/lib/execute.c @@ -1,4 +1,4 @@ -/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/execute.c,v 1.35 2002/01/08 14:25:04 meskes Exp $ */ +/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/execute.c,v 1.36 2002/01/13 08:52:08 meskes Exp $ */ /* * The aim is to get a simpler inteface to the database routines. @@ -486,14 +486,15 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var, char *newcopy = NULL; /* - * arrays are not possible + * arrays are not possible unless the attribute is an array too + * FIXME: we do not know if the attribute is an array here */ - - if (var->arrsize > 1) + +/* if (var->arrsize > 1 && ...) { ECPGraise(stmt->lineno, ECPG_ARRAY_INSERT, NULL); return false; - } + }*/ /* * Some special treatment is needed for records since we want their diff --git a/src/interfaces/ecpg/preproc/extern.h b/src/interfaces/ecpg/preproc/extern.h index 985971647b..358a141025 100644 --- a/src/interfaces/ecpg/preproc/extern.h +++ b/src/interfaces/ecpg/preproc/extern.h @@ -75,7 +75,7 @@ extern void adjust_array(enum ECPGttype, int *, int *, int, int, int); extern void reset_variables(void); extern void check_indicator(struct ECPGtype *); extern void remove_variables(int); -extern struct variable *new_variable(const char *, struct ECPGtype *); +extern struct variable *new_variable(const char *, struct ECPGtype *, int); extern ScanKeyword *ScanKeywordLookup(char *text); /* return codes */ diff --git a/src/interfaces/ecpg/preproc/preproc.y b/src/interfaces/ecpg/preproc/preproc.y index 54c64d216e..d94f2a78c5 100644 --- a/src/interfaces/ecpg/preproc/preproc.y +++ b/src/interfaces/ecpg/preproc/preproc.y @@ -4417,7 +4417,7 @@ variable: opt_pointer ECPGColLabel opt_array_bounds opt_initializer } if (struct_level == 0) - new_variable($2, type); + new_variable($2, type, braces_open); else ECPGmake_struct_member($2, type, &(struct_member_list[struct_level - 1])); diff --git a/src/interfaces/ecpg/preproc/variable.c b/src/interfaces/ecpg/preproc/variable.c index 3131a76592..cee7ab3cf5 100644 --- a/src/interfaces/ecpg/preproc/variable.c +++ b/src/interfaces/ecpg/preproc/variable.c @@ -5,13 +5,13 @@ struct variable *allvariables = NULL; struct variable * -new_variable(const char *name, struct ECPGtype * type) +new_variable(const char *name, struct ECPGtype * type, int brace_level) { struct variable *p = (struct variable *) mm_alloc(sizeof(struct variable)); p->name = mm_strdup(name); p->type = type; - p->brace_level = braces_open; + p->brace_level = brace_level; p->next = allvariables; allvariables = p; @@ -20,7 +20,7 @@ new_variable(const char *name, struct ECPGtype * type) } static struct variable * -find_struct_member(char *name, char *str, struct ECPGstruct_member * members) +find_struct_member(char *name, char *str, struct ECPGstruct_member * members, int brace_level) { char *next = strchr(++str, '.'), c = '\0'; @@ -41,12 +41,12 @@ find_struct_member(char *name, char *str, struct ECPGstruct_member * members) switch (members->type->type) { case ECPGt_array: - return (new_variable(name, ECPGmake_array_type(members->type->u.element, members->type->size))); + return (new_variable(name, ECPGmake_array_type(members->type->u.element, members->type->size), brace_level)); case ECPGt_struct: case ECPGt_union: - return (new_variable(name, ECPGmake_struct_type(members->type->u.members, members->type->type, members->type->struct_sizeof))); + return (new_variable(name, ECPGmake_struct_type(members->type->u.members, members->type->type, members->type->struct_sizeof), brace_level)); default: - return (new_variable(name, ECPGmake_simple_type(members->type->type, members->type->size))); + return (new_variable(name, ECPGmake_simple_type(members->type->type, members->type->size), brace_level)); } } else @@ -55,10 +55,10 @@ find_struct_member(char *name, char *str, struct ECPGstruct_member * members) if (c == '-') { next++; - return (find_struct_member(name, next, members->type->u.element->u.members)); + return (find_struct_member(name, next, members->type->u.element->u.members, brace_level)); } else - return (find_struct_member(name, next, members->type->u.members)); + return (find_struct_member(name, next, members->type->u.members, brace_level)); } } } @@ -94,7 +94,7 @@ find_struct(char *name, char *next) *next = c; next++; - return find_struct_member(name, next, p->type->u.element->u.members); + return find_struct_member(name, next, p->type->u.element->u.members, p->brace_level); } else { @@ -107,7 +107,7 @@ find_struct(char *name, char *next) /* restore the name, we will need it later on */ *next = c; - return find_struct_member(name, next, p->type->u.members); + return find_struct_member(name, next, p->type->u.members, p->brace_level); } } diff --git a/src/interfaces/ecpg/test/test1.pgc b/src/interfaces/ecpg/test/test1.pgc index b5e745da8e..a539c72a9e 100644 --- a/src/interfaces/ecpg/test/test1.pgc +++ b/src/interfaces/ecpg/test/test1.pgc @@ -1,7 +1,5 @@ #include -exec sql include sqlca; - /* just a test comment */ exec sql whenever sqlerror do PrintAndStop(msg); exec sql whenever sqlwarning do warn(); -- 2.40.0