Skip to content

Commit 5420ed3

Browse files
author
Michael Meskes
committed
Synced parser and keyword list.
Fixed handling of cyclic defines.
1 parent 4599521 commit 5420ed3

File tree

6 files changed

+47
-36
lines changed

6 files changed

+47
-36
lines changed

src/interfaces/ecpg/ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1845,6 +1845,11 @@ Mon, 5 Jul 2004 10:41:54 +0200
18451845
Mon Jul 5 20:50:09 CEST 2004
18461846

18471847
- Added free() calls against memory leak in interval.c.
1848+
1849+
Tue Jul 20 09:15:21 CEST 2004
1850+
1851+
- Synced parser and keyword list.
1852+
- Fixed handling of cyclic defines.
18481853
- Set pgtypes library version to 1.2.
18491854
- Set ecpg version to 3.2.0.
18501855
- Set compat library version to 1.2.

src/interfaces/ecpg/preproc/ecpg.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.88 2004/06/10 22:26:23 momjian Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.89 2004/07/20 18:06:41 meskes Exp $ */
22

33
/* New main for ecpg, the PostgreSQL embedded SQL precompiler. */
44
/* (C) Michael Meskes <meskes@postgresql.org> Feb 5th, 1998 */
@@ -96,7 +96,7 @@ add_preprocessor_define(char *define)
9696
{
9797
char *tmp;
9898

99-
/* symbol gets a value */
99+
/* symbol has a value */
100100
for (tmp = ptr - 1; *tmp == ' '; tmp--);
101101
tmp[1] = '\0';
102102
defines->old = define_copy;
@@ -105,9 +105,10 @@ add_preprocessor_define(char *define)
105105
else
106106
{
107107
defines->old = define_copy;
108-
defines->new = mm_strdup("");
108+
defines->new = mm_strdup("1");
109109
}
110110
defines->pertinent = true;
111+
defines->used = NULL;
111112
defines->next = pd;
112113
}
113114

src/interfaces/ecpg/preproc/keywords.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/keywords.c,v 1.63 2004/06/20 10:45:47 meskes Exp $
11+
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/keywords.c,v 1.64 2004/07/20 18:06:41 meskes Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -233,8 +233,6 @@ static ScanKeyword ScanKeywords[] = {
233233
{"owner", OWNER},
234234
{"partial", PARTIAL},
235235
{"password", PASSWORD},
236-
{"path", PATH_P},
237-
{"pendant", PENDANT},
238236
{"position", POSITION},
239237
{"precision", PRECISION},
240238
{"prepare", PREPARE},
@@ -327,7 +325,6 @@ static ScanKeyword ScanKeywords[] = {
327325
{"varchar", VARCHAR},
328326
{"varying", VARYING},
329327
{"verbose", VERBOSE},
330-
{"version", VERSION},
331328
{"view", VIEW},
332329
{"volatile", VOLATILE},
333330
{"when", WHEN},

src/interfaces/ecpg/preproc/pgc.l

Lines changed: 26 additions & 20 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.129 2004/06/30 15:01:57 meskes Exp $
15+
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.130 2004/07/20 18:06:41 meskes Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -598,11 +598,11 @@ cppline {space}*#(.*\\{space})+.*
598598
<SQL>{identifier} {
599599
ScanKeyword *keyword;
600600
struct _defines *ptr;
601-
601+
602602
/* How about a DEFINE? */
603603
for (ptr = defines; ptr; ptr = ptr->next)
604604
{
605-
if (strcmp(yytext, ptr->old) == 0)
605+
if (strcmp(yytext, ptr->old) == 0 && ptr->used == NULL)
606606
{
607607
struct _yy_buffer *yb;
608608

@@ -611,15 +611,14 @@ cppline {space}*#(.*\\{space})+.*
611611
yb->buffer = YY_CURRENT_BUFFER;
612612
yb->lineno = yylineno;
613613
yb->filename = mm_strdup(input_filename);
614-
yb->next = yy_buffer;
615-
614+
ptr->used = yb->next = yy_buffer;
615+
616616
yy_buffer = yb;
617617

618618
yy_scan_string(ptr->new);
619619
break;
620620
}
621621
}
622-
623622
if (ptr == NULL)
624623
{
625624
/* Is it an SQL keyword? */
@@ -640,16 +639,13 @@ cppline {space}*#(.*\\{space})+.*
640639
/*
641640
* None of the above. Return it as an identifier.
642641
*
643-
* The backend would attempt to truncate and case-fold
642+
* The backend will attempt to truncate and case-fold
644643
* the identifier, but I see no good reason for ecpg
645644
* to do so; that's just another way that ecpg could get
646645
* out of step with the backend.
647646
*/
648-
if (ptr == NULL)
649-
{
650-
yylval.str = mm_strdup(yytext);
651-
return IDENT;
652-
}
647+
yylval.str = mm_strdup(yytext);
648+
return IDENT;
653649
}
654650
}
655651
<SQL>{other} { return yytext[0]; }
@@ -700,7 +696,7 @@ cppline {space}*#(.*\\{space})+.*
700696
/* is it a define? */
701697
for (ptr = defines; ptr; ptr = ptr->next)
702698
{
703-
if (strcmp(yytext, ptr->old) == 0)
699+
if (strcmp(yytext, ptr->old) == 0 && ptr->used == NULL)
704700
{
705701
struct _yy_buffer *yb;
706702

@@ -709,7 +705,7 @@ cppline {space}*#(.*\\{space})+.*
709705
yb->buffer = YY_CURRENT_BUFFER;
710706
yb->lineno = yylineno;
711707
yb->filename = mm_strdup(input_filename);
712-
yb->next = yy_buffer;
708+
ptr->used = yb->next = yy_buffer;
713709

714710
yy_buffer = yb;
715711

@@ -739,7 +735,7 @@ cppline {space}*#(.*\\{space})+.*
739735
<C>"-" { return('-'); }
740736
<C>"(" { return('('); }
741737
<C>")" { return(')'); }
742-
<C>{space} { ECHO; }
738+
<C,xskip>{space} { ECHO; }
743739
<C>\{ { return('{'); }
744740
<C>\} { return('}'); }
745741
<C>\[ { return('['); }
@@ -975,12 +971,13 @@ cppline {space}*#(.*\\{space})+.*
975971
}
976972
if (ptr == NULL)
977973
{
978-
this = (struct _defines *) mm_alloc(sizeof(struct _defines));
974+
this = (struct _defines *) mm_alloc(sizeof(struct _defines));
979975

980-
/* initial definition */
981-
this->old = old;
982-
this->new = mm_strdup(literalbuf);
976+
/* initial definition */
977+
this->old = old;
978+
this->new = mm_strdup(literalbuf);
983979
this->next = defines;
980+
this->used = NULL;
984981
defines = this;
985982
}
986983

@@ -993,7 +990,7 @@ cppline {space}*#(.*\\{space})+.*
993990
<incl>[^;\<\>\"]+";" { parse_include(); }
994991

995992
<<EOF>> {
996-
if (yy_buffer == NULL) {
993+
if (yy_buffer == NULL) {
997994
if ( preproc_tos > 0 )
998995
{
999996
preproc_tos = 0;
@@ -1005,7 +1002,15 @@ cppline {space}*#(.*\\{space})+.*
10051002
{
10061003
struct _yy_buffer *yb = yy_buffer;
10071004
int i;
1005+
struct _defines *ptr;
10081006

1007+
for (ptr = defines; ptr; ptr = ptr->next)
1008+
if (ptr->used == yy_buffer)
1009+
{
1010+
ptr->used = NULL;
1011+
break;
1012+
}
1013+
10091014
if (yyin != NULL)
10101015
fclose(yyin);
10111016

@@ -1025,6 +1030,7 @@ cppline {space}*#(.*\\{space})+.*
10251030

10261031
if (i != 0)
10271032
output_line_number();
1033+
10281034
}
10291035
}
10301036
%%

src/interfaces/ecpg/preproc/preproc.y

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.292 2004/07/05 09:45:53 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.293 2004/07/20 18:06:41 meskes Exp $ */
22

33
/* Copyright comment */
44
%{
@@ -385,7 +385,7 @@ add_additional_variables(char *name, bool insert)
385385
OBJECT_P OF OFF OFFSET OIDS OLD ON ONLY OPERATOR OPTION OR ORDER
386386
OUT_P OUTER_P OVERLAPS OVERLAY OWNER
387387

388-
PARTIAL PASSWORD PATH_P PENDANT PLACING POSITION
388+
PARTIAL PASSWORD PLACING POSITION
389389
PRECISION PRESERVE PREPARE PRIMARY PRIOR PRIVILEGES PROCEDURAL PROCEDURE
390390

391391
QUOTE
@@ -403,7 +403,7 @@ add_additional_variables(char *name, bool insert)
403403
UNCOMMITTED UNENCRYPTED UNION UNIQUE UNKNOWN UNLISTEN UNTIL UPDATE USAGE
404404
USER USING
405405

406-
VACUUM VALID VALUES VARCHAR VARYING VERBOSE VERSION VIEW VOLATILE
406+
VACUUM VALID VALUES VARCHAR VARYING VERBOSE VIEW VOLATILE
407407
WHEN WHERE WITH WITHOUT WORK WRITE
408408
YEAR_P
409409
ZONE
@@ -414,7 +414,7 @@ add_additional_variables(char *name, bool insert)
414414
*/
415415
%token UNIONJOIN
416416

417-
/* Special keywords, not in the query language - see the "lex" file */
417+
/* Special token types, not actually keywords - see the "lex" file */
418418
%token <str> IDENT SCONST Op CSTRING CVARIABLE CPP_LINE IP BCONST XCONST
419419
%token <ival> ICONST PARAM
420420
%token <dval> FCONST
@@ -1232,6 +1232,9 @@ alter_table_cmd:
12321232
/* ALTER TABLE <name> SET WITHOUT CLUSTER */
12331233
| SET WITHOUT CLUSTER
12341234
{ $$ = make_str("set without cluster"); }
1235+
/* ALTER TABLE <name> SET TABLESPACE <tablespacename> */
1236+
| SET TABLESPACE name
1237+
{ $$ = cat_str(2, make_str("set tablespace"), $3); }
12351238
;
12361239

12371240
alter_column_default:
@@ -1590,8 +1593,8 @@ CreateAsElement: ColId { $$ = $1; }
15901593
*
15911594
*****************************************************************************/
15921595

1593-
CreateSeqStmt: CREATE OptTemp SEQUENCE qualified_name OptSeqList OptTableSpace
1594-
{ $$ = cat_str(5, make_str("create"), $2, make_str("sequence"), $4, $5, $6); }
1596+
CreateSeqStmt: CREATE OptTemp SEQUENCE qualified_name OptSeqList
1597+
{ $$ = cat_str(4, make_str("create"), $2, make_str("sequence"), $4, $5); }
15951598
;
15961599

15971600
AlterSeqStmt: ALTER SEQUENCE qualified_name OptSeqList
@@ -5857,6 +5860,7 @@ ECPGunreserved: ABORT_P { $$ = make_str("abort"); }
58575860
| ADD { $$ = make_str("add"); }
58585861
| AFTER { $$ = make_str("after"); }
58595862
| AGGREGATE { $$ = make_str("aggregate"); }
5863+
| ALSO { $$ = make_str("also"); }
58605864
| ALTER { $$ = make_str("alter"); }
58615865
| ASSERTION { $$ = make_str("assertion"); }
58625866
| ASSIGNMENT { $$ = make_str("assignment"); }
@@ -5957,8 +5961,6 @@ ECPGunreserved: ABORT_P { $$ = make_str("abort"); }
59575961
| OWNER { $$ = make_str("owner"); }
59585962
| PARTIAL { $$ = make_str("partial"); }
59595963
| PASSWORD { $$ = make_str("password"); }
5960-
| PATH_P { $$ = make_str("path"); }
5961-
| PENDANT { $$ = make_str("pendant"); }
59625964
| PREPARE { $$ = make_str("prepare"); }
59635965
| PRESERVE { $$ = make_str("preserver"); }
59645966
| PRIOR { $$ = make_str("prior"); }
@@ -6021,7 +6023,6 @@ ECPGunreserved: ABORT_P { $$ = make_str("abort"); }
60216023
| VALID { $$ = make_str("valid"); }
60226024
| VALUES { $$ = make_str("values"); }
60236025
| VARYING { $$ = make_str("varying"); }
6024-
| VERSION { $$ = make_str("version"); }
60256026
| VIEW { $$ = make_str("view"); }
60266027
| WITH { $$ = make_str("with"); }
60276028
| WITHOUT { $$ = make_str("without"); }

src/interfaces/ecpg/preproc/type.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ struct _defines
135135
char *old;
136136
char *new;
137137
int pertinent;
138+
void *used;
138139
struct _defines *next;
139140
};
140141

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