aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser/parser.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>1999-05-13 07:29:22 +0000
committerTom Lane <tgl@sss.pgh.pa.us>1999-05-13 07:29:22 +0000
commit507a0a2ab09144f524e3239b7fc201ad1ad1b78e (patch)
tree77c434943724f627e3c901f06443f02ae57d467b /src/backend/parser/parser.c
parentf80642137cc0d2dbdaea68b8e439de0d50a5c01f (diff)
downloadpostgresql-507a0a2ab09144f524e3239b7fc201ad1ad1b78e.tar.gz
postgresql-507a0a2ab09144f524e3239b7fc201ad1ad1b78e.zip
Rip out QueryTreeList structure, root and branch. Querytree
lists are now plain old garden-variety Lists, allocated with palloc, rather than specialized expansible-array data allocated with malloc. This substantially simplifies their handling and eliminates several sources of memory leakage. Several basic types of erroneous queries (syntax error, attempt to insert a duplicate key into a unique index) now demonstrably leak zero bytes per query.
Diffstat (limited to 'src/backend/parser/parser.c')
-rw-r--r--src/backend/parser/parser.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/backend/parser/parser.c b/src/backend/parser/parser.c
index 5361be4ca19..b1059936413 100644
--- a/src/backend/parser/parser.c
+++ b/src/backend/parser/parser.c
@@ -6,7 +6,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parser.c,v 1.37 1999/02/13 23:17:10 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parser.c,v 1.38 1999/05/13 07:28:39 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -20,34 +20,32 @@
#include "parser/parse_node.h"
#include "parser/parser.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 = NIL;
+List *parsetree; /* result of parsing is left here */
#ifdef SETS_FIXED
static void fixupsets();
static void define_sets();
-
#endif
+
/*
* parser-- returns a list of parse trees
- *
- * CALLER is responsible for free'ing the list returned
*/
-QueryTreeList *
+List *
parser(char *str, Oid *typev, int nargs)
{
- QueryTreeList *queryList;
+ List *queryList;
int yyresult;
-#if defined(FLEX_SCANNER)
- extern void DeleteBuffer(void);
-
-#endif /* FLEX_SCANNER */
-
init_io();
parseString = pstrdup(str);
+ parsetree = NIL; /* in case parser forgets to set it */
parser_init(typev, nargs);
yyresult = yyparse();
@@ -59,7 +57,7 @@ parser(char *str, Oid *typev, int nargs)
clearerr(stdin);
if (yyresult) /* error */
- return (QueryTreeList *) NULL;
+ return (List *) NULL;
queryList = parse_analyze(parsetree, NULL);