commit 937e23e33639f7f4b3b3753a46ef8cf1b9b2ea27
Author: Böszörményi Zoltán <zb@cybertec.at>
Date:   Fri Dec 6 13:47:05 2013 +0100

    ECPG: Allow returning the number of tuples in the cursor at the time
    of opening it if the user explicitly asked for it. This emulates
    the behaviour of Informix but can be useful natively, too.

diff --git a/doc/src/sgml/ecpg.sgml b/doc/src/sgml/ecpg.sgml
index eb5431b..4fec8f4 100644
--- a/doc/src/sgml/ecpg.sgml
+++ b/doc/src/sgml/ecpg.sgml
@@ -479,6 +479,15 @@ EXEC SQL COMMIT;
    For this reason, <literal>READAHEAD 1</literal> is recommended.
   </para>
 
+  <para>
+   There is also a possibility to return the number of tuples returned by the cursor
+   in sqlca.sqlerrd[2] at <command>OPEN</command>. To turn this on, use the
+   <option>-r detect-cursor-resultset-size</option> ECPG command line parameter.
+   This may cause side effects if the cursor query contains calls to volatile
+   functions. See <xref linkend="xfunc-volatility">. Using this feature also
+   slows down opening the cursor.
+  </para>
+
    <note>
     <para>
      The ECPG <command>DECLARE</command> command does not actually
@@ -4892,6 +4901,12 @@ struct
     processed row, if applicable, and
     <literal>sqlca.sqlerrd[2]</literal> contains the number of
     processed or returned rows, if applicable to the command.
+    The <command>OPEN</command> statement may return the
+    result set size in <literal>sqlca.sqlerrd[2]</literal> if
+    option <literal>-r detect-cursor-resultset-size</literal> 
+    is specified on the ECPG command line. This may cause side effects
+    because of traversing the result set. See <xref linkend="xfunc-volatility">.
+    It will also slow down opening the cursor.
    </para>
 
    <para>
diff --git a/doc/src/sgml/ref/ecpg-ref.sgml b/doc/src/sgml/ref/ecpg-ref.sgml
index ddbdbe5..27b6435 100644
--- a/doc/src/sgml/ref/ecpg-ref.sgml
+++ b/doc/src/sgml/ref/ecpg-ref.sgml
@@ -175,6 +175,15 @@ PostgreSQL documentation
           </para>
          </listitem>
         </varlistentry>
+        <varlistentry>
+         <term><option>detect-cursor-resultset-size</option></term>
+         <listitem>
+          <para>
+           Detect the cursor result set size during <command>OPEN</command> and
+           return it in sqlca.sqlerrd[2].
+          </para>
+         </listitem>
+        </varlistentry>
        </variablelist></para>
      </listitem>
     </varlistentry>
diff --git a/src/interfaces/ecpg/ecpglib/cursor.c b/src/interfaces/ecpg/ecpglib/cursor.c
index aa74cdc..43fd173 100644
--- a/src/interfaces/ecpg/ecpglib/cursor.c
+++ b/src/interfaces/ecpg/ecpglib/cursor.c
@@ -48,6 +48,15 @@ static bool ecpg_cursor_next_pos(struct statement *stmt,
 					int64 *next_pos_out, bool *next_atstart_out,
 					bool *next_atend_out, bool *error, bool *beyond_known);
 
+static bool ecpg_cursor_do_move_absolute(struct statement *stmt,
+					struct cursor_descriptor *cur,
+					int64 amount, int64 *return_pos);
+
+static bool ecpg_cursor_do_move_all(struct statement *stmt,
+					struct cursor_descriptor *cur,
+					enum ECPG_cursor_direction direction,
+					int64 *return_pos);
+
 static void
 raise_cursor_error(struct connection *con, int lineno, const char *name)
 {
@@ -297,11 +306,13 @@ bool
 ECPGopen(const int lineno, const int compat, const int force_indicator,
 			const char *connection_name, const bool questionmarks,
 			const bool with_hold, enum ECPG_cursor_scroll scrollable,
-			long readahead, const bool allow_ra_override,
+			long readahead, const bool allow_ra_override, bool return_rssz,
 			const char *curname, const int st, const char *query, ...)
 {
+	struct sqlca_t *sqlca = ECPGget_sqlca();
 	struct connection *con = ecpg_get_connection(connection_name);
 	struct statement *stmt;
+	struct cursor_descriptor *cur;
 	int		subxact_level;
 	va_list		args;
 
@@ -360,8 +371,6 @@ ECPGopen(const int lineno, const int compat, const int force_indicator,
 		return false;
 	}
 
-	ecpg_do_epilogue(stmt);
-
 	/* Process the environment variables only once */
 	if (!envvars_read)
 	{
@@ -398,10 +407,50 @@ ECPGopen(const int lineno, const int compat, const int force_indicator,
 		subxact_level =
 			(PQtransactionStatus(con->connection) != PQTRANS_IDLE ?
 										1 : 0);
-	add_cursor(lineno, con, curname, subxact_level, with_hold, scrollable,
+
+	cur = add_cursor(lineno, con, curname, subxact_level, with_hold, scrollable,
 					(allow_ra_override && default_fetch_size >= 1 ?
 						default_fetch_size : readahead));
 
+	/*
+	 * Now discover the number of tuples in the result set only if:
+	 * - the cursor is known scrollable, and
+	 * - the user requested to return the number of tuples in
+	 *   the result set.
+	 * Although this slows down OPEN, for some loads caching
+	 * still overweights it.
+	 *
+	 * One downside is the multiple evaluation of volatile functions
+	 * and their possible side effects.
+	 */
+	if (scrollable == ECPGcs_scroll && return_rssz)
+	{
+		int64		return_pos;
+
+		/*
+		 * We are at the start of the result set,
+		 * MOVE ALL returns the number of tuples in it.
+		 */
+		if (!ecpg_cursor_do_move_all(stmt, cur, ECPGc_forward, &return_pos))
+		{
+			del_cursor(con, lineno, curname);
+			ecpg_do_epilogue(stmt);
+			return false;
+		}
+
+		/* Go back to the beginning of the result set. */
+		if (!ecpg_cursor_move(stmt, cur, ECPGc_absolute, 0, false, true))
+		{
+			del_cursor(con, lineno, curname);
+			ecpg_do_epilogue(stmt);
+			return false;
+		}
+
+		sqlca->sqlerrd[2] = (return_pos <= LONG_MAX ? return_pos : 0);
+	}
+
+	ecpg_do_epilogue(stmt);
+
 	return true;
 }
 
diff --git a/src/interfaces/ecpg/include/ecpglib.h b/src/interfaces/ecpg/include/ecpglib.h
index 6fb7755..de78378 100644
--- a/src/interfaces/ecpg/include/ecpglib.h
+++ b/src/interfaces/ecpg/include/ecpglib.h
@@ -65,7 +65,7 @@ char	   *ECPGerrmsg(void);
 
 /* Cursor functions */
 bool		ECPGopen(const int, const int, const int, const char *, const bool, const bool,
-				enum ECPG_cursor_scroll, long, const bool,
+				enum ECPG_cursor_scroll, long, const bool, const bool,
 				const char *, const int, const char *, ...);
 bool		ECPGfetch(const int, const int, const int, const char *, const bool,
 				enum ECPG_cursor_direction, const char *, bool,
diff --git a/src/interfaces/ecpg/preproc/ecpg.c b/src/interfaces/ecpg/preproc/ecpg.c
index 453fe24..eb070ec 100644
--- a/src/interfaces/ecpg/preproc/ecpg.c
+++ b/src/interfaces/ecpg/preproc/ecpg.c
@@ -18,7 +18,8 @@ bool		autocommit = false,
 			force_indicator = true,
 			questionmarks = false,
 			regression_mode = false,
-			auto_prepare = false;
+			auto_prepare = false,
+			cursor_rssz = false;
 long		fetch_readahead = 1; /* No readahead by default */
 
 char	   *output_filename;
@@ -53,7 +54,7 @@ help(const char *progname)
 	printf(_("  -o OUTFILE     write result to OUTFILE\n"));
 	printf(_("  -r OPTION      specify run-time behavior; OPTION can be:\n"
 	 "                 \"no_indicator\", \"prepare\", \"questionmarks\",\n"
-	 "                 \"readahead=number\"\n"));
+	 "                 \"readahead=number\", \"detect-cursor-resultset-size\"\n"));
 	printf(_("  --regression   run in regression testing mode\n"));
 	printf(_("  -t             turn on autocommit of transactions\n"));
 	printf(_("  --version      output version information, then exit\n"));
@@ -247,6 +248,8 @@ main(int argc, char *const argv[])
 						return ILLEGAL_OPTION;
 					}
 				}
+				else if (strcmp(optarg, "detect-cursor-resultset-size") == 0)
+					cursor_rssz = true;
 				else
 				{
 					fprintf(stderr, _("Try \"%s --help\" for more information.\n"), argv[0]);
diff --git a/src/interfaces/ecpg/preproc/extern.h b/src/interfaces/ecpg/preproc/extern.h
index 891c768..ede2038 100644
--- a/src/interfaces/ecpg/preproc/extern.h
+++ b/src/interfaces/ecpg/preproc/extern.h
@@ -24,7 +24,8 @@ extern bool autocommit,
 			force_indicator,
 			questionmarks,
 			regression_mode,
-			auto_prepare;
+			auto_prepare,
+			cursor_rssz;
 extern long	fetch_readahead;
 extern int	braces_open,
 			ret_value,
diff --git a/src/interfaces/ecpg/preproc/output.c b/src/interfaces/ecpg/preproc/output.c
index 5a206cc..98b2588 100644
--- a/src/interfaces/ecpg/preproc/output.c
+++ b/src/interfaces/ecpg/preproc/output.c
@@ -243,10 +243,10 @@ output_open_statement(char *stmt, int whenever_mode, enum ECPG_statement_type st
 {
 	struct cursor *ptr = get_cursor(current_cursor);
 
-	fprintf(yyout, "{ ECPGopen(__LINE__, %d, %d, %s, %d, %d, %s, %ld, %d, ",
+	fprintf(yyout, "{ ECPGopen(__LINE__, %d, %d, %s, %d, %d, %s, %ld, %d, %d, ",
 						compat, force_indicator, connection ? connection : "NULL", questionmarks,
 						ptr->with_hold, ecpg_cursor_scroll_name[ptr->scrollable],
-						ptr->fetch_readahead, ptr->allow_ra_override);
+						ptr->fetch_readahead, ptr->allow_ra_override, cursor_rssz);
 	output_cursor_name(ptr);
 	output_statement_epilogue(stmt, whenever_mode, st);
 }
diff --git a/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c b/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c
index 5488511..c7bd211 100644
--- a/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c
+++ b/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c
@@ -241,7 +241,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 
 	strcpy(msg, "open");
-	{ ECPGopen(__LINE__, 1, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, "mycur1", ECPGst_normal, "declare mycur1 no scroll cursor for $1", 
+	{ ECPGopen(__LINE__, 1, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, 0, "mycur1", ECPGst_normal, "declare mycur1 no scroll cursor for $1", 
 	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 101 "sqlda.pgc"
@@ -316,7 +316,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 
 	strcpy(msg, "open");
-	{ ECPGopen(__LINE__, 1, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, "mycur2", ECPGst_normal, "declare mycur2 no scroll cursor for $1", 
+	{ ECPGopen(__LINE__, 1, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, 0, "mycur2", ECPGst_normal, "declare mycur2 no scroll cursor for $1", 
 	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 138 "sqlda.pgc"
diff --git a/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c b/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c
index c4be5cd..e1e0830 100644
--- a/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c
+++ b/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c
@@ -244,7 +244,7 @@ if (sqlca.sqlcode < 0) dosqlprint ( );}
 
 static void openit(void)
 {
-	{ ECPGopen(__LINE__, 1, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, "c", ECPGst_normal, "declare c no scroll cursor for select * from test where i <= $1 ", 
+	{ ECPGopen(__LINE__, 1, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, 0, "c", ECPGst_normal, "declare c no scroll cursor for select * from test where i <= $1 ", 
 	ECPGt_int,&(*( int  *)(ECPGget_var( 0))),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 95 "test_informix.pgc"
diff --git a/src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.c b/src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.c
index de73001..9a83cfc 100644
--- a/src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.c
+++ b/src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.c
@@ -82,7 +82,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
 	/* declare cur no scroll cursor for select id , d , d from nantest1 */
 #line 33 "nan_test.pgc"
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, "cur", ECPGst_normal, "declare cur no scroll cursor for select id , d , d from nantest1", ECPGt_EOIT, ECPGt_EORT);
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, 0, "cur", ECPGst_normal, "declare cur no scroll cursor for select id , d , d from nantest1", ECPGt_EOIT, ECPGt_EORT);
 #line 34 "nan_test.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint ( );}
@@ -137,7 +137,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
 #line 48 "nan_test.pgc"
 
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, "cur", ECPGst_normal, "declare cur no scroll cursor for select id , d , d from nantest1", ECPGt_EOIT, ECPGt_EORT);
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, 0, "cur", ECPGst_normal, "declare cur no scroll cursor for select id , d , d from nantest1", ECPGt_EOIT, ECPGt_EORT);
 #line 50 "nan_test.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint ( );}
@@ -221,7 +221,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
 	/* declare cur1 no scroll cursor for select id , d , d from nantest2 */
 #line 75 "nan_test.pgc"
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, "cur1", ECPGst_normal, "declare cur1 no scroll cursor for select id , d , d from nantest2", ECPGt_EOIT, ECPGt_EORT);
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, 0, "cur1", ECPGst_normal, "declare cur1 no scroll cursor for select id , d , d from nantest2", ECPGt_EOIT, ECPGt_EORT);
 #line 76 "nan_test.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint ( );}
diff --git a/src/interfaces/ecpg/test/expected/preproc-autoprep.c b/src/interfaces/ecpg/test/expected/preproc-autoprep.c
index 873539f..5891565 100644
--- a/src/interfaces/ecpg/test/expected/preproc-autoprep.c
+++ b/src/interfaces/ecpg/test/expected/preproc-autoprep.c
@@ -133,7 +133,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 #line 35 "autoprep.pgc"
 
 
-  { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, "C", ECPGst_normal, "declare C no scroll cursor for select Item1 from T", ECPGt_EOIT, ECPGt_EORT);
+  { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, 0, "C", ECPGst_normal, "declare C no scroll cursor for select Item1 from T", ECPGt_EOIT, ECPGt_EORT);
 #line 37 "autoprep.pgc"
 
 if (sqlca.sqlwarn[0] == 'W') sqlprint();
@@ -180,7 +180,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 #line 46 "autoprep.pgc"
 
 
-  { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, "cur1", ECPGst_normal, "declare cur1 no scroll cursor for $1", 
+  { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, 0, "cur1", ECPGst_normal, "declare cur1 no scroll cursor for $1", 
 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "stmt1", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 48 "autoprep.pgc"
diff --git a/src/interfaces/ecpg/test/expected/preproc-cursor.c b/src/interfaces/ecpg/test/expected/preproc-cursor.c
index fd47a91..02a37b2 100644
--- a/src/interfaces/ecpg/test/expected/preproc-cursor.c
+++ b/src/interfaces/ecpg/test/expected/preproc-cursor.c
@@ -187,7 +187,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 
 	strcpy(msg, "open");
-	{ ECPGopen(__LINE__, 0, 1, "test1", 0, 0, ECPGcs_no_scroll, 1, 1, curname1, ECPGst_normal, "declare $0 no scroll cursor for select id , t from t1", 
+	{ ECPGopen(__LINE__, 0, 1, "test1", 0, 0, ECPGcs_no_scroll, 1, 1, 0, curname1, ECPGst_normal, "declare $0 no scroll 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 67 "cursor.pgc"
@@ -323,7 +323,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 
 	strcpy(msg, "open");
-	{ ECPGopen(__LINE__, 0, 1, "test1", 0, 0, ECPGcs_no_scroll, 1, 1, curname2, ECPGst_normal, "declare $0 no scroll cursor for select id , t from t1", 
+	{ ECPGopen(__LINE__, 0, 1, "test1", 0, 0, ECPGcs_no_scroll, 1, 1, 0, curname2, ECPGst_normal, "declare $0 no scroll 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), 
@@ -483,7 +483,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 
 	strcpy(msg, "open");
-	{ ECPGopen(__LINE__, 0, 1, "test1", 0, 0, ECPGcs_no_scroll, 1, 1, curname3, ECPGst_normal, "declare $0 no scroll cursor for $1", 
+	{ ECPGopen(__LINE__, 0, 1, "test1", 0, 0, ECPGcs_no_scroll, 1, 1, 0, curname3, ECPGst_normal, "declare $0 no scroll 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("test1", "st_id1", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
@@ -493,7 +493,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 if (sqlca.sqlcode < 0) exit (1);}
 #line 153 "cursor.pgc"
 
-	{ ECPGopen(__LINE__, 0, 1, "test2", 0, 0, ECPGcs_no_scroll, 1, 1, curname5, ECPGst_normal, "declare $0 no scroll cursor for $1", 
+	{ ECPGopen(__LINE__, 0, 1, "test2", 0, 0, ECPGcs_no_scroll, 1, 1, 0, curname5, ECPGst_normal, "declare $0 no scroll cursor for $1", 
 	ECPGt_char,&(curname5),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char_variable,(ECPGprepared_statement("test2", "st_id1", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
@@ -663,7 +663,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 
 	strcpy(msg, "open");
-	{ ECPGopen(__LINE__, 0, 1, "test1", 0, 0, ECPGcs_no_scroll, 1, 1, curname4.arr, ECPGst_normal, "declare $0 no scroll cursor for $1", 
+	{ ECPGopen(__LINE__, 0, 1, "test1", 0, 0, ECPGcs_no_scroll, 1, 1, 0, curname4.arr, ECPGst_normal, "declare $0 no scroll cursor for $1", 
 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char_variable,(ECPGprepared_statement("test1", "st_id2", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
diff --git a/src/interfaces/ecpg/test/expected/preproc-outofscope.c b/src/interfaces/ecpg/test/expected/preproc-outofscope.c
index d94f7c0..1ad80d8 100644
--- a/src/interfaces/ecpg/test/expected/preproc-outofscope.c
+++ b/src/interfaces/ecpg/test/expected/preproc-outofscope.c
@@ -201,7 +201,7 @@ get_var1(MYTYPE **myvar0, MYNULLTYPE **mynullvar0)
 static void
 open_cur1(void)
 {
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, "mycur", ECPGst_normal, "declare mycur no scroll cursor for select * from a1", ECPGt_EOIT, 
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, 0, "mycur", ECPGst_normal, "declare mycur no scroll cursor for select * from a1", ECPGt_EOIT, 
 	ECPGt_int,&((*( MYTYPE  *)(ECPGget_var( 0)) ).id),(long)1,(long)1,sizeof(int), 
 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPGget_var( 1)) ).id),(long)1,(long)1,sizeof(int), 
 	ECPGt_char,&((*( MYTYPE  *)(ECPGget_var( 0)) ).t),(long)64,(long)1,(64)*sizeof(char), 
diff --git a/src/interfaces/ecpg/test/expected/preproc-variable.c b/src/interfaces/ecpg/test/expected/preproc-variable.c
index c68bcb4..87b0829 100644
--- a/src/interfaces/ecpg/test/expected/preproc-variable.c
+++ b/src/interfaces/ecpg/test/expected/preproc-variable.c
@@ -190,7 +190,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 
 	strcpy(msg, "open");
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, "cur", ECPGst_normal, "declare cur no scroll cursor for select name , born , age , married , children from family", ECPGt_EOIT, ECPGt_EORT);
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, 0, "cur", ECPGst_normal, "declare cur no scroll cursor for select name , born , age , married , children from family", ECPGt_EOIT, ECPGt_EORT);
 #line 63 "variable.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
diff --git a/src/interfaces/ecpg/test/expected/sql-binary.c b/src/interfaces/ecpg/test/expected/sql-binary.c
index 0538925..6f98d39 100644
--- a/src/interfaces/ecpg/test/expected/sql-binary.c
+++ b/src/interfaces/ecpg/test/expected/sql-binary.c
@@ -111,7 +111,7 @@ main (void)
  /* declare C no scroll cursor for select name , accs , byte from empl where idnum = $1  */
 #line 58 "binary.pgc"
 
-  { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, "C", ECPGst_normal, "declare C no scroll cursor for select name , accs , byte from empl where idnum = $1 ", 
+  { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, 0, "C", ECPGst_normal, "declare C no scroll cursor for select name , accs , byte from empl where idnum = $1 ", 
 	ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
 #line 59 "binary.pgc"
@@ -142,7 +142,7 @@ main (void)
  /* declare B binary no scroll cursor for select name , accs , byte from empl where idnum = $1  */
 #line 72 "binary.pgc"
 
-  { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, "B", ECPGst_normal, "declare B binary no scroll cursor for select name , accs , byte from empl where idnum = $1 ", 
+  { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, 0, "B", ECPGst_normal, "declare B binary no scroll cursor for select name , accs , byte from empl where idnum = $1 ", 
 	ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
 #line 73 "binary.pgc"
@@ -176,7 +176,7 @@ main (void)
  /* declare A binary no scroll cursor for select byte from empl where idnum = $1  */
 #line 89 "binary.pgc"
 
-  { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, "A", ECPGst_normal, "declare A binary no scroll cursor for select byte from empl where idnum = $1 ", 
+  { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, 0, "A", ECPGst_normal, "declare A binary no scroll cursor for select byte from empl where idnum = $1 ", 
 	ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
 #line 90 "binary.pgc"
diff --git a/src/interfaces/ecpg/test/expected/sql-cursor-ra-fetch.c b/src/interfaces/ecpg/test/expected/sql-cursor-ra-fetch.c
index 47ded6b..fa51afa 100644
--- a/src/interfaces/ecpg/test/expected/sql-cursor-ra-fetch.c
+++ b/src/interfaces/ecpg/test/expected/sql-cursor-ra-fetch.c
@@ -83,7 +83,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 
 	printf("test scroll_cur for move absolute n (every 4th tuple forward, positive positions)\n");
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 8, 0, "scroll_cur", ECPGst_normal, "declare scroll_cur scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT);
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 8, 0, 0, "scroll_cur", ECPGst_normal, "declare scroll_cur scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT);
 #line 38 "cursor-ra-fetch.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
@@ -150,7 +150,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 
 	printf("\ntest scroll_cur for move absolute n (every 4th tuple backward, negative positions)\n");
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 8, 0, "scroll_cur", ECPGst_normal, "declare scroll_cur scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT);
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 8, 0, 0, "scroll_cur", ECPGst_normal, "declare scroll_cur scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT);
 #line 73 "cursor-ra-fetch.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
@@ -217,7 +217,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 
 	printf("\ntest scroll_cur for fetch relative 4 (positive positions)\n");
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 8, 0, "scroll_cur", ECPGst_normal, "declare scroll_cur scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT);
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 8, 0, 0, "scroll_cur", ECPGst_normal, "declare scroll_cur scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT);
 #line 108 "cursor-ra-fetch.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
@@ -290,7 +290,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 
 	printf("\ntest scroll_cur for fetch relative -4 (negative positions)\n");
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 8, 0, "scroll_cur", ECPGst_normal, "declare scroll_cur scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT);
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 8, 0, 0, "scroll_cur", ECPGst_normal, "declare scroll_cur scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT);
 #line 153 "cursor-ra-fetch.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
@@ -380,7 +380,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 
 	printf("\ntest scroll_cur for fetch forward 4 (positive positions)\n");
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 8, 0, "scroll_cur", ECPGst_normal, "declare scroll_cur scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT);
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 8, 0, 0, "scroll_cur", ECPGst_normal, "declare scroll_cur scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT);
 #line 205 "cursor-ra-fetch.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
@@ -453,7 +453,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 
 	printf("\ntest scroll_cur for fetch forward -4 (negative positions)\n");
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 8, 0, "scroll_cur", ECPGst_normal, "declare scroll_cur scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT);
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 8, 0, 0, "scroll_cur", ECPGst_normal, "declare scroll_cur scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT);
 #line 250 "cursor-ra-fetch.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
@@ -544,7 +544,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 
 	printf("\ntest scroll_cur4 for move absolute n (every 5th tuple forward, positive positions)\n");
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 4, 0, "scroll_cur4", ECPGst_normal, "declare scroll_cur4 scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT);
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 4, 0, 0, "scroll_cur4", ECPGst_normal, "declare scroll_cur4 scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT);
 #line 303 "cursor-ra-fetch.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
@@ -655,7 +655,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 
 	printf("\ntest scroll_cur4 for move absolute n (every 5th tuple backward, negative positions)\n");
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 4, 0, "scroll_cur4", ECPGst_normal, "declare scroll_cur4 scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT);
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 4, 0, 0, "scroll_cur4", ECPGst_normal, "declare scroll_cur4 scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT);
 #line 364 "cursor-ra-fetch.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
@@ -767,7 +767,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 
 	printf("\ntest scroll_cur4 for fetch relative 5 (positive positions)\n");
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 4, 0, "scroll_cur4", ECPGst_normal, "declare scroll_cur4 scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT);
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 4, 0, 0, "scroll_cur4", ECPGst_normal, "declare scroll_cur4 scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT);
 #line 426 "cursor-ra-fetch.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
@@ -889,7 +889,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 
 	printf("\ntest scroll_cur4 for move relative -5 (negative positions)\n");
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 4, 0, "scroll_cur4", ECPGst_normal, "declare scroll_cur4 scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT);
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 4, 0, 0, "scroll_cur4", ECPGst_normal, "declare scroll_cur4 scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT);
 #line 497 "cursor-ra-fetch.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
diff --git a/src/interfaces/ecpg/test/expected/sql-cursor-ra-move.c b/src/interfaces/ecpg/test/expected/sql-cursor-ra-move.c
index ce5c03b..5156d97 100644
--- a/src/interfaces/ecpg/test/expected/sql-cursor-ra-move.c
+++ b/src/interfaces/ecpg/test/expected/sql-cursor-ra-move.c
@@ -75,7 +75,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 
 	printf("test scroll_cur for move absolute -1\n");
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 8, 0, "scroll_cur", ECPGst_normal, "declare scroll_cur scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT);
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 8, 0, 0, "scroll_cur", ECPGst_normal, "declare scroll_cur scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT);
 #line 34 "cursor-ra-move.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
@@ -104,7 +104,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 
 	printf("test noscroll_cur for move absolute -1\n");
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 8, 0, "noscroll_cur", ECPGst_normal, "declare noscroll_cur no scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT);
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 8, 0, 0, "noscroll_cur", ECPGst_normal, "declare noscroll_cur no scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT);
 #line 48 "cursor-ra-move.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
@@ -133,7 +133,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 
 	printf("test unspec_cur1 for move absolute -1\n");
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 8, 0, "unspec_cur1", ECPGst_normal, "declare unspec_cur1 no scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT);
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 8, 0, 0, "unspec_cur1", ECPGst_normal, "declare unspec_cur1 no scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT);
 #line 62 "cursor-ra-move.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
@@ -162,7 +162,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 
 	printf("test unspec_cur2 for move absolute -1\n");
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 8, 0, "unspec_cur2", ECPGst_normal, "declare unspec_cur2 no scroll cursor for select t1 . id , t1 . t , t2 . id , t2 . t from t1 join t1 as t2 on ( t1 . id = 27 - t2 . id ) order by t1 . id", ECPGt_EOIT, ECPGt_EORT);
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 8, 0, 0, "unspec_cur2", ECPGst_normal, "declare unspec_cur2 no scroll cursor for select t1 . id , t1 . t , t2 . id , t2 . t from t1 join t1 as t2 on ( t1 . id = 27 - t2 . id ) order by t1 . id", ECPGt_EOIT, ECPGt_EORT);
 #line 76 "cursor-ra-move.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
@@ -193,7 +193,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 
 	printf("test scroll_cur for move relative 8\n");
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 8, 0, "scroll_cur", ECPGst_normal, "declare scroll_cur scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT);
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 8, 0, 0, "scroll_cur", ECPGst_normal, "declare scroll_cur scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT);
 #line 92 "cursor-ra-move.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
@@ -247,7 +247,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 
 	printf("test scroll_cur for move forward 8\n");
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 8, 0, "scroll_cur", ECPGst_normal, "declare scroll_cur scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT);
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 8, 0, 0, "scroll_cur", ECPGst_normal, "declare scroll_cur scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT);
 #line 126 "cursor-ra-move.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
diff --git a/src/interfaces/ecpg/test/expected/sql-cursor-ra-swdir.c b/src/interfaces/ecpg/test/expected/sql-cursor-ra-swdir.c
index bfc798f..64d9f6a 100644
--- a/src/interfaces/ecpg/test/expected/sql-cursor-ra-swdir.c
+++ b/src/interfaces/ecpg/test/expected/sql-cursor-ra-swdir.c
@@ -157,7 +157,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 #line 70 "cursor-ra-swdir.pgc"
 
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 4, 0, "mycur", ECPGst_normal, "declare mycur scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT);
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 4, 0, 0, "mycur", ECPGst_normal, "declare mycur scroll cursor for select id , t from t1 order by id", ECPGt_EOIT, ECPGt_EORT);
 #line 72 "cursor-ra-swdir.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
diff --git a/src/interfaces/ecpg/test/expected/sql-cursorsubxact.c b/src/interfaces/ecpg/test/expected/sql-cursorsubxact.c
index e331a9c..61c3554 100644
--- a/src/interfaces/ecpg/test/expected/sql-cursorsubxact.c
+++ b/src/interfaces/ecpg/test/expected/sql-cursorsubxact.c
@@ -92,7 +92,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 #line 39 "cursorsubxact.pgc"
 
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, curname, ECPGst_normal, "declare $0 no scroll cursor for select id , t from t1", 
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, 0, curname, ECPGst_normal, "declare $0 no scroll cursor for select id , t from t1", 
 	ECPGt_char,&(curname),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 41 "cursorsubxact.pgc"
@@ -129,7 +129,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 
 	curname = QUOTED_CURNAME;
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, curname, ECPGst_normal, "declare $0 no scroll cursor for select id , t from t1", 
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, 0, curname, ECPGst_normal, "declare $0 no scroll cursor for select id , t from t1", 
 	ECPGt_char,&(curname),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 64 "cursorsubxact.pgc"
@@ -196,7 +196,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 #line 98 "cursorsubxact.pgc"
 
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, curname, ECPGst_normal, "declare $0 no scroll cursor for select id , t from t1", 
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, 0, curname, ECPGst_normal, "declare $0 no scroll cursor for select id , t from t1", 
 	ECPGt_char,&(curname),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 100 "cursorsubxact.pgc"
@@ -257,7 +257,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 	else
 		printf("\"savepoint a\" succeeded\n");
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, curname, ECPGst_normal, "declare $0 no scroll cursor for select id , t from t1", 
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, 0, curname, ECPGst_normal, "declare $0 no scroll cursor for select id , t from t1", 
 	ECPGt_char,&(curname),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 132 "cursorsubxact.pgc"
@@ -432,7 +432,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 	else
 		printf("\"savepoint a\" succeeded\n");
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, curname, ECPGst_normal, "declare $0 no scroll cursor for select id , t from t1", 
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, 0, curname, ECPGst_normal, "declare $0 no scroll cursor for select id , t from t1", 
 	ECPGt_char,&(curname),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 239 "cursorsubxact.pgc"
@@ -499,7 +499,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 	 * transaction has failed above.
 	 */
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, curname, ECPGst_normal, "declare $0 no scroll cursor for select id , t from t1", 
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, 0, curname, ECPGst_normal, "declare $0 no scroll cursor for select id , t from t1", 
 	ECPGt_char,&(curname),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 272 "cursorsubxact.pgc"
@@ -530,7 +530,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 	else
 		printf("\"rollback to a\" succeeded\n");
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, curname, ECPGst_normal, "declare $0 no scroll cursor for select id , t from t1", 
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, 0, curname, ECPGst_normal, "declare $0 no scroll cursor for select id , t from t1", 
 	ECPGt_char,&(curname),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 291 "cursorsubxact.pgc"
diff --git a/src/interfaces/ecpg/test/expected/sql-desc.c b/src/interfaces/ecpg/test/expected/sql-desc.c
index 671bce7..8ee7ff7 100644
--- a/src/interfaces/ecpg/test/expected/sql-desc.c
+++ b/src/interfaces/ecpg/test/expected/sql-desc.c
@@ -245,7 +245,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 	/* declare c1 no scroll cursor for $1 */
 #line 57 "desc.pgc"
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, "c1", ECPGst_normal, "declare c1 no scroll cursor for $1", 
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, 0, "c1", ECPGst_normal, "declare c1 no scroll cursor for $1", 
 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "foo2", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_descriptor, "indesc", 0L, 0L, 0L, 
@@ -295,7 +295,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 	/* declare c2 no scroll cursor for $1 */
 #line 69 "desc.pgc"
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, "c2", ECPGst_normal, "declare c2 no scroll cursor for $1", 
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, 0, "c2", ECPGst_normal, "declare c2 no scroll cursor for $1", 
 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "foo3", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_descriptor, "indesc", 0L, 0L, 0L, 
diff --git a/src/interfaces/ecpg/test/expected/sql-dyntest.c b/src/interfaces/ecpg/test/expected/sql-dyntest.c
index 7f86f7b..0b5ad1f 100644
--- a/src/interfaces/ecpg/test/expected/sql-dyntest.c
+++ b/src/interfaces/ecpg/test/expected/sql-dyntest.c
@@ -261,7 +261,7 @@ if (sqlca.sqlcode < 0) error ( );}
 #line 58 "dyntest.pgc"
 
 
-  { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, "MYCURS", ECPGst_normal, "declare MYCURS no scroll cursor for $1", 
+  { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, 0, "MYCURS", ECPGst_normal, "declare MYCURS no scroll cursor for $1", 
 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "myquery", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 60 "dyntest.pgc"
diff --git a/src/interfaces/ecpg/test/expected/sql-execute.c b/src/interfaces/ecpg/test/expected/sql-execute.c
index f7d4282..efcf1c4 100644
--- a/src/interfaces/ecpg/test/expected/sql-execute.c
+++ b/src/interfaces/ecpg/test/expected/sql-execute.c
@@ -140,7 +140,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 #line 50 "execute.pgc"
 
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, "CUR", ECPGst_normal, "declare CUR no scroll cursor for $1", 
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, 0, "CUR", ECPGst_normal, "declare CUR no scroll cursor for $1", 
 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "f", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 52 "execute.pgc"
@@ -205,7 +205,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 #line 72 "execute.pgc"
 
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, "CUR2", ECPGst_normal, "declare CUR2 no scroll cursor for $1", 
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, 0, "CUR2", ECPGst_normal, "declare CUR2 no scroll cursor for $1", 
 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "f", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_const,"1",(long)1,(long)1,strlen("1"), 
diff --git a/src/interfaces/ecpg/test/expected/sql-fetch.c b/src/interfaces/ecpg/test/expected/sql-fetch.c
index 8ffb0ef..cdca247 100644
--- a/src/interfaces/ecpg/test/expected/sql-fetch.c
+++ b/src/interfaces/ecpg/test/expected/sql-fetch.c
@@ -99,7 +99,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 #line 26 "fetch.pgc"
 
 
-  { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 1, 1, "C", ECPGst_normal, "declare C scroll cursor for select * from My_Table", ECPGt_EOIT, ECPGt_EORT);
+  { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 1, 1, 0, "C", ECPGst_normal, "declare C scroll cursor for select * from My_Table", ECPGt_EOIT, ECPGt_EORT);
 #line 28 "fetch.pgc"
 
 if (sqlca.sqlwarn[0] == 'W') sqlprint();
@@ -176,7 +176,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 #line 44 "fetch.pgc"
 
 
-  { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 1, 1, "D", ECPGst_normal, "declare D scroll cursor for select * from My_Table where Item1 = $1", 
+  { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 1, 1, 0, "D", ECPGst_normal, "declare D scroll cursor for select * from My_Table where Item1 = $1", 
 	ECPGt_const,"1",(long)1,(long)1,strlen("1"), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 46 "fetch.pgc"
diff --git a/src/interfaces/ecpg/test/expected/sql-oldexec.c b/src/interfaces/ecpg/test/expected/sql-oldexec.c
index 7a3790a..ee98e9a 100644
--- a/src/interfaces/ecpg/test/expected/sql-oldexec.c
+++ b/src/interfaces/ecpg/test/expected/sql-oldexec.c
@@ -140,7 +140,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 #line 50 "oldexec.pgc"
 
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 1, 0, ECPGcs_no_scroll, 1, 1, "CUR", ECPGst_normal, "declare CUR no scroll cursor for $1", 
+	{ ECPGopen(__LINE__, 0, 1, NULL, 1, 0, ECPGcs_no_scroll, 1, 1, 0, "CUR", ECPGst_normal, "declare CUR no scroll cursor for $1", 
 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "f", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 52 "oldexec.pgc"
@@ -199,7 +199,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 #line 71 "oldexec.pgc"
 
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 1, 0, ECPGcs_no_scroll, 1, 1, "CUR3", ECPGst_normal, "declare CUR3 no scroll cursor for $1", 
+	{ ECPGopen(__LINE__, 0, 1, NULL, 1, 0, ECPGcs_no_scroll, 1, 1, 0, "CUR3", ECPGst_normal, "declare CUR3 no scroll cursor for $1", 
 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "f", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_const,"1",(long)1,(long)1,strlen("1"), 
diff --git a/src/interfaces/ecpg/test/expected/sql-quote.c b/src/interfaces/ecpg/test/expected/sql-quote.c
index 0797136..25ab695 100644
--- a/src/interfaces/ecpg/test/expected/sql-quote.c
+++ b/src/interfaces/ecpg/test/expected/sql-quote.c
@@ -162,7 +162,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 #line 43 "quote.pgc"
 
 
-  { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, "C", ECPGst_normal, "declare C no scroll cursor for select * from \"My_Table\"", ECPGt_EOIT, ECPGt_EORT);
+  { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, 0, "C", ECPGst_normal, "declare C no scroll cursor for select * from \"My_Table\"", ECPGt_EOIT, ECPGt_EORT);
 #line 45 "quote.pgc"
 
 if (sqlca.sqlwarn[0] == 'W') sqlprint();
diff --git a/src/interfaces/ecpg/test/expected/sql-sqlda.c b/src/interfaces/ecpg/test/expected/sql-sqlda.c
index f53e401..605eaa0 100644
--- a/src/interfaces/ecpg/test/expected/sql-sqlda.c
+++ b/src/interfaces/ecpg/test/expected/sql-sqlda.c
@@ -251,7 +251,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 
 	strcpy(msg, "open");
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, "mycur1", ECPGst_normal, "declare mycur1 no scroll cursor for $1", 
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, 0, "mycur1", ECPGst_normal, "declare mycur1 no scroll cursor for $1", 
 	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 103 "sqlda.pgc"
@@ -324,7 +324,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 
 	strcpy(msg, "open");
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, "mycur2", ECPGst_normal, "declare mycur2 no scroll cursor for $1", 
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, 1, 0, "mycur2", ECPGst_normal, "declare mycur2 no scroll cursor for $1", 
 	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 138 "sqlda.pgc"
