summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meskes2001-12-08 20:43:35 +0000
committerMichael Meskes2001-12-08 20:43:35 +0000
commitd6fbb105560bc04eaf745a91e802052a23d7c029 (patch)
tree8531403665a1c4dd0de0697d37cec0117e23f52b
parent03a321d2143cd1168d10960cada9d688c5140520 (diff)
Fix ecpg to allow pointer to structs.
-rw-r--r--src/interfaces/ecpg/ChangeLog4
-rw-r--r--src/interfaces/ecpg/preproc/type.c14
-rw-r--r--src/interfaces/ecpg/test/test2.pgc9
3 files changed, 20 insertions, 7 deletions
diff --git a/src/interfaces/ecpg/ChangeLog b/src/interfaces/ecpg/ChangeLog
index 86bb7873536..6f742a65cfa 100644
--- a/src/interfaces/ecpg/ChangeLog
+++ b/src/interfaces/ecpg/ChangeLog
@@ -1166,5 +1166,9 @@ Thu Dec 6 14:02:56 CET 2001
- Removed debug message from preproc.y.
- Fixed some bugs in exec sql var and exec sql type command.
+
+Sat Dec 8 21:35:45 CET 2001
+
+ - Fix ecpg to allow pointer to structs.
- Set ecpg version to 2.9.0.
- Set library version to 3.3.0.
diff --git a/src/interfaces/ecpg/preproc/type.c b/src/interfaces/ecpg/preproc/type.c
index 0be9ef78157..c0cfad9ff26 100644
--- a/src/interfaces/ecpg/preproc/type.c
+++ b/src/interfaces/ecpg/preproc/type.c
@@ -361,7 +361,7 @@ ECPGdump_a_struct(FILE *o, const char *name, const char *ind_name, long arrsiz,
struct ECPGstruct_member *p,
*ind_p = NULL;
char obuf[BUFSIZ];
- char pbuf[BUFSIZ],
+ char pbuf[BUFSIZ*2],
ind_pbuf[BUFSIZ];
const char *offset;
@@ -373,7 +373,11 @@ ECPGdump_a_struct(FILE *o, const char *name, const char *ind_name, long arrsiz,
else
offset = offsetarg;
- sprintf(pbuf, "%s%s.", prefix ? prefix : "", name);
+ if (arrsiz != 0)
+ sprintf(pbuf, "%s%s.", prefix ? prefix : "", name);
+ else
+ sprintf(pbuf, "%s%s->", prefix ? prefix : "", name);
+
prefix = pbuf;
if (ind_typ == &ecpg_no_indicator)
@@ -382,7 +386,11 @@ ECPGdump_a_struct(FILE *o, const char *name, const char *ind_name, long arrsiz,
}
else if (ind_typ != NULL)
{
- sprintf(ind_pbuf, "%s%s.", ind_prefix ? ind_prefix : "", ind_name);
+ if (arrsiz != 0)
+ sprintf(ind_pbuf, "%s%s.", ind_prefix ? ind_prefix : "", ind_name);
+ else
+ sprintf(ind_pbuf, "%s%s->", ind_prefix ? ind_prefix : "", ind_name);
+
ind_prefix = ind_pbuf;
ind_p = ind_typ->u.members;
}
diff --git a/src/interfaces/ecpg/test/test2.pgc b/src/interfaces/ecpg/test/test2.pgc
index ec2c790d2b4..299250dfa5d 100644
--- a/src/interfaces/ecpg/test/test2.pgc
+++ b/src/interfaces/ecpg/test/test2.pgc
@@ -19,10 +19,10 @@ main ()
exec sql begin declare section;
struct personal_struct { str name;
birthinfo birth;
- } personal;
+ } personal, *p;
struct personal_indicator { int ind_name;
birthinfo ind_birth;
- } ind_personal;
+ } ind_personal, *i;
float ind_married;
ind children;
ind ind_children;
@@ -63,9 +63,11 @@ exec sql end declare section;
exec sql whenever not found do break;
+ p=&personal;
+ i=&ind_personal;
while (1) {
strcpy(msg, "fetch");
- exec sql fetch cur into :personal:ind_personal, :married:ind_married, :children.integer:ind_children.smallint;
+ exec sql fetch cur into :p:i, :married:ind_married, :children.integer:ind_children.smallint;
printf("%8.8s", personal.name.arr);
if (ind_personal.ind_birth.born >= 0)
printf(", born %ld", personal.birth.born);
@@ -125,6 +127,5 @@ exec sql end declare section;
if (dbgs != NULL)
fclose(dbgs);
-
return (0);
}