Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2cbaaee

Browse files
author
Michael Meskes
committed
Just another Informix compatibility change. They uses "free" for cursors as wellafter closing them.
1 parent d9b2401 commit 2cbaaee

File tree

7 files changed

+36
-5
lines changed

7 files changed

+36
-5
lines changed

src/interfaces/ecpg/ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,6 +1505,10 @@ Thu Jun 19 10:08:26 CEST 2003
15051505
Fri Jun 20 13:23:07 CEST 2003
15061506

15071507
- Enabled constants in using clause.
1508+
1509+
Fri Jun 20 15:34:29 CEST 2003
1510+
1511+
- For Informix compatibility we have to accept a "free <cursor>".
15081512
- Set ecpg version to 3.0.0
15091513
- Set ecpg library to 4.0.0
15101514
- Set pgtypes library to 1.0.0

src/interfaces/ecpg/compatlib/informix.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,16 @@ ECPGconnect_informix(int lineno, const char *name, const char *user, const char
695695
return (ECPGconnect(lineno, informix_name, user, passwd, connection_name , autocommit));
696696
}
697697

698+
bool
699+
ECPGdeallocate_informix(int lineno, char *name)
700+
{
701+
ECPGdeallocate_one(lineno, name);
702+
703+
/* Just ignore all errors since we do not know the list of cursors we
704+
* are allowed to free. We have to trust that the software. */
705+
return true;
706+
}
707+
698708
static struct var_list
699709
{
700710
int number;

src/interfaces/ecpg/ecpglib/prepare.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.2 2003/06/15 04:07:58 momjian Exp $ */
1+
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.3 2003/06/20 13:36:34 meskes Exp $ */
22

33
#define POSTGRES_ECPG_INTERNAL
44
#include "postgres_fe.h"
@@ -106,6 +106,18 @@ ECPGprepare(int lineno, char *name, char *variable)
106106
/* handle the EXEC SQL DEALLOCATE PREPARE statement */
107107
bool
108108
ECPGdeallocate(int lineno, char *name)
109+
{
110+
bool ret = ECPGdeallocate_one(lineno, name);
111+
112+
if (!ret)
113+
ECPGraise(lineno, ECPG_INVALID_STMT, name);
114+
115+
return ret;
116+
117+
}
118+
119+
bool
120+
ECPGdeallocate_one(int lineno, char *name)
109121
{
110122
struct prepared_statement *this,
111123
*prev;
@@ -126,7 +138,6 @@ ECPGdeallocate(int lineno, char *name)
126138
ECPGfree(this);
127139
return true;
128140
}
129-
ECPGraise(lineno, ECPG_INVALID_STMT, name);
130141
return false;
131142
}
132143

src/interfaces/ecpg/include/ecpg_informix.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,6 @@ extern int byleng(char *, int);
3434
extern void ldchar(char *, int, char *);
3535

3636
extern bool ECPGconnect_informix(int, const char *, const char *, const char *, const char *, int);
37+
extern bool ECPGdeallocate_informix(int, char *);
3738
extern void ECPG_informix_set_var(int, void *, int);
3839
extern void *ECPG_informix_get_var(int);

src/interfaces/ecpg/include/ecpglib.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ bool ECPGtrans(int, const char *, const char *);
5151
bool ECPGdisconnect(int, const char *);
5252
bool ECPGprepare(int, char *, char *);
5353
bool ECPGdeallocate(int, char *);
54+
bool ECPGdeallocate_one(int, char *);
5455
bool ECPGdeallocate_all(int);
5556
char *ECPGprepared_statement(char *);
5657

src/interfaces/ecpg/preproc/preproc.y

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.235 2003/06/20 12:00:59 meskes Exp $ */
1+
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.236 2003/06/20 13:36:34 meskes Exp $ */
22

33
/* Copyright comment */
44
%{
@@ -674,7 +674,10 @@ stmt: AlterDatabaseSetStmt { output_statement($1, 0, connection); }
674674
}
675675
| ECPGFree
676676
{
677-
fprintf(yyout, "{ ECPGdeallocate(__LINE__, \"%s\");", $1);
677+
if (compat == ECPG_COMPAT_INFORMIX)
678+
fprintf(yyout, "{ ECPGdeallocate_informix(__LINE__, \"%s\");", $1);
679+
else
680+
fprintf(yyout, "{ ECPGdeallocate(__LINE__, \"%s\");", $1);
678681

679682
whenever_action(2);
680683
free($1);

src/interfaces/ecpg/test/test4.pgc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ EXEC SQL BEGIN DECLARE SECTION;
1313
int *did = &i;
1414
int a[10] = {9,8,7,6,5,4,3,2,1,0};
1515
char text[10] = "klmnopqrst";
16-
char *t = "uvwxyz1234";
16+
char *t = (char *)malloc(10);
1717
double f;
1818
bool b = true;
1919
varchar database[3];
2020
EXEC SQL END DECLARE SECTION;
2121
FILE *dbgs;
2222

23+
strcpy(t, "0123456789");
2324
setlocale(LC_ALL, "de_DE");
2425

2526
if ((dbgs = fopen("log", "w")) != NULL)

0 commit comments

Comments
 (0)