aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser/parser.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/parser/parser.c')
-rw-r--r--src/backend/parser/parser.c127
1 files changed, 15 insertions, 112 deletions
diff --git a/src/backend/parser/parser.c b/src/backend/parser/parser.c
index 4a6c825498a..84b27549d36 100644
--- a/src/backend/parser/parser.c
+++ b/src/backend/parser/parser.c
@@ -1,14 +1,20 @@
/*-------------------------------------------------------------------------
*
* parser.c
- * Main entry point/driver for PostgreSQL parser
+ * Main entry point/driver for PostgreSQL grammar
+ *
+ * Note that the grammar is not allowed to perform any table access
+ * (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.
*
*
* 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.46 2000/09/12 21:07:02 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parser.c,v 1.47 2000/10/07 00:58:17 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -16,8 +22,6 @@
#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"
@@ -35,19 +39,17 @@ 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();
-
-#endif
/*
- * parser-- returns a list of parse trees
+ * parser
+ * Given a query in string form, and optionally info about
+ * parameter types, do lexical and syntactic analysis.
+ *
+ * Returns a list of raw (un-analyzed) parse trees.
*/
List *
parser(char *str, Oid *typev, int nargs)
{
- List *queryList;
int yyresult;
parseString = str;
@@ -67,28 +69,9 @@ parser(char *str, Oid *typev, int nargs)
clearerr(stdin);
if (yyresult) /* error */
- return (List *) NULL;
-
- queryList = parse_analyze(parsetree, NULL);
+ return NIL;
-#ifdef SETS_FIXED
-
- /*
- * Fixing up sets calls the parser, so it reassigns the global
- * variable parsetree. So save the real parsetree.
- */
- savetree = parsetree;
- foreach(parse, savetree)
- { /* savetree is really a list of parses */
-
- /* find set definitions embedded in query */
- fixupsets((Query *) lfirst(parse));
-
- }
- return savetree;
-#endif
-
- return queryList;
+ return parsetree;
}
@@ -135,83 +118,3 @@ yylex(void)
return cur_token;
}
-
-
-#ifdef SETS_FIXED
-static void
-fixupsets(Query *parse)
-{
- if (parse == NULL)
- return;
- if (parse->commandType == CMD_UTILITY) /* utility */
- return;
- if (parse->commandType != CMD_INSERT)
- return;
- define_sets(parse);
-}
-
-/* Recursively find all of the Consts in the parsetree. Some of
- * these may represent a set. The value of the Const will be the
- * query (a string) which defines the set. Call SetDefine to define
- * the set, and store the OID of the new set in the Const instead.
- */
-static void
-define_sets(Node *clause)
-{
- Oid setoid;
- Type t = typeidType(OIDOID);
- Oid typeoid = typeTypeId(t);
- Size oidsize = typeLen(t);
- bool oidbyval = typeByVal(t);
-
- if (clause == NULL)
- return;
- else if (IsA(clause, LispList))
- {
- define_sets(lfirst(clause));
- define_sets(lnext(clause));
- }
- else if (IsA(clause, Const))
- {
- if (get_constisnull((Const) clause) ||
- !get_constisset((Const) clause))
- return;
- setoid = SetDefine(((Const *) clause)->constvalue,
- typeidTypeName(((Const *) clause)->consttype));
- set_constvalue((Const) clause, setoid);
- set_consttype((Const) clause, typeoid);
- set_constlen((Const) clause, oidsize);
- set_constypeByVal((Const) clause, oidbyval);
- }
- else if (IsA(clause, Iter))
- define_sets(((Iter *) clause)->iterexpr);
- else if (single_node(clause))
- return;
- else if (or_clause(clause) || and_clause(clause))
- {
- List *temp;
-
- /* mapcan */
- foreach(temp, ((Expr *) clause)->args)
- define_sets(lfirst(temp));
- }
- else if (is_funcclause(clause))
- {
- List *temp;
-
- /* mapcan */
- foreach(temp, ((Expr *) clause)->args)
- define_sets(lfirst(temp));
- }
- else if (IsA(clause, ArrayRef))
- define_sets(((ArrayRef *) clause)->refassgnexpr);
- else if (not_clause(clause))
- define_sets(get_notclausearg(clause));
- else if (is_opclause(clause))
- {
- define_sets(get_leftop(clause));
- define_sets(get_rightop(clause));
- }
-}
-
-#endif