From 75ca20fa030aa24713f598688e6e0866861f9028 Mon Sep 17 00:00:00 2001 From: Michael Meskes Date: Fri, 15 Feb 2008 12:11:02 +0000 Subject: [PATCH] Changed the way symbols are defined in C in INFORMIX mode. Added SQLSTATE macro closing bug #3961. EXECUTE can return NOT FOUND so it should be checked here too. --- src/interfaces/ecpg/ChangeLog | 9 +++++ src/interfaces/ecpg/include/datetime.h | 5 +-- src/interfaces/ecpg/include/decimal.h | 3 +- src/interfaces/ecpg/include/ecpg_informix.h | 5 +++ src/interfaces/ecpg/include/ecpglib.h | 3 +- src/interfaces/ecpg/preproc/pgc.l | 39 +++------------------ src/interfaces/ecpg/preproc/preproc.y | 2 +- 7 files changed, 27 insertions(+), 39 deletions(-) diff --git a/src/interfaces/ecpg/ChangeLog b/src/interfaces/ecpg/ChangeLog index 846c67cc0c..7a2f8346a6 100644 --- a/src/interfaces/ecpg/ChangeLog +++ b/src/interfaces/ecpg/ChangeLog @@ -2307,4 +2307,13 @@ Wed, 06 Feb 2008 09:04:48 +0100 - Fixed segfault in ecpg when using an array element. - Free all memory in auto-prepare mode. +Thu, 14 Feb 2008 13:11:34 +0100 + + - Added SQLSTATE macro closing bug #3961. + - EXECUTE can return NOT FOUND so it should be checked here too. + - Changed regression test accordingly. + +Fri, 15 Feb 2008 12:01:13 +0100 + + - Changed the way symbols are defined in C in INFORMIX mode. diff --git a/src/interfaces/ecpg/include/datetime.h b/src/interfaces/ecpg/include/datetime.h index 29cefba959..03f2091db4 100644 --- a/src/interfaces/ecpg/include/datetime.h +++ b/src/interfaces/ecpg/include/datetime.h @@ -5,7 +5,8 @@ #include -typedef timestamp dtime_t; -typedef interval intrvl_t; +/* brought in by ecpg_informix.h nowadays + * typedef timestamp dtime_t; + * typedef interval intrvl_t; */ #endif /* ndef _ECPG_DATETIME_H */ diff --git a/src/interfaces/ecpg/include/decimal.h b/src/interfaces/ecpg/include/decimal.h index 0f13dd1747..ae185a99c0 100644 --- a/src/interfaces/ecpg/include/decimal.h +++ b/src/interfaces/ecpg/include/decimal.h @@ -5,6 +5,7 @@ #include -typedef decimal dec_t; +/* brought in by ecpg_informix.h nowadays + * typedef decimal dec_t; */ #endif /* ndef _ECPG_DECIMAL_H */ diff --git a/src/interfaces/ecpg/include/ecpg_informix.h b/src/interfaces/ecpg/include/ecpg_informix.h index c00914338d..4153896c33 100644 --- a/src/interfaces/ecpg/include/ecpg_informix.h +++ b/src/interfaces/ecpg/include/ecpg_informix.h @@ -82,6 +82,11 @@ extern int dttofmtasc(timestamp *, char *, int, char *); extern int intoasc(interval *, char *); extern int dtcvfmtasc(char *, char *, timestamp *); +/* we also define Informix datatypes here */ +typedef timestamp dtime_t; +typedef interval intrvl_t; +typedef decimal dec_t; + #ifdef __cplusplus } #endif diff --git a/src/interfaces/ecpg/include/ecpglib.h b/src/interfaces/ecpg/include/ecpglib.h index 684348e71c..d2706538bc 100644 --- a/src/interfaces/ecpg/include/ecpglib.h +++ b/src/interfaces/ecpg/include/ecpglib.h @@ -58,7 +58,8 @@ void sqlprint(void); /* define this for simplicity as well as compatibility */ -#define SQLCODE sqlca.sqlcode +#define SQLCODE sqlca.sqlcode +#define SQLSTATE sqlca.sqlstate /* dynamic SQL */ diff --git a/src/interfaces/ecpg/preproc/pgc.l b/src/interfaces/ecpg/preproc/pgc.l index bd0a7d265e..e7705dca6b 100644 --- a/src/interfaces/ecpg/preproc/pgc.l +++ b/src/interfaces/ecpg/preproc/pgc.l @@ -47,7 +47,6 @@ static void addlitchar (unsigned char); static void parse_include (void); static bool ecpg_isspace(char ch); static bool isdefine(void); -static bool isinformixdefine(void); char *token_start; int state_before; @@ -744,9 +743,11 @@ cppline {space}*#(.*\\{space})*.*{newline} {identifier} { const ScanKeyword *keyword; - /* Informix uses SQL defines only in SQL space */ - /* however, some defines have to be taken care of for compatibility */ - if ((!INFORMIX_MODE || !isinformixdefine()) && !isdefine()) +<<<<<<< pgc.l + if (!INFORMIX_MODE && !isdefine()) +======= + if (!isdefine()) +>>>>>>> 1.162 { keyword = ScanCKeywordLookup(yytext); if (keyword != NULL) @@ -1318,36 +1319,6 @@ static bool isdefine(void) 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; -} - /* * Called before any actual parsing is done */ diff --git a/src/interfaces/ecpg/preproc/preproc.y b/src/interfaces/ecpg/preproc/preproc.y index cfc5a06eb4..d9f5999c99 100644 --- a/src/interfaces/ecpg/preproc/preproc.y +++ b/src/interfaces/ecpg/preproc/preproc.y @@ -807,7 +807,7 @@ stmt: AlterDatabaseStmt { output_statement($1, 0, ECPGst_normal); } | DropUserStmt { output_statement($1, 0, ECPGst_normal); } | DropdbStmt { output_statement($1, 0, ECPGst_normal); } | ExplainStmt { output_statement($1, 0, ECPGst_normal); } - | ExecuteStmt { output_statement($1, 0, ECPGst_execute); } + | ExecuteStmt { output_statement($1, 1, ECPGst_execute); } | FetchStmt { output_statement($1, 1, ECPGst_normal); } | GrantStmt { output_statement($1, 0, ECPGst_normal); } | GrantRoleStmt { output_statement($1, 0, ECPGst_normal); } -- 2.39.5