mirror of
https://github.com/postgres/postgres.git
synced 2025-05-21 15:54:08 +03:00
Fixed bug in Informix define handling.
This commit is contained in:
parent
d7e1fa482a
commit
2169ad2208
@ -1,4 +1,4 @@
|
|||||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.93 2005/10/15 02:49:47 momjian Exp $ */
|
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.93.2.1 2007/08/29 13:58:51 meskes Exp $ */
|
||||||
|
|
||||||
/* New main for ecpg, the PostgreSQL embedded SQL precompiler. */
|
/* New main for ecpg, the PostgreSQL embedded SQL precompiler. */
|
||||||
/* (C) Michael Meskes <meskes@postgresql.org> Feb 5th, 1998 */
|
/* (C) Michael Meskes <meskes@postgresql.org> Feb 5th, 1998 */
|
||||||
@ -185,11 +185,6 @@ main(int argc, char *const argv[])
|
|||||||
char informix_path[MAXPGPATH];
|
char informix_path[MAXPGPATH];
|
||||||
|
|
||||||
compat = (strcmp(optarg, "INFORMIX") == 0) ? ECPG_COMPAT_INFORMIX : ECPG_COMPAT_INFORMIX_SE;
|
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);
|
get_pkginclude_path(my_exec_path, pkginclude_path);
|
||||||
snprintf(informix_path, MAXPGPATH, "%s/informix/esql", pkginclude_path);
|
snprintf(informix_path, MAXPGPATH, "%s/informix/esql", pkginclude_path);
|
||||||
add_include_path(informix_path);
|
add_include_path(informix_path);
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.137 2005/10/05 14:58:36 meskes Exp $
|
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.137.2.1 2007/08/29 13:58:51 meskes Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -47,6 +47,8 @@ static void addlit(char *ytext, int yleng);
|
|||||||
static void addlitchar (unsigned char);
|
static void addlitchar (unsigned char);
|
||||||
static void parse_include (void);
|
static void parse_include (void);
|
||||||
static void check_escape_warning(void);
|
static void check_escape_warning(void);
|
||||||
|
static bool isdefine(void);
|
||||||
|
static bool isinformixdefine(void);
|
||||||
|
|
||||||
char *token_start;
|
char *token_start;
|
||||||
int state_before;
|
int state_before;
|
||||||
@ -647,29 +649,8 @@ cppline {space}*#(.*\\{space})*.*{newline}
|
|||||||
}
|
}
|
||||||
<SQL>{identifier} {
|
<SQL>{identifier} {
|
||||||
ScanKeyword *keyword;
|
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));
|
if (!isdefine())
|
||||||
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
/* Is it an SQL keyword? */
|
/* Is it an SQL keyword? */
|
||||||
keyword = ScanKeywordLookup(yytext);
|
keyword = ScanKeywordLookup(yytext);
|
||||||
@ -741,38 +722,10 @@ cppline {space}*#(.*\\{space})*.*{newline}
|
|||||||
}
|
}
|
||||||
<C>{identifier} {
|
<C>{identifier} {
|
||||||
ScanKeyword *keyword;
|
ScanKeyword *keyword;
|
||||||
struct _defines *ptr;
|
|
||||||
|
|
||||||
if (INFORMIX_MODE)
|
/* Informix uses SQL defines only in SQL space */
|
||||||
{
|
/* however, some defines have to be taken care of for compatibility */
|
||||||
/* Informix uses SQL defines only in SQL space */
|
if ((!INFORMIX_MODE || !isinformixdefine()) && !isdefine())
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
keyword = ScanCKeywordLookup(yytext);
|
keyword = ScanCKeywordLookup(yytext);
|
||||||
if (keyword != NULL)
|
if (keyword != NULL)
|
||||||
@ -1245,3 +1198,61 @@ check_escape_warning(void)
|
|||||||
mmerror (PARSE_ERROR, ET_WARNING, "nonstandard use of escape in a string literal");
|
mmerror (PARSE_ERROR, ET_WARNING, "nonstandard use of escape in a string literal");
|
||||||
warn_on_first_escape = false; /* warn only once per string */
|
warn_on_first_escape = false; /* warn only once per string */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user