summaryrefslogtreecommitdiff
path: root/src/interfaces/ecpg/test
diff options
context:
space:
mode:
authorMichael Meskes <meskes@postgresql.org>2006-09-03 12:24:08 +0000
committerMichael Meskes <meskes@postgresql.org>2006-09-03 12:24:08 +0000
commit246bd83811e989bce7c1daf41bdff39ba133a913 (patch)
tree9207439c469c44c023ac0dbe7f6c9354fd30b0a8 /src/interfaces/ecpg/test
parentfc51c9186a095581beb40d0a46ee13ffb1f99211 (diff)
downloadpostgresql-246bd83811e989bce7c1daf41bdff39ba133a913.tar.gz
Synced parser.
Added another regression test and fixed tcp test.
Diffstat (limited to 'src/interfaces/ecpg/test')
-rw-r--r--src/interfaces/ecpg/test/expected/connect-test1.c6
-rw-r--r--src/interfaces/ecpg/test/expected/connect-test1.stderr6
-rw-r--r--src/interfaces/ecpg/test/expected/sql-update.c140
-rw-r--r--src/interfaces/ecpg/test/expected/sql-update.stderr50
-rw-r--r--src/interfaces/ecpg/test/expected/sql-update.stdout5
-rw-r--r--src/interfaces/ecpg/test/sql/Makefile1
-rw-r--r--src/interfaces/ecpg/test/sql/update.pgc35
7 files changed, 237 insertions, 6 deletions
diff --git a/src/interfaces/ecpg/test/expected/connect-test1.c b/src/interfaces/ecpg/test/expected/connect-test1.c
index 61119dd6fd..9ae85bff6d 100644
--- a/src/interfaces/ecpg/test/expected/connect-test1.c
+++ b/src/interfaces/ecpg/test/expected/connect-test1.c
@@ -56,7 +56,7 @@ main(void)
#line 27 "test1.pgc"
- { ECPGconnect(__LINE__, 0, "@localhost" , NULL,NULL , "main", 0); }
+ { ECPGconnect(__LINE__, 0, "@localhost" , "connectdb" , NULL , "main", 0); }
#line 29 "test1.pgc"
{ ECPGdisconnect(__LINE__, "main");}
@@ -70,7 +70,7 @@ main(void)
#line 33 "test1.pgc"
- { ECPGconnect(__LINE__, 0, "@localhost:55432" , NULL,NULL , "main", 0); }
+ { ECPGconnect(__LINE__, 0, "@localhost:55432" , "connectdb" , NULL , "main", 0); }
#line 35 "test1.pgc"
{ ECPGdisconnect(__LINE__, "main");}
@@ -84,7 +84,7 @@ main(void)
#line 39 "test1.pgc"
- { ECPGconnect(__LINE__, 0, ":55432" , NULL,NULL , "main", 0); }
+ { ECPGconnect(__LINE__, 0, ":55432" , "connectdb" , NULL , "main", 0); }
#line 41 "test1.pgc"
{ ECPGdisconnect(__LINE__, "main");}
diff --git a/src/interfaces/ecpg/test/expected/connect-test1.stderr b/src/interfaces/ecpg/test/expected/connect-test1.stderr
index 9668223f7a..11596cc1ca 100644
--- a/src/interfaces/ecpg/test/expected/connect-test1.stderr
+++ b/src/interfaces/ecpg/test/expected/connect-test1.stderr
@@ -15,7 +15,7 @@ THE PORT NUMBER MIGHT HAVE BEEN CHANGED BY THE REGRESSION SCRIPT
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_finish: Connection main closed.
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGconnect: opening database <DEFAULT> on localhost port <DEFAULT>
+[NO_PID]: ECPGconnect: opening database <DEFAULT> on localhost port <DEFAULT> for user connectdb
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_finish: Connection main closed.
[NO_PID]: sqlca: code: 0, state: 00000
@@ -23,7 +23,7 @@ THE PORT NUMBER MIGHT HAVE BEEN CHANGED BY THE REGRESSION SCRIPT
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_finish: Connection main closed.
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGconnect: opening database <DEFAULT> on localhost port 55432
+[NO_PID]: ECPGconnect: opening database <DEFAULT> on localhost port 55432 for user connectdb
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_finish: Connection main closed.
[NO_PID]: sqlca: code: 0, state: 00000
@@ -31,7 +31,7 @@ THE PORT NUMBER MIGHT HAVE BEEN CHANGED BY THE REGRESSION SCRIPT
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_finish: Connection main closed.
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGconnect: opening database <DEFAULT> on <DEFAULT> port 55432
+[NO_PID]: ECPGconnect: opening database <DEFAULT> on <DEFAULT> port 55432 for user connectdb
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_finish: Connection main closed.
[NO_PID]: sqlca: code: 0, state: 00000
diff --git a/src/interfaces/ecpg/test/expected/sql-update.c b/src/interfaces/ecpg/test/expected/sql-update.c
new file mode 100644
index 0000000000..39e4ddd6f6
--- /dev/null
+++ b/src/interfaces/ecpg/test/expected/sql-update.c
@@ -0,0 +1,140 @@
+/* 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 "update.pgc"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+#line 1 "regression.h"
+
+
+
+
+
+
+#line 5 "update.pgc"
+
+
+int main(int argc, char* argv[]) {
+ /* exec sql begin declare section */
+
+
+#line 9 "update.pgc"
+ int i1 [ 3 ] , i2 [ 3 ] ;
+/* exec sql end declare section */
+#line 10 "update.pgc"
+
+
+ ECPGdebug(1, stderr);
+ { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); }
+#line 13 "update.pgc"
+
+
+ /* exec sql whenever sql_warning sqlprint ; */
+#line 15 "update.pgc"
+
+ /* exec sql whenever sqlerror sqlprint ; */
+#line 16 "update.pgc"
+
+
+ { ECPGdo(__LINE__, 0, 1, NULL, "create table test ( a int , b int ) ", ECPGt_EOIT, ECPGt_EORT);
+#line 18 "update.pgc"
+
+if (sqlca.sqlwarn[0] == 'W') sqlprint();
+#line 18 "update.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 18 "update.pgc"
+
+
+ { ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( a , b ) values( 1 , 1 ) ", ECPGt_EOIT, ECPGt_EORT);
+#line 20 "update.pgc"
+
+if (sqlca.sqlwarn[0] == 'W') sqlprint();
+#line 20 "update.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 20 "update.pgc"
+
+ { ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( a , b ) values( 2 , 2 ) ", ECPGt_EOIT, ECPGt_EORT);
+#line 21 "update.pgc"
+
+if (sqlca.sqlwarn[0] == 'W') sqlprint();
+#line 21 "update.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 21 "update.pgc"
+
+ { ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( a , b ) values( 3 , 3 ) ", ECPGt_EOIT, ECPGt_EORT);
+#line 22 "update.pgc"
+
+if (sqlca.sqlwarn[0] == 'W') sqlprint();
+#line 22 "update.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 22 "update.pgc"
+
+
+ { ECPGdo(__LINE__, 0, 1, NULL, "update test set a = a + 1 ", ECPGt_EOIT, ECPGt_EORT);
+#line 24 "update.pgc"
+
+if (sqlca.sqlwarn[0] == 'W') sqlprint();
+#line 24 "update.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 24 "update.pgc"
+
+ { ECPGdo(__LINE__, 0, 1, NULL, "update test set ( a , b )=( 5 , 5 ) where a = 4 ", ECPGt_EOIT, ECPGt_EORT);
+#line 25 "update.pgc"
+
+if (sqlca.sqlwarn[0] == 'W') sqlprint();
+#line 25 "update.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 25 "update.pgc"
+
+ { ECPGdo(__LINE__, 0, 1, NULL, "update test set a = 4 where a = 3 ", ECPGt_EOIT, ECPGt_EORT);
+#line 26 "update.pgc"
+
+if (sqlca.sqlwarn[0] == 'W') sqlprint();
+#line 26 "update.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 26 "update.pgc"
+;
+
+ { ECPGdo(__LINE__, 0, 1, NULL, "select a , b from test order by a", ECPGt_EOIT,
+ ECPGt_int,(i1),(long)1,(long)3,sizeof(int),
+ ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
+ ECPGt_int,(i2),(long)1,(long)3,sizeof(int),
+ ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 28 "update.pgc"
+
+if (sqlca.sqlwarn[0] == 'W') sqlprint();
+#line 28 "update.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 28 "update.pgc"
+
+
+ printf("test\na b\n%d %d\n%d %d\n%d %d\n", i1[0], i2[0], i1[1], i2[1], i1[2], i2[2]);
+
+ { ECPGdisconnect(__LINE__, "ALL");
+#line 32 "update.pgc"
+
+if (sqlca.sqlwarn[0] == 'W') sqlprint();
+#line 32 "update.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 32 "update.pgc"
+
+
+ return 0;
+}
diff --git a/src/interfaces/ecpg/test/expected/sql-update.stderr b/src/interfaces/ecpg/test/expected/sql-update.stderr
new file mode 100644
index 0000000000..eab4a86c0d
--- /dev/null
+++ b/src/interfaces/ecpg/test/expected/sql-update.stderr
@@ -0,0 +1,50 @@
+[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 18: QUERY: create table test ( a int , b int ) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 18 Ok: CREATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 20: QUERY: insert into test ( a , b ) values( 1 , 1 ) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 20 Ok: INSERT 0 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 21: QUERY: insert into test ( a , b ) values( 2 , 2 ) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 21 Ok: INSERT 0 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 22: QUERY: insert into test ( a , b ) values( 3 , 3 ) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 22 Ok: INSERT 0 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 24: QUERY: update test set a = a + 1 on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 24 Ok: UPDATE 3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 25: QUERY: update test set ( a , b )=( 5 , 5 ) where a = 4 on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 25 Ok: UPDATE 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 26: QUERY: update test set a = 4 where a = 3 on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 26 Ok: UPDATE 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 28: QUERY: select a , b from test order by a on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGexecute line 28: Correctly got 3 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 28: RESULT: 2 offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 28: RESULT: 4 offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 28: RESULT: 5 offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 28: RESULT: 1 offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 28: RESULT: 2 offset: -1 array: Yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_data line 28: RESULT: 5 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/sql-update.stdout b/src/interfaces/ecpg/test/expected/sql-update.stdout
new file mode 100644
index 0000000000..a861f3ea2d
--- /dev/null
+++ b/src/interfaces/ecpg/test/expected/sql-update.stdout
@@ -0,0 +1,5 @@
+test
+a b
+2 1
+4 2
+5 5
diff --git a/src/interfaces/ecpg/test/sql/Makefile b/src/interfaces/ecpg/test/sql/Makefile
index 4ec2befcc7..381ff6bc6c 100644
--- a/src/interfaces/ecpg/test/sql/Makefile
+++ b/src/interfaces/ecpg/test/sql/Makefile
@@ -13,6 +13,7 @@ TESTS = define define.c \
indicators indicators.c \
quote quote.c \
show show.c \
+ update update.c \
copystdout copystdout.c
all: $(TESTS)
diff --git a/src/interfaces/ecpg/test/sql/update.pgc b/src/interfaces/ecpg/test/sql/update.pgc
new file mode 100644
index 0000000000..c406c3aba2
--- /dev/null
+++ b/src/interfaces/ecpg/test/sql/update.pgc
@@ -0,0 +1,35 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+EXEC SQL INCLUDE ../regression;
+
+int main(int argc, char* argv[]) {
+ EXEC SQL BEGIN DECLARE SECTION;
+ int i1[3], i2[3];
+ EXEC SQL END DECLARE SECTION;
+
+ ECPGdebug(1, stderr);
+ EXEC SQL CONNECT TO REGRESSDB1;
+
+ EXEC SQL WHENEVER SQLWARNING SQLPRINT;
+ EXEC SQL WHENEVER SQLERROR SQLPRINT;
+
+ EXEC SQL CREATE TABLE test(a int, b int);
+
+ EXEC SQL INSERT INTO test (a,b) values (1, 1);
+ EXEC SQL INSERT INTO test (a,b) values (2, 2);
+ EXEC SQL INSERT INTO test (a,b) values (3, 3);
+
+ EXEC SQL UPDATE test set a=a+1;
+ EXEC SQL UPDATE test set (a,b)=(5,5) where a = 4;
+ EXEC SQL UPDATE test set a=4 where a=3;;
+
+ EXEC SQL SELECT a,b into :i1,:i2 from test order by a;
+
+ printf("test\na b\n%d %d\n%d %d\n%d %d\n", i1[0], i2[0], i1[1], i2[1], i1[2], i2[2]);
+
+ EXEC SQL DISCONNECT ALL;
+
+ return 0;
+}