]> granicus.if.org Git - postgresql/commitdiff
*** empty log message ***
authorMichael Meskes <meskes@postgresql.org>
Wed, 16 Feb 2000 11:52:25 +0000 (11:52 +0000)
committerMichael Meskes <meskes@postgresql.org>
Wed, 16 Feb 2000 11:52:25 +0000 (11:52 +0000)
src/interfaces/ecpg/ChangeLog
src/interfaces/ecpg/TODO
src/interfaces/ecpg/lib/Makefile.in
src/interfaces/ecpg/lib/ecpglib.c
src/interfaces/ecpg/test/Makefile
src/interfaces/ecpg/test/test1.pgc
src/interfaces/ecpg/test/test4.pgc

index defc1cfa0fb42a5a58156df85783af8901e5026a..3d5828f6ba6bb5f06d8e1b7ab899bee0ca94e351 100644 (file)
@@ -799,5 +799,15 @@ Tue Feb 15 11:14:07 CET 2000
 
        - Synced keyword.c.
        - Synced preproc.y with gram.y.
+
+Tue Feb 15 17:39:19 CET 2000
+
+       - Do only write the first 70 bytes of the error message to the 
+         sqlca structure since there are only 70 bytes free space.
        - Set library version to 3.0.10.
+
+Wed Feb 16 11:57:02 CET 2000
+
+       - Fixed library to be able to input complete arrays.
+       - Set library version to 3.1.0.
        - Set ecpg version to 2.7.0.
index 16af86864372b67601d0a3dca48c50ce11b1a32c..542894945d18147d5780e0bd1e0734f40d3e1a14 100644 (file)
@@ -13,7 +13,8 @@ stderr. Instead it should be listed as a warning.
 The error handling has to be improved by adding additional error-rules to
 the parser.
 
-it would be nice to be able to use :var[:index] as cvariable for an array var
+it would be nice to be able to use :var[:index] or :var[<integer>] as
+cvariable for an array var
 
 How can one insert arrays from c variables?
 
index 0fcbc7b808d6f057b58c623c384a88187c2df8e3..296c3c5a409ed2d28c784eeab1bdfc32dadc64c3 100644 (file)
@@ -6,13 +6,13 @@
 # Copyright (c) 1994, Regents of the University of California
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/Makefile.in,v 1.56 2000/01/18 13:03:47 meskes Exp $
+#    $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/Makefile.in,v 1.57 2000/02/16 11:52:24 meskes Exp $
 #
 #-------------------------------------------------------------------------
 
 NAME= ecpg
 SO_MAJOR_VERSION= 3
-SO_MINOR_VERSION= 0.10
+SO_MINOR_VERSION= 1.0
 
 SRCDIR= @top_srcdir@
 include $(SRCDIR)/Makefile.global
index 205a051a1e76eacbd3632f707a66eb5dcb82743a..5074bc20e07a361f6ef580eb784d585e45c43eb8 100644 (file)
@@ -414,7 +414,7 @@ ECPGexecute(struct statement * stmt)
                char       *mallocedval = NULL;
                char       *tobeinserted = NULL;
                char       *p;
-               char            buff[20];
+               char        buff[20];
 
                /*
                 * Some special treatment is needed for records since we want
@@ -450,49 +450,132 @@ ECPGexecute(struct statement * stmt)
                {
                        switch (var->type)
                        {
+                               int element;
+                               
                                case ECPGt_short:
-                                       sprintf(buff, "%d", *(short *) var->value);
-                                       tobeinserted = buff;
+                                       if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno)))
+                                               return false;
+
+                                       sprintf(mallocedval, "%s", (var->arrsize > 1) ? "'{" : ""); 
+                                               
+                                       for (element = 0; element < var->arrsize; element++)
+                                               sprintf(mallocedval + strlen(mallocedval), "%d,", ((short *) var->value)[element]);
+                                               
+                                       sprintf(mallocedval + strlen(mallocedval) - 1, "%s", (var->arrsize > 1) ? "}'" : ""); 
+
+                                       tobeinserted = mallocedval;
                                        break;
 
                                case ECPGt_int:
-                                       sprintf(buff, "%d", *(int *) var->value);
-                                       tobeinserted = buff;
+                                       if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno)))
+                                               return false;
+
+                                       sprintf(mallocedval, "%s", (var->arrsize > 1) ? "'{" : ""); 
+                                               
+                                       for (element = 0; element < var->arrsize; element++)
+                                               sprintf(mallocedval + strlen(mallocedval), "%d,", ((int *) var->value)[element]);
+                                               
+                                       sprintf(mallocedval + strlen(mallocedval) - 1, "%s", (var->arrsize > 1) ? "}'" : ""); 
+
+                                       tobeinserted = mallocedval;
                                        break;
 
                                case ECPGt_unsigned_short:
-                                       sprintf(buff, "%d", *(unsigned short *) var->value);
-                                       tobeinserted = buff;
+                                       if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno)))
+                                               return false;
+
+                                       sprintf(mallocedval, "%s", (var->arrsize > 1) ? "'{" : ""); 
+                                               
+                                       for (element = 0; element < var->arrsize; element++)
+                                               sprintf(mallocedval + strlen(mallocedval), "%d,", ((unsigned short *) var->value)[element]);
+                                               
+                                       sprintf(mallocedval + strlen(mallocedval) - 1, "%s", (var->arrsize > 1) ? "}'" : ""); 
+
+                                       tobeinserted = mallocedval;
                                        break;
 
                                case ECPGt_unsigned_int:
-                                       sprintf(buff, "%d", *(unsigned int *) var->value);
-                                       tobeinserted = buff;
+                                       if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno)))
+                                               return false;
+
+                                       sprintf(mallocedval, "%s", (var->arrsize > 1) ? "'{" : ""); 
+                                               
+                                       for (element = 0; element < var->arrsize; element++)
+                                               sprintf(mallocedval + strlen(mallocedval), "%d,", ((unsigned int *) var->value)[element]);
+                                               
+                                       sprintf(mallocedval + strlen(mallocedval) - 1, "%s", (var->arrsize > 1) ? "}'" : ""); 
+
+                                       tobeinserted = mallocedval;
                                        break;
 
                                case ECPGt_long:
-                                       sprintf(buff, "%ld", *(long *) var->value);
-                                       tobeinserted = buff;
+                                       if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno)))
+                                               return false;
+
+                                       sprintf(mallocedval, "%s", (var->arrsize > 1) ? "'{" : ""); 
+                                               
+                                       for (element = 0; element < var->arrsize; element++)
+                                               sprintf(mallocedval + strlen(mallocedval), "%ld,", ((long *) var->value)[element]);
+                                               
+                                       sprintf(mallocedval + strlen(mallocedval) - 1, "%s", (var->arrsize > 1) ? "}'" : ""); 
+
+                                       tobeinserted = mallocedval;
                                        break;
 
                                case ECPGt_unsigned_long:
-                                       sprintf(buff, "%ld", *(unsigned long *) var->value);
-                                       tobeinserted = buff;
+                                       if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno)))
+                                               return false;
+
+                                       sprintf(mallocedval, "%s", (var->arrsize > 1) ? "'{" : ""); 
+                                               
+                                       for (element = 0; element < var->arrsize; element++)
+                                               sprintf(mallocedval + strlen(mallocedval), "%ld,", ((unsigned long *) var->value)[element]);
+                                               
+                                       sprintf(mallocedval + strlen(mallocedval) - 1, "%s", (var->arrsize > 1) ? "}'" : ""); 
+
+                                       tobeinserted = mallocedval;
                                        break;
 
                                case ECPGt_float:
-                                       sprintf(buff, "%.14g", *(float *) var->value);
-                                       tobeinserted = buff;
+                                       if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno)))
+                                               return false;
+
+                                       sprintf(mallocedval, "%s", (var->arrsize > 1) ? "'{" : ""); 
+                                               
+                                       for (element = 0; element < var->arrsize; element++)
+                                               sprintf(mallocedval + strlen(mallocedval), "%.14g,", ((float *) var->value)[element]);
+                                               
+                                       sprintf(mallocedval + strlen(mallocedval) - 1, "%s", (var->arrsize > 1) ? "}'" : ""); 
+
+                                       tobeinserted = mallocedval;
                                        break;
 
                                case ECPGt_double:
-                                       sprintf(buff, "%.14g", *(double *) var->value);
-                                       tobeinserted = buff;
+                                       if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno)))
+                                               return false;
+
+                                       sprintf(mallocedval, "%s", (var->arrsize > 1) ? "'{" : ""); 
+                                               
+                                       for (element = 0; element < var->arrsize; element++)
+                                               sprintf(mallocedval + strlen(mallocedval), "%.14g,", ((double *) var->value)[element]);
+                                               
+                                       sprintf(mallocedval + strlen(mallocedval) - 1, "%s", (var->arrsize > 1) ? "}'" : ""); 
+
+                                       tobeinserted = mallocedval;
                                        break;
 
                                case ECPGt_bool:
-                                       sprintf(buff, "'%c'", (*(char *) var->value ? 't' : 'f'));
-                                       tobeinserted = buff;
+                                       if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno)))
+                                               return false;
+
+                                       sprintf(mallocedval, "%s", (var->arrsize > 1) ? "'{" : ""); 
+                                               
+                                       for (element = 0; element < var->arrsize; element++)
+                                               sprintf(mallocedval + strlen(mallocedval), "%c,", (((char *) var->value)[element]) ? 't' : 'f');
+                                               
+                                       sprintf(mallocedval + strlen(mallocedval) - 1, "%s", (var->arrsize > 1) ? "}'" : ""); 
+
+                                       tobeinserted = mallocedval;
                                        break;
 
                                case ECPGt_char:
index c6b5621acfb13095e45be897d1915de57043bd79..03afc89b6d3a2ce1b1d7033d02f0cd772dc61596 100644 (file)
@@ -1,8 +1,8 @@
 all: stp.so test1 test2 test3 test4 test5 perftest
 
 #LDFLAGS=-g -I /usr/local/pgsql/include -L/usr/local/pgsql/lib -lecpg -lpq -lcrypt
-LDFLAGS=-g -I../include -I/usr/include/postgresql  -L/usr/lib/postgresql -L../lib -lecpg -lpq -lcrypt
-#LDFLAGS=-g -I/usr/include/postgresql -lecpg -lpq -lcrypt
+#LDFLAGS=-g -I../include -I/usr/include/postgresql  -L/usr/lib/postgresql -L../lib -lecpg -lpq -lcrypt
+LDFLAGS=-g -I/usr/include/postgresql -lecpg -lpq -lcrypt
 
 #ECPG=/usr/local/pgsql/bin/ecpg
 ECPG=../preproc/ecpg -I../include
index 02a631a12f51ba7abe51da0c60db8d16a0fd8bae..5bbabc6a44f7b207dc92464293796bfcb56ea26a 100644 (file)
@@ -18,7 +18,7 @@ void warn(void)
 exec sql include sqlca;
 
 /* comment */
-exec sql define AMOUNT 4;
+exec sql define AMOUNT 6;
 
 exec sql type intarray is int[AMOUNT];
 exec sql type string is char(8); 
@@ -97,12 +97,18 @@ exec sql end declare section;
        printf("Database: mm\n");
         for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
        {
-            printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, name[i], i, amount[i],i, letter[i][0]);
+           exec sql begin declare section;
+           char n[8], l = letter[i][0];
+           int a = amount[i];
+           exec sql end declare section;
+
+           strncpy(n, name[i], 8);
+            printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
            amount[i]+=1000;
-       }
 
-       strcpy(msg, "insert");
-       exec sql at pm insert into "Test" (name, amount, letter) values (:name, :amount, :letter);
+           strcpy(msg, "insert");
+           exec sql at pm insert into "Test" (name, amount, letter) values (:n, :a, :l);            
+       }
 
         strcpy(msg, "select");
         exec sql at pm select * into :name, :amount, :letter from "Test";
index 57a2143cc5b487a41fb21d51de6ad5adadb599ec..d482221870602de92e3490cf25a95b1d9e31021b 100644 (file)
@@ -30,7 +30,7 @@ EXEC SQL END DECLARE SECTION;
 
        EXEC SQL INSERT INTO test(f,i,a) VALUES(404.90,1,'{0,1,2,3,4,5,6,7,8,9}');
 
-/*     EXEC SQL INSERT INTO test(f,i,a) VALUES(140787.0,2,:a);*/
+       EXEC SQL INSERT INTO test(f,i,a) VALUES(140787.0,2,:a);
 
        EXEC SQL COMMIT;