Fixed handling of cyclic defines.
Mon Jul 5 20:50:09 CEST 2004
- Added free() calls against memory leak in interval.c.
+
+Tue Jul 20 09:15:21 CEST 2004
+
+ - Synced parser and keyword list.
+ - Fixed handling of cyclic defines.
- Set pgtypes library version to 1.2.
- Set ecpg version to 3.2.0.
- Set compat library version to 1.2.
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.88 2004/06/10 22:26:23 momjian Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.89 2004/07/20 18:06:41 meskes Exp $ */
/* New main for ecpg, the PostgreSQL embedded SQL precompiler. */
/* (C) Michael Meskes Feb 5th, 1998 */
{
char *tmp;
- /* symbol gets a value */
+ /* symbol has a value */
for (tmp = ptr - 1; *tmp == ' '; tmp--);
tmp[1] = '\0';
defines->old = define_copy;
else
{
defines->old = define_copy;
- defines->new = mm_strdup("");
+ defines->new = mm_strdup("1");
}
defines->pertinent = true;
+ defines->used = NULL;
defines->next = pd;
}
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/keywords.c,v 1.63 2004/06/20 10:45:47 meskes Exp $
+ * $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/keywords.c,v 1.64 2004/07/20 18:06:41 meskes Exp $
*
*-------------------------------------------------------------------------
*/
{"owner", OWNER},
{"partial", PARTIAL},
{"password", PASSWORD},
- {"path", PATH_P},
- {"pendant", PENDANT},
{"position", POSITION},
{"precision", PRECISION},
{"prepare", PREPARE},
{"varchar", VARCHAR},
{"varying", VARYING},
{"verbose", VERBOSE},
- {"version", VERSION},
{"view", VIEW},
{"volatile", VOLATILE},
{"when", WHEN},
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.129 2004/06/30 15:01:57 meskes Exp $
+ * $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.130 2004/07/20 18:06:41 meskes Exp $
*
*-------------------------------------------------------------------------
*/
{identifier} {
ScanKeyword *keyword;
struct _defines *ptr;
-
+
/* How about a DEFINE? */
for (ptr = defines; ptr; ptr = ptr->next)
{
- if (strcmp(yytext, ptr->old) == 0)
+ if (strcmp(yytext, ptr->old) == 0 && ptr->used == NULL)
{
struct _yy_buffer *yb;
yb->buffer = YY_CURRENT_BUFFER;
yb->lineno = yylineno;
yb->filename = mm_strdup(input_filename);
- yb->next = yy_buffer;
-
+ ptr->used = yb->next = yy_buffer;
+
yy_buffer = yb;
yy_scan_string(ptr->new);
break;
}
}
-
if (ptr == NULL)
{
/* Is it an SQL keyword? */
/*
* None of the above. Return it as an identifier.
*
- * The backend would attempt to truncate and case-fold
+ * The backend will attempt to truncate and case-fold
* the identifier, but I see no good reason for ecpg
* to do so; that's just another way that ecpg could get
* out of step with the backend.
*/
- if (ptr == NULL)
- {
- yylval.str = mm_strdup(yytext);
- return IDENT;
- }
+ yylval.str = mm_strdup(yytext);
+ return IDENT;
}
}
{other} { return yytext[0]; }
/* is it a define? */
for (ptr = defines; ptr; ptr = ptr->next)
{
- if (strcmp(yytext, ptr->old) == 0)
+ if (strcmp(yytext, ptr->old) == 0 && ptr->used == NULL)
{
struct _yy_buffer *yb;
yb->buffer = YY_CURRENT_BUFFER;
yb->lineno = yylineno;
yb->filename = mm_strdup(input_filename);
- yb->next = yy_buffer;
+ ptr->used = yb->next = yy_buffer;
yy_buffer = yb;
"-" { return('-'); }
"(" { return('('); }
")" { return(')'); }
->{space} { ECHO; }
+,xskip>{space} { ECHO; }
\{ { return('{'); }
\} { return('}'); }
\[ { return('['); }
}
if (ptr == NULL)
{
- this = (struct _defines *) mm_alloc(sizeof(struct _defines));
+ this = (struct _defines *) mm_alloc(sizeof(struct _defines));
- /* initial definition */
- this->old = old;
- this->new = mm_strdup(literalbuf);
+ /* initial definition */
+ this->old = old;
+ this->new = mm_strdup(literalbuf);
this->next = defines;
+ this->used = NULL;
defines = this;
}
[^;\<\>\"]+";" { parse_include(); }
<> {
- if (yy_buffer == NULL) {
+ if (yy_buffer == NULL) {
if ( preproc_tos > 0 )
{
preproc_tos = 0;
{
struct _yy_buffer *yb = yy_buffer;
int i;
+ struct _defines *ptr;
+ for (ptr = defines; ptr; ptr = ptr->next)
+ if (ptr->used == yy_buffer)
+ {
+ ptr->used = NULL;
+ break;
+ }
+
if (yyin != NULL)
fclose(yyin);
if (i != 0)
output_line_number();
+
}
}
%%
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.292 2004/07/05 09:45:53 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.293 2004/07/20 18:06:41 meskes Exp $ */
/* Copyright comment */
%{
OBJECT_P OF OFF OFFSET OIDS OLD ON ONLY OPERATOR OPTION OR ORDER
OUT_P OUTER_P OVERLAPS OVERLAY OWNER
- PARTIAL PASSWORD PATH_P PENDANT PLACING POSITION
+ PARTIAL PASSWORD PLACING POSITION
PRECISION PRESERVE PREPARE PRIMARY PRIOR PRIVILEGES PROCEDURAL PROCEDURE
QUOTE
UNCOMMITTED UNENCRYPTED UNION UNIQUE UNKNOWN UNLISTEN UNTIL UPDATE USAGE
USER USING
- VACUUM VALID VALUES VARCHAR VARYING VERBOSE VERSION VIEW VOLATILE
+ VACUUM VALID VALUES VARCHAR VARYING VERBOSE VIEW VOLATILE
WHEN WHERE WITH WITHOUT WORK WRITE
YEAR_P
ZONE
*/
%token UNIONJOIN
-/* Special keywords, not in the query language - see the "lex" file */
+/* Special token types, not actually keywords - see the "lex" file */
%token IDENT SCONST Op CSTRING CVARIABLE CPP_LINE IP BCONST XCONST
%token ICONST PARAM
%token FCONST
/* ALTER TABLE SET WITHOUT CLUSTER */
| SET WITHOUT CLUSTER
{ $$ = make_str("set without cluster"); }
+ /* ALTER TABLE
SET TABLESPACE */
+ | SET TABLESPACE name
+ { $$ = cat_str(2, make_str("set tablespace"), $3); }
;
alter_column_default:
*
*****************************************************************************/
-CreateSeqStmt: CREATE OptTemp SEQUENCE qualified_name OptSeqList OptTableSpace
- { $$ = cat_str(5, make_str("create"), $2, make_str("sequence"), $4, $5, $6); }
+CreateSeqStmt: CREATE OptTemp SEQUENCE qualified_name OptSeqList
+ { $$ = cat_str(4, make_str("create"), $2, make_str("sequence"), $4, $5); }
;
AlterSeqStmt: ALTER SEQUENCE qualified_name OptSeqList
| ADD { $$ = make_str("add"); }
| AFTER { $$ = make_str("after"); }
| AGGREGATE { $$ = make_str("aggregate"); }
+ | ALSO { $$ = make_str("also"); }
| ALTER { $$ = make_str("alter"); }
| ASSERTION { $$ = make_str("assertion"); }
| ASSIGNMENT { $$ = make_str("assignment"); }
| OWNER { $$ = make_str("owner"); }
| PARTIAL { $$ = make_str("partial"); }
| PASSWORD { $$ = make_str("password"); }
- | PATH_P { $$ = make_str("path"); }
- | PENDANT { $$ = make_str("pendant"); }
| PREPARE { $$ = make_str("prepare"); }
| PRESERVE { $$ = make_str("preserver"); }
| PRIOR { $$ = make_str("prior"); }
| VALID { $$ = make_str("valid"); }
| VALUES { $$ = make_str("values"); }
| VARYING { $$ = make_str("varying"); }
- | VERSION { $$ = make_str("version"); }
| VIEW { $$ = make_str("view"); }
| WITH { $$ = make_str("with"); }
| WITHOUT { $$ = make_str("without"); }
char *old;
char *new;
int pertinent;
+ void *used;
struct _defines *next;
};