Commit 7138a1e5 authored by Michael Meskes's avatar Michael Meskes

- Fixed variable handling for struct members.

        - Removed check for array input. An attribut might store the
          complete array.
parent 4b20cc10
...@@ -1201,5 +1201,11 @@ Fri Jan 11 15:43:39 CET 2002 ...@@ -1201,5 +1201,11 @@ Fri Jan 11 15:43:39 CET 2002
- clear sqlca on : [de]allocate descriptor & get descriptor and set - clear sqlca on : [de]allocate descriptor & get descriptor and set
sqlca.sqlerrd[2] accordingly (Christof). 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 ecpg version to 2.9.0.
- Set library version to 3.3.0. - Set library version to 3.3.0.
/* $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. * 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, ...@@ -486,14 +486,15 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
char *newcopy = NULL; 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); ECPGraise(stmt->lineno, ECPG_ARRAY_INSERT, NULL);
return false; return false;
} }*/
/* /*
* Some special treatment is needed for records since we want their * Some special treatment is needed for records since we want their
......
...@@ -75,7 +75,7 @@ extern void adjust_array(enum ECPGttype, int *, int *, int, int, int); ...@@ -75,7 +75,7 @@ extern void adjust_array(enum ECPGttype, int *, int *, int, int, int);
extern void reset_variables(void); extern void reset_variables(void);
extern void check_indicator(struct ECPGtype *); extern void check_indicator(struct ECPGtype *);
extern void remove_variables(int); 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); extern ScanKeyword *ScanKeywordLookup(char *text);
/* return codes */ /* return codes */
......
...@@ -4417,7 +4417,7 @@ variable: opt_pointer ECPGColLabel opt_array_bounds opt_initializer ...@@ -4417,7 +4417,7 @@ variable: opt_pointer ECPGColLabel opt_array_bounds opt_initializer
} }
if (struct_level == 0) if (struct_level == 0)
new_variable($2, type); new_variable($2, type, braces_open);
else else
ECPGmake_struct_member($2, type, &(struct_member_list[struct_level - 1])); ECPGmake_struct_member($2, type, &(struct_member_list[struct_level - 1]));
......
...@@ -5,13 +5,13 @@ ...@@ -5,13 +5,13 @@
struct variable *allvariables = NULL; struct variable *allvariables = NULL;
struct variable * 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)); struct variable *p = (struct variable *) mm_alloc(sizeof(struct variable));
p->name = mm_strdup(name); p->name = mm_strdup(name);
p->type = type; p->type = type;
p->brace_level = braces_open; p->brace_level = brace_level;
p->next = allvariables; p->next = allvariables;
allvariables = p; allvariables = p;
...@@ -20,7 +20,7 @@ new_variable(const char *name, struct ECPGtype * type) ...@@ -20,7 +20,7 @@ new_variable(const char *name, struct ECPGtype * type)
} }
static struct variable * 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, '.'), char *next = strchr(++str, '.'),
c = '\0'; c = '\0';
...@@ -41,12 +41,12 @@ find_struct_member(char *name, char *str, struct ECPGstruct_member * members) ...@@ -41,12 +41,12 @@ find_struct_member(char *name, char *str, struct ECPGstruct_member * members)
switch (members->type->type) switch (members->type->type)
{ {
case ECPGt_array: 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_struct:
case ECPGt_union: 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: 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 else
...@@ -55,10 +55,10 @@ find_struct_member(char *name, char *str, struct ECPGstruct_member * members) ...@@ -55,10 +55,10 @@ find_struct_member(char *name, char *str, struct ECPGstruct_member * members)
if (c == '-') if (c == '-')
{ {
next++; 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 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) ...@@ -94,7 +94,7 @@ find_struct(char *name, char *next)
*next = c; *next = c;
next++; 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 else
{ {
...@@ -107,7 +107,7 @@ find_struct(char *name, char *next) ...@@ -107,7 +107,7 @@ find_struct(char *name, char *next)
/* restore the name, we will need it later on */ /* restore the name, we will need it later on */
*next = c; *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);
} }
} }
......
#include <string.h> #include <string.h>
exec sql include sqlca;
/* just a test comment */ exec sql whenever sqlerror do PrintAndStop(msg); /* just a test comment */ exec sql whenever sqlerror do PrintAndStop(msg);
exec sql whenever sqlwarning do warn(); exec sql whenever sqlwarning do warn();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment