1996-07-09 06:22:35 +00:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-13 23:22:53 +00:00
|
|
|
* parser.c
|
2000-10-07 00:58:23 +00:00
|
|
|
* 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
|
2006-03-07 01:00:19 +00:00
|
|
|
* analyze.c and related files.
|
2000-09-12 21:07:18 +00:00
|
|
|
*
|
1996-07-09 06:22:35 +00:00
|
|
|
*
|
2006-03-05 15:59:11 +00:00
|
|
|
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
|
2000-01-26 05:58:53 +00:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-07-09 06:22:35 +00:00
|
|
|
*
|
|
|
|
* IDENTIFICATION
|
2006-03-07 01:00:19 +00:00
|
|
|
* $PostgreSQL: pgsql/src/backend/parser/parser.c,v 1.65 2006/03/07 01:00:17 tgl Exp $
|
1996-07-09 06:22:35 +00:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
1996-10-31 11:09:44 +00:00
|
|
|
#include "postgres.h"
|
2000-09-12 21:07:18 +00:00
|
|
|
|
1996-11-08 20:46:33 +00:00
|
|
|
#include "parser/gramparse.h"
|
1997-11-26 01:14:33 +00:00
|
|
|
#include "parser/parser.h"
|
1996-11-08 06:02:30 +00:00
|
|
|
|
2000-09-12 21:07:18 +00:00
|
|
|
|
1999-05-13 07:29:22 +00:00
|
|
|
List *parsetree; /* result of parsing is left here */
|
1996-07-09 06:22:35 +00:00
|
|
|
|
1999-05-13 07:29:22 +00:00
|
|
|
|
1996-07-09 06:22:35 +00:00
|
|
|
/*
|
2003-04-29 22:13:11 +00:00
|
|
|
* raw_parser
|
|
|
|
* Given a query in string form, do lexical and grammatical analysis.
|
2000-10-07 00:58:23 +00:00
|
|
|
*
|
|
|
|
* Returns a list of raw (un-analyzed) parse trees.
|
1996-07-09 06:22:35 +00:00
|
|
|
*/
|
1999-05-13 07:29:22 +00:00
|
|
|
List *
|
2003-04-29 22:13:11 +00:00
|
|
|
raw_parser(const char *str)
|
1996-07-09 06:22:35 +00:00
|
|
|
{
|
1997-09-08 02:41:22 +00:00
|
|
|
int yyresult;
|
1996-07-09 06:22:35 +00:00
|
|
|
|
2003-04-29 22:13:11 +00:00
|
|
|
parsetree = NIL; /* in case grammar forgets to set it */
|
1997-09-07 05:04:48 +00:00
|
|
|
|
2002-04-20 21:56:15 +00:00
|
|
|
scanner_init(str);
|
2002-08-27 04:55:12 +00:00
|
|
|
parser_init();
|
2000-03-17 05:29:07 +00:00
|
|
|
|
2006-03-07 01:00:19 +00:00
|
|
|
yyresult = base_yyparse();
|
1996-07-09 06:22:35 +00:00
|
|
|
|
2002-04-20 21:56:15 +00:00
|
|
|
scanner_finish();
|
1997-09-07 05:04:48 +00:00
|
|
|
|
1998-02-26 04:46:47 +00:00
|
|
|
if (yyresult) /* error */
|
2000-10-07 00:58:23 +00:00
|
|
|
return NIL;
|
1997-09-07 05:04:48 +00:00
|
|
|
|
2000-10-07 00:58:23 +00:00
|
|
|
return parsetree;
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|