diff -dcrpN postgresql.2/doc/src/sgml/ecpg.sgml postgresql.3/doc/src/sgml/ecpg.sgml
*** postgresql.2/doc/src/sgml/ecpg.sgml	2012-04-10 17:07:33.123111871 +0200
--- postgresql.3/doc/src/sgml/ecpg.sgml	2012-04-10 19:44:45.245974863 +0200
*************** EXEC SQL COMMIT;
*** 458,469 ****
     As of PostgreSQL 9.2, ECPG does cursor accounting in its runtime library and
     this makes possible to do readahead to improve performance of programs
     that use single-row FETCH statements. The default is 1 row window size,
!    i.e. no readahead. Option <literal>-R number</literal> on the ECPG command line
!    modifies the default readahead window size for all cursors. Explicit
!    <literal>READAHEAD number</literal> sets the readahead window size for
!    the specified cursor. The readahead window size may be modified after
!    the application is compiled by setting the <literal>ECPGFETCHSZ</literal>
!    environment variable to a different value.
    </para>
  
    <para>
--- 458,470 ----
     As of PostgreSQL 9.2, ECPG does cursor accounting in its runtime library and
     this makes possible to do readahead to improve performance of programs
     that use single-row FETCH statements. The default is 1 row window size,
!    i.e. no readahead. Option <option>-r readahead=number</option> on the
!    ECPG command line modifies the default readahead window size for all cursors.
!    Explicit <literal>READAHEAD number</literal> sets the readahead window size for
!    the specified cursor. If this clause is not explicitly specified for a cursor
!    (option <option>-r readahead=number</option> is considered implicit), then
!    setting the <literal>ECPGFETCHSZ</literal> environment variable overrides
!    the readahead window size for all such cursors.
    </para>
  
    <para>
*************** EXEC SQL COMMIT;
*** 476,482 ****
    <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>--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 slows
     down opening the cursor.
--- 477,483 ----
    <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 slows
     down opening the cursor.
*************** EXEC SQL COMMIT;
*** 491,496 ****
--- 492,509 ----
       the <command>OPEN</command> command is executed.
      </para>
     </note>
+    <note>
+     <para>
+      If an ECPG application written for earlier versions of PostgreSQL uses its
+      own readahead (e.g. <command>FETCH N FROM cursorname</command>) then it's
+      recommended to recompile using option <option>-r readahead=number</option>
+      where the specified number equals to custom readahead size or an integer
+      multiple of it. Alternatively, the <command>DECLARE</command> statement can
+      be modified with the <literal>READAHEAD number</literal> clause. Without this,
+      the application performance will be worse because the readahead code in the
+      ECPG runtime uses single row <command>FETCH</command> statements.
+     </para>
+    </note>
    </sect2>
  
    <sect2 id="ecpg-transactions">
*************** struct
*** 4904,4910 ****
      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>--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">.
     </para>
--- 4917,4923 ----
      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">.
     </para>
diff -dcrpN postgresql.2/doc/src/sgml/ref/ecpg-ref.sgml postgresql.3/doc/src/sgml/ref/ecpg-ref.sgml
*** postgresql.2/doc/src/sgml/ref/ecpg-ref.sgml	2012-04-10 17:07:05.046967213 +0200
--- postgresql.3/doc/src/sgml/ref/ecpg-ref.sgml	2012-04-10 19:25:44.277543667 +0200
*************** PostgreSQL documentation
*** 166,195 ****
           </para>
           </listitem>
          </varlistentry>
         </variablelist></para>
       </listitem>
      </varlistentry>
  
-     <varlistentry>
-      <term><option>-R <replaceable>number</replaceable></option></term>
-      <listitem>
-       <para>
-        Turn on cursor readahead by default using <replaceable>number</replaceable>
-        as readahead window size.
-       </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>
- 
      <varlistentry>
       <term><option>-t</option></term>
       <listitem>
--- 166,193 ----
           </para>
           </listitem>
          </varlistentry>
+         <varlistentry>
+          <term><option>readahead=<replaceable>number</replaceable></option></term>
+          <listitem>
+           <para>
+            Turn on cursor readahead by default using <replaceable>number</replaceable>
+            as readahead window size.
+           </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>
  
      <varlistentry>
       <term><option>-t</option></term>
       <listitem>
diff -dcrpN postgresql.2/src/interfaces/ecpg/ecpglib/cursor.c postgresql.3/src/interfaces/ecpg/ecpglib/cursor.c
*** postgresql.2/src/interfaces/ecpg/ecpglib/cursor.c	2012-04-10 17:07:05.049967228 +0200
--- postgresql.3/src/interfaces/ecpg/ecpglib/cursor.c	2012-04-10 17:42:38.674925949 +0200
*************** add_cursor(int lineno, struct connection
*** 111,124 ****
  	desc->subxact_level = subxact_level;
  	desc->with_hold = with_hold;
  	desc->res = NULL;
! 	/*
! 	 * The readahead windows is allowed to be overridden
! 	 * (possibly even disabled) by default_fetch_size if it's set.
! 	 */
! 	desc->ra_size = (default_fetch_size > 0 ?
! 						default_fetch_size :
! 						ra_size);
! 
  	desc->backward = false;
  	desc->cache_start_pos = 0;
  	desc->atstart = true;
--- 111,117 ----
  	desc->subxact_level = subxact_level;
  	desc->with_hold = with_hold;
  	desc->res = NULL;
! 	desc->ra_size = ra_size;
  	desc->backward = false;
  	desc->cache_start_pos = 0;
  	desc->atstart = true;
*************** ecpg_commit_cursors(int lineno, struct c
*** 248,255 ****
  bool
  ECPGopen(const int lineno, const int compat, const int force_indicator,
  		const char *connection_name, const bool questionmarks,
! 		const long ra_size, const bool return_rssz,
! 		const bool scrollable, const bool with_hold,
  		const char *curname, const int st, const char *query, ...)
  {
  	struct connection *con = ecpg_get_connection(connection_name);
--- 241,248 ----
  bool
  ECPGopen(const int lineno, const int compat, const int force_indicator,
  		const char *connection_name, const bool questionmarks,
! 		const long ra_size, const bool ra_override,
! 		const bool return_rssz, const bool scrollable, const bool with_hold,
  		const char *curname, const int st, const char *query, ...)
  {
  	struct connection *con = ecpg_get_connection(connection_name);
*************** ECPGopen(const int lineno, const int com
*** 369,375 ****
  		subxact_level =
  			(PQtransactionStatus(con->connection) != PQTRANS_IDLE ?
  				1 : 0);
! 	add_cursor(lineno, con, curname, subxact_level, with_hold, ra_size);
  
  	return true;
  }
--- 362,370 ----
  		subxact_level =
  			(PQtransactionStatus(con->connection) != PQTRANS_IDLE ?
  				1 : 0);
! 	add_cursor(lineno, con, curname, subxact_level, with_hold,
! 					(ra_override && (default_fetch_size > 0) ?
! 						default_fetch_size : ra_size));
  
  	return true;
  }
diff -dcrpN postgresql.2/src/interfaces/ecpg/include/ecpglib.h postgresql.3/src/interfaces/ecpg/include/ecpglib.h
*** postgresql.2/src/interfaces/ecpg/include/ecpglib.h	2012-04-10 17:07:05.059967280 +0200
--- postgresql.3/src/interfaces/ecpg/include/ecpglib.h	2012-04-10 17:15:42.256634455 +0200
*************** char	   *ECPGerrmsg(void);
*** 65,71 ****
  
  /* Cursor functions */
  bool		ECPGopen(const int, const int, const int, const char *, const bool,
! 				const long, const bool, const bool, const bool,
  				const char *, const int, const char *, ...);
  bool		ECPGfetch(const int, const int, const int, const char *, const bool,
  				const char *, enum ECPG_cursor_direction,
--- 65,71 ----
  
  /* Cursor functions */
  bool		ECPGopen(const int, const int, const int, const char *, const bool,
! 				const long, const bool, const bool, const bool, const bool,
  				const char *, const int, const char *, ...);
  bool		ECPGfetch(const int, const int, const int, const char *, const bool,
  				const char *, enum ECPG_cursor_direction,
diff -dcrpN postgresql.2/src/interfaces/ecpg/preproc/ecpg.addons postgresql.3/src/interfaces/ecpg/preproc/ecpg.addons
*** postgresql.2/src/interfaces/ecpg/preproc/ecpg.addons	2012-04-10 17:07:33.125111881 +0200
--- postgresql.3/src/interfaces/ecpg/preproc/ecpg.addons	2012-04-10 17:20:30.139121129 +0200
*************** ECPG: DeclareCursorStmtDECLAREcursor_nam
*** 515,521 ****
  		this->function = (current_function ? mm_strdup(current_function) : NULL);
  		this->connection = connection;
  		this->opened = false;
! 		this->fetch_readahead = atoi($4);
  		this->scrollable = current_cursor_scroll;
  		this->with_hold = (strncmp($6, "with ", 5) == 0);
  		this->command =  cat_str(7, mm_strdup("declare"), cursor_marker, $3, mm_strdup("cursor"), $6, mm_strdup("for"), $8);
--- 515,530 ----
  		this->function = (current_function ? mm_strdup(current_function) : NULL);
  		this->connection = connection;
  		this->opened = false;
! 		if (strcmp($4, "default") == 0)
! 		{
! 			this->fetch_readahead = fetch_readahead;
! 			this->ra_override = true;
! 		}
! 		else
! 		{
! 			this->fetch_readahead = atoi($4);
! 			this->ra_override = false;
! 		}
  		this->scrollable = current_cursor_scroll;
  		this->with_hold = (strncmp($6, "with ", 5) == 0);
  		this->command =  cat_str(7, mm_strdup("declare"), cursor_marker, $3, mm_strdup("cursor"), $6, mm_strdup("for"), $8);
diff -dcrpN postgresql.2/src/interfaces/ecpg/preproc/ecpg.c postgresql.3/src/interfaces/ecpg/preproc/ecpg.c
*** postgresql.2/src/interfaces/ecpg/preproc/ecpg.c	2012-04-10 17:07:33.126111886 +0200
--- postgresql.3/src/interfaces/ecpg/preproc/ecpg.c	2012-04-10 19:10:56.463062963 +0200
*************** bool		autocommit = false,
*** 21,27 ****
  			regression_mode = false,
  			auto_prepare = false,
  			cursor_rssz = false;
! long		fetch_readahead = 1; /* Disabled by default */
  
  char	   *output_filename;
  
--- 21,27 ----
  			regression_mode = false,
  			auto_prepare = false,
  			cursor_rssz = false;
! long		fetch_readahead = 1; /* No readahead by default */
  
  char	   *output_filename;
  
*************** help(const char *progname)
*** 54,65 ****
  	printf(_("  -I DIRECTORY   search DIRECTORY for include files\n"));
  	printf(_("  -o OUTFILE     write result to OUTFILE\n"));
  	printf(_("  -r OPTION      specify run-time behavior; OPTION can be:\n"
! 	 "                 \"no_indicator\", \"prepare\", \"questionmarks\"\n"));
! 	printf(_("  -R NUMBER      cursor readahead window size for FETCH statements\n"
! 	 "                 default 0 (disabled)\n"));
! 	printf(_("  --detect-cursor-resultset-size\n"
! 	 "                 opening a cursor detects and returns the number of rows\n"
! 	 "                 in sqlca.sqlerrd[2]. Read the documentation before enabling it.\n"));
  	printf(_("  --regression   run in regression testing mode\n"));
  	printf(_("  -t             turn on autocommit of transactions\n"));
  	printf(_("  --help         show this help, then exit\n"));
--- 54,61 ----
  	printf(_("  -I DIRECTORY   search DIRECTORY for include files\n"));
  	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\", \"detect-cursor-resultset-size\"\n"));
  	printf(_("  --regression   run in regression testing mode\n"));
  	printf(_("  -t             turn on autocommit of transactions\n"));
  	printf(_("  --help         show this help, then exit\n"));
*************** add_preprocessor_define(char *define)
*** 122,128 ****
  #define ECPG_GETOPT_LONG_HELP			1
  #define ECPG_GETOPT_LONG_VERSION		2
  #define ECPG_GETOPT_LONG_REGRESSION		3
- #define	ECPG_GETOPT_LONG_CURSOR_RESULTSET_SIZE	4
  int
  main(int argc, char *const argv[])
  {
--- 118,123 ----
*************** main(int argc, char *const argv[])
*** 130,136 ****
  		{"help", no_argument, NULL, ECPG_GETOPT_LONG_HELP},
  		{"version", no_argument, NULL, ECPG_GETOPT_LONG_VERSION},
  		{"regression", no_argument, NULL, ECPG_GETOPT_LONG_REGRESSION},
- 		{"detect-cursor-resultset-size", no_argument, NULL, ECPG_GETOPT_LONG_CURSOR_RESULTSET_SIZE},
  		{NULL, 0, NULL, 0}
  	};
  
--- 125,130 ----
*************** main(int argc, char *const argv[])
*** 152,158 ****
  	find_my_exec(argv[0], my_exec_path);
  
  	output_filename = NULL;
! 	while ((c = getopt_long(argc, argv, "vcio:I:tD:dC:r:R:h?", ecpg_options, NULL)) != -1)
  	{
  		switch (c)
  		{
--- 146,152 ----
  	find_my_exec(argv[0], my_exec_path);
  
  	output_filename = NULL;
! 	while ((c = getopt_long(argc, argv, "vcio:I:tD:dC:r:h?", ecpg_options, NULL)) != -1)
  	{
  		switch (c)
  		{
*************** main(int argc, char *const argv[])
*** 240,267 ****
  					auto_prepare = true;
  				else if (strcmp(optarg, "questionmarks") == 0)
  					questionmarks = true;
! 				else
  				{
! 					fprintf(stderr, _("Try \"%s --help\" for more information.\n"), argv[0]);
! 					return ILLEGAL_OPTION;
  				}
! 				break;
! 			case 'R':
! 				fetch_readahead = strtoul(optarg, &endptr, 10);
! 				if (*endptr)
  				{
- 					fprintf(stderr, _("%s is not an integer number\n"), optarg);
  					fprintf(stderr, _("Try \"%s --help\" for more information.\n"), argv[0]);
  					return ILLEGAL_OPTION;
  				}
- 				if (fetch_readahead < 1)
- 				{
- 					fprintf(stderr, _("-R argument cannot be less than 1\n"));
- 					return ILLEGAL_OPTION;
- 				}
- 				break;
- 			case ECPG_GETOPT_LONG_CURSOR_RESULTSET_SIZE:
- 				cursor_rssz = true;
  				break;
  			case 'D':
  				add_preprocessor_define(optarg);
--- 234,261 ----
  					auto_prepare = true;
  				else if (strcmp(optarg, "questionmarks") == 0)
  					questionmarks = true;
! 				else if (strncmp(optarg, "readahead=", strlen("readahead=")) == 0)
  				{
! 					fetch_readahead = strtoul(optarg + strlen("readahead="), &endptr, 10);
! 					if (*endptr)
! 					{
! 						fprintf(stderr, _("\"%s\" is not an integer number\n"), optarg + strlen("readahead="));
! 						fprintf(stderr, _("Try \"%s --help\" for more information.\n"), argv[0]);
! 						return ILLEGAL_OPTION;
! 					}
! 					if (fetch_readahead < 1)
! 					{
! 						fprintf(stderr, _("argument to readahead= cannot be less than 1\n"));
! 						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]);
  					return ILLEGAL_OPTION;
  				}
  				break;
  			case 'D':
  				add_preprocessor_define(optarg);
diff -dcrpN postgresql.2/src/interfaces/ecpg/preproc/ecpg.trailer postgresql.3/src/interfaces/ecpg/preproc/ecpg.trailer
*** postgresql.2/src/interfaces/ecpg/preproc/ecpg.trailer	2012-04-10 17:07:33.128111896 +0200
--- postgresql.3/src/interfaces/ecpg/preproc/ecpg.trailer	2012-04-10 17:18:13.235414011 +0200
*************** ECPGCursorStmt:  DECLARE cursor_name cur
*** 316,322 ****
  			this->function = (current_function ? mm_strdup(current_function) : NULL);
  			this->connection = connection;
  			this->opened = false;
! 			this->fetch_readahead = atoi($4);
  			this->scrollable = current_cursor_scroll;
  			this->with_hold = (strncmp($6, "with ", 5) == 0);
  			this->command =  cat_str(6, mm_strdup("declare"), cursor_marker, $3, mm_strdup("cursor"), $6, mm_strdup("for $1"));
--- 316,331 ----
  			this->function = (current_function ? mm_strdup(current_function) : NULL);
  			this->connection = connection;
  			this->opened = false;
! 			if (strcmp($4, "default") == 0)
! 			{
! 				this->fetch_readahead = fetch_readahead;
! 				this->ra_override = true;
! 			}
! 			else
! 			{
! 				this->fetch_readahead = atoi($4);
! 				this->ra_override = false;
! 			}
  			this->scrollable = current_cursor_scroll;
  			this->with_hold = (strncmp($6, "with ", 5) == 0);
  			this->command =  cat_str(6, mm_strdup("declare"), cursor_marker, $3, mm_strdup("cursor"), $6, mm_strdup("for $1"));
*************** ECPGCursorStmt:  DECLARE cursor_name cur
*** 353,364 ****
  		;
  
  opt_readahead:	SQL_READAHEAD Iconst				{ $$ = $2; }
! 		| /* EMPTY */
! 		{
! 			char	val[16];
! 			sprintf(val, "%ld", fetch_readahead);
! 			$$ = mm_strdup(val);
! 		}
  		;
  
  ECPGExecuteImmediateStmt: EXECUTE IMMEDIATE execstring
--- 362,368 ----
  		;
  
  opt_readahead:	SQL_READAHEAD Iconst				{ $$ = $2; }
! 		| /* EMPTY */					{ $$ = mm_strdup("default"); }
  		;
  
  ECPGExecuteImmediateStmt: EXECUTE IMMEDIATE execstring
diff -dcrpN postgresql.2/src/interfaces/ecpg/preproc/output.c postgresql.3/src/interfaces/ecpg/preproc/output.c
*** postgresql.2/src/interfaces/ecpg/preproc/output.c	2012-04-10 17:07:05.068967326 +0200
--- postgresql.3/src/interfaces/ecpg/preproc/output.c	2012-04-10 17:20:08.963011719 +0200
*************** output_open_statement(char *stmt, int fe
*** 220,231 ****
  {
  	struct cursor *ptr = get_cursor(current_cursor);
  
! 	fprintf(yyout, "{ ECPGopen(__LINE__, %d, %d, %s, %d, %ld, %d, %d, %d, ",
  			compat,
  			force_indicator,
  			connection ? connection : "NULL",
  			questionmarks,
  			ptr->fetch_readahead,
  			cursor_rssz,
  			ptr->scrollable,
  			ptr->with_hold);
--- 220,232 ----
  {
  	struct cursor *ptr = get_cursor(current_cursor);
  
! 	fprintf(yyout, "{ ECPGopen(__LINE__, %d, %d, %s, %d, %ld, %d, %d, %d, %d, ",
  			compat,
  			force_indicator,
  			connection ? connection : "NULL",
  			questionmarks,
  			ptr->fetch_readahead,
+ 			ptr->ra_override,
  			cursor_rssz,
  			ptr->scrollable,
  			ptr->with_hold);
diff -dcrpN postgresql.2/src/interfaces/ecpg/preproc/type.h postgresql.3/src/interfaces/ecpg/preproc/type.h
*** postgresql.2/src/interfaces/ecpg/preproc/type.h	2012-04-10 17:07:05.070967336 +0200
--- postgresql.3/src/interfaces/ecpg/preproc/type.h	2012-04-10 17:19:35.386838302 +0200
*************** struct cursor
*** 132,137 ****
--- 132,138 ----
  	bool		opened;
  	bool		scrollable;
  	long		fetch_readahead;
+ 	bool		ra_override;
  	bool		with_hold;
  	struct arguments *argsinsert;
  	struct arguments *argsinsert_oos;
diff -dcrpN postgresql.2/src/interfaces/ecpg/test/ecpg_schedule postgresql.3/src/interfaces/ecpg/test/ecpg_schedule
*** postgresql.2/src/interfaces/ecpg/test/ecpg_schedule	2012-04-10 17:07:05.070967336 +0200
--- postgresql.3/src/interfaces/ecpg/test/ecpg_schedule	2012-04-10 18:29:27.441935525 +0200
*************** test: preproc/autoprep
*** 21,26 ****
--- 21,27 ----
  test: preproc/comment
  test: preproc/cursor
  test: preproc/cursor-readahead
+ test: preproc/cursor-readahead2
  test: preproc/define
  test: preproc/init
  test: preproc/strings
diff -dcrpN postgresql.2/src/interfaces/ecpg/test/ecpg_schedule_tcp postgresql.3/src/interfaces/ecpg/test/ecpg_schedule_tcp
*** postgresql.2/src/interfaces/ecpg/test/ecpg_schedule_tcp	2012-04-10 17:07:05.071967341 +0200
--- postgresql.3/src/interfaces/ecpg/test/ecpg_schedule_tcp	2012-04-10 18:29:26.073928618 +0200
*************** test: preproc/autoprep
*** 21,26 ****
--- 21,27 ----
  test: preproc/comment
  test: preproc/cursor
  test: preproc/cursor-readahead
+ test: preproc/cursor-readahead2
  test: preproc/define
  test: preproc/init
  test: preproc/strings
diff -dcrpN postgresql.2/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c postgresql.3/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c
*** postgresql.2/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c	2012-04-10 17:07:33.129111901 +0200
--- postgresql.3/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c	2012-04-10 18:45:32.662609254 +0200
*************** if (sqlca.sqlcode < 0) exit (1);}
*** 241,247 ****
  
  
  	strcpy(msg, "open");
! 	{ ECPGopen(__LINE__, 1, 1, NULL, 0, 1, 0, 0, 0, "mycur1", ECPGst_normal, "declare mycur1 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"
--- 241,247 ----
  
  
  	strcpy(msg, "open");
! 	{ ECPGopen(__LINE__, 1, 1, NULL, 0, 1, 1, 0, 0, 0, "mycur1", ECPGst_normal, "declare mycur1 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"
*************** if (sqlca.sqlcode < 0) exit (1);}
*** 316,322 ****
  
  
  	strcpy(msg, "open");
! 	{ ECPGopen(__LINE__, 1, 1, NULL, 0, 1, 0, 0, 0, "mycur2", ECPGst_normal, "declare mycur2 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"
--- 316,322 ----
  
  
  	strcpy(msg, "open");
! 	{ ECPGopen(__LINE__, 1, 1, NULL, 0, 1, 1, 0, 0, 0, "mycur2", ECPGst_normal, "declare mycur2 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 -dcrpN postgresql.2/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c postgresql.3/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c
*** postgresql.2/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c	2012-04-10 17:07:33.131111912 +0200
--- postgresql.3/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c	2012-04-10 18:45:33.110611419 +0200
*************** if (sqlca.sqlcode < 0) dosqlprint ( );}
*** 244,250 ****
  
  static void openit(void)
  {
! 	{ ECPGopen(__LINE__, 1, 1, NULL, 0, 1, 0, 0, 0, "c", ECPGst_normal, "declare c 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"
--- 244,250 ----
  
  static void openit(void)
  {
! 	{ ECPGopen(__LINE__, 1, 1, NULL, 0, 1, 1, 0, 0, 0, "c", ECPGst_normal, "declare c 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 -dcrpN postgresql.2/src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.c postgresql.3/src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.c
*** postgresql.2/src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.c	2012-04-10 17:07:33.133111922 +0200
--- postgresql.3/src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.c	2012-04-10 18:45:33.454613093 +0200
*************** if (sqlca.sqlcode < 0) sqlprint ( );}
*** 82,88 ****
  	/* declare cur cursor for select id , d , d from nantest1 */
  #line 33 "nan_test.pgc"
  
! 	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 0, 0, 0, "cur", ECPGst_normal, "declare cur cursor for select id , d , d from nantest1", ECPGt_EOIT, ECPGt_EORT);
  #line 34 "nan_test.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint ( );}
--- 82,88 ----
  	/* declare cur cursor for select id , d , d from nantest1 */
  #line 33 "nan_test.pgc"
  
! 	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 1, 0, 0, 0, "cur", ECPGst_normal, "declare cur cursor for select id , d , d from nantest1", ECPGt_EOIT, ECPGt_EORT);
  #line 34 "nan_test.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint ( );}
*************** if (sqlca.sqlcode < 0) sqlprint ( );}
*** 137,143 ****
  #line 48 "nan_test.pgc"
  
  
! 	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 0, 0, 0, "cur", ECPGst_normal, "declare cur cursor for select id , d , d from nantest1", ECPGt_EOIT, ECPGt_EORT);
  #line 50 "nan_test.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint ( );}
--- 137,143 ----
  #line 48 "nan_test.pgc"
  
  
! 	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 1, 0, 0, 0, "cur", ECPGst_normal, "declare cur cursor for select id , d , d from nantest1", ECPGt_EOIT, ECPGt_EORT);
  #line 50 "nan_test.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint ( );}
*************** if (sqlca.sqlcode < 0) sqlprint ( );}
*** 221,227 ****
  	/* declare cur1 cursor for select id , d , d from nantest2 */
  #line 75 "nan_test.pgc"
  
! 	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 0, 0, 0, "cur1", ECPGst_normal, "declare cur1 cursor for select id , d , d from nantest2", ECPGt_EOIT, ECPGt_EORT);
  #line 76 "nan_test.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint ( );}
--- 221,227 ----
  	/* declare cur1 cursor for select id , d , d from nantest2 */
  #line 75 "nan_test.pgc"
  
! 	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 1, 0, 0, 0, "cur1", ECPGst_normal, "declare cur1 cursor for select id , d , d from nantest2", ECPGt_EOIT, ECPGt_EORT);
  #line 76 "nan_test.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint ( );}
diff -dcrpN postgresql.2/src/interfaces/ecpg/test/expected/preproc-autoprep.c postgresql.3/src/interfaces/ecpg/test/expected/preproc-autoprep.c
*** postgresql.2/src/interfaces/ecpg/test/expected/preproc-autoprep.c	2012-04-10 17:07:33.134111927 +0200
--- postgresql.3/src/interfaces/ecpg/test/expected/preproc-autoprep.c	2012-04-10 18:45:33.846615002 +0200
*************** if (sqlca.sqlcode < 0) sqlprint();}
*** 133,139 ****
  #line 35 "autoprep.pgc"
  
  
!   { ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 0, 0, 0, "C", ECPGst_normal, "declare C cursor for select Item1 from T", ECPGt_EOIT, ECPGt_EORT);
  #line 37 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
--- 133,139 ----
  #line 35 "autoprep.pgc"
  
  
!   { ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 1, 0, 0, 0, "C", ECPGst_normal, "declare C cursor for select Item1 from T", ECPGt_EOIT, ECPGt_EORT);
  #line 37 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
*************** if (sqlca.sqlcode < 0) sqlprint();}
*** 180,186 ****
  #line 46 "autoprep.pgc"
  
  
!   { ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 0, 0, 0, "cur1", ECPGst_normal, "declare cur1 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"
--- 180,186 ----
  #line 46 "autoprep.pgc"
  
  
!   { ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 1, 0, 0, 0, "cur1", ECPGst_normal, "declare cur1 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 -dcrpN postgresql.2/src/interfaces/ecpg/test/expected/preproc-cursor.c postgresql.3/src/interfaces/ecpg/test/expected/preproc-cursor.c
*** postgresql.2/src/interfaces/ecpg/test/expected/preproc-cursor.c	2012-04-10 17:07:33.135111932 +0200
--- postgresql.3/src/interfaces/ecpg/test/expected/preproc-cursor.c	2012-04-10 18:45:34.246616925 +0200
*************** if (sqlca.sqlcode < 0) exit (1);}
*** 187,193 ****
  
  
  	strcpy(msg, "open");
! 	{ ECPGopen(__LINE__, 0, 1, "test1", 0, 1, 0, 0, 0, curname1, 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 67 "cursor.pgc"
--- 187,193 ----
  
  
  	strcpy(msg, "open");
! 	{ ECPGopen(__LINE__, 0, 1, "test1", 0, 1, 1, 0, 0, 0, curname1, 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 67 "cursor.pgc"
*************** if (sqlca.sqlcode < 0) exit (1);}
*** 323,329 ****
  
  
  	strcpy(msg, "open");
! 	{ ECPGopen(__LINE__, 0, 1, "test1", 0, 1, 0, 0, 0, curname2, 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), 
--- 323,329 ----
  
  
  	strcpy(msg, "open");
! 	{ ECPGopen(__LINE__, 0, 1, "test1", 0, 1, 1, 0, 0, 0, curname2, 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), 
*************** if (sqlca.sqlcode < 0) exit (1);}
*** 483,489 ****
  
  
  	strcpy(msg, "open");
! 	{ ECPGopen(__LINE__, 0, 1, "test1", 0, 1, 0, 0, 0, curname3, 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("test1", "st_id1", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
--- 483,489 ----
  
  
  	strcpy(msg, "open");
! 	{ ECPGopen(__LINE__, 0, 1, "test1", 0, 1, 1, 0, 0, 0, curname3, 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("test1", "st_id1", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
*************** if (sqlca.sqlcode < 0) exit (1);}
*** 493,499 ****
  if (sqlca.sqlcode < 0) exit (1);}
  #line 153 "cursor.pgc"
  
! 	{ ECPGopen(__LINE__, 0, 1, "test2", 0, 1, 0, 0, 0, curname5, ECPGst_normal, "declare $0 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), 
--- 493,499 ----
  if (sqlca.sqlcode < 0) exit (1);}
  #line 153 "cursor.pgc"
  
! 	{ ECPGopen(__LINE__, 0, 1, "test2", 0, 1, 1, 0, 0, 0, curname5, ECPGst_normal, "declare $0 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), 
*************** if (sqlca.sqlcode < 0) exit (1);}
*** 663,669 ****
  
  
  	strcpy(msg, "open");
! 	{ ECPGopen(__LINE__, 0, 1, "test1", 0, 1, 0, 0, 0, curname4.arr, ECPGst_normal, "declare $0 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), 
--- 663,669 ----
  
  
  	strcpy(msg, "open");
! 	{ ECPGopen(__LINE__, 0, 1, "test1", 0, 1, 1, 0, 0, 0, curname4.arr, ECPGst_normal, "declare $0 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 -dcrpN postgresql.2/src/interfaces/ecpg/test/expected/preproc-cursor-readahead2.c postgresql.3/src/interfaces/ecpg/test/expected/preproc-cursor-readahead2.c
*** postgresql.2/src/interfaces/ecpg/test/expected/preproc-cursor-readahead2.c	1970-01-01 01:00:00.000000000 +0100
--- postgresql.3/src/interfaces/ecpg/test/expected/preproc-cursor-readahead2.c	2012-04-10 18:30:12.878164362 +0200
***************
*** 0 ****
--- 1,201 ----
+ /* 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-readahead2.pgc"
+ #include <stdio.h>
+ #include <stdlib.h>
+ 
+ /* test cursor readahead with ECPGFETCHSZ */
+ 
+ #line 1 "regression.h"
+ 
+ 
+ 
+ 
+ 
+ 
+ #line 5 "cursor-readahead2.pgc"
+ 
+ 
+ 
+ #line 1 "sqlda.h"
+ #ifndef ECPG_SQLDA_H
+ #define ECPG_SQLDA_H
+ 
+ #ifdef _ECPG_INFORMIX_H
+ 
+ #include "sqlda-compat.h"
+ typedef struct sqlvar_compat	sqlvar_t;
+ typedef struct sqlda_compat	sqlda_t;
+ 
+ #else
+ 
+ #include "sqlda-native.h"
+ typedef struct sqlvar_struct	sqlvar_t;
+ typedef struct sqlda_struct	sqlda_t;
+ 
+ #endif
+ 
+ #endif /* ECPG_SQLDA_H */
+ 
+ #line 7 "cursor-readahead2.pgc"
+ 
+ 
+ /* exec sql whenever sqlerror  sqlprint ; */
+ #line 9 "cursor-readahead2.pgc"
+ 
+ /* exec sql whenever sql_warning  sqlprint ; */
+ #line 10 "cursor-readahead2.pgc"
+ 
+ 
+ int main(void)
+ {
+ 	/* exec sql begin declare section */
+ 		
+ 		
+ 	
+ #line 15 "cursor-readahead2.pgc"
+  int id ;
+  
+ #line 16 "cursor-readahead2.pgc"
+  char t [ 64 ] ;
+ /* exec sql end declare section */
+ #line 17 "cursor-readahead2.pgc"
+ 
+ 
+ 	/*
+ 	 * Override the "non-readahead" cursors
+ 	 * via the environment variable.
+ 	 */
+ 	setenv("ECPGFETCHSZ", "8", 1);
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	{ ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); 
+ #line 27 "cursor-readahead2.pgc"
+ 
+ if (sqlca.sqlwarn[0] == 'W') sqlprint();
+ #line 27 "cursor-readahead2.pgc"
+ 
+ if (sqlca.sqlcode < 0) sqlprint();}
+ #line 27 "cursor-readahead2.pgc"
+ 
+ 
+ 	{ ECPGtrans(__LINE__, NULL, "begin", 0, 1, 0, NULL);
+ #line 29 "cursor-readahead2.pgc"
+ 
+ if (sqlca.sqlwarn[0] == 'W') sqlprint();
+ #line 29 "cursor-readahead2.pgc"
+ 
+ if (sqlca.sqlcode < 0) sqlprint();}
+ #line 29 "cursor-readahead2.pgc"
+ 
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table ra_test2 ( id integer primary key , t text )", ECPGt_EOIT, ECPGt_EORT);
+ #line 31 "cursor-readahead2.pgc"
+ 
+ if (sqlca.sqlwarn[0] == 'W') sqlprint();
+ #line 31 "cursor-readahead2.pgc"
+ 
+ if (sqlca.sqlcode < 0) sqlprint();}
+ #line 31 "cursor-readahead2.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into ra_test2 select i . i , 'a' from generate_series ( 1 , 10 ) as i", ECPGt_EOIT, ECPGt_EORT);
+ #line 32 "cursor-readahead2.pgc"
+ 
+ if (sqlca.sqlwarn[0] == 'W') sqlprint();
+ #line 32 "cursor-readahead2.pgc"
+ 
+ if (sqlca.sqlcode < 0) sqlprint();}
+ #line 32 "cursor-readahead2.pgc"
+ 
+ 
+ 	/* declare curname scroll cursor for select * from ra_test2 order by id */
+ #line 34 "cursor-readahead2.pgc"
+ 
+ 
+ 	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 1, 0, 1, 0, "curname", ECPGst_normal, "declare curname scroll cursor for select * from ra_test2 order by id", ECPGt_EOIT, ECPGt_EORT);
+ #line 36 "cursor-readahead2.pgc"
+ 
+ if (sqlca.sqlwarn[0] == 'W') sqlprint();
+ #line 36 "cursor-readahead2.pgc"
+ 
+ if (sqlca.sqlcode < 0) sqlprint();}
+ #line 36 "cursor-readahead2.pgc"
+ 
+ 
+ 	/* exec sql whenever not found  break ; */
+ #line 38 "cursor-readahead2.pgc"
+ 
+ 
+ 	id = 0;
+ 	while (1)
+ 	{
+ 		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, "curname", ECPGc_forward, "1", ECPGst_normal, "fetch curname", 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 43 "cursor-readahead2.pgc"
+ 
+ if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+ #line 43 "cursor-readahead2.pgc"
+ 
+ if (sqlca.sqlwarn[0] == 'W') sqlprint();
+ #line 43 "cursor-readahead2.pgc"
+ 
+ if (sqlca.sqlcode < 0) sqlprint();}
+ #line 43 "cursor-readahead2.pgc"
+ 
+ 
+ 		printf("id: %d t: '%s'\n", id, t);
+ 	}
+ 
+ 
+ 	{ ECPGclose(__LINE__, 0, 1, NULL, 0, "curname", ECPGst_normal, "close curname", ECPGt_EOIT, ECPGt_EORT);
+ #line 49 "cursor-readahead2.pgc"
+ 
+ if (sqlca.sqlwarn[0] == 'W') sqlprint();
+ #line 49 "cursor-readahead2.pgc"
+ 
+ if (sqlca.sqlcode < 0) sqlprint();}
+ #line 49 "cursor-readahead2.pgc"
+ 
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table ra_test2", ECPGt_EOIT, ECPGt_EORT);
+ #line 51 "cursor-readahead2.pgc"
+ 
+ if (sqlca.sqlwarn[0] == 'W') sqlprint();
+ #line 51 "cursor-readahead2.pgc"
+ 
+ if (sqlca.sqlcode < 0) sqlprint();}
+ #line 51 "cursor-readahead2.pgc"
+ 
+ 
+ 	{ ECPGtrans(__LINE__, NULL, "commit", 0, 0, 0, NULL);
+ #line 53 "cursor-readahead2.pgc"
+ 
+ if (sqlca.sqlwarn[0] == 'W') sqlprint();
+ #line 53 "cursor-readahead2.pgc"
+ 
+ if (sqlca.sqlcode < 0) sqlprint();}
+ #line 53 "cursor-readahead2.pgc"
+ 
+ 
+ 	{ ECPGdisconnect(__LINE__, "ALL");
+ #line 55 "cursor-readahead2.pgc"
+ 
+ if (sqlca.sqlwarn[0] == 'W') sqlprint();
+ #line 55 "cursor-readahead2.pgc"
+ 
+ if (sqlca.sqlcode < 0) sqlprint();}
+ #line 55 "cursor-readahead2.pgc"
+ 
+ 
+ 	return 0;
+ }
diff -dcrpN postgresql.2/src/interfaces/ecpg/test/expected/preproc-cursor-readahead2.stderr postgresql.3/src/interfaces/ecpg/test/expected/preproc-cursor-readahead2.stderr
*** postgresql.2/src/interfaces/ecpg/test/expected/preproc-cursor-readahead2.stderr	1970-01-01 01:00:00.000000000 +0100
--- postgresql.3/src/interfaces/ecpg/test/expected/preproc-cursor-readahead2.stderr	2012-04-10 18:30:12.878164362 +0200
***************
*** 0 ****
--- 1,228 ----
+ [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]: ECPGtrans on line 29: action "begin"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 31: query: create table ra_test2 ( id integer primary key , t text ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 31: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 31: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: query: insert into ra_test2 select i . i , 'a' from generate_series ( 1 , 10 ) as i; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: OK: INSERT 0 10
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: query: declare curname scroll cursor for select * from ra_test2 order by id; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGfetch on line 43: before ecpg_canonical_cursor_movement amount 1 direction 2 query: fetch curname
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGfetch on line 43: ecpg_canonical_cursor_movement n_amount 1 direction 2 fetchall 0 query: fetch curname
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGfetch on line 43: ECPGc_forward/ECPGc_backward, step 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: recheck_cursor_position on line 43: backward 0 atstart 1 atend 0 pos 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_cursor_execute on line 43: start_pos 0 cur->backend_pos 0
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_cursor_execute on line 43: query: fetch forward 8 from curname; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_cursor_execute on line 43: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: recheck_cursor_position on line 43: backward 0 atstart 1 atend 0 pos 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: recheck_cursor_position on line 43: clearing atstart and atend (no FETCH)
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 43: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 43: RESULT: 1 offset: -1; array: no
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 43: RESULT: a offset: -1; array: no
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGfetch on line 43: before ecpg_canonical_cursor_movement amount 1 direction 2 query: fetch curname
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGfetch on line 43: ecpg_canonical_cursor_movement n_amount 1 direction 2 fetchall 0 query: fetch curname
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGfetch on line 43: ECPGc_forward/ECPGc_backward, step 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: recheck_cursor_position on line 43: backward 0 atstart 0 atend 0 pos 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: recheck_cursor_position on line 43: clearing atstart and atend (no FETCH)
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 43: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 43: RESULT: 2 offset: -1; array: no
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 43: RESULT: a offset: -1; array: no
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGfetch on line 43: before ecpg_canonical_cursor_movement amount 1 direction 2 query: fetch curname
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGfetch on line 43: ecpg_canonical_cursor_movement n_amount 1 direction 2 fetchall 0 query: fetch curname
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGfetch on line 43: ECPGc_forward/ECPGc_backward, step 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: recheck_cursor_position on line 43: backward 0 atstart 0 atend 0 pos 3
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: recheck_cursor_position on line 43: clearing atstart and atend (no FETCH)
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 43: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 43: RESULT: 3 offset: -1; array: no
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 43: RESULT: a offset: -1; array: no
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGfetch on line 43: before ecpg_canonical_cursor_movement amount 1 direction 2 query: fetch curname
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGfetch on line 43: ecpg_canonical_cursor_movement n_amount 1 direction 2 fetchall 0 query: fetch curname
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGfetch on line 43: ECPGc_forward/ECPGc_backward, step 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: recheck_cursor_position on line 43: backward 0 atstart 0 atend 0 pos 4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: recheck_cursor_position on line 43: clearing atstart and atend (no FETCH)
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 43: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 43: RESULT: 4 offset: -1; array: no
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 43: RESULT: a offset: -1; array: no
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGfetch on line 43: before ecpg_canonical_cursor_movement amount 1 direction 2 query: fetch curname
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGfetch on line 43: ecpg_canonical_cursor_movement n_amount 1 direction 2 fetchall 0 query: fetch curname
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGfetch on line 43: ECPGc_forward/ECPGc_backward, step 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: recheck_cursor_position on line 43: backward 0 atstart 0 atend 0 pos 5
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: recheck_cursor_position on line 43: clearing atstart and atend (no FETCH)
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 43: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 43: RESULT: 5 offset: -1; array: no
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 43: RESULT: a offset: -1; array: no
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGfetch on line 43: before ecpg_canonical_cursor_movement amount 1 direction 2 query: fetch curname
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGfetch on line 43: ecpg_canonical_cursor_movement n_amount 1 direction 2 fetchall 0 query: fetch curname
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGfetch on line 43: ECPGc_forward/ECPGc_backward, step 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: recheck_cursor_position on line 43: backward 0 atstart 0 atend 0 pos 6
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: recheck_cursor_position on line 43: clearing atstart and atend (no FETCH)
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 43: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 43: RESULT: 6 offset: -1; array: no
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 43: RESULT: a offset: -1; array: no
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGfetch on line 43: before ecpg_canonical_cursor_movement amount 1 direction 2 query: fetch curname
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGfetch on line 43: ecpg_canonical_cursor_movement n_amount 1 direction 2 fetchall 0 query: fetch curname
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGfetch on line 43: ECPGc_forward/ECPGc_backward, step 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: recheck_cursor_position on line 43: backward 0 atstart 0 atend 0 pos 7
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: recheck_cursor_position on line 43: clearing atstart and atend (no FETCH)
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 43: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 43: RESULT: 7 offset: -1; array: no
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 43: RESULT: a offset: -1; array: no
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGfetch on line 43: before ecpg_canonical_cursor_movement amount 1 direction 2 query: fetch curname
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGfetch on line 43: ecpg_canonical_cursor_movement n_amount 1 direction 2 fetchall 0 query: fetch curname
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGfetch on line 43: ECPGc_forward/ECPGc_backward, step 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: recheck_cursor_position on line 43: backward 0 atstart 0 atend 0 pos 8
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: recheck_cursor_position on line 43: clearing atstart and atend (no FETCH)
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 43: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 43: RESULT: 8 offset: -1; array: no
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 43: RESULT: a offset: -1; array: no
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGfetch on line 43: before ecpg_canonical_cursor_movement amount 1 direction 2 query: fetch curname
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGfetch on line 43: ecpg_canonical_cursor_movement n_amount 1 direction 2 fetchall 0 query: fetch curname
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGfetch on line 43: ECPGc_forward/ECPGc_backward, step 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: recheck_cursor_position on line 43: backward 0 atstart 0 atend 0 pos 9
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_cursor_execute on line 43: start_pos 8 cur->backend_pos 8
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_cursor_execute on line 43: query: fetch forward 8 from curname; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_cursor_execute on line 43: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: recheck_cursor_position on line 43: backward 0 atstart 0 atend 0 pos 9
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: recheck_cursor_position on line 43: clearing atstart and atend (no FETCH)
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 43: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 43: RESULT: 9 offset: -1; array: no
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 43: RESULT: a offset: -1; array: no
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGfetch on line 43: before ecpg_canonical_cursor_movement amount 1 direction 2 query: fetch curname
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGfetch on line 43: ecpg_canonical_cursor_movement n_amount 1 direction 2 fetchall 0 query: fetch curname
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGfetch on line 43: ECPGc_forward/ECPGc_backward, step 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: recheck_cursor_position on line 43: backward 0 atstart 0 atend 0 pos 10
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: recheck_cursor_position on line 43: clearing atstart and atend (no FETCH)
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 43: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 43: RESULT: 10 offset: -1; array: no
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 43: RESULT: a offset: -1; array: no
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGfetch on line 43: before ecpg_canonical_cursor_movement amount 1 direction 2 query: fetch curname
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGfetch on line 43: ecpg_canonical_cursor_movement n_amount 1 direction 2 fetchall 0 query: fetch curname
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGfetch on line 43: ECPGc_forward/ECPGc_backward, step 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: recheck_cursor_position on line 43: backward 0 atstart 0 atend 0 pos 11
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: recheck_cursor_position on line 43: setting atend to true (no FETCH)
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: raising sqlcode 100 on line 43: no data found on line 43
+ [NO_PID]: sqlca: code: 100, state: 02000
+ [NO_PID]: ecpg_execute on line 49: query: close curname; 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: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 51: query: drop table ra_test2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 51: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 51: OK: DROP TABLE
+ [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_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN postgresql.2/src/interfaces/ecpg/test/expected/preproc-cursor-readahead2.stdout postgresql.3/src/interfaces/ecpg/test/expected/preproc-cursor-readahead2.stdout
*** postgresql.2/src/interfaces/ecpg/test/expected/preproc-cursor-readahead2.stdout	1970-01-01 01:00:00.000000000 +0100
--- postgresql.3/src/interfaces/ecpg/test/expected/preproc-cursor-readahead2.stdout	2012-04-10 18:30:12.878164362 +0200
***************
*** 0 ****
--- 1,10 ----
+ id: 1 t: 'a'
+ id: 2 t: 'a'
+ id: 3 t: 'a'
+ id: 4 t: 'a'
+ id: 5 t: 'a'
+ id: 6 t: 'a'
+ id: 7 t: 'a'
+ id: 8 t: 'a'
+ id: 9 t: 'a'
+ id: 10 t: 'a'
diff -dcrpN postgresql.2/src/interfaces/ecpg/test/expected/preproc-cursor-readahead.c postgresql.3/src/interfaces/ecpg/test/expected/preproc-cursor-readahead.c
*** postgresql.2/src/interfaces/ecpg/test/expected/preproc-cursor-readahead.c	2012-04-10 17:07:33.136111937 +0200
--- postgresql.3/src/interfaces/ecpg/test/expected/preproc-cursor-readahead.c	2012-04-10 18:45:34.662618941 +0200
***************
*** 10,16 ****
  #include <stdio.h>
  #include <stdlib.h>
  
! /* test automatic prepare for all statements */
  
  #line 1 "regression.h"
  
--- 10,16 ----
  #include <stdio.h>
  #include <stdlib.h>
  
! /* test cursor readahead */
  
  #line 1 "regression.h"
  
*************** if (sqlca.sqlcode < 0) sqlprint();}
*** 174,180 ****
  	{
  		count = counts[i];
  
! 		{ ECPGopen(__LINE__, 0, 1, NULL, 0, 256, 0, 1, 0, "xcur", ECPGst_normal, "declare xcur scroll cursor for select * from ra_test order by id", ECPGt_EOIT, ECPGt_EORT);
  #line 58 "cursor-readahead.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
--- 174,180 ----
  	{
  		count = counts[i];
  
! 		{ ECPGopen(__LINE__, 0, 1, NULL, 0, 256, 0, 0, 1, 0, "xcur", ECPGst_normal, "declare xcur scroll cursor for select * from ra_test order by id", ECPGt_EOIT, ECPGt_EORT);
  #line 58 "cursor-readahead.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
*************** if (sqlca.sqlwarn[0] == 'W') sqlprint();
*** 183,189 ****
  if (sqlca.sqlcode < 0) sqlprint();}
  #line 58 "cursor-readahead.pgc"
  
! 		{ ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 0, 1, 0, curname, ECPGst_normal, "declare $0 scroll cursor for select * from ra_test order by id", 
  	ECPGt_char,&(curname),(long)0,(long)1,(1)*sizeof(char), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
  #line 59 "cursor-readahead.pgc"
--- 183,189 ----
  if (sqlca.sqlcode < 0) sqlprint();}
  #line 58 "cursor-readahead.pgc"
  
! 		{ ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 1, 0, 1, 0, curname, ECPGst_normal, "declare $0 scroll cursor for select * from ra_test order by id", 
  	ECPGt_char,&(curname),(long)0,(long)1,(1)*sizeof(char), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
  #line 59 "cursor-readahead.pgc"
*************** if (sqlca.sqlcode < 0) sqlprint();}
*** 302,308 ****
  #line 116 "cursor-readahead.pgc"
  
  
! 		{ ECPGopen(__LINE__, 0, 1, NULL, 0, 256, 0, 1, 0, "xcur", ECPGst_normal, "declare xcur scroll cursor for select * from ra_test order by id", ECPGt_EOIT, ECPGt_EORT);
  #line 118 "cursor-readahead.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
--- 302,308 ----
  #line 116 "cursor-readahead.pgc"
  
  
! 		{ ECPGopen(__LINE__, 0, 1, NULL, 0, 256, 0, 0, 1, 0, "xcur", ECPGst_normal, "declare xcur scroll cursor for select * from ra_test order by id", ECPGt_EOIT, ECPGt_EORT);
  #line 118 "cursor-readahead.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
*************** if (sqlca.sqlwarn[0] == 'W') sqlprint();
*** 311,317 ****
  if (sqlca.sqlcode < 0) sqlprint();}
  #line 118 "cursor-readahead.pgc"
  
! 		{ ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 0, 1, 0, curname, ECPGst_normal, "declare $0 scroll cursor for select * from ra_test order by id", 
  	ECPGt_char,&(curname),(long)0,(long)1,(1)*sizeof(char), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
  #line 119 "cursor-readahead.pgc"
--- 311,317 ----
  if (sqlca.sqlcode < 0) sqlprint();}
  #line 118 "cursor-readahead.pgc"
  
! 		{ ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 1, 0, 1, 0, curname, ECPGst_normal, "declare $0 scroll cursor for select * from ra_test order by id", 
  	ECPGt_char,&(curname),(long)0,(long)1,(1)*sizeof(char), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
  #line 119 "cursor-readahead.pgc"
*************** if (sqlca.sqlcode < 0) sqlprint();}
*** 494,500 ****
  	}
  
  	sqlda = NULL;
! 	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 256, 0, 1, 0, "xcur", ECPGst_normal, "declare xcur scroll cursor for select * from ra_test order by id", ECPGt_EOIT, ECPGt_EORT);
  #line 190 "cursor-readahead.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
--- 494,500 ----
  	}
  
  	sqlda = NULL;
! 	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 256, 0, 0, 1, 0, "xcur", ECPGst_normal, "declare xcur scroll cursor for select * from ra_test order by id", ECPGt_EOIT, ECPGt_EORT);
  #line 190 "cursor-readahead.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
*************** if (sqlca.sqlcode < 0) sqlprint();}
*** 558,564 ****
  
  
  	sqlda = NULL;
! 	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 256, 0, 1, 0, "xcur", ECPGst_normal, "declare xcur scroll cursor for select * from ra_test order by id", ECPGt_EOIT, ECPGt_EORT);
  #line 224 "cursor-readahead.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
--- 558,564 ----
  
  
  	sqlda = NULL;
! 	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 256, 0, 0, 1, 0, "xcur", ECPGst_normal, "declare xcur scroll cursor for select * from ra_test order by id", ECPGt_EOIT, ECPGt_EORT);
  #line 224 "cursor-readahead.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
diff -dcrpN postgresql.2/src/interfaces/ecpg/test/expected/preproc-outofscope.c postgresql.3/src/interfaces/ecpg/test/expected/preproc-outofscope.c
*** postgresql.2/src/interfaces/ecpg/test/expected/preproc-outofscope.c	2012-04-10 17:07:33.137111943 +0200
--- postgresql.3/src/interfaces/ecpg/test/expected/preproc-outofscope.c	2012-04-10 18:45:35.942625138 +0200
*************** get_var1(MYTYPE **myvar0, MYNULLTYPE **m
*** 201,207 ****
  static void
  open_cur1(void)
  {
! 	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 0, 0, 0, "mycur", ECPGst_normal, "declare mycur 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), 
--- 201,207 ----
  static void
  open_cur1(void)
  {
! 	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 1, 0, 0, 0, "mycur", ECPGst_normal, "declare mycur 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 -dcrpN postgresql.2/src/interfaces/ecpg/test/expected/preproc-variable.c postgresql.3/src/interfaces/ecpg/test/expected/preproc-variable.c
*** postgresql.2/src/interfaces/ecpg/test/expected/preproc-variable.c	2012-04-10 17:07:33.139111953 +0200
--- postgresql.3/src/interfaces/ecpg/test/expected/preproc-variable.c	2012-04-10 18:45:35.374622390 +0200
*************** if (sqlca.sqlcode < 0) exit (1);}
*** 190,196 ****
  
  
  	strcpy(msg, "open");
! 	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 0, 0, 0, "cur", ECPGst_normal, "declare cur cursor for select name , born , age , married , children from family", ECPGt_EOIT, ECPGt_EORT);
  #line 63 "variable.pgc"
  
  if (sqlca.sqlcode < 0) exit (1);}
--- 190,196 ----
  
  
  	strcpy(msg, "open");
! 	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 1, 0, 0, 0, "cur", ECPGst_normal, "declare cur 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 -dcrpN postgresql.2/src/interfaces/ecpg/test/expected/sql-binary.c postgresql.3/src/interfaces/ecpg/test/expected/sql-binary.c
*** postgresql.2/src/interfaces/ecpg/test/expected/sql-binary.c	2012-04-10 17:07:33.141111963 +0200
--- postgresql.3/src/interfaces/ecpg/test/expected/sql-binary.c	2012-04-10 18:45:36.438627533 +0200
*************** main (void)
*** 111,117 ****
   /* declare C cursor for select name , accs , byte from empl where idnum = $1  */
  #line 58 "binary.pgc"
  
!   { ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 0, 0, 0, "C", ECPGst_normal, "declare C 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"
--- 111,117 ----
   /* declare C cursor for select name , accs , byte from empl where idnum = $1  */
  #line 58 "binary.pgc"
  
!   { ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 1, 0, 0, 0, "C", ECPGst_normal, "declare C 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"
*************** main (void)
*** 138,144 ****
   /* declare B binary cursor for select name , accs , byte from empl where idnum = $1  */
  #line 70 "binary.pgc"
  
!   { ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 0, 0, 0, "B", ECPGst_normal, "declare B binary 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 71 "binary.pgc"
--- 138,144 ----
   /* declare B binary cursor for select name , accs , byte from empl where idnum = $1  */
  #line 70 "binary.pgc"
  
!   { ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 1, 0, 0, 0, "B", ECPGst_normal, "declare B binary 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 71 "binary.pgc"
*************** main (void)
*** 172,178 ****
   /* declare A binary cursor for select byte from empl where idnum = $1  */
  #line 87 "binary.pgc"
  
!   { ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 0, 0, 0, "A", ECPGst_normal, "declare A binary 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 88 "binary.pgc"
--- 172,178 ----
   /* declare A binary cursor for select byte from empl where idnum = $1  */
  #line 87 "binary.pgc"
  
!   { ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 1, 0, 0, 0, "A", ECPGst_normal, "declare A binary 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 88 "binary.pgc"
diff -dcrpN postgresql.2/src/interfaces/ecpg/test/expected/sql-desc.c postgresql.3/src/interfaces/ecpg/test/expected/sql-desc.c
*** postgresql.2/src/interfaces/ecpg/test/expected/sql-desc.c	2012-04-10 17:07:33.141111963 +0200
--- postgresql.3/src/interfaces/ecpg/test/expected/sql-desc.c	2012-04-10 18:45:36.910629831 +0200
*************** if (sqlca.sqlcode < 0) sqlprint();}
*** 245,251 ****
  	/* declare c1 cursor for $1 */
  #line 57 "desc.pgc"
  
! 	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 0, 0, 0, "c1", ECPGst_normal, "declare c1 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, 
--- 245,251 ----
  	/* declare c1 cursor for $1 */
  #line 57 "desc.pgc"
  
! 	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 1, 0, 0, 0, "c1", ECPGst_normal, "declare c1 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, 
*************** if (sqlca.sqlcode < 0) sqlprint();}
*** 295,301 ****
  	/* declare c2 cursor for $1 */
  #line 69 "desc.pgc"
  
! 	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 0, 0, 0, "c2", ECPGst_normal, "declare c2 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, 
--- 295,301 ----
  	/* declare c2 cursor for $1 */
  #line 69 "desc.pgc"
  
! 	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 1, 0, 0, 0, "c2", ECPGst_normal, "declare c2 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 -dcrpN postgresql.2/src/interfaces/ecpg/test/expected/sql-dyntest.c postgresql.3/src/interfaces/ecpg/test/expected/sql-dyntest.c
*** postgresql.2/src/interfaces/ecpg/test/expected/sql-dyntest.c	2012-04-10 17:07:33.142111968 +0200
--- postgresql.3/src/interfaces/ecpg/test/expected/sql-dyntest.c	2012-04-10 18:45:37.886634555 +0200
*************** if (sqlca.sqlcode < 0) error ( );}
*** 261,267 ****
  #line 58 "dyntest.pgc"
  
  
!   { ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 0, 0, 0, "MYCURS", ECPGst_normal, "declare MYCURS 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"
--- 261,267 ----
  #line 58 "dyntest.pgc"
  
  
!   { ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 1, 0, 0, 0, "MYCURS", ECPGst_normal, "declare MYCURS 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 -dcrpN postgresql.2/src/interfaces/ecpg/test/expected/sql-execute.c postgresql.3/src/interfaces/ecpg/test/expected/sql-execute.c
*** postgresql.2/src/interfaces/ecpg/test/expected/sql-execute.c	2012-04-10 17:07:33.143111974 +0200
--- postgresql.3/src/interfaces/ecpg/test/expected/sql-execute.c	2012-04-10 18:45:38.374636920 +0200
*************** if (sqlca.sqlcode < 0) sqlprint();}
*** 140,146 ****
  #line 50 "execute.pgc"
  
  
! 	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 0, 0, 0, "CUR", ECPGst_normal, "declare CUR 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"
--- 140,146 ----
  #line 50 "execute.pgc"
  
  
! 	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 1, 0, 0, 0, "CUR", ECPGst_normal, "declare CUR 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"
*************** if (sqlca.sqlcode < 0) sqlprint();}
*** 205,211 ****
  #line 72 "execute.pgc"
  
  
! 	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 0, 0, 0, "CUR2", ECPGst_normal, "declare CUR2 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"), 
--- 205,211 ----
  #line 72 "execute.pgc"
  
  
! 	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 1, 0, 0, 0, "CUR2", ECPGst_normal, "declare CUR2 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 -dcrpN postgresql.2/src/interfaces/ecpg/test/expected/sql-fetch.c postgresql.3/src/interfaces/ecpg/test/expected/sql-fetch.c
*** postgresql.2/src/interfaces/ecpg/test/expected/sql-fetch.c	2012-04-10 17:07:33.145111984 +0200
--- postgresql.3/src/interfaces/ecpg/test/expected/sql-fetch.c	2012-04-10 18:45:38.998639945 +0200
*************** if (sqlca.sqlcode < 0) sqlprint();}
*** 99,105 ****
  #line 26 "fetch.pgc"
  
  
!   { ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 0, 0, 0, "C", ECPGst_normal, "declare C cursor for select * from My_Table", ECPGt_EOIT, ECPGt_EORT);
  #line 28 "fetch.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
--- 99,105 ----
  #line 26 "fetch.pgc"
  
  
!   { ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 1, 0, 0, 0, "C", ECPGst_normal, "declare C cursor for select * from My_Table", ECPGt_EOIT, ECPGt_EORT);
  #line 28 "fetch.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
*************** if (sqlca.sqlcode < 0) sqlprint();}
*** 166,172 ****
  #line 42 "fetch.pgc"
  
  
!   { ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 0, 0, 0, "D", ECPGst_normal, "declare D 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 44 "fetch.pgc"
--- 166,172 ----
  #line 42 "fetch.pgc"
  
  
!   { ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 1, 0, 0, 0, "D", ECPGst_normal, "declare D 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 44 "fetch.pgc"
diff -dcrpN postgresql.2/src/interfaces/ecpg/test/expected/sql-oldexec.c postgresql.3/src/interfaces/ecpg/test/expected/sql-oldexec.c
*** postgresql.2/src/interfaces/ecpg/test/expected/sql-oldexec.c	2012-04-10 17:07:33.147111994 +0200
--- postgresql.3/src/interfaces/ecpg/test/expected/sql-oldexec.c	2012-04-10 18:45:39.462642193 +0200
*************** if (sqlca.sqlcode < 0) sqlprint();}
*** 140,146 ****
  #line 50 "oldexec.pgc"
  
  
! 	{ ECPGopen(__LINE__, 0, 1, NULL, 1, 1, 0, 0, 0, "CUR", ECPGst_normal, "declare CUR 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"
--- 140,146 ----
  #line 50 "oldexec.pgc"
  
  
! 	{ ECPGopen(__LINE__, 0, 1, NULL, 1, 1, 1, 0, 0, 0, "CUR", ECPGst_normal, "declare CUR 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"
*************** if (sqlca.sqlcode < 0) sqlprint();}
*** 199,205 ****
  #line 71 "oldexec.pgc"
  
  
! 	{ ECPGopen(__LINE__, 0, 1, NULL, 1, 1, 0, 0, 0, "CUR3", ECPGst_normal, "declare CUR3 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"), 
--- 199,205 ----
  #line 71 "oldexec.pgc"
  
  
! 	{ ECPGopen(__LINE__, 0, 1, NULL, 1, 1, 1, 0, 0, 0, "CUR3", ECPGst_normal, "declare CUR3 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 -dcrpN postgresql.2/src/interfaces/ecpg/test/expected/sql-quote.c postgresql.3/src/interfaces/ecpg/test/expected/sql-quote.c
*** postgresql.2/src/interfaces/ecpg/test/expected/sql-quote.c	2012-04-10 17:07:33.149112004 +0200
--- postgresql.3/src/interfaces/ecpg/test/expected/sql-quote.c	2012-04-10 18:45:39.934644475 +0200
*************** if (sqlca.sqlcode < 0) sqlprint();}
*** 162,168 ****
  #line 43 "quote.pgc"
  
  
!   { ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 0, 0, 0, "C", ECPGst_normal, "declare C cursor for select * from \"My_Table\"", ECPGt_EOIT, ECPGt_EORT);
  #line 45 "quote.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
--- 162,168 ----
  #line 43 "quote.pgc"
  
  
!   { ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 1, 0, 0, 0, "C", ECPGst_normal, "declare C cursor for select * from \"My_Table\"", ECPGt_EOIT, ECPGt_EORT);
  #line 45 "quote.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
diff -dcrpN postgresql.2/src/interfaces/ecpg/test/expected/sql-sqlda.c postgresql.3/src/interfaces/ecpg/test/expected/sql-sqlda.c
*** postgresql.2/src/interfaces/ecpg/test/expected/sql-sqlda.c	2012-04-10 17:07:33.151112015 +0200
--- postgresql.3/src/interfaces/ecpg/test/expected/sql-sqlda.c	2012-04-10 18:45:37.390632155 +0200
*************** if (sqlca.sqlcode < 0) exit (1);}
*** 251,257 ****
  
  
  	strcpy(msg, "open");
! 	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 0, 0, 0, "mycur1", ECPGst_normal, "declare mycur1 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"
--- 251,257 ----
  
  
  	strcpy(msg, "open");
! 	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 1, 0, 0, 0, "mycur1", ECPGst_normal, "declare mycur1 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"
*************** if (sqlca.sqlcode < 0) exit (1);}
*** 324,330 ****
  
  
  	strcpy(msg, "open");
! 	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 0, 0, 0, "mycur2", ECPGst_normal, "declare mycur2 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"
--- 324,330 ----
  
  
  	strcpy(msg, "open");
! 	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 1, 1, 0, 0, 0, "mycur2", ECPGst_normal, "declare mycur2 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 -dcrpN postgresql.2/src/interfaces/ecpg/test/preproc/cursor-readahead2.pgc postgresql.3/src/interfaces/ecpg/test/preproc/cursor-readahead2.pgc
*** postgresql.2/src/interfaces/ecpg/test/preproc/cursor-readahead2.pgc	1970-01-01 01:00:00.000000000 +0100
--- postgresql.3/src/interfaces/ecpg/test/preproc/cursor-readahead2.pgc	2012-04-10 18:28:48.425738986 +0200
***************
*** 0 ****
--- 1,58 ----
+ #include <stdio.h>
+ #include <stdlib.h>
+ 
+ /* test cursor readahead with ECPGFETCHSZ */
+ EXEC SQL INCLUDE ../regression;
+ 
+ EXEC SQL INCLUDE sqlda.h;
+ 
+ EXEC SQL WHENEVER SQLERROR SQLPRINT;
+ EXEC SQL WHENEVER SQLWARNING SQLPRINT;
+ 
+ int main(void)
+ {
+ 	EXEC SQL BEGIN DECLARE SECTION;
+ 	int	id;
+ 	char	t[64];
+ 	EXEC SQL END DECLARE SECTION;
+ 
+ 	/*
+ 	 * Override the "non-readahead" cursors
+ 	 * via the environment variable.
+ 	 */
+ 	setenv("ECPGFETCHSZ", "8", 1);
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	EXEC SQL CONNECT TO REGRESSDB1;
+ 
+ 	EXEC SQL BEGIN;
+ 
+ 	EXEC SQL CREATE TABLE ra_test2 (id INTEGER PRIMARY KEY, t text);
+ 	EXEC SQL INSERT INTO ra_test2 SELECT i.i, 'a' FROM generate_series(1, 10) as i;
+ 
+ 	EXEC SQL DECLARE curname SCROLL CURSOR FOR SELECT * FROM ra_test2 ORDER BY id;
+ 
+ 	EXEC SQL OPEN curname;
+ 
+ 	EXEC SQL WHENEVER NOT FOUND DO BREAK;
+ 
+ 	id = 0;
+ 	while (1)
+ 	{
+ 		EXEC SQL FETCH curname INTO :id, :t;
+ 
+ 		printf("id: %d t: '%s'\n", id, t);
+ 	}
+ 
+ 
+ 	EXEC SQL CLOSE curname;
+ 
+ 	EXEC SQL DROP TABLE ra_test2;
+ 
+ 	EXEC SQL COMMIT;
+ 
+ 	EXEC SQL DISCONNECT ALL;
+ 
+ 	return 0;
+ }
diff -dcrpN postgresql.2/src/interfaces/ecpg/test/preproc/cursor-readahead.pgc postgresql.3/src/interfaces/ecpg/test/preproc/cursor-readahead.pgc
*** postgresql.2/src/interfaces/ecpg/test/preproc/cursor-readahead.pgc	2012-04-10 17:07:33.153112025 +0200
--- postgresql.3/src/interfaces/ecpg/test/preproc/cursor-readahead.pgc	2012-04-10 17:56:28.351029885 +0200
***************
*** 1,7 ****
  #include <stdio.h>
  #include <stdlib.h>
  
! /* test automatic prepare for all statements */
  EXEC SQL INCLUDE ../regression;
  
  EXEC SQL INCLUDE sqlda.h;
--- 1,7 ----
  #include <stdio.h>
  #include <stdlib.h>
  
! /* test cursor readahead */
  EXEC SQL INCLUDE ../regression;
  
  EXEC SQL INCLUDE sqlda.h;
diff -dcrpN postgresql.2/src/interfaces/ecpg/test/preproc/Makefile postgresql.3/src/interfaces/ecpg/test/preproc/Makefile
*** postgresql.2/src/interfaces/ecpg/test/preproc/Makefile	2012-04-10 17:07:05.088967428 +0200
--- postgresql.3/src/interfaces/ecpg/test/preproc/Makefile	2012-04-10 18:27:07.849232596 +0200
*************** TESTS = array_of_struct array_of_struct.
*** 9,14 ****
--- 9,15 ----
  	comment comment.c \
  	cursor cursor.c \
  	cursor-readahead cursor-readahead.c \
+ 	cursor-readahead2 cursor-readahead2.c \
  	define define.c \
  	init init.c \
  	strings strings.c \
