diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/ecpg.addons pgsql/src/interfaces/ecpg/preproc/ecpg.addons *** pgsql.orig/src/interfaces/ecpg/preproc/ecpg.addons 2010-01-26 10:09:40.000000000 +0100 --- pgsql/src/interfaces/ecpg/preproc/ecpg.addons 2010-01-26 18:58:18.000000000 +0100 *************** ECPG: DeclareCursorStmtDECLAREcursor_nam *** 298,304 **** { struct cursor *ptr, *this; char *cursor_marker = $2[0] == ':' ? make_str("$0") : mm_strdup($2); ! char *comment, *c1, *c2; for (ptr = cur; ptr != NULL; ptr = ptr->next) { --- 298,304 ---- { struct cursor *ptr, *this; char *cursor_marker = $2[0] == ':' ? make_str("$0") : mm_strdup($2); ! char *comment, *c1, *c2, *oo1, *oo2; for (ptr = cur; ptr != NULL; ptr = ptr->next) { *************** ECPG: DeclareCursorStmtDECLAREcursor_nam *** 330,346 **** } comment = cat_str(3, make_str("/*"), c1, make_str("*/")); if ((braces_open > 0) && INFORMIX_MODE) /* we're in a function */ ! $$ = cat_str(4, ! adjust_outofscope_cursor_vars(this, true), ! adjust_outofscope_cursor_vars(this, false), make_str("ECPG_informix_reset_sqlca();"), comment); else ! $$ = cat_str(3, ! adjust_outofscope_cursor_vars(this, true), ! adjust_outofscope_cursor_vars(this, false), ! comment); } ECPG: ClosePortalStmtCLOSEcursor_name block { --- 330,344 ---- } comment = cat_str(3, make_str("/*"), c1, make_str("*/")); + oo1 = adjust_outofscope_cursor_vars(this, true); + oo2 = adjust_outofscope_cursor_vars(this, false); + if ((braces_open > 0) && INFORMIX_MODE) /* we're in a function */ ! $$ = cat_str(4, oo1, oo2, make_str("ECPG_informix_reset_sqlca();"), comment); else ! $$ = cat_str(3, oo1, oo2, comment); } ECPG: ClosePortalStmtCLOSEcursor_name block { diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/ecpg.trailer pgsql/src/interfaces/ecpg/preproc/ecpg.trailer *** pgsql.orig/src/interfaces/ecpg/preproc/ecpg.trailer 2010-01-26 10:09:40.000000000 +0100 --- pgsql/src/interfaces/ecpg/preproc/ecpg.trailer 2010-01-26 18:58:20.000000000 +0100 *************** ECPGCursorStmt: DECLARE cursor_name cur *** 291,297 **** char *cursor_marker = $2[0] == ':' ? make_str("$0") : mm_strdup($2); struct variable *thisquery = (struct variable *)mm_alloc(sizeof(struct variable)); const char *con = connection ? connection : "NULL"; ! char *comment; for (ptr = cur; ptr != NULL; ptr = ptr->next) { --- 291,297 ---- char *cursor_marker = $2[0] == ':' ? make_str("$0") : mm_strdup($2); struct variable *thisquery = (struct variable *)mm_alloc(sizeof(struct variable)); const char *con = connection ? connection : "NULL"; ! char *comment, *oo1, *oo2; for (ptr = cur; ptr != NULL; ptr = ptr->next) { *************** ECPGCursorStmt: DECLARE cursor_name cur *** 331,347 **** comment = cat_str(3, make_str("/*"), mm_strdup(this->command), make_str("*/")); if ((braces_open > 0) && INFORMIX_MODE) /* we're in a function */ ! $$ = cat_str(4, ! adjust_outofscope_cursor_vars(this, true), ! adjust_outofscope_cursor_vars(this, false), make_str("ECPG_informix_reset_sqlca();"), comment); else ! $$ = cat_str(3, ! adjust_outofscope_cursor_vars(this, true), ! adjust_outofscope_cursor_vars(this, false), ! comment); } ; --- 331,345 ---- comment = cat_str(3, make_str("/*"), mm_strdup(this->command), make_str("*/")); + oo1 = adjust_outofscope_cursor_vars(this, true); + oo2 = adjust_outofscope_cursor_vars(this, false); + if ((braces_open > 0) && INFORMIX_MODE) /* we're in a function */ ! $$ = cat_str(4, oo1, oo2, make_str("ECPG_informix_reset_sqlca();"), comment); else ! $$ = cat_str(3, oo1, oo2, comment); } ; diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/preproc-cursor.c pgsql/src/interfaces/ecpg/test/expected/preproc-cursor.c *** pgsql.orig/src/interfaces/ecpg/test/expected/preproc-cursor.c 2010-01-26 10:09:40.000000000 +0100 --- pgsql/src/interfaces/ecpg/test/expected/preproc-cursor.c 2010-01-26 19:01:18.000000000 +0100 *************** if (sqlca.sqlcode < 0) exit (1);} *** 287,295 **** /* Dynamic cursorname test with INTO list in DECLARE stmt */ strcpy(msg, "declare"); ! ECPGset_var( 3, &( curname2 ), __LINE__);\ ! ECPGset_var( 1, ( t ), __LINE__);\ ! ECPGset_var( 2, &( id ), __LINE__);\ /* declare $0 cursor for select id , t from t1 */ #line 100 "cursor.pgc" --- 287,295 ---- /* Dynamic cursorname test with INTO list in DECLARE stmt */ strcpy(msg, "declare"); ! ECPGset_var( 1, &( curname2 ), __LINE__);\ ! ECPGset_var( 2, ( t ), __LINE__);\ ! ECPGset_var( 3, &( id ), __LINE__);\ /* declare $0 cursor for select id , t from t1 */ #line 100 "cursor.pgc" diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/preproc-outofscope.c pgsql/src/interfaces/ecpg/test/expected/preproc-outofscope.c *** pgsql.orig/src/interfaces/ecpg/test/expected/preproc-outofscope.c 2010-01-26 11:31:14.000000000 +0100 --- pgsql/src/interfaces/ecpg/test/expected/preproc-outofscope.c 2010-01-26 15:25:31.000000000 +0100 *************** if (sqlca.sqlcode < 0) exit (1);} *** 305,329 **** if (sqlca.sqlcode < 0) exit (1);} #line 85 "outofscope.pgc" ! { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , '\"a\"' , - 1.0 , 'nan' :: float8 , 'a' )", ECPGt_EOIT, ECPGt_EORT); #line 86 "outofscope.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 86 "outofscope.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'b' , 2.0 , 3 , 'b' )", ECPGt_EOIT, ECPGt_EORT); - #line 87 "outofscope.pgc" - - if (sqlca.sqlcode < 0) exit (1);} - #line 87 "outofscope.pgc" - strcpy(msg, "commit"); { ECPGtrans(__LINE__, NULL, "commit"); ! #line 90 "outofscope.pgc" if (sqlca.sqlcode < 0) exit (1);} ! #line 90 "outofscope.pgc" /* Test out-of-scope DECLARE/OPEN/FETCH/CLOSE */ --- 305,323 ---- if (sqlca.sqlcode < 0) exit (1);} #line 85 "outofscope.pgc" ! { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'b' , 2.0 , 3 , 'b' )", ECPGt_EOIT, ECPGt_EORT); #line 86 "outofscope.pgc" if (sqlca.sqlcode < 0) exit (1);} #line 86 "outofscope.pgc" strcpy(msg, "commit"); { ECPGtrans(__LINE__, NULL, "commit"); ! #line 89 "outofscope.pgc" if (sqlca.sqlcode < 0) exit (1);} ! #line 89 "outofscope.pgc" /* Test out-of-scope DECLARE/OPEN/FETCH/CLOSE */ *************** if (sqlca.sqlcode < 0) exit (1);} *** 332,338 **** open_cur1(); /* exec sql whenever not found break ; */ ! #line 97 "outofscope.pgc" while (1) --- 326,332 ---- open_cur1(); /* exec sql whenever not found break ; */ ! #line 96 "outofscope.pgc" while (1) *************** if (sqlca.sqlcode < 0) exit (1);} *** 353,378 **** strcpy(msg, "drop"); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table a1", ECPGt_EOIT, ECPGt_EORT); ! #line 116 "outofscope.pgc" if (sqlca.sqlcode < 0) exit (1);} ! #line 116 "outofscope.pgc" strcpy(msg, "commit"); { ECPGtrans(__LINE__, NULL, "commit"); ! #line 119 "outofscope.pgc" if (sqlca.sqlcode < 0) exit (1);} ! #line 119 "outofscope.pgc" strcpy(msg, "disconnect"); { ECPGdisconnect(__LINE__, "CURRENT"); ! #line 122 "outofscope.pgc" if (sqlca.sqlcode < 0) exit (1);} ! #line 122 "outofscope.pgc" return (0); --- 347,372 ---- strcpy(msg, "drop"); { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table a1", ECPGt_EOIT, ECPGt_EORT); ! #line 115 "outofscope.pgc" if (sqlca.sqlcode < 0) exit (1);} ! #line 115 "outofscope.pgc" strcpy(msg, "commit"); { ECPGtrans(__LINE__, NULL, "commit"); ! #line 118 "outofscope.pgc" if (sqlca.sqlcode < 0) exit (1);} ! #line 118 "outofscope.pgc" strcpy(msg, "disconnect"); { ECPGdisconnect(__LINE__, "CURRENT"); ! #line 121 "outofscope.pgc" if (sqlca.sqlcode < 0) exit (1);} ! #line 121 "outofscope.pgc" return (0); diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/preproc-outofscope.stderr pgsql/src/interfaces/ecpg/test/expected/preproc-outofscope.stderr *** pgsql.orig/src/interfaces/ecpg/test/expected/preproc-outofscope.stderr 2010-01-26 11:31:14.000000000 +0100 --- pgsql/src/interfaces/ecpg/test/expected/preproc-outofscope.stderr 2010-01-26 15:25:32.000000000 +0100 *************** *** 26,44 **** [NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: ecpg_execute on line 85: OK: INSERT 0 1 [NO_PID]: sqlca: code: 0, state: 00000 ! [NO_PID]: ecpg_execute on line 86: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , '"a"' , - 1.0 , 'nan' :: float8 , 'a' ); with 0 parameter(s) on connection regress1 [NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: ecpg_execute on line 86: using PQexec [NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: ecpg_execute on line 86: OK: INSERT 0 1 [NO_PID]: sqlca: code: 0, state: 00000 ! [NO_PID]: ecpg_execute on line 87: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'b' , 2.0 , 3 , 'b' ); with 0 parameter(s) on connection regress1 ! [NO_PID]: sqlca: code: 0, state: 00000 ! [NO_PID]: ecpg_execute on line 87: using PQexec ! [NO_PID]: sqlca: code: 0, state: 00000 ! [NO_PID]: ecpg_execute on line 87: OK: INSERT 0 1 ! [NO_PID]: sqlca: code: 0, state: 00000 ! [NO_PID]: ECPGtrans on line 90: action "commit"; connection "regress1" [NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: ecpg_execute on line 40: query: declare mycur cursor for select * from a1; with 0 parameter(s) on connection regress1 [NO_PID]: sqlca: code: 0, state: 00000 --- 26,38 ---- [NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: ecpg_execute on line 85: OK: INSERT 0 1 [NO_PID]: sqlca: code: 0, state: 00000 ! [NO_PID]: ecpg_execute on line 86: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'b' , 2.0 , 3 , 'b' ); with 0 parameter(s) on connection regress1 [NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: ecpg_execute on line 86: using PQexec [NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: ecpg_execute on line 86: OK: INSERT 0 1 [NO_PID]: sqlca: code: 0, state: 00000 ! [NO_PID]: ECPGtrans on line 89: action "commit"; connection "regress1" [NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: ecpg_execute on line 40: query: declare mycur cursor for select * from a1; with 0 parameter(s) on connection regress1 [NO_PID]: sqlca: code: 0, state: 00000 *************** *** 86,107 **** [NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: ecpg_get_data on line 49: RESULT: 3 offset: -1; array: yes [NO_PID]: sqlca: code: 0, state: 00000 - [NO_PID]: ecpg_get_data on line 49: RESULT: "a" offset: -1; array: yes - [NO_PID]: sqlca: code: 0, state: 00000 - [NO_PID]: ecpg_get_data on line 49: RESULT: -1.0 offset: -1; array: yes - [NO_PID]: sqlca: code: 0, state: 00000 - [NO_PID]: ecpg_get_data on line 49: RESULT: NaN offset: -1; array: yes - [NO_PID]: sqlca: code: 0, state: 00000 - [NO_PID]: ecpg_get_data on line 49: RESULT: a offset: -1; array: yes - [NO_PID]: sqlca: code: 0, state: 00000 - [NO_PID]: ecpg_execute on line 49: query: fetch mycur; with 0 parameter(s) on connection regress1 - [NO_PID]: sqlca: code: 0, state: 00000 - [NO_PID]: ecpg_execute on line 49: using PQexec - [NO_PID]: sqlca: code: 0, state: 00000 - [NO_PID]: ecpg_execute on line 49: correctly got 1 tuples with 5 fields - [NO_PID]: sqlca: code: 0, state: 00000 - [NO_PID]: ecpg_get_data on line 49: RESULT: 4 offset: -1; array: yes - [NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: ecpg_get_data on line 49: RESULT: b offset: -1; array: yes [NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: ecpg_get_data on line 49: RESULT: 2.0 offset: -1; array: yes --- 80,85 ---- *************** *** 124,136 **** [NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: ecpg_execute on line 58: OK: CLOSE CURSOR [NO_PID]: sqlca: code: 0, state: 00000 ! [NO_PID]: ecpg_execute on line 116: query: drop table a1; with 0 parameter(s) on connection regress1 [NO_PID]: sqlca: code: 0, state: 00000 ! [NO_PID]: ecpg_execute on line 116: using PQexec [NO_PID]: sqlca: code: 0, state: 00000 ! [NO_PID]: ecpg_execute on line 116: OK: DROP TABLE [NO_PID]: sqlca: code: 0, state: 00000 ! [NO_PID]: ECPGtrans on line 119: action "commit"; connection "regress1" [NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: ecpg_finish: connection regress1 closed [NO_PID]: sqlca: code: 0, state: 00000 --- 102,114 ---- [NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: ecpg_execute on line 58: OK: CLOSE CURSOR [NO_PID]: sqlca: code: 0, state: 00000 ! [NO_PID]: ecpg_execute on line 115: query: drop table a1; with 0 parameter(s) on connection regress1 [NO_PID]: sqlca: code: 0, state: 00000 ! [NO_PID]: ecpg_execute on line 115: using PQexec [NO_PID]: sqlca: code: 0, state: 00000 ! [NO_PID]: ecpg_execute on line 115: OK: DROP TABLE [NO_PID]: sqlca: code: 0, state: 00000 ! [NO_PID]: ECPGtrans on line 118: action "commit"; connection "regress1" [NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: ecpg_finish: connection regress1 closed [NO_PID]: sqlca: code: 0, state: 00000 diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/preproc-outofscope.stdout pgsql/src/interfaces/ecpg/test/expected/preproc-outofscope.stdout *** pgsql.orig/src/interfaces/ecpg/test/expected/preproc-outofscope.stdout 2010-01-26 11:31:14.000000000 +0100 --- pgsql/src/interfaces/ecpg/test/expected/preproc-outofscope.stdout 2010-01-26 15:25:32.000000000 +0100 *************** *** 1,4 **** id=1 t='a' d1=1.000000 d2=2.000000 c = 'a ' id=2 t='' (NULL) d1=0.000000 (NULL) d2=0.000000 (NULL) c = '' (NULL) ! id=3 t='"a"' d1=-1.000000 d2=nan c = 'a ' ! id=4 t='b' d1=2.000000 d2=3.000000 c = 'b ' --- 1,3 ---- id=1 t='a' d1=1.000000 d2=2.000000 c = 'a ' id=2 t='' (NULL) d1=0.000000 (NULL) d2=0.000000 (NULL) c = '' (NULL) ! id=3 t='b' d1=2.000000 d2=3.000000 c = 'b ' diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/preproc/outofscope.pgc pgsql/src/interfaces/ecpg/test/preproc/outofscope.pgc *** pgsql.orig/src/interfaces/ecpg/test/preproc/outofscope.pgc 2010-01-26 11:31:14.000000000 +0100 --- pgsql/src/interfaces/ecpg/test/preproc/outofscope.pgc 2010-01-26 15:23:51.000000000 +0100 *************** main (void) *** 83,89 **** strcpy(msg, "insert"); exec sql insert into a1(id, t, d1, d2, c) values (default, 'a', 1.0, 2, 'a'); exec sql insert into a1(id, t, d1, d2, c) values (default, null, null, null, null); - exec sql insert into a1(id, t, d1, d2, c) values (default, '"a"', -1.0, 'nan'::float8, 'a'); exec sql insert into a1(id, t, d1, d2, c) values (default, 'b', 2.0, 3, 'b'); strcpy(msg, "commit"); --- 83,88 ----