commit bac00ac007c87475527ee9ee0c0af2d0325d0888
Author: Böszörményi Zoltán <zb@cybertec.at>
Date:   Thu Nov 28 14:29:57 2013 +0100

    ECPG: Add cursor readahead for caching tuples locally on the client side.
    This would speed up applications using ECPG. Exploit the new backend
    information about cursor scrollability. Besides the SGML documentation,
    a README is added. Three extra regression tests were added to exercise
    certain aspects and corner cases. Another regression test was rewritten.

diff --git a/doc/src/sgml/ecpg.sgml b/doc/src/sgml/ecpg.sgml
index b242fcc..ddcb93f 100644
--- a/doc/src/sgml/ecpg.sgml
+++ b/doc/src/sgml/ecpg.sgml
@@ -458,6 +458,24 @@ EXEC SQL COMMIT;
    details.
   </para>
 
+  <para>
+   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.
+  </para>
+
+  <para>
+   To execute an UPDATE or DELETE statement bearing the <literal>WHERE CURRENT OF</literal>
+   clause, ECPG may first execute an implicit MOVE to synchronize the server
+   cursor position with the local cursor position.  This can reduce or
+   eliminate the performance benefit of readahead for affected cursors.
+   For this reason, <literal>READAHEAD 1</literal> is recommended.
+  </para>
+
    <note>
     <para>
      The ECPG <command>DECLARE</command> command does not actually
@@ -467,6 +485,18 @@ EXEC SQL COMMIT;
      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">
@@ -5280,6 +5310,10 @@ while (1)
        This error code may occur in the following conditions.
       </para>
       <para>
+       The readahead window size you are trying to use is invalid.
+       (SQLSTATE 24000)
+      </para>
+      <para>
        The cursor name you are trying to use is invalid.
        (SQLSTATE 34000)
       </para>
@@ -6607,8 +6641,8 @@ EXEC SQL DEALLOCATE DESCRIPTOR mydesc;
 
    <refsynopsisdiv>
 <synopsis>
-DECLARE <replaceable class="PARAMETER">cursor_name</replaceable> [ BINARY ] [ INSENSITIVE ] [ [ NO ] SCROLL ] CURSOR [ { WITH | WITHOUT } HOLD ] FOR <replaceable class="PARAMETER">prepared_name</replaceable>
-DECLARE <replaceable class="PARAMETER">cursor_name</replaceable> [ BINARY ] [ INSENSITIVE ] [ [ NO ] SCROLL ] CURSOR [ { WITH | WITHOUT } HOLD ] FOR <replaceable class="PARAMETER">query</replaceable>
+DECLARE <replaceable class="PARAMETER">cursor_name</replaceable> [ BINARY ] [ INSENSITIVE ] [ [ NO ] SCROLL ] [ READAHEAD number ] CURSOR [ { WITH | WITHOUT } HOLD ] FOR <replaceable class="PARAMETER">prepared_name</replaceable>
+DECLARE <replaceable class="PARAMETER">cursor_name</replaceable> [ BINARY ] [ INSENSITIVE ] [ [ NO ] SCROLL ] [ READAHEAD number ] CURSOR [ { WITH | WITHOUT } HOLD ] FOR <replaceable class="PARAMETER">query</replaceable>
 </synopsis>
    </refsynopsisdiv>
 
@@ -6663,11 +6697,30 @@ DECLARE <replaceable class="PARAMETER">cursor_name</replaceable> [ BINARY ] [ IN
       </listitem>
      </varlistentry>
     </variablelist>
+   </refsect1>
+
+   <refsect1>
+    <title>ECPG-specific cursor options</title>
 
     <para>
-     For the meaning of the cursor options,
-     see <xref linkend="sql-declare">.
+     For the meaning of regular cursor options, see <xref linkend="sql-declare">.
     </para>
+
+    <variablelist>
+     <varlistentry>
+      <term><literal>READAHEAD number</literal></term>
+       <listitem>
+        <para>
+         The ECPG preprocessor and runtime library use client-side cursor
+         tracking and accounting. <literal>READAHEAD number</literal> sets
+         data readahead used during <command>FETCH</command>. This improves
+         performance for programs that use single-row <command>FETCH</command>
+         statements.
+        </para>
+       </listitem>
+     </varlistentry>
+    </variablelist>
+
    </refsect1>
 
    <refsect1>
diff --git a/doc/src/sgml/ref/ecpg-ref.sgml b/doc/src/sgml/ref/ecpg-ref.sgml
index edd20dc..ddbdbe5 100644
--- a/doc/src/sgml/ref/ecpg-ref.sgml
+++ b/doc/src/sgml/ref/ecpg-ref.sgml
@@ -166,6 +166,15 @@ PostgreSQL documentation
          </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>
        </variablelist></para>
      </listitem>
     </varlistentry>
diff --git a/src/interfaces/ecpg/ecpglib/README.cursor+subxact b/src/interfaces/ecpg/ecpglib/README.cursor+subxact
new file mode 100644
index 0000000..6ef02ba
--- /dev/null
+++ b/src/interfaces/ecpg/ecpglib/README.cursor+subxact
@@ -0,0 +1,176 @@
+Theory of operation for client side cursor accounting and readahead
+===================================================================
+
+Contents of tuples returned by a cursor always reflect the data present at
+the time of declaring the cursor. Because of this, executing DML commands
+involving the table(s) appearing in the cursor's SELECT query won't modify
+the result set returned by the cursor. Because of this, cursor readahead is
+possible and the cursor readahead window always contains the same data as
+the underlying cursor.
+
+Tracking the maximum known backend position value allows the number of MOVE
+commands sent to the server to be reduced and re-fetching the same readahead
+window avoided in case the application suddenly changes cursor positioning
+from positive to negative and vice-versa.
+
+The idea behind cursor readahead is to move one tuple less than asked by
+the application and then ecpglib performs a FETCH FORWARD/BACKWARD N to
+populate the local tuple cache.
+
+By using a readahead window larger than 1 tuple, the cursor positions known
+by the backend and the application are different most of the time. As a
+consequence, UPDATE/DELETE ... WHERE CURRENT OF requires a MOVE behind the
+application's back. This may reduce or eliminate the caching effects in the
+cursor and it will not work for non-scrollable cursors. Either the cursor
+must be scrollable or READAHEAD 1 must be explicitly specified for such
+cursors.
+
+The slight problem with this approach is that ABSOLUTE and RELATIVE movements
+needs two operations. If the next command issued by the application spills
+out of the cache and it happens frequently, it may actually decrease
+performance. To prevent this, the ECPG runtime switches to executing these
+kinds of commands as is after 3 cache misses. FETCH FORWARD/BACKWARD allows
+switching back to caching.
+
+The ECPG runtime library has "struct subxact_descriptor" and
+"struct cursor_descriptor" for tracking subtransactions and cursors.
+
+Explanation of structure members of "struct cursor_descriptor" are below.
+
+subxact_level: The cursor was declared in this transaction level.
+--------------
+Valid values are:
+0:  Outside of transactions. This is a WITH HOLD cursor, committed
+    in a previous transaction.
+1:  The cursor was declared in the currently running toplevel
+    transaction.
+>2: The cursor was declared in the currently running transaction
+    in the specified SAVEPOINT.
+
+As soon as a (sub-)transaction is committed or rolled back, cursors are
+either implicitly propagated to the next subtransaction level upwards,
+i.e. subxact_level is decreased by 1.
+
+with_hold: WITH HOLD cursor (true or false)
+----------
+
+scrollable: The scrollability of the cursor.
+-----------
+Accepted values are: ECPGcs_no_scroll or ECPGcs_scroll
+
+There is also a third enum value, ECPGcs_unspecified which is used
+internally by the ECPG preprocessor when the application didn't
+explicitly specify neither SCROLL nor NO SCROLL. It will be eventually
+overridden by NO SCROLL in the DECLARE statement and ECPGcs_no_scroll
+in the "scrollable" argument.
+
+res: The current readahead window.
+----
+It is used to return data across several FETCH commands, speeding up
+the application by reducing network turnaround.
+
+readahead: The size of the readahead window.
+----------
+The ECPG runtime library attempts to fetch this amount of records at once.
+
+cache_start_pos: The start position of the readahead window.
+----------------
+The value is 1-based. Position 0 means that the cursor is before the first
+tuple in the result set.
+
+I can also be negative (but also 1-based) if the application started with
+FETCH/MOVE ABSOLUTE <some negative number>. In this case the numbering
+is used to count from the end of the result set.
+
+backward: The ECPG runtime library fetched this readahead window backward.
+---------
+
+atstart: The current position is at the start of the result set.
+--------
+
+atend: The current position is at the end of the result set.
+------
+
+pos: The current cursor position, as known by the application.
+----
+The comments above for "cache_start_pos" are also applicable here.
+"atstart" and "atend" apply to this position.
+
+backend_pos: The current cursor position, as known by the server.
+------------
+
+mkbpos: The maximum known backend position.
+-------
+If the application tries to execute a MOVE and it's over the previously
+known maximum value, different things happen depending on the type of the
+motion.
+
+MOVE [FORWARD|BACKWARD] ALL
+The number of records from the previous position to the end of the result
+set is reported.
+
+MOVE ABSOLUTE N, MOVE [FORWARD|BACKWARD] RELATIVE N
+If there is a tuple on this position, the server indicates the existence of
+a tuple on that position.
+
+This value is trivially updated for FETCH commands.
+
+mkbp_is_last: Maximum Known Backend Position is the last valid position.
+-------------
+The "mkbpos" is the last cursor position where a tuple exists 
+
+Structure members of "struct subxact_descriptor" don't need too much
+explanation. New savepoints get prepended to the list of subtransations
+which are per-connection, so the head of the list is found in
+struct connection. However, the necessity of this structure is explained
+below.
+
+Tracking (sub-)transactions
+===========================
+
+One side effect/requirement of tracking cursors in the ECPG runtime library
+is that (sub-)transactions are also needed to be tracked. These two are
+in some kind of symbiosis: if a command fails, the (sub-)transaction returns
+"current transaction is aborted" error for every subsequent commands.
+Such a failed command can be a cursor command using an invalid cursor name.
+
+By tracking cursors in the ECPG runtime library, detecting an invalid cursor
+name can be done early which reduces the network turnaround further.
+
+But doing this, the server and the application now disagree on the failed
+transaction. Because of this, a "client side error" flag was introduced into
+"struct connection".
+
+Subsequent commands (in execute.c::ecpg_prologue() and misc.c::ECPGtrans())
+check this flag and return the "current transaction is aborted" error to the
+application without executing them in the server. As mentioned above, the
+server and the application at this point disagree on the failed transaction
+and he issued command may be executed without an error, causing unwanted
+effects.
+
+Checking the "client side error" flag further reduces network turnaround for
+transactions failed on the client side and buggy applications that don't check
+for failed commands and roll back the (sub-)transaction.
+
+Executing COMMIT or PREPARE TRANSACTION for a failed transaction silently
+overrides these commands as ROLLBACK in the server. By checking the "client
+side error" flag, it can be done explicitly.
+
+In a failed transaction, only the ROLLBACK and ROLLBACK TO SAVEPOINT commands
+are allowed to be executed without errors in the server. These also pass
+through in client side tracking code, allowing the "client side error" flag
+to be cleared.
+
+All other transaction commands are treated as regular commands in a failed
+transactions in that the "current transaction is aborted" error is returned.
+
+Cursors are mostly transactional, i.e. rolling back a (sub-)transaction makes
+cursors declared in that subtransaction forgotten in the server.
+
+Committing a transaction or releasing a subtransaction make cursors declared
+in this (sub-)transaction or some levels below that propagates the cursor
+upwards with only WITH HOLD cursors surviving a committed transaction.
+
+The ECPG runtime library must also follow the server behaviour in tracking
+cursors across (sub-)transactions. This is done in misc.c in the ECPGtrans()
+function and in cursor.c in the ecpg_commit_cursors() function.
diff --git a/src/interfaces/ecpg/ecpglib/cursor.c b/src/interfaces/ecpg/ecpglib/cursor.c
index b9b3500..bd8a043 100644
--- a/src/interfaces/ecpg/ecpglib/cursor.c
+++ b/src/interfaces/ecpg/ecpglib/cursor.c
@@ -15,6 +15,33 @@
 #include "ecpgerrno.h"
 #include "extern.h"
 
+static char *ecpg_cursor_direction_sql_name[] = {
+	"absolute",
+	"relative",
+	"forward",
+	"backward",
+	"absolute",
+	"relative",
+	"forward",
+	"backward"
+};
+ 
+static bool ecpg_cursor_do_move_all(struct statement *stmt,
+					struct cursor_descriptor *cur,
+					enum ECPG_cursor_direction direction,
+					int64 *return_pos);
+static bool ecpg_cursor_move(struct statement *stmt,
+					struct cursor_descriptor *cur,
+					enum ECPG_cursor_direction direction,
+					int64 amount, bool fetchall,
+					bool do_override);
+static bool ecpg_cursor_next_pos(struct statement *stmt,
+					struct cursor_descriptor *cur,
+					enum ECPG_cursor_direction direction, bool fetch,
+					int64 amount, bool fetchall, long *qresult,
+					int64 *next_pos_out, bool *next_atstart_out,
+					bool *next_atend_out, bool *error, bool *beyond_known);
+
 static void
 raise_cursor_error(struct connection *con, int lineno, const char *name)
 {
@@ -50,7 +77,8 @@ find_cursor(struct connection *con, int lineno, const char *name, bool ignore,
 
 	/*
 	 * This will ensure that:
-	 * - quoted cursor names will be the first ones in the list ordered case-sensitively
+	 * - quoted cursor names will be the first ones in the list ordered
+	 *   case-sensitively
 	 * - unquoted cursor names at the end, ordered case-insensitively.
 	 */
 	strcmp_fn = (name[0] == '"' ? strcmp : pg_strcasecmp);
@@ -98,7 +126,8 @@ add_cursor(int lineno, struct connection *con,
 					const char *name,
 					int subxact_level,
 					bool with_hold,
-					enum ECPG_cursor_scroll scrollable)
+					enum ECPG_cursor_scroll scrollable,
+					long readahead)
 {
 	struct cursor_descriptor *desc, *prev;
 
@@ -125,6 +154,18 @@ add_cursor(int lineno, struct connection *con,
 	desc->subxact_level = subxact_level;
 	desc->with_hold = with_hold;
 	desc->scrollable = scrollable;
+	desc->res = NULL;
+	desc->readahead = readahead;
+	desc->backward = false;
+	desc->cache_start_pos = 0;
+	desc->atstart = true;
+	desc->atend = false;
+	desc->pos = 0;
+	desc->backend_atstart = true;
+	desc->backend_atend = false;
+	desc->backend_pos = 0;
+	desc->mkbpos = 0;
+	desc->mkbpos_is_last = false;
 
 	if (prev)
 	{
@@ -156,6 +197,7 @@ del_cursor(struct connection *con, int lineno, const char *name)
 			con->cursor_desc = desc->next;
 
 		ecpg_free((void *)desc->name);
+		PQclear(desc->res);
 		ecpg_free(desc);
 	}
 }
@@ -195,6 +237,7 @@ ecpg_commit_cursors(int lineno, struct connection * conn,
 			{
 				tmp = desc->next;
 				ecpg_free(desc->name);
+				PQclear(desc->res);
 				ecpg_free(desc);
 				desc = tmp;
 				if (prev)
@@ -223,6 +266,7 @@ ecpg_commit_cursors(int lineno, struct connection * conn,
 			{
 				tmp = desc->next;
 				ecpg_free(desc->name);
+				PQclear(desc->res);
 				ecpg_free(desc);
 				desc = tmp;
 				if (prev)
@@ -238,33 +282,80 @@ ecpg_commit_cursors(int lineno, struct connection * conn,
 }
 
 /*
- * Declare the cursor in the backend and create a
- * minimalistic descriptor to make tracking possible.
+ * Declare the cursor in the backend and create a descriptor to make tracking
+ * and cursor readahead possible.
+ *
  * This function is called when the ECPG code OPENs the cursor.
  */
 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 char *curname, const int st, const char *query, ...)
 {
 	struct connection *con = ecpg_get_connection(connection_name);
+	struct statement *stmt;
+	char	   *cmdstatus;
 	int		subxact_level;
-	bool		ret;
 	va_list		args;
 
+	if (curname == NULL)
+	{
+		ecpg_raise(lineno, ECPG_INVALID_CURSOR, ECPG_SQLSTATE_INVALID_CURSOR_NAME, ecpg_gettext("<empty>"));
+		con->client_side_error = true;
+		return false;
+	}
+
+	if (scrollable == ECPGcs_unspecified || readahead < 1)
+	{
+		ecpg_raise(lineno, ECPG_INVALID_CURSOR, ECPG_SQLSTATE_INVALID_CURSOR_STATE, curname);
+		con->client_side_error = true;
+		return false;
+	}
+
 	/*
 	 * Execute the DECLARE query in the backend.
 	 */
 	va_start(args, query);
-	ret = ecpg_do(lineno, compat, force_indicator, connection_name, questionmarks,
-										st,
-										query,
-										args);
+
+	if (!ecpg_do_prologue(lineno, compat, force_indicator,
+				connection_name, questionmarks,
+				(enum ECPG_statement_type) st,
+				query, args, &stmt))
+	{
+		ecpg_do_epilogue(stmt);
+		va_end(args);
+		return false;
+	}
+
 	va_end(args);
 
-	if (!ret)
+	if (!ecpg_build_params(stmt, false))
+	{
+		ecpg_do_epilogue(stmt);
+		return false;
+	}
+
+	if (!ecpg_autostart_transaction(stmt))
+	{
+		ecpg_do_epilogue(stmt);
+		return false;
+	}
+
+	if (!ecpg_execute(stmt))
+	{
+		ecpg_do_epilogue(stmt);
+		return false;
+	}
+
+	if (!ecpg_process_output(stmt, 0, PQntuples(stmt->results), LOOP_FORWARD, 0, true, false))
+	{
+		ecpg_do_epilogue(stmt);
 		return false;
+	}
+
+	ecpg_do_epilogue(stmt);
 
 	/* Finally add the cursor to the connection. */
 	if (con->subxact_desc)
@@ -273,7 +364,7 @@ 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);
+	add_cursor(lineno, con, curname, subxact_level, with_hold, scrollable, readahead);
 
 	return true;
 }
@@ -324,9 +415,9 @@ ecpg_canonical_cursor_movement(enum ECPG_cursor_direction *direction, const char
 
 	/*
 	 * Canonicalize ECPGc_backward but don't lose
-	 * FETCH BACKWARD ALL semantics.
+	 * FETCH BACKWARD ALL and FETCH BACKWARD 0 semantics.
 	 */
-	if ((*fetchall == false) && (*direction == ECPGc_backward))
+	if ((*fetchall == false) && (amount != 0) && (*direction == ECPGc_backward))
 	{
 		amount1 = -amount1;
 		*direction = ECPGc_forward;
@@ -337,121 +428,1513 @@ ecpg_canonical_cursor_movement(enum ECPG_cursor_direction *direction, const char
 }
 
 /*
- * ECPGfetch
- * Execute a FETCH or MOVE statement for the application.
- *
- * This function maintains the internal cursor descriptor and
- * reduces the the network roundtrip by:
- * - returning early for an unknown cursor name
- * - checking whether the cursor is scrollable against the direction
+ * ecpg_cursor_do_move_all
  */
-bool
-ECPGfetch(const int lineno, const int compat, const int force_indicator,
-				const char *connection_name, const bool questionmarks,
-				enum ECPG_cursor_direction dir, const char *amount,
-				const char *curname, const int st, const char *query, ...)
+static bool
+ecpg_cursor_do_move_all(struct statement *stmt, struct cursor_descriptor *cur,
+					enum ECPG_cursor_direction direction,
+					int64 *ntuples)
 {
-	struct connection  *con = ecpg_get_connection(connection_name);
-	struct cursor_descriptor *cur;
-	struct statement   *stmt;
-	int64		amount1;
-	bool		fetchall;
-	bool		ret;
-	va_list		args;
+	bool		error;
+	char	   *cmdstatus;
 
-	if (!find_cursor(con, lineno, curname, false, &cur, NULL))
-		return false;
+	if ((direction == ECPGc_forward && cur->backend_atend) ||
+		(direction == ECPGc_backward && cur->backend_atstart))
+	{
+		*ntuples = llabs(cur->backend_pos - cur->pos) - 1;
+		return true;
+	}
 
-	va_start(args, query);
+	ecpg_free(stmt->command);
 
-	if (!ecpg_do_prologue(lineno, compat, force_indicator,
-				connection_name, questionmarks,
-				(enum ECPG_statement_type) st,
-				query, args, &stmt))
-	{
-		ecpg_do_epilogue(stmt);
-		va_end(args);
+	stmt->command = ecpg_alloc(strlen(cur->name) + 24, stmt->lineno);
+	if (stmt->command == NULL)
 		return false;
-	}
+	sprintf(stmt->command, "move %s all in %s", ecpg_cursor_direction_sql_name[direction], cur->name);
 
-	va_end(args);
+	if (!ecpg_execute(stmt))
+		return false;
 
-	if (!ecpg_build_params(stmt, (dir >= ECPGc_absolute_in_var)))
-	{
-		ecpg_do_epilogue(stmt);
+	cmdstatus = PQcmdStatus(stmt->results);
+	*ntuples = atol(cmdstatus + 5);
+
+	PQclear(stmt->results);
+	stmt->results = NULL;
+
+	ecpg_cursor_next_pos(stmt, cur, direction, false, 0, true, ntuples,
+				&cur->pos, &cur->atstart, &cur->atend, &error, NULL);
+	cur->backend_pos = cur->pos;
+	cur->backend_atstart = cur->atstart;
+	cur->backend_atend = cur->atend;
+
+	return true;
+}
+
+/*
+ * ecpg_cursor_do_move_absolute
+ *
+ * Called in case of uncertainty to exactly track the
+ * cursor position in the backend.
+ *
+ * Only called for nonzero "amount" values.
+ */
+static bool
+ecpg_cursor_do_move_absolute(struct statement *stmt, struct cursor_descriptor *cur,
+					int64 amount, int64 *return_pos)
+{
+	char		amount_s[64];
+	bool		error;
+	char	   *cmdstatus;
+	long		have_tuple;
+
+	ecpg_free(stmt->command);
+
+	sprintf(amount_s, "%lld", (long long)amount);
+	stmt->command = ecpg_alloc(strlen(amount_s) + strlen(cur->name) + 20, stmt->lineno);
+	if (stmt->command == NULL)
 		return false;
-	}
+	sprintf(stmt->command, "move absolute %s in %s", amount_s, cur->name);
 
-	if (dir >= ECPGc_absolute_in_var)
+	if (!ecpg_execute(stmt))
+		return false;
+
+	cmdstatus = PQcmdStatus(stmt->results);
+	*return_pos = have_tuple = (cmdstatus[5] == '1');
+
+	PQclear(stmt->results);
+	stmt->results = NULL;
+
+	ecpg_cursor_next_pos(stmt, cur, ECPGc_absolute, false, amount, false, &have_tuple,
+				&cur->pos, &cur->atstart, &cur->atend, &error, NULL);
+
+	cur->backend_pos = cur->pos;
+	cur->backend_atstart = cur->atstart;
+	cur->backend_atend = cur->atend;
+
+	return true;
+}
+
+/*
+ * ecpg_cursor_do_move_relative
+ *
+ * Called in case of uncertainty to exactly track the
+ * cursor position in the backend.
+ *
+ * Only called for nonzero "amount" values.
+ */
+static bool
+ecpg_cursor_do_move_relative(struct statement *stmt, struct cursor_descriptor *cur,
+					int64 amount, int64 *return_pos)
+{
+	char		amount_s[64];
+	bool		error;
+	char	   *cmdstatus;
+	long		have_tuple;
+
+	if (cur->pos != cur->backend_pos)
 	{
-		dir -= ECPGc_absolute_in_var;
-		amount = stmt->cursor_amount;
+		if (cur->atend)
+		{
+			if (!ecpg_cursor_do_move_all(stmt, cur, ECPGc_forward, return_pos))
+				return false;
+		}
+		else if (cur->atstart)
+		{
+			if (!ecpg_cursor_do_move_all(stmt, cur, ECPGc_backward, return_pos))
+				return false;
+		}
+		else
+		{
+			if (!ecpg_cursor_do_move_absolute(stmt, cur, cur->pos, return_pos))
+				return false;
+		}
 	}
 
-	if (!ecpg_canonical_cursor_movement(&dir, amount, &fetchall, &amount1))
-	{
-		ecpg_do_epilogue(stmt);
-		ecpg_raise(lineno, ECPG_NUMERIC_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, amount);
-		con->client_side_error = true;
+	ecpg_free(stmt->command);
+
+	sprintf(amount_s, "%lld", (long long)amount);
+	stmt->command = ecpg_alloc(strlen(amount_s) + strlen(cur->name) + 20, stmt->lineno);
+	if (stmt->command == NULL)
 		return false;
-	}
+	sprintf(stmt->command, "move relative %s in %s", amount_s, cur->name);
 
-	if (cur->scrollable == ECPGcs_no_scroll && (amount1 < 0 || dir == ECPGc_backward))
-	{
-		ecpg_do_epilogue(stmt);
-		ecpg_raise(lineno, ECPG_NUMERIC_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, amount);
-		con->client_side_error = true;
+	if (!ecpg_execute(stmt))
 		return false;
-	}
 
-	if (!ecpg_autostart_transaction(stmt))
+	cmdstatus = PQcmdStatus(stmt->results);
+	*return_pos = have_tuple = (cmdstatus[5] == '1');
+
+	PQclear(stmt->results);
+	stmt->results = NULL;
+
+	ecpg_cursor_next_pos(stmt, cur, ECPGc_relative, false, amount, false, &have_tuple,
+				&cur->pos, &cur->atstart, &cur->atend, &error, NULL);
+
+	cur->backend_pos = cur->pos;
+	cur->backend_atstart = cur->atstart;
+	cur->backend_atend = cur->atend;
+
+	return true;
+}
+
+/*
+ * ecpg_cursor_do_move_forward
+ *
+ * Called in case of uncertainty to exactly track the
+ * cursor position in the backend.
+ *
+ * Only called for nonzero "amount" values.
+ */
+static bool
+ecpg_cursor_do_move_forward(struct statement *stmt, struct cursor_descriptor *cur,
+					int64 amount, int64 *return_pos)
+{
+	char		amount_s[64];
+	bool		error;
+	char	   *cmdstatus;
+	long		ntuples;
+
+	if (cur->pos != cur->backend_pos)
 	{
-		ecpg_do_epilogue(stmt);
-		return false;
+		if (cur->atend)
+		{
+			if (!ecpg_cursor_do_move_all(stmt, cur, ECPGc_forward, return_pos))
+				return false;
+		}
+		else if (cur->atstart)
+		{
+			if (!ecpg_cursor_do_move_all(stmt, cur, ECPGc_backward, return_pos))
+				return false;
+		}
+		else
+		{
+			if (!ecpg_cursor_do_move_absolute(stmt, cur, cur->pos, return_pos))
+				return false;
+		}
 	}
 
+	ecpg_free(stmt->command);
+
+	sprintf(amount_s, "%lld", (long long)amount);
+	stmt->command = ecpg_alloc(strlen(amount_s) + strlen(cur->name) + 20, stmt->lineno);
+	if (stmt->command == NULL)
+		return false;
+	sprintf(stmt->command, "move forward %s in %s", amount_s, cur->name);
+
 	if (!ecpg_execute(stmt))
-	{
-		ecpg_do_epilogue(stmt);
 		return false;
-	}
 
-	if (!ecpg_process_output(stmt, 0, PQntuples(stmt->results), LOOP_FORWARD, 0, true, false))
+	cmdstatus = PQcmdStatus(stmt->results);
+	*return_pos = ntuples = atol(cmdstatus + 5);
+
+	ecpg_cursor_next_pos(stmt, cur, ECPGc_forward, false, amount, false, &ntuples,
+				&cur->pos, &cur->atstart, &cur->atend, &error, NULL);
+
+	cur->backend_pos = cur->pos;
+	cur->backend_atstart = cur->atstart;
+	cur->backend_atend = cur->atend;
+
+	return true;
+}
+
+/*
+ * ecpg_cursor_negate_position
+ *
+ * If the number of tuples is already known for the whole
+ * result set, recompute the specified position so it's
+ * numeric sign matches the current cur->pos.
+ */
+static void
+ecpg_cursor_negate_position(struct cursor_descriptor *cur, int64 *pos)
+{
+	if (cur->mkbpos_is_last)
 	{
-		ecpg_do_epilogue(stmt);
-		return false;
-	}
+		int64		lpos = *pos;
 
-	ecpg_do_epilogue(stmt);
+		if ((cur->pos < 0 || (cur->atend  && cur->pos == 0)) && lpos > 0)
+			lpos = lpos - cur->mkbpos - 1;
+		else if ((cur->pos > 0 || (cur->atstart && cur->pos == 0)) && lpos < 0)
+			lpos = lpos + cur->mkbpos + 1;
 
-	return ret;
+		*pos = lpos;
+	}
 }
 
 /*
- * ECPGcursor_dml
- * Called for DELETE / UPDATE ... WHERE CURRENT OF cursorname
+ * ecpg_cursor_move
+ *
+ * Save network turnaround of MOVE statements as much as possible.
+ *
+ * Compute the cursor position here for the application instead and send a
+ * MOVE ABSOLUTE to the server before the first FETCH in ecpg_cursor_execute()
+ * in case the cursor position known by the server and the application are
+ * different.
+ *
+ * At all times, cur->pos and cur->backend_pos are assumed to use the same
+ * sign (both are either >=0 or <=0) and end up having the same sign at the
+ * end.
+ *
+ * Also, cur->atstart and cur->atend is assumed to be correctly set and
+ * end up to be correctly set.
+ *
+ * Having any of cur->atstart and cur->atend set while the size of
+ * the cursor result set is unknown at the start of implies cur->pos == 0
+ * and ends up so.
+ *
+ * Any shortcut taken means the cur->pos will deviate from cur->backend_pos
+ * and possibly a MOVE statement is saved.
  */
-bool
-ECPGcursor_dml(const int lineno, const int compat, const int force_indicator,
-				const char *connection_name, const bool questionmarks,
-				const char *curname, const int st, const char *query, ...)
+static bool
+ecpg_cursor_move(struct statement *stmt, struct cursor_descriptor *cur,
+					enum ECPG_cursor_direction direction,
+					int64 amount, bool fetchall,
+					bool do_override)
 {
-	struct connection  *con = ecpg_get_connection(connection_name);
-	struct cursor_descriptor *cur;
-	bool		ret;
-	va_list		args;
+	struct sqlca_t *sqlca = ECPGget_sqlca();
+	bool		next_atstart, next_atend, error, beyond_known;
+	int64		next_pos;
+	int64		return_pos = 0;
 
-	if (!find_cursor(con, lineno, curname, false, &cur, NULL))
+	sqlca->sqlerrd[2] = 0;
+
+	switch (direction)
+	{
+	case ECPGc_absolute:
+		return_pos = -1;
+		if (ecpg_cursor_next_pos(stmt, cur, direction, false,
+					 amount, fetchall, &return_pos,
+					 &next_pos, &next_atstart, &next_atend,
+					 &error, &beyond_known))
+		{
+			if (error)
+				return false;
+
+			if (!beyond_known)
+			{
+				cur->pos = next_pos;
+				cur->atstart = next_atstart;
+				cur->atend = next_atend;
+				break;
+			}
+		}
+
+		/*
+		 * The application moves beyond the currently known
+		 * last position, discovery cannot be avoided
+		 * in order to exactly track the cursor position.
+		 */
+		if (!ecpg_cursor_do_move_absolute(stmt, cur, amount, &return_pos))
+			return false;
+
+		break;
+
+	case ECPGc_relative:
+		return_pos = -1;
+		if (ecpg_cursor_next_pos(stmt, cur, direction, false,
+					 amount, fetchall, &return_pos,
+					 &next_pos, &next_atstart, &next_atend,
+					 &error, &beyond_known))
+		{
+			if (error)
+				return false;
+
+			if (!beyond_known)
+			{
+				cur->pos = next_pos;
+				cur->atstart = next_atstart;
+				cur->atend = next_atend;
+				break;
+			}
+		}
+
+		/*
+		 * The application moves beyond the currently known
+		 * last position, discovery cannot be avoided
+		 * in order to exactly track the cursor position.
+		 */
+		if (!ecpg_cursor_do_move_relative(stmt, cur, amount, &return_pos))
+			return false;
+
+		break;
+
+	case ECPGc_forward:
+	case ECPGc_backward:
+		/*
+		 * Handle all of MOVE [BACKWARD|FORWARD] ALL cases here.
+		 *
+		 * After canonicalization, ECPGc_backward shows up only
+		 * when BACKWARD ALL/BACKWARD 0 was specified.
+		 *
+		 * MOVE BACKWARD ALL is allowed for NO SCROLL cursors,
+		 * it simply restarts the scanning.
+		 */
+
+		return_pos = -1;
+		if (ecpg_cursor_next_pos(stmt, cur, direction, false,
+					 amount, fetchall, &return_pos,
+					 &next_pos, &next_atstart, &next_atend,
+					 &error, &beyond_known))
+		{
+			if (error)
+				return false;
+
+			if (!beyond_known)
+			{
+				cur->pos = next_pos;
+				cur->atstart = next_atstart;
+				cur->atend = next_atend;
+				break;
+			}
+		}
+
+
+		/*
+		 * Use this opportunity to discover the size of the
+		 * result set.
+		 */
+		if (fetchall)
+		{
+			if (!ecpg_cursor_do_move_all(stmt, cur, direction, &return_pos))
+				return false;
+		}
+		else
+		{
+			if (!ecpg_cursor_do_move_forward(stmt, cur, amount, &return_pos))
+				return false;
+		}
+
+		break;
+
+	default:
+		/*
+		 * The ECPGc_*_in_var variants cannot occur here.
+		 */
+		ecpg_raise(stmt->lineno, ECPG_INVALID_CURSOR,
+					ECPG_SQLSTATE_ECPG_INTERNAL_ERROR,
+					NULL);
 		return false;
+	}
+
+	sqlca->sqlerrd[2] = (return_pos <= LONG_MAX ? return_pos : 0);
+
+	ecpg_cursor_negate_position(cur, &cur->backend_pos);
+	ecpg_cursor_negate_position(cur, &cur->cache_start_pos);
+
+	return true;
+}
+
+/*
+ * ecpg_cursor_execute
+ * Execute the next FETCH statement if needed.
+ * 
+ */
+static bool
+ecpg_cursor_execute(struct statement * stmt, struct cursor_descriptor *cur,
+					bool backward, int64 next_pos,
+					bool next_atstart, bool next_atend)
+{
+	bool		do_fetch = true;
+	int		step;
+
+	/*
+	 * The application have fallen off the cursors's result set,
+	 * in which the number of tuples is an integer multiple of
+	 * the readahead window size (or the application started to
+	 * read from a position that the cache ended up empty.
+	 * Don't read any further and don't count it as a cache-miss
+	 * either.
+	 */
+	if (next_atstart && backward)
+		do_fetch = false;
+	else if (next_atend && !backward)
+		do_fetch = false;
+	else if (cur->res != NULL)
+	{
+		int		ntuples = PQntuples(cur->res);
+
+		/*
+		 * Check the conditions when the cache has to be filled
+		 * up by a new FETCH command.
+		 */
+		ecpg_cursor_negate_position(cur, &cur->cache_start_pos);
+		ecpg_cursor_negate_position(cur, &cur->backend_pos);
+
+		/*
+		 * If the numeric sign of cur->cache_start_pos matches cur->pos,
+		 * the next tuple may already be in the cache.
+		 */
+		if ( ((next_pos < 0 || (next_atend  && next_pos == 0)) && cur->cache_start_pos < 0) ||
+		     ((next_pos > 0 || (next_atstart && next_pos == 0)) && cur->cache_start_pos > 0) )
+		{
+			int64		start_pos, end_pos;
+
+			if (cur->backward)
+			{
+				start_pos = cur->cache_start_pos - ntuples + 1;
+				end_pos = cur->cache_start_pos;
+			}
+			else
+			{
+				start_pos = cur->cache_start_pos;
+				end_pos = cur->cache_start_pos + ntuples - 1;
+			}
+
+			if ((start_pos <= next_pos) && (next_pos <= end_pos))
+			{
+				/*
+				 * The next tuple to be fetched is in the cache.
+				 */
+				do_fetch = false;
+			}
+			else if ((ntuples > 0) && (ntuples < cur->readahead) && (backward == cur->backward) &&
+				((((next_pos < 0) || next_atend) && (next_pos < start_pos)) ||
+				 (((next_pos > 0) || next_atstart) && (next_pos > end_pos))))
+			{
+				/*
+				 * The next tuple to be fetched is over the cache and
+				 * the cache is already at the edge of the result set.
+				 */
+				do_fetch = false;
+			}
+		}
+	}
+
+	if (do_fetch)
+	{
+		int		ntuples;
+		char		amount[64];
+
+		if (cur->pos != cur->backend_pos)
+		{
+			int64		return_pos;
+
+			if (cur->pos == 0 && cur->atend)
+			{
+				if (!ecpg_cursor_do_move_all(stmt, cur, ECPGc_forward, &return_pos))
+					return false;
+			}
+			else
+			{
+				if (!ecpg_cursor_do_move_absolute(stmt, cur, cur->pos, &return_pos))
+					return false;
+			}
+		}
+
+		ecpg_free(stmt->command);
+
+		sprintf(amount, "%lld", (long long)cur->readahead);
+		stmt->command = ecpg_alloc(strlen(amount) + strlen(cur->name) + 24, stmt->lineno);
+		if (stmt->command == NULL)
+			return false;
+		sprintf(stmt->command, "fetch %s %s from %s",
+						(backward ? "backward" : "forward"),
+						amount, cur->name);
+
+		PQclear(cur->res);
+
+		if (!ecpg_execute(stmt))
+			return false;
+
+		cur->res = stmt->results;
+
+		ntuples = PQntuples(cur->res);
+
+		ecpg_log("ecpg_cursor_execute on line %d: command %s; returned %d tuples\n",
+				stmt->lineno, stmt->command, ntuples);
+
+		step = (backward ? -1 : 1);
+		if ((cur->backend_atstart && backward) || (cur->backend_atend && !backward))
+			cur->cache_start_pos = cur->backend_pos;
+		else
+			cur->cache_start_pos = cur->backend_pos + step;
+		cur->backward = backward;
+		cur->backend_pos += ntuples * step;
+
+		if (llabs(cur->backend_pos) >= cur->mkbpos)
+			cur->mkbpos = llabs(cur->backend_pos);
+		if (ntuples < cur->readahead)
+		{
+			/*
+			 * The cursor has moved to the start or the end:
+			 * backend_pos will be either 0 or
+			 * +/- (PQntuples(whole_results_set)+1)
+			 * In the latter case we can adjust the maximum known
+			 * backend position and mark it as the last.
+			 */
+			cur->mkbpos_is_last = true;
+
+			/* But don't go over zero. */
+			if (cur->backend_pos != 0)
+				cur->backend_pos += step;
+
+			cur->backend_atstart = backward;
+			cur->backend_atend = !backward;
+		}
+		else
+		{
+			cur->backend_atstart = false;
+			cur->backend_atend = false;
+		}
+
+		cur->cache_miss++;
+	}
+	else
+	{
+		stmt->results = cur->res;
+		cur->cache_miss = 0;
+		ecpg_log("ecpg_cursor_execute on line %d: tuple already in cache\n",
+							stmt->lineno);
+	}
+
+	return true;
+}
+
+/*
+ * ecpg_cursor_next_pos
+ * The big unified function to get the next cursor position.
+ *
+ * Early processing checks for NO SCROLL cursor and returns true
+ * together with *error = true, raising the proper ECPG error.
+ *
+ * Possible values of *qresult:
+ * -1:
+ *	Unknown. Set the position if the range is already known.
+ *	Return true and set *qresult relative to cur->pos if the range
+ *	is already known.
+ * 0 and up:
+ *	*qresult was returned by a actual query sent to the server.
+ *	Set the new position according to it. *qresult may be
+ *	modified if the cur->pos and cur->backend_pos are different.
+ *	Return unconditionally false in this case
+ * Also return false for invalid "direction" values (which cannot happen).
+ */
+static bool
+ecpg_cursor_next_pos(struct statement *stmt, struct cursor_descriptor *cur,
+			enum ECPG_cursor_direction direction, bool fetch,
+			int64 amount, bool fetchall, long *qresult,
+			int64 *next_pos_out, bool *next_atstart_out,
+			bool *next_atend_out, bool *error, bool *beyond_known)
+{
+	int64		wanted_pos, next_pos, fetchall_step = 0;
+	long		lresult = *qresult;
+	bool		next_atstart, next_atend;
+	bool		edge_on_backward, edge_on_forward;
+
+	if (qresult)
+		*qresult = -1; /* invalid value */
+	if (error)
+		*error = false;
+	if (beyond_known)
+		*beyond_known = false;
+
+	if (cur->scrollable == ECPGcs_no_scroll)
+	{
+		if ((amount < 0) ||
+			(fetch && amount == 0 && direction == ECPGc_backward))
+		{
+			ecpg_raise(stmt->lineno, ECPG_INVALID_CURSOR,
+						ECPG_SQLSTATE_OBJECT_NOT_IN_PREREQUISITE_STATE,
+						cur->name);
+			stmt->connection->client_side_error = true;
+			if (error)
+				*error = true;
+			return true;
+		}
+	}
+
+	next_atstart = next_atend = false;
+	edge_on_backward = edge_on_forward = false;
+
+	switch (direction)
+	{
+	case ECPGc_absolute:
+		wanted_pos = amount;
+		next_atstart = (amount == 0);
+		break;
+
+	case ECPGc_backward:
+		/*
+		 * ECPGc_backward must only occur with BACKWARD ALL.
+		 * Anyway, report the error and do the sensible thing.
+		 */
+		if (!fetchall)
+		{
+			direction = ECPGc_forward;
+			amount = -amount;
+		}
+		/* Fall though. */
+
+	case ECPGc_forward:
+	case ECPGc_relative:
+		if (direction == ECPGc_relative)
+		{
+			if (lresult == 0)
+			{
+				if (amount < 0)
+				{
+					wanted_pos = 0;
+					next_atstart = true;
+					next_atend = false;
+					edge_on_backward = true;
+				}
+				else if (amount > 0)
+				{
+					wanted_pos = 0;
+					next_atstart = false;
+					next_atend = true;
+					edge_on_forward = true;
+				}
+				else
+				{
+					wanted_pos = cur->pos;
+					next_atstart = cur->atstart;
+					next_atend = cur->atend;
+				}
+			}
+			else
+				wanted_pos = cur->pos + amount;
+		}
+		else if (fetchall)
+		{
+			fetchall_step = (direction == ECPGc_backward ? -1 : 1);
+			if (lresult >= 0)
+				wanted_pos = cur->backend_pos + fetchall_step * (lresult + 1);
+			else
+				wanted_pos = cur->pos + amount;
+		}
+		else
+		{
+			if (lresult >= 0)
+			{
+				if (amount > 0)
+					fetchall_step = 1;
+				else if (amount < 0)
+					fetchall_step = -1;
+				else
+					fetchall_step = 0;
+
+				wanted_pos = cur->pos + fetchall_step * lresult;
+				if (llabs(amount) > lresult)
+				{
+					wanted_pos += fetchall_step;
+					if (amount < 0)
+						edge_on_backward = next_atstart = true;
+					else if (amount > 0)
+						edge_on_forward = next_atend = true;
+				}
+			}
+			else
+				wanted_pos = cur->pos + amount;
+		}
+
+		if (!edge_on_forward && !edge_on_backward)
+		{
+			/* Truncate if wanted_pos crossed over zero. */
+			if ((cur->pos < 0 || (cur->pos == 0 && cur->atend)) && wanted_pos >= 0)
+			{
+				wanted_pos = 0;
+				next_atstart = false;
+				next_atend = true;
+				edge_on_forward = true;
+			}
+			else if ((cur->pos > 0 || (cur->pos == 0 && cur->atstart)) && wanted_pos <= 0)
+			{
+				wanted_pos = 0;
+				next_atstart = true;
+				next_atend = false;
+				edge_on_backward = true;
+			}
+		}
+
+		break;
+
+	default:
+		/* cannot happen */
+		if (error)
+			*error = true;
+		return true;
+	}
+
+	if (lresult == -1)
+	{
+		if (cur->mkbpos_is_last && (fetchall || (llabs(wanted_pos) > cur->mkbpos)))
+		{
+			bool		negative;
+
+			/*
+			 * The size of the result set is already known and the
+			 * command wants to position the cursor beyond it.
+			 * The position can be set exactly without executing
+			 * the query.
+			 */
+
+			/* empty result set */
+			if (cur->mkbpos == 0)
+			{
+				*qresult = 0;
+				*next_pos_out = 0;
+				*next_atstart_out = true;
+				*next_atend_out = true;
+				
+				return true;
+			}
+
+			negative = (amount < 0) || (direction == ECPGc_backward);
+
+			switch (direction)
+			{
+			case ECPGc_relative:
+				*qresult = 0;
+				break;
+
+			case ECPGc_absolute:
+				*qresult = 0;
+				break;
+
+			case ECPGc_forward:
+				if (cur->atstart)
+					*qresult = cur->mkbpos;
+				else if (cur->atend)
+					*qresult = 0;
+				else if (cur->pos < 0)
+					*qresult = -cur->pos - 1;
+				else
+				{
+					/*
+					 * cur->pos > 0 here because both
+					 * cur->atstart and cur->atend are
+					 * false
+					 */
+					if (cur->pos == cur->mkbpos)
+						*qresult = 0;
+					else
+						*qresult = cur->mkbpos - cur->pos;
+				}
+				break;
+
+			case ECPGc_backward:
+				if (cur->atstart)
+					*qresult = 0;
+				else if (cur->atend)
+					*qresult = cur->mkbpos;
+				else if (cur->pos > 0)
+					*qresult = cur->pos - 1;
+				else
+				{
+					/*
+					 * cur->pos < 0 here because both
+					 * cur->atstart and cur->atend are
+					 * false
+					 */
+					if (-cur->pos == cur->mkbpos)
+						*qresult = 0;
+					else
+						*qresult = cur->mkbpos + cur->pos;
+				}
+				break;
+
+			default:
+				/* cannot happen */
+				*qresult = 0;
+				return false;
+			}
+
+			*next_pos_out = (negative ? -1 : 1) * (cur->mkbpos + 1);
+			*next_atstart_out = negative;
+			*next_atend_out = !negative;
+
+			return true;
+		}
+
+		/*
+		 * The size of the result set is unknown at this point.
+		 */
+		if (fetchall)
+		{
+			if ((cur->pos < 0 || cur->atend) && direction == ECPGc_forward)
+			{
+				/*
+				 * The cursor is positioned in negative terms or is
+				 * already at the end and the application wants to
+				 * go back to the end.
+				 */
+				*qresult = (cur->atend ? 0 : -cur->pos);
+				*next_pos_out = 0;
+				*next_atstart_out = false;
+				*next_atend_out = true;
+
+				return true;
+			}
+
+			if ((cur->pos > 0 || cur->atstart) && direction == ECPGc_backward)
+			{
+				/*
+				 * The cursor is positioned in positive terms or is
+				 * already at the beginning and the application wants
+				 * to go back to the beginning: shortcut.
+				 */
+				*qresult = (cur->atstart ? 0 : cur->pos);
+				*next_pos_out = 0;
+				*next_atstart_out = true;
+				*next_atend_out = false;
+
+				return true;
+			}
+
+		}
+
+		if (!fetchall && llabs(wanted_pos) <= cur->mkbpos)
+		{
+			/*
+			 * If the absolute value of the new position is less than or
+			 * equal to the maximum known backend position then store the
+			 * new position as-is, even negative positions.
+			 */
+			switch (direction)
+			{
+			case ECPGc_absolute:
+				lresult = !next_atstart;
+				break;
+
+			case ECPGc_relative:
+				lresult = !(next_atstart || next_atend);
+				break;
+
+			case ECPGc_forward:
+				if (amount == 0)
+					lresult = !(cur->atstart || cur->atend);
+				else
+				{
+					if (edge_on_forward)
+						lresult = ((direction == ECPGc_relative || cur->pos == 0) ? 0 : -cur->pos - 1);
+					else if (edge_on_backward)
+						lresult = ((direction == ECPGc_relative || cur->pos == 0) ? 0 : cur->pos - 1);
+					else
+						lresult = llabs(amount);
+				}
+				break;
+			default:
+				/* cannot happen */
+				*qresult = 0;
+				return false;
+			}
+
+			*qresult = lresult;
+			*next_pos_out = wanted_pos;
+			*next_atstart_out = next_atstart;
+			*next_atend_out = next_atend;
+
+			return true;
+		}
+
+		*qresult = wanted_pos - cur->pos;
+		*next_pos_out = wanted_pos;
+		*next_atstart_out = next_atstart;
+		*next_atend_out = next_atend;
+		if (beyond_known)
+			*beyond_known = true;
+
+		return false;
+	}
+
+	if (wanted_pos != 0 && lresult == 0)
+	{
+		if ((wanted_pos > 0) && (wanted_pos == cur->mkbpos + 1))
+		{
+			cur->mkbpos_is_last = true;
+			next_pos = wanted_pos;
+		}
+		else if ((wanted_pos < 0) && (wanted_pos == -cur->mkbpos - 1))
+		{
+			cur->mkbpos_is_last = true;
+			next_pos = wanted_pos;
+		}
+		else
+			next_pos = 0;
+
+		if (wanted_pos < 0)
+		{
+			next_atstart = true;
+			next_atend = (cur->mkbpos_is_last && cur->mkbpos == 0);
+		}
+		else /* wanted_pos > 0 */
+		{
+			next_atstart = (cur->mkbpos_is_last && cur->mkbpos == 0);
+			next_atend = true;
+		}
+	}
+	else /* wanted_pos == 0 || result != 0 */
+	{
+		next_pos = wanted_pos;
+		if (edge_on_backward)
+		{
+			if (next_pos < 0)
+			{
+				cur->mkbpos_is_last = true;
+				cur->mkbpos = -next_pos - 1;
+			}
+		}
+		else if (edge_on_forward)
+		{
+			if (next_pos > 0)
+			{
+				cur->mkbpos_is_last = true;
+				cur->mkbpos = next_pos - 1;
+			}
+		}
+		else if (next_pos == 0)
+		{
+			next_atstart = true;
+			next_atend = (cur->mkbpos_is_last && cur->mkbpos == 0);
+		}
+		else
+		{
+			int64	last_pos;
+
+			if (fetchall)
+			{
+				last_pos = next_pos - fetchall_step;
+				next_atstart = (direction == ECPGc_backward);
+				next_atend = !next_atstart;
+			}
+			else
+			{
+				last_pos = next_pos;
+				next_atstart = false;
+				next_atend = false;
+			}
+
+			if (llabs(last_pos) > cur->mkbpos)
+				cur->mkbpos = llabs(last_pos);
+		}
+	}
+
+	if (fetchall)
+		*qresult = cur->backend_pos - cur->pos + lresult;
+	*next_pos_out = next_pos;
+	*next_atstart_out = next_atstart;
+	*next_atend_out = next_atend;
+
+	return false;
+}
+
+/*
+ * ecpg_cursor_fetch
+ * Return tuples to the application from local cache.
+ */
+static bool
+ecpg_cursor_fetch(struct statement *stmt, struct cursor_descriptor *cur,
+					enum ECPG_cursor_direction direction,
+					int64 amount, bool fetchall)
+{
+	struct sqlca_t *sqlca = ECPGget_sqlca();
+	bool		backward, next_atstart, next_atend, error, append;
+	long		ntuples;
+	int		step;
+	int64		prev_pos, next_pos, start_idx, var_index;
+
+	switch (direction)
+	{
+	case ECPGc_absolute:
+	case ECPGc_relative:
+abs_rel:
+
+		/*
+		 * If there were MAX_CACHE_MISS cache misses already, switch to
+		 * executing the FETCH ABSOLUTE/RELATIVE as is.
+		 */
+		if (cur->cache_miss >= MAX_CACHE_MISS)
+		{
+			if (cur->pos != cur->backend_pos && direction == ECPGc_relative)
+			{
+				char	   *oldquery;
+				int64		return_pos;
+
+				/*
+				 * Save the original command and prevent it from
+				 * being freed by ecpg_cursor_do_move_abs_or_rel().
+				 * Restore it afterwards.
+				 */
+				oldquery = stmt->command;
+				stmt->command = NULL;
+
+				ecpg_cursor_do_move_absolute(stmt, cur, cur->pos, &return_pos);
+
+				ecpg_free(stmt->command);
+				stmt->command = oldquery;
+			}
+
+			if (!ecpg_execute(stmt))
+				return false;
+
+			ntuples = PQntuples(stmt->results);
+			ecpg_cursor_next_pos(stmt, cur, direction, true,
+							amount, fetchall, &ntuples,
+							&cur->pos, &cur->atstart, &next_atend,
+							&error, NULL);
+			cur->backend_pos = cur->pos;
+			cur->backend_atstart = cur->atstart;
+			cur->backend_atend = next_atend;
+
+			if (!ecpg_process_output(stmt, 0, PQntuples(stmt->results), LOOP_FORWARD, 0, true, false))
+				return false;
+
+			return true;
+		}
+
+		/*
+		 * Override the statement with possibly executing two
+		 * statements: a MOVE (just before the wanted position)
+		 * and a FETCH that would possibly save us time by serving
+		 * the client from the cache later.
+		 */
+		if (amount > 0)
+		{
+			prev_pos = amount - 1;
+			step = 1;
+			backward = false;
+		}
+		else if (amount < 0)
+		{
+			prev_pos = amount + 1;
+			step = -1;
+			backward = true;
+		}
+		else
+		{
+			prev_pos = amount;
+			step = 0;
+			backward = (direction == ECPGc_relative);
+		}
+		if (direction == ECPGc_absolute && amount == -1)
+		{
+			direction = ECPGc_forward;
+			fetchall = true;
+		}
+
+		/*
+		 * Move the cursor's client side position to just before the
+		 * new start index of the cache.
+		 */
+		if (!ecpg_cursor_move(stmt, cur, direction, prev_pos, fetchall, true))
+		{
+			if ((cur->atstart && backward) || (cur->atend && !backward))
+			{
+				ecpg_raise(stmt->lineno, ECPG_NOT_FOUND, ECPG_SQLSTATE_NO_DATA, NULL);
+				return false;
+			}
+
+			return false;
+		}
+
+		ntuples = -1;
+		ecpg_cursor_next_pos(stmt, cur, ECPGc_relative, false, step, false, &ntuples,
+					&next_pos, &next_atstart, &next_atend, &error, NULL);
+		/*
+		 * Populate the cache
+		 */
+		if (!ecpg_cursor_execute(stmt, cur, backward,
+					next_pos, next_atstart, next_atend))
+			return false;
+
+		/*
+		 * Move the cursor's client side position to the originally
+		 * required one.
+		 */
+		if (!ecpg_cursor_move(stmt, cur, ECPGc_relative, step, false, true))
+			return false;
+
+		if (cur->atstart || cur->atend)
+		{
+			sqlca->sqlerrd[2] = 0;
+			ecpg_raise(stmt->lineno, ECPG_NOT_FOUND, ECPG_SQLSTATE_NO_DATA, NULL);
+			return false;
+		}
+
+		/*
+		 * If the first command-overriding code used MOVE ALL,
+		 * it's possible that cur->cache_start_pos is positive
+		 * and the cur->pos is negative. Let's make both
+		 * cur->cache_start_pos and cur->backend_pos match
+		 * cur->pos.
+		 */
+		if (backward && amount == -1)
+		{
+			ecpg_cursor_negate_position(cur, &cur->cache_start_pos);
+			ecpg_cursor_negate_position(cur, &cur->backend_pos);
+		}
+
+		start_idx = llabs(cur->cache_start_pos - cur->pos);
+
+		if (!ecpg_process_output(stmt, start_idx, 1, LOOP_FORWARD, 0, false, false))
+		{
+			sqlca->sqlerrd[2] = 0;
+			return false;
+		}
+		sqlca->sqlerrd[2] = 1;
+		break;
+
+	case ECPGc_backward:
+		/*
+		 * After canonicalization, BACKWARD occurs for
+		 * FETCH BACKWARD ALL or FETCH BACKWARD 0.
+		 * FETCH BACKWARD 0 fails for non-scrollable cursors,
+		 * otherwise fall through with turning making
+		 * BACKWARD 0 into FORWARD 0.
+		 */
+		if (amount == 0)
+		{
+			if (cur->scrollable == ECPGcs_no_scroll)
+			{
+				ecpg_raise(stmt->lineno, ECPG_INVALID_CURSOR,
+						ECPG_SQLSTATE_OBJECT_NOT_IN_PREREQUISITE_STATE,
+						cur->name);
+				stmt->connection->client_side_error = true;
+				return false;
+			}
+
+			direction = ECPGc_forward;
+		}
+
+	case ECPGc_forward:
+		if (!fetchall && amount == 0)
+		{
+			direction = ECPGc_relative;
+			goto abs_rel;
+		}
+
+		/*
+		 * The direction is backward if FETCH BACKWARD ALL
+		 * or the amount to fetch is negative.
+		 */
+		backward = ((direction == ECPGc_backward) || (amount < 0));
+		step = (backward ? LOOP_BACKWARD : LOOP_FORWARD);
+
+		var_index = 0;
+		append = false;
+		while (fetchall || (!fetchall && amount))
+		{
+			int		cache_step, output_step;
+			int64		next_pos, end_pos;
+			int64		cur_amount;
+
+			ntuples = -1;
+			ecpg_cursor_next_pos(stmt, cur, direction, true,
+						step, false, &ntuples,
+						&next_pos, &next_atstart, &next_atend,
+						&error, NULL);
+
+			if (!ecpg_cursor_execute(stmt, cur, backward,
+						next_pos, next_atstart, next_atend))
+				return false;
+
+			if (!ecpg_cursor_move(stmt, cur, ECPGc_forward, step, false, true))
+				return false;
+
+			if (cur->atstart || cur->atend)
+				break;
+
+			cache_step = (cur->backward ? LOOP_BACKWARD : LOOP_FORWARD);
+			output_step = (backward == cur->backward ? LOOP_FORWARD : LOOP_BACKWARD);
+
+			/*
+			 * After ecpg_cursor_execute(), the cache and cur->pos
+			 * numbering has the same numeric sign.
+			 */
+			start_idx = llabs(cur->cache_start_pos - cur->pos);
+			end_pos = cur->cache_start_pos + cache_step * (PQntuples(cur->res) - 1);
+
+			if (backward)
+			{
+				if (cur->backward)
+					cur_amount = cur->pos - end_pos + 1;
+				else
+					cur_amount = cur->pos - cur->cache_start_pos + 1;
+			}
+			else
+			{
+				if (cur->backward)
+					cur_amount = cur->cache_start_pos - cur->pos + 1;
+				else
+					cur_amount = end_pos  - cur->pos + 1;
+			}
+			if (!fetchall && cur_amount > llabs(amount))
+				cur_amount = llabs(amount);
+
+			if (!ecpg_process_output(stmt, start_idx, cur_amount, output_step, var_index, false, append))
+				return false;
+
+			if (!ecpg_cursor_move(stmt, cur, ECPGc_forward, step * (cur_amount - 1), false, true))
+				return false;
+			if (cur->atstart || cur->atend)
+				break;
+
+			var_index += cur_amount;
+			if (!fetchall)
+			{
+				if (backward)
+					amount += cur_amount;
+				else
+					amount -= cur_amount;
+			}
+
+			if (cur_amount > 1)
+				cur->cache_miss = 0;
+
+			append = true;
+		}
+
+		sqlca->sqlerrd[2] = (var_index <= LONG_MAX ? var_index : 0);
+
+		if (var_index == 0)
+		{
+			ecpg_raise(stmt->lineno, ECPG_NOT_FOUND, ECPG_SQLSTATE_NO_DATA, NULL);
+			return false;
+		}
+		break;
+
+	default:
+		/*
+		 * The ECPGc_*_in_var variants cannot occur here.
+		 */
+		ecpg_raise(stmt->lineno, ECPG_INVALID_CURSOR,
+					ECPG_SQLSTATE_ECPG_INTERNAL_ERROR,
+					NULL);
+		return false;
+	}
+
+	return true;
+}
+
+/*
+ * ECPGfetch
+ * Execute a FETCH or MOVE statement for the application.
+ *
+ * This function maintains the internal cursor descriptor and
+ * reduces the the network roundtrip by:
+ * - returning early for an unknown cursor name
+ * - checking whether the cursor is scrollable against the direction
+ */
+bool
+ECPGfetch(const int lineno, const int compat, const int force_indicator,
+				const char *connection_name, const bool questionmarks,
+				enum ECPG_cursor_direction dir, const char *amount, bool move,
+				const char *curname, const int st, const char *query, ...)
+{
+	struct connection  *con = ecpg_get_connection(connection_name);
+	struct cursor_descriptor *cur;
+	struct statement   *stmt;
+	int64		amount1;
+	bool		fetchall;
+	bool		ret;
+	va_list		args;
+
+	if (!find_cursor(con, lineno, curname, false, &cur, NULL))
+		return false;
+
+	va_start(args, query);
+
+	if (!ecpg_do_prologue(lineno, compat, force_indicator,
+				connection_name, questionmarks,
+				(enum ECPG_statement_type) st,
+				query, args, &stmt))
+	{
+		ecpg_do_epilogue(stmt);
+		va_end(args);
+		return false;
+	}
 
-	va_start(args, query);
-	ret = ecpg_do(lineno, compat, force_indicator, connection_name, questionmarks,
-									st, query, args);
 	va_end(args);
+
+	if (!ecpg_build_params(stmt, (dir >= ECPGc_absolute_in_var)))
+	{
+		ecpg_do_epilogue(stmt);
+		return false;
+	}
+
+	if (dir >= ECPGc_absolute_in_var)
+	{
+		dir -= ECPGc_absolute_in_var;
+		amount = stmt->cursor_amount;
+	}
+
+	if (!ecpg_canonical_cursor_movement(&dir, amount, &fetchall, &amount1))
+	{
+		ecpg_do_epilogue(stmt);
+		ecpg_raise(lineno, ECPG_NUMERIC_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, amount);
+		con->client_side_error = true;
+		return false;
+	}
+
+	if (cur->scrollable == ECPGcs_no_scroll && (amount1 < 0 || dir == ECPGc_backward))
+	{
+		ecpg_do_epilogue(stmt);
+		ecpg_raise(lineno, ECPG_INVALID_CURSOR, ECPG_SQLSTATE_OBJECT_NOT_IN_PREREQUISITE_STATE, curname);
+		con->client_side_error = true;
+		return false;
+	}
+
+	if (!ecpg_autostart_transaction(stmt))
+	{
+		ecpg_do_epilogue(stmt);
+		return false;
+	}
+
+	if (cur->readahead == 1)
+	{
+		/*
+		 * If there is no readahead, it's no use playing games
+		 * behind the application's back.
+		 */
+		if (!ecpg_execute(stmt))
+		{
+			ecpg_do_epilogue(stmt);
+			return false;
+		}
+
+		if (!ecpg_process_output(stmt, 0, PQntuples(stmt->results), LOOP_FORWARD, 0, true, false))
+		{
+			ecpg_do_epilogue(stmt);
+			return false;
+		}
+	}
+	else
+	{
+		ecpg_log("ECPGfetch on line %d: query: %s; fetch all: %d amount: %lld\n",
+							   lineno, query, fetchall, (long long)amount1);
+
+		/*
+		 * Make sure there are no query parameters.
+		 * This code overrides the statements coming from
+		 * the application with custom MOVE and FETCH statements.
+		 */
+		ecpg_free_params(stmt, true);
+
+		/*
+		 * There is no expected output from MOVE statements but process
+		 * it to detect excess arguments. ecpg_process_output() is called
+		 * from ecpg_cursor_execute().
+		 */
+		if (move)
+		{
+			if (!ecpg_cursor_move(stmt, cur, dir, amount1, fetchall, false))
+			{
+				ecpg_do_epilogue(stmt);
+				return false;
+			}
+			if (!ecpg_process_output(stmt, 0, PQntuples(stmt->results), LOOP_FORWARD, 0, true, false))
+			{
+				ecpg_do_epilogue(stmt);
+				return false;
+			}
+		}
+		else
+		{
+			if (!ecpg_cursor_fetch(stmt, cur, dir, amount1, fetchall))
+			{
+				ecpg_do_epilogue(stmt);
+				return false;
+			}
+		}
+	}
+
+	ecpg_do_epilogue(stmt);
+
 	return ret;
 }
 
 /*
+ * ECPGcursor_dml
+ * Called for DELETE / UPDATE ... WHERE CURRENT OF cursorname
+ */
+bool
+ECPGcursor_dml(const int lineno, const int compat, const int force_indicator,
+				const char *connection_name, const bool questionmarks,
+				const char *curname, const int st, const char *query, ...)
+{
+	struct connection  *con = ecpg_get_connection(connection_name);
+	struct cursor_descriptor *cur;
+	struct statement   *stmt;
+	va_list		args;
+
+	if (!find_cursor(con, lineno, curname, false, &cur, NULL))
+		return false;
+
+	va_start(args, query);
+
+	if (!ecpg_do_prologue(lineno, compat, force_indicator,
+				connection_name, questionmarks,
+				(enum ECPG_statement_type) st,
+				query, args, &stmt))
+	{
+		ecpg_do_epilogue(stmt);
+		return false;
+	}
+
+	va_end(args);
+
+	if (!ecpg_build_params(stmt, false))
+	{
+		ecpg_do_epilogue(stmt);
+		return false;
+	}
+
+	if (!ecpg_autostart_transaction(stmt))
+	{
+		ecpg_do_epilogue(stmt);
+		return false;
+	}
+
+	if (cur->pos != cur->backend_pos)
+	{
+		int64		ntuples;
+		char	   *oldquery;
+		bool		ret;
+
+		oldquery = stmt->command;
+		stmt->command = NULL;
+
+		if (cur->atstart)
+			ret = ecpg_cursor_do_move_absolute(stmt, cur, 0, &ntuples);
+		else if (cur->atend)
+			ret = ecpg_cursor_do_move_all(stmt, cur, ECPGc_forward, &ntuples);
+		else if (cur->scrollable == ECPGcs_scroll)
+		{
+			int64		diff = cur->pos - cur->backend_pos;
+
+			ret = ecpg_cursor_do_move_relative(stmt, cur, diff, &ntuples);
+		}
+		else
+			ret = ecpg_cursor_do_move_absolute(stmt, cur, cur->pos, &ntuples);
+
+		if (!ret)
+		{
+			ecpg_do_epilogue(stmt);
+			return false;
+		}
+
+		ecpg_free(stmt->command);
+		stmt->command = oldquery;
+	}
+
+	if (!ecpg_execute(stmt))
+	{
+		ecpg_do_epilogue(stmt);
+		return false;
+	}
+
+	if (!ecpg_process_output(stmt, 0, PQntuples(stmt->results), LOOP_FORWARD, 0, true, false))
+	{
+		ecpg_do_epilogue(stmt);
+		return false;
+	}
+
+	ecpg_do_epilogue(stmt);
+
+	return true;
+}
+
+/*
  * ECPGclose
  * Close and free a cursor.
  */
@@ -473,7 +1956,9 @@ ECPGclose(const int lineno, const int compat, const int force_indicator,
 									st, query, args);
 	va_end(args);
 
-	del_cursor(con, lineno, curname);
+	/* Only free the cursor structure if the command succeeded */
+	if (ret)
+		del_cursor(con, lineno, curname);
 
 	return ret;
 }
diff --git a/src/interfaces/ecpg/ecpglib/error.c b/src/interfaces/ecpg/ecpglib/error.c
index b5b5550..ad31345 100644
--- a/src/interfaces/ecpg/ecpglib/error.c
+++ b/src/interfaces/ecpg/ecpglib/error.c
@@ -197,8 +197,8 @@ ecpg_raise(int line, int code, const char *sqlstate, const char *str)
 			else
 			{
 				snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
-  			/*------
- 			   translator: this string will be truncated at 149 characters expanded.  */
+			/*------
+			   translator: this string will be truncated at 149 characters expanded.  */
 					 ecpg_gettext("error in transaction processing on line %d"), line);
 			}
 			break;
@@ -211,7 +211,14 @@ ecpg_raise(int line, int code, const char *sqlstate, const char *str)
 			break;
 
 		case ECPG_INVALID_CURSOR:
-			if (strcmp(sqlstate, ECPG_SQLSTATE_INVALID_CURSOR_NAME) == 0)
+			if (strcmp(sqlstate, ECPG_SQLSTATE_INVALID_CURSOR_STATE) == 0)
+			{
+				snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
+			/*------
+			   translator: this string will be truncated at 149 characters expanded.  */
+					 ecpg_gettext("invalid readahead window size for cursor \"%s\" on line %d"), str, line);
+			}
+			else if (strcmp(sqlstate, ECPG_SQLSTATE_INVALID_CURSOR_NAME) == 0)
 			{
 				snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
 			/*------
@@ -221,7 +228,7 @@ ecpg_raise(int line, int code, const char *sqlstate, const char *str)
 			else if (strcmp(sqlstate, ECPG_SQLSTATE_OBJECT_NOT_IN_PREREQUISITE_STATE) == 0)
 			{
 				snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
-			/*
+			/*------
 			   translator: this string will be truncated at 149 characters expanded.  */
 					 ecpg_gettext("cursor \"%s\" can only scan forward on line %d"), str, line);
 			}
diff --git a/src/interfaces/ecpg/ecpglib/execute.c b/src/interfaces/ecpg/ecpglib/execute.c
index 18e3461..5140e7d 100644
--- a/src/interfaces/ecpg/ecpglib/execute.c
+++ b/src/interfaces/ecpg/ecpglib/execute.c
@@ -15,6 +15,7 @@
 
 #define POSTGRES_ECPG_INTERNAL
 #include "postgres_fe.h"
+#include "libpq-fe.h"
 
 #include <locale.h>
 #include <float.h>
@@ -1093,6 +1094,8 @@ ecpg_free_params(struct statement *stmt, bool print)
 		ecpg_free(stmt->paramvalues[n]);
 	}
 	ecpg_free(stmt->paramvalues);
+	stmt->nparams = 0;
+	stmt->paramvalues = NULL;
 }
 
 
@@ -1524,6 +1527,12 @@ ecpg_process_output(struct statement * stmt, int start, int ntuples, int directi
 	PGnotify   *notify;
 	struct sqlca_t *sqlca = ECPGget_sqlca();
 
+	if (stmt->results == NULL)
+	{
+		ecpg_log("ecpg_process_output on line %d: stmt->results is NULL, ignoring\n", stmt->lineno);
+		return true;
+	}
+
 	var = stmt->outlist;
 	switch (PQresultStatus(stmt->results))
 	{
@@ -1581,8 +1590,26 @@ ecpg_process_output(struct statement * stmt, int start, int ntuples, int directi
 					{
 						if (desc->result)
 							PQclear(desc->result);
-						desc->result = stmt->results;
-						clear_result = false;
+						/*
+						 * Copy the SQL DESCRIPTOR's new results
+						 * from the current one. This allows data
+						 * in the descriptor to survive changes
+						 * in the cursor readahead cache and to
+						 * avoid overriding "clear_result".
+						 */
+						desc->result = PQcopyResult(stmt->results,
+										PG_COPYRES_ATTRS |
+										PG_COPYRES_TUPLES |
+										PG_COPYRES_EVENTS |
+										PG_COPYRES_NOTICEHOOKS);
+						if (desc->result == NULL)
+						{
+							ecpg_raise(stmt->lineno, ECPG_OUT_OF_MEMORY,
+										ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY,
+										NULL);
+							status = false;
+							break;
+						}
 						ecpg_log("ecpg_process_output on line %d: putting result (%d tuples) into descriptor %s\n",
 								 stmt->lineno, ntuples, (const char *) var->pointer);
 					}
diff --git a/src/interfaces/ecpg/ecpglib/extern.h b/src/interfaces/ecpg/ecpglib/extern.h
index bc54a84..612412f 100644
--- a/src/interfaces/ecpg/ecpglib/extern.h
+++ b/src/interfaces/ecpg/ecpglib/extern.h
@@ -31,6 +31,7 @@ enum ARRAY_TYPE
 
 #define LOOP_FORWARD	(1)
 #define LOOP_BACKWARD	(-1)
+#define MAX_CACHE_MISS	(3)
 
 /* A generic varchar type. */
 struct ECPGgeneric_varchar
@@ -100,6 +101,24 @@ struct cursor_descriptor {
 	int		subxact_level;
 	bool		with_hold;
 	enum ECPG_cursor_scroll scrollable;
+
+	PGresult   *res;
+	long		readahead;
+	int64		cache_start_pos;
+	bool		backward;
+
+	bool		atstart;
+	bool		atend;
+	int64		pos;
+
+	bool		backend_atstart;
+	bool		backend_atend;
+	int64		backend_pos;
+
+	int64		mkbpos;
+	bool		mkbpos_is_last;
+
+	int		cache_miss;
 };
 
 /* structure to store connections */
@@ -241,6 +260,7 @@ void		ecpg_commit_cursors(int lineno, struct connection * conn, bool rollback, i
 #define ECPG_SQLSTATE_TRANSACTION_RESOLUTION_UNKNOWN	"08007"
 #define ECPG_SQLSTATE_CARDINALITY_VIOLATION "21000"
 #define ECPG_SQLSTATE_NULL_VALUE_NO_INDICATOR_PARAMETER "22002"
+#define ECPG_SQLSTATE_INVALID_CURSOR_STATE		"24000"
 #define ECPG_SQLSTATE_ACTIVE_SQL_TRANSACTION		"25001"
 #define ECPG_SQLSTATE_NO_ACTIVE_SQL_TRANSACTION		"25P01"
 #define ECPG_SQLSTATE_IN_FAILED_SQL_TRANSACTION		"25P02"
diff --git a/src/interfaces/ecpg/include/ecpglib.h b/src/interfaces/ecpg/include/ecpglib.h
index ace2d2c..76735a0 100644
--- a/src/interfaces/ecpg/include/ecpglib.h
+++ b/src/interfaces/ecpg/include/ecpglib.h
@@ -65,10 +65,10 @@ char	   *ECPGerrmsg(void);
 
 /* Cursor functions */
 bool		ECPGopen(const int, const int, const int, const char *, const bool, const bool,
-				enum ECPG_cursor_scroll,
+				enum ECPG_cursor_scroll, long readahead,
 				const char *, const int, const char *, ...);
 bool		ECPGfetch(const int, const int, const int, const char *, const bool,
-				enum ECPG_cursor_direction, const char *,
+				enum ECPG_cursor_direction, const char *, bool,
 				const char *, const int, const char *, ...);
 bool		ECPGcursor_dml(const int, const int, const int, const char *, const bool,
 				const char *, const int, const char *, ...);
diff --git a/src/interfaces/ecpg/preproc/check_rules.pl b/src/interfaces/ecpg/preproc/check_rules.pl
index b6d4fb5..92d35c1 100644
--- a/src/interfaces/ecpg/preproc/check_rules.pl
+++ b/src/interfaces/ecpg/preproc/check_rules.pl
@@ -43,7 +43,10 @@ my %replace_line = (
 	  => 'CREATE OptTemp TABLE create_as_target AS EXECUTE prepared_name execute_param_clause',
 
 	'PrepareStmtPREPAREnameprep_type_clauseASPreparableStmt' =>
-	  'PREPARE prepared_name prep_type_clause AS PreparableStmt');
+	  'PREPARE prepared_name prep_type_clause AS PreparableStmt',
+
+	'DeclareCursorStmtDECLAREcursor_namecursor_optionsCURSORopt_holdFORSelectStmt' =>
+	  'DECLARE cursor_name cursor_options opt_readahead CURSOR opt_hold FOR SelectStmt');
 
 my $block        = '';
 my $yaccmode     = 0;
diff --git a/src/interfaces/ecpg/preproc/ecpg.addons b/src/interfaces/ecpg/preproc/ecpg.addons
index 9229f2c..e85eaa3 100644
--- a/src/interfaces/ecpg/preproc/ecpg.addons
+++ b/src/interfaces/ecpg/preproc/ecpg.addons
@@ -26,7 +26,7 @@ ECPG: stmtDeclareCursorStmt block
 ECPG: stmtDiscardStmt block
 	{ output_statement($1, 1, ECPGst_normal); }
 ECPG: stmtFetchStmt block
-	{ output_fetch_statement($1, 1, ECPGst_normal); }
+	{ output_fetch_statement($1, 1, ECPGst_normal, current_cursor_move); }
 ECPG: stmtInsertStmt block
 ECPG: stmtSelectStmt block
 	{ output_statement($1, 1, ECPGst_prepnormal); }
@@ -505,7 +505,7 @@ ECPG: PrepareStmtPREPAREprepared_nameprep_type_clauseASPreparableStmt block
 	}
 ECPG: ExecuteStmtEXECUTEprepared_nameexecute_param_clauseexecute_rest block
 	{ $$ = $2; }
-ECPG: DeclareCursorStmtDECLAREcursor_namecursor_optionsCURSORopt_holdFORSelectStmt block
+ECPG: DeclareCursorStmtDECLAREcursor_namecursor_optionsopt_readaheadCURSORopt_holdFORSelectStmt block
 	{
 		struct cursor *ptr, *this;
 		char *cursor_marker = $2[0] == ':' ? mm_strdup("$0") : mm_strdup($2);
@@ -530,17 +530,27 @@ ECPG: DeclareCursorStmtDECLAREcursor_namecursor_optionsCURSORopt_holdFORSelectSt
 		this->function = (current_function ? mm_strdup(current_function) : NULL);
 		this->connection = connection;
 		this->opened = false;
-		this->with_hold = (strncmp($5, "with ", 5) == 0);
+		this->with_hold = (strncmp($6, "with ", 5) == 0);
+		if (strcmp($4, "default") == 0)
+			this->fetch_readahead = fetch_readahead;
+		else
+		{
+			int	this_readahead = atoi($4);
+
+			if (this_readahead < 1)
+				mmerror(PARSE_ERROR, ET_ERROR, "cursor readahead cannot be less than 1");
+			this->fetch_readahead = atoi($4);
+		}
 		this->vartype = current_cursor_vartype;
 		if (current_cursor_scrollable == ECPGcs_unspecified)
 		{
 			this->scrollable = ECPGcs_no_scroll;
-			this->command =  cat_str(8, mm_strdup("declare"), cursor_marker, $3, mm_strdup("no scroll"), mm_strdup("cursor"), $5, mm_strdup("for"), $7);
+			this->command =  cat_str(8, mm_strdup("declare"), cursor_marker, $3, mm_strdup("no scroll"), mm_strdup("cursor"), $6, mm_strdup("for"), $8);
 		}
 		else
 		{
 			this->scrollable = current_cursor_scrollable;
-			this->command =  cat_str(7, mm_strdup("declare"), cursor_marker, $3, mm_strdup("cursor"), $5, mm_strdup("for"), $7);
+			this->command =  cat_str(7, mm_strdup("declare"), cursor_marker, $3, mm_strdup("cursor"), $6, mm_strdup("for"), $8);
 			current_cursor_scrollable = ECPGcs_unspecified;
 		}
 		this->argsinsert = argsinsert;
@@ -639,15 +649,26 @@ ECPG: VariableShowStmtSHOWALL block
 		mmerror(PARSE_ERROR, ET_ERROR, "SHOW ALL is not implemented");
 		$$ = EMPTY;
 	}
-ECPG: FetchStmtMOVEfetch_args rule
+ECPG: FetchStmtFETCHfetch_args block
+	{
+		current_cursor_move = false;
+		$$ = cat_str(2,mm_strdup("fetch"),$2);
+	}
+ECPG: FetchStmtMOVEfetch_args block
+	{
+		current_cursor_move = true;
+		$$ = cat_str(2,mm_strdup("move"),$2);
+	}
 	| FETCH fetch_args ecpg_fetch_into
 	{
+		current_cursor_move = false;
 		$$ = cat2_str(mm_strdup("fetch"), $2);
 	}
 	| FETCH FORWARD cursor_name opt_ecpg_fetch_into
 	{
 		char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
 		add_additional_variables($3, false);
+		current_cursor_move = false;
 		current_cursor_direction = ECPGc_forward;
 		current_cursor_amount = mm_strdup("1");
 		$$ = cat_str(2, mm_strdup("fetch forward"), cursor_marker);
@@ -656,6 +677,7 @@ ECPG: FetchStmtMOVEfetch_args rule
 	{
 		char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
 		add_additional_variables($4, false);
+		current_cursor_move = false;
 		current_cursor_direction = ECPGc_forward;
 		current_cursor_amount = mm_strdup("1");
 		$$ = cat_str(2, mm_strdup("fetch forward from"), cursor_marker);
@@ -664,6 +686,7 @@ ECPG: FetchStmtMOVEfetch_args rule
 	{
 		char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
 		add_additional_variables($3, false);
+		current_cursor_move = false;
 		current_cursor_direction = ECPGc_backward;
 		current_cursor_amount = mm_strdup("1");
 		$$ = cat_str(2, mm_strdup("fetch backward"), cursor_marker);
@@ -672,6 +695,7 @@ ECPG: FetchStmtMOVEfetch_args rule
 	{
 		char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
 		add_additional_variables($4, false);
+		current_cursor_move = false;
 		current_cursor_direction = ECPGc_backward;
 		current_cursor_amount = mm_strdup("1");
 		$$ = cat_str(2, mm_strdup("fetch backward from"), cursor_marker);
@@ -680,6 +704,7 @@ ECPG: FetchStmtMOVEfetch_args rule
 	{
 		char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
 		add_additional_variables($3, false);
+		current_cursor_move = true;
 		current_cursor_direction = ECPGc_forward;
 		current_cursor_amount = mm_strdup("1");
 		$$ = cat_str(2, mm_strdup("move forward"), cursor_marker);
@@ -688,6 +713,7 @@ ECPG: FetchStmtMOVEfetch_args rule
 	{
 		char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
 		add_additional_variables($4, false);
+		current_cursor_move = true;
 		current_cursor_direction = ECPGc_forward;
 		current_cursor_amount = mm_strdup("1");
 		$$ = cat_str(2, mm_strdup("move forward from"), cursor_marker);
@@ -696,6 +722,7 @@ ECPG: FetchStmtMOVEfetch_args rule
 	{
 		char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
 		add_additional_variables($3, false);
+		current_cursor_move = true;
 		current_cursor_direction = ECPGc_backward;
 		current_cursor_amount = mm_strdup("1");
 		$$ = cat_str(2, mm_strdup("move backward"), cursor_marker);
@@ -704,6 +731,7 @@ ECPG: FetchStmtMOVEfetch_args rule
 	{
 		char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
 		add_additional_variables($4, false);
+		current_cursor_move = true;
 		current_cursor_direction = ECPGc_backward;
 		current_cursor_amount = mm_strdup("1");
 		$$ = cat_str(2, mm_strdup("move backward from"), cursor_marker);
diff --git a/src/interfaces/ecpg/preproc/ecpg.c b/src/interfaces/ecpg/preproc/ecpg.c
index bbea3e1..453fe24 100644
--- a/src/interfaces/ecpg/preproc/ecpg.c
+++ b/src/interfaces/ecpg/preproc/ecpg.c
@@ -19,6 +19,7 @@ bool		autocommit = false,
 			questionmarks = false,
 			regression_mode = false,
 			auto_prepare = false;
+long		fetch_readahead = 1; /* No readahead by default */
 
 char	   *output_filename;
 
@@ -51,7 +52,8 @@ help(const char *progname)
 	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"));
+	 "                 \"no_indicator\", \"prepare\", \"questionmarks\",\n"
+	 "                 \"readahead=number\"\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"));
@@ -131,6 +133,7 @@ main(int argc, char *const argv[])
 				header_mode = false;
 	struct _include_path *ip;
 	const char *progname;
+	char	   *endptr;
 	char		my_exec_path[MAXPGPATH];
 	char		include_path[MAXPGPATH];
 
@@ -229,6 +232,21 @@ main(int argc, char *const argv[])
 					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
 				{
 					fprintf(stderr, _("Try \"%s --help\" for more information.\n"), argv[0]);
diff --git a/src/interfaces/ecpg/preproc/ecpg.header b/src/interfaces/ecpg/preproc/ecpg.header
index 1d15539..6423780 100644
--- a/src/interfaces/ecpg/preproc/ecpg.header
+++ b/src/interfaces/ecpg/preproc/ecpg.header
@@ -37,6 +37,7 @@ int braces_open; /* brace level counter */
 char *current_function;
 char *current_cursor = NULL;
 enum ECPGttype current_cursor_vartype;
+bool current_cursor_move;
 enum ECPG_cursor_direction current_cursor_direction;
 enum ECPG_cursor_scroll current_cursor_scrollable = ECPGcs_unspecified;
 char *current_cursor_amount = NULL;
diff --git a/src/interfaces/ecpg/preproc/ecpg.tokens b/src/interfaces/ecpg/preproc/ecpg.tokens
index b55138a..3995b59 100644
--- a/src/interfaces/ecpg/preproc/ecpg.tokens
+++ b/src/interfaces/ecpg/preproc/ecpg.tokens
@@ -10,7 +10,7 @@
                 SQL_FREE SQL_GET SQL_GO SQL_GOTO SQL_IDENTIFIED
                 SQL_INDICATOR SQL_KEY_MEMBER SQL_LENGTH
                 SQL_LONG SQL_NULLABLE SQL_OCTET_LENGTH
-                SQL_OPEN SQL_OUTPUT SQL_REFERENCE
+                SQL_OPEN SQL_OUTPUT SQL_READAHEAD SQL_REFERENCE
                 SQL_RETURNED_LENGTH SQL_RETURNED_OCTET_LENGTH SQL_SCALE
                 SQL_SECTION SQL_SHORT SQL_SIGNED SQL_SQL SQL_SQLERROR
                 SQL_SQLPRINT SQL_SQLWARNING SQL_START SQL_STOP
diff --git a/src/interfaces/ecpg/preproc/ecpg.trailer b/src/interfaces/ecpg/preproc/ecpg.trailer
index 124a036..9fe47ee 100644
--- a/src/interfaces/ecpg/preproc/ecpg.trailer
+++ b/src/interfaces/ecpg/preproc/ecpg.trailer
@@ -287,7 +287,7 @@ prepared_name: name
  * Declare a prepared cursor. The syntax is different from the standard
  * declare statement, so we create a new rule.
  */
-ECPGCursorStmt:  DECLARE cursor_name cursor_options CURSOR opt_hold FOR prepared_name
+ECPGCursorStmt:	DECLARE cursor_name cursor_options opt_readahead CURSOR opt_hold FOR prepared_name
 		{
 			struct cursor *ptr, *this;
 			char *cursor_marker = $2[0] == ':' ? mm_strdup("$0") : mm_strdup($2);
@@ -316,17 +316,27 @@ ECPGCursorStmt:  DECLARE cursor_name cursor_options CURSOR opt_hold FOR prepared
 			this->function = (current_function ? mm_strdup(current_function) : NULL);
 			this->connection = connection;
 			this->opened = false;
-			this->with_hold = (strncmp($5, "with ", 5) == 0);
+			this->with_hold = (strncmp($6, "with ", 5) == 0);
+			if (strcmp($4, "default") == 0)
+				this->fetch_readahead = fetch_readahead;
+			else
+			{
+				int	this_readahead = atoi($4);
+
+				if (this_readahead < 1)
+					mmerror(PARSE_ERROR, ET_ERROR, "cursor readahead cannot be less than 1");
+				this->fetch_readahead = this_readahead;
+			}
 			this->vartype = current_cursor_vartype;
 			if (current_cursor_scrollable == ECPGcs_unspecified)
 			{
 				this->scrollable = ECPGcs_no_scroll;
-				this->command =  cat_str(7, mm_strdup("declare"), cursor_marker, $3, mm_strdup("no scroll"), mm_strdup("cursor"), $5, mm_strdup("for $1"));
+				this->command =  cat_str(7, mm_strdup("declare"), cursor_marker, $3, mm_strdup("no scroll"), mm_strdup("cursor"), $6, mm_strdup("for $1"));
 			}
 			else
 			{
 				this->scrollable = current_cursor_scrollable;
-				this->command =  cat_str(6, mm_strdup("declare"), cursor_marker, $3, mm_strdup("cursor"), $5, mm_strdup("for $1"));
+				this->command =  cat_str(6, mm_strdup("declare"), cursor_marker, $3, mm_strdup("cursor"), $6, mm_strdup("for $1"));
 				current_cursor_scrollable = ECPGcs_unspecified;
 			}
 			this->argsresult = NULL;
@@ -335,8 +345,8 @@ ECPGCursorStmt:  DECLARE cursor_name cursor_options CURSOR opt_hold FOR prepared
 			thisquery->type = &ecpg_query;
 			thisquery->brace_level = 0;
 			thisquery->next = NULL;
-			thisquery->name = (char *) mm_alloc(sizeof("ECPGprepared_statement(, , __LINE__)") + strlen(con) + strlen($7));
-			sprintf(thisquery->name, "ECPGprepared_statement(%s, %s, __LINE__)", con, $7);
+			thisquery->name = (char *) mm_alloc(sizeof("ECPGprepared_statement(, , __LINE__)") + strlen(con) + strlen($8));
+			sprintf(thisquery->name, "ECPGprepared_statement(%s, %s, __LINE__)", con, $8);
 
 			this->argsinsert = NULL;
 			this->argsinsert_oos = NULL;
@@ -361,6 +371,10 @@ ECPGCursorStmt:  DECLARE cursor_name cursor_options CURSOR opt_hold FOR prepared
 		}
 		;
 
+opt_readahead:	SQL_READAHEAD Iconst				{ $$ = $2; }
+		| /* EMPTY */					{ $$ = mm_strdup("default"); }
+		;
+
 ECPGExecuteImmediateStmt: EXECUTE IMMEDIATE execstring
 			{
 			  /* execute immediate means prepare the statement and
diff --git a/src/interfaces/ecpg/preproc/ecpg.type b/src/interfaces/ecpg/preproc/ecpg.type
index ac6aa00..2662372 100644
--- a/src/interfaces/ecpg/preproc/ecpg.type
+++ b/src/interfaces/ecpg/preproc/ecpg.type
@@ -85,6 +85,7 @@
 %type <str> opt_output
 %type <str> opt_pointer
 %type <str> opt_port
+%type <str> opt_readahead
 %type <str> opt_reference
 %type <str> opt_scale
 %type <str> opt_server
diff --git a/src/interfaces/ecpg/preproc/ecpg_keywords.c b/src/interfaces/ecpg/preproc/ecpg_keywords.c
index fb54d7b..396eee8 100644
--- a/src/interfaces/ecpg/preproc/ecpg_keywords.c
+++ b/src/interfaces/ecpg/preproc/ecpg_keywords.c
@@ -60,6 +60,7 @@ static const ScanKeyword ECPGScanKeywords[] = {
 	{"octet_length", SQL_OCTET_LENGTH, 0},
 	{"open", SQL_OPEN, 0},
 	{"output", SQL_OUTPUT, 0},
+	{"readahead", SQL_READAHEAD, 0},
 	{"reference", SQL_REFERENCE, 0},
 	{"returned_length", SQL_RETURNED_LENGTH, 0},
 	{"returned_octet_length", SQL_RETURNED_OCTET_LENGTH, 0},
diff --git a/src/interfaces/ecpg/preproc/extern.h b/src/interfaces/ecpg/preproc/extern.h
index 134b581..891c768 100644
--- a/src/interfaces/ecpg/preproc/extern.h
+++ b/src/interfaces/ecpg/preproc/extern.h
@@ -25,6 +25,7 @@ extern bool autocommit,
 			questionmarks,
 			regression_mode,
 			auto_prepare;
+extern long	fetch_readahead;
 extern int	braces_open,
 			ret_value,
 			struct_level,
@@ -32,6 +33,7 @@ extern int	braces_open,
 extern char *current_function;
 extern char *current_cursor;
 extern enum ECPGttype current_cursor_vartype;
+extern bool current_cursor_move;
 extern enum ECPG_cursor_direction current_cursor_direction;
 extern enum ECPG_cursor_scroll current_cursor_scrollable;
 extern char *current_cursor_amount;
@@ -73,7 +75,7 @@ extern void output_prepare_statement(char *, char *);
 extern void output_deallocate_prepare_statement(char *);
 extern void output_simple_statement(char *);
 extern void output_open_statement(char *, int, enum ECPG_statement_type);
-extern void output_fetch_statement(char *, int, enum ECPG_statement_type);
+extern void output_fetch_statement(char *, int, enum ECPG_statement_type, bool);
 extern void output_cursor_dml_statement(char *, int, enum ECPG_statement_type);
 extern void output_close_statement(char *, int, enum ECPG_statement_type);
 extern char *hashline_number(void);
diff --git a/src/interfaces/ecpg/preproc/output.c b/src/interfaces/ecpg/preproc/output.c
index 22fb67e..8d0c3a5 100644
--- a/src/interfaces/ecpg/preproc/output.c
+++ b/src/interfaces/ecpg/preproc/output.c
@@ -243,15 +243,16 @@ 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, ",
+	fprintf(yyout, "{ ECPGopen(__LINE__, %d, %d, %s, %d, %d, %s, %ld, ",
 						compat, force_indicator, connection ? connection : "NULL", questionmarks,
-						ptr->with_hold, ecpg_cursor_scroll_name[ptr->scrollable]);
+						ptr->with_hold, ecpg_cursor_scroll_name[ptr->scrollable],
+						ptr->fetch_readahead);
 	output_cursor_name(ptr);
 	output_statement_epilogue(stmt, whenever_mode, st);
 }
 
 void
-output_fetch_statement(char *stmt, int whenever_mode, enum ECPG_statement_type st)
+output_fetch_statement(char *stmt, int whenever_mode, enum ECPG_statement_type st, bool move)
 {
 	struct cursor *ptr = get_cursor(current_cursor);
 	char	   *amount;
@@ -265,9 +266,9 @@ output_fetch_statement(char *stmt, int whenever_mode, enum ECPG_statement_type s
 	else
 		amount = mm_strdup("NULL");
 
-	fprintf(yyout, "{ ECPGfetch(__LINE__, %d, %d, %s, %d, %s, %s, ",
+	fprintf(yyout, "{ ECPGfetch(__LINE__, %d, %d, %s, %d, %s, %s, %d, ",
 						compat, force_indicator, connection ? connection : "NULL", questionmarks,
-						ecpg_cursor_direction_name[current_cursor_direction], amount);
+						ecpg_cursor_direction_name[current_cursor_direction], amount, move);
 	output_cursor_name(ptr);
 	output_statement_epilogue(stmt, whenever_mode, st);
 	free(amount);
diff --git a/src/interfaces/ecpg/preproc/parse.pl b/src/interfaces/ecpg/preproc/parse.pl
index c10a4d5..9092e17 100644
--- a/src/interfaces/ecpg/preproc/parse.pl
+++ b/src/interfaces/ecpg/preproc/parse.pl
@@ -88,6 +88,8 @@ my %replace_line = (
 	'fetch_argsFORWARDopt_from_incursor_name'      => 'ignore',
 	'fetch_argsBACKWARDopt_from_incursor_name'     => 'ignore',
 	"opt_array_boundsopt_array_bounds'['Iconst']'" => 'ignore',
+	'DeclareCursorStmtDECLAREcursor_namecursor_optionsCURSORopt_holdFORSelectStmt' =>
+			'DECLARE cursor_name cursor_options opt_readahead CURSOR opt_hold FOR SelectStmt',
 	'VariableShowStmtSHOWvar_name' => 'SHOW var_name ecpg_into',
 	'VariableShowStmtSHOWTIMEZONE' => 'SHOW TIME ZONE ecpg_into',
 	'VariableShowStmtSHOWTRANSACTIONISOLATIONLEVEL' =>
diff --git a/src/interfaces/ecpg/preproc/type.h b/src/interfaces/ecpg/preproc/type.h
index f0a26f5..50a6057 100644
--- a/src/interfaces/ecpg/preproc/type.h
+++ b/src/interfaces/ecpg/preproc/type.h
@@ -130,6 +130,7 @@ struct cursor
 	char	   *connection;
 	bool		opened;
 	bool		with_hold;
+	long		fetch_readahead;
 	enum ECPGttype	vartype;
 	enum ECPG_cursor_scroll scrollable;
 	struct arguments *argsinsert;
diff --git a/src/interfaces/ecpg/test/ecpg_schedule b/src/interfaces/ecpg/test/ecpg_schedule
index e4170cc..80ae2a0 100644
--- a/src/interfaces/ecpg/test/ecpg_schedule
+++ b/src/interfaces/ecpg/test/ecpg_schedule
@@ -31,6 +31,9 @@ test: sql/array
 test: sql/binary
 test: sql/code100
 test: sql/copystdout
+test: sql/cursor-ra-fetch
+test: sql/cursor-ra-move
+test: sql/cursor-ra-swdir
 test: sql/cursorsubxact
 test: sql/define
 test: sql/desc
diff --git a/src/interfaces/ecpg/test/ecpg_schedule_tcp b/src/interfaces/ecpg/test/ecpg_schedule_tcp
index 26a4bae..a2c3b15 100644
--- a/src/interfaces/ecpg/test/ecpg_schedule_tcp
+++ b/src/interfaces/ecpg/test/ecpg_schedule_tcp
@@ -31,6 +31,9 @@ test: sql/array
 test: sql/binary
 test: sql/code100
 test: sql/copystdout
+test: sql/cursor-ra-fetch
+test: sql/cursor-ra-move
+test: sql/cursor-ra-swdir
 test: sql/cursorsubxact
 test: sql/define
 test: sql/desc
diff --git a/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c b/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c
index 9b5ba19..1b343d1 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, "mycur1", ECPGst_normal, "declare mycur1 no scroll cursor for $1", 
+	{ ECPGopen(__LINE__, 1, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, "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"
@@ -258,7 +258,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 	while (1)
 	{
 		strcpy(msg, "fetch");
-		{ ECPGfetch(__LINE__, 1, 1, NULL, 0, ECPGc_forward, "1", "mycur1", ECPGst_normal, "fetch 1 from mycur1", ECPGt_EOIT, 
+		{ ECPGfetch(__LINE__, 1, 1, NULL, 0, ECPGc_forward, "1", 0, "mycur1", ECPGst_normal, "fetch 1 from mycur1", ECPGt_EOIT, 
 	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 109 "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, "mycur2", ECPGst_normal, "declare mycur2 no scroll cursor for $1", 
+	{ ECPGopen(__LINE__, 1, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, "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"
@@ -333,7 +333,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 	while (1)
 	{
 		strcpy(msg, "fetch");
-		{ ECPGfetch(__LINE__, 1, 1, NULL, 0, ECPGc_forward, "1", "mycur2", ECPGst_normal, "fetch from mycur2", ECPGt_EOIT, 
+		{ ECPGfetch(__LINE__, 1, 1, NULL, 0, ECPGc_forward, "1", 0, "mycur2", ECPGst_normal, "fetch from mycur2", ECPGt_EOIT, 
 	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 146 "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 71c65b3..430eb4e 100644
--- a/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c
+++ b/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c
@@ -158,7 +158,7 @@ if (sqlca.sqlcode < 0) dosqlprint ( );}
 
 	while (1)
 	{
-		{ ECPGfetch(__LINE__, 1, 1, NULL, 0, ECPGc_forward, "1", "c", ECPGst_normal, "fetch forward c", ECPGt_EOIT, 
+		{ ECPGfetch(__LINE__, 1, 1, NULL, 0, ECPGc_forward, "1", 0, "c", ECPGst_normal, "fetch forward c", ECPGt_EOIT, 
 	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_decimal,&(j),(long)1,(long)1,sizeof(decimal), 
@@ -244,7 +244,7 @@ if (sqlca.sqlcode < 0) dosqlprint ( );}
 
 static void openit(void)
 {
-	{ ECPGopen(__LINE__, 1, 1, NULL, 0, 0, ECPGcs_no_scroll, "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, "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 3cbcb81..4f57003 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, "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, "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 ( );}
@@ -90,7 +90,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
 
 	while (1)
 	{
-		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", "cur", ECPGst_normal, "fetch from cur", ECPGt_EOIT, 
+		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", 0, "cur", ECPGst_normal, "fetch from cur", ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_double,&(d),(long)1,(long)1,sizeof(double), 
@@ -137,7 +137,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
 #line 48 "nan_test.pgc"
 
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, "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, "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 ( );}
@@ -145,7 +145,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
 
 	while (1)
 	{
-		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", "cur", ECPGst_normal, "fetch from cur", ECPGt_EOIT, 
+		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", 0, "cur", ECPGst_normal, "fetch from cur", ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_double,&(d),(long)1,(long)1,sizeof(double), 
@@ -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, "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, "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 ( );}
@@ -229,7 +229,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
 
 	while (1)
 	{
-		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", "cur1", ECPGst_normal, "fetch from cur1", ECPGt_EOIT, 
+		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", 0, "cur1", ECPGst_normal, "fetch from cur1", ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_numeric,&(num),(long)1,(long)0,sizeof(numeric), 
diff --git a/src/interfaces/ecpg/test/expected/preproc-autoprep.c b/src/interfaces/ecpg/test/expected/preproc-autoprep.c
index 5bb6b1d..9b475a7 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, "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, "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();
@@ -143,7 +143,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 #line 37 "autoprep.pgc"
 
 
-  { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", "C", ECPGst_normal, "fetch 1 in C", ECPGt_EOIT, 
+  { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", 0, "C", ECPGst_normal, "fetch 1 in C", ECPGt_EOIT, 
 	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 39 "autoprep.pgc"
@@ -180,7 +180,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 #line 46 "autoprep.pgc"
 
 
-  { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, "cur1", ECPGst_normal, "declare cur1 no scroll cursor for $1", 
+  { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, "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"
@@ -199,7 +199,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
   i = 0;
   while (1)
   {
-	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", "cur1", ECPGst_normal, "fetch cur1", ECPGt_EOIT, 
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", 0, "cur1", ECPGst_normal, "fetch cur1", ECPGt_EOIT, 
 	ECPGt_int,&(item1),(long)1,(long)1,sizeof(int), 
 	ECPGt_int,&(ind1),(long)1,(long)1,sizeof(int), ECPGt_EORT);
 #line 55 "autoprep.pgc"
diff --git a/src/interfaces/ecpg/test/expected/preproc-cursor.c b/src/interfaces/ecpg/test/expected/preproc-cursor.c
index 8bd0f9f..94c91d2 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, 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, 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"
@@ -197,7 +197,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 
 	strcpy(msg, "fetch from");
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", curname1, ECPGst_normal, "fetch forward from $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", 0, curname1, ECPGst_normal, "fetch forward from $0", 
 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
@@ -212,7 +212,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "fetch");
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", curname1, ECPGst_normal, "fetch forward $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", 0, curname1, ECPGst_normal, "fetch forward $0", 
 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
@@ -227,7 +227,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "fetch 1 from");
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", curname1, ECPGst_normal, "fetch 1 from $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", 0, curname1, ECPGst_normal, "fetch 1 from $0", 
 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
@@ -243,7 +243,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 	strcpy(msg, "fetch :count from");
 	count = 1;
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward_in_var, NULL, curname1, ECPGst_normal, "fetch $0 from $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward_in_var, NULL, 0, curname1, ECPGst_normal, "fetch $0 from $0", 
 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
@@ -260,7 +260,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "move in");
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_absolute, "0", curname1, ECPGst_normal, "move absolute 0 in $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_absolute, "0", 1, curname1, ECPGst_normal, "move absolute 0 in $0", 
 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 87 "cursor.pgc"
@@ -270,7 +270,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 
 	strcpy(msg, "fetch 1");
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", curname1, ECPGst_normal, "fetch 1 $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", 0, curname1, ECPGst_normal, "fetch 1 $0", 
 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
@@ -286,7 +286,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 	strcpy(msg, "fetch :count");
 	count = 1;
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward_in_var, NULL, curname1, ECPGst_normal, "fetch $0 $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward_in_var, NULL, 0, curname1, ECPGst_normal, "fetch $0 $0", 
 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
@@ -323,7 +323,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 
 	strcpy(msg, "open");
-	{ ECPGopen(__LINE__, 0, 1, "test1", 0, 0, ECPGcs_no_scroll, 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, 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), 
@@ -337,7 +337,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 
 	strcpy(msg, "fetch from");
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", curname2, ECPGst_normal, "fetch from $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", 0, curname2, ECPGst_normal, "fetch from $0", 
 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
@@ -352,7 +352,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "fetch");
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", curname2, ECPGst_normal, "fetch $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", 0, curname2, ECPGst_normal, "fetch $0", 
 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
@@ -367,7 +367,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "fetch 1 from");
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", curname2, ECPGst_normal, "fetch 1 from $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", 0, curname2, ECPGst_normal, "fetch 1 from $0", 
 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
@@ -383,7 +383,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 	strcpy(msg, "fetch :count from");
 	count = 1;
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward_in_var, NULL, curname2, ECPGst_normal, "fetch $0 from $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward_in_var, NULL, 0, curname2, ECPGst_normal, "fetch $0 from $0", 
 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
@@ -400,7 +400,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "move");
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_absolute, "0", curname2, ECPGst_normal, "move absolute 0 $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_absolute, "0", 1, curname2, ECPGst_normal, "move absolute 0 $0", 
 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
@@ -414,7 +414,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 
 	strcpy(msg, "fetch 1");
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", curname2, ECPGst_normal, "fetch 1 $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", 0, curname2, ECPGst_normal, "fetch 1 $0", 
 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
@@ -430,7 +430,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 	strcpy(msg, "fetch :count");
 	count = 1;
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward_in_var, NULL, curname2, ECPGst_normal, "fetch $0 $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward_in_var, NULL, 0, curname2, ECPGst_normal, "fetch $0 $0", 
 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
@@ -483,7 +483,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 
 	strcpy(msg, "open");
-	{ ECPGopen(__LINE__, 0, 1, "test1", 0, 0, ECPGcs_no_scroll, curname3, ECPGst_normal, "declare $0 no scroll cursor for $1", 
+	{ ECPGopen(__LINE__, 0, 1, "test1", 0, 0, ECPGcs_no_scroll, 1, 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, curname5, ECPGst_normal, "declare $0 no scroll cursor for $1", 
+	{ ECPGopen(__LINE__, 0, 1, "test2", 0, 0, ECPGcs_no_scroll, 1, 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), 
@@ -505,7 +505,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 
 	strcpy(msg, "fetch");
-	{ ECPGfetch(__LINE__, 0, 1, "test2", 0, ECPGc_forward, "1", curname5, ECPGst_normal, "fetch $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test2", 0, ECPGc_forward, "1", 0, curname5, ECPGst_normal, "fetch $0", 
 	ECPGt_char,&(curname5),(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), 
@@ -520,7 +520,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "fetch from");
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", curname3, ECPGst_normal, "fetch from $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", 0, curname3, ECPGst_normal, "fetch from $0", 
 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
@@ -535,7 +535,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "fetch 1 from");
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", curname3, ECPGst_normal, "fetch 1 from $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", 0, curname3, ECPGst_normal, "fetch 1 from $0", 
 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
@@ -551,7 +551,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 	strcpy(msg, "fetch :count from");
 	count = 1;
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward_in_var, NULL, curname3, ECPGst_normal, "fetch $0 from $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward_in_var, NULL, 0, curname3, ECPGst_normal, "fetch $0 from $0", 
 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
@@ -568,7 +568,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "move");
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_absolute, "0", curname3, ECPGst_normal, "move absolute 0 $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_absolute, "0", 1, curname3, ECPGst_normal, "move absolute 0 $0", 
 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 174 "cursor.pgc"
@@ -578,7 +578,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 
 	strcpy(msg, "fetch 1");
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", curname3, ECPGst_normal, "fetch 1 $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", 0, curname3, ECPGst_normal, "fetch 1 $0", 
 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
@@ -594,7 +594,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 	strcpy(msg, "fetch :count");
 	count = 1;
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward_in_var, NULL, curname3, ECPGst_normal, "fetch $0 $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward_in_var, NULL, 0, curname3, ECPGst_normal, "fetch $0 $0", 
 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
@@ -663,7 +663,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 
 	strcpy(msg, "open");
-	{ ECPGopen(__LINE__, 0, 1, "test1", 0, 0, ECPGcs_no_scroll, curname4.arr, ECPGst_normal, "declare $0 no scroll cursor for $1", 
+	{ ECPGopen(__LINE__, 0, 1, "test1", 0, 0, ECPGcs_no_scroll, 1, 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), 
@@ -675,7 +675,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 
 	strcpy(msg, "fetch from");
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", curname4.arr, ECPGst_normal, "fetch from $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", 0, curname4.arr, ECPGst_normal, "fetch from $0", 
 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
@@ -690,7 +690,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "fetch");
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", curname4.arr, ECPGst_normal, "fetch $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", 0, curname4.arr, ECPGst_normal, "fetch $0", 
 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
@@ -705,7 +705,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "fetch 1 from");
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", curname4.arr, ECPGst_normal, "fetch 1 from $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", 0, curname4.arr, ECPGst_normal, "fetch 1 from $0", 
 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
@@ -721,7 +721,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 	strcpy(msg, "fetch :count from");
 	count = 1;
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward_in_var, NULL, curname4.arr, ECPGst_normal, "fetch $0 from $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward_in_var, NULL, 0, curname4.arr, ECPGst_normal, "fetch $0 from $0", 
 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1), 
@@ -738,7 +738,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "move");
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_absolute, "0", curname4.arr, ECPGst_normal, "move absolute 0 $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_absolute, "0", 1, curname4.arr, ECPGst_normal, "move absolute 0 $0", 
 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 226 "cursor.pgc"
@@ -748,7 +748,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 
 	strcpy(msg, "fetch 1");
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", curname4.arr, ECPGst_normal, "fetch 1 $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", 0, curname4.arr, ECPGst_normal, "fetch 1 $0", 
 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
@@ -764,7 +764,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 	strcpy(msg, "fetch :count");
 	count = 1;
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward_in_var, NULL, curname4.arr, ECPGst_normal, "fetch $0 $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward_in_var, NULL, 0, curname4.arr, ECPGst_normal, "fetch $0 $0", 
 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1), 
diff --git a/src/interfaces/ecpg/test/expected/preproc-outofscope.c b/src/interfaces/ecpg/test/expected/preproc-outofscope.c
index f5e3813..2867e6e 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, "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, "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), 
@@ -225,7 +225,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 static void
 get_record1(void)
 {
-	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", "mycur", ECPGst_normal, "fetch mycur", ECPGt_EOIT, 
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", 0, "mycur", ECPGst_normal, "fetch mycur", 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 89ade6b..d70ab17 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, "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, "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);}
@@ -206,7 +206,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 	memset(i, 0, sizeof(ind_personal));
 	while (1) {
 		strcpy(msg, "fetch");
-		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", "cur", ECPGst_normal, "fetch cur", ECPGt_EOIT, 
+		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", 0, "cur", ECPGst_normal, "fetch cur", ECPGt_EOIT, 
 	ECPGt_varchar,&(p->name),(long)BUFFERSIZ,(long)1,sizeof(struct varchar_1), 
 	ECPGt_int,&(i->ind_name),(long)1,(long)1,sizeof(int), 
 	ECPGt_long,&(p->birth.born),(long)1,(long)1,sizeof(long), 
diff --git a/src/interfaces/ecpg/test/expected/sql-binary.c b/src/interfaces/ecpg/test/expected/sql-binary.c
index c1233dc..4bcb9a7 100644
--- a/src/interfaces/ecpg/test/expected/sql-binary.c
+++ b/src/interfaces/ecpg/test/expected/sql-binary.c
@@ -111,12 +111,12 @@ 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, "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, "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"
 
-  { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", "C", ECPGst_normal, "fetch C", ECPGt_EOIT, 
+  { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", 0, "C", ECPGst_normal, "fetch C", ECPGt_EOIT, 
 	ECPGt_char,(empl.name),(long)21,(long)1,(21)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_short,&(empl.accs),(long)1,(long)1,sizeof(short), 
@@ -142,12 +142,12 @@ 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, "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, "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"
 
-  { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", "B", ECPGst_normal, "fetch B", ECPGt_EOIT, 
+  { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", 0, "B", ECPGst_normal, "fetch B", ECPGt_EOIT, 
 	ECPGt_char,(empl.name),(long)21,(long)1,(21)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_short,&(empl.accs),(long)1,(long)1,sizeof(short), 
@@ -176,12 +176,12 @@ 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, "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, "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"
 
-  { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", "A", ECPGst_normal, "fetch A", ECPGt_EOIT, 
+  { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", 0, "A", ECPGst_normal, "fetch A", ECPGt_EOIT, 
 	ECPGt_char,&(pointer),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
 #line 91 "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
new file mode 100644
index 0000000..800da8f
--- /dev/null
+++ b/src/interfaces/ecpg/test/expected/sql-cursor-ra-fetch.c
@@ -0,0 +1,1046 @@
+/* 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-ra-fetch.pgc"
+#include <stdlib.h>
+#include <string.h>
+
+
+#line 1 "regression.h"
+
+
+
+
+
+
+#line 4 "cursor-ra-fetch.pgc"
+
+
+/* exec sql whenever sqlerror  sqlprint ; */
+#line 6 "cursor-ra-fetch.pgc"
+
+
+int main(void)
+{
+/* exec sql begin declare section */
+		 
+		
+
+#line 11 "cursor-ra-fetch.pgc"
+ int id [ 8 ] , i ;
+ 
+#line 12 "cursor-ra-fetch.pgc"
+  struct varchar_1  { int len; char arr[ 50 ]; }  t [ 8 ] ;
+/* exec sql end declare section */
+#line 13 "cursor-ra-fetch.pgc"
+
+	int	quit_loop;
+
+	ECPGdebug(1, stderr);
+
+	{ ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); 
+#line 18 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 18 "cursor-ra-fetch.pgc"
+
+
+	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table t1 ( id serial primary key , t text )", ECPGt_EOIT, ECPGt_EORT);
+#line 20 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 20 "cursor-ra-fetch.pgc"
+
+	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( t ) values ( 'a' ) , ( 'b' ) , ( 'c' ) , ( 'd' ) , ( 'e' ) , ( 'f' ) , ( 'g' ) , ( 'h' ) , ( 'i' ) , ( 'j' ) , ( 'k' ) , ( 'l' ) , ( 'm' ) , ( 'n' ) , ( 'o' ) , ( 'p' ) , ( 'q' ) , ( 'r' ) , ( 's' ) , ( 't' ) , ( 'u' ) , ( 'v' ) , ( 'w' ) , ( 'x' ) , ( 'y' ) , ( 'z' )", ECPGt_EOIT, ECPGt_EORT);
+#line 25 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 25 "cursor-ra-fetch.pgc"
+
+	{ ECPGtrans(__LINE__, NULL, "commit", 0, 0, 0, NULL);
+#line 26 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 26 "cursor-ra-fetch.pgc"
+
+
+	/* declare scroll_cur scroll cursor for select id , t from t1 order by id */
+#line 28 "cursor-ra-fetch.pgc"
+
+	/* declare scroll_cur4 scroll cursor for select id , t from t1 order by id */
+#line 29 "cursor-ra-fetch.pgc"
+
+
+	/*
+	 * Test FETCH ABSOLUTE N with an interval of 4 using positive positions.
+	 * Readahead is 8 so caching is in effect.
+	 */
+
+	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, "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();}
+#line 38 "cursor-ra-fetch.pgc"
+
+	if (sqlca.sqlcode < 0)
+		printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate);
+
+	for (i = 1; i < 33; i += 4)
+	{
+		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_absolute_in_var, NULL, 0, "scroll_cur", ECPGst_normal, "fetch absolute $0 from scroll_cur", 
+	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 44 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 44 "cursor-ra-fetch.pgc"
+
+
+		if (sqlca.sqlerrd[2] == 1)
+			printf("\trow %d: id: %d\tt: %s\n", i, id[0], t[0].arr);
+		else
+			printf("\trow %d does not exist\n", i);
+	}
+
+	printf("\ntest scroll_cur for move absolute n (every 4th tuple backward, positive positions)\n");
+
+	for (i = 33; i >= 0; i -= 4)
+	{
+		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_absolute_in_var, NULL, 0, "scroll_cur", ECPGst_normal, "fetch absolute $0 from scroll_cur", 
+	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 56 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 56 "cursor-ra-fetch.pgc"
+
+
+		if (sqlca.sqlerrd[2] == 1)
+			printf("\trow %d: id: %d\tt: %s\n", i, id[0], t[0].arr);
+		else
+			printf("\trow %d does not exist\n", i);
+	}
+
+	{ ECPGtrans(__LINE__, NULL, "rollback", 0, 0, 1, NULL);
+#line 64 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 64 "cursor-ra-fetch.pgc"
+
+
+	/*
+	 * Test FETCH ABSOLUTE N with an interval of 4 using negative positions.
+	 * Readahead is 8 so caching is in effect.
+	 */
+
+	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, "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();}
+#line 73 "cursor-ra-fetch.pgc"
+
+	if (sqlca.sqlcode < 0)
+		printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate);
+
+	for (i = -1; i > -33; i -= 4)
+	{
+		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_absolute_in_var, NULL, 0, "scroll_cur", ECPGst_normal, "fetch absolute $0 from scroll_cur", 
+	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 79 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 79 "cursor-ra-fetch.pgc"
+
+
+		if (sqlca.sqlerrd[2] == 1)
+			printf("\trow %d: id: %d\tt: %s\n", i, id[0], t[0].arr);
+		else
+			printf("\trow %d does not exist\n", i);
+	}
+
+	printf("\ntest scroll_cur for move absolute n (every 4th tuple forward, negative positions)\n");
+
+	for (i = -33; i <= 0; i += 4)
+	{
+		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_absolute_in_var, NULL, 0, "scroll_cur", ECPGst_normal, "fetch absolute $0 from scroll_cur", 
+	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 91 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 91 "cursor-ra-fetch.pgc"
+
+
+		if (sqlca.sqlerrd[2] == 1)
+			printf("\trow %d: id: %d\tt: %s\n", i, id[0], t[0].arr);
+		else
+			printf("\trow %d does not exist\n", i);
+	}
+
+	{ ECPGtrans(__LINE__, NULL, "rollback", 0, 0, 1, NULL);
+#line 99 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 99 "cursor-ra-fetch.pgc"
+
+
+	/*
+	 * Test FETCH RELATIVE +/- 4 using positive positions
+	 * readahead is 8, so caching is in effect
+	 */
+
+	printf("\ntest scroll_cur for fetch relative 4 (positive positions)\n");
+
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 8, "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();}
+#line 108 "cursor-ra-fetch.pgc"
+
+	if (sqlca.sqlcode < 0)
+		printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate);
+
+	quit_loop = 0;
+	while (!quit_loop)
+	{
+		for (i = 0; i < 8; i++)
+			id[i] = 0, t[i].arr[0] = '\0';
+		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_relative, "4", 0, "scroll_cur", ECPGst_normal, "fetch relative 4 in scroll_cur", ECPGt_EOIT, 
+	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 117 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 117 "cursor-ra-fetch.pgc"
+
+		if (sqlca.sqlcode < 0)
+			printf("fetch relative 4 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
+		else
+			printf("fetch relative 4 in scroll_cur succeeded, sqlerrd[2] %ld\n", sqlca.sqlerrd[2]);
+		for (i = 0; i < sqlca.sqlerrd[2]; i++)
+			printf("\tid: %d\tt: %s\n", id[i], t[i].arr);
+		quit_loop = (sqlca.sqlerrd[2] == 0);
+	}
+
+	printf("\ntest scroll_cur for fetch relative -4 (positive positions)\n");
+
+	quit_loop = 0;
+	while (!quit_loop)
+	{
+		for (i = 0; i < 8; i++)
+			id[i] = 0, t[i].arr[0] = '\0';
+		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_relative, "- 4", 0, "scroll_cur", ECPGst_normal, "fetch relative - 4 in scroll_cur", ECPGt_EOIT, 
+	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 134 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 134 "cursor-ra-fetch.pgc"
+
+		if (sqlca.sqlcode < 0)
+			printf("fetch relative -4 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
+		else
+			printf("fetch relative -4 in scroll_cur succeeded, sqlerrd[2] %ld\n", sqlca.sqlerrd[2]);
+		for (i = 0; i < sqlca.sqlerrd[2]; i++)
+			printf("\tid: %d\tt: %s\n", id[i], t[i].arr);
+		quit_loop = (sqlca.sqlerrd[2] == 0);
+	}
+
+	{ ECPGtrans(__LINE__, NULL, "rollback", 0, 0, 1, NULL);
+#line 144 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 144 "cursor-ra-fetch.pgc"
+
+
+	/*
+	 * Test FETCH RELATIVE +/- 4 using negative positions
+	 * readahead is 8, so caching is in effect
+	 */
+
+	printf("\ntest scroll_cur for fetch relative -4 (negative positions)\n");
+
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 8, "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();}
+#line 153 "cursor-ra-fetch.pgc"
+
+	if (sqlca.sqlcode < 0)
+		printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate);
+
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_absolute, "- 1", 1, "scroll_cur", ECPGst_normal, "move absolute - 1 in scroll_cur", ECPGt_EOIT, ECPGt_EORT);
+#line 157 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 157 "cursor-ra-fetch.pgc"
+
+	if (sqlca.sqlcode < 0)
+		printf("move absolute -1 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", 1, "scroll_cur", ECPGst_normal, "move forward 1 in scroll_cur", ECPGt_EOIT, ECPGt_EORT);
+#line 160 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 160 "cursor-ra-fetch.pgc"
+
+	if (sqlca.sqlcode < 0)
+		printf("move forward 1 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
+
+	quit_loop = 0;
+	while (!quit_loop)
+	{
+		for (i = 0; i < 8; i++)
+			id[i] = 0, t[i].arr[0] = '\0';
+		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_relative, "- 4", 0, "scroll_cur", ECPGst_normal, "fetch relative - 4 in scroll_cur", ECPGt_EOIT, 
+	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 169 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 169 "cursor-ra-fetch.pgc"
+
+		if (sqlca.sqlcode < 0)
+			printf("fetch relative -4 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
+		else
+			printf("fetch relative -4 in scroll_cur succeeded, sqlerrd[2] %ld\n", sqlca.sqlerrd[2]);
+		for (i = 0; i < sqlca.sqlerrd[2]; i++)
+			printf("\tid: %d\tt: %s\n", id[i], t[i].arr);
+		quit_loop = (sqlca.sqlerrd[2] == 0);
+	}
+
+	printf("\ntest scroll_cur for fetch relative 4 (negative positions)\n");
+
+	quit_loop = 0;
+	while (!quit_loop)
+	{
+		for (i = 0; i < 8; i++)
+			id[i] = 0, t[i].arr[0] = '\0';
+		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_relative, "4", 0, "scroll_cur", ECPGst_normal, "fetch relative 4 in scroll_cur", ECPGt_EOIT, 
+	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 186 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 186 "cursor-ra-fetch.pgc"
+
+		if (sqlca.sqlcode < 0)
+			printf("fetch relative 4 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
+		else
+			printf("fetch relative 4 in scroll_cur succeeded, sqlerrd[2] %ld\n", sqlca.sqlerrd[2]);
+		for (i = 0; i < sqlca.sqlerrd[2]; i++)
+			printf("\tid: %d\tt: %s\n", id[i], t[i].arr);
+		quit_loop = (sqlca.sqlerrd[2] == 0);
+	}
+
+	{ ECPGtrans(__LINE__, NULL, "rollback", 0, 0, 1, NULL);
+#line 196 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 196 "cursor-ra-fetch.pgc"
+
+
+	/*
+	 * Test FETCH FORWARD +/- 4 using positive positions
+	 * readahead is 8, so caching is in effect
+	 */
+
+	printf("\ntest scroll_cur for fetch forward 4 (positive positions)\n");
+
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 8, "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();}
+#line 205 "cursor-ra-fetch.pgc"
+
+	if (sqlca.sqlcode < 0)
+		printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate);
+
+	quit_loop = 0;
+	while (!quit_loop)
+	{
+		for (i = 0; i < 8; i++)
+			id[i] = 0, t[i].arr[0] = '\0';
+		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "4", 0, "scroll_cur", ECPGst_normal, "fetch forward 4 in scroll_cur", ECPGt_EOIT, 
+	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 214 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 214 "cursor-ra-fetch.pgc"
+
+		if (sqlca.sqlcode < 0)
+			printf("fetch forward 4 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
+		else
+			printf("fetch forward 4 in scroll_cur succeeded, sqlerrd[2] %ld\n", sqlca.sqlerrd[2]);
+		for (i = 0; i < sqlca.sqlerrd[2]; i++)
+			printf("\tid: %d\tt: %s\n", id[i], t[i].arr);
+		quit_loop = (sqlca.sqlerrd[2] == 0);
+	}
+
+	printf("\ntest scroll_cur for fetch forward -4 (positive positions)\n");
+
+	quit_loop = 0;
+	while (!quit_loop)
+	{
+		for (i = 0; i < 8; i++)
+			id[i] = 0, t[i].arr[0] = '\0';
+		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "- 4", 0, "scroll_cur", ECPGst_normal, "fetch forward - 4 in scroll_cur", ECPGt_EOIT, 
+	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 231 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 231 "cursor-ra-fetch.pgc"
+
+		if (sqlca.sqlcode < 0)
+			printf("fetch forward -4 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
+		else
+			printf("fetch forward -4 in scroll_cur succeeded, sqlerrd[2] %ld\n", sqlca.sqlerrd[2]);
+		for (i = 0; i < sqlca.sqlerrd[2]; i++)
+			printf("\tid: %d\tt: %s\n", id[i], t[i].arr);
+		quit_loop = (sqlca.sqlerrd[2] == 0);
+	}
+
+	{ ECPGtrans(__LINE__, NULL, "rollback", 0, 0, 1, NULL);
+#line 241 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 241 "cursor-ra-fetch.pgc"
+
+
+	/*
+	 * Test FETCH FORWARD +/- 4 using negative positions
+	 * readahead is 8, so caching is in effect
+	 */
+
+	printf("\ntest scroll_cur for fetch forward -4 (negative positions)\n");
+
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 8, "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();}
+#line 250 "cursor-ra-fetch.pgc"
+
+	if (sqlca.sqlcode < 0)
+		printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate);
+
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_absolute, "- 1", 1, "scroll_cur", ECPGst_normal, "move absolute - 1 in scroll_cur", ECPGt_EOIT, ECPGt_EORT);
+#line 254 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 254 "cursor-ra-fetch.pgc"
+
+	if (sqlca.sqlcode < 0)
+		printf("move absolute -1 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", 1, "scroll_cur", ECPGst_normal, "move forward 1 in scroll_cur", ECPGt_EOIT, ECPGt_EORT);
+#line 257 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 257 "cursor-ra-fetch.pgc"
+
+	if (sqlca.sqlcode < 0)
+		printf("move forward 1 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
+
+	quit_loop = 0;
+	while (!quit_loop)
+	{
+		for (i = 0; i < 8; i++)
+			id[i] = 0, t[i].arr[0] = '\0';
+		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "- 4", 0, "scroll_cur", ECPGst_normal, "fetch forward - 4 in scroll_cur", ECPGt_EOIT, 
+	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 266 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 266 "cursor-ra-fetch.pgc"
+
+		if (sqlca.sqlcode < 0)
+			printf("fetch forward -4 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
+		else
+			printf("fetch forward -4 in scroll_cur succeeded, sqlerrd[2] %ld\n", sqlca.sqlerrd[2]);
+		for (i = 0; i < sqlca.sqlerrd[2]; i++)
+			printf("\tid: %d\tt: %s\n", id[i], t[i].arr);
+		quit_loop = (sqlca.sqlerrd[2] == 0);
+	}
+
+	printf("\ntest scroll_cur for fetch forward 4 (negative positions)\n");
+
+	quit_loop = 0;
+	while (!quit_loop)
+	{
+		for (i = 0; i < 8; i++)
+			id[i] = 0, t[i].arr[0] = '\0';
+		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "4", 0, "scroll_cur", ECPGst_normal, "fetch forward 4 in scroll_cur", ECPGt_EOIT, 
+	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 283 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 283 "cursor-ra-fetch.pgc"
+
+		if (sqlca.sqlcode < 0)
+			printf("fetch forward 4 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
+		else
+			printf("fetch forward 4 in scroll_cur succeeded, sqlerrd[2] %ld\n", sqlca.sqlerrd[2]);
+		for (i = 0; i < sqlca.sqlerrd[2]; i++)
+			printf("\tid: %d\tt: %s\n", id[i], t[i].arr);
+		quit_loop = (sqlca.sqlerrd[2] == 0);
+	}
+
+	{ ECPGtrans(__LINE__, NULL, "rollback", 0, 0, 1, NULL);
+#line 293 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 293 "cursor-ra-fetch.pgc"
+
+
+	/*
+	 * Test FETCH ABSOLUTE N with an interval of 5 using positive positions.
+	 * Readahead is 4 so cache misses occur.
+	 * ecpglib will switch to plain ecpg_execute after 3 cache misses
+	 */
+
+	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, "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();}
+#line 303 "cursor-ra-fetch.pgc"
+
+	if (sqlca.sqlcode < 0)
+		printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate);
+
+	for (i = 1; i < 35; i += 5)
+	{
+		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_absolute_in_var, NULL, 0, "scroll_cur4", ECPGst_normal, "fetch absolute $0 from scroll_cur4", 
+	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 309 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 309 "cursor-ra-fetch.pgc"
+
+
+		if (sqlca.sqlerrd[2] == 1)
+			printf("\trow %d: id: %d\tt: %s\n", i, id[0], t[0].arr);
+		else
+			printf("\trow %d does not exist\n", i);
+	}
+
+	/*
+	 * Let's see caching recovers by fetching 2x the readahead size.
+	 * The cursor must be at the end now, with the cursor's pos,
+	 * backend_pos, atstart and atend correctly set.
+	 */
+
+	printf("\ntest fetch backward 8 from scroll_cur4 after the cursor switched to ecpg_execute()\n");
+
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_backward, "8", 0, "scroll_cur4", ECPGst_normal, "fetch backward 8 from scroll_cur4", ECPGt_EOIT, 
+	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 325 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 325 "cursor-ra-fetch.pgc"
+
+	for (i = 0; i < sqlca.sqlerrd[2]; i++)
+		printf("\tid: %d t: %s\n", id[i], t[i].arr);
+
+	printf("\ntest scroll_cur4 for move absolute n (every 5th tuple backward, positive positions)\n");
+
+	for (i = 36; i >= 0; i -= 5)
+	{
+		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_absolute_in_var, NULL, 0, "scroll_cur4", ECPGst_normal, "fetch absolute $0 from scroll_cur4", 
+	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 333 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 333 "cursor-ra-fetch.pgc"
+
+
+		if (sqlca.sqlerrd[2] == 1)
+			printf("\trow %d: id: %d\tt: %s\n", i, id[0], t[0].arr);
+		else
+			printf("\trow %d does not exist\n", i);
+	}
+
+	/*
+	 * Let's see caching recovers by fetching 2x the readahead size.
+	 * The cursor must be at the start+1 (pos == 1) now,
+	 * with the cursor's pos, backend_pos, atstart and atend
+	 * correctly set.
+	 */
+
+	printf("\ntest fetch forward 8 from scroll_cur4 after the cursor switched to ecpg_execute()\n");
+
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "8", 0, "scroll_cur4", ECPGst_normal, "fetch forward 8 from scroll_cur4", ECPGt_EOIT, 
+	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 350 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 350 "cursor-ra-fetch.pgc"
+
+	for (i = 0; i < sqlca.sqlerrd[2]; i++)
+		printf("\tid: %d t: %s\n", id[i], t[i].arr);
+
+	{ ECPGtrans(__LINE__, NULL, "rollback", 0, 0, 1, NULL);
+#line 354 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 354 "cursor-ra-fetch.pgc"
+
+
+	/*
+	 * Test FETCH ABSOLUTE N with an interval of 5 using negative positions.
+	 * Readahead is 4 so cache misses occur.
+	 * ecpglib will switch to plain ecpg_execute after 3 cache misses
+	 */
+
+	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, "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();}
+#line 364 "cursor-ra-fetch.pgc"
+
+	if (sqlca.sqlcode < 0)
+		printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate);
+
+	for (i = -1; i > -35; i -= 5)
+	{
+		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_absolute_in_var, NULL, 0, "scroll_cur4", ECPGst_normal, "fetch absolute $0 from scroll_cur4", 
+	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 370 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 370 "cursor-ra-fetch.pgc"
+
+
+		if (sqlca.sqlerrd[2] == 1)
+			printf("\trow %d: id: %d\tt: %s\n", i, id[0], t[0].arr);
+		else
+			printf("\trow %d does not exist\n", i);
+	}
+
+	/*
+	 * Let's see caching recovers by fetching 2x the readahead size.
+	 * The cursor must be at the start (pos == -27) now,
+	 * with the cursor's pos, backend_pos, atstart and atend
+	 * correctly set.
+	 */
+
+	printf("\ntest fetch forward 8 from scroll_cur4 after the cursor switched to ecpg_execute()\n");
+
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "8", 0, "scroll_cur4", ECPGst_normal, "fetch forward 8 from scroll_cur4", ECPGt_EOIT, 
+	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 387 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 387 "cursor-ra-fetch.pgc"
+
+	for (i = 0; i < sqlca.sqlerrd[2]; i++)
+		printf("\tid: %d t: %s\n", id[i], t[i].arr);
+
+	printf("\ntest scroll_cur4 for move absolute n (every 5th tuple forward, negative positions)\n");
+
+	for (i = -36; i <= 0; i += 5)
+	{
+		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_absolute_in_var, NULL, 0, "scroll_cur4", ECPGst_normal, "fetch absolute $0 from scroll_cur4", 
+	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 395 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 395 "cursor-ra-fetch.pgc"
+
+
+		if (sqlca.sqlerrd[2] == 1)
+			printf("\trow %d: id: %d\tt: %s\n", i, id[0], t[0].arr);
+		else
+			printf("\trow %d does not exist\n", i);
+	}
+
+	/*
+	 * Let's see caching recovers by fetching 2x the readahead size.
+	 * The cursor must be at the end-1 (pos == -1) now,
+	 * with the cursor's pos, backend_pos, atstart and atend
+	 * correctly set.
+	 */
+
+	printf("\ntest fetch backward 8 from scroll_cur4 after the cursor switched to ecpg_execute()\n");
+
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_backward, "8", 0, "scroll_cur4", ECPGst_normal, "fetch backward 8 from scroll_cur4", ECPGt_EOIT, 
+	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 412 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 412 "cursor-ra-fetch.pgc"
+
+	for (i = 0; i < sqlca.sqlerrd[2]; i++)
+		printf("\tid: %d t: %s\n", id[i], t[i].arr);
+
+	{ ECPGtrans(__LINE__, NULL, "rollback", 0, 0, 1, NULL);
+#line 416 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 416 "cursor-ra-fetch.pgc"
+
+
+	/*
+	 * Test FETCH RELATIVE +/- 5 using positive positions.
+	 * Readahead is 4 so cache misses occur.
+	 * ecpglib will switch to plain ecpg_execute after 3 cache misses
+	 */
+
+	printf("\ntest scroll_cur4 for fetch relative 5 (positive positions)\n");
+
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 4, "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();}
+#line 426 "cursor-ra-fetch.pgc"
+
+	if (sqlca.sqlcode < 0)
+		printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate);
+
+	quit_loop = 0;
+	while (!quit_loop)
+	{
+		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_relative, "5", 0, "scroll_cur4", ECPGst_normal, "fetch relative 5 from scroll_cur4", ECPGt_EOIT, 
+	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 433 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 433 "cursor-ra-fetch.pgc"
+
+
+		if (sqlca.sqlerrd[2] == 1)
+			printf("\tid: %d\tt: %s\n", id[0], t[0].arr);
+		else
+			printf("\tfetch returned empty\n");
+		quit_loop = (sqlca.sqlerrd[2] == 0);
+	}
+
+	/*
+	 * Let's see caching recovers by fetching 2x the readahead size.
+	 * The cursor must be at the end now,
+	 * with the cursor's pos, backend_pos, atstart and atend
+	 * correctly set.
+	 */
+
+	printf("\ntest fetch backward 8 from scroll_cur4 after the cursor switched to ecpg_execute()\n");
+
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_backward, "8", 0, "scroll_cur4", ECPGst_normal, "fetch backward 8 from scroll_cur4", ECPGt_EOIT, 
+	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 451 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 451 "cursor-ra-fetch.pgc"
+
+	for (i = 0; i < sqlca.sqlerrd[2]; i++)
+		printf("\tid: %d t: %s\n", id[i], t[i].arr);
+
+	/* Exaggerate the number of tuples, move to the end. */
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "100", 1, "scroll_cur4", ECPGst_normal, "move forward 100 in scroll_cur4", ECPGt_EOIT, ECPGt_EORT);
+#line 456 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 456 "cursor-ra-fetch.pgc"
+
+	if (sqlca.sqlcode < 0)
+		printf("move forward 100 in scroll_cur4 failed with SQLSTATE %5s\n", sqlca.sqlstate);
+
+	printf("\ntest scroll_cur4 for fetch relative -5 (positive positions)\n");
+
+	quit_loop = 0;
+	while (!quit_loop)
+	{
+		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_relative, "- 5", 0, "scroll_cur4", ECPGst_normal, "fetch relative - 5 from scroll_cur4", ECPGt_EOIT, 
+	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 465 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 465 "cursor-ra-fetch.pgc"
+
+
+		if (sqlca.sqlerrd[2] == 1)
+			printf("\tid: %d\tt: %s\n", id[0], t[0].arr);
+		else
+			printf("\tfetch returned empty\n");
+		quit_loop = (sqlca.sqlerrd[2] == 0);
+	}
+
+	/*
+	 * Let's see caching recovers by fetching 2x the readahead size.
+	 * The cursor must be at the start now,
+	 * with the cursor's pos, backend_pos, atstart and atend
+	 * correctly set.
+	 */
+
+	printf("\ntest fetch forward 8 from scroll_cur4 after the cursor switched to ecpg_execute()\n");
+
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "8", 0, "scroll_cur4", ECPGst_normal, "fetch forward 8 from scroll_cur4", ECPGt_EOIT, 
+	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 483 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 483 "cursor-ra-fetch.pgc"
+
+	for (i = 0; i < sqlca.sqlerrd[2]; i++)
+		printf("\tid: %d t: %s\n", id[i], t[i].arr);
+
+	{ ECPGtrans(__LINE__, NULL, "rollback", 0, 0, 1, NULL);
+#line 487 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 487 "cursor-ra-fetch.pgc"
+
+
+	/*
+	 * Test FETCH RELATIVE +/- 5 using negative positions.
+	 * Readahead is 4 so cache misses occur.
+	 * ecpglib will switch to plain ecpg_execute after 3 cache misses
+	 */
+
+	printf("\ntest scroll_cur4 for move relative -5 (negative positions)\n");
+
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 4, "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();}
+#line 497 "cursor-ra-fetch.pgc"
+
+	if (sqlca.sqlcode < 0)
+		printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate);
+
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_absolute, "- 1", 1, "scroll_cur4", ECPGst_normal, "move absolute - 1 in scroll_cur4", ECPGt_EOIT, ECPGt_EORT);
+#line 501 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 501 "cursor-ra-fetch.pgc"
+
+	if (sqlca.sqlcode < 0)
+		printf("move absolute -1 in scroll_cur4 failed with SQLSTATE %5s\n", sqlca.sqlstate);
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", 1, "scroll_cur4", ECPGst_normal, "move forward 1 in scroll_cur4", ECPGt_EOIT, ECPGt_EORT);
+#line 504 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 504 "cursor-ra-fetch.pgc"
+
+	if (sqlca.sqlcode < 0)
+		printf("move forward 1 in scroll_cur4 failed with SQLSTATE %5s\n", sqlca.sqlstate);
+
+	quit_loop = 0;
+	while (!quit_loop)
+	{
+		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_relative, "- 5", 0, "scroll_cur4", ECPGst_normal, "fetch relative - 5 from scroll_cur4", ECPGt_EOIT, 
+	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 511 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 511 "cursor-ra-fetch.pgc"
+
+
+		if (sqlca.sqlerrd[2] == 1)
+			printf("\tid: %d\tt: %s\n", id[0], t[0].arr);
+		else
+			printf("\tfetch returned empty\n");
+		quit_loop = (sqlca.sqlerrd[2] == 0);
+	}
+
+	/*
+	 * Let's see caching recovers by fetching 2x the readahead size.
+	 * The cursor must be at the start now,
+	 * with the cursor's pos, backend_pos, atstart and atend
+	 * correctly set.
+	 */
+
+	printf("\ntest fetch forward 8 from scroll_cur4 after the cursor switched to ecpg_execute()\n");
+
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "8", 0, "scroll_cur4", ECPGst_normal, "fetch forward 8 from scroll_cur4", ECPGt_EOIT, 
+	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 529 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 529 "cursor-ra-fetch.pgc"
+
+	for (i = 0; i < sqlca.sqlerrd[2]; i++)
+		printf("\tid: %d t: %s\n", id[i], t[i].arr);
+
+	/* Exaggerate the number of tuples, move to the start. */
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_backward, "100", 1, "scroll_cur4", ECPGst_normal, "move backward 100 in scroll_cur4", ECPGt_EOIT, ECPGt_EORT);
+#line 534 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 534 "cursor-ra-fetch.pgc"
+
+	if (sqlca.sqlcode < 0)
+		printf("move backward 100 in scroll_cur4 failed with SQLSTATE %5s\n", sqlca.sqlstate);
+
+	printf("\ntest scroll_cur for move relative 5 (negative positions)\n");
+
+	quit_loop = 0;
+	while (!quit_loop)
+	{
+		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_relative, "5", 0, "scroll_cur4", ECPGst_normal, "fetch relative 5 from scroll_cur4", ECPGt_EOIT, 
+	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 543 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 543 "cursor-ra-fetch.pgc"
+
+
+		if (sqlca.sqlerrd[2] == 1)
+			printf("\tid: %d\tt: %s\n", id[0], t[0].arr);
+		else
+			printf("\tfetch returned empty\n");
+		quit_loop = (sqlca.sqlerrd[2] == 0);
+	}
+
+	/*
+	 * Let's see caching recovers by fetching 2x the readahead size.
+	 * The cursor must be at the end now,
+	 * with the cursor's pos, backend_pos, atstart and atend
+	 * correctly set.
+	 */
+
+	printf("\ntest fetch backward 8 from scroll_cur4 after the cursor switched to ecpg_execute()\n");
+
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_backward, "8", 0, "scroll_cur4", ECPGst_normal, "fetch backward 8 from scroll_cur4", ECPGt_EOIT, 
+	ECPGt_int,(id),(long)1,(long)8,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_varchar,(t),(long)50,(long)8,sizeof(struct varchar_1), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 561 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 561 "cursor-ra-fetch.pgc"
+
+	for (i = 0; i < sqlca.sqlerrd[2]; i++)
+		printf("\tid: %d t: %s\n", id[i], t[i].arr);
+
+	{ ECPGtrans(__LINE__, NULL, "rollback", 0, 0, 1, NULL);
+#line 565 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 565 "cursor-ra-fetch.pgc"
+
+
+	/* Drop the test table */
+
+	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
+#line 569 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 569 "cursor-ra-fetch.pgc"
+
+	{ ECPGtrans(__LINE__, NULL, "commit", 0, 0, 0, NULL);
+#line 570 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 570 "cursor-ra-fetch.pgc"
+
+
+	{ ECPGdisconnect(__LINE__, "ALL");
+#line 572 "cursor-ra-fetch.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 572 "cursor-ra-fetch.pgc"
+
+
+	return 0;
+}
diff --git a/src/interfaces/ecpg/test/expected/sql-cursor-ra-fetch.stderr b/src/interfaces/ecpg/test/expected/sql-cursor-ra-fetch.stderr
new file mode 100644
index 0000000..474dc04
--- /dev/null
+++ b/src/interfaces/ecpg/test/expected/sql-cursor-ra-fetch.stderr
@@ -0,0 +1,2806 @@
+[NO_PID]: ECPGdebug: set to 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 20: query: create table t1 ( id serial primary key , t text ); with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 20: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 20: OK: CREATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 21: query: insert into t1 ( t ) values ( 'a' ) , ( 'b' ) , ( 'c' ) , ( 'd' ) , ( 'e' ) , ( 'f' ) , ( 'g' ) , ( 'h' ) , ( 'i' ) , ( 'j' ) , ( 'k' ) , ( 'l' ) , ( 'm' ) , ( 'n' ) , ( 'o' ) , ( 'p' ) , ( 'q' ) , ( 'r' ) , ( 's' ) , ( 't' ) , ( 'u' ) , ( 'v' ) , ( 'w' ) , ( 'x' ) , ( 'y' ) , ( 'z' ); with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 21: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 21: OK: INSERT 0 26
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 26: action "commit"; connection "regress1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 38: query: declare scroll_cur scroll cursor for select id , t from t1 order by id; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 38: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 38: OK: DECLARE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 44: query: fetch absolute $0 from scroll_cur; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 44: query: fetch forward 8 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 44: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 44: command fetch forward 8 from scroll_cur; returned 8 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 44: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 44: RESULT: 1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 44: RESULT: a offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 44: query: fetch absolute $0 from scroll_cur; fetch all: 0 amount: 5
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 44: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 44: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 44: RESULT: 5 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 44: RESULT: e offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 44: query: fetch absolute $0 from scroll_cur; fetch all: 0 amount: 9
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 44: query: fetch forward 8 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 44: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 44: command fetch forward 8 from scroll_cur; returned 8 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 44: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 44: RESULT: 9 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 44: RESULT: i offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 44: query: fetch absolute $0 from scroll_cur; fetch all: 0 amount: 13
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 44: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 44: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 44: RESULT: 13 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 44: RESULT: m offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 44: query: fetch absolute $0 from scroll_cur; fetch all: 0 amount: 17
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 44: query: fetch forward 8 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 44: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 44: command fetch forward 8 from scroll_cur; returned 8 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 44: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 44: RESULT: 17 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 44: RESULT: q offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 44: query: fetch absolute $0 from scroll_cur; fetch all: 0 amount: 21
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 44: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 44: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 44: RESULT: 21 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 44: RESULT: u offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 44: query: fetch absolute $0 from scroll_cur; fetch all: 0 amount: 25
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 44: query: fetch forward 8 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 44: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 44: command fetch forward 8 from scroll_cur; returned 2 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 44: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 44: RESULT: 25 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 44: RESULT: y offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 44: query: fetch absolute $0 from scroll_cur; fetch all: 0 amount: 29
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 44: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 44: no data found on line 44
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ECPGfetch on line 56: query: fetch absolute $0 from scroll_cur; fetch all: 0 amount: 33
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 56: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 56: no data found on line 56
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ECPGfetch on line 56: query: fetch absolute $0 from scroll_cur; fetch all: 0 amount: 29
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 56: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 56: no data found on line 56
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ECPGfetch on line 56: query: fetch absolute $0 from scroll_cur; fetch all: 0 amount: 25
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 56: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 56: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 56: RESULT: 25 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 56: RESULT: y offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 56: query: fetch absolute $0 from scroll_cur; fetch all: 0 amount: 21
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 56: query: move absolute 20 in scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 56: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 56: query: fetch forward 8 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 56: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 56: command fetch forward 8 from scroll_cur; returned 6 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 56: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 56: RESULT: 21 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 56: RESULT: u offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 56: query: fetch absolute $0 from scroll_cur; fetch all: 0 amount: 17
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 56: query: move absolute 16 in scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 56: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 56: query: fetch forward 8 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 56: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 56: command fetch forward 8 from scroll_cur; returned 8 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 56: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 56: RESULT: 17 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 56: RESULT: q offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 56: query: fetch absolute $0 from scroll_cur; fetch all: 0 amount: 13
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 56: query: move absolute 12 in scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 56: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 56: query: fetch forward 8 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 56: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 56: command fetch forward 8 from scroll_cur; returned 8 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 56: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 56: RESULT: 13 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 56: RESULT: m offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 56: query: fetch absolute $0 from scroll_cur; fetch all: 0 amount: 9
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 56: query: fetch absolute 9 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 56: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 56: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 56: RESULT: 9 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 56: RESULT: i offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 56: query: fetch absolute $0 from scroll_cur; fetch all: 0 amount: 5
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 56: query: fetch absolute 5 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 56: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 56: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 56: RESULT: 5 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 56: RESULT: e offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 56: query: fetch absolute $0 from scroll_cur; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 56: query: fetch absolute 1 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 56: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 56: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 56: RESULT: 1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 56: RESULT: a offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 64: action "rollback"; connection "regress1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 73: query: declare scroll_cur scroll cursor for select id , t from t1 order by id; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 73: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 73: OK: DECLARE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 79: query: fetch absolute $0 from scroll_cur; fetch all: 0 amount: -1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 79: query: move forward all in scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 79: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 79: query: fetch backward 8 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 79: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 79: command fetch backward 8 from scroll_cur; returned 8 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 79: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 79: RESULT: 26 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 79: RESULT: z offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 79: query: fetch absolute $0 from scroll_cur; fetch all: 0 amount: -5
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 79: query: move absolute -4 in scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 79: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 79: query: fetch backward 8 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 79: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 79: command fetch backward 8 from scroll_cur; returned 8 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 79: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 79: RESULT: 22 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 79: RESULT: v offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 79: query: fetch absolute $0 from scroll_cur; fetch all: 0 amount: -9
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 79: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 79: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 79: RESULT: 18 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 79: RESULT: r offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 79: query: fetch absolute $0 from scroll_cur; fetch all: 0 amount: -13
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 79: query: fetch backward 8 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 79: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 79: command fetch backward 8 from scroll_cur; returned 8 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 79: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 79: RESULT: 14 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 79: RESULT: n offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 79: query: fetch absolute $0 from scroll_cur; fetch all: 0 amount: -17
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 79: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 79: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 79: RESULT: 10 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 79: RESULT: j offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 79: query: fetch absolute $0 from scroll_cur; fetch all: 0 amount: -21
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 79: query: fetch backward 8 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 79: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 79: command fetch backward 8 from scroll_cur; returned 6 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 79: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 79: RESULT: 6 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 79: RESULT: f offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 79: query: fetch absolute $0 from scroll_cur; fetch all: 0 amount: -25
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 79: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 79: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 79: RESULT: 2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 79: RESULT: b offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 79: query: fetch absolute $0 from scroll_cur; fetch all: 0 amount: -29
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 79: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 79: no data found on line 79
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ECPGfetch on line 91: query: fetch absolute $0 from scroll_cur; fetch all: 0 amount: -33
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 91: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 91: no data found on line 91
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ECPGfetch on line 91: query: fetch absolute $0 from scroll_cur; fetch all: 0 amount: -29
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 91: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 91: no data found on line 91
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ECPGfetch on line 91: query: fetch absolute $0 from scroll_cur; fetch all: 0 amount: -25
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 91: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 91: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 91: RESULT: 2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 91: RESULT: b offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 91: query: fetch absolute $0 from scroll_cur; fetch all: 0 amount: -21
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 91: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 91: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 91: RESULT: 6 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 91: RESULT: f offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 91: query: fetch absolute $0 from scroll_cur; fetch all: 0 amount: -17
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 91: query: move absolute -16 in scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 91: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 91: query: fetch backward 8 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 91: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 91: command fetch backward 8 from scroll_cur; returned 8 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 91: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 91: RESULT: 10 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 91: RESULT: j offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 91: query: fetch absolute $0 from scroll_cur; fetch all: 0 amount: -13
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 91: query: move absolute -12 in scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 91: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 91: query: fetch backward 8 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 91: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 91: command fetch backward 8 from scroll_cur; returned 8 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 91: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 91: RESULT: 14 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 91: RESULT: n offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 91: query: fetch absolute $0 from scroll_cur; fetch all: 0 amount: -9
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 91: query: move absolute -8 in scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 91: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 91: query: fetch backward 8 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 91: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 91: command fetch backward 8 from scroll_cur; returned 8 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 91: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 91: RESULT: 18 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 91: RESULT: r offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 91: query: fetch absolute $0 from scroll_cur; fetch all: 0 amount: -5
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 91: query: fetch absolute -5 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 91: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 91: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 91: RESULT: 22 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 91: RESULT: v offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 91: query: fetch absolute $0 from scroll_cur; fetch all: 0 amount: -1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 91: query: fetch absolute -1 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 91: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 91: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 91: RESULT: 26 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 91: RESULT: z offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 99: action "rollback"; connection "regress1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 108: query: declare scroll_cur scroll cursor for select id , t from t1 order by id; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 108: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 108: OK: DECLARE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 117: query: fetch relative 4 in scroll_cur; fetch all: 0 amount: 4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 117: query: move relative 3 in scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 117: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 117: query: fetch forward 8 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 117: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 117: command fetch forward 8 from scroll_cur; returned 8 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 117: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 117: RESULT: 4 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 117: RESULT: d offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 117: query: fetch relative 4 in scroll_cur; fetch all: 0 amount: 4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 117: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 117: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 117: RESULT: 8 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 117: RESULT: h offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 117: query: fetch relative 4 in scroll_cur; fetch all: 0 amount: 4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 117: query: fetch forward 8 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 117: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 117: command fetch forward 8 from scroll_cur; returned 8 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 117: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 117: RESULT: 12 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 117: RESULT: l offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 117: query: fetch relative 4 in scroll_cur; fetch all: 0 amount: 4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 117: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 117: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 117: RESULT: 16 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 117: RESULT: p offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 117: query: fetch relative 4 in scroll_cur; fetch all: 0 amount: 4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 117: query: fetch forward 8 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 117: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 117: command fetch forward 8 from scroll_cur; returned 7 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 117: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 117: RESULT: 20 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 117: RESULT: t offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 117: query: fetch relative 4 in scroll_cur; fetch all: 0 amount: 4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 117: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 117: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 117: RESULT: 24 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 117: RESULT: x offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 117: query: fetch relative 4 in scroll_cur; fetch all: 0 amount: 4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 117: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 117: no data found on line 117
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ECPGfetch on line 134: query: fetch relative - 4 in scroll_cur; fetch all: 0 amount: -4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 134: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 134: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 134: RESULT: 23 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 134: RESULT: w offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 134: query: fetch relative - 4 in scroll_cur; fetch all: 0 amount: -4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 134: query: move absolute 20 in scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 134: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 134: query: fetch backward 8 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 134: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 134: command fetch backward 8 from scroll_cur; returned 8 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 134: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 134: RESULT: 19 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 134: RESULT: s offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 134: query: fetch relative - 4 in scroll_cur; fetch all: 0 amount: -4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 134: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 134: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 134: RESULT: 15 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 134: RESULT: o offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 134: query: fetch relative - 4 in scroll_cur; fetch all: 0 amount: -4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 134: query: fetch backward 8 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 134: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 134: command fetch backward 8 from scroll_cur; returned 8 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 134: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 134: RESULT: 11 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 134: RESULT: k offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 134: query: fetch relative - 4 in scroll_cur; fetch all: 0 amount: -4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 134: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 134: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 134: RESULT: 7 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 134: RESULT: g offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 134: query: fetch relative - 4 in scroll_cur; fetch all: 0 amount: -4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 134: query: fetch backward 8 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 134: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 134: command fetch backward 8 from scroll_cur; returned 3 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 134: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 134: RESULT: 3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 134: RESULT: c offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 134: query: fetch relative - 4 in scroll_cur; fetch all: 0 amount: -4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 134: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 134: no data found on line 134
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ECPGtrans on line 144: action "rollback"; connection "regress1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 153: query: declare scroll_cur scroll cursor for select id , t from t1 order by id; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 153: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 153: OK: DECLARE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 157: query: move absolute - 1 in scroll_cur; fetch all: 0 amount: -1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 157: query: move absolute -1 in scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 157: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 157: stmt->results is NULL, ignoring
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 160: query: move forward 1 in scroll_cur; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 160: stmt->results is NULL, ignoring
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 169: query: fetch relative - 4 in scroll_cur; fetch all: 0 amount: -4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 169: query: move forward all in scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 169: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 169: query: move relative -3 in scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 169: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 169: query: fetch backward 8 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 169: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 169: command fetch backward 8 from scroll_cur; returned 8 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 169: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 169: RESULT: 23 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 169: RESULT: w offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 169: query: fetch relative - 4 in scroll_cur; fetch all: 0 amount: -4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 169: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 169: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 169: RESULT: 19 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 169: RESULT: s offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 169: query: fetch relative - 4 in scroll_cur; fetch all: 0 amount: -4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 169: query: fetch backward 8 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 169: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 169: command fetch backward 8 from scroll_cur; returned 8 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 169: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 169: RESULT: 15 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 169: RESULT: o offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 169: query: fetch relative - 4 in scroll_cur; fetch all: 0 amount: -4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 169: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 169: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 169: RESULT: 11 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 169: RESULT: k offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 169: query: fetch relative - 4 in scroll_cur; fetch all: 0 amount: -4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 169: query: fetch backward 8 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 169: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 169: command fetch backward 8 from scroll_cur; returned 7 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 169: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 169: RESULT: 7 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 169: RESULT: g offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 169: query: fetch relative - 4 in scroll_cur; fetch all: 0 amount: -4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 169: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 169: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 169: RESULT: 3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 169: RESULT: c offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 169: query: fetch relative - 4 in scroll_cur; fetch all: 0 amount: -4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 169: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 169: no data found on line 169
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ECPGfetch on line 186: query: fetch relative 4 in scroll_cur; fetch all: 0 amount: 4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 186: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 186: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 186: RESULT: 4 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 186: RESULT: d offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 186: query: fetch relative 4 in scroll_cur; fetch all: 0 amount: 4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 186: query: move absolute -20 in scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 186: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 186: query: fetch forward 8 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 186: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 186: command fetch forward 8 from scroll_cur; returned 8 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 186: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 186: RESULT: 8 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 186: RESULT: h offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 186: query: fetch relative 4 in scroll_cur; fetch all: 0 amount: 4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 186: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 186: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 186: RESULT: 12 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 186: RESULT: l offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 186: query: fetch relative 4 in scroll_cur; fetch all: 0 amount: 4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 186: query: fetch forward 8 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 186: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 186: command fetch forward 8 from scroll_cur; returned 8 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 186: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 186: RESULT: 16 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 186: RESULT: p offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 186: query: fetch relative 4 in scroll_cur; fetch all: 0 amount: 4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 186: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 186: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 186: RESULT: 20 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 186: RESULT: t offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 186: query: fetch relative 4 in scroll_cur; fetch all: 0 amount: 4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 186: query: fetch forward 8 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 186: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 186: command fetch forward 8 from scroll_cur; returned 3 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 186: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 186: RESULT: 24 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 186: RESULT: x offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 186: query: fetch relative 4 in scroll_cur; fetch all: 0 amount: 4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 186: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 186: no data found on line 186
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ECPGtrans on line 196: action "rollback"; connection "regress1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 205: query: declare scroll_cur scroll cursor for select id , t from t1 order by id; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 205: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 205: OK: DECLARE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 214: query: fetch forward 4 in scroll_cur; fetch all: 0 amount: 4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 214: query: fetch forward 8 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 214: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 214: command fetch forward 8 from scroll_cur; returned 8 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 214: correctly got 4 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: 1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: 2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: 3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: 4 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: a offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: b offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: c offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: d offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 214: query: fetch forward 4 in scroll_cur; fetch all: 0 amount: 4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 214: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 214: correctly got 4 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: 5 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: 6 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: 7 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: 8 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: e offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: f offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: g offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: h offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 214: query: fetch forward 4 in scroll_cur; fetch all: 0 amount: 4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 214: query: fetch forward 8 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 214: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 214: command fetch forward 8 from scroll_cur; returned 8 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 214: correctly got 4 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: 9 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: 10 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: 11 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: 12 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: i offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: j offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: k offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: l offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 214: query: fetch forward 4 in scroll_cur; fetch all: 0 amount: 4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 214: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 214: correctly got 4 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: 13 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: 14 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: 15 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: 16 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: m offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: n offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: o offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: p offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 214: query: fetch forward 4 in scroll_cur; fetch all: 0 amount: 4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 214: query: fetch forward 8 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 214: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 214: command fetch forward 8 from scroll_cur; returned 8 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 214: correctly got 4 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: 17 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: 18 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: 19 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: 20 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: q offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: r offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: s offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: t offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 214: query: fetch forward 4 in scroll_cur; fetch all: 0 amount: 4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 214: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 214: correctly got 4 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: 21 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: 22 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: 23 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: 24 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: u offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: v offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: w offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: x offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 214: query: fetch forward 4 in scroll_cur; fetch all: 0 amount: 4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 214: query: fetch forward 8 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 214: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 214: command fetch forward 8 from scroll_cur; returned 2 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 214: correctly got 2 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: 25 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: 26 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: y offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 214: RESULT: z offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 214: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 214: query: fetch forward 4 in scroll_cur; fetch all: 0 amount: 4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 214: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 214: no data found on line 214
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ECPGfetch on line 231: query: fetch forward - 4 in scroll_cur; fetch all: 0 amount: -4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 231: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 231: correctly got 2 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: 26 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: 25 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: z offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: y offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 231: query: move absolute 25 in scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 231: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 231: query: fetch backward 8 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 231: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 231: command fetch backward 8 from scroll_cur; returned 8 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 231: correctly got 2 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: 24 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: 23 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: x offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: w offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 231: query: fetch forward - 4 in scroll_cur; fetch all: 0 amount: -4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 231: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 231: correctly got 4 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: 22 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: 21 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: 20 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: 19 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: v offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: u offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: t offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: s offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 231: query: fetch forward - 4 in scroll_cur; fetch all: 0 amount: -4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 231: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 231: correctly got 2 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: 18 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: 17 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: r offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: q offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 231: query: fetch backward 8 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 231: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 231: command fetch backward 8 from scroll_cur; returned 8 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 231: correctly got 2 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: 16 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: 15 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: p offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: o offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 231: query: fetch forward - 4 in scroll_cur; fetch all: 0 amount: -4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 231: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 231: correctly got 4 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: 14 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: 13 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: 12 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: 11 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: n offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: m offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: l offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: k offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 231: query: fetch forward - 4 in scroll_cur; fetch all: 0 amount: -4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 231: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 231: correctly got 2 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: 10 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: 9 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: j offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: i offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 231: query: fetch backward 8 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 231: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 231: command fetch backward 8 from scroll_cur; returned 8 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 231: correctly got 2 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: 8 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: 7 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: h offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: g offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 231: query: fetch forward - 4 in scroll_cur; fetch all: 0 amount: -4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 231: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 231: correctly got 4 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: 6 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: 5 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: 4 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: 3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: f offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: e offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: d offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: c offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 231: query: fetch forward - 4 in scroll_cur; fetch all: 0 amount: -4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 231: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 231: correctly got 2 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: 2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: 1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: b offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 231: RESULT: a offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 231: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 231: query: fetch forward - 4 in scroll_cur; fetch all: 0 amount: -4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 231: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 231: no data found on line 231
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ECPGtrans on line 241: action "rollback"; connection "regress1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 250: query: declare scroll_cur scroll cursor for select id , t from t1 order by id; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 250: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 250: OK: DECLARE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 254: query: move absolute - 1 in scroll_cur; fetch all: 0 amount: -1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 254: query: move absolute -1 in scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 254: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 254: stmt->results is NULL, ignoring
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 257: query: move forward 1 in scroll_cur; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 257: stmt->results is NULL, ignoring
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 266: query: fetch forward - 4 in scroll_cur; fetch all: 0 amount: -4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 266: query: move forward all in scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 266: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 266: query: fetch backward 8 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 266: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 266: command fetch backward 8 from scroll_cur; returned 8 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 266: correctly got 4 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: 26 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: 25 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: 24 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: 23 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: z offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: y offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: x offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: w offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 266: query: fetch forward - 4 in scroll_cur; fetch all: 0 amount: -4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 266: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 266: correctly got 4 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: 22 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: 21 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: 20 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: 19 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: v offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: u offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: t offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: s offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 266: query: fetch forward - 4 in scroll_cur; fetch all: 0 amount: -4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 266: query: fetch backward 8 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 266: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 266: command fetch backward 8 from scroll_cur; returned 8 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 266: correctly got 4 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: 18 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: 17 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: 16 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: 15 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: r offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: q offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: p offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: o offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 266: query: fetch forward - 4 in scroll_cur; fetch all: 0 amount: -4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 266: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 266: correctly got 4 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: 14 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: 13 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: 12 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: 11 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: n offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: m offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: l offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: k offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 266: query: fetch forward - 4 in scroll_cur; fetch all: 0 amount: -4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 266: query: fetch backward 8 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 266: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 266: command fetch backward 8 from scroll_cur; returned 8 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 266: correctly got 4 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: 10 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: 9 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: 8 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: 7 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: j offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: i offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: h offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: g offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 266: query: fetch forward - 4 in scroll_cur; fetch all: 0 amount: -4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 266: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 266: correctly got 4 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: 6 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: 5 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: 4 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: 3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: f offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: e offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: d offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: c offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 266: query: fetch forward - 4 in scroll_cur; fetch all: 0 amount: -4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 266: query: fetch backward 8 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 266: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 266: command fetch backward 8 from scroll_cur; returned 2 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 266: correctly got 2 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: 2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: 1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: b offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 266: RESULT: a offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 266: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 266: query: fetch forward - 4 in scroll_cur; fetch all: 0 amount: -4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 266: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 266: no data found on line 266
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ECPGfetch on line 283: query: fetch forward 4 in scroll_cur; fetch all: 0 amount: 4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 283: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 283: correctly got 2 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: 1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: 2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: a offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: b offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 283: query: move absolute -25 in scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 283: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 283: query: fetch forward 8 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 283: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 283: command fetch forward 8 from scroll_cur; returned 8 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 283: correctly got 2 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: 3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: 4 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: c offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: d offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 283: query: fetch forward 4 in scroll_cur; fetch all: 0 amount: 4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 283: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 283: correctly got 4 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: 5 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: 6 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: 7 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: 8 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: e offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: f offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: g offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: h offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 283: query: fetch forward 4 in scroll_cur; fetch all: 0 amount: 4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 283: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 283: correctly got 2 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: 9 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: 10 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: i offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: j offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 283: query: fetch forward 8 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 283: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 283: command fetch forward 8 from scroll_cur; returned 8 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 283: correctly got 2 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: 11 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: 12 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: k offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: l offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 283: query: fetch forward 4 in scroll_cur; fetch all: 0 amount: 4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 283: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 283: correctly got 4 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: 13 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: 14 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: 15 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: 16 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: m offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: n offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: o offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: p offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 283: query: fetch forward 4 in scroll_cur; fetch all: 0 amount: 4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 283: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 283: correctly got 2 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: 17 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: 18 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: q offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: r offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 283: query: fetch forward 8 from scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 283: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 283: command fetch forward 8 from scroll_cur; returned 8 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 283: correctly got 2 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: 19 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: 20 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: s offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: t offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 283: query: fetch forward 4 in scroll_cur; fetch all: 0 amount: 4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 283: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 283: correctly got 4 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: 21 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: 22 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: 23 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: 24 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: u offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: v offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: w offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: x offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 283: query: fetch forward 4 in scroll_cur; fetch all: 0 amount: 4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 283: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 283: correctly got 2 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: 25 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: 26 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: y offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 283: RESULT: z offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 283: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 283: query: fetch forward 4 in scroll_cur; fetch all: 0 amount: 4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 283: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 283: no data found on line 283
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ECPGtrans on line 293: action "rollback"; connection "regress1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 303: query: declare scroll_cur4 scroll cursor for select id , t from t1 order by id; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 303: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 303: OK: DECLARE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 309: query: fetch absolute $0 from scroll_cur4; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 309: query: fetch forward 4 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 309: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 309: command fetch forward 4 from scroll_cur4; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 309: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 309: RESULT: 1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 309: RESULT: a offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 309: query: fetch absolute $0 from scroll_cur4; fetch all: 0 amount: 6
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 309: query: move absolute 5 in scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 309: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 309: query: fetch forward 4 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 309: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 309: command fetch forward 4 from scroll_cur4; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 309: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 309: RESULT: 6 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 309: RESULT: f offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 309: query: fetch absolute $0 from scroll_cur4; fetch all: 0 amount: 11
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 309: query: move absolute 10 in scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 309: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 309: query: fetch forward 4 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 309: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 309: command fetch forward 4 from scroll_cur4; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 309: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 309: RESULT: 11 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 309: RESULT: k offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 309: query: fetch absolute $0 from scroll_cur4; fetch all: 0 amount: 16
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 309: query: fetch absolute 16 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 309: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 309: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 309: RESULT: 16 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 309: RESULT: p offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 309: query: fetch absolute $0 from scroll_cur4; fetch all: 0 amount: 21
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 309: query: fetch absolute 21 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 309: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 309: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 309: RESULT: 21 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 309: RESULT: u offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 309: query: fetch absolute $0 from scroll_cur4; fetch all: 0 amount: 26
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 309: query: fetch absolute 26 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 309: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 309: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 309: RESULT: 26 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 309: RESULT: z offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 309: query: fetch absolute $0 from scroll_cur4; fetch all: 0 amount: 31
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 309: query: fetch absolute 31 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 309: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 309: correctly got 0 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 309: no data found on line 309
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ECPGfetch on line 325: query: fetch backward 8 from scroll_cur4; fetch all: 0 amount: -8
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 325: query: fetch backward 4 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 325: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 325: command fetch backward 4 from scroll_cur4; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 325: correctly got 4 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 325: RESULT: 26 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 325: RESULT: 25 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 325: RESULT: 24 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 325: RESULT: 23 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 325: RESULT: z offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 325: RESULT: y offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 325: RESULT: x offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 325: RESULT: w offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 325: query: fetch backward 4 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 325: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 325: command fetch backward 4 from scroll_cur4; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 325: correctly got 4 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 325: RESULT: 22 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 325: RESULT: 21 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 325: RESULT: 20 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 325: RESULT: 19 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 325: RESULT: v offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 325: RESULT: u offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 325: RESULT: t offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 325: RESULT: s offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 333: query: fetch absolute $0 from scroll_cur4; fetch all: 0 amount: 36
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 333: query: move absolute 35 in scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 333: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 333: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 333: no data found on line 333
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ECPGfetch on line 333: query: fetch absolute $0 from scroll_cur4; fetch all: 0 amount: 31
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 333: query: move absolute 30 in scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 333: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 333: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 333: no data found on line 333
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ECPGfetch on line 333: query: fetch absolute $0 from scroll_cur4; fetch all: 0 amount: 26
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 333: query: move absolute 25 in scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 333: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 333: query: fetch forward 4 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 333: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 333: command fetch forward 4 from scroll_cur4; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 333: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 333: RESULT: 26 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 333: RESULT: z offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 333: query: fetch absolute $0 from scroll_cur4; fetch all: 0 amount: 21
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 333: query: move absolute 20 in scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 333: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 333: query: fetch forward 4 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 333: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 333: command fetch forward 4 from scroll_cur4; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 333: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 333: RESULT: 21 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 333: RESULT: u offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 333: query: fetch absolute $0 from scroll_cur4; fetch all: 0 amount: 16
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 333: query: move absolute 15 in scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 333: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 333: query: fetch forward 4 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 333: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 333: command fetch forward 4 from scroll_cur4; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 333: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 333: RESULT: 16 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 333: RESULT: p offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 333: query: fetch absolute $0 from scroll_cur4; fetch all: 0 amount: 11
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 333: query: fetch absolute 11 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 333: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 333: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 333: RESULT: 11 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 333: RESULT: k offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 333: query: fetch absolute $0 from scroll_cur4; fetch all: 0 amount: 6
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 333: query: fetch absolute 6 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 333: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 333: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 333: RESULT: 6 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 333: RESULT: f offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 333: query: fetch absolute $0 from scroll_cur4; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 333: query: fetch absolute 1 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 333: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 333: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 333: RESULT: 1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 333: RESULT: a offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 350: query: fetch forward 8 from scroll_cur4; fetch all: 0 amount: 8
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 350: query: fetch forward 4 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 350: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 350: command fetch forward 4 from scroll_cur4; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 350: correctly got 4 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 350: RESULT: 2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 350: RESULT: 3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 350: RESULT: 4 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 350: RESULT: 5 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 350: RESULT: b offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 350: RESULT: c offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 350: RESULT: d offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 350: RESULT: e offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 350: query: fetch forward 4 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 350: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 350: command fetch forward 4 from scroll_cur4; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 350: correctly got 4 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 350: RESULT: 6 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 350: RESULT: 7 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 350: RESULT: 8 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 350: RESULT: 9 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 350: RESULT: f offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 350: RESULT: g offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 350: RESULT: h offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 350: RESULT: i offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 354: action "rollback"; connection "regress1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 364: query: declare scroll_cur4 scroll cursor for select id , t from t1 order by id; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 364: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 364: OK: DECLARE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 370: query: fetch absolute $0 from scroll_cur4; fetch all: 0 amount: -1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 370: query: move forward all in scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 370: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 370: query: fetch backward 4 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 370: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 370: command fetch backward 4 from scroll_cur4; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 370: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 370: RESULT: 26 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 370: RESULT: z offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 370: query: fetch absolute $0 from scroll_cur4; fetch all: 0 amount: -6
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 370: query: move absolute -5 in scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 370: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 370: query: fetch backward 4 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 370: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 370: command fetch backward 4 from scroll_cur4; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 370: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 370: RESULT: 21 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 370: RESULT: u offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 370: query: fetch absolute $0 from scroll_cur4; fetch all: 0 amount: -11
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 370: query: move absolute -10 in scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 370: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 370: query: fetch backward 4 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 370: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 370: command fetch backward 4 from scroll_cur4; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 370: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 370: RESULT: 16 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 370: RESULT: p offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 370: query: fetch absolute $0 from scroll_cur4; fetch all: 0 amount: -16
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 370: query: fetch absolute -16 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 370: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 370: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 370: RESULT: 11 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 370: RESULT: k offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 370: query: fetch absolute $0 from scroll_cur4; fetch all: 0 amount: -21
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 370: query: fetch absolute -21 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 370: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 370: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 370: RESULT: 6 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 370: RESULT: f offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 370: query: fetch absolute $0 from scroll_cur4; fetch all: 0 amount: -26
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 370: query: fetch absolute -26 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 370: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 370: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 370: RESULT: 1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 370: RESULT: a offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 370: query: fetch absolute $0 from scroll_cur4; fetch all: 0 amount: -31
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 370: query: fetch absolute -31 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 370: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 370: correctly got 0 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 370: no data found on line 370
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ECPGfetch on line 387: query: fetch forward 8 from scroll_cur4; fetch all: 0 amount: 8
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 387: query: fetch forward 4 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 387: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 387: command fetch forward 4 from scroll_cur4; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 387: correctly got 4 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 387: RESULT: 1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 387: RESULT: 2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 387: RESULT: 3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 387: RESULT: 4 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 387: RESULT: a offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 387: RESULT: b offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 387: RESULT: c offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 387: RESULT: d offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 387: query: fetch forward 4 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 387: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 387: command fetch forward 4 from scroll_cur4; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 387: correctly got 4 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 387: RESULT: 5 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 387: RESULT: 6 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 387: RESULT: 7 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 387: RESULT: 8 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 387: RESULT: e offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 387: RESULT: f offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 387: RESULT: g offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 387: RESULT: h offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 395: query: fetch absolute $0 from scroll_cur4; fetch all: 0 amount: -36
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 395: query: move absolute -35 in scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 395: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 395: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 395: no data found on line 395
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ECPGfetch on line 395: query: fetch absolute $0 from scroll_cur4; fetch all: 0 amount: -31
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 395: query: move absolute -30 in scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 395: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 395: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 395: no data found on line 395
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ECPGfetch on line 395: query: fetch absolute $0 from scroll_cur4; fetch all: 0 amount: -26
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 395: query: move absolute -25 in scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 395: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 395: query: fetch backward 4 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 395: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 395: command fetch backward 4 from scroll_cur4; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 395: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 395: RESULT: 1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 395: RESULT: a offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 395: query: fetch absolute $0 from scroll_cur4; fetch all: 0 amount: -21
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 395: query: move absolute -20 in scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 395: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 395: query: fetch backward 4 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 395: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 395: command fetch backward 4 from scroll_cur4; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 395: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 395: RESULT: 6 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 395: RESULT: f offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 395: query: fetch absolute $0 from scroll_cur4; fetch all: 0 amount: -16
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 395: query: move absolute -15 in scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 395: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 395: query: fetch backward 4 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 395: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 395: command fetch backward 4 from scroll_cur4; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 395: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 395: RESULT: 11 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 395: RESULT: k offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 395: query: fetch absolute $0 from scroll_cur4; fetch all: 0 amount: -11
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 395: query: fetch absolute -11 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 395: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 395: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 395: RESULT: 16 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 395: RESULT: p offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 395: query: fetch absolute $0 from scroll_cur4; fetch all: 0 amount: -6
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 395: query: fetch absolute -6 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 395: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 395: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 395: RESULT: 21 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 395: RESULT: u offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 395: query: fetch absolute $0 from scroll_cur4; fetch all: 0 amount: -1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 395: query: fetch absolute -1 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 395: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 395: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 395: RESULT: 26 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 395: RESULT: z offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 412: query: fetch backward 8 from scroll_cur4; fetch all: 0 amount: -8
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 412: query: fetch backward 4 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 412: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 412: command fetch backward 4 from scroll_cur4; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 412: correctly got 4 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 412: RESULT: 25 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 412: RESULT: 24 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 412: RESULT: 23 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 412: RESULT: 22 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 412: RESULT: y offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 412: RESULT: x offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 412: RESULT: w offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 412: RESULT: v offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 412: query: fetch backward 4 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 412: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 412: command fetch backward 4 from scroll_cur4; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 412: correctly got 4 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 412: RESULT: 21 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 412: RESULT: 20 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 412: RESULT: 19 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 412: RESULT: 18 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 412: RESULT: u offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 412: RESULT: t offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 412: RESULT: s offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 412: RESULT: r offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 416: action "rollback"; connection "regress1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 426: query: declare scroll_cur4 scroll cursor for select id , t from t1 order by id; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 426: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 426: OK: DECLARE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 433: query: fetch relative 5 from scroll_cur4; fetch all: 0 amount: 5
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 433: query: move relative 4 in scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 433: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 433: query: fetch forward 4 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 433: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 433: command fetch forward 4 from scroll_cur4; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 433: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 433: RESULT: 5 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 433: RESULT: e offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 433: query: fetch relative 5 from scroll_cur4; fetch all: 0 amount: 5
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 433: query: move absolute 5 in scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 433: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 433: query: move relative 4 in scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 433: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 433: query: fetch forward 4 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 433: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 433: command fetch forward 4 from scroll_cur4; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 433: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 433: RESULT: 10 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 433: RESULT: j offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 433: query: fetch relative 5 from scroll_cur4; fetch all: 0 amount: 5
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 433: query: move absolute 10 in scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 433: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 433: query: move relative 4 in scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 433: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 433: query: fetch forward 4 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 433: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 433: command fetch forward 4 from scroll_cur4; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 433: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 433: RESULT: 15 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 433: RESULT: o offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 433: query: fetch relative 5 from scroll_cur4; fetch all: 0 amount: 5
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 433: query: move absolute 15 in scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 433: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 433: query: fetch relative 5 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 433: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 433: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 433: RESULT: 20 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 433: RESULT: t offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 433: query: fetch relative 5 from scroll_cur4; fetch all: 0 amount: 5
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 433: query: fetch relative 5 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 433: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 433: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 433: RESULT: 25 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 433: RESULT: y offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 433: query: fetch relative 5 from scroll_cur4; fetch all: 0 amount: 5
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 433: query: fetch relative 5 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 433: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 433: correctly got 0 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 433: no data found on line 433
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ECPGfetch on line 451: query: fetch backward 8 from scroll_cur4; fetch all: 0 amount: -8
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 451: query: fetch backward 4 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 451: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 451: command fetch backward 4 from scroll_cur4; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 451: correctly got 4 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 451: RESULT: 26 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 451: RESULT: 25 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 451: RESULT: 24 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 451: RESULT: 23 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 451: RESULT: z offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 451: RESULT: y offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 451: RESULT: x offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 451: RESULT: w offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 451: query: fetch backward 4 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 451: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 451: command fetch backward 4 from scroll_cur4; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 451: correctly got 4 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 451: RESULT: 22 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 451: RESULT: 21 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 451: RESULT: 20 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 451: RESULT: 19 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 451: RESULT: v offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 451: RESULT: u offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 451: RESULT: t offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 451: RESULT: s offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 456: query: move forward 100 in scroll_cur4; fetch all: 0 amount: 100
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 456: stmt->results is NULL, ignoring
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 465: query: fetch relative - 5 from scroll_cur4; fetch all: 0 amount: -5
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 465: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 465: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 465: RESULT: 22 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 465: RESULT: v offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 465: query: fetch relative - 5 from scroll_cur4; fetch all: 0 amount: -5
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 465: query: move absolute -9 in scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 465: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 465: query: fetch backward 4 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 465: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 465: command fetch backward 4 from scroll_cur4; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 465: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 465: RESULT: 17 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 465: RESULT: q offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 465: query: fetch relative - 5 from scroll_cur4; fetch all: 0 amount: -5
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 465: query: move absolute -14 in scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 465: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 465: query: fetch backward 4 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 465: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 465: command fetch backward 4 from scroll_cur4; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 465: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 465: RESULT: 12 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 465: RESULT: l offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 465: query: fetch relative - 5 from scroll_cur4; fetch all: 0 amount: -5
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 465: query: move absolute -19 in scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 465: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 465: query: fetch backward 4 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 465: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 465: command fetch backward 4 from scroll_cur4; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 465: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 465: RESULT: 7 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 465: RESULT: g offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 465: query: fetch relative - 5 from scroll_cur4; fetch all: 0 amount: -5
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 465: query: move absolute -20 in scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 465: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 465: query: fetch relative - 5 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 465: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 465: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 465: RESULT: 2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 465: RESULT: b offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 465: query: fetch relative - 5 from scroll_cur4; fetch all: 0 amount: -5
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 465: query: fetch relative - 5 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 465: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 465: correctly got 0 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 465: no data found on line 465
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ECPGfetch on line 483: query: fetch forward 8 from scroll_cur4; fetch all: 0 amount: 8
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 483: query: fetch forward 4 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 483: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 483: command fetch forward 4 from scroll_cur4; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 483: correctly got 4 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 483: RESULT: 1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 483: RESULT: 2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 483: RESULT: 3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 483: RESULT: 4 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 483: RESULT: a offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 483: RESULT: b offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 483: RESULT: c offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 483: RESULT: d offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 483: query: fetch forward 4 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 483: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 483: command fetch forward 4 from scroll_cur4; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 483: correctly got 4 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 483: RESULT: 5 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 483: RESULT: 6 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 483: RESULT: 7 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 483: RESULT: 8 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 483: RESULT: e offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 483: RESULT: f offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 483: RESULT: g offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 483: RESULT: h offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 487: action "rollback"; connection "regress1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 497: query: declare scroll_cur4 scroll cursor for select id , t from t1 order by id; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 497: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 497: OK: DECLARE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 501: query: move absolute - 1 in scroll_cur4; fetch all: 0 amount: -1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 501: query: move absolute -1 in scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 501: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 501: stmt->results is NULL, ignoring
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 504: query: move forward 1 in scroll_cur4; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 504: stmt->results is NULL, ignoring
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 511: query: fetch relative - 5 from scroll_cur4; fetch all: 0 amount: -5
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 511: query: move forward all in scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 511: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 511: query: move relative -4 in scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 511: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 511: query: fetch backward 4 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 511: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 511: command fetch backward 4 from scroll_cur4; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 511: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 511: RESULT: 22 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 511: RESULT: v offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 511: query: fetch relative - 5 from scroll_cur4; fetch all: 0 amount: -5
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 511: query: move absolute -5 in scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 511: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 511: query: move relative -4 in scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 511: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 511: query: fetch backward 4 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 511: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 511: command fetch backward 4 from scroll_cur4; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 511: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 511: RESULT: 17 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 511: RESULT: q offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 511: query: fetch relative - 5 from scroll_cur4; fetch all: 0 amount: -5
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 511: query: move absolute -10 in scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 511: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 511: query: move relative -4 in scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 511: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 511: query: fetch backward 4 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 511: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 511: command fetch backward 4 from scroll_cur4; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 511: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 511: RESULT: 12 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 511: RESULT: l offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 511: query: fetch relative - 5 from scroll_cur4; fetch all: 0 amount: -5
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 511: query: move absolute -15 in scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 511: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 511: query: fetch relative - 5 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 511: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 511: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 511: RESULT: 7 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 511: RESULT: g offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 511: query: fetch relative - 5 from scroll_cur4; fetch all: 0 amount: -5
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 511: query: fetch relative - 5 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 511: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 511: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 511: RESULT: 2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 511: RESULT: b offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 511: query: fetch relative - 5 from scroll_cur4; fetch all: 0 amount: -5
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 511: query: fetch relative - 5 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 511: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 511: correctly got 0 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 511: no data found on line 511
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ECPGfetch on line 529: query: fetch forward 8 from scroll_cur4; fetch all: 0 amount: 8
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 529: query: fetch forward 4 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 529: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 529: command fetch forward 4 from scroll_cur4; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 529: correctly got 4 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 529: RESULT: 1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 529: RESULT: 2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 529: RESULT: 3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 529: RESULT: 4 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 529: RESULT: a offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 529: RESULT: b offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 529: RESULT: c offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 529: RESULT: d offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 529: query: fetch forward 4 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 529: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 529: command fetch forward 4 from scroll_cur4; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 529: correctly got 4 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 529: RESULT: 5 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 529: RESULT: 6 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 529: RESULT: 7 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 529: RESULT: 8 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 529: RESULT: e offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 529: RESULT: f offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 529: RESULT: g offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 529: RESULT: h offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 534: query: move backward 100 in scroll_cur4; fetch all: 0 amount: -100
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 534: stmt->results is NULL, ignoring
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 543: query: fetch relative 5 from scroll_cur4; fetch all: 0 amount: 5
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 543: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 543: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 543: RESULT: 5 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 543: RESULT: e offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 543: query: fetch relative 5 from scroll_cur4; fetch all: 0 amount: 5
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 543: query: move absolute 9 in scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 543: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 543: query: fetch forward 4 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 543: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 543: command fetch forward 4 from scroll_cur4; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 543: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 543: RESULT: 10 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 543: RESULT: j offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 543: query: fetch relative 5 from scroll_cur4; fetch all: 0 amount: 5
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 543: query: move absolute 14 in scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 543: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 543: query: fetch forward 4 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 543: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 543: command fetch forward 4 from scroll_cur4; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 543: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 543: RESULT: 15 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 543: RESULT: o offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 543: query: fetch relative 5 from scroll_cur4; fetch all: 0 amount: 5
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 543: query: move absolute 19 in scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 543: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 543: query: fetch forward 4 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 543: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 543: command fetch forward 4 from scroll_cur4; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 543: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 543: RESULT: 20 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 543: RESULT: t offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 543: query: fetch relative 5 from scroll_cur4; fetch all: 0 amount: 5
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 543: query: move absolute 20 in scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 543: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 543: query: fetch relative 5 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 543: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 543: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 543: RESULT: 25 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 543: RESULT: y offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 543: query: fetch relative 5 from scroll_cur4; fetch all: 0 amount: 5
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 543: query: fetch relative 5 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 543: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 543: correctly got 0 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 543: no data found on line 543
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ECPGfetch on line 561: query: fetch backward 8 from scroll_cur4; fetch all: 0 amount: -8
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 561: query: fetch backward 4 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 561: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 561: command fetch backward 4 from scroll_cur4; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 561: correctly got 4 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 561: RESULT: 26 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 561: RESULT: 25 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 561: RESULT: 24 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 561: RESULT: 23 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 561: RESULT: z offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 561: RESULT: y offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 561: RESULT: x offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 561: RESULT: w offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 561: query: fetch backward 4 from scroll_cur4; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 561: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 561: command fetch backward 4 from scroll_cur4; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 561: correctly got 4 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 561: RESULT: 22 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 561: RESULT: 21 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 561: RESULT: 20 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 561: RESULT: 19 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 561: RESULT: v offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 561: RESULT: u offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 561: RESULT: t offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 561: RESULT: s offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 565: action "rollback"; connection "regress1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 569: query: drop table t1; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 569: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 569: OK: DROP TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 570: action "commit"; connection "regress1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_finish: connection regress1 closed
+[NO_PID]: sqlca: code: 0, state: 00000
diff --git a/src/interfaces/ecpg/test/expected/sql-cursor-ra-fetch.stdout b/src/interfaces/ecpg/test/expected/sql-cursor-ra-fetch.stdout
new file mode 100644
index 0000000..5f70761
--- /dev/null
+++ b/src/interfaces/ecpg/test/expected/sql-cursor-ra-fetch.stdout
@@ -0,0 +1,395 @@
+test scroll_cur for move absolute n (every 4th tuple forward, positive positions)
+	row 1: id: 1	t: a
+	row 5: id: 5	t: e
+	row 9: id: 9	t: i
+	row 13: id: 13	t: m
+	row 17: id: 17	t: q
+	row 21: id: 21	t: u
+	row 25: id: 25	t: y
+	row 29 does not exist
+
+test scroll_cur for move absolute n (every 4th tuple backward, positive positions)
+	row 33 does not exist
+	row 29 does not exist
+	row 25: id: 25	t: y
+	row 21: id: 21	t: u
+	row 17: id: 17	t: q
+	row 13: id: 13	t: m
+	row 9: id: 9	t: i
+	row 5: id: 5	t: e
+	row 1: id: 1	t: a
+
+test scroll_cur for move absolute n (every 4th tuple backward, negative positions)
+	row -1: id: 26	t: z
+	row -5: id: 22	t: v
+	row -9: id: 18	t: r
+	row -13: id: 14	t: n
+	row -17: id: 10	t: j
+	row -21: id: 6	t: f
+	row -25: id: 2	t: b
+	row -29 does not exist
+
+test scroll_cur for move absolute n (every 4th tuple forward, negative positions)
+	row -33 does not exist
+	row -29 does not exist
+	row -25: id: 2	t: b
+	row -21: id: 6	t: f
+	row -17: id: 10	t: j
+	row -13: id: 14	t: n
+	row -9: id: 18	t: r
+	row -5: id: 22	t: v
+	row -1: id: 26	t: z
+
+test scroll_cur for fetch relative 4 (positive positions)
+fetch relative 4 in scroll_cur succeeded, sqlerrd[2] 1
+	id: 4	t: d
+fetch relative 4 in scroll_cur succeeded, sqlerrd[2] 1
+	id: 8	t: h
+fetch relative 4 in scroll_cur succeeded, sqlerrd[2] 1
+	id: 12	t: l
+fetch relative 4 in scroll_cur succeeded, sqlerrd[2] 1
+	id: 16	t: p
+fetch relative 4 in scroll_cur succeeded, sqlerrd[2] 1
+	id: 20	t: t
+fetch relative 4 in scroll_cur succeeded, sqlerrd[2] 1
+	id: 24	t: x
+fetch relative 4 in scroll_cur succeeded, sqlerrd[2] 0
+
+test scroll_cur for fetch relative -4 (positive positions)
+fetch relative -4 in scroll_cur succeeded, sqlerrd[2] 1
+	id: 23	t: w
+fetch relative -4 in scroll_cur succeeded, sqlerrd[2] 1
+	id: 19	t: s
+fetch relative -4 in scroll_cur succeeded, sqlerrd[2] 1
+	id: 15	t: o
+fetch relative -4 in scroll_cur succeeded, sqlerrd[2] 1
+	id: 11	t: k
+fetch relative -4 in scroll_cur succeeded, sqlerrd[2] 1
+	id: 7	t: g
+fetch relative -4 in scroll_cur succeeded, sqlerrd[2] 1
+	id: 3	t: c
+fetch relative -4 in scroll_cur succeeded, sqlerrd[2] 0
+
+test scroll_cur for fetch relative -4 (negative positions)
+fetch relative -4 in scroll_cur succeeded, sqlerrd[2] 1
+	id: 23	t: w
+fetch relative -4 in scroll_cur succeeded, sqlerrd[2] 1
+	id: 19	t: s
+fetch relative -4 in scroll_cur succeeded, sqlerrd[2] 1
+	id: 15	t: o
+fetch relative -4 in scroll_cur succeeded, sqlerrd[2] 1
+	id: 11	t: k
+fetch relative -4 in scroll_cur succeeded, sqlerrd[2] 1
+	id: 7	t: g
+fetch relative -4 in scroll_cur succeeded, sqlerrd[2] 1
+	id: 3	t: c
+fetch relative -4 in scroll_cur succeeded, sqlerrd[2] 0
+
+test scroll_cur for fetch relative 4 (negative positions)
+fetch relative 4 in scroll_cur succeeded, sqlerrd[2] 1
+	id: 4	t: d
+fetch relative 4 in scroll_cur succeeded, sqlerrd[2] 1
+	id: 8	t: h
+fetch relative 4 in scroll_cur succeeded, sqlerrd[2] 1
+	id: 12	t: l
+fetch relative 4 in scroll_cur succeeded, sqlerrd[2] 1
+	id: 16	t: p
+fetch relative 4 in scroll_cur succeeded, sqlerrd[2] 1
+	id: 20	t: t
+fetch relative 4 in scroll_cur succeeded, sqlerrd[2] 1
+	id: 24	t: x
+fetch relative 4 in scroll_cur succeeded, sqlerrd[2] 0
+
+test scroll_cur for fetch forward 4 (positive positions)
+fetch forward 4 in scroll_cur succeeded, sqlerrd[2] 4
+	id: 1	t: a
+	id: 2	t: b
+	id: 3	t: c
+	id: 4	t: d
+fetch forward 4 in scroll_cur succeeded, sqlerrd[2] 4
+	id: 5	t: e
+	id: 6	t: f
+	id: 7	t: g
+	id: 8	t: h
+fetch forward 4 in scroll_cur succeeded, sqlerrd[2] 4
+	id: 9	t: i
+	id: 10	t: j
+	id: 11	t: k
+	id: 12	t: l
+fetch forward 4 in scroll_cur succeeded, sqlerrd[2] 4
+	id: 13	t: m
+	id: 14	t: n
+	id: 15	t: o
+	id: 16	t: p
+fetch forward 4 in scroll_cur succeeded, sqlerrd[2] 4
+	id: 17	t: q
+	id: 18	t: r
+	id: 19	t: s
+	id: 20	t: t
+fetch forward 4 in scroll_cur succeeded, sqlerrd[2] 4
+	id: 21	t: u
+	id: 22	t: v
+	id: 23	t: w
+	id: 24	t: x
+fetch forward 4 in scroll_cur succeeded, sqlerrd[2] 2
+	id: 25	t: y
+	id: 26	t: z
+fetch forward 4 in scroll_cur succeeded, sqlerrd[2] 0
+
+test scroll_cur for fetch forward -4 (positive positions)
+fetch forward -4 in scroll_cur succeeded, sqlerrd[2] 4
+	id: 26	t: z
+	id: 25	t: y
+	id: 24	t: x
+	id: 23	t: w
+fetch forward -4 in scroll_cur succeeded, sqlerrd[2] 4
+	id: 22	t: v
+	id: 21	t: u
+	id: 20	t: t
+	id: 19	t: s
+fetch forward -4 in scroll_cur succeeded, sqlerrd[2] 4
+	id: 18	t: r
+	id: 17	t: q
+	id: 16	t: p
+	id: 15	t: o
+fetch forward -4 in scroll_cur succeeded, sqlerrd[2] 4
+	id: 14	t: n
+	id: 13	t: m
+	id: 12	t: l
+	id: 11	t: k
+fetch forward -4 in scroll_cur succeeded, sqlerrd[2] 4
+	id: 10	t: j
+	id: 9	t: i
+	id: 8	t: h
+	id: 7	t: g
+fetch forward -4 in scroll_cur succeeded, sqlerrd[2] 4
+	id: 6	t: f
+	id: 5	t: e
+	id: 4	t: d
+	id: 3	t: c
+fetch forward -4 in scroll_cur succeeded, sqlerrd[2] 2
+	id: 2	t: b
+	id: 1	t: a
+fetch forward -4 in scroll_cur succeeded, sqlerrd[2] 0
+
+test scroll_cur for fetch forward -4 (negative positions)
+fetch forward -4 in scroll_cur succeeded, sqlerrd[2] 4
+	id: 26	t: z
+	id: 25	t: y
+	id: 24	t: x
+	id: 23	t: w
+fetch forward -4 in scroll_cur succeeded, sqlerrd[2] 4
+	id: 22	t: v
+	id: 21	t: u
+	id: 20	t: t
+	id: 19	t: s
+fetch forward -4 in scroll_cur succeeded, sqlerrd[2] 4
+	id: 18	t: r
+	id: 17	t: q
+	id: 16	t: p
+	id: 15	t: o
+fetch forward -4 in scroll_cur succeeded, sqlerrd[2] 4
+	id: 14	t: n
+	id: 13	t: m
+	id: 12	t: l
+	id: 11	t: k
+fetch forward -4 in scroll_cur succeeded, sqlerrd[2] 4
+	id: 10	t: j
+	id: 9	t: i
+	id: 8	t: h
+	id: 7	t: g
+fetch forward -4 in scroll_cur succeeded, sqlerrd[2] 4
+	id: 6	t: f
+	id: 5	t: e
+	id: 4	t: d
+	id: 3	t: c
+fetch forward -4 in scroll_cur succeeded, sqlerrd[2] 2
+	id: 2	t: b
+	id: 1	t: a
+fetch forward -4 in scroll_cur succeeded, sqlerrd[2] 0
+
+test scroll_cur for fetch forward 4 (negative positions)
+fetch forward 4 in scroll_cur succeeded, sqlerrd[2] 4
+	id: 1	t: a
+	id: 2	t: b
+	id: 3	t: c
+	id: 4	t: d
+fetch forward 4 in scroll_cur succeeded, sqlerrd[2] 4
+	id: 5	t: e
+	id: 6	t: f
+	id: 7	t: g
+	id: 8	t: h
+fetch forward 4 in scroll_cur succeeded, sqlerrd[2] 4
+	id: 9	t: i
+	id: 10	t: j
+	id: 11	t: k
+	id: 12	t: l
+fetch forward 4 in scroll_cur succeeded, sqlerrd[2] 4
+	id: 13	t: m
+	id: 14	t: n
+	id: 15	t: o
+	id: 16	t: p
+fetch forward 4 in scroll_cur succeeded, sqlerrd[2] 4
+	id: 17	t: q
+	id: 18	t: r
+	id: 19	t: s
+	id: 20	t: t
+fetch forward 4 in scroll_cur succeeded, sqlerrd[2] 4
+	id: 21	t: u
+	id: 22	t: v
+	id: 23	t: w
+	id: 24	t: x
+fetch forward 4 in scroll_cur succeeded, sqlerrd[2] 2
+	id: 25	t: y
+	id: 26	t: z
+fetch forward 4 in scroll_cur succeeded, sqlerrd[2] 0
+
+test scroll_cur4 for move absolute n (every 5th tuple forward, positive positions)
+	row 1: id: 1	t: a
+	row 6: id: 6	t: f
+	row 11: id: 11	t: k
+	row 16: id: 16	t: p
+	row 21: id: 21	t: u
+	row 26: id: 26	t: z
+	row 31 does not exist
+
+test fetch backward 8 from scroll_cur4 after the cursor switched to ecpg_execute()
+	id: 26 t: z
+	id: 25 t: y
+	id: 24 t: x
+	id: 23 t: w
+	id: 22 t: v
+	id: 21 t: u
+	id: 20 t: t
+	id: 19 t: s
+
+test scroll_cur4 for move absolute n (every 5th tuple backward, positive positions)
+	row 36 does not exist
+	row 31 does not exist
+	row 26: id: 26	t: z
+	row 21: id: 21	t: u
+	row 16: id: 16	t: p
+	row 11: id: 11	t: k
+	row 6: id: 6	t: f
+	row 1: id: 1	t: a
+
+test fetch forward 8 from scroll_cur4 after the cursor switched to ecpg_execute()
+	id: 2 t: b
+	id: 3 t: c
+	id: 4 t: d
+	id: 5 t: e
+	id: 6 t: f
+	id: 7 t: g
+	id: 8 t: h
+	id: 9 t: i
+
+test scroll_cur4 for move absolute n (every 5th tuple backward, negative positions)
+	row -1: id: 26	t: z
+	row -6: id: 21	t: u
+	row -11: id: 16	t: p
+	row -16: id: 11	t: k
+	row -21: id: 6	t: f
+	row -26: id: 1	t: a
+	row -31 does not exist
+
+test fetch forward 8 from scroll_cur4 after the cursor switched to ecpg_execute()
+	id: 1 t: a
+	id: 2 t: b
+	id: 3 t: c
+	id: 4 t: d
+	id: 5 t: e
+	id: 6 t: f
+	id: 7 t: g
+	id: 8 t: h
+
+test scroll_cur4 for move absolute n (every 5th tuple forward, negative positions)
+	row -36 does not exist
+	row -31 does not exist
+	row -26: id: 1	t: a
+	row -21: id: 6	t: f
+	row -16: id: 11	t: k
+	row -11: id: 16	t: p
+	row -6: id: 21	t: u
+	row -1: id: 26	t: z
+
+test fetch backward 8 from scroll_cur4 after the cursor switched to ecpg_execute()
+	id: 25 t: y
+	id: 24 t: x
+	id: 23 t: w
+	id: 22 t: v
+	id: 21 t: u
+	id: 20 t: t
+	id: 19 t: s
+	id: 18 t: r
+
+test scroll_cur4 for fetch relative 5 (positive positions)
+	id: 5	t: e
+	id: 10	t: j
+	id: 15	t: o
+	id: 20	t: t
+	id: 25	t: y
+	fetch returned empty
+
+test fetch backward 8 from scroll_cur4 after the cursor switched to ecpg_execute()
+	id: 26 t: z
+	id: 25 t: y
+	id: 24 t: x
+	id: 23 t: w
+	id: 22 t: v
+	id: 21 t: u
+	id: 20 t: t
+	id: 19 t: s
+
+test scroll_cur4 for fetch relative -5 (positive positions)
+	id: 22	t: v
+	id: 17	t: q
+	id: 12	t: l
+	id: 7	t: g
+	id: 2	t: b
+	fetch returned empty
+
+test fetch forward 8 from scroll_cur4 after the cursor switched to ecpg_execute()
+	id: 1 t: a
+	id: 2 t: b
+	id: 3 t: c
+	id: 4 t: d
+	id: 5 t: e
+	id: 6 t: f
+	id: 7 t: g
+	id: 8 t: h
+
+test scroll_cur4 for move relative -5 (negative positions)
+	id: 22	t: v
+	id: 17	t: q
+	id: 12	t: l
+	id: 7	t: g
+	id: 2	t: b
+	fetch returned empty
+
+test fetch forward 8 from scroll_cur4 after the cursor switched to ecpg_execute()
+	id: 1 t: a
+	id: 2 t: b
+	id: 3 t: c
+	id: 4 t: d
+	id: 5 t: e
+	id: 6 t: f
+	id: 7 t: g
+	id: 8 t: h
+
+test scroll_cur for move relative 5 (negative positions)
+	id: 5	t: e
+	id: 10	t: j
+	id: 15	t: o
+	id: 20	t: t
+	id: 25	t: y
+	fetch returned empty
+
+test fetch backward 8 from scroll_cur4 after the cursor switched to ecpg_execute()
+	id: 26 t: z
+	id: 25 t: y
+	id: 24 t: x
+	id: 23 t: w
+	id: 22 t: v
+	id: 21 t: u
+	id: 20 t: t
+	id: 19 t: s
diff --git a/src/interfaces/ecpg/test/expected/sql-cursor-ra-move.c b/src/interfaces/ecpg/test/expected/sql-cursor-ra-move.c
new file mode 100644
index 0000000..5a5dd70
--- /dev/null
+++ b/src/interfaces/ecpg/test/expected/sql-cursor-ra-move.c
@@ -0,0 +1,323 @@
+/* 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-ra-move.pgc"
+#include <stdlib.h>
+#include <string.h>
+
+
+#line 1 "regression.h"
+
+
+
+
+
+
+#line 4 "cursor-ra-move.pgc"
+
+
+/* exec sql whenever sqlerror  sqlprint ; */
+#line 6 "cursor-ra-move.pgc"
+
+
+int main(void)
+{
+	int	quit_loop;
+
+	ECPGdebug(1, stderr);
+
+	{ ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); 
+#line 14 "cursor-ra-move.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 14 "cursor-ra-move.pgc"
+
+
+	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table t1 ( id serial primary key , t text )", ECPGt_EOIT, ECPGt_EORT);
+#line 16 "cursor-ra-move.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 16 "cursor-ra-move.pgc"
+
+	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( t ) values ( 'a' ) , ( 'b' ) , ( 'c' ) , ( 'd' ) , ( 'e' ) , ( 'f' ) , ( 'g' ) , ( 'h' ) , ( 'i' ) , ( 'j' ) , ( 'k' ) , ( 'l' ) , ( 'm' ) , ( 'n' ) , ( 'o' ) , ( 'p' ) , ( 'q' ) , ( 'r' ) , ( 's' ) , ( 't' ) , ( 'u' ) , ( 'v' ) , ( 'w' ) , ( 'x' ) , ( 'y' ) , ( 'z' )", ECPGt_EOIT, ECPGt_EORT);
+#line 21 "cursor-ra-move.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 21 "cursor-ra-move.pgc"
+
+	{ ECPGtrans(__LINE__, NULL, "commit", 0, 0, 0, NULL);
+#line 22 "cursor-ra-move.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 22 "cursor-ra-move.pgc"
+
+
+	/* declare scroll_cur scroll cursor for select id , t from t1 order by id */
+#line 24 "cursor-ra-move.pgc"
+
+	/* declare noscroll_cur no scroll cursor for select id , t from t1 order by id */
+#line 25 "cursor-ra-move.pgc"
+
+	/* Implicitly non-scrollable cursors */
+	/* declare unspec_cur1 no scroll cursor for select id , t from t1 order by id */
+#line 27 "cursor-ra-move.pgc"
+
+	/* 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 */
+#line 28 "cursor-ra-move.pgc"
+
+
+	/* Test MOVE ABSOLUTE -1 for all 4 cursors */
+
+	printf("test scroll_cur for move absolute -1\n");
+
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 8, "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();}
+#line 34 "cursor-ra-move.pgc"
+
+	if (sqlca.sqlcode < 0)
+		printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate);
+
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_absolute, "- 1", 1, "scroll_cur", ECPGst_normal, "move absolute - 1 in scroll_cur", ECPGt_EOIT, ECPGt_EORT);
+#line 38 "cursor-ra-move.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 38 "cursor-ra-move.pgc"
+
+	if (sqlca.sqlcode < 0)
+		printf("move absolute -1 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
+	else
+		printf("move absolute -1 in scroll_cur succeeded\n");
+
+	{ ECPGtrans(__LINE__, NULL, "rollback", 0, 0, 1, NULL);
+#line 44 "cursor-ra-move.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 44 "cursor-ra-move.pgc"
+
+
+	printf("test noscroll_cur for move absolute -1\n");
+
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 8, "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();}
+#line 48 "cursor-ra-move.pgc"
+
+	if (sqlca.sqlcode < 0)
+		printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate);
+
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_absolute, "- 1", 1, "noscroll_cur", ECPGst_normal, "move absolute - 1 in noscroll_cur", ECPGt_EOIT, ECPGt_EORT);
+#line 52 "cursor-ra-move.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 52 "cursor-ra-move.pgc"
+
+	if (sqlca.sqlcode < 0)
+		printf("move absolute -1 in noscroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
+	else
+		printf("move absolute -1 in noscroll_cur succeeded\n");
+
+	{ ECPGtrans(__LINE__, NULL, "rollback", 0, 0, 1, NULL);
+#line 58 "cursor-ra-move.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 58 "cursor-ra-move.pgc"
+
+
+	printf("test unspec_cur1 for move absolute -1\n");
+
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 8, "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();}
+#line 62 "cursor-ra-move.pgc"
+
+	if (sqlca.sqlcode < 0)
+		printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate);
+
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_absolute, "- 1", 1, "unspec_cur1", ECPGst_normal, "move absolute - 1 in unspec_cur1", ECPGt_EOIT, ECPGt_EORT);
+#line 66 "cursor-ra-move.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 66 "cursor-ra-move.pgc"
+
+	if (sqlca.sqlcode < 0)
+		printf("move absolute -1 in unspec_cur1 failed with SQLSTATE %5s\n", sqlca.sqlstate);
+	else
+		printf("move absolute -1 in unspec_cur1 succeeded\n");
+
+	{ ECPGtrans(__LINE__, NULL, "rollback", 0, 0, 1, NULL);
+#line 72 "cursor-ra-move.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 72 "cursor-ra-move.pgc"
+
+
+	printf("test unspec_cur2 for move absolute -1\n");
+
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 8, "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();}
+#line 76 "cursor-ra-move.pgc"
+
+	if (sqlca.sqlcode < 0)
+		printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate);
+
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_absolute, "- 1", 1, "unspec_cur2", ECPGst_normal, "move absolute - 1 in unspec_cur2", ECPGt_EOIT, ECPGt_EORT);
+#line 80 "cursor-ra-move.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 80 "cursor-ra-move.pgc"
+
+	if (sqlca.sqlcode < 0)
+		printf("move absolute -1 in unspec_cur2 failed with SQLSTATE %5s\n", sqlca.sqlstate);
+	else
+		printf("move absolute -1 in unspec_cur2 succeeded\n");
+
+	{ ECPGtrans(__LINE__, NULL, "rollback", 0, 0, 1, NULL);
+#line 86 "cursor-ra-move.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 86 "cursor-ra-move.pgc"
+
+
+	/* Test MOVE RELATIVE 8 */
+
+	printf("test scroll_cur for move relative 8\n");
+
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 8, "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();}
+#line 92 "cursor-ra-move.pgc"
+
+	if (sqlca.sqlcode < 0)
+		printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate);
+
+	quit_loop = 0;
+	while (!quit_loop)
+	{
+		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_relative, "8", 1, "scroll_cur", ECPGst_normal, "move relative 8 in scroll_cur", ECPGt_EOIT, ECPGt_EORT);
+#line 99 "cursor-ra-move.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 99 "cursor-ra-move.pgc"
+
+		if (sqlca.sqlcode < 0)
+			printf("move relative 8 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
+		else
+			printf("move relative 8 in scroll_cur succeeded, sqlerrd[2] %ld\n", sqlca.sqlerrd[2]);
+		quit_loop = (sqlca.sqlerrd[2] == 0);
+	}
+
+	printf("test scroll_cur for move relative -8\n");
+
+	quit_loop = 0;
+	while (!quit_loop)
+	{
+		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_relative, "- 8", 1, "scroll_cur", ECPGst_normal, "move relative - 8 in scroll_cur", ECPGt_EOIT, ECPGt_EORT);
+#line 112 "cursor-ra-move.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 112 "cursor-ra-move.pgc"
+
+		if (sqlca.sqlcode < 0)
+			printf("move relative -8 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
+		else
+			printf("move relative -8 in scroll_cur succeeded, sqlerrd[2] %ld\n", sqlca.sqlerrd[2]);
+		quit_loop = (sqlca.sqlerrd[2] == 0);
+	}
+
+	{ ECPGtrans(__LINE__, NULL, "rollback", 0, 0, 1, NULL);
+#line 120 "cursor-ra-move.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 120 "cursor-ra-move.pgc"
+
+
+	/* Test MOVE FORWARD 8 */
+
+	printf("test scroll_cur for move forward 8\n");
+
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 8, "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();}
+#line 126 "cursor-ra-move.pgc"
+
+	if (sqlca.sqlcode < 0)
+		printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate);
+
+	quit_loop = 0;
+	while (!quit_loop)
+	{
+		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "8", 1, "scroll_cur", ECPGst_normal, "move forward 8 in scroll_cur", ECPGt_EOIT, ECPGt_EORT);
+#line 133 "cursor-ra-move.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 133 "cursor-ra-move.pgc"
+
+		if (sqlca.sqlcode < 0)
+			printf("move forward 8 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
+		else
+			printf("move forward 8 in scroll_cur succeeded, sqlerrd[2] %ld\n", sqlca.sqlerrd[2]);
+		quit_loop = (sqlca.sqlerrd[2] == 0);
+	}
+
+	printf("test scroll_cur for move forward -8\n");
+
+	quit_loop = 0;
+	while (!quit_loop)
+	{
+		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "- 8", 1, "scroll_cur", ECPGst_normal, "move forward - 8 in scroll_cur", ECPGt_EOIT, ECPGt_EORT);
+#line 146 "cursor-ra-move.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 146 "cursor-ra-move.pgc"
+
+		if (sqlca.sqlcode < 0)
+			printf("move forward -8 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
+		else
+			printf("move forward -8 in scroll_cur succeeded, sqlerrd[2] %ld\n", sqlca.sqlerrd[2]);
+		quit_loop = (sqlca.sqlerrd[2] == 0);
+	}
+
+	{ ECPGtrans(__LINE__, NULL, "rollback", 0, 0, 1, NULL);
+#line 154 "cursor-ra-move.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 154 "cursor-ra-move.pgc"
+
+
+	/* Drop the test table */
+
+	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
+#line 158 "cursor-ra-move.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 158 "cursor-ra-move.pgc"
+
+	{ ECPGtrans(__LINE__, NULL, "commit", 0, 0, 0, NULL);
+#line 159 "cursor-ra-move.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 159 "cursor-ra-move.pgc"
+
+
+	{ ECPGdisconnect(__LINE__, "ALL");
+#line 161 "cursor-ra-move.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 161 "cursor-ra-move.pgc"
+
+
+	return 0;
+}
diff --git a/src/interfaces/ecpg/test/expected/sql-cursor-ra-move.stderr b/src/interfaces/ecpg/test/expected/sql-cursor-ra-move.stderr
new file mode 100644
index 0000000..8a1cadc
--- /dev/null
+++ b/src/interfaces/ecpg/test/expected/sql-cursor-ra-move.stderr
@@ -0,0 +1,205 @@
+[NO_PID]: ECPGdebug: set to 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 16: query: create table t1 ( id serial primary key , t text ); with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 16: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 16: OK: CREATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 17: query: insert into t1 ( t ) values ( 'a' ) , ( 'b' ) , ( 'c' ) , ( 'd' ) , ( 'e' ) , ( 'f' ) , ( 'g' ) , ( 'h' ) , ( 'i' ) , ( 'j' ) , ( 'k' ) , ( 'l' ) , ( 'm' ) , ( 'n' ) , ( 'o' ) , ( 'p' ) , ( 'q' ) , ( 'r' ) , ( 's' ) , ( 't' ) , ( 'u' ) , ( 'v' ) , ( 'w' ) , ( 'x' ) , ( 'y' ) , ( 'z' ); with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 17: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 17: OK: INSERT 0 26
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 22: action "commit"; connection "regress1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 34: query: declare scroll_cur scroll cursor for select id , t from t1 order by id; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 34: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 34: OK: DECLARE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 38: query: move absolute - 1 in scroll_cur; fetch all: 0 amount: -1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 38: query: move absolute -1 in scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 38: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 38: stmt->results is NULL, ignoring
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 44: action "rollback"; connection "regress1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 48: query: declare noscroll_cur no scroll cursor for select id , t from t1 order by id; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 48: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 48: OK: DECLARE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode -231 on line 52: cursor "noscroll_cur" can only scan forward on line 52
+[NO_PID]: sqlca: code: -231, state: 55000
+SQL error: cursor "noscroll_cur" can only scan forward on line 52
+[NO_PID]: ECPGtrans on line 58: action "rollback"; connection "regress1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 62: query: declare unspec_cur1 no scroll cursor for select id , t from t1 order by id; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 62: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 62: OK: DECLARE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode -231 on line 66: cursor "unspec_cur1" can only scan forward on line 66
+[NO_PID]: sqlca: code: -231, state: 55000
+SQL error: cursor "unspec_cur1" can only scan forward on line 66
+[NO_PID]: ECPGtrans on line 72: action "rollback"; connection "regress1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 76: query: 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; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 76: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 76: OK: DECLARE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode -231 on line 80: cursor "unspec_cur2" can only scan forward on line 80
+[NO_PID]: sqlca: code: -231, state: 55000
+SQL error: cursor "unspec_cur2" can only scan forward on line 80
+[NO_PID]: ECPGtrans on line 86: action "rollback"; connection "regress1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 92: query: declare scroll_cur scroll cursor for select id , t from t1 order by id; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 92: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 92: OK: DECLARE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 99: query: move relative 8 in scroll_cur; fetch all: 0 amount: 8
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 99: query: move relative 8 in scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 99: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 99: stmt->results is NULL, ignoring
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 99: query: move relative 8 in scroll_cur; fetch all: 0 amount: 8
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 99: query: move relative 8 in scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 99: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 99: stmt->results is NULL, ignoring
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 99: query: move relative 8 in scroll_cur; fetch all: 0 amount: 8
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 99: query: move relative 8 in scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 99: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 99: stmt->results is NULL, ignoring
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 99: query: move relative 8 in scroll_cur; fetch all: 0 amount: 8
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 99: query: move relative 8 in scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 99: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 99: stmt->results is NULL, ignoring
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 112: query: move relative - 8 in scroll_cur; fetch all: 0 amount: -8
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 112: stmt->results is NULL, ignoring
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 112: query: move relative - 8 in scroll_cur; fetch all: 0 amount: -8
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 112: stmt->results is NULL, ignoring
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 112: query: move relative - 8 in scroll_cur; fetch all: 0 amount: -8
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 112: stmt->results is NULL, ignoring
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 112: query: move relative - 8 in scroll_cur; fetch all: 0 amount: -8
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 112: query: move absolute -24 in scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 112: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 112: query: move relative -8 in scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 112: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 112: stmt->results is NULL, ignoring
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 120: action "rollback"; connection "regress1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 126: query: declare scroll_cur scroll cursor for select id , t from t1 order by id; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 126: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 126: OK: DECLARE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 133: query: move forward 8 in scroll_cur; fetch all: 0 amount: 8
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 133: query: move forward 8 in scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 133: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 133: OK: MOVE 8
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 133: query: move forward 8 in scroll_cur; fetch all: 0 amount: 8
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 133: query: move forward 8 in scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 133: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 133: OK: MOVE 8
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 133: query: move forward 8 in scroll_cur; fetch all: 0 amount: 8
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 133: query: move forward 8 in scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 133: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 133: OK: MOVE 8
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 133: query: move forward 8 in scroll_cur; fetch all: 0 amount: 8
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 133: query: move forward 8 in scroll_cur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 133: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 133: OK: MOVE 2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 133: query: move forward 8 in scroll_cur; fetch all: 0 amount: 8
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 133: stmt->results is NULL, ignoring
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 146: query: move forward - 8 in scroll_cur; fetch all: 0 amount: -8
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 146: stmt->results is NULL, ignoring
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 146: query: move forward - 8 in scroll_cur; fetch all: 0 amount: -8
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 146: stmt->results is NULL, ignoring
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 146: query: move forward - 8 in scroll_cur; fetch all: 0 amount: -8
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 146: stmt->results is NULL, ignoring
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 146: query: move forward - 8 in scroll_cur; fetch all: 0 amount: -8
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 146: stmt->results is NULL, ignoring
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 146: query: move forward - 8 in scroll_cur; fetch all: 0 amount: -8
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 146: stmt->results is NULL, ignoring
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 154: action "rollback"; connection "regress1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 158: query: drop table t1; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 158: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 158: OK: DROP TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 159: action "commit"; connection "regress1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_finish: connection regress1 closed
+[NO_PID]: sqlca: code: 0, state: 00000
diff --git a/src/interfaces/ecpg/test/expected/sql-cursor-ra-move.stdout b/src/interfaces/ecpg/test/expected/sql-cursor-ra-move.stdout
new file mode 100644
index 0000000..5285668
--- /dev/null
+++ b/src/interfaces/ecpg/test/expected/sql-cursor-ra-move.stdout
@@ -0,0 +1,30 @@
+test scroll_cur for move absolute -1
+move absolute -1 in scroll_cur succeeded
+test noscroll_cur for move absolute -1
+move absolute -1 in noscroll_cur failed with SQLSTATE 55000
+test unspec_cur1 for move absolute -1
+move absolute -1 in unspec_cur1 failed with SQLSTATE 55000
+test unspec_cur2 for move absolute -1
+move absolute -1 in unspec_cur2 failed with SQLSTATE 55000
+test scroll_cur for move relative 8
+move relative 8 in scroll_cur succeeded, sqlerrd[2] 1
+move relative 8 in scroll_cur succeeded, sqlerrd[2] 1
+move relative 8 in scroll_cur succeeded, sqlerrd[2] 1
+move relative 8 in scroll_cur succeeded, sqlerrd[2] 0
+test scroll_cur for move relative -8
+move relative -8 in scroll_cur succeeded, sqlerrd[2] 1
+move relative -8 in scroll_cur succeeded, sqlerrd[2] 1
+move relative -8 in scroll_cur succeeded, sqlerrd[2] 1
+move relative -8 in scroll_cur succeeded, sqlerrd[2] 0
+test scroll_cur for move forward 8
+move forward 8 in scroll_cur succeeded, sqlerrd[2] 8
+move forward 8 in scroll_cur succeeded, sqlerrd[2] 8
+move forward 8 in scroll_cur succeeded, sqlerrd[2] 8
+move forward 8 in scroll_cur succeeded, sqlerrd[2] 2
+move forward 8 in scroll_cur succeeded, sqlerrd[2] 0
+test scroll_cur for move forward -8
+move forward -8 in scroll_cur succeeded, sqlerrd[2] 8
+move forward -8 in scroll_cur succeeded, sqlerrd[2] 8
+move forward -8 in scroll_cur succeeded, sqlerrd[2] 8
+move forward -8 in scroll_cur succeeded, sqlerrd[2] 2
+move forward -8 in scroll_cur succeeded, sqlerrd[2] 0
diff --git a/src/interfaces/ecpg/test/expected/sql-cursor-ra-swdir.c b/src/interfaces/ecpg/test/expected/sql-cursor-ra-swdir.c
new file mode 100644
index 0000000..db04f60
--- /dev/null
+++ b/src/interfaces/ecpg/test/expected/sql-cursor-ra-swdir.c
@@ -0,0 +1,238 @@
+/* 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-ra-swdir.pgc"
+/*
+ * Test MOVE ABSOLUTE N with alternating positive/negative
+ * positions and FETCH FORWARD/BACKWARD another record according
+ * to the current value.
+ *
+ * This code makes the result set size known by reaching the end.
+ * in both directions.
+ *
+ * After reaching the end, the cache_start_pos can be flipped
+ * from positive to negative to match the cursor position
+ * issued by the application.
+ *
+ * To watch this effect, execute:
+ *
+ * $ grep -n ecpg_cursor_execute results/sql-cursor-ra-swdir.stderr
+ *
+ */
+#include <stdlib.h>
+#include <string.h>
+
+
+#line 1 "regression.h"
+
+
+
+
+
+
+#line 21 "cursor-ra-swdir.pgc"
+
+
+/* exec sql whenever sqlerror  sqlprint ; */
+#line 23 "cursor-ra-swdir.pgc"
+
+
+/* declare mycur scroll cursor for select id , t from t1 order by id */
+#line 25 "cursor-ra-swdir.pgc"
+
+
+/* exec sql begin declare section */
+	
+	
+
+#line 28 "cursor-ra-swdir.pgc"
+ int id [ 2 ] ;
+ 
+#line 29 "cursor-ra-swdir.pgc"
+  struct varchar_1  { int len; char arr[ 50 ]; }  t [ 2 ] ;
+/* exec sql end declare section */
+#line 30 "cursor-ra-swdir.pgc"
+
+
+static void fetch2(int absolute)
+{
+	/* exec sql begin declare section */
+		  
+	
+#line 35 "cursor-ra-swdir.pgc"
+ int absolute1 = absolute ;
+/* exec sql end declare section */
+#line 36 "cursor-ra-swdir.pgc"
+
+
+	int	i, rows = 1;
+	int	direction = (absolute < 0 ? -1 : 1);
+
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_absolute_in_var, NULL, 0, "mycur", ECPGst_normal, "fetch absolute $0 from mycur", 
+	ECPGt_int,&(absolute1),(long)1,(long)1,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+	ECPGt_int,&(id[0]),(long)1,(long)1,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_varchar,&(t[0]),(long)50,(long)1,sizeof(struct varchar_1), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 41 "cursor-ra-swdir.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 41 "cursor-ra-swdir.pgc"
+
+	if (direction > 0)
+	{
+		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", 0, "mycur", ECPGst_normal, "fetch forward 1 from mycur", ECPGt_EOIT, 
+	ECPGt_int,&(id[1]),(long)1,(long)1,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_varchar,&(t[1]),(long)50,(long)1,sizeof(struct varchar_1), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 44 "cursor-ra-swdir.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 44 "cursor-ra-swdir.pgc"
+
+	}
+	else
+	{
+		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_backward, "1", 0, "mycur", ECPGst_normal, "fetch backward 1 from mycur", ECPGt_EOIT, 
+	ECPGt_int,&(id[1]),(long)1,(long)1,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_varchar,&(t[1]),(long)50,(long)1,sizeof(struct varchar_1), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 48 "cursor-ra-swdir.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 48 "cursor-ra-swdir.pgc"
+
+	}
+
+	rows += sqlca.sqlerrd[2];
+
+	for (i = 0; i < rows; i++)
+		printf("absolute: %d id: %d t '%s'\n", absolute + i*direction, id[i], t[i].arr);
+}
+
+int main(void)
+{
+	/* exec sql begin declare section */
+		 
+	
+#line 60 "cursor-ra-swdir.pgc"
+ int i , j ;
+/* exec sql end declare section */
+#line 61 "cursor-ra-swdir.pgc"
+
+
+	ECPGdebug(1, stderr);
+
+	{ ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); 
+#line 65 "cursor-ra-swdir.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 65 "cursor-ra-swdir.pgc"
+
+
+	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table t1 ( id serial primary key , t text )", ECPGt_EOIT, ECPGt_EORT);
+#line 67 "cursor-ra-swdir.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 67 "cursor-ra-swdir.pgc"
+
+	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( t ) values ( 'a' ) , ( 'b' ) , ( 'c' ) , ( 'd' ) , ( 'e' ) , ( 'f' ) , ( 'g' )", ECPGt_EOIT, ECPGt_EORT);
+#line 69 "cursor-ra-swdir.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 69 "cursor-ra-swdir.pgc"
+
+	{ ECPGtrans(__LINE__, NULL, "commit", 0, 0, 0, NULL);
+#line 70 "cursor-ra-swdir.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 70 "cursor-ra-swdir.pgc"
+
+
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, 4, "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();}
+#line 72 "cursor-ra-swdir.pgc"
+
+
+	printf("Discover total number of tuples and test flipping fetch directions\n");
+
+	/*
+	 * This part verifies that the returned rows are correct
+	 * in each direction and the runtime eventually discovers
+	 * the size of the result set by reaching the end.
+	 * These position series are fetched, constantly switching
+	 * directions:
+	 *   1,  2,  3,  4,  5,  6,  7
+	 *  -1, -2, -3, -4, -5, -6, -7
+	 * Only the FETCH FORWARD/BACKWARD after every FETCH ABSOLUTE
+	 * hits the cache initially because the result set size is
+	 * unknown. When it becomes known, the readahead windows from
+	 * different directions don't overlap.
+	 */
+	for (i = 1, j = -1; i <= 7; i++, j--)
+	{
+		fetch2(i);
+		fetch2(j);
+	}
+
+	printf("Re-test flipping of fetch directions\n");
+
+	/*
+	 * Re-test flipping with different positions. The result set
+	 * size is already known from the previous loop.
+	 * Test this interval that also involve the end of the result set:
+	 *	-->      5,  6,  7, (end)
+	 *	    -4, -3, -2, -1  <--
+	 * After the first fetch, this loop can be served
+	 * almost entirely from the same cache except the last
+	 * request: fetch2(-3) does:
+	 *	FETCH ABSOLUTE -3 (still in the cache)
+	 *	FETCH BACKWARD 1 (does a new FETCH)
+	 */
+	for (i = 5, j = -1; i <= 7; i++, j--)
+	{
+		fetch2(i);
+		fetch2(j);
+	}
+
+	{ ECPGclose(__LINE__, 0, 1, NULL, 0, "mycur", ECPGst_normal, "close mycur", ECPGt_EOIT, ECPGt_EORT);
+#line 115 "cursor-ra-swdir.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 115 "cursor-ra-swdir.pgc"
+
+
+	/* Drop the test table */
+
+	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
+#line 119 "cursor-ra-swdir.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 119 "cursor-ra-swdir.pgc"
+
+	{ ECPGtrans(__LINE__, NULL, "commit", 0, 0, 0, NULL);
+#line 120 "cursor-ra-swdir.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 120 "cursor-ra-swdir.pgc"
+
+
+	{ ECPGdisconnect(__LINE__, "ALL");
+#line 122 "cursor-ra-swdir.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 122 "cursor-ra-swdir.pgc"
+
+
+	return 0;
+}
diff --git a/src/interfaces/ecpg/test/expected/sql-cursor-ra-swdir.stderr b/src/interfaces/ecpg/test/expected/sql-cursor-ra-swdir.stderr
new file mode 100644
index 0000000..121c8f6
--- /dev/null
+++ b/src/interfaces/ecpg/test/expected/sql-cursor-ra-swdir.stderr
@@ -0,0 +1,552 @@
+[NO_PID]: ECPGdebug: set to 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 67: query: create table t1 ( id serial primary key , t text ); with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 67: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 67: OK: CREATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 68: query: insert into t1 ( t ) values ( 'a' ) , ( 'b' ) , ( 'c' ) , ( 'd' ) , ( 'e' ) , ( 'f' ) , ( 'g' ); with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 68: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 68: OK: INSERT 0 7
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 70: action "commit"; connection "regress1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 72: query: declare mycur scroll cursor for select id , t from t1 order by id; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 72: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 72: OK: DECLARE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 41: query: fetch absolute $0 from mycur; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: query: fetch forward 4 from mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 41: command fetch forward 4 from mycur; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 41: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 41: RESULT: 1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 41: RESULT: a offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 44: query: fetch forward 1 from mycur; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 44: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 44: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 44: RESULT: 2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 44: RESULT: b offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 41: query: fetch absolute $0 from mycur; fetch all: 0 amount: -1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: query: move forward all in mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: query: fetch backward 4 from mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 41: command fetch backward 4 from mycur; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 41: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 41: RESULT: 7 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 41: RESULT: g offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 48: query: fetch backward 1 from mycur; fetch all: 0 amount: -1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 48: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 48: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 48: RESULT: 6 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 48: RESULT: f offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 41: query: fetch absolute $0 from mycur; fetch all: 0 amount: 2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: query: move absolute 1 in mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: query: fetch forward 4 from mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 41: command fetch forward 4 from mycur; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 41: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 41: RESULT: 2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 41: RESULT: b offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 44: query: fetch forward 1 from mycur; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 44: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 44: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 44: RESULT: 3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 44: RESULT: c offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 41: query: fetch absolute $0 from mycur; fetch all: 0 amount: -2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: query: move absolute -1 in mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: query: fetch backward 4 from mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 41: command fetch backward 4 from mycur; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 41: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 41: RESULT: 6 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 41: RESULT: f offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 48: query: fetch backward 1 from mycur; fetch all: 0 amount: -1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 48: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 48: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 48: RESULT: 5 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 48: RESULT: e offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 41: query: fetch absolute $0 from mycur; fetch all: 0 amount: 3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: query: move absolute 2 in mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: query: fetch forward 4 from mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 41: command fetch forward 4 from mycur; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 41: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 41: RESULT: 3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 41: RESULT: c offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 44: query: fetch forward 1 from mycur; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 44: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 44: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 44: RESULT: 4 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 44: RESULT: d offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 41: query: fetch absolute $0 from mycur; fetch all: 0 amount: -3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: query: move absolute -2 in mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: query: fetch backward 4 from mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 41: command fetch backward 4 from mycur; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 41: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 41: RESULT: 5 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 41: RESULT: e offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 48: query: fetch backward 1 from mycur; fetch all: 0 amount: -1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 48: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 48: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 48: RESULT: 4 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 48: RESULT: d offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 41: query: fetch absolute $0 from mycur; fetch all: 0 amount: 4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: query: move absolute 3 in mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: query: fetch forward 4 from mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 41: command fetch forward 4 from mycur; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 41: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 41: RESULT: 4 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 41: RESULT: d offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 44: query: fetch forward 1 from mycur; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 44: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 44: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 44: RESULT: 5 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 44: RESULT: e offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 41: query: fetch absolute $0 from mycur; fetch all: 0 amount: -4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: query: move absolute -3 in mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: query: fetch backward 4 from mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 41: command fetch backward 4 from mycur; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 41: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 41: RESULT: 4 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 41: RESULT: d offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 48: query: fetch backward 1 from mycur; fetch all: 0 amount: -1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 48: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 48: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 48: RESULT: 3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 48: RESULT: c offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 41: query: fetch absolute $0 from mycur; fetch all: 0 amount: 5
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: query: move absolute 4 in mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: query: fetch forward 4 from mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 41: command fetch forward 4 from mycur; returned 3 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 41: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 41: RESULT: 5 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 41: RESULT: e offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 44: query: fetch forward 1 from mycur; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 44: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 44: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 44: RESULT: 6 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 44: RESULT: f offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 41: query: fetch absolute $0 from mycur; fetch all: 0 amount: -5
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: query: move absolute -4 in mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: query: fetch backward 4 from mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 41: command fetch backward 4 from mycur; returned 3 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 41: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 41: RESULT: 3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 41: RESULT: c offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 48: query: fetch backward 1 from mycur; fetch all: 0 amount: -1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 48: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 48: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 48: RESULT: 2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 48: RESULT: b offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 41: query: fetch absolute $0 from mycur; fetch all: 0 amount: 6
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: query: move absolute 5 in mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: query: fetch forward 4 from mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 41: command fetch forward 4 from mycur; returned 2 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 41: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 41: RESULT: 6 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 41: RESULT: f offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 44: query: fetch forward 1 from mycur; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 44: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 44: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 44: RESULT: 7 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 44: RESULT: g offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 41: query: fetch absolute $0 from mycur; fetch all: 0 amount: -6
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: query: move absolute -5 in mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: query: fetch backward 4 from mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 41: command fetch backward 4 from mycur; returned 2 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 41: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 41: RESULT: 2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 41: RESULT: b offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 48: query: fetch backward 1 from mycur; fetch all: 0 amount: -1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 48: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 48: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 48: RESULT: 1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 48: RESULT: a offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 41: query: fetch absolute $0 from mycur; fetch all: 0 amount: 7
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: query: move absolute 6 in mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: query: fetch forward 4 from mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 41: command fetch forward 4 from mycur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 41: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 41: RESULT: 7 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 41: RESULT: g offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 44: query: fetch forward 1 from mycur; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 44: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 44: no data found on line 44
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ECPGfetch on line 41: query: fetch absolute $0 from mycur; fetch all: 0 amount: -7
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: query: move absolute -6 in mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: query: fetch backward 4 from mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 41: command fetch backward 4 from mycur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 41: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 41: RESULT: 1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 41: RESULT: a offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 48: query: fetch backward 1 from mycur; fetch all: 0 amount: -1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 48: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 48: no data found on line 48
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ECPGfetch on line 41: query: fetch absolute $0 from mycur; fetch all: 0 amount: 5
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: query: move absolute 4 in mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: query: fetch forward 4 from mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 41: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 41: command fetch forward 4 from mycur; returned 3 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 41: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 41: RESULT: 5 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 41: RESULT: e offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 44: query: fetch forward 1 from mycur; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 44: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 44: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 44: RESULT: 6 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 44: RESULT: f offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 41: query: fetch absolute $0 from mycur; fetch all: 0 amount: -1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 41: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 41: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 41: RESULT: 7 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 41: RESULT: g offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 48: query: fetch backward 1 from mycur; fetch all: 0 amount: -1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 48: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 48: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 48: RESULT: 6 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 48: RESULT: f offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 41: query: fetch absolute $0 from mycur; fetch all: 0 amount: 6
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 41: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 41: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 41: RESULT: 6 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 41: RESULT: f offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 44: query: fetch forward 1 from mycur; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 44: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 44: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 44: RESULT: 7 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 44: RESULT: g offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 41: query: fetch absolute $0 from mycur; fetch all: 0 amount: -2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 41: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 41: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 41: RESULT: 6 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 41: RESULT: f offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 48: query: fetch backward 1 from mycur; fetch all: 0 amount: -1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 48: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 48: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 48: RESULT: 5 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 48: RESULT: e offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 41: query: fetch absolute $0 from mycur; fetch all: 0 amount: 7
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 41: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 41: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 41: RESULT: 7 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 41: RESULT: g offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 44: query: fetch forward 1 from mycur; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 44: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 44: no data found on line 44
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ECPGfetch on line 41: query: fetch absolute $0 from mycur; fetch all: 0 amount: -3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 41: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 41: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 41: RESULT: 5 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 41: RESULT: e offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 48: query: fetch backward 1 from mycur; fetch all: 0 amount: -1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 48: query: move absolute -3 in mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 48: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 48: query: fetch backward 4 from mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 48: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 48: command fetch backward 4 from mycur; returned 4 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 48: correctly got 1 tuples with 2 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 48: RESULT: 4 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 48: RESULT: d offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 115: query: close mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 115: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 115: OK: CLOSE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 119: query: drop table t1; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 119: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 119: OK: DROP TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 120: action "commit"; connection "regress1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_finish: connection regress1 closed
+[NO_PID]: sqlca: code: 0, state: 00000
diff --git a/src/interfaces/ecpg/test/expected/sql-cursor-ra-swdir.stdout b/src/interfaces/ecpg/test/expected/sql-cursor-ra-swdir.stdout
new file mode 100644
index 0000000..92ddbd0
--- /dev/null
+++ b/src/interfaces/ecpg/test/expected/sql-cursor-ra-swdir.stdout
@@ -0,0 +1,39 @@
+Discover total number of tuples and test flipping fetch directions
+absolute: 1 id: 1 t 'a'
+absolute: 2 id: 2 t 'b'
+absolute: -1 id: 7 t 'g'
+absolute: -2 id: 6 t 'f'
+absolute: 2 id: 2 t 'b'
+absolute: 3 id: 3 t 'c'
+absolute: -2 id: 6 t 'f'
+absolute: -3 id: 5 t 'e'
+absolute: 3 id: 3 t 'c'
+absolute: 4 id: 4 t 'd'
+absolute: -3 id: 5 t 'e'
+absolute: -4 id: 4 t 'd'
+absolute: 4 id: 4 t 'd'
+absolute: 5 id: 5 t 'e'
+absolute: -4 id: 4 t 'd'
+absolute: -5 id: 3 t 'c'
+absolute: 5 id: 5 t 'e'
+absolute: 6 id: 6 t 'f'
+absolute: -5 id: 3 t 'c'
+absolute: -6 id: 2 t 'b'
+absolute: 6 id: 6 t 'f'
+absolute: 7 id: 7 t 'g'
+absolute: -6 id: 2 t 'b'
+absolute: -7 id: 1 t 'a'
+absolute: 7 id: 7 t 'g'
+absolute: -7 id: 1 t 'a'
+Re-test flipping of fetch directions
+absolute: 5 id: 5 t 'e'
+absolute: 6 id: 6 t 'f'
+absolute: -1 id: 7 t 'g'
+absolute: -2 id: 6 t 'f'
+absolute: 6 id: 6 t 'f'
+absolute: 7 id: 7 t 'g'
+absolute: -2 id: 6 t 'f'
+absolute: -3 id: 5 t 'e'
+absolute: 7 id: 7 t 'g'
+absolute: -3 id: 5 t 'e'
+absolute: -4 id: 4 t 'd'
diff --git a/src/interfaces/ecpg/test/expected/sql-cursorsubxact.c b/src/interfaces/ecpg/test/expected/sql-cursorsubxact.c
index eb628ce..1df5659 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, 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, 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, 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, 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, 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, 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"
@@ -255,7 +255,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 	else
 		printf("\"savepoint a\" succeeded\n");
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 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, 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 130 "cursorsubxact.pgc"
@@ -332,7 +332,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 
 	/* the cursor was declared under savepoint "a", was forgotten */
 
-	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", curname, ECPGst_normal, "fetch from $0", 
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", 0, curname, ECPGst_normal, "fetch from $0", 
 	ECPGt_char,&(curname),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id[0]),(long)1,(long)1,sizeof(int), 
@@ -413,7 +413,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 	else
 		printf("\"savepoint a\" succeeded\n");
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 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, 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 220 "cursorsubxact.pgc"
@@ -426,7 +426,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 	else
 		printf("open %s (case sensitive) succeeded\n", curname);
 
-	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", curname, ECPGst_normal, "fetch from $0", 
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", 0, curname, ECPGst_normal, "fetch from $0", 
 	ECPGt_char,&(curname),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id[0]),(long)1,(long)1,sizeof(int), 
@@ -456,7 +456,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 
 	/* there's no cursor now */
 
-	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", curname, ECPGst_normal, "fetch from $0", 
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", 0, curname, ECPGst_normal, "fetch from $0", 
 	ECPGt_char,&(curname),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id[1]),(long)1,(long)1,sizeof(int), 
@@ -473,7 +473,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 	else
 		printf("fetch from %s (case sensitive) unexpectedly succeeded (expected 34000)\n", curname);
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 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, 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 246 "cursorsubxact.pgc"
@@ -497,7 +497,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 	else
 		printf("\"rollback to a\" succeeded\n");
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 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, 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 258 "cursorsubxact.pgc"
@@ -523,7 +523,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 
 	/* release savepoint propagated the cursor to the toplevel transaction */
 
-	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", curname, ECPGst_normal, "fetch from $0", 
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", 0, curname, ECPGst_normal, "fetch from $0", 
 	ECPGt_char,&(curname),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id[2]),(long)1,(long)1,sizeof(int), 
diff --git a/src/interfaces/ecpg/test/expected/sql-desc.c b/src/interfaces/ecpg/test/expected/sql-desc.c
index 6e4a25e..34cc95e 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, "c1", ECPGst_normal, "declare c1 no scroll cursor for $1", 
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, "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, 
@@ -256,7 +256,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 #line 58 "desc.pgc"
 
 
-	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", "c1", ECPGst_normal, "fetch next from c1", ECPGt_EOIT, 
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", 0, "c1", ECPGst_normal, "fetch next from c1", ECPGt_EOIT, 
 	ECPGt_int,&(val1output),(long)1,(long)1,sizeof(int), 
 	ECPGt_int,&(ind1),(long)1,(long)1,sizeof(int), 
 	ECPGt_char,(val2output),(long)sizeof("AAA"),(long)1,(sizeof("AAA"))*sizeof(char), 
@@ -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, "c2", ECPGst_normal, "declare c2 no scroll cursor for $1", 
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, "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, 
@@ -306,7 +306,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 #line 70 "desc.pgc"
 
 
-	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", "c2", ECPGst_normal, "fetch next from c2", ECPGt_EOIT, 
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", 0, "c2", ECPGst_normal, "fetch next from c2", ECPGt_EOIT, 
 	ECPGt_int,&(val1output),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,(val2output),(long)sizeof("AAA"),(long)1,(sizeof("AAA"))*sizeof(char), 
diff --git a/src/interfaces/ecpg/test/expected/sql-dyntest.c b/src/interfaces/ecpg/test/expected/sql-dyntest.c
index 980c1e8..20e3ef7 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, "MYCURS", ECPGst_normal, "declare MYCURS no scroll cursor for $1", 
+  { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, "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"
@@ -272,7 +272,7 @@ if (sqlca.sqlcode < 0) error ( );}
 
   while (1)
     {
-      { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", "MYCURS", ECPGst_normal, "fetch in MYCURS", ECPGt_EOIT, 
+      { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", 0, "MYCURS", ECPGst_normal, "fetch in MYCURS", ECPGt_EOIT, 
 	ECPGt_descriptor, "MYDESC", 0L, 0L, 0L, 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 64 "dyntest.pgc"
diff --git a/src/interfaces/ecpg/test/expected/sql-execute.c b/src/interfaces/ecpg/test/expected/sql-execute.c
index c6c5501..d0e33b1 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, "CUR", ECPGst_normal, "declare CUR no scroll cursor for $1", 
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, "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"
@@ -148,7 +148,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 52 "execute.pgc"
 
-	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "8", "CUR", ECPGst_normal, "fetch 8 in CUR", ECPGt_EOIT, 
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "8", 0, "CUR", ECPGst_normal, "fetch 8 in CUR", ECPGt_EOIT, 
 	ECPGt_char,(name),(long)8,(long)8,(8)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_int,(amount),(long)1,(long)8,sizeof(int), 
@@ -205,7 +205,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 #line 72 "execute.pgc"
 
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, "CUR2", ECPGst_normal, "declare CUR2 no scroll cursor for $1", 
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, "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"), 
@@ -215,7 +215,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 74 "execute.pgc"
 
-	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", "CUR2", ECPGst_normal, "fetch in CUR2", ECPGt_EOIT, 
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", 0, "CUR2", ECPGst_normal, "fetch in CUR2", ECPGt_EOIT, 
 	ECPGt_char,(name),(long)8,(long)8,(8)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_int,(amount),(long)1,(long)8,sizeof(int), 
diff --git a/src/interfaces/ecpg/test/expected/sql-fetch.c b/src/interfaces/ecpg/test/expected/sql-fetch.c
index 6f8bcad..56781d7 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, "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, "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();
@@ -113,7 +113,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 #line 30 "fetch.pgc"
 
   while (1) {
-	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", "C", ECPGst_normal, "fetch 1 in C", ECPGt_EOIT, 
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", 0, "C", ECPGst_normal, "fetch 1 in C", ECPGt_EOIT, 
 	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,(str),(long)25,(long)1,(25)*sizeof(char), 
@@ -135,7 +135,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
   /* exec sql whenever not found  continue ; */
 #line 36 "fetch.pgc"
 
-  { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_backward, "2", "C", ECPGst_normal, "move backward 2 in C", ECPGt_EOIT, ECPGt_EORT);
+  { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_backward, "2", 1, "C", ECPGst_normal, "move backward 2 in C", ECPGt_EOIT, ECPGt_EORT);
 #line 37 "fetch.pgc"
 
 if (sqlca.sqlwarn[0] == 'W') sqlprint();
@@ -145,7 +145,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 #line 37 "fetch.pgc"
 
 
-  { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward_in_var, NULL, "C", ECPGst_normal, "fetch $0 in C", 
+  { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward_in_var, NULL, 0, "C", ECPGst_normal, "fetch $0 in C", 
 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
@@ -176,7 +176,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 #line 44 "fetch.pgc"
 
 
-  { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, "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, "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"
@@ -192,7 +192,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 #line 48 "fetch.pgc"
 
   while (1) {
-	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", "D", ECPGst_normal, "fetch 1 in D", ECPGt_EOIT, 
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", 0, "D", ECPGst_normal, "fetch 1 in D", ECPGt_EOIT, 
 	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,(str),(long)25,(long)1,(25)*sizeof(char), 
diff --git a/src/interfaces/ecpg/test/expected/sql-oldexec.c b/src/interfaces/ecpg/test/expected/sql-oldexec.c
index 5e456a4..5ffffa5 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, "CUR", ECPGst_normal, "declare CUR no scroll cursor for $1", 
+	{ ECPGopen(__LINE__, 0, 1, NULL, 1, 0, ECPGcs_no_scroll, 1, "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"
@@ -148,7 +148,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 52 "oldexec.pgc"
 
-	{ ECPGfetch(__LINE__, 0, 1, NULL, 1, ECPGc_forward, "8", "CUR", ECPGst_normal, "fetch 8 in CUR", ECPGt_EOIT, 
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 1, ECPGc_forward, "8", 0, "CUR", ECPGst_normal, "fetch 8 in CUR", ECPGt_EOIT, 
 	ECPGt_char,(name),(long)8,(long)8,(8)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_int,(amount),(long)1,(long)8,sizeof(int), 
@@ -199,7 +199,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 #line 71 "oldexec.pgc"
 
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 1, 0, ECPGcs_no_scroll, "CUR3", ECPGst_normal, "declare CUR3 no scroll cursor for $1", 
+	{ ECPGopen(__LINE__, 0, 1, NULL, 1, 0, ECPGcs_no_scroll, 1, "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"), 
@@ -209,7 +209,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 73 "oldexec.pgc"
 
-	{ ECPGfetch(__LINE__, 0, 1, NULL, 1, ECPGc_forward, "1", "CUR3", ECPGst_normal, "fetch in CUR3", ECPGt_EOIT, 
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 1, ECPGc_forward, "1", 0, "CUR3", ECPGst_normal, "fetch in CUR3", ECPGt_EOIT, 
 	ECPGt_char,(name),(long)8,(long)8,(8)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_int,(amount),(long)1,(long)8,sizeof(int), 
diff --git a/src/interfaces/ecpg/test/expected/sql-quote.c b/src/interfaces/ecpg/test/expected/sql-quote.c
index e34f58e..bd44405 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, "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, "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();
@@ -178,7 +178,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 
   while (true)
   {
-	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", "C", ECPGst_normal, "fetch C", ECPGt_EOIT, 
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", 0, "C", ECPGst_normal, "fetch C", ECPGt_EOIT, 
 	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char), 
diff --git a/src/interfaces/ecpg/test/expected/sql-sqlda.c b/src/interfaces/ecpg/test/expected/sql-sqlda.c
index 277c14e..906b980 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, "mycur1", ECPGst_normal, "declare mycur1 no scroll cursor for $1", 
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, "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"
@@ -268,7 +268,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 	while (1)
 	{
 		strcpy(msg, "fetch");
-		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", "mycur1", ECPGst_normal, "fetch 1 from mycur1", ECPGt_EOIT, 
+		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", 0, "mycur1", ECPGst_normal, "fetch 1 from mycur1", ECPGt_EOIT, 
 	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 111 "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, "mycur2", ECPGst_normal, "declare mycur2 no scroll cursor for $1", 
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, 1, "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"
@@ -334,7 +334,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 
 	strcpy(msg, "fetch");
-	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "all", "mycur2", ECPGst_normal, "fetch all from mycur2", ECPGt_EOIT, 
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "all", 0, "mycur2", ECPGst_normal, "fetch all from mycur2", ECPGt_EOIT, 
 	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 141 "sqlda.pgc"
diff --git a/src/interfaces/ecpg/test/sql/.gitignore b/src/interfaces/ecpg/test/sql/.gitignore
index 4458eb3..c2fe945 100644
--- a/src/interfaces/ecpg/test/sql/.gitignore
+++ b/src/interfaces/ecpg/test/sql/.gitignore
@@ -6,6 +6,12 @@
 /code100.c
 /copystdout
 /copystdout.c
+/cursor-ra-fetch
+/cursor-ra-fetch.c
+/cursor-ra-move
+/cursor-ra-move.c
+/cursor-ra-swdir
+/cursor-ra-swdir.c
 /cursorsubxact
 /cursorsubxact.c
 /define
diff --git a/src/interfaces/ecpg/test/sql/Makefile b/src/interfaces/ecpg/test/sql/Makefile
index f3fdff2..f9b8301 100644
--- a/src/interfaces/ecpg/test/sql/Makefile
+++ b/src/interfaces/ecpg/test/sql/Makefile
@@ -7,6 +7,9 @@ TESTS = array array.c \
 	binary binary.c \
 	code100 code100.c \
         copystdout copystdout.c \
+        cursor-ra-fetch cursor-ra-fetch.c \
+        cursor-ra-move cursor-ra-move.c \
+        cursor-ra-swdir cursor-ra-swdir.c \
         cursorsubxact cursorsubxact.c \
 	define define.c \
         desc desc.c \
diff --git a/src/interfaces/ecpg/test/sql/cursor-ra-fetch.pgc b/src/interfaces/ecpg/test/sql/cursor-ra-fetch.pgc
new file mode 100644
index 0000000..2959e2d
--- /dev/null
+++ b/src/interfaces/ecpg/test/sql/cursor-ra-fetch.pgc
@@ -0,0 +1,575 @@
+#include <stdlib.h>
+#include <string.h>
+
+EXEC SQL INCLUDE ../regression;
+
+exec sql whenever sqlerror sqlprint;
+
+int main(void)
+{
+exec sql begin declare section;
+	int	id[8], i;
+	varchar	t[8][50];
+exec sql end declare section;
+	int	quit_loop;
+
+	ECPGdebug(1, stderr);
+
+	exec sql connect to REGRESSDB1;
+
+	exec sql create table t1 (id serial primary key, t text);
+	exec sql insert into t1 (t) values
+			('a'), ('b'), ('c'), ('d'), ('e'), ('f'), ('g'), ('h'),
+			('i'), ('j'), ('k'), ('l'), ('m'), ('n'), ('o'), ('p'),
+			('q'), ('r'), ('s'), ('t'), ('u'), ('v'), ('w'), ('x'),
+			('y'), ('z');
+	exec sql commit;
+
+	exec sql declare scroll_cur scroll readahead 8 cursor for select id, t from t1 order by id;
+	exec sql declare scroll_cur4 scroll readahead 4 cursor for select id, t from t1 order by id;
+
+	/*
+	 * Test FETCH ABSOLUTE N with an interval of 4 using positive positions.
+	 * Readahead is 8 so caching is in effect.
+	 */
+
+	printf("test scroll_cur for move absolute n (every 4th tuple forward, positive positions)\n");
+
+	exec sql open scroll_cur;
+	if (sqlca.sqlcode < 0)
+		printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate);
+
+	for (i = 1; i < 33; i += 4)
+	{
+		exec sql fetch absolute :i from scroll_cur into :id, :t;
+
+		if (sqlca.sqlerrd[2] == 1)
+			printf("\trow %d: id: %d\tt: %s\n", i, id[0], t[0].arr);
+		else
+			printf("\trow %d does not exist\n", i);
+	}
+
+	printf("\ntest scroll_cur for move absolute n (every 4th tuple backward, positive positions)\n");
+
+	for (i = 33; i >= 0; i -= 4)
+	{
+		exec sql fetch absolute :i from scroll_cur into :id, :t;
+
+		if (sqlca.sqlerrd[2] == 1)
+			printf("\trow %d: id: %d\tt: %s\n", i, id[0], t[0].arr);
+		else
+			printf("\trow %d does not exist\n", i);
+	}
+
+	exec sql rollback;
+
+	/*
+	 * Test FETCH ABSOLUTE N with an interval of 4 using negative positions.
+	 * Readahead is 8 so caching is in effect.
+	 */
+
+	printf("\ntest scroll_cur for move absolute n (every 4th tuple backward, negative positions)\n");
+
+	exec sql open scroll_cur;
+	if (sqlca.sqlcode < 0)
+		printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate);
+
+	for (i = -1; i > -33; i -= 4)
+	{
+		exec sql fetch absolute :i from scroll_cur into :id, :t;
+
+		if (sqlca.sqlerrd[2] == 1)
+			printf("\trow %d: id: %d\tt: %s\n", i, id[0], t[0].arr);
+		else
+			printf("\trow %d does not exist\n", i);
+	}
+
+	printf("\ntest scroll_cur for move absolute n (every 4th tuple forward, negative positions)\n");
+
+	for (i = -33; i <= 0; i += 4)
+	{
+		exec sql fetch absolute :i from scroll_cur into :id, :t;
+
+		if (sqlca.sqlerrd[2] == 1)
+			printf("\trow %d: id: %d\tt: %s\n", i, id[0], t[0].arr);
+		else
+			printf("\trow %d does not exist\n", i);
+	}
+
+	exec sql rollback;
+
+	/*
+	 * Test FETCH RELATIVE +/- 4 using positive positions
+	 * readahead is 8, so caching is in effect
+	 */
+
+	printf("\ntest scroll_cur for fetch relative 4 (positive positions)\n");
+
+	exec sql open scroll_cur;
+	if (sqlca.sqlcode < 0)
+		printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate);
+
+	quit_loop = 0;
+	while (!quit_loop)
+	{
+		for (i = 0; i < 8; i++)
+			id[i] = 0, t[i].arr[0] = '\0';
+		exec sql fetch relative 4 in scroll_cur into :id, :t;
+		if (sqlca.sqlcode < 0)
+			printf("fetch relative 4 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
+		else
+			printf("fetch relative 4 in scroll_cur succeeded, sqlerrd[2] %ld\n", sqlca.sqlerrd[2]);
+		for (i = 0; i < sqlca.sqlerrd[2]; i++)
+			printf("\tid: %d\tt: %s\n", id[i], t[i].arr);
+		quit_loop = (sqlca.sqlerrd[2] == 0);
+	}
+
+	printf("\ntest scroll_cur for fetch relative -4 (positive positions)\n");
+
+	quit_loop = 0;
+	while (!quit_loop)
+	{
+		for (i = 0; i < 8; i++)
+			id[i] = 0, t[i].arr[0] = '\0';
+		exec sql fetch relative -4 in scroll_cur into :id, :t;
+		if (sqlca.sqlcode < 0)
+			printf("fetch relative -4 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
+		else
+			printf("fetch relative -4 in scroll_cur succeeded, sqlerrd[2] %ld\n", sqlca.sqlerrd[2]);
+		for (i = 0; i < sqlca.sqlerrd[2]; i++)
+			printf("\tid: %d\tt: %s\n", id[i], t[i].arr);
+		quit_loop = (sqlca.sqlerrd[2] == 0);
+	}
+
+	exec sql rollback;
+
+	/*
+	 * Test FETCH RELATIVE +/- 4 using negative positions
+	 * readahead is 8, so caching is in effect
+	 */
+
+	printf("\ntest scroll_cur for fetch relative -4 (negative positions)\n");
+
+	exec sql open scroll_cur;
+	if (sqlca.sqlcode < 0)
+		printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate);
+
+	exec sql move absolute -1 in scroll_cur;
+	if (sqlca.sqlcode < 0)
+		printf("move absolute -1 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
+	exec sql move forward 1 in scroll_cur;
+	if (sqlca.sqlcode < 0)
+		printf("move forward 1 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
+
+	quit_loop = 0;
+	while (!quit_loop)
+	{
+		for (i = 0; i < 8; i++)
+			id[i] = 0, t[i].arr[0] = '\0';
+		exec sql fetch relative -4 in scroll_cur into :id, :t;
+		if (sqlca.sqlcode < 0)
+			printf("fetch relative -4 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
+		else
+			printf("fetch relative -4 in scroll_cur succeeded, sqlerrd[2] %ld\n", sqlca.sqlerrd[2]);
+		for (i = 0; i < sqlca.sqlerrd[2]; i++)
+			printf("\tid: %d\tt: %s\n", id[i], t[i].arr);
+		quit_loop = (sqlca.sqlerrd[2] == 0);
+	}
+
+	printf("\ntest scroll_cur for fetch relative 4 (negative positions)\n");
+
+	quit_loop = 0;
+	while (!quit_loop)
+	{
+		for (i = 0; i < 8; i++)
+			id[i] = 0, t[i].arr[0] = '\0';
+		exec sql fetch relative 4 in scroll_cur into :id, :t;
+		if (sqlca.sqlcode < 0)
+			printf("fetch relative 4 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
+		else
+			printf("fetch relative 4 in scroll_cur succeeded, sqlerrd[2] %ld\n", sqlca.sqlerrd[2]);
+		for (i = 0; i < sqlca.sqlerrd[2]; i++)
+			printf("\tid: %d\tt: %s\n", id[i], t[i].arr);
+		quit_loop = (sqlca.sqlerrd[2] == 0);
+	}
+
+	exec sql rollback;
+
+	/*
+	 * Test FETCH FORWARD +/- 4 using positive positions
+	 * readahead is 8, so caching is in effect
+	 */
+
+	printf("\ntest scroll_cur for fetch forward 4 (positive positions)\n");
+
+	exec sql open scroll_cur;
+	if (sqlca.sqlcode < 0)
+		printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate);
+
+	quit_loop = 0;
+	while (!quit_loop)
+	{
+		for (i = 0; i < 8; i++)
+			id[i] = 0, t[i].arr[0] = '\0';
+		exec sql fetch forward 4 in scroll_cur into :id, :t;
+		if (sqlca.sqlcode < 0)
+			printf("fetch forward 4 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
+		else
+			printf("fetch forward 4 in scroll_cur succeeded, sqlerrd[2] %ld\n", sqlca.sqlerrd[2]);
+		for (i = 0; i < sqlca.sqlerrd[2]; i++)
+			printf("\tid: %d\tt: %s\n", id[i], t[i].arr);
+		quit_loop = (sqlca.sqlerrd[2] == 0);
+	}
+
+	printf("\ntest scroll_cur for fetch forward -4 (positive positions)\n");
+
+	quit_loop = 0;
+	while (!quit_loop)
+	{
+		for (i = 0; i < 8; i++)
+			id[i] = 0, t[i].arr[0] = '\0';
+		exec sql fetch forward -4 in scroll_cur into :id, :t;
+		if (sqlca.sqlcode < 0)
+			printf("fetch forward -4 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
+		else
+			printf("fetch forward -4 in scroll_cur succeeded, sqlerrd[2] %ld\n", sqlca.sqlerrd[2]);
+		for (i = 0; i < sqlca.sqlerrd[2]; i++)
+			printf("\tid: %d\tt: %s\n", id[i], t[i].arr);
+		quit_loop = (sqlca.sqlerrd[2] == 0);
+	}
+
+	exec sql rollback;
+
+	/*
+	 * Test FETCH FORWARD +/- 4 using negative positions
+	 * readahead is 8, so caching is in effect
+	 */
+
+	printf("\ntest scroll_cur for fetch forward -4 (negative positions)\n");
+
+	exec sql open scroll_cur;
+	if (sqlca.sqlcode < 0)
+		printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate);
+
+	exec sql move absolute -1 in scroll_cur;
+	if (sqlca.sqlcode < 0)
+		printf("move absolute -1 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
+	exec sql move forward 1 in scroll_cur;
+	if (sqlca.sqlcode < 0)
+		printf("move forward 1 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
+
+	quit_loop = 0;
+	while (!quit_loop)
+	{
+		for (i = 0; i < 8; i++)
+			id[i] = 0, t[i].arr[0] = '\0';
+		exec sql fetch forward -4 in scroll_cur into :id, :t;
+		if (sqlca.sqlcode < 0)
+			printf("fetch forward -4 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
+		else
+			printf("fetch forward -4 in scroll_cur succeeded, sqlerrd[2] %ld\n", sqlca.sqlerrd[2]);
+		for (i = 0; i < sqlca.sqlerrd[2]; i++)
+			printf("\tid: %d\tt: %s\n", id[i], t[i].arr);
+		quit_loop = (sqlca.sqlerrd[2] == 0);
+	}
+
+	printf("\ntest scroll_cur for fetch forward 4 (negative positions)\n");
+
+	quit_loop = 0;
+	while (!quit_loop)
+	{
+		for (i = 0; i < 8; i++)
+			id[i] = 0, t[i].arr[0] = '\0';
+		exec sql fetch forward 4 in scroll_cur into :id, :t;
+		if (sqlca.sqlcode < 0)
+			printf("fetch forward 4 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
+		else
+			printf("fetch forward 4 in scroll_cur succeeded, sqlerrd[2] %ld\n", sqlca.sqlerrd[2]);
+		for (i = 0; i < sqlca.sqlerrd[2]; i++)
+			printf("\tid: %d\tt: %s\n", id[i], t[i].arr);
+		quit_loop = (sqlca.sqlerrd[2] == 0);
+	}
+
+	exec sql rollback;
+
+	/*
+	 * Test FETCH ABSOLUTE N with an interval of 5 using positive positions.
+	 * Readahead is 4 so cache misses occur.
+	 * ecpglib will switch to plain ecpg_execute after 3 cache misses
+	 */
+
+	printf("\ntest scroll_cur4 for move absolute n (every 5th tuple forward, positive positions)\n");
+
+	exec sql open scroll_cur4;
+	if (sqlca.sqlcode < 0)
+		printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate);
+
+	for (i = 1; i < 35; i += 5)
+	{
+		exec sql fetch absolute :i from scroll_cur4 into :id, :t;
+
+		if (sqlca.sqlerrd[2] == 1)
+			printf("\trow %d: id: %d\tt: %s\n", i, id[0], t[0].arr);
+		else
+			printf("\trow %d does not exist\n", i);
+	}
+
+	/*
+	 * Let's see caching recovers by fetching 2x the readahead size.
+	 * The cursor must be at the end now, with the cursor's pos,
+	 * backend_pos, atstart and atend correctly set.
+	 */
+
+	printf("\ntest fetch backward 8 from scroll_cur4 after the cursor switched to ecpg_execute()\n");
+
+	exec sql fetch backward 8 from scroll_cur4 into :id, :t;
+	for (i = 0; i < sqlca.sqlerrd[2]; i++)
+		printf("\tid: %d t: %s\n", id[i], t[i].arr);
+
+	printf("\ntest scroll_cur4 for move absolute n (every 5th tuple backward, positive positions)\n");
+
+	for (i = 36; i >= 0; i -= 5)
+	{
+		exec sql fetch absolute :i from scroll_cur4 into :id, :t;
+
+		if (sqlca.sqlerrd[2] == 1)
+			printf("\trow %d: id: %d\tt: %s\n", i, id[0], t[0].arr);
+		else
+			printf("\trow %d does not exist\n", i);
+	}
+
+	/*
+	 * Let's see caching recovers by fetching 2x the readahead size.
+	 * The cursor must be at the start+1 (pos == 1) now,
+	 * with the cursor's pos, backend_pos, atstart and atend
+	 * correctly set.
+	 */
+
+	printf("\ntest fetch forward 8 from scroll_cur4 after the cursor switched to ecpg_execute()\n");
+
+	exec sql fetch forward 8 from scroll_cur4 into :id, :t;
+	for (i = 0; i < sqlca.sqlerrd[2]; i++)
+		printf("\tid: %d t: %s\n", id[i], t[i].arr);
+
+	exec sql rollback;
+
+	/*
+	 * Test FETCH ABSOLUTE N with an interval of 5 using negative positions.
+	 * Readahead is 4 so cache misses occur.
+	 * ecpglib will switch to plain ecpg_execute after 3 cache misses
+	 */
+
+	printf("\ntest scroll_cur4 for move absolute n (every 5th tuple backward, negative positions)\n");
+
+	exec sql open scroll_cur4;
+	if (sqlca.sqlcode < 0)
+		printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate);
+
+	for (i = -1; i > -35; i -= 5)
+	{
+		exec sql fetch absolute :i from scroll_cur4 into :id, :t;
+
+		if (sqlca.sqlerrd[2] == 1)
+			printf("\trow %d: id: %d\tt: %s\n", i, id[0], t[0].arr);
+		else
+			printf("\trow %d does not exist\n", i);
+	}
+
+	/*
+	 * Let's see caching recovers by fetching 2x the readahead size.
+	 * The cursor must be at the start (pos == -27) now,
+	 * with the cursor's pos, backend_pos, atstart and atend
+	 * correctly set.
+	 */
+
+	printf("\ntest fetch forward 8 from scroll_cur4 after the cursor switched to ecpg_execute()\n");
+
+	exec sql fetch forward 8 from scroll_cur4 into :id, :t;
+	for (i = 0; i < sqlca.sqlerrd[2]; i++)
+		printf("\tid: %d t: %s\n", id[i], t[i].arr);
+
+	printf("\ntest scroll_cur4 for move absolute n (every 5th tuple forward, negative positions)\n");
+
+	for (i = -36; i <= 0; i += 5)
+	{
+		exec sql fetch absolute :i from scroll_cur4 into :id, :t;
+
+		if (sqlca.sqlerrd[2] == 1)
+			printf("\trow %d: id: %d\tt: %s\n", i, id[0], t[0].arr);
+		else
+			printf("\trow %d does not exist\n", i);
+	}
+
+	/*
+	 * Let's see caching recovers by fetching 2x the readahead size.
+	 * The cursor must be at the end-1 (pos == -1) now,
+	 * with the cursor's pos, backend_pos, atstart and atend
+	 * correctly set.
+	 */
+
+	printf("\ntest fetch backward 8 from scroll_cur4 after the cursor switched to ecpg_execute()\n");
+
+	exec sql fetch backward 8 from scroll_cur4 into :id, :t;
+	for (i = 0; i < sqlca.sqlerrd[2]; i++)
+		printf("\tid: %d t: %s\n", id[i], t[i].arr);
+
+	exec sql rollback;
+
+	/*
+	 * Test FETCH RELATIVE +/- 5 using positive positions.
+	 * Readahead is 4 so cache misses occur.
+	 * ecpglib will switch to plain ecpg_execute after 3 cache misses
+	 */
+
+	printf("\ntest scroll_cur4 for fetch relative 5 (positive positions)\n");
+
+	exec sql open scroll_cur4;
+	if (sqlca.sqlcode < 0)
+		printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate);
+
+	quit_loop = 0;
+	while (!quit_loop)
+	{
+		exec sql fetch relative 5 from scroll_cur4 into :id, :t;
+
+		if (sqlca.sqlerrd[2] == 1)
+			printf("\tid: %d\tt: %s\n", id[0], t[0].arr);
+		else
+			printf("\tfetch returned empty\n");
+		quit_loop = (sqlca.sqlerrd[2] == 0);
+	}
+
+	/*
+	 * Let's see caching recovers by fetching 2x the readahead size.
+	 * The cursor must be at the end now,
+	 * with the cursor's pos, backend_pos, atstart and atend
+	 * correctly set.
+	 */
+
+	printf("\ntest fetch backward 8 from scroll_cur4 after the cursor switched to ecpg_execute()\n");
+
+	exec sql fetch backward 8 from scroll_cur4 into :id, :t;
+	for (i = 0; i < sqlca.sqlerrd[2]; i++)
+		printf("\tid: %d t: %s\n", id[i], t[i].arr);
+
+	/* Exaggerate the number of tuples, move to the end. */
+	exec sql move forward 100 in scroll_cur4;
+	if (sqlca.sqlcode < 0)
+		printf("move forward 100 in scroll_cur4 failed with SQLSTATE %5s\n", sqlca.sqlstate);
+
+	printf("\ntest scroll_cur4 for fetch relative -5 (positive positions)\n");
+
+	quit_loop = 0;
+	while (!quit_loop)
+	{
+		exec sql fetch relative -5 from scroll_cur4 into :id, :t;
+
+		if (sqlca.sqlerrd[2] == 1)
+			printf("\tid: %d\tt: %s\n", id[0], t[0].arr);
+		else
+			printf("\tfetch returned empty\n");
+		quit_loop = (sqlca.sqlerrd[2] == 0);
+	}
+
+	/*
+	 * Let's see caching recovers by fetching 2x the readahead size.
+	 * The cursor must be at the start now,
+	 * with the cursor's pos, backend_pos, atstart and atend
+	 * correctly set.
+	 */
+
+	printf("\ntest fetch forward 8 from scroll_cur4 after the cursor switched to ecpg_execute()\n");
+
+	exec sql fetch forward 8 from scroll_cur4 into :id, :t;
+	for (i = 0; i < sqlca.sqlerrd[2]; i++)
+		printf("\tid: %d t: %s\n", id[i], t[i].arr);
+
+	exec sql rollback;
+
+	/*
+	 * Test FETCH RELATIVE +/- 5 using negative positions.
+	 * Readahead is 4 so cache misses occur.
+	 * ecpglib will switch to plain ecpg_execute after 3 cache misses
+	 */
+
+	printf("\ntest scroll_cur4 for move relative -5 (negative positions)\n");
+
+	exec sql open scroll_cur4;
+	if (sqlca.sqlcode < 0)
+		printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate);
+
+	exec sql move absolute -1 in scroll_cur4;
+	if (sqlca.sqlcode < 0)
+		printf("move absolute -1 in scroll_cur4 failed with SQLSTATE %5s\n", sqlca.sqlstate);
+	exec sql move forward 1 in scroll_cur4;
+	if (sqlca.sqlcode < 0)
+		printf("move forward 1 in scroll_cur4 failed with SQLSTATE %5s\n", sqlca.sqlstate);
+
+	quit_loop = 0;
+	while (!quit_loop)
+	{
+		exec sql fetch relative -5 from scroll_cur4 into :id, :t;
+
+		if (sqlca.sqlerrd[2] == 1)
+			printf("\tid: %d\tt: %s\n", id[0], t[0].arr);
+		else
+			printf("\tfetch returned empty\n");
+		quit_loop = (sqlca.sqlerrd[2] == 0);
+	}
+
+	/*
+	 * Let's see caching recovers by fetching 2x the readahead size.
+	 * The cursor must be at the start now,
+	 * with the cursor's pos, backend_pos, atstart and atend
+	 * correctly set.
+	 */
+
+	printf("\ntest fetch forward 8 from scroll_cur4 after the cursor switched to ecpg_execute()\n");
+
+	exec sql fetch forward 8 from scroll_cur4 into :id, :t;
+	for (i = 0; i < sqlca.sqlerrd[2]; i++)
+		printf("\tid: %d t: %s\n", id[i], t[i].arr);
+
+	/* Exaggerate the number of tuples, move to the start. */
+	exec sql move backward 100 in scroll_cur4;
+	if (sqlca.sqlcode < 0)
+		printf("move backward 100 in scroll_cur4 failed with SQLSTATE %5s\n", sqlca.sqlstate);
+
+	printf("\ntest scroll_cur for move relative 5 (negative positions)\n");
+
+	quit_loop = 0;
+	while (!quit_loop)
+	{
+		exec sql fetch relative 5 from scroll_cur4 into :id, :t;
+
+		if (sqlca.sqlerrd[2] == 1)
+			printf("\tid: %d\tt: %s\n", id[0], t[0].arr);
+		else
+			printf("\tfetch returned empty\n");
+		quit_loop = (sqlca.sqlerrd[2] == 0);
+	}
+
+	/*
+	 * Let's see caching recovers by fetching 2x the readahead size.
+	 * The cursor must be at the end now,
+	 * with the cursor's pos, backend_pos, atstart and atend
+	 * correctly set.
+	 */
+
+	printf("\ntest fetch backward 8 from scroll_cur4 after the cursor switched to ecpg_execute()\n");
+
+	exec sql fetch backward 8 from scroll_cur4 into :id, :t;
+	for (i = 0; i < sqlca.sqlerrd[2]; i++)
+		printf("\tid: %d t: %s\n", id[i], t[i].arr);
+
+	exec sql rollback;
+
+	/* Drop the test table */
+
+	exec sql drop table t1;
+	exec sql commit;
+
+	exec sql disconnect all;
+
+	return 0;
+}
diff --git a/src/interfaces/ecpg/test/sql/cursor-ra-move.pgc b/src/interfaces/ecpg/test/sql/cursor-ra-move.pgc
new file mode 100644
index 0000000..2122552
--- /dev/null
+++ b/src/interfaces/ecpg/test/sql/cursor-ra-move.pgc
@@ -0,0 +1,164 @@
+#include <stdlib.h>
+#include <string.h>
+
+EXEC SQL INCLUDE ../regression;
+
+exec sql whenever sqlerror sqlprint;
+
+int main(void)
+{
+	int	quit_loop;
+
+	ECPGdebug(1, stderr);
+
+	exec sql connect to REGRESSDB1;
+
+	exec sql create table t1 (id serial primary key, t text);
+	exec sql insert into t1 (t) values
+			('a'), ('b'), ('c'), ('d'), ('e'), ('f'), ('g'), ('h'),
+			('i'), ('j'), ('k'), ('l'), ('m'), ('n'), ('o'), ('p'),
+			('q'), ('r'), ('s'), ('t'), ('u'), ('v'), ('w'), ('x'),
+			('y'), ('z');
+	exec sql commit;
+
+	exec sql declare scroll_cur scroll readahead 8 cursor for select id, t from t1 order by id;
+	exec sql declare noscroll_cur no scroll readahead 8 cursor for select id, t from t1 order by id;
+	/* Implicitly non-scrollable cursors */
+	exec sql declare unspec_cur1 readahead 8 cursor for select id, t from t1 order by id;
+	exec sql declare unspec_cur2 readahead 8 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;
+
+	/* Test MOVE ABSOLUTE -1 for all 4 cursors */
+
+	printf("test scroll_cur for move absolute -1\n");
+
+	exec sql open scroll_cur;
+	if (sqlca.sqlcode < 0)
+		printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate);
+
+	exec sql move absolute -1 in scroll_cur;
+	if (sqlca.sqlcode < 0)
+		printf("move absolute -1 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
+	else
+		printf("move absolute -1 in scroll_cur succeeded\n");
+
+	exec sql rollback;
+
+	printf("test noscroll_cur for move absolute -1\n");
+
+	exec sql open noscroll_cur;
+	if (sqlca.sqlcode < 0)
+		printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate);
+
+	exec sql move absolute -1 in noscroll_cur;
+	if (sqlca.sqlcode < 0)
+		printf("move absolute -1 in noscroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
+	else
+		printf("move absolute -1 in noscroll_cur succeeded\n");
+
+	exec sql rollback;
+
+	printf("test unspec_cur1 for move absolute -1\n");
+
+	exec sql open unspec_cur1;
+	if (sqlca.sqlcode < 0)
+		printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate);
+
+	exec sql move absolute -1 in unspec_cur1;
+	if (sqlca.sqlcode < 0)
+		printf("move absolute -1 in unspec_cur1 failed with SQLSTATE %5s\n", sqlca.sqlstate);
+	else
+		printf("move absolute -1 in unspec_cur1 succeeded\n");
+
+	exec sql rollback;
+
+	printf("test unspec_cur2 for move absolute -1\n");
+
+	exec sql open unspec_cur2;
+	if (sqlca.sqlcode < 0)
+		printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate);
+
+	exec sql move absolute -1 in unspec_cur2;
+	if (sqlca.sqlcode < 0)
+		printf("move absolute -1 in unspec_cur2 failed with SQLSTATE %5s\n", sqlca.sqlstate);
+	else
+		printf("move absolute -1 in unspec_cur2 succeeded\n");
+
+	exec sql rollback;
+
+	/* Test MOVE RELATIVE 8 */
+
+	printf("test scroll_cur for move relative 8\n");
+
+	exec sql open scroll_cur;
+	if (sqlca.sqlcode < 0)
+		printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate);
+
+	quit_loop = 0;
+	while (!quit_loop)
+	{
+		exec sql move relative 8 in scroll_cur;
+		if (sqlca.sqlcode < 0)
+			printf("move relative 8 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
+		else
+			printf("move relative 8 in scroll_cur succeeded, sqlerrd[2] %ld\n", sqlca.sqlerrd[2]);
+		quit_loop = (sqlca.sqlerrd[2] == 0);
+	}
+
+	printf("test scroll_cur for move relative -8\n");
+
+	quit_loop = 0;
+	while (!quit_loop)
+	{
+		exec sql move relative -8 in scroll_cur;
+		if (sqlca.sqlcode < 0)
+			printf("move relative -8 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
+		else
+			printf("move relative -8 in scroll_cur succeeded, sqlerrd[2] %ld\n", sqlca.sqlerrd[2]);
+		quit_loop = (sqlca.sqlerrd[2] == 0);
+	}
+
+	exec sql rollback;
+
+	/* Test MOVE FORWARD 8 */
+
+	printf("test scroll_cur for move forward 8\n");
+
+	exec sql open scroll_cur;
+	if (sqlca.sqlcode < 0)
+		printf("open failed with SQLSTATE %5s\n", sqlca.sqlstate);
+
+	quit_loop = 0;
+	while (!quit_loop)
+	{
+		exec sql move forward 8 in scroll_cur;
+		if (sqlca.sqlcode < 0)
+			printf("move forward 8 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
+		else
+			printf("move forward 8 in scroll_cur succeeded, sqlerrd[2] %ld\n", sqlca.sqlerrd[2]);
+		quit_loop = (sqlca.sqlerrd[2] == 0);
+	}
+
+	printf("test scroll_cur for move forward -8\n");
+
+	quit_loop = 0;
+	while (!quit_loop)
+	{
+		exec sql move forward -8 in scroll_cur;
+		if (sqlca.sqlcode < 0)
+			printf("move forward -8 in scroll_cur failed with SQLSTATE %5s\n", sqlca.sqlstate);
+		else
+			printf("move forward -8 in scroll_cur succeeded, sqlerrd[2] %ld\n", sqlca.sqlerrd[2]);
+		quit_loop = (sqlca.sqlerrd[2] == 0);
+	}
+
+	exec sql rollback;
+
+	/* Drop the test table */
+
+	exec sql drop table t1;
+	exec sql commit;
+
+	exec sql disconnect all;
+
+	return 0;
+}
diff --git a/src/interfaces/ecpg/test/sql/cursor-ra-swdir.pgc b/src/interfaces/ecpg/test/sql/cursor-ra-swdir.pgc
new file mode 100644
index 0000000..201960c
--- /dev/null
+++ b/src/interfaces/ecpg/test/sql/cursor-ra-swdir.pgc
@@ -0,0 +1,125 @@
+/*
+ * Test MOVE ABSOLUTE N with alternating positive/negative
+ * positions and FETCH FORWARD/BACKWARD another record according
+ * to the current value.
+ *
+ * This code makes the result set size known by reaching the end.
+ * in both directions.
+ *
+ * After reaching the end, the cache_start_pos can be flipped
+ * from positive to negative to match the cursor position
+ * issued by the application.
+ *
+ * To watch this effect, execute:
+ *
+ * $ grep -n ecpg_cursor_execute results/sql-cursor-ra-swdir.stderr
+ *
+ */
+#include <stdlib.h>
+#include <string.h>
+
+EXEC SQL INCLUDE ../regression;
+
+exec sql whenever sqlerror sqlprint;
+
+exec sql declare mycur scroll readahead 4 cursor for select id, t from t1 order by id;
+
+exec sql begin declare section;
+int	id[2];
+varchar	t[2][50];
+exec sql end declare section;
+
+static void fetch2(int absolute)
+{
+	exec sql begin declare section;
+	int	absolute1 = absolute;
+	exec sql end declare section;
+
+	int	i, rows = 1;
+	int	direction = (absolute < 0 ? -1 : 1);
+
+	exec sql fetch absolute :absolute1 from mycur into :id[0], :t[0];
+	if (direction > 0)
+	{
+		exec sql fetch forward 1 from mycur into :id[1], :t[1];
+	}
+	else
+	{
+		exec sql fetch backward 1 from mycur into :id[1], :t[1];
+	}
+
+	rows += sqlca.sqlerrd[2];
+
+	for (i = 0; i < rows; i++)
+		printf("absolute: %d id: %d t '%s'\n", absolute + i*direction, id[i], t[i].arr);
+}
+
+int main(void)
+{
+	exec sql begin declare section;
+	int	i, j;
+	exec sql end declare section;
+
+	ECPGdebug(1, stderr);
+
+	exec sql connect to REGRESSDB1;
+
+	exec sql create table t1 (id serial primary key, t text);
+	exec sql insert into t1 (t) values
+			('a'), ('b'), ('c'), ('d'), ('e'), ('f'), ('g');
+	exec sql commit;
+
+	exec sql open mycur;
+
+	printf("Discover total number of tuples and test flipping fetch directions\n");
+
+	/*
+	 * This part verifies that the returned rows are correct
+	 * in each direction and the runtime eventually discovers
+	 * the size of the result set by reaching the end.
+	 * These position series are fetched, constantly switching
+	 * directions:
+	 *   1,  2,  3,  4,  5,  6,  7
+	 *  -1, -2, -3, -4, -5, -6, -7
+	 * Only the FETCH FORWARD/BACKWARD after every FETCH ABSOLUTE
+	 * hits the cache initially because the result set size is
+	 * unknown. When it becomes known, the readahead windows from
+	 * different directions don't overlap.
+	 */
+	for (i = 1, j = -1; i <= 7; i++, j--)
+	{
+		fetch2(i);
+		fetch2(j);
+	}
+
+	printf("Re-test flipping of fetch directions\n");
+
+	/*
+	 * Re-test flipping with different positions. The result set
+	 * size is already known from the previous loop.
+	 * Test this interval that also involve the end of the result set:
+	 *	-->      5,  6,  7, (end)
+	 *	    -4, -3, -2, -1  <--
+	 * After the first fetch, this loop can be served
+	 * almost entirely from the same cache except the last
+	 * request: fetch2(-3) does:
+	 *	FETCH ABSOLUTE -3 (still in the cache)
+	 *	FETCH BACKWARD 1 (does a new FETCH)
+	 */
+	for (i = 5, j = -1; i <= 7; i++, j--)
+	{
+		fetch2(i);
+		fetch2(j);
+	}
+
+	exec sql close mycur;
+
+	/* Drop the test table */
+
+	exec sql drop table t1;
+	exec sql commit;
+
+	exec sql disconnect all;
+
+	return 0;
+}
