Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcf37d68

Browse files
author
Michael Meskes
committed
Made sure sqlca is reset for declare cursor in Informix mode as pointed out by
Böszörményi Zoltán <zb@cybertec.at>.
1 parentc74d8a7 commitcf37d68

File tree

12 files changed

+132
-70
lines changed

12 files changed

+132
-70
lines changed

‎src/interfaces/ecpg/ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2419,5 +2419,11 @@ Fri, 07 Aug 2009 10:41:28 +0200
24192419

24202420
- Added STRING datatype for Informix compatibility mode. This work is
24212421
based on a patch send in by Böszörményi Zoltán <zb@cybertec.at>.
2422+
2423+
Fri, 14 Aug 2009 14:45:02 +0200
2424+
2425+
- Made sure sqlca is reset for declare cursor in Informix mode as
2426+
pointed out by Böszörményi Zoltán <zb@cybertec.at>.
24222427
- Set ecpg library version to 6.2.
2428+
- Set compat library version to 3.2.
24232429
- Set ecpg version to 4.6.

‎src/interfaces/ecpg/compatlib/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
66
# Portions Copyright (c) 1994, Regents of the University of California
77
#
8-
# $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/Makefile,v 1.44 2009/08/07 10:51:20 meskes Exp $
8+
# $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/Makefile,v 1.45 2009/08/14 13:28:22 meskes Exp $
99
#
1010
#-------------------------------------------------------------------------
1111

@@ -15,7 +15,7 @@ include $(top_builddir)/src/Makefile.global
1515

1616
NAME= ecpg_compat
1717
SO_MAJOR_VERSION= 3
18-
SO_MINOR_VERSION=1
18+
SO_MINOR_VERSION=2
1919

2020
overrideCPPFLAGS := -I../include -I$(top_srcdir)/src/interfaces/ecpg/include\
2121
-I$(libpq_srcdir) -I$(top_srcdir)/src/include/utils$(CPPFLAGS)

‎src/interfaces/ecpg/compatlib/exports.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/exports.txt,v 1.4 2007/10/04 17:49:31 meskes Exp $
1+
# $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/exports.txt,v 1.5 2009/08/14 13:28:22 meskes Exp $
22
# Functions to be exported by ecpg_compatlib DLL
33
ECPG_informix_get_var 1
44
ECPG_informix_set_var 2
@@ -41,3 +41,4 @@ rtypwidth 38
4141
rupshift 39
4242
ldchar 40
4343
byleng 41
44+
ECPG_informix_reset_sqlca42

‎src/interfaces/ecpg/compatlib/informix.c

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/informix.c,v 1.59 2009/06/11 14:49:13 momjian Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/informix.c,v 1.60 2009/08/14 13:28:22 meskes Exp $ */
22

33
#definePOSTGRES_ECPG_INTERNAL
44
#include"postgres_fe.h"
@@ -16,6 +16,34 @@
1616
#include<sqlca.h>
1717
#include<ecpgerrno.h>
1818

19+
/* this is also defined in ecpglib/misc.c, by defining it twice we don't have to export the symbol */
20+
21+
staticstructsqlca_tsqlca_init=
22+
{
23+
{
24+
'S','Q','L','C','A',' ',' ',' '
25+
},
26+
sizeof(structsqlca_t),
27+
0,
28+
{
29+
0,
30+
{
31+
0
32+
}
33+
},
34+
{
35+
'N','O','T',' ','S','E','T',' '
36+
},
37+
{
38+
0,0,0,0,0,0
39+
},
40+
{
41+
0,0,0,0,0,0,0,0
42+
},
43+
{
44+
'0','0','0','0','0'
45+
}
46+
};
1947
staticint
2048
deccall2(decimal*arg1,decimal*arg2,int (*ptr) (numeric*,numeric*))
2149
{
@@ -1033,6 +1061,14 @@ ECPG_informix_get_var(int number)
10331061
return (ptr) ?ptr->pointer :NULL;
10341062
}
10351063

1064+
void
1065+
ECPG_informix_reset_sqlca(void)
1066+
{
1067+
structsqlca_t*sqlca=ECPGget_sqlca();
1068+
1069+
memcpy((char*)sqlca, (char*)&sqlca_init,sizeof(structsqlca_t));
1070+
}
1071+
10361072
int
10371073
rsetnull(intt,char*ptr)
10381074
{

‎src/interfaces/ecpg/include/ecpg_informix.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* This file contains stuff needed to be as compatible to Informix as possible.
3-
* $PostgreSQL: pgsql/src/interfaces/ecpg/include/ecpg_informix.h,v 1.22 2008/02/17 18:14:29 meskes Exp $
3+
* $PostgreSQL: pgsql/src/interfaces/ecpg/include/ecpg_informix.h,v 1.23 2009/08/14 13:28:22 meskes Exp $
44
*/
55
#ifndef_ECPG_INFORMIX_H
66
#define_ECPG_INFORMIX_H
@@ -34,7 +34,7 @@ extern"C"
3434
#endif
3535

3636
externintrdatestr(date,char*);
37-
externvoidrtoday(date*);
37+
externvoidrtoday(date*);
3838
externintrjulmdy(date,short*);
3939
externintrdefmtdate(date*,char*,char*);
4040
externintrfmtdate(date,char*,char*);
@@ -49,13 +49,14 @@ extern intrsetnull(int, char *);
4949
externintrtypalign(int,int);
5050
externintrtypmsize(int,int);
5151
externintrtypwidth(int,int);
52-
externvoidrupshift(char*);
52+
externvoidrupshift(char*);
5353

5454
externintbyleng(char*,int);
5555
externvoidldchar(char*,int,char*);
5656

5757
externvoidECPG_informix_set_var(int,void*,int);
5858
externvoid*ECPG_informix_get_var(int);
59+
externvoidECPG_informix_reset_sqlca(void);
5960

6061
/* Informix defines these in decimal.h */
6162
intdecadd(decimal*,decimal*,decimal*);

‎src/interfaces/ecpg/preproc/ecpg.addons

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.addons,v 1.4 2009/01/30 12:53:43 petere Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.addons,v 1.5 2009/08/14 13:28:22 meskes Exp $ */
22

33
ECPG: stmtClosePortalStmt block
44
{
@@ -238,6 +238,7 @@ ECPG: ExecuteStmtEXECUTEprepared_nameexecute_param_clauseexecute_rest block
238238
ECPG: DeclareCursorStmtDECLAREnamecursor_optionsCURSORopt_holdFORSelectStmt block
239239
{
240240
struct cursor *ptr, *this;
241+
char *comment;
241242

242243
for (ptr = cur; ptr != NULL; ptr = ptr->next)
243244
{
@@ -257,10 +258,19 @@ ECPG: DeclareCursorStmtDECLAREnamecursor_optionsCURSORopt_holdFORSelectStmt bloc
257258
argsinsert = argsresult = NULL;
258259
cur = this;
259260

261+
comment = cat_str(3, make_str("/*"), mm_strdup(this->command), make_str("*/"));
262+
260263
if (INFORMIX_MODE)
261-
$$ = cat_str(5, adjust_informix(this->argsinsert), adjust_informix(this->argsresult), make_str("/*"), mm_strdup(this->command), make_str("*/"));
264+
{
265+
if (braces_open > 0) /* we're in a function */
266+
{
267+
$$ = cat_str(4, adjust_informix(this->argsinsert), adjust_informix(this->argsresult), make_str("ECPG_informix_reset_sqlca();"), comment);
268+
}
269+
else
270+
$$ = cat_str(3, adjust_informix(this->argsinsert), adjust_informix(this->argsresult), comment);
271+
}
262272
else
263-
$$ =cat_str(3, make_str("/*"), mm_strdup(this->command), make_str("*/"));
273+
$$ =comment;
264274
}
265275
ECPG: opt_hold block
266276
{

‎src/interfaces/ecpg/preproc/ecpg.trailer

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.trailer,v 1.10 2009/08/07 10:51:20 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.trailer,v 1.11 2009/08/14 13:28:22 meskes Exp $ */
22

33
statements: /*EMPTY*/
44
| statements statement
@@ -318,7 +318,10 @@ ECPGCursorStmt: DECLARE name cursor_options CURSOR opt_hold FOR prepared_name
318318

319319
cur = this;
320320

321-
$$ = cat_str(3, make_str("/*"), mm_strdup(this->command), make_str("*/"));
321+
if (INFORMIX_MODE && braces_open > 0) /* we're in a function */
322+
$$ = cat_str(4, make_str("ECPG_informix_reset_sqlca();"), make_str("/*"), mm_strdup(this->command), make_str("*/"));
323+
else
324+
$$ = cat_str(3, make_str("/*"), mm_strdup(this->command), make_str("*/"));
322325
}
323326
;
324327

‎src/interfaces/ecpg/test/compat_informix/test_informix.pgc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ int main(void)
4545
printf("SELECT: %ld=%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
4646
if (sqlca.sqlcode != 0) $rollback;
4747

48+
sqlca.sqlcode = 100;
4849
$declare c cursor for select * from test where i <= :i;
50+
printf ("%ld\n", sqlca.sqlcode);
4951
openit();
5052

5153
deccvint(0, &j);

‎src/interfaces/ecpg/test/expected/compat_informix-test_informix.c

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,12 @@ if (sqlca.sqlcode < 0) dosqlprint ( );}
146146
#line 46 "test_informix.pgc"
147147

148148

149+
sqlca.sqlcode=100;
149150
ECPG_informix_set_var(0,&(i ),__LINE__);\
150-
/* declare c cursor for select * from test where i <= $1 */
151-
#line48 "test_informix.pgc"
151+
ECPG_informix_reset_sqlca();/* declare c cursor for select * from test where i <= $1 */
152+
#line49 "test_informix.pgc"
152153

154+
printf ("%ld\n",sqlca.sqlcode);
153155
openit();
154156

155157
deccvint(0,&j);
@@ -163,10 +165,10 @@ if (sqlca.sqlcode < 0) dosqlprint ( );}
163165
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,
164166
ECPGt_string,(c),(long)10,(long)1,(10)*sizeof(char),
165167
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,ECPGt_EORT);
166-
#line55 "test_informix.pgc"
168+
#line57 "test_informix.pgc"
167169

168170
if (sqlca.sqlcode<0)dosqlprint ( );}
169-
#line55 "test_informix.pgc"
171+
#line57 "test_informix.pgc"
170172

171173
if (sqlca.sqlcode==100)break;
172174
elseif (sqlca.sqlcode!=0)printf ("Error: %ld\n",sqlca.sqlcode);
@@ -188,53 +190,53 @@ if (sqlca.sqlcode < 0) dosqlprint ( );}
188190
{ECPGdo(__LINE__,1,1,NULL,0,ECPGst_normal,"delete from test where i = $1 :: decimal",
189191
ECPGt_decimal,&(n),(long)1,(long)1,sizeof(decimal),
190192
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,ECPGt_EOIT,ECPGt_EORT);
191-
#line73 "test_informix.pgc"
193+
#line75 "test_informix.pgc"
192194

193195
if (sqlca.sqlcode<0)dosqlprint ( );}
194-
#line73 "test_informix.pgc"
196+
#line75 "test_informix.pgc"
195197

196198
printf("DELETE: %ld\n",sqlca.sqlcode);
197199

198200
{ECPGdo(__LINE__,1,1,NULL,0,ECPGst_normal,"select 1 from test where i = 14",ECPGt_EOIT,ECPGt_EORT);
199-
#line76 "test_informix.pgc"
201+
#line78 "test_informix.pgc"
200202

201203
if (sqlca.sqlcode<0)dosqlprint ( );}
202-
#line76 "test_informix.pgc"
204+
#line78 "test_informix.pgc"
203205

204206
printf("Exists: %ld\n",sqlca.sqlcode);
205207

206208
{ECPGdo(__LINE__,1,1,NULL,0,ECPGst_normal,"select 1 from test where i = 147",ECPGt_EOIT,ECPGt_EORT);
207-
#line79 "test_informix.pgc"
209+
#line81 "test_informix.pgc"
208210

209211
if (sqlca.sqlcode<0)dosqlprint ( );}
210-
#line79 "test_informix.pgc"
212+
#line81 "test_informix.pgc"
211213

212214
printf("Does not exist: %ld\n",sqlca.sqlcode);
213215

214216
{ECPGtrans(__LINE__,NULL,"commit");
215-
#line82 "test_informix.pgc"
217+
#line84 "test_informix.pgc"
216218

217219
if (sqlca.sqlcode<0)dosqlprint ( );}
218-
#line82 "test_informix.pgc"
220+
#line84 "test_informix.pgc"
219221

220222
{ECPGdo(__LINE__,1,1,NULL,0,ECPGst_normal,"drop table test",ECPGt_EOIT,ECPGt_EORT);
221-
#line83 "test_informix.pgc"
223+
#line85 "test_informix.pgc"
222224

223225
if (sqlca.sqlcode<0)dosqlprint ( );}
224-
#line83 "test_informix.pgc"
226+
#line85 "test_informix.pgc"
225227

226228
{ECPGtrans(__LINE__,NULL,"commit");
227-
#line84 "test_informix.pgc"
229+
#line86 "test_informix.pgc"
228230

229231
if (sqlca.sqlcode<0)dosqlprint ( );}
230-
#line84 "test_informix.pgc"
232+
#line86 "test_informix.pgc"
231233

232234

233235
{ECPGdisconnect(__LINE__,"CURRENT");
234-
#line86 "test_informix.pgc"
236+
#line88 "test_informix.pgc"
235237

236238
if (sqlca.sqlcode<0)dosqlprint ( );}
237-
#line86 "test_informix.pgc"
239+
#line88 "test_informix.pgc"
238240

239241

240242
return0;
@@ -245,10 +247,10 @@ static void openit(void)
245247
{ECPGdo(__LINE__,1,1,NULL,0,ECPGst_normal,"declare c cursor for select * from test where i <= $1 ",
246248
ECPGt_int,&(*(int*)(ECPG_informix_get_var(0))),(long)1,(long)1,sizeof(int),
247249
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,ECPGt_EOIT,ECPGt_EORT);
248-
#line93 "test_informix.pgc"
250+
#line95 "test_informix.pgc"
249251

250252
if (sqlca.sqlcode<0)dosqlprint ( );}
251-
#line93 "test_informix.pgc"
253+
#line95 "test_informix.pgc"
252254

253255
}
254256

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp