OSDN Git Service

Added missing files.
authorMichael Meskes <meskes@postgresql.org>
Thu, 26 Nov 2009 15:55:57 +0000 (15:55 +0000)
committerMichael Meskes <meskes@postgresql.org>
Thu, 26 Nov 2009 15:55:57 +0000 (15:55 +0000)
src/interfaces/ecpg/test/expected/preproc-cursor.c [new file with mode: 0644]
src/interfaces/ecpg/test/expected/preproc-cursor.stderr [new file with mode: 0644]
src/interfaces/ecpg/test/expected/preproc-cursor.stdout [new file with mode: 0644]
src/interfaces/ecpg/test/preproc/cursor.pgc [new file with mode: 0644]

diff --git a/src/interfaces/ecpg/test/expected/preproc-cursor.c b/src/interfaces/ecpg/test/expected/preproc-cursor.c
new file mode 100644 (file)
index 0000000..b9bf541
--- /dev/null
@@ -0,0 +1,760 @@
+/* Processed by ecpg (regression mode) */
+/* These include files are added by the preprocessor */
+#include <ecpglib.h>
+#include <ecpgerrno.h>
+#include <sqlca.h>
+/* End of automatic include section */
+#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+
+#line 1 "cursor.pgc"
+#include <stdlib.h>
+#include <string.h>
+
+
+#line 1 "regression.h"
+
+
+
+
+
+
+#line 4 "cursor.pgc"
+
+
+/* exec sql whenever sqlerror  stop ; */
+#line 6 "cursor.pgc"
+
+
+/* exec sql type c is char reference */
+#line 8 "cursor.pgc"
+
+typedef char* c;
+
+/* exec sql type ind is union { 
+#line 11 "cursor.pgc"
+ int integer ;
+#line 11 "cursor.pgc"
+ short smallint ;
+ } */
+#line 11 "cursor.pgc"
+
+typedef union { int integer; short smallint; } ind;
+
+#define BUFFERSIZ 8
+/* exec sql type str is [ BUFFERSIZ ] */
+#line 15 "cursor.pgc"
+
+
+#define CURNAME "mycur"
+
+int
+main (void)
+{
+/* exec sql begin declare section */
+                 
+                 
+                 
+                 
+               
+               
+               
+               
+
+#line 23 "cursor.pgc"
+ char * stmt1 = "SELECT id, t FROM t1" ;
+#line 24 "cursor.pgc"
+ char * curname1 = CURNAME ;
+#line 25 "cursor.pgc"
+ char * curname2 = CURNAME ;
+#line 26 "cursor.pgc"
+ char * curname3 = CURNAME ;
+#line 27 "cursor.pgc"
+  struct varchar_curname4_27  { int len; char arr[ 50 ]; }  curname4 ;
+#line 28 "cursor.pgc"
+ int count ;
+#line 29 "cursor.pgc"
+ int id ;
+#line 30 "cursor.pgc"
+ char t [ 64 ] ;
+/* exec sql end declare section */
+#line 31 "cursor.pgc"
+
+
+       char msg[128];
+
+       ECPGdebug(1, stderr);
+
+       strcpy(msg, "connect");
+       { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); 
+#line 38 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 38 "cursor.pgc"
+
+
+       strcpy(msg, "set");
+       { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+#line 41 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 41 "cursor.pgc"
+
+
+       strcpy(msg, "create");
+       { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table t1 ( id serial primary key , t text )", ECPGt_EOIT, ECPGt_EORT);
+#line 44 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 44 "cursor.pgc"
+
+
+       strcpy(msg, "insert");
+       { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'a' )", ECPGt_EOIT, ECPGt_EORT);
+#line 47 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 47 "cursor.pgc"
+
+       { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'b' )", ECPGt_EOIT, ECPGt_EORT);
+#line 48 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 48 "cursor.pgc"
+
+       { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'c' )", ECPGt_EOIT, ECPGt_EORT);
+#line 49 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 49 "cursor.pgc"
+
+       { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'd' )", ECPGt_EOIT, ECPGt_EORT);
+#line 50 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 50 "cursor.pgc"
+
+
+       strcpy(msg, "commit");
+       { ECPGtrans(__LINE__, NULL, "commit");
+#line 53 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 53 "cursor.pgc"
+
+
+       /* Dynamic cursorname test with INTO list in FETCH stmts */
+
+       strcpy(msg, "declare");
+       /* declare $0 cursor for select id , t from t1 */
+#line 59 "cursor.pgc"
+
+
+       strcpy(msg, "open");
+       { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for select id , t from t1", 
+       ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+#line 62 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 62 "cursor.pgc"
+
+
+       strcpy(msg, "fetch from");
+       { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch forward from $0", 
+       ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+       ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+       ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 65 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 65 "cursor.pgc"
+
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "fetch");
+       { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch forward $0", 
+       ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+       ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+       ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 69 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 69 "cursor.pgc"
+
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "fetch 1 from");
+       { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 from $0", 
+       ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+       ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+       ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 73 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 73 "cursor.pgc"
+
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "fetch :count from");
+       count = 1;
+       { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0 from $0", 
+       ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+       ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+       ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+       ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 78 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 78 "cursor.pgc"
+
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "move in");
+       { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "move absolute 0 in $0", 
+       ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+#line 82 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 82 "cursor.pgc"
+
+
+       strcpy(msg, "fetch 1");
+       { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 $0", 
+       ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+       ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+       ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 85 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 85 "cursor.pgc"
+
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "fetch :count");
+       count = 1;
+       { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0 $0", 
+       ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+       ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+       ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+       ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 90 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 90 "cursor.pgc"
+
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "close");
+       { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close $0", 
+       ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+#line 94 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 94 "cursor.pgc"
+
+
+       /* Dynamic cursorname test with INTO list in DECLARE stmt */
+
+       strcpy(msg, "declare");
+       /* declare $0 cursor for select id , t from t1 */
+#line 100 "cursor.pgc"
+
+
+       strcpy(msg, "open");
+       { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for select id , t from t1", 
+       ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+       ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+       ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 103 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 103 "cursor.pgc"
+
+
+       strcpy(msg, "fetch from");
+       { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch from $0", 
+       ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+       ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+       ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 106 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 106 "cursor.pgc"
+
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "fetch");
+       { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0", 
+       ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+       ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+       ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 110 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 110 "cursor.pgc"
+
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "fetch 1 from");
+       { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 from $0", 
+       ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+       ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+       ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 114 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 114 "cursor.pgc"
+
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "fetch :count from");
+       count = 1;
+       { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0 from $0", 
+       ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+       ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+       ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+       ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 119 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 119 "cursor.pgc"
+
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "move");
+       { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "move absolute 0 $0", 
+       ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+       ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+       ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 123 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 123 "cursor.pgc"
+
+
+       strcpy(msg, "fetch 1");
+       { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 $0", 
+       ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+       ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+       ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 126 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 126 "cursor.pgc"
+
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "fetch :count");
+       count = 1;
+       { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0 $0", 
+       ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+       ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+       ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+       ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 131 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 131 "cursor.pgc"
+
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "close");
+       { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close $0", 
+       ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+#line 135 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 135 "cursor.pgc"
+
+
+       /* Dynamic cursorname test with PREPARED stmt */
+
+       strcpy(msg, "prepare");
+       { ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
+#line 140 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 140 "cursor.pgc"
+
+
+       strcpy(msg, "declare");
+       /* declare $0 cursor for $1 */
+#line 143 "cursor.pgc"
+
+
+       strcpy(msg, "open");
+       { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for $1", 
+       ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+       ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id1", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+#line 146 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 146 "cursor.pgc"
+
+
+       strcpy(msg, "fetch from");
+       { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch from $0", 
+       ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+       ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+       ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 149 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 149 "cursor.pgc"
+
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "fetch");
+       { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0", 
+       ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+       ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+       ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 153 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 153 "cursor.pgc"
+
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "fetch 1 from");
+       { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 from $0", 
+       ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+       ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+       ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 157 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 157 "cursor.pgc"
+
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "fetch :count from");
+       count = 1;
+       { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0 from $0", 
+       ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+       ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+       ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+       ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 162 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 162 "cursor.pgc"
+
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "move");
+       { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "move absolute 0 $0", 
+       ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+#line 166 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 166 "cursor.pgc"
+
+
+       strcpy(msg, "fetch 1");
+       { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 $0", 
+       ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+       ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+       ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 169 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 169 "cursor.pgc"
+
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "fetch :count");
+       count = 1;
+       { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0 $0", 
+       ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+       ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+       ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+       ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 174 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 174 "cursor.pgc"
+
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "close");
+       { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close $0", 
+       ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+#line 178 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 178 "cursor.pgc"
+
+
+       strcpy(msg, "deallocate prepare");
+       { ECPGdeallocate(__LINE__, 0, NULL, "st_id1");
+#line 181 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 181 "cursor.pgc"
+
+
+       /* Dynamic cursorname test with PREPARED stmt,
+          cursor name in varchar */
+
+       curname4.len = strlen(CURNAME);
+       strcpy(curname4.arr, CURNAME);
+
+       strcpy(msg, "prepare");
+       { ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt1);
+#line 190 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 190 "cursor.pgc"
+
+
+       strcpy(msg, "declare");
+       /* declare $0 cursor for $1 */
+#line 193 "cursor.pgc"
+
+
+       strcpy(msg, "open");
+       { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for $1", 
+       ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+       ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id2", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+#line 196 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 196 "cursor.pgc"
+
+
+       strcpy(msg, "fetch from");
+       { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch from $0", 
+       ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+       ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+       ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 199 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 199 "cursor.pgc"
+
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "fetch");
+       { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0", 
+       ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+       ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+       ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 203 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 203 "cursor.pgc"
+
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "fetch 1 from");
+       { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 from $0", 
+       ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+       ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+       ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 207 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 207 "cursor.pgc"
+
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "fetch :count from");
+       count = 1;
+       { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0 from $0", 
+       ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+       ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+       ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+       ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 212 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 212 "cursor.pgc"
+
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "move");
+       { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "move absolute 0 $0", 
+       ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+#line 216 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 216 "cursor.pgc"
+
+
+       strcpy(msg, "fetch 1");
+       { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 $0", 
+       ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+       ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+       ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 219 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 219 "cursor.pgc"
+
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "fetch :count");
+       count = 1;
+       { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0 $0", 
+       ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+       ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+       ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+       ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 224 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 224 "cursor.pgc"
+
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "close");
+       { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close $0", 
+       ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+       ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+#line 228 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 228 "cursor.pgc"
+
+
+       strcpy(msg, "deallocate prepare");
+       { ECPGdeallocate(__LINE__, 0, NULL, "st_id2");
+#line 231 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 231 "cursor.pgc"
+
+
+       /* End test */
+
+       strcpy(msg, "drop");
+       { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
+#line 236 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 236 "cursor.pgc"
+
+
+       strcpy(msg, "commit");
+       { ECPGtrans(__LINE__, NULL, "commit");
+#line 239 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 239 "cursor.pgc"
+
+
+       strcpy(msg, "disconnect"); 
+       { ECPGdisconnect(__LINE__, "CURRENT");
+#line 242 "cursor.pgc"
+
+if (sqlca.sqlcode < 0) exit (1);}
+#line 242 "cursor.pgc"
+
+
+       return (0);
+}
diff --git a/src/interfaces/ecpg/test/expected/preproc-cursor.stderr b/src/interfaces/ecpg/test/expected/preproc-cursor.stderr
new file mode 100644 (file)
index 0000000..0178edb
--- /dev/null
@@ -0,0 +1,372 @@
+[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]: ecpg_execute on line 41: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: OK: SET
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 44: query: create table t1 ( id serial primary key , t text ); with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 44: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 44: OK: CREATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 47: query: insert into t1 ( id , t ) values ( default , 'a' ); with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 47: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 47: OK: INSERT 0 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 48: query: insert into t1 ( id , t ) values ( default , 'b' ); with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 48: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 48: OK: INSERT 0 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 49: query: insert into t1 ( id , t ) values ( default , 'c' ); with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 49: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 49: OK: INSERT 0 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 50: query: insert into t1 ( id , t ) values ( default , 'd' ); with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 50: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 50: OK: INSERT 0 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 53: action "commit"; connection "regress1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 62: query: declare mycur cursor for select id , t from t1; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 62: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 62: OK: DECLARE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 65: query: fetch forward from mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 65: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 65: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 65: RESULT: 1 offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 65: RESULT: a offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 69: query: fetch forward mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 69: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 69: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 69: RESULT: 2 offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 69: RESULT: b offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 73: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 73: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 73: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 73: RESULT: 3 offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 73: RESULT: c offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 78: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 78: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 78: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 78: RESULT: 4 offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 78: RESULT: d offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 82: query: move absolute 0 in mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 82: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 82: OK: MOVE 0
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 85: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 85: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 85: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 85: RESULT: 1 offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 85: RESULT: a offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 90: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 90: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 90: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 90: RESULT: 2 offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 90: RESULT: b offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 94: query: close mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 94: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 94: OK: CLOSE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 103: query: declare mycur cursor for select id , t from t1; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 103: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 103: OK: DECLARE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 106: query: fetch from mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 106: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 106: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 106: RESULT: 1 offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 106: RESULT: a offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 110: query: fetch mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 110: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 110: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 110: RESULT: 2 offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 110: RESULT: b offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 114: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 114: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 114: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 114: RESULT: 3 offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 114: RESULT: c offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 119: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 119: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 119: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 119: RESULT: 4 offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 119: RESULT: d offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 123: query: move absolute 0 mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 123: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 123: OK: MOVE 0
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 126: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 126: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 126: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 126: RESULT: 1 offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 126: RESULT: a offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 131: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 131: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 131: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 131: RESULT: 2 offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 131: RESULT: b offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 135: query: close mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 135: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 135: OK: CLOSE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGprepare on line 140: name st_id1; query: "SELECT id, t FROM t1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 146: query: declare mycur cursor for SELECT id, t FROM t1; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 146: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 146: OK: DECLARE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 149: query: fetch from mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 149: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 149: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 149: RESULT: 1 offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 149: RESULT: a offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 153: query: fetch mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 153: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 153: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 153: RESULT: 2 offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 153: RESULT: b offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 157: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 157: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 157: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 157: RESULT: 3 offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 157: RESULT: c offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 162: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 162: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 162: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 162: RESULT: 4 offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 162: RESULT: d offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 166: query: move absolute 0 mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 166: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 166: OK: MOVE 0
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 169: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 169: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 169: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 169: RESULT: 1 offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 169: RESULT: a offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 174: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 174: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 174: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 174: RESULT: 2 offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 174: RESULT: b offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 178: query: close mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 178: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 178: OK: CLOSE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGdeallocate on line 181: name st_id1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGprepare on line 190: name st_id2; query: "SELECT id, t FROM t1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 196: query: declare mycur cursor for SELECT id, t FROM t1; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 196: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 196: OK: DECLARE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 199: query: fetch from mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 199: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 199: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 199: RESULT: 1 offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 199: RESULT: a offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 203: query: fetch mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 203: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 203: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 203: RESULT: 2 offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 203: RESULT: b offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 207: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 207: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 207: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 207: RESULT: 3 offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 207: RESULT: c offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 212: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 212: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 212: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 212: RESULT: 4 offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 212: RESULT: d offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 216: query: move absolute 0 mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 216: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 216: OK: MOVE 0
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 219: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 219: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 219: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 219: RESULT: 1 offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 219: RESULT: a offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 224: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 224: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 224: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 224: RESULT: 2 offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 224: RESULT: b offset: -1; array: yes
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 228: query: close mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 228: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 228: OK: CLOSE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGdeallocate on line 231: name st_id2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 236: query: drop table t1; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 236: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 236: OK: DROP TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 239: 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/preproc-cursor.stdout b/src/interfaces/ecpg/test/expected/preproc-cursor.stdout
new file mode 100644 (file)
index 0000000..451f784
--- /dev/null
@@ -0,0 +1,24 @@
+1 a
+2 b
+3 c
+4 d
+1 a
+2 b
+1 a
+2 b
+3 c
+4 d
+1 a
+2 b
+1 a
+2 b
+3 c
+4 d
+1 a
+2 b
+1 a
+2 b
+3 c
+4 d
+1 a
+2 b
diff --git a/src/interfaces/ecpg/test/preproc/cursor.pgc b/src/interfaces/ecpg/test/preproc/cursor.pgc
new file mode 100644 (file)
index 0000000..397806c
--- /dev/null
@@ -0,0 +1,245 @@
+#include <stdlib.h>
+#include <string.h>
+
+exec sql include ../regression;
+
+exec sql whenever sqlerror stop;
+
+exec sql type c is char reference;
+typedef char* c;
+
+exec sql type ind is union { int integer; short smallint; };
+typedef union { int integer; short smallint; } ind;
+
+#define BUFFERSIZ 8
+exec sql type str is varchar[BUFFERSIZ];
+
+#define CURNAME "mycur"
+
+int
+main (void)
+{
+exec sql begin declare section;
+       char    *stmt1 = "SELECT id, t FROM t1";
+       char    *curname1 = CURNAME;
+       char    *curname2 = CURNAME;
+       char    *curname3 = CURNAME;
+       varchar curname4[50];
+       int     count;
+       int     id;
+       char    t[64];
+exec sql end declare section;
+
+       char msg[128];
+
+       ECPGdebug(1, stderr);
+
+       strcpy(msg, "connect");
+       exec sql connect to REGRESSDB1;
+
+       strcpy(msg, "set");
+       exec sql set datestyle to iso;
+
+       strcpy(msg, "create");
+       exec sql create table t1(id serial primary key, t text);
+
+       strcpy(msg, "insert");
+       exec sql insert into t1(id, t) values (default, 'a');
+       exec sql insert into t1(id, t) values (default, 'b');
+       exec sql insert into t1(id, t) values (default, 'c');
+       exec sql insert into t1(id, t) values (default, 'd');
+
+       strcpy(msg, "commit");
+       exec sql commit;
+
+       /* Dynamic cursorname test with INTO list in FETCH stmts */
+
+       strcpy(msg, "declare");
+       exec sql declare :curname1 cursor for
+               select id, t from t1;
+
+       strcpy(msg, "open");
+       exec sql open :curname1;
+
+       strcpy(msg, "fetch from");
+       exec sql fetch forward from :curname1 into :id, :t;
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "fetch");
+       exec sql fetch forward :curname1 into :id, :t;
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "fetch 1 from");
+       exec sql fetch 1 from :curname1 into :id, :t;
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "fetch :count from");
+       count = 1;
+       exec sql fetch :count from :curname1 into :id, :t;
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "move in");
+       exec sql move absolute 0 in :curname1;
+
+       strcpy(msg, "fetch 1");
+       exec sql fetch 1 :curname1 into :id, :t;
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "fetch :count");
+       count = 1;
+       exec sql fetch :count :curname1 into :id, :t;
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "close");
+       exec sql close :curname1;
+
+       /* Dynamic cursorname test with INTO list in DECLARE stmt */
+
+       strcpy(msg, "declare");
+       exec sql declare :curname2 cursor for
+               select id, t into :id, :t from t1;
+
+       strcpy(msg, "open");
+       exec sql open :curname2;
+
+       strcpy(msg, "fetch from");
+       exec sql fetch from :curname2;
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "fetch");
+       exec sql fetch :curname2;
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "fetch 1 from");
+       exec sql fetch 1 from :curname2;
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "fetch :count from");
+       count = 1;
+       exec sql fetch :count from :curname2;
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "move");
+       exec sql move absolute 0 :curname2;
+
+       strcpy(msg, "fetch 1");
+       exec sql fetch 1 :curname2;
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "fetch :count");
+       count = 1;
+       exec sql fetch :count :curname2;
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "close");
+       exec sql close :curname2;
+
+       /* Dynamic cursorname test with PREPARED stmt */
+
+       strcpy(msg, "prepare");
+       exec sql prepare st_id1 from :stmt1;
+
+       strcpy(msg, "declare");
+       exec sql declare :curname3 cursor for st_id1;
+
+       strcpy(msg, "open");
+       exec sql open :curname3;
+
+       strcpy(msg, "fetch from");
+       exec sql fetch from :curname3 into :id, :t;
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "fetch");
+       exec sql fetch :curname3 into :id, :t;
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "fetch 1 from");
+       exec sql fetch 1 from :curname3 into :id, :t;
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "fetch :count from");
+       count = 1;
+       exec sql fetch :count from :curname3 into :id, :t;
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "move");
+       exec sql move absolute 0 :curname3;
+
+       strcpy(msg, "fetch 1");
+       exec sql fetch 1 :curname3 into :id, :t;
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "fetch :count");
+       count = 1;
+       exec sql fetch :count :curname3 into :id, :t;
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "close");
+       exec sql close :curname3;
+
+       strcpy(msg, "deallocate prepare");
+       exec sql deallocate prepare st_id1;
+
+       /* Dynamic cursorname test with PREPARED stmt,
+          cursor name in varchar */
+
+       curname4.len = strlen(CURNAME);
+       strcpy(curname4.arr, CURNAME);
+
+       strcpy(msg, "prepare");
+       exec sql prepare st_id2 from :stmt1;
+
+       strcpy(msg, "declare");
+       exec sql declare :curname4 cursor for st_id2;
+
+       strcpy(msg, "open");
+       exec sql open :curname4;
+
+       strcpy(msg, "fetch from");
+       exec sql fetch from :curname4 into :id, :t;
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "fetch");
+       exec sql fetch :curname4 into :id, :t;
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "fetch 1 from");
+       exec sql fetch 1 from :curname4 into :id, :t;
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "fetch :count from");
+       count = 1;
+       exec sql fetch :count from :curname4 into :id, :t;
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "move");
+       exec sql move absolute 0 :curname4;
+
+       strcpy(msg, "fetch 1");
+       exec sql fetch 1 :curname4 into :id, :t;
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "fetch :count");
+       count = 1;
+       exec sql fetch :count :curname4 into :id, :t;
+       printf("%d %s\n", id, t);
+
+       strcpy(msg, "close");
+       exec sql close :curname4;
+
+       strcpy(msg, "deallocate prepare");
+       exec sql deallocate prepare st_id2;
+
+       /* End test */
+
+       strcpy(msg, "drop");
+       exec sql drop table t1;
+
+       strcpy(msg, "commit");
+       exec sql commit;
+
+       strcpy(msg, "disconnect"); 
+       exec sql disconnect;
+
+       return (0);
+}