On Tue, Aug 28, 2007 at 10:59:42AM -0400, Paul Tilles wrote:
> We have upgraded from Version 7.4.x to Version 8.2.4.
> In 7.4.x, we use the Informix compatibility functionality to use legacy
> code.
> Our .pgc code looks as follows:
> ...
This is indeed a bug. Thanks for reporting it.
What happens is that ecpg defines the data types, but does not use that
define while in C code. I just committed patches to CVS. I also attach
it here. Could you please try if this fixes your problem?
Thanks.
Michael
--
Michael Meskes
Email: Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: [EMAIL PROTECTED]
Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!
--- preproc/ecpg.c 8 Feb 2006 09:10:04 -0000 1.94
+++ preproc/ecpg.c 29 Aug 2007 13:50:55 -0000
@@ -185,11 +185,6 @@
char informix_path[MAXPGPATH];
compat = (strcmp(optarg, "INFORMIX") == 0) ? ECPG_COMPAT_INFORMIX : ECPG_COMPAT_INFORMIX_SE;
- /* system_includes = true; */
- add_preprocessor_define("dec_t=decimal");
- add_preprocessor_define("intrvl_t=interval");
- add_preprocessor_define("dtime_t=timestamp");
-
get_pkginclude_path(my_exec_path, pkginclude_path);
snprintf(informix_path, MAXPGPATH, "%s/informix/esql", pkginclude_path);
add_include_path(informix_path);
--- preproc/pgc.l 22 Sep 2006 21:39:58 -0000 1.150
+++ preproc/pgc.l 29 Aug 2007 13:50:55 -0000
@@ -48,6 +48,8 @@
static void parse_include (void);
static void check_escape_warning(void);
static bool ecpg_isspace(char ch);
+static bool isdefine(void);
+static bool isinformixdefine(void);
char *token_start;
int state_before;
@@ -671,29 +673,8 @@
}
<SQL>{identifier} {
ScanKeyword *keyword;
- struct _defines *ptr;
-
- /* How about a DEFINE? */
- for (ptr = defines; ptr; ptr = ptr->next)
- {
- if (strcmp(yytext, ptr->old) == 0 && ptr->used == NULL)
- {
- struct _yy_buffer *yb;
-
- yb = mm_alloc(sizeof(struct _yy_buffer));
-
- yb->buffer = YY_CURRENT_BUFFER;
- yb->lineno = yylineno;
- yb->filename = mm_strdup(input_filename);
- yb->next = yy_buffer;
-
- ptr->used = yy_buffer = yb;
- yy_scan_string(ptr->new);
- break;
- }
- }
- if (ptr == NULL)
+ if (!isdefine())
{
/* Is it an SQL keyword? */
keyword = ScanKeywordLookup(yytext);
@@ -765,38 +746,10 @@
}
<C>{identifier} {
ScanKeyword *keyword;
- struct _defines *ptr;
-
- if (INFORMIX_MODE)
- {
- /* Informix uses SQL defines only in SQL space */
- ptr = NULL;
- }
- else
- {
- /* is it a define? */
- for (ptr = defines; ptr; ptr = ptr->next)
- {
- if (strcmp(yytext, ptr->old) == 0 && ptr->used == NULL)
- {
- struct _yy_buffer *yb;
-
- yb = mm_alloc(sizeof(struct _yy_buffer));
- yb->buffer = YY_CURRENT_BUFFER;
- yb->lineno = yylineno;
- yb->filename = mm_strdup(input_filename);
- yb->next = yy_buffer;
-
- ptr->used = yy_buffer = yb;
-
- yy_scan_string(ptr->new);
- break;
- }
- }
- }
-
- if (ptr == NULL)
+ /* Informix uses SQL defines only in SQL space */
+ /* however, some defines have to be taken care of for compatibility */
+ if ((!INFORMIX_MODE || !isinformixdefine()) && !isdefine())
{
keyword = ScanCKeywordLookup(yytext);
if (keyword != NULL)
@@ -1347,3 +1300,61 @@
return true;
return false;
}
+
+static bool isdefine(void)
+{
+ struct _defines *ptr;
+
+ /* is it a define? */
+ for (ptr = defines; ptr; ptr = ptr->next)
+ {
+ if (strcmp(yytext, ptr->old) == 0 && ptr->used == NULL)
+ {
+ struct _yy_buffer *yb;
+
+ yb = mm_alloc(sizeof(struct _yy_buffer));
+
+ yb->buffer = YY_CURRENT_BUFFER;
+ yb->lineno = yylineno;
+ yb->filename = mm_strdup(input_filename);
+ yb->next = yy_buffer;
+
+ ptr->used = yy_buffer = yb;
+
+ yy_scan_string(ptr->new);
+ return true;
+ }
+ }
+
+ return false;
+}
+
+static bool isinformixdefine(void)
+{
+ const char *new = NULL;
+
+ if (strcmp(yytext, "dec_t") == 0)
+ new = "decimal";
+ else if (strcmp(yytext, "intrvl_t") == 0)
+ new = "interval";
+ else if (strcmp(yytext, "dtime_t") == 0)
+ new = "timestamp";
+
+ if (new)
+ {
+ struct _yy_buffer *yb;
+
+ yb = mm_alloc(sizeof(struct _yy_buffer));
+
+ yb->buffer = YY_CURRENT_BUFFER;
+ yb->lineno = yylineno;
+ yb->filename = mm_strdup(input_filename);
+ yb->next = yy_buffer;
+ yy_buffer = yb;
+
+ yy_scan_string(new);
+ return true;
+ }
+
+ return false;
+}
---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings