commit c845196c2cf68219db971aff80e8d649cc22526b
Author: Böszörményi Zoltán <zb@cybertec.at>
Date:   Fri Dec 6 13:52:17 2013 +0100

    ECPG: Really drive every cursor through the readahead code,
    not just those with READAHEAD N > 1.

diff --git a/src/interfaces/ecpg/ecpglib/cursor.c b/src/interfaces/ecpg/ecpglib/cursor.c
index 7e231d7..59fce47 100644
--- a/src/interfaces/ecpg/ecpglib/cursor.c
+++ b/src/interfaces/ecpg/ecpglib/cursor.c
@@ -1871,18 +1871,28 @@ ECPGfetch(const int lineno, const int compat, const int force_indicator,
 		return false;
 	}
 
-	if (cur->readahead == 1)
+	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);
+
+	if (move)
 	{
 		/*
-		 * If there is no readahead, it's no use playing games
-		 * behind the application's back.
+		 * 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 (!ecpg_execute(stmt))
+		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);
@@ -1891,51 +1901,19 @@ ECPGfetch(const int lineno, const int compat, const int force_indicator,
 	}
 	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 (dir == ECPGc_forward || dir == ECPGc_relative)
 		{
-			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))
+			if (llabs(amount1) > cur->readahead)
 			{
-				ecpg_do_epilogue(stmt);
-				return false;
+				cur->readahead = llabs(amount1);
+				ecpg_log("ECPGfetch on line %d: permanently raising readahead window size to %lld\n",
+								lineno, (long long)cur->readahead);
 			}
 		}
-		else
+		if (!ecpg_cursor_fetch(stmt, cur, dir, amount1, fetchall))
 		{
-			if (dir == ECPGc_forward || dir == ECPGc_relative)
-			{
-				if (llabs(amount1) > cur->readahead)
-				{
-					cur->readahead = llabs(amount1);
-					ecpg_log("ECPGfetch on line %d: permanently raising readahead window size to %lld\n",
-									lineno, (long long)cur->readahead);
-				}
-			}
-
-			if (!ecpg_cursor_fetch(stmt, cur, dir, amount1, fetchall))
-			{
-				ecpg_do_epilogue(stmt);
-				return false;
-			}
+			ecpg_do_epilogue(stmt);
+			return false;
 		}
 	}
 
diff --git a/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stderr b/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stderr
index 1ed5dde..41a32c7 100644
--- a/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stderr
+++ b/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stderr
@@ -30,10 +30,14 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 101: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 109: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 109: query: fetch 1 from mycur1; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 109: query: fetch forward 1 from mycur1; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 109: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 109: command fetch forward 1 from mycur1; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 109: correctly got 1 tuples with 5 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_build_compat_sqlda on line 109 sqld = 5
@@ -62,10 +66,14 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 109: putting result (1 tuple 5 fields) into sqlda descriptor
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 109: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 109: query: fetch 1 from mycur1; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 109: query: fetch forward 1 from mycur1; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 109: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 109: command fetch forward 1 from mycur1; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 109: correctly got 1 tuples with 5 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_build_compat_sqlda on line 109 sqld = 5
@@ -86,10 +94,14 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 109: putting result (1 tuple 5 fields) into sqlda descriptor
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 109: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 109: query: fetch 1 from mycur1; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 109: query: fetch forward 1 from mycur1; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 109: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 109: command fetch forward 1 from mycur1; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 109: correctly got 1 tuples with 5 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_build_compat_sqlda on line 109 sqld = 5
@@ -118,11 +130,13 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 109: putting result (1 tuple 5 fields) into sqlda descriptor
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 109: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 109: query: fetch 1 from mycur1; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 109: query: fetch forward 1 from mycur1; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 109: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_process_output on line 109: correctly got 0 tuples with 5 fields
+[NO_PID]: ecpg_cursor_execute on line 109: command fetch forward 1 from mycur1; returned 0 tuples
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: raising sqlcode 100 on line 109: no data found on line 109
 [NO_PID]: sqlca: code: 100, state: 02000
@@ -142,10 +156,14 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 138: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 146: query: fetch from mycur2; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 146: query: fetch from mycur2; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 146: query: fetch forward 1 from mycur2; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 146: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 146: command fetch forward 1 from mycur2; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 146: correctly got 1 tuples with 5 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_build_compat_sqlda on line 146 sqld = 5
@@ -174,10 +192,14 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 146: putting result (1 tuple 5 fields) into sqlda descriptor
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 146: query: fetch from mycur2; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 146: query: fetch from mycur2; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 146: query: fetch forward 1 from mycur2; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 146: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 146: command fetch forward 1 from mycur2; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 146: correctly got 1 tuples with 5 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_build_compat_sqlda on line 146 sqld = 5
@@ -198,10 +220,14 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 146: putting result (1 tuple 5 fields) into sqlda descriptor
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 146: query: fetch from mycur2; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 146: query: fetch from mycur2; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 146: query: fetch forward 1 from mycur2; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 146: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 146: command fetch forward 1 from mycur2; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 146: correctly got 1 tuples with 5 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_build_compat_sqlda on line 146 sqld = 5
@@ -230,11 +256,13 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 146: putting result (1 tuple 5 fields) into sqlda descriptor
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 146: query: fetch from mycur2; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 146: query: fetch from mycur2; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 146: query: fetch forward 1 from mycur2; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 146: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_process_output on line 146: correctly got 0 tuples with 5 fields
+[NO_PID]: ecpg_cursor_execute on line 146: command fetch forward 1 from mycur2; returned 0 tuples
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: raising sqlcode 100 on line 146: no data found on line 146
 [NO_PID]: sqlca: code: 100, state: 02000
diff --git a/src/interfaces/ecpg/test/expected/compat_informix-test_informix.stderr b/src/interfaces/ecpg/test/expected/compat_informix-test_informix.stderr
index a5a1b3c..96e37b9 100644
--- a/src/interfaces/ecpg/test/expected/compat_informix-test_informix.stderr
+++ b/src/interfaces/ecpg/test/expected/compat_informix-test_informix.stderr
@@ -63,10 +63,14 @@ DETAIL:  Key (i)=(7) already exists.
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 95: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 57: query: fetch forward c; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 57: query: fetch forward c; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 57: query: fetch forward 1 from c; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 57: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 57: command fetch forward 1 from c; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 57: correctly got 1 tuples with 3 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 57: RESULT: 7 offset: -1; array: no
@@ -75,10 +79,14 @@ DETAIL:  Key (i)=(7) already exists.
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 57: RESULT: test    offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 57: query: fetch forward c; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 57: query: fetch forward c; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 57: query: fetch forward 1 from c; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 57: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 57: command fetch forward 1 from c; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 57: correctly got 1 tuples with 3 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 57: RESULT: 14 offset: -1; array: no
@@ -87,11 +95,13 @@ DETAIL:  Key (i)=(7) already exists.
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 57: RESULT: a       offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 57: query: fetch forward c; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 57: query: fetch forward c; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 57: query: fetch forward 1 from c; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 57: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_process_output on line 57: correctly got 0 tuples with 3 fields
+[NO_PID]: ecpg_cursor_execute on line 57: command fetch forward 1 from c; returned 0 tuples
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: raising sqlcode 100 on line 57: no data found on line 57
 [NO_PID]: sqlca: code: 100, state: 02000
diff --git a/src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.stderr b/src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.stderr
index b07ed65..ba4c46e 100644
--- a/src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.stderr
+++ b/src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.stderr
@@ -20,10 +20,14 @@
 [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]: ecpg_execute on line 37: query: fetch from cur; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 37: query: fetch from cur; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 37: query: fetch forward 1 from cur; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 37: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 37: command fetch forward 1 from cur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 37: correctly got 1 tuples with 3 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 37: RESULT: 1 offset: -1; array: no
@@ -52,10 +56,14 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 46: OK: INSERT 0 1
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 37: query: fetch from cur; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 37: query: fetch from cur; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 37: query: fetch forward 1 from cur; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 37: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 37: command fetch forward 1 from cur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 37: correctly got 1 tuples with 3 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 37: RESULT: 2 offset: -1; array: no
@@ -84,10 +92,14 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 46: OK: INSERT 0 1
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 37: query: fetch from cur; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 37: query: fetch from cur; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 37: query: fetch forward 1 from cur; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 37: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 37: command fetch forward 1 from cur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 37: correctly got 1 tuples with 3 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 37: RESULT: 3 offset: -1; array: no
@@ -116,11 +128,13 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 46: OK: INSERT 0 1
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 37: query: fetch from cur; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 37: query: fetch from cur; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 37: query: fetch forward 1 from cur; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 37: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_process_output on line 37: correctly got 0 tuples with 3 fields
+[NO_PID]: ecpg_cursor_execute on line 37: command fetch forward 1 from cur; returned 0 tuples
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: raising sqlcode 100 on line 37: no data found on line 37
 [NO_PID]: sqlca: code: 100, state: 02000
@@ -136,10 +150,14 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 50: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 53: query: fetch from cur; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 53: query: fetch from cur; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 53: query: fetch forward 1 from cur; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 53: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 53: command fetch forward 1 from cur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 53: correctly got 1 tuples with 3 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 53: RESULT: 1 offset: -1; array: no
@@ -148,10 +166,14 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 53: RESULT: NaN offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 53: query: fetch from cur; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 53: query: fetch from cur; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 53: query: fetch forward 1 from cur; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 53: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 53: command fetch forward 1 from cur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 53: correctly got 1 tuples with 3 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 53: RESULT: 2 offset: -1; array: no
@@ -160,10 +182,14 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 53: RESULT: Infinity offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 53: query: fetch from cur; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 53: query: fetch from cur; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 53: query: fetch forward 1 from cur; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 53: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 53: command fetch forward 1 from cur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 53: correctly got 1 tuples with 3 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 53: RESULT: 3 offset: -1; array: no
@@ -172,10 +198,14 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 53: RESULT: -Infinity offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 53: query: fetch from cur; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 53: query: fetch from cur; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 53: query: fetch forward 1 from cur; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 53: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 53: command fetch forward 1 from cur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 53: correctly got 1 tuples with 3 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 53: RESULT: 4 offset: -1; array: no
@@ -184,10 +214,14 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 53: RESULT: NaN offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 53: query: fetch from cur; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 53: query: fetch from cur; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 53: query: fetch forward 1 from cur; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 53: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 53: command fetch forward 1 from cur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 53: correctly got 1 tuples with 3 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 53: RESULT: 7 offset: -1; array: no
@@ -196,10 +230,14 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 53: RESULT: NaN offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 53: query: fetch from cur; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 53: query: fetch from cur; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 53: query: fetch forward 1 from cur; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 53: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 53: command fetch forward 1 from cur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 53: correctly got 1 tuples with 3 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 53: RESULT: 5 offset: -1; array: no
@@ -208,10 +246,14 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 53: RESULT: Infinity offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 53: query: fetch from cur; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 53: query: fetch from cur; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 53: query: fetch forward 1 from cur; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 53: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 53: command fetch forward 1 from cur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 53: correctly got 1 tuples with 3 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 53: RESULT: 8 offset: -1; array: no
@@ -220,10 +262,14 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 53: RESULT: Infinity offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 53: query: fetch from cur; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 53: query: fetch from cur; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 53: query: fetch forward 1 from cur; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 53: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 53: command fetch forward 1 from cur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 53: correctly got 1 tuples with 3 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 53: RESULT: 6 offset: -1; array: no
@@ -232,10 +278,14 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 53: RESULT: -Infinity offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 53: query: fetch from cur; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 53: query: fetch from cur; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 53: query: fetch forward 1 from cur; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 53: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 53: command fetch forward 1 from cur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 53: correctly got 1 tuples with 3 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 53: RESULT: 9 offset: -1; array: no
@@ -244,11 +294,13 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 53: RESULT: -Infinity offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 53: query: fetch from cur; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 53: query: fetch from cur; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 53: query: fetch forward 1 from cur; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 53: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_process_output on line 53: correctly got 0 tuples with 3 fields
+[NO_PID]: ecpg_cursor_execute on line 53: command fetch forward 1 from cur; returned 0 tuples
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: raising sqlcode 100 on line 53: no data found on line 53
 [NO_PID]: sqlca: code: 100, state: 02000
@@ -304,10 +356,14 @@
 [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]: ecpg_execute on line 79: query: fetch from cur1; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 79: query: fetch from cur1; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 79: query: fetch forward 1 from cur1; 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 forward 1 from cur1; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 79: correctly got 1 tuples with 3 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 79: RESULT: 4 offset: -1; array: no
@@ -316,10 +372,14 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 79: RESULT: NaN offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 79: query: fetch from cur1; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 79: query: fetch from cur1; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 79: query: fetch forward 1 from cur1; 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 forward 1 from cur1; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 79: correctly got 1 tuples with 3 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 79: RESULT: 5 offset: -1; array: no
@@ -328,10 +388,14 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 79: RESULT: NaN offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 79: query: fetch from cur1; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 79: query: fetch from cur1; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 79: query: fetch forward 1 from cur1; 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 forward 1 from cur1; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 79: correctly got 1 tuples with 3 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 79: RESULT: 6 offset: -1; array: no
@@ -340,11 +404,13 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 79: RESULT: NaN offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 79: query: fetch from cur1; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 79: query: fetch from cur1; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 79: query: fetch forward 1 from cur1; 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_process_output on line 79: correctly got 0 tuples with 3 fields
+[NO_PID]: ecpg_cursor_execute on line 79: command fetch forward 1 from cur1; returned 0 tuples
 [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
diff --git a/src/interfaces/ecpg/test/expected/preproc-autoprep.stderr b/src/interfaces/ecpg/test/expected/preproc-autoprep.stderr
index d2b0828..089c0a9 100644
--- a/src/interfaces/ecpg/test/expected/preproc-autoprep.stderr
+++ b/src/interfaces/ecpg/test/expected/preproc-autoprep.stderr
@@ -72,10 +72,14 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 37: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 39: query: fetch 1 in C; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 39: query: fetch 1 in C; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 39: query: fetch forward 1 from C; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 39: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 39: command fetch forward 1 from C; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 39: correctly got 1 tuples with 1 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 39: RESULT: 1 offset: -1; array: no
@@ -94,43 +98,61 @@
 [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]: ecpg_execute on line 55: query: fetch cur1; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 55: query: fetch cur1; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 55: query: fetch forward 1 from cur1; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 55: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 55: command fetch forward 1 from cur1; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 55: correctly got 1 tuples with 1 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 55: RESULT: 1 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 55: query: fetch cur1; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 55: query: fetch cur1; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 55: query: fetch forward 1 from cur1; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 55: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 55: command fetch forward 1 from cur1; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 55: correctly got 1 tuples with 1 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 55: RESULT: 2 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 55: query: fetch cur1; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 55: query: fetch cur1; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 55: query: fetch forward 1 from cur1; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 55: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 55: command fetch forward 1 from cur1; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 55: correctly got 1 tuples with 1 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 55: RESULT: 2 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 55: query: fetch cur1; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 55: query: fetch cur1; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 55: query: fetch forward 1 from cur1; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 55: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 55: command fetch forward 1 from cur1; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 55: correctly got 1 tuples with 1 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 55: RESULT:  offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 55: query: fetch cur1; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 55: query: fetch cur1; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 55: query: fetch forward 1 from cur1; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 55: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_process_output on line 55: correctly got 0 tuples with 1 fields
+[NO_PID]: ecpg_cursor_execute on line 55: command fetch forward 1 from cur1; returned 0 tuples
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: raising sqlcode 100 on line 55: no data found on line 55
 [NO_PID]: sqlca: code: 100, state: 02000
@@ -232,10 +254,14 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 37: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 39: query: fetch 1 in C; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 39: query: fetch 1 in C; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 39: query: fetch forward 1 from C; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 39: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 39: command fetch forward 1 from C; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 39: correctly got 1 tuples with 1 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 39: RESULT: 1 offset: -1; array: no
@@ -254,43 +280,61 @@
 [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]: ecpg_execute on line 55: query: fetch cur1; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 55: query: fetch cur1; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 55: query: fetch forward 1 from cur1; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 55: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 55: command fetch forward 1 from cur1; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 55: correctly got 1 tuples with 1 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 55: RESULT: 1 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 55: query: fetch cur1; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 55: query: fetch cur1; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 55: query: fetch forward 1 from cur1; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 55: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 55: command fetch forward 1 from cur1; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 55: correctly got 1 tuples with 1 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 55: RESULT: 2 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 55: query: fetch cur1; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 55: query: fetch cur1; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 55: query: fetch forward 1 from cur1; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 55: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 55: command fetch forward 1 from cur1; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 55: correctly got 1 tuples with 1 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 55: RESULT: 2 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 55: query: fetch cur1; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 55: query: fetch cur1; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 55: query: fetch forward 1 from cur1; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 55: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 55: command fetch forward 1 from cur1; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 55: correctly got 1 tuples with 1 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 55: RESULT:  offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 55: query: fetch cur1; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 55: query: fetch cur1; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 55: query: fetch forward 1 from cur1; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 55: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_process_output on line 55: correctly got 0 tuples with 1 fields
+[NO_PID]: ecpg_cursor_execute on line 55: command fetch forward 1 from cur1; returned 0 tuples
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: raising sqlcode 100 on line 55: no data found on line 55
 [NO_PID]: sqlca: code: 100, state: 02000
diff --git a/src/interfaces/ecpg/test/expected/preproc-cursor.stderr b/src/interfaces/ecpg/test/expected/preproc-cursor.stderr
index 6eb0ad8..377bd72 100644
--- a/src/interfaces/ecpg/test/expected/preproc-cursor.stderr
+++ b/src/interfaces/ecpg/test/expected/preproc-cursor.stderr
@@ -62,66 +62,92 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 67: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 70: query: fetch forward from mycur; with 0 parameter(s) on connection test1
+[NO_PID]: ECPGfetch on line 70: query: fetch forward from $0; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 70: query: fetch forward 1 from mycur; with 0 parameter(s) on connection test1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 70: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 70: command fetch forward 1 from mycur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 70: correctly got 1 tuples with 2 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 70: RESULT: 1 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 70: RESULT: a offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 74: query: fetch forward mycur; with 0 parameter(s) on connection test1
+[NO_PID]: ECPGfetch on line 74: query: fetch forward $0; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 74: query: fetch forward 1 from mycur; with 0 parameter(s) on connection test1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 74: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 74: command fetch forward 1 from mycur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 74: correctly got 1 tuples with 2 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 74: RESULT: 2 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 74: RESULT: b offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 78: query: fetch 1 from mycur; with 0 parameter(s) on connection test1
+[NO_PID]: ECPGfetch on line 78: query: fetch 1 from $0; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 78: query: fetch forward 1 from mycur; with 0 parameter(s) on connection test1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 78: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 78: command fetch forward 1 from mycur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 78: correctly got 1 tuples with 2 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 78: RESULT: 3 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 78: RESULT: c offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 83: query: fetch 1 from mycur; with 0 parameter(s) on connection test1
+[NO_PID]: ECPGfetch on line 83: query: fetch $0 from $0; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 83: query: fetch forward 1 from mycur; with 0 parameter(s) on connection test1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 83: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 83: command fetch forward 1 from mycur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 83: correctly got 1 tuples with 2 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 83: RESULT: 4 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 83: RESULT: d offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 87: query: move absolute 0 in mycur; with 0 parameter(s) on connection test1
+[NO_PID]: ECPGfetch on line 87: query: move absolute 0 in $0; fetch all: 0 amount: 0
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 87: stmt->results is NULL, ignoring
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 87: using PQexec
+[NO_PID]: ECPGfetch on line 90: query: fetch 1 $0; fetch all: 0 amount: 1
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_process_output on line 87: OK: MOVE 0
+[NO_PID]: ecpg_execute on line 90: query: move absolute 0 in mycur; with 0 parameter(s) on connection test1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 90: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 90: query: fetch 1 mycur; with 0 parameter(s) on connection test1
+[NO_PID]: ecpg_execute on line 90: query: fetch forward 1 from mycur; with 0 parameter(s) on connection test1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 90: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 90: command fetch forward 1 from mycur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 90: correctly got 1 tuples with 2 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 90: RESULT: 1 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 90: RESULT: a offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 95: query: fetch 1 mycur; with 0 parameter(s) on connection test1
+[NO_PID]: ECPGfetch on line 95: query: fetch $0 $0; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 95: query: fetch forward 1 from mycur; with 0 parameter(s) on connection test1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 95: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 95: command fetch forward 1 from mycur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 95: correctly got 1 tuples with 2 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 95: RESULT: 2 offset: -1; array: no
@@ -140,66 +166,92 @@
 [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]: ecpg_execute on line 111: query: fetch from mycur; with 0 parameter(s) on connection test1
+[NO_PID]: ECPGfetch on line 111: query: fetch from $0; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 111: query: fetch forward 1 from mycur; with 0 parameter(s) on connection test1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 111: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 111: command fetch forward 1 from mycur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 111: correctly got 1 tuples with 2 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 111: RESULT: 1 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 111: RESULT: a offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 115: query: fetch mycur; with 0 parameter(s) on connection test1
+[NO_PID]: ECPGfetch on line 115: query: fetch $0; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 115: query: fetch forward 1 from mycur; with 0 parameter(s) on connection test1
 [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_cursor_execute on line 115: command fetch forward 1 from mycur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 115: correctly got 1 tuples with 2 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 115: RESULT: 2 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 115: RESULT: b offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 119: query: fetch 1 from mycur; with 0 parameter(s) on connection test1
+[NO_PID]: ECPGfetch on line 119: query: fetch 1 from $0; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 119: query: fetch forward 1 from mycur; with 0 parameter(s) on connection test1
 [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_cursor_execute on line 119: command fetch forward 1 from mycur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 119: correctly got 1 tuples with 2 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 119: RESULT: 3 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 119: RESULT: c offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 124: query: fetch 1 from mycur; with 0 parameter(s) on connection test1
+[NO_PID]: ECPGfetch on line 124: query: fetch $0 from $0; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 124: query: fetch forward 1 from mycur; with 0 parameter(s) on connection test1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 124: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 124: command fetch forward 1 from mycur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 124: correctly got 1 tuples with 2 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 124: RESULT: 4 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 124: RESULT: d offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 128: query: move absolute 0 mycur; with 0 parameter(s) on connection test1
+[NO_PID]: ECPGfetch on line 128: query: move absolute 0 $0; fetch all: 0 amount: 0
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 128: stmt->results is NULL, ignoring
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 128: using PQexec
+[NO_PID]: ECPGfetch on line 131: query: fetch 1 $0; fetch all: 0 amount: 1
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_process_output on line 128: OK: MOVE 0
+[NO_PID]: ecpg_execute on line 131: query: move absolute 0 in mycur; with 0 parameter(s) on connection test1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 131: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 131: query: fetch 1 mycur; with 0 parameter(s) on connection test1
+[NO_PID]: ecpg_execute on line 131: query: fetch forward 1 from mycur; with 0 parameter(s) on connection test1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 131: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 131: command fetch forward 1 from mycur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 131: correctly got 1 tuples with 2 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 131: RESULT: 1 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 131: RESULT: a offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 136: query: fetch 1 mycur; with 0 parameter(s) on connection test1
+[NO_PID]: ECPGfetch on line 136: query: fetch $0 $0; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 136: query: fetch forward 1 from mycur; with 0 parameter(s) on connection test1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 136: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 136: command fetch forward 1 from mycur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 136: correctly got 1 tuples with 2 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 136: RESULT: 2 offset: -1; array: no
@@ -228,66 +280,92 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 154: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 157: query: fetch mycur; with 0 parameter(s) on connection test2
+[NO_PID]: ECPGfetch on line 157: query: fetch $0; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 157: query: fetch forward 1 from mycur; with 0 parameter(s) on connection test2
 [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_cursor_execute on line 157: command fetch forward 1 from mycur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 157: correctly got 1 tuples with 2 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 157: RESULT: 1 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 157: RESULT: e offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 161: query: fetch from mycur; with 0 parameter(s) on connection test1
+[NO_PID]: ECPGfetch on line 161: query: fetch from $0; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 161: query: fetch forward 1 from mycur; with 0 parameter(s) on connection test1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 161: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 161: command fetch forward 1 from mycur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 161: correctly got 1 tuples with 2 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 161: RESULT: 1 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 161: RESULT: a offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 165: query: fetch 1 from mycur; with 0 parameter(s) on connection test1
+[NO_PID]: ECPGfetch on line 165: query: fetch 1 from $0; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 165: query: fetch forward 1 from mycur; with 0 parameter(s) on connection test1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 165: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 165: command fetch forward 1 from mycur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 165: correctly got 1 tuples with 2 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 165: RESULT: 2 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 165: RESULT: b offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 170: query: fetch 1 from mycur; with 0 parameter(s) on connection test1
+[NO_PID]: ECPGfetch on line 170: query: fetch $0 from $0; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 170: query: fetch forward 1 from mycur; with 0 parameter(s) on connection test1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 170: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 170: command fetch forward 1 from mycur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 170: correctly got 1 tuples with 2 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 170: RESULT: 3 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 170: RESULT: c offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 174: query: move absolute 0 mycur; with 0 parameter(s) on connection test1
+[NO_PID]: ECPGfetch on line 174: query: move absolute 0 $0; fetch all: 0 amount: 0
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 174: stmt->results is NULL, ignoring
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 174: using PQexec
+[NO_PID]: ECPGfetch on line 177: query: fetch 1 $0; fetch all: 0 amount: 1
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_process_output on line 174: OK: MOVE 0
+[NO_PID]: ecpg_execute on line 177: query: move absolute 0 in mycur; with 0 parameter(s) on connection test1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 177: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 177: query: fetch 1 mycur; with 0 parameter(s) on connection test1
+[NO_PID]: ecpg_execute on line 177: query: fetch forward 1 from mycur; with 0 parameter(s) on connection test1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 177: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 177: command fetch forward 1 from mycur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 177: correctly got 1 tuples with 2 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 177: RESULT: 1 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 177: RESULT: a offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 182: query: fetch 1 mycur; with 0 parameter(s) on connection test1
+[NO_PID]: ECPGfetch on line 182: query: fetch $0 $0; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 182: query: fetch forward 1 from mycur; with 0 parameter(s) on connection test1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 182: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 182: command fetch forward 1 from mycur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 182: correctly got 1 tuples with 2 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 182: RESULT: 2 offset: -1; array: no
@@ -318,66 +396,92 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 206: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 209: query: fetch from mycur; with 0 parameter(s) on connection test1
+[NO_PID]: ECPGfetch on line 209: query: fetch from $0; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 209: query: fetch forward 1 from mycur; with 0 parameter(s) on connection test1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 209: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 209: command fetch forward 1 from mycur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 209: correctly got 1 tuples with 2 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 209: RESULT: 1 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 209: RESULT: a offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 213: query: fetch mycur; with 0 parameter(s) on connection test1
+[NO_PID]: ECPGfetch on line 213: query: fetch $0; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 213: query: fetch forward 1 from mycur; with 0 parameter(s) on connection test1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 213: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 213: command fetch forward 1 from mycur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 213: correctly got 1 tuples with 2 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 213: RESULT: 2 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 213: RESULT: b offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 217: query: fetch 1 from mycur; with 0 parameter(s) on connection test1
+[NO_PID]: ECPGfetch on line 217: query: fetch 1 from $0; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 217: query: fetch forward 1 from mycur; with 0 parameter(s) on connection test1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 217: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 217: command fetch forward 1 from mycur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 217: correctly got 1 tuples with 2 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 217: RESULT: 3 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 217: RESULT: c offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 222: query: fetch 1 from mycur; with 0 parameter(s) on connection test1
+[NO_PID]: ECPGfetch on line 222: query: fetch $0 from $0; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 222: query: fetch forward 1 from mycur; with 0 parameter(s) on connection test1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 222: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 222: command fetch forward 1 from mycur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 222: correctly got 1 tuples with 2 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 222: RESULT: 4 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 222: RESULT: d offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 226: query: move absolute 0 mycur; with 0 parameter(s) on connection test1
+[NO_PID]: ECPGfetch on line 226: query: move absolute 0 $0; fetch all: 0 amount: 0
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 226: stmt->results is NULL, ignoring
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 226: using PQexec
+[NO_PID]: ECPGfetch on line 229: query: fetch 1 $0; fetch all: 0 amount: 1
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_process_output on line 226: OK: MOVE 0
+[NO_PID]: ecpg_execute on line 229: query: move absolute 0 in mycur; with 0 parameter(s) on connection test1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 229: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 229: query: fetch 1 mycur; with 0 parameter(s) on connection test1
+[NO_PID]: ecpg_execute on line 229: query: fetch forward 1 from mycur; with 0 parameter(s) on connection test1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 229: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 229: command fetch forward 1 from mycur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 229: correctly got 1 tuples with 2 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 229: RESULT: 1 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 229: RESULT: a offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 234: query: fetch 1 mycur; with 0 parameter(s) on connection test1
+[NO_PID]: ECPGfetch on line 234: query: fetch $0 $0; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 234: query: fetch forward 1 from mycur; with 0 parameter(s) on connection test1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 234: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 234: command fetch forward 1 from mycur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 234: correctly got 1 tuples with 2 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 234: RESULT: 2 offset: -1; array: no
diff --git a/src/interfaces/ecpg/test/expected/preproc-outofscope.stderr b/src/interfaces/ecpg/test/expected/preproc-outofscope.stderr
index 76cedd9..8e8049a 100644
--- a/src/interfaces/ecpg/test/expected/preproc-outofscope.stderr
+++ b/src/interfaces/ecpg/test/expected/preproc-outofscope.stderr
@@ -40,10 +40,14 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 40: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 49: query: fetch mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 49: query: fetch mycur; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 49: query: fetch forward 1 from mycur; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 49: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 49: command fetch forward 1 from mycur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 49: correctly got 1 tuples with 5 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 49: RESULT: 1 offset: -1; array: no
@@ -56,10 +60,14 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 49: RESULT: a          offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 49: query: fetch mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 49: query: fetch mycur; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 49: query: fetch forward 1 from mycur; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 49: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 49: command fetch forward 1 from mycur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 49: correctly got 1 tuples with 5 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 49: RESULT: 2 offset: -1; array: no
@@ -72,10 +80,14 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 49: RESULT:  offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 49: query: fetch mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 49: query: fetch mycur; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 49: query: fetch forward 1 from mycur; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 49: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 49: command fetch forward 1 from mycur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 49: correctly got 1 tuples with 5 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 49: RESULT: 3 offset: -1; array: no
@@ -88,11 +100,13 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 49: RESULT: b          offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 49: query: fetch mycur; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 49: query: fetch mycur; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 49: query: fetch forward 1 from mycur; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 49: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_process_output on line 49: correctly got 0 tuples with 5 fields
+[NO_PID]: ecpg_cursor_execute on line 49: command fetch forward 1 from mycur; returned 0 tuples
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: raising sqlcode 100 on line 49: no data found on line 49
 [NO_PID]: sqlca: code: 100, state: 02000
diff --git a/src/interfaces/ecpg/test/expected/preproc-variable.stderr b/src/interfaces/ecpg/test/expected/preproc-variable.stderr
index 0757d22..18ce4a0 100644
--- a/src/interfaces/ecpg/test/expected/preproc-variable.stderr
+++ b/src/interfaces/ecpg/test/expected/preproc-variable.stderr
@@ -52,10 +52,14 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 63: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 72: query: fetch cur; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 72: query: fetch cur; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 72: query: fetch forward 1 from cur; 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_cursor_execute on line 72: command fetch forward 1 from cur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 72: correctly got 1 tuples with 5 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 72: RESULT: Mum      offset: -1; array: no
@@ -70,10 +74,14 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 72: RESULT: 3 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 72: query: fetch cur; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 72: query: fetch cur; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 72: query: fetch forward 1 from cur; 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_cursor_execute on line 72: command fetch forward 1 from cur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 72: correctly got 1 tuples with 5 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 72: RESULT: Dad      offset: -1; array: no
@@ -88,10 +96,14 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 72: RESULT: 3 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 72: query: fetch cur; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 72: query: fetch cur; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 72: query: fetch forward 1 from cur; 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_cursor_execute on line 72: command fetch forward 1 from cur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 72: correctly got 1 tuples with 5 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 72: RESULT: Child 1  offset: -1; array: no
@@ -106,10 +118,14 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 72: RESULT:  offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 72: query: fetch cur; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 72: query: fetch cur; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 72: query: fetch forward 1 from cur; 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_cursor_execute on line 72: command fetch forward 1 from cur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 72: correctly got 1 tuples with 5 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 72: RESULT: Child 2  offset: -1; array: no
@@ -124,10 +140,14 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 72: RESULT:  offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 72: query: fetch cur; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 72: query: fetch cur; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 72: query: fetch forward 1 from cur; 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_cursor_execute on line 72: command fetch forward 1 from cur; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 72: correctly got 1 tuples with 5 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 72: RESULT: Child 3  offset: -1; array: no
@@ -142,11 +162,13 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 72: RESULT:  offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 72: query: fetch cur; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 72: query: fetch cur; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 72: query: fetch forward 1 from cur; 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: correctly got 0 tuples with 5 fields
+[NO_PID]: ecpg_cursor_execute on line 72: command fetch forward 1 from cur; returned 0 tuples
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: raising sqlcode 100 on line 72: no data found on line 72
 [NO_PID]: sqlca: code: 100, state: 02000
diff --git a/src/interfaces/ecpg/test/expected/sql-binary.stderr b/src/interfaces/ecpg/test/expected/sql-binary.stderr
index 03495b2..e0e4960 100644
--- a/src/interfaces/ecpg/test/expected/sql-binary.stderr
+++ b/src/interfaces/ecpg/test/expected/sql-binary.stderr
@@ -30,10 +30,14 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 59: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 60: query: fetch C; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 60: query: fetch C; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 60: query: fetch forward 1 from C; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 60: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 60: command fetch forward 1 from C; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 60: correctly got 1 tuples with 3 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 60: RESULT: first user           offset: -1; array: no
@@ -56,10 +60,14 @@
 [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]: ecpg_execute on line 74: query: fetch B; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 74: query: fetch B; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 74: query: fetch forward 1 from B; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 74: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 74: command fetch forward 1 from B; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 74: correctly got 1 tuples with 3 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 74: RESULT: BINARY offset: -1; array: no
@@ -82,10 +90,14 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 90: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 91: query: fetch A; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 91: query: fetch A; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 91: query: fetch forward 1 from A; 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 forward 1 from A; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 91: correctly got 1 tuples with 1 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_store_result on line 91: allocating memory for 1 tuples
diff --git a/src/interfaces/ecpg/test/expected/sql-cursorsubxact.stderr b/src/interfaces/ecpg/test/expected/sql-cursorsubxact.stderr
index b48379d..87fb484 100644
--- a/src/interfaces/ecpg/test/expected/sql-cursorsubxact.stderr
+++ b/src/interfaces/ecpg/test/expected/sql-cursorsubxact.stderr
@@ -109,10 +109,14 @@ SQL error: no such savepoint on line 218
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 239: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 245: query: fetch from "MyCur"; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 245: query: fetch from $0; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 245: query: fetch forward 1 from "MyCur"; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 245: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 245: command fetch forward 1 from "MyCur"; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 245: correctly got 1 tuples with 2 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 245: RESULT: 1 offset: -1; array: no
@@ -137,10 +141,14 @@ SQL error: current transaction is aborted, commands ignored until end of transac
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGtrans on line 301: action "savepoint a"; connection "regress1"
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 307: query: fetch from "MyCur"; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 307: query: fetch from $0; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 307: query: fetch forward 1 from "MyCur"; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 307: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 307: command fetch forward 1 from "MyCur"; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 307: correctly got 1 tuples with 2 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 307: RESULT: 1 offset: -1; array: no
@@ -149,10 +157,14 @@ SQL error: current transaction is aborted, commands ignored until end of transac
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGtrans on line 319: action "rollback to a"; connection "regress1"
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 325: query: fetch from "MyCur"; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 325: query: fetch from $0; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 325: query: fetch forward 1 from "MyCur"; 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 forward 1 from "MyCur"; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 325: correctly got 1 tuples with 2 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 325: RESULT: 2 offset: -1; array: no
diff --git a/src/interfaces/ecpg/test/expected/sql-desc.stderr b/src/interfaces/ecpg/test/expected/sql-desc.stderr
index a079365..ff6bb5b 100644
--- a/src/interfaces/ecpg/test/expected/sql-desc.stderr
+++ b/src/interfaces/ecpg/test/expected/sql-desc.stderr
@@ -74,10 +74,14 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 58: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 60: query: fetch next from c1; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 60: query: fetch next from c1; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 60: query: fetch forward 1 from c1; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 60: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 60: command fetch forward 1 from c1; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 60: correctly got 1 tuples with 2 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 60: RESULT: 1 offset: -1; array: no
@@ -98,10 +102,14 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 70: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 72: query: fetch next from c2; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 72: query: fetch next from c2; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 72: query: fetch forward 1 from c2; 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_cursor_execute on line 72: command fetch forward 1 from c2; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 72: correctly got 1 tuples with 2 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 72: RESULT: 2 offset: -1; array: no
diff --git a/src/interfaces/ecpg/test/expected/sql-dyntest.stderr b/src/interfaces/ecpg/test/expected/sql-dyntest.stderr
index dd15cad..b5d0d33 100644
--- a/src/interfaces/ecpg/test/expected/sql-dyntest.stderr
+++ b/src/interfaces/ecpg/test/expected/sql-dyntest.stderr
@@ -34,10 +34,14 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 60: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 64: query: fetch in MYCURS; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 64: query: fetch in MYCURS; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 64: query: fetch forward 1 from MYCURS; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 64: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 64: command fetch forward 1 from MYCURS; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 64: correctly got 1 tuples with 7 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 64: putting result (1 tuples) into descriptor MYDESC
@@ -204,10 +208,14 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 176: RESULT: 14.07.1987 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 64: query: fetch in MYCURS; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 64: query: fetch in MYCURS; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 64: query: fetch forward 1 from MYCURS; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 64: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 64: command fetch forward 1 from MYCURS; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 64: correctly got 1 tuples with 7 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 64: putting result (1 tuples) into descriptor MYDESC
@@ -374,11 +382,13 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 176: RESULT: 05.11.1999 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 64: query: fetch in MYCURS; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 64: query: fetch in MYCURS; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 64: query: fetch forward 1 from MYCURS; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 64: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_process_output on line 64: correctly got 0 tuples with 7 fields
+[NO_PID]: ecpg_cursor_execute on line 64: command fetch forward 1 from MYCURS; returned 0 tuples
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: raising sqlcode 100 on line 64: no data found on line 64
 [NO_PID]: sqlca: code: 100, state: 02000
diff --git a/src/interfaces/ecpg/test/expected/sql-execute.stderr b/src/interfaces/ecpg/test/expected/sql-execute.stderr
index 6adb523..80a61ef 100644
--- a/src/interfaces/ecpg/test/expected/sql-execute.stderr
+++ b/src/interfaces/ecpg/test/expected/sql-execute.stderr
@@ -48,10 +48,16 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 52: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 53: query: fetch 8 in CUR; with 0 parameter(s) on connection main
+[NO_PID]: ECPGfetch on line 53: query: fetch 8 in CUR; fetch all: 0 amount: 8
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 53: permanently raising readahead window size to 8
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 53: query: fetch forward 8 from CUR; with 0 parameter(s) on connection main
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 53: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 53: command fetch forward 8 from CUR; returned 8 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 53: correctly got 8 tuples with 3 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 53: RESULT: db: 'r1' offset: -1; array: no
@@ -120,10 +126,14 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 74: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 75: query: fetch in CUR2; with 0 parameter(s) on connection main
+[NO_PID]: ECPGfetch on line 75: query: fetch in CUR2; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 75: query: fetch forward 1 from CUR2; with 0 parameter(s) on connection main
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 75: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 75: command fetch forward 1 from CUR2; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 75: correctly got 1 tuples with 3 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 75: RESULT: db: 'r1' offset: -1; array: no
diff --git a/src/interfaces/ecpg/test/expected/sql-fetch.stderr b/src/interfaces/ecpg/test/expected/sql-fetch.stderr
index a7c3a77..6a2004c 100644
--- a/src/interfaces/ecpg/test/expected/sql-fetch.stderr
+++ b/src/interfaces/ecpg/test/expected/sql-fetch.stderr
@@ -38,64 +38,88 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 28: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 32: query: fetch 1 in C; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 32: query: fetch 1 in C; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 32: query: fetch forward 1 from C; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 32: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 32: command fetch forward 1 from C; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 32: correctly got 1 tuples with 2 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 32: RESULT: 1 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 32: RESULT: text1 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 32: query: fetch 1 in C; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 32: query: fetch 1 in C; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 32: query: fetch forward 1 from C; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 32: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 32: command fetch forward 1 from C; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 32: correctly got 1 tuples with 2 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 32: RESULT: 2 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 32: RESULT: text2 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 32: query: fetch 1 in C; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 32: query: fetch 1 in C; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 32: query: fetch forward 1 from C; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 32: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 32: command fetch forward 1 from C; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 32: correctly got 1 tuples with 2 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 32: RESULT: 3 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 32: RESULT: text3 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 32: query: fetch 1 in C; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 32: query: fetch 1 in C; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 32: query: fetch forward 1 from C; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 32: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 32: command fetch forward 1 from C; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 32: correctly got 1 tuples with 2 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 32: RESULT: 4 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 32: RESULT: text4 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 32: query: fetch 1 in C; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 32: query: fetch 1 in C; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 32: query: fetch forward 1 from C; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 32: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_process_output on line 32: correctly got 0 tuples with 2 fields
+[NO_PID]: ecpg_cursor_execute on line 32: command fetch forward 1 from C; returned 0 tuples
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: raising sqlcode 100 on line 32: no data found on line 32
 [NO_PID]: sqlca: code: 100, state: 02000
-[NO_PID]: ecpg_execute on line 37: query: move backward 2 in C; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 37: query: move backward 2 in C; fetch all: 0 amount: -2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 37: stmt->results is NULL, ignoring
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 37: using PQexec
+[NO_PID]: ECPGfetch on line 39: query: fetch $0 in C; fetch all: 0 amount: 1
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_process_output on line 37: OK: MOVE 2
+[NO_PID]: ecpg_execute on line 39: query: move absolute 3 in C; with 0 parameter(s) on connection regress1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 39: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 39: query: fetch 1 in C; with 0 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 39: query: fetch forward 1 from C; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 39: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 39: command fetch forward 1 from C; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 39: correctly got 1 tuples with 2 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 39: RESULT: 4 offset: -1; array: no
@@ -116,21 +140,27 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 46: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 50: query: fetch 1 in D; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 50: query: fetch 1 in D; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 50: query: fetch forward 1 from D; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 50: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 50: command fetch forward 1 from D; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 50: correctly got 1 tuples with 2 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 50: RESULT: 1 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 50: RESULT: text1 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 50: query: fetch 1 in D; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 50: query: fetch 1 in D; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 50: query: fetch forward 1 from D; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 50: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_process_output on line 50: correctly got 0 tuples with 2 fields
+[NO_PID]: ecpg_cursor_execute on line 50: command fetch forward 1 from D; returned 0 tuples
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: raising sqlcode 100 on line 50: no data found on line 50
 [NO_PID]: sqlca: code: 100, state: 02000
diff --git a/src/interfaces/ecpg/test/expected/sql-oldexec.stderr b/src/interfaces/ecpg/test/expected/sql-oldexec.stderr
index fda8531..0459a31 100644
--- a/src/interfaces/ecpg/test/expected/sql-oldexec.stderr
+++ b/src/interfaces/ecpg/test/expected/sql-oldexec.stderr
@@ -48,10 +48,16 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 52: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 53: query: fetch 8 in CUR; with 0 parameter(s) on connection main
+[NO_PID]: ECPGfetch on line 53: query: fetch 8 in CUR; fetch all: 0 amount: 8
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGfetch on line 53: permanently raising readahead window size to 8
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 53: query: fetch forward 8 from CUR; with 0 parameter(s) on connection main
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 53: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 53: command fetch forward 8 from CUR; returned 8 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 53: correctly got 8 tuples with 3 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 53: RESULT: db: 'r1' offset: -1; array: no
@@ -120,10 +126,14 @@
 [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]: ecpg_execute on line 74: query: fetch in CUR3; with 0 parameter(s) on connection main
+[NO_PID]: ECPGfetch on line 74: query: fetch in CUR3; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 74: query: fetch forward 1 from CUR3; with 0 parameter(s) on connection main
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 74: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 74: command fetch forward 1 from CUR3; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 74: correctly got 1 tuples with 3 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 74: RESULT: db: 'r1' offset: -1; array: no
diff --git a/src/interfaces/ecpg/test/expected/sql-quote.stderr b/src/interfaces/ecpg/test/expected/sql-quote.stderr
index e867377..2e2a744 100644
--- a/src/interfaces/ecpg/test/expected/sql-quote.stderr
+++ b/src/interfaces/ecpg/test/expected/sql-quote.stderr
@@ -75,51 +75,69 @@ SQL error: nonstandard use of \\ in a string literal
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 45: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 51: query: fetch C; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 51: query: fetch C; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 51: query: fetch forward 1 from C; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 51: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 51: command fetch forward 1 from C; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 51: correctly got 1 tuples with 2 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 51: RESULT: 1 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 51: RESULT: a\\b offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 51: query: fetch C; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 51: query: fetch C; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 51: query: fetch forward 1 from C; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 51: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 51: command fetch forward 1 from C; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 51: correctly got 1 tuples with 2 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 51: RESULT: 1 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 51: RESULT: a\\b offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 51: query: fetch C; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 51: query: fetch C; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 51: query: fetch forward 1 from C; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 51: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 51: command fetch forward 1 from C; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 51: correctly got 1 tuples with 2 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 51: RESULT: 2 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 51: RESULT: a\\\\b offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 51: query: fetch C; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 51: query: fetch C; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 51: query: fetch forward 1 from C; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 51: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 51: command fetch forward 1 from C; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 51: correctly got 1 tuples with 2 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 51: RESULT: 2 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 51: RESULT: a\\b offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 51: query: fetch C; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 51: query: fetch C; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 51: query: fetch forward 1 from C; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 51: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_process_output on line 51: correctly got 0 tuples with 2 fields
+[NO_PID]: ecpg_cursor_execute on line 51: command fetch forward 1 from C; returned 0 tuples
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: raising sqlcode 100 on line 51: no data found on line 51
 [NO_PID]: sqlca: code: 100, state: 02000
diff --git a/src/interfaces/ecpg/test/expected/sql-sqlda.stderr b/src/interfaces/ecpg/test/expected/sql-sqlda.stderr
index 6ed6605..daf7521 100644
--- a/src/interfaces/ecpg/test/expected/sql-sqlda.stderr
+++ b/src/interfaces/ecpg/test/expected/sql-sqlda.stderr
@@ -30,10 +30,14 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 103: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 111: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 111: query: fetch 1 from mycur1; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 111: query: fetch forward 1 from mycur1; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 111: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 111: command fetch forward 1 from mycur1; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 111: correctly got 1 tuples with 5 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_build_native_sqlda on line 111 sqld = 5
@@ -60,10 +64,14 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 111: putting result (1 tuple 5 fields) into sqlda descriptor
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 111: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 111: query: fetch 1 from mycur1; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 111: query: fetch forward 1 from mycur1; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 111: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 111: command fetch forward 1 from mycur1; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 111: correctly got 1 tuples with 5 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_build_native_sqlda on line 111 sqld = 5
@@ -84,10 +92,14 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 111: putting result (1 tuple 5 fields) into sqlda descriptor
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 111: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 111: query: fetch 1 from mycur1; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 111: query: fetch forward 1 from mycur1; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 111: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 111: command fetch forward 1 from mycur1; returned 1 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 111: correctly got 1 tuples with 5 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_build_native_sqlda on line 111 sqld = 5
@@ -114,11 +126,13 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 111: putting result (1 tuple 5 fields) into sqlda descriptor
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 111: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 111: query: fetch 1 from mycur1; fetch all: 0 amount: 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 111: query: fetch forward 1 from mycur1; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 111: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_process_output on line 111: correctly got 0 tuples with 5 fields
+[NO_PID]: ecpg_cursor_execute on line 111: command fetch forward 1 from mycur1; returned 0 tuples
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: raising sqlcode 100 on line 111: no data found on line 111
 [NO_PID]: sqlca: code: 100, state: 02000
@@ -138,10 +152,14 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 138: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 141: query: fetch all from mycur2; with 0 parameter(s) on connection regress1
+[NO_PID]: ECPGfetch on line 141: query: fetch all from mycur2; fetch all: 1 amount: 0
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 141: query: fetch forward 1000 from mycur2; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 141: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 141: command fetch forward 1000 from mycur2; returned 3 tuples
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 141: correctly got 3 tuples with 5 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_build_native_sqlda on line 141 sqld = 5
@@ -210,6 +228,8 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 141: putting result (1 tuple 5 fields) into sqlda descriptor
 [NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_cursor_execute on line 141: tuple already in cache
+[NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 157: query: close mycur2; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 157: using PQexec
