Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit462227d

Browse files
committed
Avoid having backend-only code compiled into ecpg. Per Zdenek Kotala
1 parent8164fb8 commit462227d

File tree

4 files changed

+142
-9
lines changed

4 files changed

+142
-9
lines changed

‎src/interfaces/ecpg/preproc/Makefile

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# Copyright (c) 1998-2007, PostgreSQL Global Development Group
66
#
7-
# $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/Makefile,v 1.128 2007/08/22 08:20:58 meskes Exp $
7+
# $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/Makefile,v 1.129 2007/10/26 14:17:53 tgl Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -59,9 +59,6 @@ endif
5959

6060
c_keywords.okeywords.opreproc.oparser.o: preproc.h
6161

62-
parser.c:$(top_srcdir)/src/backend/parser/parser.c
63-
rm -f$@&&$(LN_S)$<.
64-
6562
distprep:$(srcdir)/preproc.c$(srcdir)/preproc.h$(srcdir)/pgc.c
6663

6764
install: all installdirs
@@ -74,7 +71,7 @@ uninstall:
7471
rm -f'$(DESTDIR)$(bindir)/ecpg$(X)'
7572

7673
cleandistclean:
77-
rm -f*.o ecpg$(X) parser.c
74+
rm -f*.o ecpg$(X)
7875
# garbage from partial builds
7976
@rm -f y.tab.c y.tab.h
8077
# garbage from development

‎src/interfaces/ecpg/preproc/parser.c

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
/*-------------------------------------------------------------------------
2+
*
3+
* parser.c
4+
*Main entry point/driver for PostgreSQL grammar
5+
*
6+
* Note that the grammar is not allowed to perform any table access
7+
* (since we need to be able to do basic parsing even while inside an
8+
* aborted transaction). Therefore, the data structures returned by
9+
* the grammar are "raw" parsetrees that still need to be analyzed by
10+
* analyze.c and related files.
11+
*
12+
*
13+
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
14+
* Portions Copyright (c) 1994, Regents of the University of California
15+
*
16+
* IDENTIFICATION
17+
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/parser.c,v 1.1 2007/10/26 14:17:53 tgl Exp $
18+
*
19+
*-------------------------------------------------------------------------
20+
*/
21+
22+
#include"postgres_fe.h"
23+
24+
#include"extern.h"
25+
#include"preproc.h"
26+
27+
28+
staticboolhave_lookahead;/* is lookahead info valid? */
29+
staticintlookahead_token;/* one-token lookahead */
30+
staticYYSTYPElookahead_yylval;/* yylval for lookahead token */
31+
staticYYLTYPElookahead_yylloc;/* yylloc for lookahead token */
32+
33+
34+
/*
35+
* Intermediate filter between parser and base lexer (base_yylex in scan.l).
36+
*
37+
* The filter is needed because in some cases the standard SQL grammar
38+
* requires more than one token lookahead.We reduce these cases to one-token
39+
* lookahead by combining tokens here, in order to keep the grammar LALR(1).
40+
*
41+
* Using a filter is simpler than trying to recognize multiword tokens
42+
* directly in scan.l, because we'd have to allow for comments between the
43+
* words. Furthermore it's not clear how to do it without re-introducing
44+
* scanner backtrack, which would cost more performance than this filter
45+
* layer does.
46+
*/
47+
int
48+
filtered_base_yylex(void)
49+
{
50+
intcur_token;
51+
intnext_token;
52+
YYSTYPEcur_yylval;
53+
YYLTYPEcur_yylloc;
54+
55+
/* Get next token --- we might already have it */
56+
if (have_lookahead)
57+
{
58+
cur_token=lookahead_token;
59+
base_yylval=lookahead_yylval;
60+
base_yylloc=lookahead_yylloc;
61+
have_lookahead= false;
62+
}
63+
else
64+
cur_token=base_yylex();
65+
66+
/* Do we need to look ahead for a possible multiword token? */
67+
switch (cur_token)
68+
{
69+
caseNULLS_P:
70+
/*
71+
* NULLS FIRST and NULLS LAST must be reduced to one token
72+
*/
73+
cur_yylval=base_yylval;
74+
cur_yylloc=base_yylloc;
75+
next_token=base_yylex();
76+
switch (next_token)
77+
{
78+
caseFIRST_P:
79+
cur_token=NULLS_FIRST;
80+
break;
81+
caseLAST_P:
82+
cur_token=NULLS_LAST;
83+
break;
84+
default:
85+
/* save the lookahead token for next time */
86+
lookahead_token=next_token;
87+
lookahead_yylval=base_yylval;
88+
lookahead_yylloc=base_yylloc;
89+
have_lookahead= true;
90+
/* and back up the output info to cur_token */
91+
base_yylval=cur_yylval;
92+
base_yylloc=cur_yylloc;
93+
break;
94+
}
95+
break;
96+
97+
caseWITH:
98+
/*
99+
* WITH CASCADED, LOCAL, or CHECK must be reduced to one token
100+
*
101+
* XXX an alternative way is to recognize just WITH_TIME and put
102+
* the ugliness into the datetime datatype productions instead of
103+
* WITH CHECK OPTION. However that requires promoting WITH to a
104+
* fully reserved word. If we ever have to do that anyway
105+
* (perhaps for SQL99 recursive queries), come back and simplify
106+
* this code.
107+
*/
108+
cur_yylval=base_yylval;
109+
cur_yylloc=base_yylloc;
110+
next_token=base_yylex();
111+
switch (next_token)
112+
{
113+
caseCASCADED:
114+
cur_token=WITH_CASCADED;
115+
break;
116+
caseLOCAL:
117+
cur_token=WITH_LOCAL;
118+
break;
119+
caseCHECK:
120+
cur_token=WITH_CHECK;
121+
break;
122+
default:
123+
/* save the lookahead token for next time */
124+
lookahead_token=next_token;
125+
lookahead_yylval=base_yylval;
126+
lookahead_yylloc=base_yylloc;
127+
have_lookahead= true;
128+
/* and back up the output info to cur_token */
129+
base_yylval=cur_yylval;
130+
base_yylloc=cur_yylloc;
131+
break;
132+
}
133+
break;
134+
135+
default:
136+
break;
137+
}
138+
139+
returncur_token;
140+
}

‎src/interfaces/ecpg/preproc/parser/README

Lines changed: 0 additions & 1 deletion
This file was deleted.

‎src/interfaces/ecpg/preproc/parser/parse.h

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp