ECPG: WHENEVER statement with DO CONTINUE action

Started by vinayakover 8 years ago19 messages
#1vinayak
Pokale_Vinayak_q3@lab.ntt.co.jp
1 attachment(s)

Hello,

To develop the ECPG application more efficiently and improve portability,
I would like to suggest one minor improvement "WHENEVER condition *DO
CONTINUE*" support in ECPG.
Oracle Pro*C supports WHENEVER statement with DO CONTINUE action.[1]https://docs.oracle.com/cd/B28359_01/appdev.111/b28427/pc_09err.htm#i12340

EXEC SQL WHENEVER SQLERROR CONTINUE;
is not same as
EXEC SQL WHENEVER SQLERROR DO CONTINUE;

The CONTINUE action instructs the client application to proceed to the
next statement whereas DO CONTINUE action instructs the client
application to emit a C continue statement and the flow of control
return to the beginning of the enclosing loop.

I have tried to implement it. Please check the attached patch.

Please give me feedback.

[1]: https://docs.oracle.com/cd/B28359_01/appdev.111/b28427/pc_09err.htm#i12340

Regards,

Vinayak Pokale
NTT Open Source Software Center

Attachments:

whenever-do-continue.patchbinary/octet-stream; name=whenever-do-continue.patchDownload
diff --git a/doc/src/sgml/ecpg.sgml b/doc/src/sgml/ecpg.sgml
index dead4c3..a32ba4f 100644
--- a/doc/src/sgml/ecpg.sgml
+++ b/doc/src/sgml/ecpg.sgml
@@ -4764,6 +4764,17 @@ EXEC SQL WHENEVER <replaceable>condition</replaceable> <replaceable>action</repl
      </varlistentry>
 
      <varlistentry>
+      <term><literal>DO CONTINUE</literal></term>
+      <listitem>
+       <para>
+        Execute the C statement <literal>continue</literal>.  This should
+        only be used in loops statements.  if executed, will cause the flow 
+        of control to return to the top of the loop.
+       </para>
+      </listitem>
+     </varlistentry>
+
+     <varlistentry>
       <term><literal>CALL <replaceable>name</replaceable> (<replaceable>args</replaceable>)</literal></term>
       <term><literal>DO <replaceable>name</replaceable> (<replaceable>args</replaceable>)</literal></term>
       <listitem>
@@ -7800,6 +7811,7 @@ WHENEVER { NOT FOUND | SQLERROR | SQLWARNING } <replaceable class="PARAMETER">ac
 <programlisting>
 EXEC SQL WHENEVER NOT FOUND CONTINUE;
 EXEC SQL WHENEVER NOT FOUND DO BREAK;
+EXEC SQL WHENEVER NOT FOUND DO CONTINUE;
 EXEC SQL WHENEVER SQLWARNING SQLPRINT;
 EXEC SQL WHENEVER SQLWARNING DO warn();
 EXEC SQL WHENEVER SQLERROR sqlprint;
diff --git a/src/interfaces/ecpg/preproc/ecpg.trailer b/src/interfaces/ecpg/preproc/ecpg.trailer
index 1c10879..b42bca4 100644
--- a/src/interfaces/ecpg/preproc/ecpg.trailer
+++ b/src/interfaces/ecpg/preproc/ecpg.trailer
@@ -1454,6 +1454,12 @@ action : CONTINUE_P
 			$<action>$.command = NULL;
 			$<action>$.str = mm_strdup("break");
 		}
+		| DO CONTINUE_P
+		{
+			$<action>$.code = W_CONTINUE;
+			$<action>$.command = NULL;
+			$<action>$.str = mm_strdup("continue");
+		}
 		| SQL_CALL name '(' c_args ')'
 		{
 			$<action>$.code = W_DO;
diff --git a/src/interfaces/ecpg/preproc/output.c b/src/interfaces/ecpg/preproc/output.c
index 59d5d30..14d7066 100644
--- a/src/interfaces/ecpg/preproc/output.c
+++ b/src/interfaces/ecpg/preproc/output.c
@@ -51,6 +51,9 @@ print_action(struct when * w)
 		case W_BREAK:
 			fprintf(base_yyout, "break;");
 			break;
+		case W_CONTINUE:
+			fprintf(base_yyout, "continue;");
+			break;
 		default:
 			fprintf(base_yyout, "{/* %d not implemented yet */}", w->code);
 			break;
#2Michael Meskes
meskes@postgresql.org
In reply to: vinayak (#1)
Re: ECPG: WHENEVER statement with DO CONTINUE action

Hi,

To develop the ECPG application more efficiently and improve
portability,
I would like to suggest one minor improvement "WHENEVER condition DO
CONTINUE" support in ECPG.
Oracle Pro*C supports WHENEVER statement with DO CONTINUE action.[1]

EXEC SQL WHENEVER SQLERROR CONTINUE;
is not same as
EXEC SQL WHENEVER SQLERROR DO CONTINUE;

The CONTINUE action instructs the client application to proceed to
the next statement whereas DO CONTINUE action instructs the client
application to emit a C continue statement and the flow of control
return to the beginning of the enclosing loop.

This did actual escape me. Thanks for bringing it to our attention and
fixing this missing functionality.

I have tried to implement it. Please check the attached patch.
Please give me feedback.
...

Could you please add a "DO CONTINUE" case to one of the test cases? Or
add a new one? We would need a test case IMO.

Thanks

Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Meskes at (Debian|Postgresql) dot Org
Jabber: michael at xmpp dot meskes dot org
VfL Borussia! Força Barça! SF 49ers! Use Debian GNU/Linux, PostgreSQL

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3Vinayak Pokale
vinpokale@gmail.com
In reply to: Michael Meskes (#2)
Re: ECPG: WHENEVER statement with DO CONTINUE action

Thank you for your reply

On Jun 9, 2017 5:39 PM, "Michael Meskes" <meskes@postgresql.org> wrote:

Hi,

To develop the ECPG application more efficiently and improve
portability,
I would like to suggest one minor improvement "WHENEVER condition DO
CONTINUE" support in ECPG.
Oracle Pro*C supports WHENEVER statement with DO CONTINUE action.[1]

EXEC SQL WHENEVER SQLERROR CONTINUE;
is not same as
EXEC SQL WHENEVER SQLERROR DO CONTINUE;

The CONTINUE action instructs the client application to proceed to
the next statement whereas DO CONTINUE action instructs the client
application to emit a C continue statement and the flow of control
return to the beginning of the enclosing loop.

This did actual escape me. Thanks for bringing it to our attention and
fixing this missing functionality.

I have tried to implement it. Please check the attached patch.
Please give me feedback.
...

Could you please add a "DO CONTINUE" case to one of the test cases? Or
add a new one? We would need a test case IMO.

Yes I will add test case and send updated patch.

Regards,
Vinayak Pokale

#4vinayak
Pokale_Vinayak_q3@lab.ntt.co.jp
In reply to: Vinayak Pokale (#3)
1 attachment(s)
Re: ECPG: WHENEVER statement with DO CONTINUE action

Hi,

On 2017/06/10 12:23, Vinayak Pokale wrote:

Thank you for your reply

On Jun 9, 2017 5:39 PM, "Michael Meskes" <meskes@postgresql.org
<mailto:meskes@postgresql.org>> wrote:

Could you please add a "DO CONTINUE" case to one of the test cases? Or
add a new one? We would need a test case IMO.

Yes I will add test case and send updated patch.

I have added new test case for DO CONTINUE.
Please check the attached patch.

Regards,
Vinayak Pokale
NTT Open Source Software Center

Attachments:

WHENEVER-statement-DO-CONTINUE-support.patchbinary/octet-stream; name=WHENEVER-statement-DO-CONTINUE-support.patchDownload
From 8e10afb89d9f7de3e0e8f9e0cf206b44438284a4 Mon Sep 17 00:00:00 2001
From: Vinayak Pokale <vinpokale@gmail.com>
Date: Mon, 12 Jun 2017 13:03:21 +0900
Subject: [PATCH] WHENEVER statement DO CONTINUE support

---
 doc/src/sgml/ecpg.sgml                             |   12 ++
 src/interfaces/ecpg/preproc/ecpg.trailer           |    6 +
 src/interfaces/ecpg/preproc/output.c               |    3 +
 src/interfaces/ecpg/test/ecpg_schedule             |    1 +
 .../test/expected/preproc-whenever_do_continue.c   |  155 ++++++++++++++++++++
 .../expected/preproc-whenever_do_continue.stderr   |  116 +++++++++++++++
 .../expected/preproc-whenever_do_continue.stdout   |    2 +
 src/interfaces/ecpg/test/preproc/Makefile          |    1 +
 .../ecpg/test/preproc/whenever_do_continue.pgc     |   57 +++++++
 9 files changed, 353 insertions(+), 0 deletions(-)
 create mode 100644 src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.c
 create mode 100644 src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.stderr
 create mode 100644 src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.stdout
 create mode 100644 src/interfaces/ecpg/test/preproc/whenever_do_continue.pgc

diff --git a/doc/src/sgml/ecpg.sgml b/doc/src/sgml/ecpg.sgml
index f13a0e9..3cb4001 100644
--- a/doc/src/sgml/ecpg.sgml
+++ b/doc/src/sgml/ecpg.sgml
@@ -4763,6 +4763,17 @@ EXEC SQL WHENEVER <replaceable>condition</replaceable> <replaceable>action</repl
      </varlistentry>
 
      <varlistentry>
+      <term><literal>DO CONTINUE</literal></term>
+      <listitem>
+       <para>
+        Execute the C statement <literal>continue</literal>.  This should
+        only be used in loops statements.  if executed, will cause the flow 
+        of control to return to the top of the loop.
+       </para>
+      </listitem>
+     </varlistentry>
+
+     <varlistentry>
       <term><literal>CALL <replaceable>name</replaceable> (<replaceable>args</replaceable>)</literal></term>
       <term><literal>DO <replaceable>name</replaceable> (<replaceable>args</replaceable>)</literal></term>
       <listitem>
@@ -7799,6 +7810,7 @@ WHENEVER { NOT FOUND | SQLERROR | SQLWARNING } <replaceable class="PARAMETER">ac
 <programlisting>
 EXEC SQL WHENEVER NOT FOUND CONTINUE;
 EXEC SQL WHENEVER NOT FOUND DO BREAK;
+EXEC SQL WHENEVER NOT FOUND DO CONTINUE;
 EXEC SQL WHENEVER SQLWARNING SQLPRINT;
 EXEC SQL WHENEVER SQLWARNING DO warn();
 EXEC SQL WHENEVER SQLERROR sqlprint;
diff --git a/src/interfaces/ecpg/preproc/ecpg.trailer b/src/interfaces/ecpg/preproc/ecpg.trailer
index 1c10879..b42bca4 100644
--- a/src/interfaces/ecpg/preproc/ecpg.trailer
+++ b/src/interfaces/ecpg/preproc/ecpg.trailer
@@ -1454,6 +1454,12 @@ action : CONTINUE_P
 			$<action>$.command = NULL;
 			$<action>$.str = mm_strdup("break");
 		}
+		| DO CONTINUE_P
+		{
+			$<action>$.code = W_CONTINUE;
+			$<action>$.command = NULL;
+			$<action>$.str = mm_strdup("continue");
+		}
 		| SQL_CALL name '(' c_args ')'
 		{
 			$<action>$.code = W_DO;
diff --git a/src/interfaces/ecpg/preproc/output.c b/src/interfaces/ecpg/preproc/output.c
index 59d5d30..14d7066 100644
--- a/src/interfaces/ecpg/preproc/output.c
+++ b/src/interfaces/ecpg/preproc/output.c
@@ -51,6 +51,9 @@ print_action(struct when * w)
 		case W_BREAK:
 			fprintf(base_yyout, "break;");
 			break;
+		case W_CONTINUE:
+			fprintf(base_yyout, "continue;");
+			break;
 		default:
 			fprintf(base_yyout, "{/* %d not implemented yet */}", w->code);
 			break;
diff --git a/src/interfaces/ecpg/test/ecpg_schedule b/src/interfaces/ecpg/test/ecpg_schedule
index c3ec125..cff4eeb 100644
--- a/src/interfaces/ecpg/test/ecpg_schedule
+++ b/src/interfaces/ecpg/test/ecpg_schedule
@@ -28,6 +28,7 @@ test: preproc/type
 test: preproc/variable
 test: preproc/outofscope
 test: preproc/whenever
+test: preproc/whenever_do_continue
 test: sql/array
 test: sql/binary
 test: sql/code100
diff --git a/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.c b/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.c
new file mode 100644
index 0000000..2c9d16f
--- /dev/null
+++ b/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.c
@@ -0,0 +1,155 @@
+/* Processed by ecpg (regression mode) */
+/* These include files are added by the preprocessor */
+#include <ecpglib.h>
+#include <ecpgerrno.h>
+#include <sqlca.h>
+/* End of automatic include section */
+#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+
+#line 1 "whenever_do_continue.pgc"
+#include <stdlib.h>
+
+
+#line 1 "regression.h"
+
+
+
+
+
+
+#line 3 "whenever_do_continue.pgc"
+
+
+/* exec sql whenever sqlerror  sqlprint ; */
+#line 5 "whenever_do_continue.pgc"
+
+
+int main(void)
+{
+	/* exec sql begin declare section */
+    
+    
+         
+         
+         
+     
+	
+	 
+    
+#line 15 "whenever_do_continue.pgc"
+ struct { 
+#line 12 "whenever_do_continue.pgc"
+ char ename [ 12 ] ;
+ 
+#line 13 "whenever_do_continue.pgc"
+ float sal ;
+ 
+#line 14 "whenever_do_continue.pgc"
+ float comm ;
+ } emp ;
+ 
+#line 17 "whenever_do_continue.pgc"
+ char msg [ 128 ] ;
+/* exec sql end declare section */
+#line 18 "whenever_do_continue.pgc"
+
+
+    ECPGdebug(1, stderr);
+	
+	strcpy(msg, "connect");
+    { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); 
+#line 23 "whenever_do_continue.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 23 "whenever_do_continue.pgc"
+
+	
+	strcpy(msg, "create");
+    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table emp ( ename varchar , sal double precision , comm double precision )", ECPGt_EOIT, ECPGt_EORT);
+#line 26 "whenever_do_continue.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 26 "whenever_do_continue.pgc"
+
+	
+	strcpy(msg, "insert");
+    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into emp values ( 'Ram' , 111100 , 21 )", ECPGt_EOIT, ECPGt_EORT);
+#line 29 "whenever_do_continue.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 29 "whenever_do_continue.pgc"
+
+	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into emp values ( 'aryan' , 11110 , null )", ECPGt_EOIT, ECPGt_EORT);
+#line 30 "whenever_do_continue.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 30 "whenever_do_continue.pgc"
+
+	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into emp values ( 'josh' , 10000 , 10 )", ECPGt_EOIT, ECPGt_EORT);
+#line 31 "whenever_do_continue.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 31 "whenever_do_continue.pgc"
+
+	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into emp values ( 'tom' , 20000 , null )", ECPGt_EOIT, ECPGt_EORT);
+#line 32 "whenever_do_continue.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 32 "whenever_do_continue.pgc"
+
+
+	/* declare c cursor for select ename , sal , comm from emp order by ename asc */
+#line 34 "whenever_do_continue.pgc"
+
+	
+	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare c cursor for select ename , sal , comm from emp order by ename asc", ECPGt_EOIT, ECPGt_EORT);
+#line 36 "whenever_do_continue.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 36 "whenever_do_continue.pgc"
+
+	
+	/* exec sql whenever not found  break ; */
+#line 38 "whenever_do_continue.pgc"
+
+	
+	/* exec sql whenever sqlerror  continue ; */
+#line 40 "whenever_do_continue.pgc"
+
+	
+	while (1)
+	{
+		{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch c", ECPGt_EOIT, 
+	ECPGt_char,&(emp.ename),(long)12,(long)1,(12)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_float,&(emp.sal),(long)1,(long)1,sizeof(float), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_float,&(emp.comm),(long)1,(long)1,sizeof(float), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 44 "whenever_do_continue.pgc"
+
+if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+#line 44 "whenever_do_continue.pgc"
+
+if (sqlca.sqlcode < 0) continue;}
+#line 44 "whenever_do_continue.pgc"
+
+		 printf("%s %7.2f %9.2f\n", emp.ename, emp.sal, emp.comm);
+	}
+	
+	/* exec sql whenever sqlerror  continue ; */
+#line 48 "whenever_do_continue.pgc"
+
+	
+	strcpy(msg, "drop");
+	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table emp", ECPGt_EOIT, ECPGt_EORT);}
+#line 51 "whenever_do_continue.pgc"
+
+	
+	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close c", ECPGt_EOIT, ECPGt_EORT);}
+#line 53 "whenever_do_continue.pgc"
+
+	
+	exit(0);
+}
+
diff --git a/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.stderr b/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.stderr
new file mode 100644
index 0000000..d0cdec5
--- /dev/null
+++ b/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.stderr
@@ -0,0 +1,116 @@
+[NO_PID]: ECPGdebug: set to 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGconnect: opening database ecpg1_regression on <DEFAULT> port <DEFAULT>  
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 26: query: create table emp ( ename varchar , sal double precision , comm double precision ); with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 26: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 26: OK: CREATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 29: query: insert into emp values ( 'Ram' , 111100 , 21 ); with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 29: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 29: OK: INSERT 0 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 30: query: insert into emp values ( 'aryan' , 11110 , null ); with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 30: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 30: OK: INSERT 0 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 31: query: insert into emp values ( 'josh' , 10000 , 10 ); with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 31: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 31: OK: INSERT 0 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 32: query: insert into emp values ( 'tom' , 20000 , null ); with 0 parameter(s) on connection ecpg1_regression
+[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: OK: INSERT 0 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 36: query: declare c cursor for select ename , sal , comm from emp order by ename asc; with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 36: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 36: OK: DECLARE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 44: query: fetch c; with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 44: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 44: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 44: RESULT: aryan offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 44: RESULT: 11110 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 44: RESULT:  offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode -213 on line 44: null value without indicator on line 44
+[NO_PID]: sqlca: code: -213, state: 22002
+[NO_PID]: ecpg_execute on line 44: query: fetch c; with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 44: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 44: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 44: RESULT: josh offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 44: RESULT: 10000 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 44: RESULT: 10 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 44: query: fetch c; with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 44: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 44: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 44: RESULT: Ram offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 44: RESULT: 111100 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 44: RESULT: 21 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 44: query: fetch c; with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 44: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 44: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 44: RESULT: tom offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 44: RESULT: 20000 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 44: RESULT:  offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode -213 on line 44: null value without indicator on line 44
+[NO_PID]: sqlca: code: -213, state: 22002
+[NO_PID]: ecpg_execute on line 44: query: fetch c; with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 44: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 44: correctly got 0 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 44: no data found on line 44
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ecpg_execute on line 51: query: drop table emp; with 0 parameter(s) on connection ecpg1_regression
+[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_check_PQresult on line 51: bad response - ERROR:  cannot DROP TABLE "emp" because it is being used by active queries in this session
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlstate 55006 (sqlcode -400): cannot DROP TABLE "emp" because it is being used by active queries in this session on line 51
+[NO_PID]: sqlca: code: -400, state: 55006
+[NO_PID]: ecpg_execute on line 53: query: close c; with 0 parameter(s) on connection ecpg1_regression
+[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_check_PQresult on line 53: bad response - ERROR:  current transaction is aborted, commands ignored until end of transaction block
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlstate 25P02 (sqlcode -400): current transaction is aborted, commands ignored until end of transaction block on line 53
+[NO_PID]: sqlca: code: -400, state: 25P02
diff --git a/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.stdout b/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.stdout
new file mode 100644
index 0000000..75fb6ce
--- /dev/null
+++ b/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.stdout
@@ -0,0 +1,2 @@
+josh 10000.00     10.00
+Ram 111100.00     21.00
diff --git a/src/interfaces/ecpg/test/preproc/Makefile b/src/interfaces/ecpg/test/preproc/Makefile
index d658a4d..39b1974 100644
--- a/src/interfaces/ecpg/test/preproc/Makefile
+++ b/src/interfaces/ecpg/test/preproc/Makefile
@@ -15,6 +15,7 @@ TESTS = array_of_struct array_of_struct.c \
 	type type.c \
 	variable variable.c \
 	whenever whenever.c \
+	whenever_do_continue whenever_do_continue.c \
 	pointer_to_struct pointer_to_struct.c
 
 all: $(TESTS)
diff --git a/src/interfaces/ecpg/test/preproc/whenever_do_continue.pgc b/src/interfaces/ecpg/test/preproc/whenever_do_continue.pgc
new file mode 100644
index 0000000..f3c8a10
--- /dev/null
+++ b/src/interfaces/ecpg/test/preproc/whenever_do_continue.pgc
@@ -0,0 +1,57 @@
+#include <stdlib.h>
+
+exec sql include ../regression;
+
+exec sql whenever sqlerror sqlprint;
+
+int main(void)
+{
+	exec sql begin declare section;
+    struct
+    {
+        char ename[12];
+        float sal;
+        float comm;
+    } emp;
+	
+	char msg[128];
+    exec sql end declare section;
+
+    ECPGdebug(1, stderr);
+	
+	strcpy(msg, "connect");
+    exec sql connect to REGRESSDB1;
+	
+	strcpy(msg, "create");
+    exec sql  create table emp(ename varchar,sal double precision, comm double precision);
+	
+	strcpy(msg, "insert");
+    exec sql insert into emp values ('Ram',111100,21);
+	exec sql insert into emp values ('aryan',11110,null);
+	exec sql insert into emp values ('josh',10000,10);
+	exec sql insert into emp values ('tom',20000,null);
+
+	exec sql declare c cursor for select ename, sal, comm from emp order by ename asc;
+	
+	exec sql open c;
+	
+	exec sql whenever not found do break;
+	
+	exec sql whenever sqlerror do continue;
+	
+	while (1)
+	{
+		exec sql fetch c into :emp;
+		 printf("%s %7.2f %9.2f\n", emp.ename, emp.sal, emp.comm);
+	}
+	
+	exec sql whenever sqlerror continue;
+	
+	strcpy(msg, "drop");
+	exec sql drop table emp;
+	
+	exec sql close c;
+	
+	exit(0);
+}
+
-- 
1.7.1

#5vinayak
Pokale_Vinayak_q3@lab.ntt.co.jp
In reply to: vinayak (#4)
Re: ECPG: WHENEVER statement with DO CONTINUE action

On 2017/06/12 13:09, vinayak wrote:

Hi,

On 2017/06/10 12:23, Vinayak Pokale wrote:

Thank you for your reply

On Jun 9, 2017 5:39 PM, "Michael Meskes" <meskes@postgresql.org
<mailto:meskes@postgresql.org>> wrote:

Could you please add a "DO CONTINUE" case to one of the test cases? Or
add a new one? We would need a test case IMO.

Yes I will add test case and send updated patch.

I have added new test case for DO CONTINUE.
Please check the attached patch.

I have added this in Sept. CF
https://commitfest.postgresql.org/14/1173/

Regards,
Vinayak Pokale
NTT Open Source Software Center

#6Masahiko Sawada
sawada.mshk@gmail.com
In reply to: vinayak (#5)
Re: ECPG: WHENEVER statement with DO CONTINUE action

On Tue, Jun 20, 2017 at 1:51 PM, vinayak
<Pokale_Vinayak_q3@lab.ntt.co.jp> wrote:

On 2017/06/12 13:09, vinayak wrote:

Hi,

On 2017/06/10 12:23, Vinayak Pokale wrote:

Thank you for your reply

On Jun 9, 2017 5:39 PM, "Michael Meskes" <meskes@postgresql.org> wrote:

Could you please add a "DO CONTINUE" case to one of the test cases? Or
add a new one? We would need a test case IMO.

Yes I will add test case and send updated patch.

I have added new test case for DO CONTINUE.
Please check the attached patch.

I have added this in Sept. CF
https://commitfest.postgresql.org/14/1173/

I got the following warning by git show --check. I think you should
remove unnecessary whitespace. Also the code indent of
whenever_do_continue.pgc seems to need to be adjusted.

$ git show --check
commit a854aa0130589b7bd43b2c6c1c86651be91b1f59
Author: Vinayak Pokale <vinpokale@gmail.com>
Date: Mon Jun 12 13:03:21 2017 +0900

WHENEVER statement DO CONTINUE support

src/interfaces/ecpg/test/preproc/whenever_do_continue.pgc:16: trailing
whitespace.
+
src/interfaces/ecpg/test/preproc/whenever_do_continue.pgc:21: trailing
whitespace.
+
src/interfaces/ecpg/test/preproc/whenever_do_continue.pgc:24: trailing
whitespace.
+
src/interfaces/ecpg/test/preproc/whenever_do_continue.pgc:27: trailing
whitespace.
+
src/interfaces/ecpg/test/preproc/whenever_do_continue.pgc:35: trailing
whitespace.
+
src/interfaces/ecpg/test/preproc/whenever_do_continue.pgc:37: trailing
whitespace.
+
src/interfaces/ecpg/test/preproc/whenever_do_continue.pgc:39: trailing
whitespace.
+
src/interfaces/ecpg/test/preproc/whenever_do_continue.pgc:41: trailing
whitespace.
+
src/interfaces/ecpg/test/preproc/whenever_do_continue.pgc:47: trailing
whitespace.
+
src/interfaces/ecpg/test/preproc/whenever_do_continue.pgc:49: trailing
whitespace.
+
src/interfaces/ecpg/test/preproc/whenever_do_continue.pgc:52: trailing
whitespace.
+
src/interfaces/ecpg/test/preproc/whenever_do_continue.pgc:54: trailing
whitespace.
+
src/interfaces/ecpg/test/preproc/whenever_do_continue.pgc:1: new blank
line at EOF.

------
In whenever_do_continue.pgc file, the following line seems not to be
processed successfully by ecpg but should we fix that?

+
+       exec sql whenever sqlerror continue;
+

Also, you wrote the test case using "WHENEVER sqlerror DO CONTINUE"
action but that seems not to emit sqlerror, so "DO CONTINUE" is not
executed. I think the test case for DO CONTINUE should be a C code
that executes the "continue" clause.

Regards,

--
Masahiko Sawada
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#7vinayak
Pokale_Vinayak_q3@lab.ntt.co.jp
In reply to: Masahiko Sawada (#6)
Re: ECPG: WHENEVER statement with DO CONTINUE action

Hi Sawada-san,

On 2017/06/20 17:22, Masahiko Sawada wrote:

On Tue, Jun 20, 2017 at 1:51 PM, vinayak
<Pokale_Vinayak_q3@lab.ntt.co.jp> wrote:

On 2017/06/12 13:09, vinayak wrote:

Hi,

On 2017/06/10 12:23, Vinayak Pokale wrote:

Thank you for your reply

On Jun 9, 2017 5:39 PM, "Michael Meskes" <meskes@postgresql.org> wrote:

Could you please add a "DO CONTINUE" case to one of the test cases? Or
add a new one? We would need a test case IMO.

Yes I will add test case and send updated patch.

I have added new test case for DO CONTINUE.
Please check the attached patch.

I have added this in Sept. CF
https://commitfest.postgresql.org/14/1173/

I got the following warning by git show --check. I think you should
remove unnecessary whitespace. Also the code indent of
whenever_do_continue.pgc seems to need to be adjusted.

$ git show --check
commit a854aa0130589b7bd43b2c6c1c86651be91b1f59
Author: Vinayak Pokale <vinpokale@gmail.com>
Date: Mon Jun 12 13:03:21 2017 +0900

WHENEVER statement DO CONTINUE support

src/interfaces/ecpg/test/preproc/whenever_do_continue.pgc:16: trailing
whitespace.
+
src/interfaces/ecpg/test/preproc/whenever_do_continue.pgc:21: trailing
whitespace.
+
src/interfaces/ecpg/test/preproc/whenever_do_continue.pgc:24: trailing
whitespace.
+
src/interfaces/ecpg/test/preproc/whenever_do_continue.pgc:27: trailing
whitespace.
+
src/interfaces/ecpg/test/preproc/whenever_do_continue.pgc:35: trailing
whitespace.
+
src/interfaces/ecpg/test/preproc/whenever_do_continue.pgc:37: trailing
whitespace.
+
src/interfaces/ecpg/test/preproc/whenever_do_continue.pgc:39: trailing
whitespace.
+
src/interfaces/ecpg/test/preproc/whenever_do_continue.pgc:41: trailing
whitespace.
+
src/interfaces/ecpg/test/preproc/whenever_do_continue.pgc:47: trailing
whitespace.
+
src/interfaces/ecpg/test/preproc/whenever_do_continue.pgc:49: trailing
whitespace.
+
src/interfaces/ecpg/test/preproc/whenever_do_continue.pgc:52: trailing
whitespace.
+
src/interfaces/ecpg/test/preproc/whenever_do_continue.pgc:54: trailing
whitespace.
+
src/interfaces/ecpg/test/preproc/whenever_do_continue.pgc:1: new blank
line at EOF.

------
In whenever_do_continue.pgc file, the following line seems not to be
processed successfully by ecpg but should we fix that?

+
+       exec sql whenever sqlerror continue;
+

Also, you wrote the test case using "WHENEVER sqlerror DO CONTINUE"
action but that seems not to emit sqlerror, so "DO CONTINUE" is not
executed. I think the test case for DO CONTINUE should be a C code
that executes the "continue" clause.

Thank you for testing the patch.
I agreed with your comments. I will update the patch.

Regards,
Vinayak Pokale
NTT Open Source Software Center

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#8vinayak
Pokale_Vinayak_q3@lab.ntt.co.jp
In reply to: vinayak (#7)
1 attachment(s)
Re: ECPG: WHENEVER statement with DO CONTINUE action

On 2017/06/20 17:35, vinayak wrote:

Hi Sawada-san,

On 2017/06/20 17:22, Masahiko Sawada wrote:

On Tue, Jun 20, 2017 at 1:51 PM, vinayak
<Pokale_Vinayak_q3@lab.ntt.co.jp> wrote:

On 2017/06/12 13:09, vinayak wrote:

Hi,

On 2017/06/10 12:23, Vinayak Pokale wrote:

Thank you for your reply

On Jun 9, 2017 5:39 PM, "Michael Meskes" <meskes@postgresql.org> wrote:

Could you please add a "DO CONTINUE" case to one of the test cases? Or
add a new one? We would need a test case IMO.

Yes I will add test case and send updated patch.

I have added new test case for DO CONTINUE.
Please check the attached patch.

I have added this in Sept. CF
https://commitfest.postgresql.org/14/1173/

------
In whenever_do_continue.pgc file, the following line seems not to be
processed successfully by ecpg but should we fix that?

+
+       exec sql whenever sqlerror continue;
+

Also, you wrote the test case using "WHENEVER sqlerror DO CONTINUE"
action but that seems not to emit sqlerror, so "DO CONTINUE" is not
executed. I think the test case for DO CONTINUE should be a C code
that executes the "continue" clause.

Thank you for testing the patch.
I agreed with your comments. I will update the patch.

Please check the attached updated patch.

Regards,
Vinayak Pokale
NTT Open Source Software Center

Attachments:

WHENEVER-statement-DO-CONTINUE-support_v1.patchtext/x-diff; name=WHENEVER-statement-DO-CONTINUE-support_v1.patchDownload
From cd71bf7229a8566cadfde3d0e89b1b445baf1fee Mon Sep 17 00:00:00 2001
From: Vinayak Pokale <vinpokale@gmail.com>
Date: Thu, 22 Jun 2017 11:08:38 +0900
Subject: [PATCH] WHENEVER statement DO CONTINUE support

---
 doc/src/sgml/ecpg.sgml                             |   12 ++
 src/interfaces/ecpg/preproc/ecpg.trailer           |    6 +
 src/interfaces/ecpg/preproc/output.c               |    3 +
 src/interfaces/ecpg/test/ecpg_schedule             |    1 +
 .../test/expected/preproc-whenever_do_continue.c   |  159 ++++++++++++++++++++
 .../expected/preproc-whenever_do_continue.stderr   |  112 ++++++++++++++
 .../expected/preproc-whenever_do_continue.stdout   |    2 +
 src/interfaces/ecpg/test/preproc/Makefile          |    1 +
 .../ecpg/test/preproc/whenever_do_continue.pgc     |   61 ++++++++
 9 files changed, 357 insertions(+), 0 deletions(-)
 create mode 100644 src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.c
 create mode 100644 src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.stderr
 create mode 100644 src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.stdout
 create mode 100644 src/interfaces/ecpg/test/preproc/whenever_do_continue.pgc

diff --git a/doc/src/sgml/ecpg.sgml b/doc/src/sgml/ecpg.sgml
index f13a0e9..3cb4001 100644
--- a/doc/src/sgml/ecpg.sgml
+++ b/doc/src/sgml/ecpg.sgml
@@ -4763,6 +4763,17 @@ EXEC SQL WHENEVER <replaceable>condition</replaceable> <replaceable>action</repl
      </varlistentry>
 
      <varlistentry>
+      <term><literal>DO CONTINUE</literal></term>
+      <listitem>
+       <para>
+        Execute the C statement <literal>continue</literal>.  This should
+        only be used in loops statements.  if executed, will cause the flow 
+        of control to return to the top of the loop.
+       </para>
+      </listitem>
+     </varlistentry>
+
+     <varlistentry>
       <term><literal>CALL <replaceable>name</replaceable> (<replaceable>args</replaceable>)</literal></term>
       <term><literal>DO <replaceable>name</replaceable> (<replaceable>args</replaceable>)</literal></term>
       <listitem>
@@ -7799,6 +7810,7 @@ WHENEVER { NOT FOUND | SQLERROR | SQLWARNING } <replaceable class="PARAMETER">ac
 <programlisting>
 EXEC SQL WHENEVER NOT FOUND CONTINUE;
 EXEC SQL WHENEVER NOT FOUND DO BREAK;
+EXEC SQL WHENEVER NOT FOUND DO CONTINUE;
 EXEC SQL WHENEVER SQLWARNING SQLPRINT;
 EXEC SQL WHENEVER SQLWARNING DO warn();
 EXEC SQL WHENEVER SQLERROR sqlprint;
diff --git a/src/interfaces/ecpg/preproc/ecpg.trailer b/src/interfaces/ecpg/preproc/ecpg.trailer
index 1c10879..b42bca4 100644
--- a/src/interfaces/ecpg/preproc/ecpg.trailer
+++ b/src/interfaces/ecpg/preproc/ecpg.trailer
@@ -1454,6 +1454,12 @@ action : CONTINUE_P
 			$<action>$.command = NULL;
 			$<action>$.str = mm_strdup("break");
 		}
+		| DO CONTINUE_P
+		{
+			$<action>$.code = W_CONTINUE;
+			$<action>$.command = NULL;
+			$<action>$.str = mm_strdup("continue");
+		}
 		| SQL_CALL name '(' c_args ')'
 		{
 			$<action>$.code = W_DO;
diff --git a/src/interfaces/ecpg/preproc/output.c b/src/interfaces/ecpg/preproc/output.c
index 59d5d30..14d7066 100644
--- a/src/interfaces/ecpg/preproc/output.c
+++ b/src/interfaces/ecpg/preproc/output.c
@@ -51,6 +51,9 @@ print_action(struct when * w)
 		case W_BREAK:
 			fprintf(base_yyout, "break;");
 			break;
+		case W_CONTINUE:
+			fprintf(base_yyout, "continue;");
+			break;
 		default:
 			fprintf(base_yyout, "{/* %d not implemented yet */}", w->code);
 			break;
diff --git a/src/interfaces/ecpg/test/ecpg_schedule b/src/interfaces/ecpg/test/ecpg_schedule
index c3ec125..cff4eeb 100644
--- a/src/interfaces/ecpg/test/ecpg_schedule
+++ b/src/interfaces/ecpg/test/ecpg_schedule
@@ -28,6 +28,7 @@ test: preproc/type
 test: preproc/variable
 test: preproc/outofscope
 test: preproc/whenever
+test: preproc/whenever_do_continue
 test: sql/array
 test: sql/binary
 test: sql/code100
diff --git a/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.c b/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.c
new file mode 100644
index 0000000..22d98ca
--- /dev/null
+++ b/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.c
@@ -0,0 +1,159 @@
+/* Processed by ecpg (regression mode) */
+/* These include files are added by the preprocessor */
+#include <ecpglib.h>
+#include <ecpgerrno.h>
+#include <sqlca.h>
+/* End of automatic include section */
+#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+
+#line 1 "whenever_do_continue.pgc"
+#include <stdlib.h>
+
+
+#line 1 "regression.h"
+
+
+
+
+
+
+#line 3 "whenever_do_continue.pgc"
+
+
+/* exec sql whenever sqlerror  sqlprint ; */
+#line 5 "whenever_do_continue.pgc"
+
+
+int main(void)
+{
+	/* exec sql begin declare section */
+	
+	
+		 
+		 
+		 
+	 
+
+	 
+	
+#line 15 "whenever_do_continue.pgc"
+ struct { 
+#line 12 "whenever_do_continue.pgc"
+ char ename [ 12 ] ;
+ 
+#line 13 "whenever_do_continue.pgc"
+ float sal ;
+ 
+#line 14 "whenever_do_continue.pgc"
+ float comm ;
+ } emp ;
+ 
+#line 17 "whenever_do_continue.pgc"
+ char msg [ 128 ] ;
+/* exec sql end declare section */
+#line 18 "whenever_do_continue.pgc"
+
+
+	ECPGdebug(1, stderr);
+
+	strcpy(msg, "connect");
+	{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); 
+#line 23 "whenever_do_continue.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 23 "whenever_do_continue.pgc"
+
+
+	strcpy(msg, "create");
+	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table emp ( ename varchar , sal double precision , comm double precision )", ECPGt_EOIT, ECPGt_EORT);
+#line 26 "whenever_do_continue.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 26 "whenever_do_continue.pgc"
+
+
+	strcpy(msg, "insert");
+	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into emp values ( 'Ram' , 111100 , 21 )", ECPGt_EOIT, ECPGt_EORT);
+#line 29 "whenever_do_continue.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 29 "whenever_do_continue.pgc"
+
+	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into emp values ( 'aryan' , 11110 , null )", ECPGt_EOIT, ECPGt_EORT);
+#line 30 "whenever_do_continue.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 30 "whenever_do_continue.pgc"
+
+	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into emp values ( 'josh' , 10000 , 10 )", ECPGt_EOIT, ECPGt_EORT);
+#line 31 "whenever_do_continue.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 31 "whenever_do_continue.pgc"
+
+	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into emp values ( 'tom' , 20000 , null )", ECPGt_EOIT, ECPGt_EORT);
+#line 32 "whenever_do_continue.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 32 "whenever_do_continue.pgc"
+
+
+	/* declare c cursor for select ename , sal , comm from emp order by ename asc */
+#line 34 "whenever_do_continue.pgc"
+
+
+	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare c cursor for select ename , sal , comm from emp order by ename asc", ECPGt_EOIT, ECPGt_EORT);
+#line 36 "whenever_do_continue.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 36 "whenever_do_continue.pgc"
+
+
+	/* The 'BREAK' condition to exit the loop. */
+	/* exec sql whenever not found  break ; */
+#line 39 "whenever_do_continue.pgc"
+
+
+	/* The DO CONTINUE makes the loop start at the next iteration when an error occurs.*/
+	/* exec sql whenever sqlerror  continue ; */
+#line 42 "whenever_do_continue.pgc"
+
+
+	while (1)
+	{
+		{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch c", ECPGt_EOIT, 
+	ECPGt_char,&(emp.ename),(long)12,(long)1,(12)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_float,&(emp.sal),(long)1,(long)1,sizeof(float), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_float,&(emp.comm),(long)1,(long)1,sizeof(float), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 46 "whenever_do_continue.pgc"
+
+if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+#line 46 "whenever_do_continue.pgc"
+
+if (sqlca.sqlcode < 0) continue;}
+#line 46 "whenever_do_continue.pgc"
+
+		/* The employees with non-NULL commissions will be displayed. */
+		printf("%s %7.2f %9.2f\n", emp.ename, emp.sal, emp.comm);
+	}
+
+	/* This 'CONTINUE' shuts off the 'DO CONTINUE' and allow the program to 
+   proceed if any further errors do occur. */
+	/* exec sql whenever sqlerror  continue ; */
+#line 53 "whenever_do_continue.pgc"
+
+
+	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close c", ECPGt_EOIT, ECPGt_EORT);}
+#line 55 "whenever_do_continue.pgc"
+
+
+	strcpy(msg, "drop");
+	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table emp", ECPGt_EOIT, ECPGt_EORT);}
+#line 58 "whenever_do_continue.pgc"
+
+
+	exit(0);
+}
diff --git a/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.stderr b/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.stderr
new file mode 100644
index 0000000..8f2ccf7
--- /dev/null
+++ b/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.stderr
@@ -0,0 +1,112 @@
+[NO_PID]: ECPGdebug: set to 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGconnect: opening database ecpg1_regression on <DEFAULT> port <DEFAULT>  
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 26: query: create table emp ( ename varchar , sal double precision , comm double precision ); with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 26: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 26: OK: CREATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 29: query: insert into emp values ( 'Ram' , 111100 , 21 ); with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 29: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 29: OK: INSERT 0 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 30: query: insert into emp values ( 'aryan' , 11110 , null ); with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 30: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 30: OK: INSERT 0 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 31: query: insert into emp values ( 'josh' , 10000 , 10 ); with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 31: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 31: OK: INSERT 0 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 32: query: insert into emp values ( 'tom' , 20000 , null ); with 0 parameter(s) on connection ecpg1_regression
+[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: OK: INSERT 0 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 36: query: declare c cursor for select ename , sal , comm from emp order by ename asc; with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 36: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 36: OK: DECLARE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 46: query: fetch c; with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 46: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 46: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 46: RESULT: aryan offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 46: RESULT: 11110 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 46: RESULT:  offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode -213 on line 46: null value without indicator on line 46
+[NO_PID]: sqlca: code: -213, state: 22002
+[NO_PID]: ecpg_execute on line 46: query: fetch c; with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 46: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 46: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 46: RESULT: josh offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 46: RESULT: 10000 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 46: RESULT: 10 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 46: query: fetch c; with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 46: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 46: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 46: RESULT: Ram offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 46: RESULT: 111100 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 46: RESULT: 21 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 46: query: fetch c; with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 46: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 46: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 46: RESULT: tom offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 46: RESULT: 20000 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 46: RESULT:  offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode -213 on line 46: null value without indicator on line 46
+[NO_PID]: sqlca: code: -213, state: 22002
+[NO_PID]: ecpg_execute on line 46: query: fetch c; with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 46: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 46: correctly got 0 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 46: no data found on line 46
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ecpg_execute on line 55: query: close c; with 0 parameter(s) on connection ecpg1_regression
+[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: OK: CLOSE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 58: query: drop table emp; with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 58: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 58: OK: DROP TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
diff --git a/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.stdout b/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.stdout
new file mode 100644
index 0000000..75fb6ce
--- /dev/null
+++ b/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.stdout
@@ -0,0 +1,2 @@
+josh 10000.00     10.00
+Ram 111100.00     21.00
diff --git a/src/interfaces/ecpg/test/preproc/Makefile b/src/interfaces/ecpg/test/preproc/Makefile
index d658a4d..39b1974 100644
--- a/src/interfaces/ecpg/test/preproc/Makefile
+++ b/src/interfaces/ecpg/test/preproc/Makefile
@@ -15,6 +15,7 @@ TESTS = array_of_struct array_of_struct.c \
 	type type.c \
 	variable variable.c \
 	whenever whenever.c \
+	whenever_do_continue whenever_do_continue.c \
 	pointer_to_struct pointer_to_struct.c
 
 all: $(TESTS)
diff --git a/src/interfaces/ecpg/test/preproc/whenever_do_continue.pgc b/src/interfaces/ecpg/test/preproc/whenever_do_continue.pgc
new file mode 100644
index 0000000..d590199
--- /dev/null
+++ b/src/interfaces/ecpg/test/preproc/whenever_do_continue.pgc
@@ -0,0 +1,61 @@
+#include <stdlib.h>
+
+exec sql include ../regression;
+
+exec sql whenever sqlerror sqlprint;
+
+int main(void)
+{
+	exec sql begin declare section;
+	struct
+	{
+		char ename[12];
+		float sal;
+		float comm;
+	} emp;
+
+	char msg[128];
+	exec sql end declare section;
+
+	ECPGdebug(1, stderr);
+
+	strcpy(msg, "connect");
+	exec sql connect to REGRESSDB1;
+
+	strcpy(msg, "create");
+	exec sql  create table emp(ename varchar,sal double precision, comm double precision);
+
+	strcpy(msg, "insert");
+	exec sql insert into emp values ('Ram',111100,21);
+	exec sql insert into emp values ('aryan',11110,null);
+	exec sql insert into emp values ('josh',10000,10);
+	exec sql insert into emp values ('tom',20000,null);
+
+	exec sql declare c cursor for select ename, sal, comm from emp order by ename asc;
+
+	exec sql open c;
+
+	/* The 'BREAK' condition to exit the loop. */
+	exec sql whenever not found do break;
+
+	/* The DO CONTINUE makes the loop start at the next iteration when an error occurs.*/
+	exec sql whenever sqlerror do continue;
+
+	while (1)
+	{
+		exec sql fetch c into :emp;
+		/* The employees with non-NULL commissions will be displayed. */
+		printf("%s %7.2f %9.2f\n", emp.ename, emp.sal, emp.comm);
+	}
+
+	/* This 'CONTINUE' shuts off the 'DO CONTINUE' and allow the program to
+	proceed if any further errors do occur. */
+	exec sql whenever sqlerror continue;
+
+	exec sql close c;
+
+	strcpy(msg, "drop");
+	exec sql drop table emp;
+
+	exit(0);
+}
-- 
1.7.1

#9Masahiko Sawada
sawada.mshk@gmail.com
In reply to: vinayak (#8)
Re: ECPG: WHENEVER statement with DO CONTINUE action

On Fri, Aug 18, 2017 at 5:20 PM, vinayak
<Pokale_Vinayak_q3@lab.ntt.co.jp> wrote:

On 2017/06/20 17:35, vinayak wrote:

Hi Sawada-san,

On 2017/06/20 17:22, Masahiko Sawada wrote:

On Tue, Jun 20, 2017 at 1:51 PM, vinayak
<Pokale_Vinayak_q3@lab.ntt.co.jp> wrote:

On 2017/06/12 13:09, vinayak wrote:

Hi,

On 2017/06/10 12:23, Vinayak Pokale wrote:

Thank you for your reply

On Jun 9, 2017 5:39 PM, "Michael Meskes" <meskes@postgresql.org> wrote:

Could you please add a "DO CONTINUE" case to one of the test cases? Or
add a new one? We would need a test case IMO.

Yes I will add test case and send updated patch.

I have added new test case for DO CONTINUE.
Please check the attached patch.

I have added this in Sept. CF
https://commitfest.postgresql.org/14/1173/

------
In whenever_do_continue.pgc file, the following line seems not to be
processed successfully by ecpg but should we fix that?

+
+       exec sql whenever sqlerror continue;
+

Also, you wrote the test case using "WHENEVER sqlerror DO CONTINUE"
action but that seems not to emit sqlerror, so "DO CONTINUE" is not
executed. I think the test case for DO CONTINUE should be a C code
that executes the "continue" clause.

Thank you for testing the patch.
I agreed with your comments. I will update the patch.

Please check the attached updated patch.

Thank you for updating.

The regression test failed after applied latest patch by git am.

*** /tmp/pg/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.c
   2017-08-24 20:01:10.023201132 -0700
--- /tmp/pg/src/interfaces/ecpg/test/results/preproc-whenever_do_continue.c
    2017-08-24 20:22:54.308200853 -0700
***************
*** 140,147 ****
                printf("%s %7.2f %9.2f\n", emp.ename, emp.sal, emp.comm);
        }

! /* This 'CONTINUE' shuts off the 'DO CONTINUE' and allow the program to
! proceed if any further errors do occur. */
/* exec sql whenever sqlerror continue ; */
#line 53 "whenever_do_continue.pgc"

--- 140,147 ----
                printf("%s %7.2f %9.2f\n", emp.ename, emp.sal, emp.comm);
        }

! /* This 'CONTINUE' shuts off the 'DO CONTINUE' and allow the program to
! proceed if any further errors do occur. */
/* exec sql whenever sqlerror continue ; */
#line 53 "whenever_do_continue.pgc"

======================================================================

+       /* This 'CONTINUE' shuts off the 'DO CONTINUE' and allow the program to
+       proceed if any further errors do occur. */

I think this comment should obey the coding style guide.

Regards,

--
Masahiko Sawada
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#10vinayak
Pokale_Vinayak_q3@lab.ntt.co.jp
In reply to: Masahiko Sawada (#9)
1 attachment(s)
Re: ECPG: WHENEVER statement with DO CONTINUE action

Hi Sawada-san,

On 2017/08/25 11:07, Masahiko Sawada wrote:

On Fri, Aug 18, 2017 at 5:20 PM, vinayak
<Pokale_Vinayak_q3@lab.ntt.co.jp> wrote:

On 2017/06/20 17:35, vinayak wrote:

Hi Sawada-san,

On 2017/06/20 17:22, Masahiko Sawada wrote:

On Tue, Jun 20, 2017 at 1:51 PM, vinayak
<Pokale_Vinayak_q3@lab.ntt.co.jp> wrote:

On 2017/06/12 13:09, vinayak wrote:

Hi,

On 2017/06/10 12:23, Vinayak Pokale wrote:

Thank you for your reply

On Jun 9, 2017 5:39 PM, "Michael Meskes" <meskes@postgresql.org> wrote:

Could you please add a "DO CONTINUE" case to one of the test cases? Or
add a new one? We would need a test case IMO.

Yes I will add test case and send updated patch.

I have added new test case for DO CONTINUE.
Please check the attached patch.

I have added this in Sept. CF
https://commitfest.postgresql.org/14/1173/

------
In whenever_do_continue.pgc file, the following line seems not to be
processed successfully by ecpg but should we fix that?

+
+       exec sql whenever sqlerror continue;
+

Also, you wrote the test case using "WHENEVER sqlerror DO CONTINUE"
action but that seems not to emit sqlerror, so "DO CONTINUE" is not
executed. I think the test case for DO CONTINUE should be a C code
that executes the "continue" clause.

Thank you for testing the patch.
I agreed with your comments. I will update the patch.

Please check the attached updated patch.

Thank you for updating.

The regression test failed after applied latest patch by git am.

*** /tmp/pg/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.c
2017-08-24 20:01:10.023201132 -0700
--- /tmp/pg/src/interfaces/ecpg/test/results/preproc-whenever_do_continue.c
2017-08-24 20:22:54.308200853 -0700
***************
*** 140,147 ****
printf("%s %7.2f %9.2f\n", emp.ename, emp.sal, emp.comm);
}

! /* This 'CONTINUE' shuts off the 'DO CONTINUE' and allow the program to
! proceed if any further errors do occur. */
/* exec sql whenever sqlerror continue ; */
#line 53 "whenever_do_continue.pgc"

--- 140,147 ----
printf("%s %7.2f %9.2f\n", emp.ename, emp.sal, emp.comm);
}

! /* This 'CONTINUE' shuts off the 'DO CONTINUE' and allow the program to
! proceed if any further errors do occur. */
/* exec sql whenever sqlerror continue ; */
#line 53 "whenever_do_continue.pgc"

======================================================================

+       /* This 'CONTINUE' shuts off the 'DO CONTINUE' and allow the program to
+       proceed if any further errors do occur. */

I think this comment should obey the coding style guide.

Thank you for testing.

I have updated the patch.
PFA.

Regards,
Vinayak Pokale
NTT Open Source Software Center

Attachments:

WHENEVER-statement-DO-CONTINUE-support_v2.patchtext/x-patch; name=WHENEVER-statement-DO-CONTINUE-support_v2.patchDownload
From cd71bf7229a8566cadfde3d0e89b1b445baf1fee Mon Sep 17 00:00:00 2001
From: Vinayak Pokale <vinpokale@gmail.com>
Date: Thu, 22 Jun 2017 11:08:38 +0900
Subject: [PATCH] WHENEVER statement DO CONTINUE support

---
 doc/src/sgml/ecpg.sgml                             |   12 ++
 src/interfaces/ecpg/preproc/ecpg.trailer           |    6 +
 src/interfaces/ecpg/preproc/output.c               |    3 +
 src/interfaces/ecpg/test/ecpg_schedule             |    1 +
 .../test/expected/preproc-whenever_do_continue.c   |  159 ++++++++++++++++++++
 .../expected/preproc-whenever_do_continue.stderr   |  112 ++++++++++++++
 .../expected/preproc-whenever_do_continue.stdout   |    2 +
 src/interfaces/ecpg/test/preproc/Makefile          |    1 +
 .../ecpg/test/preproc/whenever_do_continue.pgc     |   61 ++++++++
 9 files changed, 357 insertions(+), 0 deletions(-)
 create mode 100644 src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.c
 create mode 100644 src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.stderr
 create mode 100644 src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.stdout
 create mode 100644 src/interfaces/ecpg/test/preproc/whenever_do_continue.pgc

diff --git a/doc/src/sgml/ecpg.sgml b/doc/src/sgml/ecpg.sgml
index f13a0e9..3cb4001 100644
--- a/doc/src/sgml/ecpg.sgml
+++ b/doc/src/sgml/ecpg.sgml
@@ -4763,6 +4763,17 @@ EXEC SQL WHENEVER <replaceable>condition</replaceable> <replaceable>action</repl
      </varlistentry>
 
      <varlistentry>
+      <term><literal>DO CONTINUE</literal></term>
+      <listitem>
+       <para>
+        Execute the C statement <literal>continue</literal>.  This should
+        only be used in loops statements.  if executed, will cause the flow 
+        of control to return to the top of the loop.
+       </para>
+      </listitem>
+     </varlistentry>
+
+     <varlistentry>
       <term><literal>CALL <replaceable>name</replaceable> (<replaceable>args</replaceable>)</literal></term>
       <term><literal>DO <replaceable>name</replaceable> (<replaceable>args</replaceable>)</literal></term>
       <listitem>
@@ -7799,6 +7810,7 @@ WHENEVER { NOT FOUND | SQLERROR | SQLWARNING } <replaceable class="PARAMETER">ac
 <programlisting>
 EXEC SQL WHENEVER NOT FOUND CONTINUE;
 EXEC SQL WHENEVER NOT FOUND DO BREAK;
+EXEC SQL WHENEVER NOT FOUND DO CONTINUE;
 EXEC SQL WHENEVER SQLWARNING SQLPRINT;
 EXEC SQL WHENEVER SQLWARNING DO warn();
 EXEC SQL WHENEVER SQLERROR sqlprint;
diff --git a/src/interfaces/ecpg/preproc/ecpg.trailer b/src/interfaces/ecpg/preproc/ecpg.trailer
index 1c10879..b42bca4 100644
--- a/src/interfaces/ecpg/preproc/ecpg.trailer
+++ b/src/interfaces/ecpg/preproc/ecpg.trailer
@@ -1454,6 +1454,12 @@ action : CONTINUE_P
 			$<action>$.command = NULL;
 			$<action>$.str = mm_strdup("break");
 		}
+		| DO CONTINUE_P
+		{
+			$<action>$.code = W_CONTINUE;
+			$<action>$.command = NULL;
+			$<action>$.str = mm_strdup("continue");
+		}
 		| SQL_CALL name '(' c_args ')'
 		{
 			$<action>$.code = W_DO;
diff --git a/src/interfaces/ecpg/preproc/output.c b/src/interfaces/ecpg/preproc/output.c
index 59d5d30..14d7066 100644
--- a/src/interfaces/ecpg/preproc/output.c
+++ b/src/interfaces/ecpg/preproc/output.c
@@ -51,6 +51,9 @@ print_action(struct when * w)
 		case W_BREAK:
 			fprintf(base_yyout, "break;");
 			break;
+		case W_CONTINUE:
+			fprintf(base_yyout, "continue;");
+			break;
 		default:
 			fprintf(base_yyout, "{/* %d not implemented yet */}", w->code);
 			break;
diff --git a/src/interfaces/ecpg/test/ecpg_schedule b/src/interfaces/ecpg/test/ecpg_schedule
index c3ec125..cff4eeb 100644
--- a/src/interfaces/ecpg/test/ecpg_schedule
+++ b/src/interfaces/ecpg/test/ecpg_schedule
@@ -28,6 +28,7 @@ test: preproc/type
 test: preproc/variable
 test: preproc/outofscope
 test: preproc/whenever
+test: preproc/whenever_do_continue
 test: sql/array
 test: sql/binary
 test: sql/code100
diff --git a/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.c b/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.c
new file mode 100644
index 0000000..22d98ca
--- /dev/null
+++ b/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.c
@@ -0,0 +1,159 @@
+/* Processed by ecpg (regression mode) */
+/* These include files are added by the preprocessor */
+#include <ecpglib.h>
+#include <ecpgerrno.h>
+#include <sqlca.h>
+/* End of automatic include section */
+#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+
+#line 1 "whenever_do_continue.pgc"
+#include <stdlib.h>
+
+
+#line 1 "regression.h"
+
+
+
+
+
+
+#line 3 "whenever_do_continue.pgc"
+
+
+/* exec sql whenever sqlerror  sqlprint ; */
+#line 5 "whenever_do_continue.pgc"
+
+
+int main(void)
+{
+	/* exec sql begin declare section */
+	
+	
+		 
+		 
+		 
+	 
+
+	 
+	
+#line 15 "whenever_do_continue.pgc"
+ struct { 
+#line 12 "whenever_do_continue.pgc"
+ char ename [ 12 ] ;
+ 
+#line 13 "whenever_do_continue.pgc"
+ float sal ;
+ 
+#line 14 "whenever_do_continue.pgc"
+ float comm ;
+ } emp ;
+ 
+#line 17 "whenever_do_continue.pgc"
+ char msg [ 128 ] ;
+/* exec sql end declare section */
+#line 18 "whenever_do_continue.pgc"
+
+
+	ECPGdebug(1, stderr);
+
+	strcpy(msg, "connect");
+	{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); 
+#line 23 "whenever_do_continue.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 23 "whenever_do_continue.pgc"
+
+
+	strcpy(msg, "create");
+	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table emp ( ename varchar , sal double precision , comm double precision )", ECPGt_EOIT, ECPGt_EORT);
+#line 26 "whenever_do_continue.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 26 "whenever_do_continue.pgc"
+
+
+	strcpy(msg, "insert");
+	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into emp values ( 'Ram' , 111100 , 21 )", ECPGt_EOIT, ECPGt_EORT);
+#line 29 "whenever_do_continue.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 29 "whenever_do_continue.pgc"
+
+	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into emp values ( 'aryan' , 11110 , null )", ECPGt_EOIT, ECPGt_EORT);
+#line 30 "whenever_do_continue.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 30 "whenever_do_continue.pgc"
+
+	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into emp values ( 'josh' , 10000 , 10 )", ECPGt_EOIT, ECPGt_EORT);
+#line 31 "whenever_do_continue.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 31 "whenever_do_continue.pgc"
+
+	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into emp values ( 'tom' , 20000 , null )", ECPGt_EOIT, ECPGt_EORT);
+#line 32 "whenever_do_continue.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 32 "whenever_do_continue.pgc"
+
+
+	/* declare c cursor for select ename , sal , comm from emp order by ename asc */
+#line 34 "whenever_do_continue.pgc"
+
+
+	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare c cursor for select ename , sal , comm from emp order by ename asc", ECPGt_EOIT, ECPGt_EORT);
+#line 36 "whenever_do_continue.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 36 "whenever_do_continue.pgc"
+
+
+	/* The 'BREAK' condition to exit the loop. */
+	/* exec sql whenever not found  break ; */
+#line 39 "whenever_do_continue.pgc"
+
+
+	/* The DO CONTINUE makes the loop start at the next iteration when an error occurs.*/
+	/* exec sql whenever sqlerror  continue ; */
+#line 42 "whenever_do_continue.pgc"
+
+
+	while (1)
+	{
+		{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch c", ECPGt_EOIT, 
+	ECPGt_char,&(emp.ename),(long)12,(long)1,(12)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_float,&(emp.sal),(long)1,(long)1,sizeof(float), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_float,&(emp.comm),(long)1,(long)1,sizeof(float), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 46 "whenever_do_continue.pgc"
+
+if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+#line 46 "whenever_do_continue.pgc"
+
+if (sqlca.sqlcode < 0) continue;}
+#line 46 "whenever_do_continue.pgc"
+
+		/* The employees with non-NULL commissions will be displayed. */
+		printf("%s %7.2f %9.2f\n", emp.ename, emp.sal, emp.comm);
+	}
+
+	/* This 'CONTINUE' shuts off the 'DO CONTINUE' and allow the program to
+	proceed if any further errors do occur. */
+	/* exec sql whenever sqlerror  continue ; */
+#line 53 "whenever_do_continue.pgc"
+
+
+	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close c", ECPGt_EOIT, ECPGt_EORT);}
+#line 55 "whenever_do_continue.pgc"
+
+
+	strcpy(msg, "drop");
+	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table emp", ECPGt_EOIT, ECPGt_EORT);}
+#line 58 "whenever_do_continue.pgc"
+
+
+	exit(0);
+}
diff --git a/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.stderr b/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.stderr
new file mode 100644
index 0000000..8f2ccf7
--- /dev/null
+++ b/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.stderr
@@ -0,0 +1,112 @@
+[NO_PID]: ECPGdebug: set to 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGconnect: opening database ecpg1_regression on <DEFAULT> port <DEFAULT>  
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 26: query: create table emp ( ename varchar , sal double precision , comm double precision ); with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 26: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 26: OK: CREATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 29: query: insert into emp values ( 'Ram' , 111100 , 21 ); with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 29: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 29: OK: INSERT 0 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 30: query: insert into emp values ( 'aryan' , 11110 , null ); with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 30: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 30: OK: INSERT 0 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 31: query: insert into emp values ( 'josh' , 10000 , 10 ); with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 31: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 31: OK: INSERT 0 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 32: query: insert into emp values ( 'tom' , 20000 , null ); with 0 parameter(s) on connection ecpg1_regression
+[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: OK: INSERT 0 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 36: query: declare c cursor for select ename , sal , comm from emp order by ename asc; with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 36: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 36: OK: DECLARE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 46: query: fetch c; with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 46: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 46: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 46: RESULT: aryan offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 46: RESULT: 11110 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 46: RESULT:  offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode -213 on line 46: null value without indicator on line 46
+[NO_PID]: sqlca: code: -213, state: 22002
+[NO_PID]: ecpg_execute on line 46: query: fetch c; with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 46: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 46: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 46: RESULT: josh offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 46: RESULT: 10000 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 46: RESULT: 10 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 46: query: fetch c; with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 46: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 46: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 46: RESULT: Ram offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 46: RESULT: 111100 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 46: RESULT: 21 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 46: query: fetch c; with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 46: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 46: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 46: RESULT: tom offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 46: RESULT: 20000 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 46: RESULT:  offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode -213 on line 46: null value without indicator on line 46
+[NO_PID]: sqlca: code: -213, state: 22002
+[NO_PID]: ecpg_execute on line 46: query: fetch c; with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 46: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 46: correctly got 0 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 46: no data found on line 46
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ecpg_execute on line 55: query: close c; with 0 parameter(s) on connection ecpg1_regression
+[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: OK: CLOSE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 58: query: drop table emp; with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 58: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 58: OK: DROP TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
diff --git a/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.stdout b/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.stdout
new file mode 100644
index 0000000..75fb6ce
--- /dev/null
+++ b/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.stdout
@@ -0,0 +1,2 @@
+josh 10000.00     10.00
+Ram 111100.00     21.00
diff --git a/src/interfaces/ecpg/test/preproc/Makefile b/src/interfaces/ecpg/test/preproc/Makefile
index d658a4d..39b1974 100644
--- a/src/interfaces/ecpg/test/preproc/Makefile
+++ b/src/interfaces/ecpg/test/preproc/Makefile
@@ -15,6 +15,7 @@ TESTS = array_of_struct array_of_struct.c \
 	type type.c \
 	variable variable.c \
 	whenever whenever.c \
+	whenever_do_continue whenever_do_continue.c \
 	pointer_to_struct pointer_to_struct.c
 
 all: $(TESTS)
diff --git a/src/interfaces/ecpg/test/preproc/whenever_do_continue.pgc b/src/interfaces/ecpg/test/preproc/whenever_do_continue.pgc
new file mode 100644
index 0000000..d590199
--- /dev/null
+++ b/src/interfaces/ecpg/test/preproc/whenever_do_continue.pgc
@@ -0,0 +1,61 @@
+#include <stdlib.h>
+
+exec sql include ../regression;
+
+exec sql whenever sqlerror sqlprint;
+
+int main(void)
+{
+	exec sql begin declare section;
+	struct
+	{
+		char ename[12];
+		float sal;
+		float comm;
+	} emp;
+
+	char msg[128];
+	exec sql end declare section;
+
+	ECPGdebug(1, stderr);
+
+	strcpy(msg, "connect");
+	exec sql connect to REGRESSDB1;
+
+	strcpy(msg, "create");
+	exec sql  create table emp(ename varchar,sal double precision, comm double precision);
+
+	strcpy(msg, "insert");
+	exec sql insert into emp values ('Ram',111100,21);
+	exec sql insert into emp values ('aryan',11110,null);
+	exec sql insert into emp values ('josh',10000,10);
+	exec sql insert into emp values ('tom',20000,null);
+
+	exec sql declare c cursor for select ename, sal, comm from emp order by ename asc;
+
+	exec sql open c;
+
+	/* The 'BREAK' condition to exit the loop. */
+	exec sql whenever not found do break;
+
+	/* The DO CONTINUE makes the loop start at the next iteration when an error occurs.*/
+	exec sql whenever sqlerror do continue;
+
+	while (1)
+	{
+		exec sql fetch c into :emp;
+		/* The employees with non-NULL commissions will be displayed. */
+		printf("%s %7.2f %9.2f\n", emp.ename, emp.sal, emp.comm);
+	}
+
+	/* This 'CONTINUE' shuts off the 'DO CONTINUE' and allow the program to
+	proceed if any further errors do occur. */
+	exec sql whenever sqlerror continue;
+
+	exec sql close c;
+
+	strcpy(msg, "drop");
+	exec sql drop table emp;
+
+	exit(0);
+}
-- 
1.7.1

#11Masahiko Sawada
sawada.mshk@gmail.com
In reply to: vinayak (#10)
1 attachment(s)
Re: ECPG: WHENEVER statement with DO CONTINUE action

On Fri, Aug 25, 2017 at 2:57 PM, vinayak
<Pokale_Vinayak_q3@lab.ntt.co.jp> wrote:

Hi Sawada-san,

On 2017/08/25 11:07, Masahiko Sawada wrote:

On Fri, Aug 18, 2017 at 5:20 PM, vinayak
<Pokale_Vinayak_q3@lab.ntt.co.jp> wrote:

On 2017/06/20 17:35, vinayak wrote:

Hi Sawada-san,

On 2017/06/20 17:22, Masahiko Sawada wrote:

On Tue, Jun 20, 2017 at 1:51 PM, vinayak
<Pokale_Vinayak_q3@lab.ntt.co.jp> wrote:

On 2017/06/12 13:09, vinayak wrote:

Hi,

On 2017/06/10 12:23, Vinayak Pokale wrote:

Thank you for your reply

On Jun 9, 2017 5:39 PM, "Michael Meskes" <meskes@postgresql.org>
wrote:

Could you please add a "DO CONTINUE" case to one of the test cases?
Or
add a new one? We would need a test case IMO.

Yes I will add test case and send updated patch.

I have added new test case for DO CONTINUE.
Please check the attached patch.

I have added this in Sept. CF
https://commitfest.postgresql.org/14/1173/

------
In whenever_do_continue.pgc file, the following line seems not to be
processed successfully by ecpg but should we fix that?

+
+       exec sql whenever sqlerror continue;
+

Also, you wrote the test case using "WHENEVER sqlerror DO CONTINUE"
action but that seems not to emit sqlerror, so "DO CONTINUE" is not
executed. I think the test case for DO CONTINUE should be a C code
that executes the "continue" clause.

Thank you for testing the patch.
I agreed with your comments. I will update the patch.

Please check the attached updated patch.

Thank you for updating.

The regression test failed after applied latest patch by git am.

***
/tmp/pg/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.c
2017-08-24 20:01:10.023201132 -0700
---
/tmp/pg/src/interfaces/ecpg/test/results/preproc-whenever_do_continue.c
2017-08-24 20:22:54.308200853 -0700
***************
*** 140,147 ****
printf("%s %7.2f %9.2f\n", emp.ename, emp.sal, emp.comm);
}

! /* This 'CONTINUE' shuts off the 'DO CONTINUE' and allow the
program to
! proceed if any further errors do occur. */
/* exec sql whenever sqlerror continue ; */
#line 53 "whenever_do_continue.pgc"

--- 140,147 ----
printf("%s %7.2f %9.2f\n", emp.ename, emp.sal, emp.comm);
}

! /* This 'CONTINUE' shuts off the 'DO CONTINUE' and allow the
program to
! proceed if any further errors do occur. */
/* exec sql whenever sqlerror continue ; */
#line 53 "whenever_do_continue.pgc"

======================================================================

+       /* This 'CONTINUE' shuts off the 'DO CONTINUE' and allow the
program to
+       proceed if any further errors do occur. */

I think this comment should obey the coding style guide.

Thank you for testing.

I have updated the patch.
PFA.

Thank you for updating the patch. It seems not to incorporate my
second review comment. Attached an updated patch including a fix of a
comment style in whenever_do_continue.pgc file. Please find an
attached file.

Regards,

--
Masahiko Sawada
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center

Attachments:

0001-WHENEVER-statement-DO-CONTINUE-support_v3.patchapplication/octet-stream; name=0001-WHENEVER-statement-DO-CONTINUE-support_v3.patchDownload
From 7da35642d55e3be412824eaad211ec0ffa83cf65 Mon Sep 17 00:00:00 2001
From: Vinayak Pokale <vinpokale@gmail.com>
Date: Thu, 22 Jun 2017 11:08:38 +0900
Subject: [PATCH] WHENEVER statement DO CONTINUE support

---
 doc/src/sgml/ecpg.sgml                             |   12 ++
 src/interfaces/ecpg/preproc/ecpg.trailer           |    6 +
 src/interfaces/ecpg/preproc/output.c               |    3 +
 src/interfaces/ecpg/test/ecpg_schedule             |    1 +
 .../test/expected/preproc-whenever_do_continue.c   |  161 ++++++++++++++++++++
 .../expected/preproc-whenever_do_continue.stderr   |  112 ++++++++++++++
 .../expected/preproc-whenever_do_continue.stdout   |    2 +
 src/interfaces/ecpg/test/preproc/Makefile          |    1 +
 .../ecpg/test/preproc/whenever_do_continue.pgc     |   63 ++++++++
 9 files changed, 361 insertions(+), 0 deletions(-)
 create mode 100644 src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.c
 create mode 100644 src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.stderr
 create mode 100644 src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.stdout
 create mode 100644 src/interfaces/ecpg/test/preproc/whenever_do_continue.pgc

diff --git a/doc/src/sgml/ecpg.sgml b/doc/src/sgml/ecpg.sgml
index f13a0e9..3cb4001 100644
--- a/doc/src/sgml/ecpg.sgml
+++ b/doc/src/sgml/ecpg.sgml
@@ -4763,6 +4763,17 @@ EXEC SQL WHENEVER <replaceable>condition</replaceable> <replaceable>action</repl
      </varlistentry>
 
      <varlistentry>
+      <term><literal>DO CONTINUE</literal></term>
+      <listitem>
+       <para>
+        Execute the C statement <literal>continue</literal>.  This should
+        only be used in loops statements.  if executed, will cause the flow 
+        of control to return to the top of the loop.
+       </para>
+      </listitem>
+     </varlistentry>
+
+     <varlistentry>
       <term><literal>CALL <replaceable>name</replaceable> (<replaceable>args</replaceable>)</literal></term>
       <term><literal>DO <replaceable>name</replaceable> (<replaceable>args</replaceable>)</literal></term>
       <listitem>
@@ -7799,6 +7810,7 @@ WHENEVER { NOT FOUND | SQLERROR | SQLWARNING } <replaceable class="PARAMETER">ac
 <programlisting>
 EXEC SQL WHENEVER NOT FOUND CONTINUE;
 EXEC SQL WHENEVER NOT FOUND DO BREAK;
+EXEC SQL WHENEVER NOT FOUND DO CONTINUE;
 EXEC SQL WHENEVER SQLWARNING SQLPRINT;
 EXEC SQL WHENEVER SQLWARNING DO warn();
 EXEC SQL WHENEVER SQLERROR sqlprint;
diff --git a/src/interfaces/ecpg/preproc/ecpg.trailer b/src/interfaces/ecpg/preproc/ecpg.trailer
index d273070..f60a620 100644
--- a/src/interfaces/ecpg/preproc/ecpg.trailer
+++ b/src/interfaces/ecpg/preproc/ecpg.trailer
@@ -1454,6 +1454,12 @@ action : CONTINUE_P
 			$<action>$.command = NULL;
 			$<action>$.str = mm_strdup("break");
 		}
+		| DO CONTINUE_P
+		{
+			$<action>$.code = W_CONTINUE;
+			$<action>$.command = NULL;
+			$<action>$.str = mm_strdup("continue");
+		}
 		| SQL_CALL name '(' c_args ')'
 		{
 			$<action>$.code = W_DO;
diff --git a/src/interfaces/ecpg/preproc/output.c b/src/interfaces/ecpg/preproc/output.c
index 0479c93..a55bf2b 100644
--- a/src/interfaces/ecpg/preproc/output.c
+++ b/src/interfaces/ecpg/preproc/output.c
@@ -51,6 +51,9 @@ print_action(struct when *w)
 		case W_BREAK:
 			fprintf(base_yyout, "break;");
 			break;
+		case W_CONTINUE:
+			fprintf(base_yyout, "continue;");
+			break;
 		default:
 			fprintf(base_yyout, "{/* %d not implemented yet */}", w->code);
 			break;
diff --git a/src/interfaces/ecpg/test/ecpg_schedule b/src/interfaces/ecpg/test/ecpg_schedule
index c3ec125..cff4eeb 100644
--- a/src/interfaces/ecpg/test/ecpg_schedule
+++ b/src/interfaces/ecpg/test/ecpg_schedule
@@ -28,6 +28,7 @@ test: preproc/type
 test: preproc/variable
 test: preproc/outofscope
 test: preproc/whenever
+test: preproc/whenever_do_continue
 test: sql/array
 test: sql/binary
 test: sql/code100
diff --git a/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.c b/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.c
new file mode 100644
index 0000000..2e95581
--- /dev/null
+++ b/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.c
@@ -0,0 +1,161 @@
+/* Processed by ecpg (regression mode) */
+/* These include files are added by the preprocessor */
+#include <ecpglib.h>
+#include <ecpgerrno.h>
+#include <sqlca.h>
+/* End of automatic include section */
+#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+
+#line 1 "whenever_do_continue.pgc"
+#include <stdlib.h>
+
+
+#line 1 "regression.h"
+
+
+
+
+
+
+#line 3 "whenever_do_continue.pgc"
+
+
+/* exec sql whenever sqlerror  sqlprint ; */
+#line 5 "whenever_do_continue.pgc"
+
+
+int main(void)
+{
+	/* exec sql begin declare section */
+	
+	
+		 
+		 
+		 
+	 
+
+	 
+	
+#line 15 "whenever_do_continue.pgc"
+ struct { 
+#line 12 "whenever_do_continue.pgc"
+ char ename [ 12 ] ;
+ 
+#line 13 "whenever_do_continue.pgc"
+ float sal ;
+ 
+#line 14 "whenever_do_continue.pgc"
+ float comm ;
+ } emp ;
+ 
+#line 17 "whenever_do_continue.pgc"
+ char msg [ 128 ] ;
+/* exec sql end declare section */
+#line 18 "whenever_do_continue.pgc"
+
+
+	ECPGdebug(1, stderr);
+
+	strcpy(msg, "connect");
+	{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); 
+#line 23 "whenever_do_continue.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 23 "whenever_do_continue.pgc"
+
+
+	strcpy(msg, "create");
+	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table emp ( ename varchar , sal double precision , comm double precision )", ECPGt_EOIT, ECPGt_EORT);
+#line 26 "whenever_do_continue.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 26 "whenever_do_continue.pgc"
+
+
+	strcpy(msg, "insert");
+	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into emp values ( 'Ram' , 111100 , 21 )", ECPGt_EOIT, ECPGt_EORT);
+#line 29 "whenever_do_continue.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 29 "whenever_do_continue.pgc"
+
+	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into emp values ( 'aryan' , 11110 , null )", ECPGt_EOIT, ECPGt_EORT);
+#line 30 "whenever_do_continue.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 30 "whenever_do_continue.pgc"
+
+	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into emp values ( 'josh' , 10000 , 10 )", ECPGt_EOIT, ECPGt_EORT);
+#line 31 "whenever_do_continue.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 31 "whenever_do_continue.pgc"
+
+	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into emp values ( 'tom' , 20000 , null )", ECPGt_EOIT, ECPGt_EORT);
+#line 32 "whenever_do_continue.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 32 "whenever_do_continue.pgc"
+
+
+	/* declare c cursor for select ename , sal , comm from emp order by ename asc */
+#line 34 "whenever_do_continue.pgc"
+
+
+	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare c cursor for select ename , sal , comm from emp order by ename asc", ECPGt_EOIT, ECPGt_EORT);
+#line 36 "whenever_do_continue.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 36 "whenever_do_continue.pgc"
+
+
+	/* The 'BREAK' condition to exit the loop. */
+	/* exec sql whenever not found  break ; */
+#line 39 "whenever_do_continue.pgc"
+
+
+	/* The DO CONTINUE makes the loop start at the next iteration when an error occurs.*/
+	/* exec sql whenever sqlerror  continue ; */
+#line 42 "whenever_do_continue.pgc"
+
+
+	while (1)
+	{
+		{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch c", ECPGt_EOIT, 
+	ECPGt_char,&(emp.ename),(long)12,(long)1,(12)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_float,&(emp.sal),(long)1,(long)1,sizeof(float), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_float,&(emp.comm),(long)1,(long)1,sizeof(float), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 46 "whenever_do_continue.pgc"
+
+if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+#line 46 "whenever_do_continue.pgc"
+
+if (sqlca.sqlcode < 0) continue;}
+#line 46 "whenever_do_continue.pgc"
+
+		/* The employees with non-NULL commissions will be displayed. */
+		printf("%s %7.2f %9.2f\n", emp.ename, emp.sal, emp.comm);
+	}
+
+	/*
+	 * This 'CONTINUE' shuts off the 'DO CONTINUE' and allow the program to
+	 * proceed if any further errors do occur.
+	 */
+	/* exec sql whenever sqlerror  continue ; */
+#line 55 "whenever_do_continue.pgc"
+
+
+	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close c", ECPGt_EOIT, ECPGt_EORT);}
+#line 57 "whenever_do_continue.pgc"
+
+
+	strcpy(msg, "drop");
+	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table emp", ECPGt_EOIT, ECPGt_EORT);}
+#line 60 "whenever_do_continue.pgc"
+
+
+	exit(0);
+}
diff --git a/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.stderr b/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.stderr
new file mode 100644
index 0000000..b33329b
--- /dev/null
+++ b/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.stderr
@@ -0,0 +1,112 @@
+[NO_PID]: ECPGdebug: set to 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGconnect: opening database ecpg1_regression on <DEFAULT> port <DEFAULT>  
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 26: query: create table emp ( ename varchar , sal double precision , comm double precision ); with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 26: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 26: OK: CREATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 29: query: insert into emp values ( 'Ram' , 111100 , 21 ); with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 29: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 29: OK: INSERT 0 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 30: query: insert into emp values ( 'aryan' , 11110 , null ); with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 30: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 30: OK: INSERT 0 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 31: query: insert into emp values ( 'josh' , 10000 , 10 ); with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 31: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 31: OK: INSERT 0 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 32: query: insert into emp values ( 'tom' , 20000 , null ); with 0 parameter(s) on connection ecpg1_regression
+[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: OK: INSERT 0 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 36: query: declare c cursor for select ename , sal , comm from emp order by ename asc; with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 36: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 36: OK: DECLARE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 46: query: fetch c; with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 46: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 46: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 46: RESULT: aryan offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 46: RESULT: 11110 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 46: RESULT:  offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode -213 on line 46: null value without indicator on line 46
+[NO_PID]: sqlca: code: -213, state: 22002
+[NO_PID]: ecpg_execute on line 46: query: fetch c; with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 46: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 46: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 46: RESULT: josh offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 46: RESULT: 10000 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 46: RESULT: 10 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 46: query: fetch c; with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 46: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 46: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 46: RESULT: Ram offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 46: RESULT: 111100 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 46: RESULT: 21 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 46: query: fetch c; with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 46: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 46: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 46: RESULT: tom offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 46: RESULT: 20000 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 46: RESULT:  offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode -213 on line 46: null value without indicator on line 46
+[NO_PID]: sqlca: code: -213, state: 22002
+[NO_PID]: ecpg_execute on line 46: query: fetch c; with 0 parameter(s) on connection ecpg1_regression
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 46: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 46: correctly got 0 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 46: no data found on line 46
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ecpg_execute on line 57: query: close c; with 0 parameter(s) on connection ecpg1_regression
+[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: OK: CLOSE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 60: query: drop table emp; with 0 parameter(s) on connection ecpg1_regression
+[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_process_output on line 60: OK: DROP TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
diff --git a/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.stdout b/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.stdout
new file mode 100644
index 0000000..75fb6ce
--- /dev/null
+++ b/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.stdout
@@ -0,0 +1,2 @@
+josh 10000.00     10.00
+Ram 111100.00     21.00
diff --git a/src/interfaces/ecpg/test/preproc/Makefile b/src/interfaces/ecpg/test/preproc/Makefile
index d658a4d..39b1974 100644
--- a/src/interfaces/ecpg/test/preproc/Makefile
+++ b/src/interfaces/ecpg/test/preproc/Makefile
@@ -15,6 +15,7 @@ TESTS = array_of_struct array_of_struct.c \
 	type type.c \
 	variable variable.c \
 	whenever whenever.c \
+	whenever_do_continue whenever_do_continue.c \
 	pointer_to_struct pointer_to_struct.c
 
 all: $(TESTS)
diff --git a/src/interfaces/ecpg/test/preproc/whenever_do_continue.pgc b/src/interfaces/ecpg/test/preproc/whenever_do_continue.pgc
new file mode 100644
index 0000000..8ceda69
--- /dev/null
+++ b/src/interfaces/ecpg/test/preproc/whenever_do_continue.pgc
@@ -0,0 +1,63 @@
+#include <stdlib.h>
+
+exec sql include ../regression;
+
+exec sql whenever sqlerror sqlprint;
+
+int main(void)
+{
+	exec sql begin declare section;
+	struct
+	{
+		char ename[12];
+		float sal;
+		float comm;
+	} emp;
+
+	char msg[128];
+	exec sql end declare section;
+
+	ECPGdebug(1, stderr);
+
+	strcpy(msg, "connect");
+	exec sql connect to REGRESSDB1;
+
+	strcpy(msg, "create");
+	exec sql  create table emp(ename varchar,sal double precision, comm double precision);
+
+	strcpy(msg, "insert");
+	exec sql insert into emp values ('Ram',111100,21);
+	exec sql insert into emp values ('aryan',11110,null);
+	exec sql insert into emp values ('josh',10000,10);
+	exec sql insert into emp values ('tom',20000,null);
+
+	exec sql declare c cursor for select ename, sal, comm from emp order by ename asc;
+
+	exec sql open c;
+
+	/* The 'BREAK' condition to exit the loop. */
+	exec sql whenever not found do break;
+
+	/* The DO CONTINUE makes the loop start at the next iteration when an error occurs.*/
+	exec sql whenever sqlerror do continue;
+
+	while (1)
+	{
+		exec sql fetch c into :emp;
+		/* The employees with non-NULL commissions will be displayed. */
+		printf("%s %7.2f %9.2f\n", emp.ename, emp.sal, emp.comm);
+	}
+
+	/*
+	 * This 'CONTINUE' shuts off the 'DO CONTINUE' and allow the program to
+	 * proceed if any further errors do occur.
+	 */
+	exec sql whenever sqlerror continue;
+
+	exec sql close c;
+
+	strcpy(msg, "drop");
+	exec sql drop table emp;
+
+	exit(0);
+}
-- 
1.7.1

#12vinayak
Pokale_Vinayak_q3@lab.ntt.co.jp
In reply to: Masahiko Sawada (#11)
Re: ECPG: WHENEVER statement with DO CONTINUE action

On 2017/08/25 16:18, Masahiko Sawada wrote:

On Fri, Aug 25, 2017 at 2:57 PM, vinayak
<Pokale_Vinayak_q3@lab.ntt.co.jp> wrote:

Hi Sawada-san,

On 2017/08/25 11:07, Masahiko Sawada wrote:

On Fri, Aug 18, 2017 at 5:20 PM, vinayak
<Pokale_Vinayak_q3@lab.ntt.co.jp> wrote:

On 2017/06/20 17:35, vinayak wrote:

Hi Sawada-san,

On 2017/06/20 17:22, Masahiko Sawada wrote:

On Tue, Jun 20, 2017 at 1:51 PM, vinayak
<Pokale_Vinayak_q3@lab.ntt.co.jp> wrote:

On 2017/06/12 13:09, vinayak wrote:

Hi,

On 2017/06/10 12:23, Vinayak Pokale wrote:

Thank you for your reply

On Jun 9, 2017 5:39 PM, "Michael Meskes" <meskes@postgresql.org>
wrote:

Could you please add a "DO CONTINUE" case to one of the test cases?
Or
add a new one? We would need a test case IMO.

Yes I will add test case and send updated patch.

I have added new test case for DO CONTINUE.
Please check the attached patch.

I have added this in Sept. CF
https://commitfest.postgresql.org/14/1173/

------
In whenever_do_continue.pgc file, the following line seems not to be
processed successfully by ecpg but should we fix that?

+
+       exec sql whenever sqlerror continue;
+

Also, you wrote the test case using "WHENEVER sqlerror DO CONTINUE"
action but that seems not to emit sqlerror, so "DO CONTINUE" is not
executed. I think the test case for DO CONTINUE should be a C code
that executes the "continue" clause.

Thank you for testing the patch.
I agreed with your comments. I will update the patch.

Please check the attached updated patch.

Thank you for updating.

The regression test failed after applied latest patch by git am.

***
/tmp/pg/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.c
2017-08-24 20:01:10.023201132 -0700
---
/tmp/pg/src/interfaces/ecpg/test/results/preproc-whenever_do_continue.c
2017-08-24 20:22:54.308200853 -0700
***************
*** 140,147 ****
printf("%s %7.2f %9.2f\n", emp.ename, emp.sal, emp.comm);
}

! /* This 'CONTINUE' shuts off the 'DO CONTINUE' and allow the
program to
! proceed if any further errors do occur. */
/* exec sql whenever sqlerror continue ; */
#line 53 "whenever_do_continue.pgc"

--- 140,147 ----
printf("%s %7.2f %9.2f\n", emp.ename, emp.sal, emp.comm);
}

! /* This 'CONTINUE' shuts off the 'DO CONTINUE' and allow the
program to
! proceed if any further errors do occur. */
/* exec sql whenever sqlerror continue ; */
#line 53 "whenever_do_continue.pgc"

======================================================================

+       /* This 'CONTINUE' shuts off the 'DO CONTINUE' and allow the
program to
+       proceed if any further errors do occur. */

I think this comment should obey the coding style guide.

Thank you for testing.

I have updated the patch.
PFA.

Thank you for updating the patch. It seems not to incorporate my
second review comment. Attached an updated patch including a fix of a
comment style in whenever_do_continue.pgc file. Please find an
attached file.

Sorry, I missed it.
Thank you for fixing the comment style.

Regards,
Vinayak Pokale
NTT Open Source Software Center

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#13Masahiko Sawada
sawada.mshk@gmail.com
In reply to: vinayak (#12)
Re: ECPG: WHENEVER statement with DO CONTINUE action

On Fri, Aug 25, 2017 at 4:27 PM, vinayak
<Pokale_Vinayak_q3@lab.ntt.co.jp> wrote:

On 2017/08/25 16:18, Masahiko Sawada wrote:

On Fri, Aug 25, 2017 at 2:57 PM, vinayak
<Pokale_Vinayak_q3@lab.ntt.co.jp> wrote:

Hi Sawada-san,

On 2017/08/25 11:07, Masahiko Sawada wrote:

On Fri, Aug 18, 2017 at 5:20 PM, vinayak
<Pokale_Vinayak_q3@lab.ntt.co.jp> wrote:

On 2017/06/20 17:35, vinayak wrote:

Hi Sawada-san,

On 2017/06/20 17:22, Masahiko Sawada wrote:

On Tue, Jun 20, 2017 at 1:51 PM, vinayak
<Pokale_Vinayak_q3@lab.ntt.co.jp> wrote:

On 2017/06/12 13:09, vinayak wrote:

Hi,

On 2017/06/10 12:23, Vinayak Pokale wrote:

Thank you for your reply

On Jun 9, 2017 5:39 PM, "Michael Meskes" <meskes@postgresql.org>
wrote:

Could you please add a "DO CONTINUE" case to one of the test cases?
Or
add a new one? We would need a test case IMO.

Yes I will add test case and send updated patch.

I have added new test case for DO CONTINUE.
Please check the attached patch.

I have added this in Sept. CF
https://commitfest.postgresql.org/14/1173/

------
In whenever_do_continue.pgc file, the following line seems not to be
processed successfully by ecpg but should we fix that?

+
+       exec sql whenever sqlerror continue;
+

Also, you wrote the test case using "WHENEVER sqlerror DO CONTINUE"
action but that seems not to emit sqlerror, so "DO CONTINUE" is not
executed. I think the test case for DO CONTINUE should be a C code
that executes the "continue" clause.

Thank you for testing the patch.
I agreed with your comments. I will update the patch.

Please check the attached updated patch.

Thank you for updating.

The regression test failed after applied latest patch by git am.

***
/tmp/pg/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.c
2017-08-24 20:01:10.023201132 -0700
---
/tmp/pg/src/interfaces/ecpg/test/results/preproc-whenever_do_continue.c
2017-08-24 20:22:54.308200853 -0700
***************
*** 140,147 ****
printf("%s %7.2f %9.2f\n", emp.ename, emp.sal,
emp.comm);
}

! /* This 'CONTINUE' shuts off the 'DO CONTINUE' and allow the
program to
! proceed if any further errors do occur. */
/* exec sql whenever sqlerror continue ; */
#line 53 "whenever_do_continue.pgc"

--- 140,147 ----
printf("%s %7.2f %9.2f\n", emp.ename, emp.sal,
emp.comm);
}

! /* This 'CONTINUE' shuts off the 'DO CONTINUE' and allow the
program to
! proceed if any further errors do occur. */
/* exec sql whenever sqlerror continue ; */
#line 53 "whenever_do_continue.pgc"

======================================================================

+       /* This 'CONTINUE' shuts off the 'DO CONTINUE' and allow the
program to
+       proceed if any further errors do occur. */

I think this comment should obey the coding style guide.

Thank you for testing.

I have updated the patch.
PFA.

Thank you for updating the patch. It seems not to incorporate my
second review comment. Attached an updated patch including a fix of a
comment style in whenever_do_continue.pgc file. Please find an
attached file.

Sorry, I missed it.
Thank you for fixing the comment style.

The v3 patch looks good to me. I've changed this patch status to Ready
for Committer.

Regards,

--
Masahiko Sawada
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#14vinayak
Pokale_Vinayak_q3@lab.ntt.co.jp
In reply to: Masahiko Sawada (#13)
Re: ECPG: WHENEVER statement with DO CONTINUE action

On 2017/08/25 17:13, Masahiko Sawada wrote:

On Fri, Aug 25, 2017 at 4:27 PM, vinayak
<Pokale_Vinayak_q3@lab.ntt.co.jp> wrote:

On 2017/08/25 16:18, Masahiko Sawada wrote:

On Fri, Aug 25, 2017 at 2:57 PM, vinayak
<Pokale_Vinayak_q3@lab.ntt.co.jp> wrote:

Hi Sawada-san,

On 2017/08/25 11:07, Masahiko Sawada wrote:

On Fri, Aug 18, 2017 at 5:20 PM, vinayak
<Pokale_Vinayak_q3@lab.ntt.co.jp> wrote:

On 2017/06/20 17:35, vinayak wrote:

Hi Sawada-san,

On 2017/06/20 17:22, Masahiko Sawada wrote:

On Tue, Jun 20, 2017 at 1:51 PM, vinayak
<Pokale_Vinayak_q3@lab.ntt.co.jp> wrote:

On 2017/06/12 13:09, vinayak wrote:

Hi,

On 2017/06/10 12:23, Vinayak Pokale wrote:

Thank you for your reply

On Jun 9, 2017 5:39 PM, "Michael Meskes" <meskes@postgresql.org>
wrote:

Could you please add a "DO CONTINUE" case to one of the test cases?
Or
add a new one? We would need a test case IMO.

Yes I will add test case and send updated patch.

I have added new test case for DO CONTINUE.
Please check the attached patch.

I have added this in Sept. CF
https://commitfest.postgresql.org/14/1173/

------
In whenever_do_continue.pgc file, the following line seems not to be
processed successfully by ecpg but should we fix that?

+
+       exec sql whenever sqlerror continue;
+

Also, you wrote the test case using "WHENEVER sqlerror DO CONTINUE"
action but that seems not to emit sqlerror, so "DO CONTINUE" is not
executed. I think the test case for DO CONTINUE should be a C code
that executes the "continue" clause.

Thank you for testing the patch.
I agreed with your comments. I will update the patch.

Please check the attached updated patch.

Thank you for updating.

The regression test failed after applied latest patch by git am.

***
/tmp/pg/src/interfaces/ecpg/test/expected/preproc-whenever_do_continue.c
2017-08-24 20:01:10.023201132 -0700
---
/tmp/pg/src/interfaces/ecpg/test/results/preproc-whenever_do_continue.c
2017-08-24 20:22:54.308200853 -0700
***************
*** 140,147 ****
printf("%s %7.2f %9.2f\n", emp.ename, emp.sal,
emp.comm);
}

! /* This 'CONTINUE' shuts off the 'DO CONTINUE' and allow the
program to
! proceed if any further errors do occur. */
/* exec sql whenever sqlerror continue ; */
#line 53 "whenever_do_continue.pgc"

--- 140,147 ----
printf("%s %7.2f %9.2f\n", emp.ename, emp.sal,
emp.comm);
}

! /* This 'CONTINUE' shuts off the 'DO CONTINUE' and allow the
program to
! proceed if any further errors do occur. */
/* exec sql whenever sqlerror continue ; */
#line 53 "whenever_do_continue.pgc"

======================================================================

+       /* This 'CONTINUE' shuts off the 'DO CONTINUE' and allow the
program to
+       proceed if any further errors do occur. */

I think this comment should obey the coding style guide.

Thank you for testing.

I have updated the patch.
PFA.

Thank you for updating the patch. It seems not to incorporate my
second review comment. Attached an updated patch including a fix of a
comment style in whenever_do_continue.pgc file. Please find an
attached file.

Sorry, I missed it.
Thank you for fixing the comment style.

The v3 patch looks good to me. I've changed this patch status to Ready
for Committer.

Thank you for updating the status in the CF.
We can wait for committers feedback.

Regards,
Vinayak Pokale
NTT Open Source Software Center

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#15Michael Meskes
meskes@postgresql.org
In reply to: Masahiko Sawada (#13)
Re: ECPG: WHENEVER statement with DO CONTINUE action

The v3 patch looks good to me. I've changed this patch status to Ready
for Committer.

Thank you all, committed.

Michael

--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Meskes at (Debian|Postgresql) dot Org
Jabber: michael at xmpp dot meskes dot org
VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#16Vinayak Pokale
vinpokale@gmail.com
In reply to: Michael Meskes (#15)
Re: ECPG: WHENEVER statement with DO CONTINUE action

On Aug 25, 2017 10:45 PM, "Michael Meskes" <meskes@postgresql.org> wrote:

The v3 patch looks good to me. I've changed this patch status to Ready
for Committer.

Thank you all, committed.

Thank you very much.

Regards,
Vinayak Pokale

#17Christian Ullrich
chris@chrullrich.net
In reply to: Michael Meskes (#15)
Re: ECPG: WHENEVER statement with DO CONTINUE action

* Michael Meskes wrote:

The v3 patch looks good to me. I've changed this patch status to Ready
for Committer.

Thank you all, committed.

The buildfarm says that sorting is frequently done case-sensitively:

*** 1,2 ****
- josh 10000.00     10.00
   Ram 111100.00     21.00
--- 1,2 ----
   Ram 111100.00     21.00
+ josh 10000.00     10.00

--
Christian

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#18Tom Lane
tgl@sss.pgh.pa.us
In reply to: Christian Ullrich (#17)
Re: ECPG: WHENEVER statement with DO CONTINUE action

Christian Ullrich <chris@chrullrich.net> writes:

The buildfarm says that sorting is frequently done case-sensitively:

Given that it's Friday evening in Europe, I'm betting Michael is gone
for the day. In the interests of getting the buildfarm back to green,
I'll see if I can fix this.

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#19Michael Meskes
meskes@postgresql.org
In reply to: Tom Lane (#18)
Re: ECPG: WHENEVER statement with DO CONTINUE action

Given that it's Friday evening in Europe, I'm betting Michael is gone
for the day.  In the interests of getting the buildfarm back to
green,
I'll see if I can fix this.

Correct, thanks Tom.

Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Meskes at (Debian|Postgresql) dot Org
Jabber: michael at xmpp dot meskes dot org
VfL Borussia! Força Barça! SF 49ers! Use Debian GNU/Linux, PostgreSQL

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers