OSDN Git Service

Started to cleanup complex tests.
authorMichael Meskes <meskes@postgresql.org>
Tue, 5 Sep 2006 12:11:03 +0000 (12:11 +0000)
committerMichael Meskes <meskes@postgresql.org>
Tue, 5 Sep 2006 12:11:03 +0000 (12:11 +0000)
Added some interval checks to regression suite.

25 files changed:
src/interfaces/ecpg/test/Makefile
src/interfaces/ecpg/test/complex/Makefile
src/interfaces/ecpg/test/expected/complex-test4.stderr [deleted file]
src/interfaces/ecpg/test/expected/complex-test5.stderr [deleted file]
src/interfaces/ecpg/test/expected/pgtypeslib-dt_test2.c
src/interfaces/ecpg/test/expected/pgtypeslib-dt_test2.stdout
src/interfaces/ecpg/test/expected/preproc-define.c [new file with mode: 0644]
src/interfaces/ecpg/test/expected/preproc-define.stderr [new file with mode: 0644]
src/interfaces/ecpg/test/expected/preproc-define.stdout [new file with mode: 0644]
src/interfaces/ecpg/test/expected/preproc-init.c [moved from src/interfaces/ecpg/test/expected/errors-init.c with 100% similarity]
src/interfaces/ecpg/test/expected/preproc-init.stderr [moved from src/interfaces/ecpg/test/expected/errors-init.stderr with 100% similarity]
src/interfaces/ecpg/test/expected/preproc-init.stdout [moved from src/interfaces/ecpg/test/expected/errors-init.stdout with 100% similarity]
src/interfaces/ecpg/test/expected/sql-array.c [moved from src/interfaces/ecpg/test/expected/complex-test4.c with 71% similarity]
src/interfaces/ecpg/test/expected/sql-array.stderr [new file with mode: 0644]
src/interfaces/ecpg/test/expected/sql-array.stdout [moved from src/interfaces/ecpg/test/expected/complex-test4.stdout with 84% similarity]
src/interfaces/ecpg/test/expected/sql-binary.c [moved from src/interfaces/ecpg/test/expected/complex-test5.c with 67% similarity]
src/interfaces/ecpg/test/expected/sql-binary.stderr [new file with mode: 0644]
src/interfaces/ecpg/test/expected/sql-binary.stdout [moved from src/interfaces/ecpg/test/expected/complex-test5.stdout with 65% similarity]
src/interfaces/ecpg/test/pgtypeslib/dt_test2.pgc
src/interfaces/ecpg/test/preproc/Makefile [new file with mode: 0644]
src/interfaces/ecpg/test/preproc/define.pgc [new file with mode: 0644]
src/interfaces/ecpg/test/preproc/init.pgc [new file with mode: 0644]
src/interfaces/ecpg/test/sql/Makefile
src/interfaces/ecpg/test/sql/array.pgc [moved from src/interfaces/ecpg/test/complex/test4.pgc with 59% similarity]
src/interfaces/ecpg/test/sql/binary.pgc [moved from src/interfaces/ecpg/test/complex/test5.pgc with 73% similarity]

index 9147b7d..5ed4622 100644 (file)
@@ -1,4 +1,4 @@
-# $PostgreSQL: pgsql/src/interfaces/ecpg/test/Makefile,v 1.60 2006/08/29 12:33:45 meskes Exp $
+# $PostgreSQL: pgsql/src/interfaces/ecpg/test/Makefile,v 1.61 2006/09/05 12:11:01 meskes Exp $
 
 subdir = src/interfaces/ecpg/test
 top_builddir = ../../../..
@@ -27,7 +27,7 @@ all install installdirs uninstall dep depend distprep:
        $(MAKE) -C connect $@
        $(MAKE) -C sql $@
        $(MAKE) -C pgtypeslib $@
-       $(MAKE) -C errors $@
+       $(MAKE) -C preproc $@
        $(MAKE) -C compat_informix $@
        $(MAKE) -C complex $@
        $(MAKE) -C thread $@
@@ -37,7 +37,7 @@ clean distclean maintainer-clean:
        $(MAKE) -C connect extraclean
        $(MAKE) -C sql $@
        $(MAKE) -C pgtypeslib $@
-       $(MAKE) -C errors $@
+       $(MAKE) -C preproc $@
        $(MAKE) -C compat_informix $@
        $(MAKE) -C complex $@
        $(MAKE) -C thread $@
index 0883341..5cd59f2 100644 (file)
@@ -6,12 +6,7 @@ include $(top_srcdir)/$(subdir)/../Makefile.regress
 
 TESTS = test1 test1.c \
         test2 test2.c \
-        test3 test3.c \
-        test4 test4.c \
-        test5 test5.c
+        test3 test3.c 
 
 all: $(TESTS)
 
-# test4 needs the -c option for the "EXEC SQL TYPE" construct
-test4.c: test4.pgc ../regression.h
-       $(ECPG) -c -o $@ -I$(srcdir) $<
diff --git a/src/interfaces/ecpg/test/expected/complex-test4.stderr b/src/interfaces/ecpg/test/expected/complex-test4.stderr
deleted file mode 100644 (file)
index e9924b1..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-[NO_PID]: ECPGdebug: set to 1
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT> 
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGsetcommit line 42 action = on connection = regress1
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGtrans line 44 action = begin transaction  connection = regress1
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGexecute line 46: QUERY: create  table test ( f float    , i int   , a int [ 10 ]   , text char  ( 10 )    , b bool   , t int   , err int   )     on connection regress1
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGexecute line 46 Ok: CREATE TABLE
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGexecute line 48: QUERY: insert into test ( f  , i  , a  , text  , b  , t  , err  ) values( 404.90 , 3 , '{0,1,2,3,4,5,6,7,8,9}' , 'abcdefghij' , 'f' , 0 , 0 ) on connection regress1
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGexecute line 48 Ok: INSERT 0 1
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGexecute line 50: QUERY: insert into test ( f  , i  , a  , text  , b  , t  , err  ) values( 140787.0 , 2 ,  array [9,8,7,6,5,4,3,2,1,0] ,  'klmnopqrst' , 't' , 2 , 14 ) on connection regress1
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGexecute line 50 Ok: INSERT 0 1
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGexecute line 55: QUERY: insert into test ( f  , i  , a  , text  , b  , t  , err  ) values( 14.07 ,  1 ,  array [9,8,7,6,5,4,3,2,1,0] ,  '0123456789' ,  't' , 1 , 147 ) on connection regress1
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGexecute line 55 Ok: INSERT 0 1
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGtrans line 59 action = commit connection = regress1
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGtrans line 61 action = begin transaction  connection = regress1
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGexecute line 63: QUERY: select  f , text , b  from test where i = 1   on connection regress1
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGexecute line 63: Correctly got 1 tuples with 3 fields
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGget_data line 63: RESULT: 14.07 offset: -1 array: Yes
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGget_data line 63: RESULT: 0123456789 offset: -1 array: Yes
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGget_data line 63: RESULT: t offset: -1 array: Yes
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGexecute line 71: QUERY: select  a , text  from test where f =  140787   on connection regress1
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGexecute line 71: Correctly got 1 tuples with 2 fields
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGis_type_an_array line 71: TYPE database: 1007 C: 5 array: Yes
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGget_data line 71: RESULT: {9,8,7,6,5,4,3,2,1,0} offset: -1 array: Yes
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGget_data line 71: RESULT: klmnopqrst offset: -1 array: Yes
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGexecute line 81: QUERY: select  a  from test where f =  140787   on connection regress1
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGexecute line 81: Correctly got 1 tuples with 1 fields
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGget_data line 81: RESULT: {9,8,7,6,5,4,3,2,1,0} offset: -1 array: Yes
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGexecute line 88: QUERY: drop table test  on connection regress1
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGexecute line 88 Ok: DROP TABLE
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGtrans line 90 action = commit connection = regress1
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_finish: Connection regress1 closed.
-[NO_PID]: sqlca: code: 0, state: 00000
diff --git a/src/interfaces/ecpg/test/expected/complex-test5.stderr b/src/interfaces/ecpg/test/expected/complex-test5.stderr
deleted file mode 100644 (file)
index 164d09b..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-[NO_PID]: ECPGdebug: set to 1
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT> 
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGexecute line 44: QUERY: create  table empl ( idnum integer   , name char  ( 20 )    , accs smallint   , byte bytea   )     on connection regress1
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGexecute line 44 Ok: CREATE TABLE
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGexecute line 52: QUERY: insert into empl values( 1 , 'first user' , 320 ,  E'\\001\\155\\000\\212' ) on connection regress1
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGexecute line 52 Ok: INSERT 0 1
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGexecute line 59: QUERY: select  name , accs , byte  from empl where idnum =  1   on connection regress1
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGexecute line 59: Correctly got 1 tuples with 3 fields
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGget_data line 59: RESULT: first user           offset: -1 array: Yes
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGget_data line 59: RESULT: 320 offset: -1 array: Yes
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGget_data line 59: RESULT: \001m\000\212 offset: -1 array: Yes
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGexecute line 71: QUERY: declare C  cursor  for select  name , accs , byte  from empl where idnum =  1   on connection regress1
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGexecute line 71 Ok: DECLARE CURSOR
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGexecute line 72: QUERY: fetch C on connection regress1
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGexecute line 72: Correctly got 1 tuples with 3 fields
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGget_data line 72: RESULT: first user           offset: -1 array: Yes
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGget_data line 72: RESULT: 320 offset: -1 array: Yes
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGget_data line 72: RESULT: \001m\000\212 offset: -1 array: Yes
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGexecute line 84: QUERY: declare B  binary cursor  for select  name , accs , byte  from empl where idnum =  1   on connection regress1
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGexecute line 84 Ok: DECLARE CURSOR
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGexecute line 85: QUERY: fetch B on connection regress1
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGexecute line 85: Correctly got 1 tuples with 3 fields
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGget_data line 85: RESULT: BINARY offset: -1 array: Yes
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGget_data line 85: RESULT: BINARY offset: -1 array: Yes
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGget_data line 85: RESULT: BINARY offset: -1 array: Yes
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGexecute line 92: QUERY: close B on connection regress1
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGexecute line 92 Ok: CLOSE CURSOR
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_finish: Connection regress1 closed.
-[NO_PID]: sqlca: code: 0, state: 00000
index 805f50f..4a30736 100644 (file)
@@ -10,6 +10,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
+#include <limits.h>
 #include <pgtypes_date.h>
 #include <pgtypes_timestamp.h>
 
 
 
 
-#line 7 "dt_test2.pgc"
+#line 8 "dt_test2.pgc"
 
 
+char *dates[] = { "19990108foobar",
+                                 "19990108 foobar",
+                                 "1999-01-08 foobar",
+                                 "January 8, 1999",
+                                 "1999-01-08",
+                                 "1/8/1999",
+                                 "1/18/1999",
+                                 "01/02/03",
+                                 "1999-Jan-08",
+                                 "Jan-08-1999",
+                                 "08-Jan-1999",
+                                 "99-Jan-08",
+                                 "08-Jan-99",
+                                 "08-Jan-06",
+                                 "Jan-08-99",
+                                 "19990108",
+                                 "990108",
+                                 "1999.008",
+                                 "J2451187",
+                                 "January 8, 99 BC",
+                                 NULL };
+
+char *times[] = { "0:04",
+                                 "1:59 PDT",
+                                 "13:24:40 -8:00",
+                                 "13:24:40.495+3",
+                                 NULL };
+
+char *intervals[] = { "1 minute",
+                                         "1 12:59:10",
+                                         "2 day 12 hour 59 minute 10 second",
+                                         "1 days 12 hrs 59 mins 10 secs",
+                                         "1 days 1 hours 1 minutes 1 seconds",
+                                         "1 year 59 mins",
+                                         "1 year 59 mins foobar",
+                                         NULL };
+
 int
 main(void)
 {
        /* exec sql begin declare section */
                 
+                 
                 
                 
        
-#line 13 "dt_test2.pgc"
+#line 51 "dt_test2.pgc"
  date  date1    ;
  
-#line 14 "dt_test2.pgc"
- timestamp  ts1    ;
+#line 52 "dt_test2.pgc"
+ timestamp  ts1    ,  ts2    ;
  
-#line 15 "dt_test2.pgc"
+#line 53 "dt_test2.pgc"
  char * text    ;
+#line 54 "dt_test2.pgc"
+ interval * i1    ;
 /* exec sql end declare section */
-#line 16 "dt_test2.pgc"
+#line 55 "dt_test2.pgc"
+
 
+       int i, j;
+       char *endptr;
 
        ECPGdebug(1, stderr);
 
@@ -57,6 +102,58 @@ main(void)
        printf("Date of timestamp: %s\n", text);
        free(text);
 
+       for (i = 0; dates[i]; i++)
+       {
+               bool err = false;
+               date1 = PGTYPESdate_from_asc(dates[i], &endptr);
+               if (date1 == INT_MIN) {
+                       err = true;
+               }
+               text = PGTYPESdate_to_asc(date1);
+               printf("Date[%d]: %s (%c - %c)\n",
+                                       i, err ? "-" : text,
+                                       endptr ? 'N' : 'Y',
+                                       err ? 'T' : 'F');
+               free(text);
+               if (!err)
+               {
+                       for (j = 0; times[j]; j++)
+                       {
+                               int length = strlen(dates[i])
+                                               + 1
+                                               + strlen(times[j])
+                                               + 1;
+                               char* t = malloc(length);
+                               sprintf(t, "%s %s", dates[i], times[j]);
+                               ts1 = PGTYPEStimestamp_from_asc(t, NULL);
+                               text = PGTYPEStimestamp_to_asc(ts1);
+                               printf("TS[%d,%d]: %s\n",
+                                               i, j, errno ? "-" : text);
+                               free(text);
+                       }
+               }
+       }
+
+       ts1 = PGTYPEStimestamp_from_asc("2004-04-04 23:23:23", NULL);
+
+       for (i = 0; intervals[i]; i++)
+       {
+               i1 = PGTYPESinterval_from_asc(intervals[i], &endptr);
+               if (*endptr)
+                       printf("endptr set to %s\n", endptr);
+               if (!i1)
+               {
+                       printf("Error parsing interval %d\n", i);
+                       continue;
+               }
+               j = PGTYPEStimestamp_add_interval(&ts1, i1, &ts2);
+               if (j < 0)
+                       continue;
+               text = PGTYPESinterval_to_asc(i1);
+               printf("interval[%d]: %s\n", i, text ? text : "-");
+               free(text);
+       }
+
        return (0);
 }
 
index d4c7838..d52555f 100644 (file)
@@ -1,2 +1,97 @@
 timestamp: 2003-12-04 17:34:29
 Date of timestamp: 2003-12-04
+Date[0]: - (N - T)
+Date[1]: - (N - T)
+Date[2]: - (N - T)
+Date[3]: 1999-01-08 (N - F)
+TS[3,0]: 1999-01-08 00:04:00
+TS[3,1]: 1999-01-08 01:59:00
+TS[3,2]: 1999-01-08 13:24:40
+TS[3,3]: 1999-01-08 13:24:40.495
+Date[4]: 1999-01-08 (N - F)
+TS[4,0]: 1999-01-08 00:04:00
+TS[4,1]: 1999-01-08 01:59:00
+TS[4,2]: 1999-01-08 13:24:40
+TS[4,3]: 1999-01-08 13:24:40.495
+Date[5]: 1999-01-08 (N - F)
+TS[5,0]: 1999-01-08 00:04:00
+TS[5,1]: 1999-01-08 01:59:00
+TS[5,2]: 1999-01-08 13:24:40
+TS[5,3]: 1999-01-08 13:24:40.495
+Date[6]: 1999-01-18 (N - F)
+TS[6,0]: 1999-01-18 00:04:00
+TS[6,1]: 1999-01-18 01:59:00
+TS[6,2]: 1999-01-18 13:24:40
+TS[6,3]: 1999-01-18 13:24:40.495
+Date[7]: 2003-01-02 (N - F)
+TS[7,0]: 2003-01-02 00:04:00
+TS[7,1]: 2003-01-02 01:59:00
+TS[7,2]: 2003-01-02 13:24:40
+TS[7,3]: 2003-01-02 13:24:40.495
+Date[8]: 1999-01-08 (N - F)
+TS[8,0]: 1999-01-08 00:04:00
+TS[8,1]: 1999-01-08 01:59:00
+TS[8,2]: 1999-01-08 13:24:40
+TS[8,3]: 1999-01-08 13:24:40.495
+Date[9]: 1999-01-08 (N - F)
+TS[9,0]: 1999-01-08 00:04:00
+TS[9,1]: 1999-01-08 01:59:00
+TS[9,2]: 1999-01-08 13:24:40
+TS[9,3]: 1999-01-08 13:24:40.495
+Date[10]: 1999-01-08 (N - F)
+TS[10,0]: 1999-01-08 00:04:00
+TS[10,1]: 1999-01-08 01:59:00
+TS[10,2]: 1999-01-08 13:24:40
+TS[10,3]: 1999-01-08 13:24:40.495
+Date[11]: 1999-01-08 (N - F)
+TS[11,0]: 1999-01-08 00:04:00
+TS[11,1]: 1999-01-08 01:59:00
+TS[11,2]: 1999-01-08 13:24:40
+TS[11,3]: 1999-01-08 13:24:40.495
+Date[12]: 1999-01-08 (N - F)
+TS[12,0]: 1999-01-08 00:04:00
+TS[12,1]: 1999-01-08 01:59:00
+TS[12,2]: 1999-01-08 13:24:40
+TS[12,3]: 1999-01-08 13:24:40.495
+Date[13]: 2006-01-08 (N - F)
+TS[13,0]: 2006-01-08 00:04:00
+TS[13,1]: 2006-01-08 01:59:00
+TS[13,2]: 2006-01-08 13:24:40
+TS[13,3]: 2006-01-08 13:24:40.495
+Date[14]: 1999-01-08 (N - F)
+TS[14,0]: 1999-01-08 00:04:00
+TS[14,1]: 1999-01-08 01:59:00
+TS[14,2]: 1999-01-08 13:24:40
+TS[14,3]: 1999-01-08 13:24:40.495
+Date[15]: 1999-01-08 (N - F)
+TS[15,0]: 1999-01-08 00:04:00
+TS[15,1]: 1999-01-08 01:59:00
+TS[15,2]: 1999-01-08 13:24:40
+TS[15,3]: 1999-01-08 13:24:40.495
+Date[16]: 1999-01-08 (N - F)
+TS[16,0]: 1999-01-08 00:04:00
+TS[16,1]: 1999-01-08 01:59:00
+TS[16,2]: 1999-01-08 13:24:40
+TS[16,3]: 1999-01-08 13:24:40.495
+Date[17]: 1999-01-08 (N - F)
+TS[17,0]: 1999-01-08 00:04:00
+TS[17,1]: 1999-01-08 01:59:00
+TS[17,2]: 1999-01-08 13:24:40
+TS[17,3]: 1999-01-08 13:24:40.495
+Date[18]: 1999-01-08 (N - F)
+TS[18,0]: 1999-01-08 00:04:00
+TS[18,1]: 1999-01-08 01:59:00
+TS[18,2]: 1999-01-08 13:24:40
+TS[18,3]: 1999-01-08 13:24:40.495
+Date[19]: 0099-01-08 BC (N - F)
+TS[19,0]: 0099-01-08 00:04:00 BC
+TS[19,1]: 0099-01-08 01:59:00 BC
+TS[19,2]: 0099-01-08 13:24:40 BC
+TS[19,3]: 0099-01-08 13:24:40.495 BC
+interval[0]: @ 1 min
+interval[1]: @ 1 day 12 hours 59 mins 10 secs
+interval[2]: @ 2 days 12 hours 59 mins 10 secs
+interval[3]: @ 1 day 12 hours 59 mins 10 secs
+interval[4]: @ 1 day 1 hour 1 min 1 sec
+interval[5]: @ 1 year 59 mins
+Error parsing interval 6
diff --git a/src/interfaces/ecpg/test/expected/preproc-define.c b/src/interfaces/ecpg/test/expected/preproc-define.c
new file mode 100644 (file)
index 0000000..b5d01a9
--- /dev/null
@@ -0,0 +1,127 @@
+/* Processed by ecpg (4.2.1) */
+/* These include files are added by the preprocessor */
+#include <ecpgtype.h>
+#include <ecpglib.h>
+#include <ecpgerrno.h>
+#include <sqlca.h>
+/* End of automatic include section */
+
+#line 1 "define.pgc"
+#include <stdio.h>
+#include <stdlib.h>
+
+
+#line 1 "regression.h"
+
+
+
+
+
+
+#line 4 "define.pgc"
+
+
+typedef long  mmInteger ;
+
+#line 6 "define.pgc"
+
+#line 6 "define.pgc"
+
+typedef char  mmChar ;
+
+#line 7 "define.pgc"
+
+#line 7 "define.pgc"
+
+typedef short  mmSmallInt ;
+
+#line 8 "define.pgc"
+
+#line 8 "define.pgc"
+
+
+/* exec sql begin declare section */
+
+   
+   
+   
+
+struct TBempl { 
+#line 13 "define.pgc"
+ mmInteger  idnum    ;
+#line 14 "define.pgc"
+ mmChar  name [ 21 ]    ;
+#line 15 "define.pgc"
+ mmSmallInt  accs    ;
+ } ;/* exec sql end declare section */
+#line 17 "define.pgc"
+
+
+int
+main (void)
+{
+  /* exec sql begin declare section */
+    
+  
+#line 23 "define.pgc"
+ struct TBempl  empl    ;
+/* exec sql end declare section */
+#line 24 "define.pgc"
+
+
+  ECPGdebug (1, stderr);
+
+  empl.idnum = 1;
+  { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); }
+#line 29 "define.pgc"
+
+  if (sqlca.sqlcode)
+    {
+      printf ("connect error = %ld\n", sqlca.sqlcode);
+      exit (sqlca.sqlcode);
+    }
+
+  { ECPGdo(__LINE__, 0, 1, NULL, "create  table empl ( idnum integer   , name char  ( 20 )    , accs smallint   )    ", ECPGt_EOIT, ECPGt_EORT);}
+#line 37 "define.pgc"
+
+  if (sqlca.sqlcode)
+    {
+      printf ("create error = %ld\n", sqlca.sqlcode);
+      exit (sqlca.sqlcode);
+    }
+
+  { ECPGdo(__LINE__, 0, 1, NULL, "insert into empl values ( 1 , 'first user' , 320 ) ", ECPGt_EOIT, ECPGt_EORT);}
+#line 44 "define.pgc"
+
+  if (sqlca.sqlcode)
+    {
+      printf ("insert error = %ld\n", sqlca.sqlcode);
+      exit (sqlca.sqlcode);
+    }
+
+  { ECPGdo(__LINE__, 0, 1, NULL, "select  idnum , name , accs  from empl where idnum =  ?  ", 
+       ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+       ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+       ECPGt_char,&(empl.name),(long)21,(long)1,(21)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+       ECPGt_short,&(empl.accs),(long)1,(long)1,sizeof(short), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+#line 54 "define.pgc"
+
+  if (sqlca.sqlcode)
+    {
+      printf ("select error = %ld\n", sqlca.sqlcode);
+      exit (sqlca.sqlcode);
+    }
+  printf ("id=%ld name=%s, accs=%d\n", empl.idnum, empl.name, empl.accs);
+
+  { ECPGdisconnect(__LINE__, "CURRENT");}
+#line 62 "define.pgc"
+
+  exit (0);
+}
diff --git a/src/interfaces/ecpg/test/expected/preproc-define.stderr b/src/interfaces/ecpg/test/expected/preproc-define.stderr
new file mode 100644 (file)
index 0000000..34610cb
--- /dev/null
@@ -0,0 +1,24 @@
+[NO_PID]: ECPGdebug: set to 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT> 
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 36: QUERY: create  table empl ( idnum integer   , name char  ( 20 )    , accs smallint   )     on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 36 Ok: CREATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 44: QUERY: insert into empl values ( 1 , 'first user' , 320 )  on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 44 Ok: INSERT 0 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 51: QUERY: select  idnum , name , accs  from empl where idnum =  1   on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 51: Correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 51: RESULT: 1 offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 51: RESULT: first user           offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 51: RESULT: 320 offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_finish: Connection regress1 closed.
+[NO_PID]: sqlca: code: 0, state: 00000
diff --git a/src/interfaces/ecpg/test/expected/preproc-define.stdout b/src/interfaces/ecpg/test/expected/preproc-define.stdout
new file mode 100644 (file)
index 0000000..63c2bbb
--- /dev/null
@@ -0,0 +1 @@
+id=1 name=first user          , accs=320
@@ -6,13 +6,13 @@
 #include <sqlca.h>
 /* End of automatic include section */
 
-#line 1 "test4.pgc"
+#line 1 "array.pgc"
 #include <locale.h>
 #include <string.h>
 #include <stdlib.h>
 
 /* exec sql whenever sqlerror  sqlprint ; */
-#line 5 "test4.pgc"
+#line 5 "array.pgc"
 
 
 
@@ -84,7 +84,7 @@ struct sqlca_t *ECPGget_sqlca(void);
 
 #endif
 
-#line 7 "test4.pgc"
+#line 7 "array.pgc"
 
 
 #line 1 "regression.h"
@@ -94,61 +94,39 @@ struct sqlca_t *ECPGget_sqlca(void);
 
 
 
-#line 8 "test4.pgc"
-
-
-typedef  enum { OK = 0 , ERR = 1 , WARN = 2 }   errtype ;
-#line 15 "test4.pgc"
+#line 8 "array.pgc"
 
 
 int
 main (void)
 {
 /* exec sql begin declare section */
-        
-       
-                 
-                 
-           
           
           
           
           
            
         
-          
 
-#line 25 "test4.pgc"
- struct { 
-#line 23 "test4.pgc"
- errtype  e  : 2  ;
-#line 24 "test4.pgc"
- int  code  : 14  ;
- }  error   = { 1 , 147 } ;
-#line 26 "test4.pgc"
+#line 14 "array.pgc"
  int  i   = 1 ;
  
-#line 27 "test4.pgc"
+#line 15 "array.pgc"
  int * did   = & i ;
  
-#line 28 "test4.pgc"
+#line 16 "array.pgc"
  int  a [ 10 ]   = { 9 , 8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 , 0 } ;
  
-#line 29 "test4.pgc"
+#line 17 "array.pgc"
  char  text [ 25 ]   = "klmnopqrst" ;
  
-#line 30 "test4.pgc"
+#line 18 "array.pgc"
  char * t   = ( char * ) malloc ( 11 ) ;
  
-#line 31 "test4.pgc"
+#line 19 "array.pgc"
  double  f    ;
-#line 32 "test4.pgc"
- bool  b   = true ;
 /* exec sql end declare section */
-#line 33 "test4.pgc"
+#line 20 "array.pgc"
 
 
        strcpy(t, "0123456789");
@@ -157,99 +135,90 @@ main (void)
        ECPGdebug(1, stderr);
 
         { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); 
-#line 40 "test4.pgc"
+#line 27 "array.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
-#line 40 "test4.pgc"
+#line 27 "array.pgc"
 
 
        { ECPGsetcommit(__LINE__, "on", NULL);
-#line 42 "test4.pgc"
+#line 29 "array.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
-#line 42 "test4.pgc"
+#line 29 "array.pgc"
 
 
        { ECPGtrans(__LINE__, NULL, "begin transaction ");
-#line 44 "test4.pgc"
+#line 31 "array.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
-#line 44 "test4.pgc"
+#line 31 "array.pgc"
 
 
-       { ECPGdo(__LINE__, 0, 1, NULL, "create  table test ( f float    , i int   , a int [ 10 ]   , text char  ( 10 )    , b bool   , t int   , err int   )    ", ECPGt_EOIT, ECPGt_EORT);
-#line 46 "test4.pgc"
+       { ECPGdo(__LINE__, 0, 1, NULL, "create  table test ( f float    , i int   , a int [ 10 ]   , text char  ( 10 )    )    ", ECPGt_EOIT, ECPGt_EORT);
+#line 33 "array.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
-#line 46 "test4.pgc"
+#line 33 "array.pgc"
 
 
-       { ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( f  , i  , a  , text  , b  , t  , err  ) values( 404.90 , 3 , '{0,1,2,3,4,5,6,7,8,9}' , 'abcdefghij' , 'f' , 0 , 0 ) ", ECPGt_EOIT, ECPGt_EORT);
-#line 48 "test4.pgc"
+       { ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( f  , i  , a  , text  ) values ( 404.90 , 3 , '{0,1,2,3,4,5,6,7,8,9}' , 'abcdefghij' ) ", ECPGt_EOIT, ECPGt_EORT);
+#line 35 "array.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
-#line 48 "test4.pgc"
+#line 35 "array.pgc"
 
 
-       { ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( f  , i  , a  , text  , b  , t  , err  ) values( 140787.0 , 2 ,  ? ,  ? , 't' , 2 , 14 ) ", 
+       { ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( f  , i  , a  , text  ) values ( 140787.0 , 2 ,  ? ,  ? ) ", 
        ECPGt_int,(a),(long)1,(long)10,sizeof(int), 
        ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
        ECPGt_char,(text),(long)25,(long)1,(25)*sizeof(char), 
        ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
-#line 50 "test4.pgc"
+#line 37 "array.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
-#line 50 "test4.pgc"
+#line 37 "array.pgc"
 
        
-
-            
-
-       { ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( f  , i  , a  , text  , b  , t  , err  ) values( 14.07 ,  ? ,  ? ,  ? ,  ? , 1 , 147 ) ", 
+       { ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( f  , i  , a  , text  ) values ( 14.07 ,  ? ,  ? ,  ? ) ", 
        ECPGt_int,&(did),(long)1,(long)0,sizeof(int), 
        ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
        ECPGt_int,(a),(long)1,(long)10,sizeof(int), 
        ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
        ECPGt_char,&(t),(long)0,(long)1,(1)*sizeof(char), 
-       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-       ECPGt_bool,&(b),(long)1,(long)1,sizeof(bool), 
        ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
-#line 55 "test4.pgc"
+#line 39 "array.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
-#line 55 "test4.pgc"
-
-       error.code=0;
+#line 39 "array.pgc"
 
 
        { ECPGtrans(__LINE__, NULL, "commit");
-#line 59 "test4.pgc"
+#line 41 "array.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
-#line 59 "test4.pgc"
+#line 41 "array.pgc"
 
 
        { ECPGtrans(__LINE__, NULL, "begin transaction ");
-#line 61 "test4.pgc"
+#line 43 "array.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
-#line 61 "test4.pgc"
+#line 43 "array.pgc"
  
 
-       { ECPGdo(__LINE__, 0, 1, NULL, "select  f , text , b  from test where i = 1  ", ECPGt_EOIT, 
+       { ECPGdo(__LINE__, 0, 1, NULL, "select  f , text  from test where i = 1  ", ECPGt_EOIT, 
        ECPGt_double,&(f),(long)1,(long)1,sizeof(double), 
        ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
        ECPGt_char,(text),(long)25,(long)1,(25)*sizeof(char), 
-       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-       ECPGt_bool,&(b),(long)1,(long)1,sizeof(bool), 
        ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
-#line 66 "test4.pgc"
+#line 48 "array.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
-#line 66 "test4.pgc"
+#line 48 "array.pgc"
 
 
-       printf("Found f=%f text=%10.10s b=%d\n", f, text, b);
+       printf("Found f=%f text=%10.10s\n", f, text);
 
        f=140787;
        { ECPGdo(__LINE__, 0, 1, NULL, "select  a , text  from test where f =  ?  ", 
@@ -259,10 +228,10 @@ if (sqlca.sqlcode < 0) sqlprint();}
        ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
        ECPGt_char,&(t),(long)0,(long)1,(1)*sizeof(char), 
        ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
-#line 74 "test4.pgc"
+#line 56 "array.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
-#line 74 "test4.pgc"
+#line 56 "array.pgc"
 
 
        for (i = 0; i < 10; i++)
@@ -275,33 +244,33 @@ if (sqlca.sqlcode < 0) sqlprint();}
        ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
        ECPGt_char,(text),(long)25,(long)1,(25)*sizeof(char), 
        ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
-#line 84 "test4.pgc"
+#line 66 "array.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
-#line 84 "test4.pgc"
+#line 66 "array.pgc"
 
 
        printf("Found text=%s\n", text);
 
        { ECPGdo(__LINE__, 0, 1, NULL, "drop table test ", ECPGt_EOIT, ECPGt_EORT);
-#line 88 "test4.pgc"
+#line 70 "array.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
-#line 88 "test4.pgc"
+#line 70 "array.pgc"
 
 
        { ECPGtrans(__LINE__, NULL, "commit");
-#line 90 "test4.pgc"
+#line 72 "array.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
-#line 90 "test4.pgc"
+#line 72 "array.pgc"
 
 
        { ECPGdisconnect(__LINE__, "CURRENT");
-#line 92 "test4.pgc"
+#line 74 "array.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
-#line 92 "test4.pgc"
+#line 74 "array.pgc"
 
 
        return (0);
diff --git a/src/interfaces/ecpg/test/expected/sql-array.stderr b/src/interfaces/ecpg/test/expected/sql-array.stderr
new file mode 100644 (file)
index 0000000..00eda21
--- /dev/null
@@ -0,0 +1,60 @@
+[NO_PID]: ECPGdebug: set to 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT> 
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGsetcommit line 29 action = on connection = regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans line 31 action = begin transaction  connection = regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 33: QUERY: create  table test ( f float    , i int   , a int [ 10 ]   , text char  ( 10 )    )     on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 33 Ok: CREATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 35: QUERY: insert into test ( f  , i  , a  , text  ) values ( 404.90 , 3 , '{0,1,2,3,4,5,6,7,8,9}' , 'abcdefghij' )  on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 35 Ok: INSERT 0 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 37: QUERY: insert into test ( f  , i  , a  , text  ) values ( 140787.0 , 2 ,  array [9,8,7,6,5,4,3,2,1,0] ,  'klmnopqrst' )  on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 37 Ok: INSERT 0 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 39: QUERY: insert into test ( f  , i  , a  , text  ) values ( 14.07 ,  1 ,  array [9,8,7,6,5,4,3,2,1,0] ,  '0123456789' )  on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 39 Ok: INSERT 0 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans line 41 action = commit connection = regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans line 43 action = begin transaction  connection = regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 45: QUERY: select  f , text  from test where i = 1   on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 45: Correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 45: RESULT: 14.07 offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 45: RESULT: 0123456789 offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 53: QUERY: select  a , text  from test where f =  140787   on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 53: Correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGis_type_an_array line 53: TYPE database: 1007 C: 5 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 53: RESULT: {9,8,7,6,5,4,3,2,1,0} offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 53: RESULT: klmnopqrst offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 63: QUERY: select  a  from test where f =  140787   on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 63: Correctly got 1 tuples with 1 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 63: RESULT: {9,8,7,6,5,4,3,2,1,0} offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 70: QUERY: drop table test  on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 70 Ok: DROP TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans line 72 action = commit connection = regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_finish: Connection regress1 closed.
+[NO_PID]: sqlca: code: 0, state: 00000
@@ -1,4 +1,4 @@
-Found f=14.070000 text=0123456789 b=1
+Found f=14.070000 text=0123456789
 Found a[0] = 9
 Found a[1] = 8
 Found a[2] = 7
@@ -6,7 +6,7 @@
 #include <sqlca.h>
 /* End of automatic include section */
 
-#line 1 "test5.pgc"
+#line 1 "binary.pgc"
 #include <stdio.h>
 #include <stdlib.h>
 
 
 
 
-#line 4 "test5.pgc"
-
-
-typedef long  mmInteger ;
-
-#line 6 "test5.pgc"
-
-#line 6 "test5.pgc"
-
-typedef char  mmChar ;
-
-#line 7 "test5.pgc"
-
-#line 7 "test5.pgc"
-
-typedef short  mmSmallInt ;
-
-#line 8 "test5.pgc"
-
-#line 8 "test5.pgc"
+#line 4 "binary.pgc"
 
 
 /* exec sql begin declare section */
@@ -49,19 +30,19 @@ typedef short  mmSmallInt ;
    
 
 struct TBempl { 
-#line 13 "test5.pgc"
mmInteger  idnum    ;
+#line 9 "binary.pgc"
long  idnum    ;
  
-#line 14 "test5.pgc"
mmChar  name [ 21 ]    ;
+#line 10 "binary.pgc"
char  name [ 21 ]    ;
  
-#line 15 "test5.pgc"
mmSmallInt  accs    ;
+#line 11 "binary.pgc"
short  accs    ;
  
-#line 16 "test5.pgc"
mmChar  byte [ 20 ]    ;
+#line 12 "binary.pgc"
char  byte [ 20 ]    ;
  } ;/* exec sql end declare section */
-#line 18 "test5.pgc"
+#line 14 "binary.pgc"
 
 
 int
@@ -70,28 +51,14 @@ main (void)
   /* exec sql begin declare section */
     
      
-   
   
-        
-        
-   
-  
-#line 24 "test5.pgc"
+#line 20 "binary.pgc"
  struct TBempl  empl    ;
  
-#line 25 "test5.pgc"
+#line 21 "binary.pgc"
  char * data   = "\\001\\155\\000\\212" ;
-#line 30 "test5.pgc"
- union { 
-#line 28 "test5.pgc"
- mmSmallInt  accs    ;
-#line 29 "test5.pgc"
- char  t [ 2 ]    ;
- }  a    ;
 /* exec sql end declare section */
-#line 31 "test5.pgc"
+#line 22 "binary.pgc"
 
   int i;
 
@@ -99,7 +66,7 @@ main (void)
 
   empl.idnum = 1;
   { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); }
-#line 37 "test5.pgc"
+#line 28 "binary.pgc"
 
   if (sqlca.sqlcode)
     {
@@ -108,7 +75,7 @@ main (void)
     }
 
   { ECPGdo(__LINE__, 0, 1, NULL, "create  table empl ( idnum integer   , name char  ( 20 )    , accs smallint   , byte bytea   )    ", ECPGt_EOIT, ECPGt_EORT);}
-#line 45 "test5.pgc"
+#line 36 "binary.pgc"
 
   if (sqlca.sqlcode)
     {
@@ -116,10 +83,10 @@ main (void)
       exit (sqlca.sqlcode);
     }
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "insert into empl values( 1 , 'first user' , 320 ,  ? ) ", 
+  { ECPGdo(__LINE__, 0, 1, NULL, "insert into empl values ( 1 , 'first user' , 320 ,  ? ) ", 
        ECPGt_char,&(data),(long)0,(long)1,(1)*sizeof(char), 
        ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
-#line 52 "test5.pgc"
+#line 43 "binary.pgc"
 
   if (sqlca.sqlcode)
     {
@@ -127,31 +94,13 @@ main (void)
       exit (sqlca.sqlcode);
     }
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "select  name , accs , byte  from empl where idnum =  ?  ", 
-       ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long), 
-       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
-       ECPGt_char,(empl.name),(long)21,(long)1,(21)*sizeof(char), 
-       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-       ECPGt_short,&(empl.accs),(long)1,(long)1,sizeof(short), 
-       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-       ECPGt_char,(empl.byte),(long)20,(long)1,(20)*sizeof(char), 
-       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
-#line 62 "test5.pgc"
-
-  if (sqlca.sqlcode)
-    {
-      printf ("select error = %ld\n", sqlca.sqlcode);
-      exit (sqlca.sqlcode);
-    }
-  printf ("name=%s, accs=%d byte=%s\n", empl.name, empl.accs, empl.byte);
-
   /* declare C  cursor  for select  name , accs , byte  from empl where idnum =  ?   */
-#line 70 "test5.pgc"
+#line 50 "binary.pgc"
 
   { ECPGdo(__LINE__, 0, 1, NULL, "declare C  cursor  for select  name , accs , byte  from empl where idnum =  ?  ", 
        ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long), 
        ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
-#line 71 "test5.pgc"
+#line 51 "binary.pgc"
 
   { ECPGdo(__LINE__, 0, 1, NULL, "fetch C", ECPGt_EOIT, 
        ECPGt_char,(empl.name),(long)21,(long)1,(21)*sizeof(char), 
@@ -160,7 +109,7 @@ main (void)
        ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
        ECPGt_char,(empl.byte),(long)20,(long)1,(20)*sizeof(char), 
        ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
-#line 72 "test5.pgc"
+#line 52 "binary.pgc"
 
   if (sqlca.sqlcode)
     {
@@ -173,21 +122,21 @@ main (void)
   memset(empl.name, 0, 21L);
   memset(empl.byte, '#', 20L);
   /* declare B  binary cursor  for select  name , accs , byte  from empl where idnum =  ?   */
-#line 83 "test5.pgc"
+#line 63 "binary.pgc"
 
   { ECPGdo(__LINE__, 0, 1, NULL, "declare B  binary cursor  for select  name , accs , byte  from empl where idnum =  ?  ", 
        ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long), 
        ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
-#line 84 "test5.pgc"
+#line 64 "binary.pgc"
 
   { ECPGdo(__LINE__, 0, 1, NULL, "fetch B", ECPGt_EOIT, 
        ECPGt_char,(empl.name),(long)21,(long)1,(21)*sizeof(char), 
        ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-       ECPGt_short,&(a.accs),(long)1,(long)1,sizeof(short), 
+       ECPGt_short,&(empl.accs),(long)1,(long)1,sizeof(short), 
        ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
        ECPGt_char,(empl.byte),(long)20,(long)1,(20)*sizeof(char), 
        ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
-#line 85 "test5.pgc"
+#line 65 "binary.pgc"
 
   if (sqlca.sqlcode)
     {
@@ -196,7 +145,7 @@ main (void)
     }
 
   { ECPGdo(__LINE__, 0, 1, NULL, "close B", ECPGt_EOIT, ECPGt_EORT);}
-#line 92 "test5.pgc"
+#line 72 "binary.pgc"
 
 
   /* do not print a.accs because big/little endian will have different outputs here */
@@ -209,7 +158,7 @@ main (void)
   }
   printf("\n");
   { ECPGdisconnect(__LINE__, "CURRENT");}
-#line 103 "test5.pgc"
+#line 83 "binary.pgc"
 
   exit (0);
 }
diff --git a/src/interfaces/ecpg/test/expected/sql-binary.stderr b/src/interfaces/ecpg/test/expected/sql-binary.stderr
new file mode 100644 (file)
index 0000000..8b589b7
--- /dev/null
@@ -0,0 +1,46 @@
+[NO_PID]: ECPGdebug: set to 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT> 
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 35: QUERY: create  table empl ( idnum integer   , name char  ( 20 )    , accs smallint   , byte bytea   )     on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 35 Ok: CREATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 43: QUERY: insert into empl values ( 1 , 'first user' , 320 ,  E'\\001\\155\\000\\212' )  on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 43 Ok: INSERT 0 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 51: QUERY: declare C  cursor  for select  name , accs , byte  from empl where idnum =  1   on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 51 Ok: DECLARE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 52: QUERY: fetch C on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 52: Correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 52: RESULT: first user           offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 52: RESULT: 320 offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 52: RESULT: \001m\000\212 offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 64: QUERY: declare B  binary cursor  for select  name , accs , byte  from empl where idnum =  1   on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 64 Ok: DECLARE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 65: QUERY: fetch B on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 65: Correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 65: RESULT: BINARY offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 65: RESULT: BINARY offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 65: RESULT: BINARY offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 72: QUERY: close B on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 72 Ok: CLOSE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_finish: Connection regress1 closed.
+[NO_PID]: sqlca: code: 0, state: 00000
@@ -1,3 +1,2 @@
 name=first user          , accs=320 byte=\001m\000\212
-name=first user          , accs=320 byte=\001m\000\212
 name=first user          , byte=(1)(155)(0)(212)
index 179f97f..1591dde 100644 (file)
@@ -1,20 +1,62 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
+#include <limits.h>
 #include <pgtypes_date.h>
 #include <pgtypes_timestamp.h>
 
 exec sql include ../regression;
 
+char *dates[] = { "19990108foobar",
+                                 "19990108 foobar",
+                                 "1999-01-08 foobar",
+                                 "January 8, 1999",
+                                 "1999-01-08",
+                                 "1/8/1999",
+                                 "1/18/1999",
+                                 "01/02/03",
+                                 "1999-Jan-08",
+                                 "Jan-08-1999",
+                                 "08-Jan-1999",
+                                 "99-Jan-08",
+                                 "08-Jan-99",
+                                 "08-Jan-06",
+                                 "Jan-08-99",
+                                 "19990108",
+                                 "990108",
+                                 "1999.008",
+                                 "J2451187",
+                                 "January 8, 99 BC",
+                                 NULL };
+
+char *times[] = { "0:04",
+                                 "1:59 PDT",
+                                 "13:24:40 -8:00",
+                                 "13:24:40.495+3",
+                                 NULL };
+
+char *intervals[] = { "1 minute",
+                                         "1 12:59:10",
+                                         "2 day 12 hour 59 minute 10 second",
+                                         "1 days 12 hrs 59 mins 10 secs",
+                                         "1 days 1 hours 1 minutes 1 seconds",
+                                         "1 year 59 mins",
+                                         "1 year 59 mins foobar",
+                                         NULL };
+
 int
 main(void)
 {
        exec sql begin declare section;
                date date1;
-               timestamp ts1;
-               char* text;
+               timestamp ts1, ts2;
+               char *text;
+               interval *i1;
        exec sql end declare section;
 
+       int i, j;
+       char *endptr;
+
        ECPGdebug(1, stderr);
 
        ts1 = PGTYPEStimestamp_from_asc("2003-12-04 17:34:29", NULL);
@@ -28,6 +70,58 @@ main(void)
        printf("Date of timestamp: %s\n", text);
        free(text);
 
+       for (i = 0; dates[i]; i++)
+       {
+               bool err = false;
+               date1 = PGTYPESdate_from_asc(dates[i], &endptr);
+               if (date1 == INT_MIN) {
+                       err = true;
+               }
+               text = PGTYPESdate_to_asc(date1);
+               printf("Date[%d]: %s (%c - %c)\n",
+                                       i, err ? "-" : text,
+                                       endptr ? 'N' : 'Y',
+                                       err ? 'T' : 'F');
+               free(text);
+               if (!err)
+               {
+                       for (j = 0; times[j]; j++)
+                       {
+                               int length = strlen(dates[i])
+                                               + 1
+                                               + strlen(times[j])
+                                               + 1;
+                               char* t = malloc(length);
+                               sprintf(t, "%s %s", dates[i], times[j]);
+                               ts1 = PGTYPEStimestamp_from_asc(t, NULL);
+                               text = PGTYPEStimestamp_to_asc(ts1);
+                               printf("TS[%d,%d]: %s\n",
+                                               i, j, errno ? "-" : text);
+                               free(text);
+                       }
+               }
+       }
+
+       ts1 = PGTYPEStimestamp_from_asc("2004-04-04 23:23:23", NULL);
+
+       for (i = 0; intervals[i]; i++)
+       {
+               i1 = PGTYPESinterval_from_asc(intervals[i], &endptr);
+               if (*endptr)
+                       printf("endptr set to %s\n", endptr);
+               if (!i1)
+               {
+                       printf("Error parsing interval %d\n", i);
+                       continue;
+               }
+               j = PGTYPEStimestamp_add_interval(&ts1, i1, &ts2);
+               if (j < 0)
+                       continue;
+               text = PGTYPESinterval_to_asc(i1);
+               printf("interval[%d]: %s\n", i, text ? text : "-");
+               free(text);
+       }
+
        return (0);
 }
 
diff --git a/src/interfaces/ecpg/test/preproc/Makefile b/src/interfaces/ecpg/test/preproc/Makefile
new file mode 100644 (file)
index 0000000..2184beb
--- /dev/null
@@ -0,0 +1,11 @@
+subdir = src/interfaces/ecpg/test/preproc
+top_builddir = ../../../../..
+include $(top_builddir)/src/Makefile.global
+include $(top_srcdir)/$(subdir)/../Makefile.regress
+
+
+TESTS = define define.c \
+       init init.c
+
+all: $(TESTS)
+
diff --git a/src/interfaces/ecpg/test/preproc/define.pgc b/src/interfaces/ecpg/test/preproc/define.pgc
new file mode 100644 (file)
index 0000000..1a4ac74
--- /dev/null
@@ -0,0 +1,64 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+EXEC SQL include ../regression;
+
+EXEC SQL typedef long mmInteger;
+EXEC SQL typedef char mmChar;
+EXEC SQL typedef short mmSmallInt;
+
+EXEC SQL BEGIN DECLARE SECTION;
+struct TBempl
+{
+  mmInteger idnum;
+  mmChar name[21];
+  mmSmallInt accs;
+};
+EXEC SQL END DECLARE SECTION;
+
+int
+main (void)
+{
+  EXEC SQL BEGIN DECLARE SECTION;
+  struct TBempl empl;
+  EXEC SQL END DECLARE SECTION;
+
+  ECPGdebug (1, stderr);
+
+  empl.idnum = 1;
+  EXEC SQL connect to REGRESSDB1;
+  if (sqlca.sqlcode)
+    {
+      printf ("connect error = %ld\n", sqlca.sqlcode);
+      exit (sqlca.sqlcode);
+    }
+
+  EXEC SQL create table empl
+    (idnum integer, name char (20), accs smallint);
+  if (sqlca.sqlcode)
+    {
+      printf ("create error = %ld\n", sqlca.sqlcode);
+      exit (sqlca.sqlcode);
+    }
+
+  EXEC SQL insert into empl values (1, 'first user', 320);
+  if (sqlca.sqlcode)
+    {
+      printf ("insert error = %ld\n", sqlca.sqlcode);
+      exit (sqlca.sqlcode);
+    }
+
+  EXEC SQL select idnum, name, accs
+       into :empl
+       from empl
+       where idnum =:empl.idnum;
+  if (sqlca.sqlcode)
+    {
+      printf ("select error = %ld\n", sqlca.sqlcode);
+      exit (sqlca.sqlcode);
+    }
+  printf ("id=%ld name=%s, accs=%d\n", empl.idnum, empl.name, empl.accs);
+
+  EXEC SQL disconnect;
+  exit (0);
+}
diff --git a/src/interfaces/ecpg/test/preproc/init.pgc b/src/interfaces/ecpg/test/preproc/init.pgc
new file mode 100644 (file)
index 0000000..8521e44
--- /dev/null
@@ -0,0 +1,100 @@
+exec sql include sqlca;
+
+enum e { ENUM0, ENUM1 };
+struct sa { int member; };
+
+static int fa(void)
+{
+       printf("in fa\n");
+       return 2;
+}
+
+static int
+fb(int x)
+{
+       printf("in fb (%d)\n", x);
+       return x;
+}
+
+static int
+fc(const char *x)
+{
+       printf("in fc (%s)\n", x);
+       return *x;
+}
+
+static int fd(const char *x,int i)
+{
+       printf("in fd (%s, %d)\n", x, i);
+       return (*x)*i;
+}
+
+static int fe(enum e x)
+{
+       printf("in fe (%d)\n", (int) x);
+       return (int)x;
+}
+
+static void sqlnotice(char *notice, short trans)
+{
+       if (!notice)
+               notice = "-empty-";
+       printf("in sqlnotice (%s, %d)\n", notice, trans);
+}
+
+exec sql define NONO 0;
+
+#define YES 1
+
+#ifdef _cplusplus
+namespace N
+{
+       static const int i=2;
+};
+#endif
+
+int main(void)
+{
+       struct sa x = { 14 },*y = &x;
+       exec sql begin declare section;
+               int a=(int)2;
+               int b=2+2;
+               int b2=(14*7);
+               int d=x.member;
+               int g=fb(2);
+               int i=3^1;
+               int j=1?1:2;
+
+               int e=y->member;
+               int c=10>>2;
+               bool h=2||1; 
+               long iay /* = 1L */ ;
+       exec sql end declare section;
+
+       int f=fa();
+
+#ifdef _cplusplus
+       exec sql begin declare section;
+       int k=N::i; /* compile error */
+       exec sql end declare section;
+#endif
+
+       ECPGdebug(1, stderr);
+
+       printf("%d %d %d %d %d %d %d %d %d %d %d\n", a, b, b2, c, d, e, f, g, h, i, j);
+       iay = 0;
+       printf("%ld\n", iay);
+       exec sql whenever sqlerror do fa();
+       exec sql select now();
+       exec sql whenever sqlerror do fb(20);
+       exec sql select now();
+       exec sql whenever sqlerror do fc("50");
+       exec sql select now();
+       exec sql whenever sqlerror do fd("50",1);
+       exec sql select now();
+       exec sql whenever sqlerror do fe(ENUM0);
+       exec sql select now();
+       exec sql whenever sqlerror do sqlnotice(NULL, NONO); 
+       exec sql select now();
+       return 0;
+}
index 381ff6b..f44ec6a 100644 (file)
@@ -3,18 +3,24 @@ top_builddir = ../../../../..
 include $(top_builddir)/src/Makefile.global
 include $(top_srcdir)/$(subdir)/../Makefile.regress
 
-TESTS = define define.c \
-        dyntest dyntest.c \
-        code100 code100.c \
+TESTS = array array.c \
+       binary binary.c \
+       code100 code100.c \
+        copystdout copystdout.c \
+       define define.c \
         desc desc.c \
+        dyntest dyntest.c \
         dynalloc dynalloc.c \
         dynalloc2 dynalloc2.c \
         func func.c \
         indicators indicators.c \
         quote quote.c \
         show show.c \
-        update update.c \
-        copystdout copystdout.c
+        update update.c 
 
 all: $(TESTS)
 
+# bits needs the -c option for the "EXEC SQL TYPE" construct
+bits.c: bits.pgc ../regression.h
+       $(ECPG) -c -o $@ -I$(srcdir) $<
+
similarity index 59%
rename from src/interfaces/ecpg/test/complex/test4.pgc
rename to src/interfaces/ecpg/test/sql/array.pgc
index 4be713b..2444e01 100644 (file)
@@ -7,29 +7,16 @@ exec sql whenever sqlerror sqlprint;
 exec sql include sqlca;
 exec sql include ../regression;
 
-EXEC SQL type errtype is enum
-{
-       OK   = 0,
-       ERR  = 1,
-       WARN = 2
-};
-
 int
 main (void)
 {
 EXEC SQL BEGIN DECLARE SECTION;
-       struct 
-       {
-               errtype e :2;
-               int code :14;
-       } error = {1, 147};
        int i = 1;
        int *did = &i;
        int a[10] = {9,8,7,6,5,4,3,2,1,0};
        char text[25] = "klmnopqrst";
        char *t = (char *)malloc(11);
        double f;
-       bool b = true;
 EXEC SQL END DECLARE SECTION;
 
        strcpy(t, "0123456789");
@@ -43,29 +30,24 @@ EXEC SQL END DECLARE SECTION;
 
        EXEC SQL BEGIN WORK;
 
-       EXEC SQL CREATE TABLE test (f float, i int, a int[10], text char(10), b bool, t int, err int);
+       EXEC SQL CREATE TABLE test (f float, i int, a int[10], text char(10));
 
-       EXEC SQL INSERT INTO test(f,i,a,text,b,t,err) VALUES(404.90,3,'{0,1,2,3,4,5,6,7,8,9}','abcdefghij','f',0,0);
+       EXEC SQL INSERT INTO test(f,i,a,text) VALUES(404.90,3,'{0,1,2,3,4,5,6,7,8,9}','abcdefghij');
 
-       EXEC SQL INSERT INTO test(f,i,a,text,b,t,err) VALUES(140787.0,2,:a,:text,'t',2,14);
+       EXEC SQL INSERT INTO test(f,i,a,text) VALUES(140787.0,2,:a,:text);
        
-EXEC SQL IFDEF BIT_FIELD_IS_NOT_ACCESSIBLE;
-       EXEC SQL INSERT INTO test(f,i,a,text,b,t,err) VALUES(14.07,:did,:a,:t,:b,:error);
-EXEC SQL ELSE;
-       EXEC SQL INSERT INTO test(f,i,a,text,b,t,err) VALUES(14.07,:did,:a,:t,:b,1,147);
-       error.code=0;
-EXEC SQL ENDIF;
+       EXEC SQL INSERT INTO test(f,i,a,text) VALUES(14.07,:did,:a,:t);
 
        EXEC SQL COMMIT;
 
        EXEC SQL BEGIN WORK; 
 
-       EXEC SQL SELECT f,text,b
-         INTO :f,:text,:b
+       EXEC SQL SELECT f,text
+         INTO :f,:text
          FROM test
          WHERE i = 1;
 
-       printf("Found f=%f text=%10.10s b=%d\n", f, text, b);
+       printf("Found f=%f text=%10.10s\n", f, text);
 
        f=140787;
        EXEC SQL SELECT a,text
similarity index 73%
rename from src/interfaces/ecpg/test/complex/test5.pgc
rename to src/interfaces/ecpg/test/sql/binary.pgc
index fa759c0..9be7340 100644 (file)
@@ -3,17 +3,13 @@
 
 EXEC SQL include ../regression;
 
-EXEC SQL typedef long mmInteger;
-EXEC SQL typedef char mmChar;
-EXEC SQL typedef short mmSmallInt;
-
 EXEC SQL BEGIN DECLARE SECTION;
 struct TBempl
 {
-  mmInteger idnum;
-  mmChar name[21];
-  mmSmallInt accs;
-  mmChar byte[20];
+  long idnum;
+  char name[21];
+  short accs;
+  char byte[20];
 };
 EXEC SQL END DECLARE SECTION;
 
@@ -23,11 +19,6 @@ main (void)
   EXEC SQL BEGIN DECLARE SECTION;
   struct TBempl empl;
   char *data = "\\001\\155\\000\\212";
-  union 
-  {
-       mmSmallInt accs;
-       char t[2];
-  } a;
   EXEC SQL END DECLARE SECTION;
   int i;
 
@@ -49,24 +40,13 @@ main (void)
       exit (sqlca.sqlcode);
     }
 
-  EXEC SQL insert into empl values (1, 'first user', 320,:data);
+  EXEC SQL insert into empl values (1, 'first user', 320, :data);
   if (sqlca.sqlcode)
     {
       printf ("insert error = %ld\n", sqlca.sqlcode);
       exit (sqlca.sqlcode);
     }
 
-  EXEC SQL select name, accs, byte
-       into :empl.name, :empl.accs, :empl.byte
-       from empl
-       where idnum =:empl.idnum;
-  if (sqlca.sqlcode)
-    {
-      printf ("select error = %ld\n", sqlca.sqlcode);
-      exit (sqlca.sqlcode);
-    }
-  printf ("name=%s, accs=%d byte=%s\n", empl.name, empl.accs, empl.byte);
-
   EXEC SQL DECLARE C CURSOR FOR select name, accs, byte from empl where idnum =:empl.idnum;
   EXEC SQL OPEN C;
   EXEC SQL FETCH C INTO:empl.name,:empl.accs,:empl.byte;
@@ -82,7 +62,7 @@ main (void)
   memset(empl.byte, '#', 20L);
   EXEC SQL DECLARE B BINARY CURSOR FOR select name, accs, byte from empl where idnum =:empl.idnum;
   EXEC SQL OPEN B;
-  EXEC SQL FETCH B INTO :empl.name,:a.accs,:empl.byte;
+  EXEC SQL FETCH B INTO :empl.name,:empl.accs,:empl.byte;
   if (sqlca.sqlcode)
     {
       printf ("fetch error = %ld\n", sqlca.sqlcode);