Fix ecpg to allow pointer to structs.
authorMichael Meskes
Sat, 8 Dec 2001 20:43:35 +0000 (20:43 +0000)
committerMichael Meskes
Sat, 8 Dec 2001 20:43:35 +0000 (20:43 +0000)
src/interfaces/ecpg/ChangeLog
src/interfaces/ecpg/preproc/type.c
src/interfaces/ecpg/test/test2.pgc

index 86bb78735362dd2aafd7ab3f0a529dac7fc7e4ef..6f742a65cfaafc13211820e563e20a6a44fe615d 100644 (file)
@@ -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.
index 0be9ef78157d6bd8425a656db1d93b254bc6049a..c0cfad9ff26ae8cb6ba505311aa8a7650225d231 100644 (file)
@@ -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;
    }
index ec2c790d2b4d430b60adc6b4a02066d7bc08c46e..299250dfa5d4188920f523d6921e3954ed21ec4e 100644 (file)
@@ -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);
 }