Skip to content

Commit c7b6593

Browse files
author
Michael Meskes
committed
Fixed bug in Informix define handling.
1 parent f145de2 commit c7b6593

File tree

3 files changed

+41
-9
lines changed

3 files changed

+41
-9
lines changed

src/interfaces/ecpg/ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2229,5 +2229,9 @@ Tue, 14 Aug 2007 11:46:51 +0200
22292229
Wed, 22 Aug 2007 08:41:33 +0200
22302230

22312231
- More cleaning up and removed some duplicates.
2232+
2233+
Wed, 29 Aug 2007 15:41:58 +0200
2234+
2235+
- Fixed bug in Informix define handling.
22322236
- Set ecpg library version to 6.0.
22332237
- Set ecpg version to 4.4.

src/interfaces/ecpg/preproc/ecpg.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.100 2007/08/14 10:01:53 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.101 2007/08/29 13:58:13 meskes Exp $ */
22

33
/* New main for ecpg, the PostgreSQL embedded SQL precompiler. */
44
/* (C) Michael Meskes <meskes@postgresql.org> Feb 5th, 1998 */
@@ -212,11 +212,6 @@ main(int argc, char *const argv[])
212212
char informix_path[MAXPGPATH];
213213

214214
compat = (strcmp(optarg, "INFORMIX") == 0) ? ECPG_COMPAT_INFORMIX : ECPG_COMPAT_INFORMIX_SE;
215-
/* system_includes = true; */
216-
add_preprocessor_define("dec_t=decimal");
217-
add_preprocessor_define("intrvl_t=interval");
218-
add_preprocessor_define("dtime_t=timestamp");
219-
220215
get_pkginclude_path(my_exec_path, pkginclude_path);
221216
snprintf(informix_path, MAXPGPATH, "%s/informix/esql", pkginclude_path);
222217
add_include_path(informix_path);

src/interfaces/ecpg/preproc/pgc.l

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*
1313
*
1414
* IDENTIFICATION
15-
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.154 2007/08/22 08:20:58 meskes Exp $
15+
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.155 2007/08/29 13:58:13 meskes Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -50,6 +50,7 @@ static void parse_include (void);
5050
static void check_escape_warning(void);
5151
static bool ecpg_isspace(char ch);
5252
static bool isdefine(void);
53+
static bool isinformixdefine(void);
5354

5455
char *token_start;
5556
int state_before;
@@ -751,8 +752,10 @@ cppline {space}*#(.*\\{space})*.*{newline}
751752
}
752753
<C>{identifier} {
753754
const ScanKeyword *keyword;
754-
755-
if (INFORMIX_MODE || !isdefine())
755+
756+
/* Informix uses SQL defines only in SQL space */
757+
/* however, some defines have to be taken care of for compatibility */
758+
if ((!INFORMIX_MODE || !isinformixdefine()) && !isdefine())
756759
{
757760
keyword = ScanCKeywordLookup(yytext);
758761
if (keyword != NULL)
@@ -1332,6 +1335,36 @@ static bool isdefine(void)
13321335
return false;
13331336
}
13341337

1338+
static bool isinformixdefine(void)
1339+
{
1340+
const char *new = NULL;
1341+
1342+
if (strcmp(yytext, "dec_t") == 0)
1343+
new = "decimal";
1344+
else if (strcmp(yytext, "intrvl_t") == 0)
1345+
new = "interval";
1346+
else if (strcmp(yytext, "dtime_t") == 0)
1347+
new = "timestamp";
1348+
1349+
if (new)
1350+
{
1351+
struct _yy_buffer *yb;
1352+
1353+
yb = mm_alloc(sizeof(struct _yy_buffer));
1354+
1355+
yb->buffer = YY_CURRENT_BUFFER;
1356+
yb->lineno = yylineno;
1357+
yb->filename = mm_strdup(input_filename);
1358+
yb->next = yy_buffer;
1359+
yy_buffer = yb;
1360+
1361+
yy_scan_string(new);
1362+
return true;
1363+
}
1364+
1365+
return false;
1366+
}
1367+
13351368
/*
13361369
* Called before any actual parsing is done
13371370
*/

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy