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

First cut at full support for OUTER JOINs. There are still a few loose

ends to clean up (see my message of same date to pghackers), but mostly
it works.  INITDB REQUIRED!
This commit is contained in:
Tom Lane
2000-09-12 21:07:18 +00:00
parent b5c0ab278b
commit ed5003c584
93 changed files with 6386 additions and 4262 deletions

View File

@ -1,32 +1,40 @@
/*-------------------------------------------------------------------------
*
* parser.c
* Main entry point/driver for PostgreSQL parser
*
*
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parser.c,v 1.45 2000/04/12 17:15:27 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parser.c,v 1.46 2000/09/12 21:07:02 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include "nodes/parsenodes.h"
#include "nodes/pg_list.h"
#include "parser/analyze.h"
#include "parser/gramparse.h"
#include "parser/parse.h"
#include "parser/parser.h"
#include "parser/parse_expr.h"
#if defined(FLEX_SCANNER)
extern void DeleteBuffer(void);
#endif /* FLEX_SCANNER */
char *parseString; /* the char* which holds the string to be
* parsed */
List *parsetree; /* result of parsing is left here */
static int lookahead_token; /* one-token lookahead */
static bool have_lookahead; /* lookahead_token set? */
#ifdef SETS_FIXED
static void fixupsets();
static void define_sets();
@ -42,11 +50,11 @@ parser(char *str, Oid *typev, int nargs)
List *queryList;
int yyresult;
init_io();
parseString = pstrdup(str);
parseString = str;
parsetree = NIL; /* in case parser forgets to set it */
have_lookahead = false;
scanner_init();
parser_init(typev, nargs);
parse_expr_init();
@ -83,6 +91,52 @@ parser(char *str, Oid *typev, int nargs)
return queryList;
}
/*
* 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;
}
#ifdef SETS_FIXED
static void
fixupsets(Query *parse)