Böszörményi Zoltán <zb@cybertec.at>.
- Added STRING datatype for Informix compatibility mode. This work is
based on a patch send in by Böszörményi Zoltán <zb@cybertec.at>.
+
+Fri, 14 Aug 2009 14:45:02 +0200
+
+ - Made sure sqlca is reset for declare cursor in Informix mode as
+ pointed out by Böszörményi Zoltán <zb@cybertec.at>.
- Set ecpg library version to 6.2.
+ - Set compat library version to 3.2.
- Set ecpg version to 4.6.
# Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
# Portions Copyright (c) 1994, Regents of the University of California
#
-# $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/Makefile,v 1.44 2009/08/07 10:51:20 meskes Exp $
+# $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/Makefile,v 1.45 2009/08/14 13:28:22 meskes Exp $
#
#-------------------------------------------------------------------------
NAME= ecpg_compat
SO_MAJOR_VERSION= 3
-SO_MINOR_VERSION= 1
+SO_MINOR_VERSION= 2
override CPPFLAGS := -I../include -I$(top_srcdir)/src/interfaces/ecpg/include \
-I$(libpq_srcdir) -I$(top_srcdir)/src/include/utils $(CPPFLAGS)
-# $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/exports.txt,v 1.4 2007/10/04 17:49:31 meskes Exp $
+# $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/exports.txt,v 1.5 2009/08/14 13:28:22 meskes Exp $
# Functions to be exported by ecpg_compatlib DLL
ECPG_informix_get_var 1
ECPG_informix_set_var 2
rupshift 39
ldchar 40
byleng 41
+ECPG_informix_reset_sqlca 42
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/informix.c,v 1.59 2009/06/11 14:49:13 momjian Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/informix.c,v 1.60 2009/08/14 13:28:22 meskes Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
#include <sqlca.h>
#include <ecpgerrno.h>
+/* this is also defined in ecpglib/misc.c, by defining it twice we don't have to export the symbol */
+
+static struct sqlca_t sqlca_init =
+{
+ {
+ 'S', 'Q', 'L', 'C', 'A', ' ', ' ', ' '
+ },
+ sizeof(struct sqlca_t),
+ 0,
+ {
+ 0,
+ {
+ 0
+ }
+ },
+ {
+ 'N', 'O', 'T', ' ', 'S', 'E', 'T', ' '
+ },
+ {
+ 0, 0, 0, 0, 0, 0
+ },
+ {
+ 0, 0, 0, 0, 0, 0, 0, 0
+ },
+ {
+ '0', '0', '0', '0', '0'
+ }
+};
static int
deccall2(decimal *arg1, decimal *arg2, int (*ptr) (numeric *, numeric *))
{
return (ptr) ? ptr->pointer : NULL;
}
+void
+ECPG_informix_reset_sqlca(void)
+{
+ struct sqlca_t *sqlca = ECPGget_sqlca();
+
+ memcpy((char *) sqlca, (char *) &sqlca_init, sizeof(struct sqlca_t));
+}
+
int
rsetnull(int t, char *ptr)
{
/*
* This file contains stuff needed to be as compatible to Informix as possible.
- * $PostgreSQL: pgsql/src/interfaces/ecpg/include/ecpg_informix.h,v 1.22 2008/02/17 18:14:29 meskes Exp $
+ * $PostgreSQL: pgsql/src/interfaces/ecpg/include/ecpg_informix.h,v 1.23 2009/08/14 13:28:22 meskes Exp $
*/
#ifndef _ECPG_INFORMIX_H
#define _ECPG_INFORMIX_H
#endif
extern int rdatestr(date, char *);
-extern void rtoday(date *);
+extern void rtoday(date *);
extern int rjulmdy(date, short *);
extern int rdefmtdate(date *, char *, char *);
extern int rfmtdate(date, char *, char *);
extern int rtypalign(int, int);
extern int rtypmsize(int, int);
extern int rtypwidth(int, int);
-extern void rupshift(char *);
+extern void rupshift(char *);
extern int byleng(char *, int);
extern void ldchar(char *, int, char *);
extern void ECPG_informix_set_var(int, void *, int);
extern void *ECPG_informix_get_var(int);
+extern void ECPG_informix_reset_sqlca(void);
/* Informix defines these in decimal.h */
int decadd(decimal *, decimal *, decimal *);
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.addons,v 1.4 2009/01/30 12:53:43 petere Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.addons,v 1.5 2009/08/14 13:28:22 meskes Exp $ */
ECPG: stmtClosePortalStmt block
{
ECPG: DeclareCursorStmtDECLAREnamecursor_optionsCURSORopt_holdFORSelectStmt block
{
struct cursor *ptr, *this;
+ char *comment;
for (ptr = cur; ptr != NULL; ptr = ptr->next)
{
argsinsert = argsresult = NULL;
cur = this;
+ comment = cat_str(3, make_str("/*"), mm_strdup(this->command), make_str("*/"));
+
if (INFORMIX_MODE)
- $$ = cat_str(5, adjust_informix(this->argsinsert), adjust_informix(this->argsresult), make_str("/*"), mm_strdup(this->command), make_str("*/"));
+ {
+ if (braces_open > 0) /* we're in a function */
+ {
+ $$ = cat_str(4, adjust_informix(this->argsinsert), adjust_informix(this->argsresult), make_str("ECPG_informix_reset_sqlca();"), comment);
+ }
+ else
+ $$ = cat_str(3, adjust_informix(this->argsinsert), adjust_informix(this->argsresult), comment);
+ }
else
- $$ = cat_str(3, make_str("/*"), mm_strdup(this->command), make_str("*/"));
+ $$ = comment;
}
ECPG: opt_hold block
{
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.trailer,v 1.10 2009/08/07 10:51:20 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.trailer,v 1.11 2009/08/14 13:28:22 meskes Exp $ */
statements: /*EMPTY*/
| statements statement
cur = this;
- $$ = cat_str(3, make_str("/*"), mm_strdup(this->command), make_str("*/"));
+ if (INFORMIX_MODE && braces_open > 0) /* we're in a function */
+ $$ = cat_str(4, make_str("ECPG_informix_reset_sqlca();"), make_str("/*"), mm_strdup(this->command), make_str("*/"));
+ else
+ $$ = cat_str(3, make_str("/*"), mm_strdup(this->command), make_str("*/"));
}
;
printf("SELECT: %ld=%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
if (sqlca.sqlcode != 0) $rollback;
+ sqlca.sqlcode = 100;
$declare c cursor for select * from test where i <= :i;
+ printf ("%ld\n", sqlca.sqlcode);
openit();
deccvint(0, &j);
#line 46 "test_informix.pgc"
+ sqlca.sqlcode = 100;
ECPG_informix_set_var( 0, &( i ), __LINE__);\
- /* declare c cursor for select * from test where i <= $1 */
-#line 48 "test_informix.pgc"
+ ECPG_informix_reset_sqlca(); /* declare c cursor for select * from test where i <= $1 */
+#line 49 "test_informix.pgc"
+ printf ("%ld\n", sqlca.sqlcode);
openit();
deccvint(0, &j);
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_string,(c),(long)10,(long)1,(10)*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
-#line 55 "test_informix.pgc"
+#line 57 "test_informix.pgc"
if (sqlca.sqlcode < 0) dosqlprint ( );}
-#line 55 "test_informix.pgc"
+#line 57 "test_informix.pgc"
if (sqlca.sqlcode == 100) break;
else if (sqlca.sqlcode != 0) printf ("Error: %ld\n", sqlca.sqlcode);
{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "delete from test where i = $1 :: decimal",
ECPGt_decimal,&(n),(long)1,(long)1,sizeof(decimal),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
-#line 73 "test_informix.pgc"
+#line 75 "test_informix.pgc"
if (sqlca.sqlcode < 0) dosqlprint ( );}
-#line 73 "test_informix.pgc"
+#line 75 "test_informix.pgc"
printf("DELETE: %ld\n", sqlca.sqlcode);
{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "select 1 from test where i = 14", ECPGt_EOIT, ECPGt_EORT);
-#line 76 "test_informix.pgc"
+#line 78 "test_informix.pgc"
if (sqlca.sqlcode < 0) dosqlprint ( );}
-#line 76 "test_informix.pgc"
+#line 78 "test_informix.pgc"
printf("Exists: %ld\n", sqlca.sqlcode);
{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "select 1 from test where i = 147", ECPGt_EOIT, ECPGt_EORT);
-#line 79 "test_informix.pgc"
+#line 81 "test_informix.pgc"
if (sqlca.sqlcode < 0) dosqlprint ( );}
-#line 79 "test_informix.pgc"
+#line 81 "test_informix.pgc"
printf("Does not exist: %ld\n", sqlca.sqlcode);
{ ECPGtrans(__LINE__, NULL, "commit");
-#line 82 "test_informix.pgc"
+#line 84 "test_informix.pgc"
if (sqlca.sqlcode < 0) dosqlprint ( );}
-#line 82 "test_informix.pgc"
+#line 84 "test_informix.pgc"
{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "drop table test", ECPGt_EOIT, ECPGt_EORT);
-#line 83 "test_informix.pgc"
+#line 85 "test_informix.pgc"
if (sqlca.sqlcode < 0) dosqlprint ( );}
-#line 83 "test_informix.pgc"
+#line 85 "test_informix.pgc"
{ ECPGtrans(__LINE__, NULL, "commit");
-#line 84 "test_informix.pgc"
+#line 86 "test_informix.pgc"
if (sqlca.sqlcode < 0) dosqlprint ( );}
-#line 84 "test_informix.pgc"
+#line 86 "test_informix.pgc"
{ ECPGdisconnect(__LINE__, "CURRENT");
-#line 86 "test_informix.pgc"
+#line 88 "test_informix.pgc"
if (sqlca.sqlcode < 0) dosqlprint ( );}
-#line 86 "test_informix.pgc"
+#line 88 "test_informix.pgc"
return 0;
{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare c cursor for select * from test where i <= $1 ",
ECPGt_int,&(*( int *)(ECPG_informix_get_var( 0))),(long)1,(long)1,sizeof(int),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
-#line 93 "test_informix.pgc"
+#line 95 "test_informix.pgc"
if (sqlca.sqlcode < 0) dosqlprint ( );}
-#line 93 "test_informix.pgc"
+#line 95 "test_informix.pgc"
}
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 44: correctly got 1 tuples with 1 fields
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 93: query: declare c cursor for select * from test where i <= $1 ; with 1 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 95: query: declare c cursor for select * from test where i <= $1 ; with 1 parameter(s) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 93: using PQexecParams
+[NO_PID]: ecpg_execute on line 95: using PQexecParams
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: free_params on line 93: parameter 1 = 14
+[NO_PID]: free_params on line 95: parameter 1 = 14
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 93: OK: DECLARE CURSOR
+[NO_PID]: ecpg_execute on line 95: OK: DECLARE CURSOR
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 55: query: fetch forward from c; with 0 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 57: query: fetch forward from c; with 0 parameter(s) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 55: using PQexec
+[NO_PID]: ecpg_execute on line 57: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 55: correctly got 1 tuples with 3 fields
+[NO_PID]: ecpg_execute on line 57: correctly got 1 tuples with 3 fields
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_get_data on line 55: RESULT: 7 offset: -1; array: yes
+[NO_PID]: ecpg_get_data on line 57: RESULT: 7 offset: -1; array: yes
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_get_data on line 55: RESULT: 0 offset: -1; array: yes
+[NO_PID]: ecpg_get_data on line 57: RESULT: 0 offset: -1; array: yes
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_get_data on line 55: RESULT: test offset: -1; array: yes
+[NO_PID]: ecpg_get_data on line 57: RESULT: test offset: -1; array: yes
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 55: query: fetch forward from c; with 0 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 57: query: fetch forward from c; with 0 parameter(s) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 55: using PQexec
+[NO_PID]: ecpg_execute on line 57: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 55: correctly got 1 tuples with 3 fields
+[NO_PID]: ecpg_execute on line 57: correctly got 1 tuples with 3 fields
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_get_data on line 55: RESULT: 14 offset: -1; array: yes
+[NO_PID]: ecpg_get_data on line 57: RESULT: 14 offset: -1; array: yes
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_get_data on line 55: RESULT: 1 offset: -1; array: yes
+[NO_PID]: ecpg_get_data on line 57: RESULT: 1 offset: -1; array: yes
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_get_data on line 55: RESULT: a offset: -1; array: yes
+[NO_PID]: ecpg_get_data on line 57: RESULT: a offset: -1; array: yes
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 55: query: fetch forward from c; with 0 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 57: query: fetch forward from c; with 0 parameter(s) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 55: using PQexec
+[NO_PID]: ecpg_execute on line 57: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 55: correctly got 0 tuples with 3 fields
+[NO_PID]: ecpg_execute on line 57: correctly got 0 tuples with 3 fields
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: raising sqlcode 100 on line 55: no data found on line 55
+[NO_PID]: raising sqlcode 100 on line 57: no data found on line 57
[NO_PID]: sqlca: code: 100, state: 02000
-[NO_PID]: ecpg_execute on line 73: query: delete from test where i = $1 :: decimal; with 1 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 75: query: delete from test where i = $1 :: decimal; with 1 parameter(s) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 73: using PQexecParams
+[NO_PID]: ecpg_execute on line 75: using PQexecParams
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: free_params on line 73: parameter 1 = 21.0
+[NO_PID]: free_params on line 75: parameter 1 = 21.0
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 73: OK: DELETE 0
+[NO_PID]: ecpg_execute on line 75: OK: DELETE 0
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: raising sqlcode 100 on line 73: no data found on line 73
+[NO_PID]: raising sqlcode 100 on line 75: no data found on line 75
[NO_PID]: sqlca: code: 100, state: 02000
-[NO_PID]: ecpg_execute on line 76: query: select 1 from test where i = 14; with 0 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 78: query: select 1 from test where i = 14; with 0 parameter(s) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 76: using PQexec
+[NO_PID]: ecpg_execute on line 78: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 76: correctly got 1 tuples with 1 fields
+[NO_PID]: ecpg_execute on line 78: correctly got 1 tuples with 1 fields
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 79: query: select 1 from test where i = 147; with 0 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 81: query: select 1 from test where i = 147; with 0 parameter(s) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 79: using PQexec
+[NO_PID]: ecpg_execute on line 81: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 79: correctly got 0 tuples with 1 fields
+[NO_PID]: ecpg_execute on line 81: correctly got 0 tuples with 1 fields
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: raising sqlcode 100 on line 79: no data found on line 79
+[NO_PID]: raising sqlcode 100 on line 81: no data found on line 81
[NO_PID]: sqlca: code: 100, state: 02000
-[NO_PID]: ECPGtrans on line 82: action "commit"; connection "regress1"
+[NO_PID]: ECPGtrans on line 84: action "commit"; connection "regress1"
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 83: query: drop table test; with 0 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 85: query: drop table test; with 0 parameter(s) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 83: using PQexec
+[NO_PID]: ecpg_execute on line 85: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 83: OK: DROP TABLE
+[NO_PID]: ecpg_execute on line 85: OK: DROP TABLE
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGtrans on line 84: action "commit"; connection "regress1"
+[NO_PID]: ECPGtrans on line 86: 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
INSERT: -239=duplicate key value violates unique constraint "test_pkey" on line 32
doSQLprint: Error: more than one row returned by a subquery used as an expression on line 40
SELECT: 0=
+0
7 0 "test"
14 1 "a"
DELETE: 100
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: raising sqlcode -402 on line 53: could not connect to database "nonexistant" on line 53
[NO_PID]: sqlca: code: -402, state: 08001
-[NO_PID]: raising sqlcode -220 on line 54: no such connection CURRENT on line 54
+[NO_PID]: raising sqlcode -220 on line 54: connection "CURRENT" does not exist on line 54
[NO_PID]: sqlca: code: -220, state: 08003
[NO_PID]: ECPGconnect: opening database connectdb on localhost port <REGRESSION_PORT> for user connectuser
[NO_PID]: sqlca: code: 0, state: 00000