1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-17 17:02:08 +03:00

Remove the stub support we had for UNION JOIN; per discussion, this is

not likely ever to be implemented seeing it's been removed from SQL2003.
This allows getting rid of the 'filter' version of yylex() that we had in
parser.c, which should save at least a few microseconds in parsing.
This commit is contained in:
Tom Lane
2006-03-07 01:00:19 +00:00
parent 48cf295742
commit 012abebab1
14 changed files with 20 additions and 158 deletions

View File

@ -7,32 +7,26 @@
* (since we need to be able to do basic parsing even while inside an
* aborted transaction). Therefore, the data structures returned by
* the grammar are "raw" parsetrees that still need to be analyzed by
* parse_analyze.
* analyze.c and related files.
*
*
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/parser.c,v 1.64 2006/03/05 15:58:34 momjian Exp $
* $PostgreSQL: pgsql/src/backend/parser/parser.c,v 1.65 2006/03/07 01:00:17 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include "nodes/parsenodes.h"
#include "parser/gramparse.h"
#include "parser/parse.h"
#include "parser/parser.h"
#include "parser/parse_expr.h"
List *parsetree; /* result of parsing is left here */
static int lookahead_token; /* one-token lookahead */
static bool have_lookahead; /* lookahead_token set? */
/*
* raw_parser
@ -46,12 +40,11 @@ raw_parser(const char *str)
int yyresult;
parsetree = NIL; /* in case grammar forgets to set it */
have_lookahead = false;
scanner_init(str);
parser_init();
yyresult = yyparse();
yyresult = base_yyparse();
scanner_finish();
@ -60,48 +53,3 @@ raw_parser(const char *str)
return parsetree;
}
/*
* Intermediate filter between parser and base lexer (base_yylex in scan.l).
*
* The filter is needed because in some cases SQL92 requires more than one
* token lookahead. We reduce these cases to one-token lookahead by combining
* tokens here, in order to keep the grammar LR(1).
*
* Using a filter is simpler than trying to recognize multiword tokens
* directly in scan.l, because we'd have to allow for comments between the
* words ...
*/
int
yylex(void)
{
int cur_token;
/* Get next token --- we might already have it */
if (have_lookahead)
{
cur_token = lookahead_token;
have_lookahead = false;
}
else
cur_token = base_yylex();
/* Do we need to look ahead for a possible multiword token? */
switch (cur_token)
{
case UNION:
/* UNION JOIN must be reduced to a single UNIONJOIN token */
lookahead_token = base_yylex();
if (lookahead_token == JOIN)
cur_token = UNIONJOIN;
else
have_lookahead = true;
break;
default:
break;
}
return cur_token;
}