diff options
author | Neil Conway <neilc@samurai.com> | 2004-05-26 04:41:50 +0000 |
---|---|---|
committer | Neil Conway <neilc@samurai.com> | 2004-05-26 04:41:50 +0000 |
commit | d0b4399d81f39decccb23fa38f772b71b51bf96a (patch) | |
tree | 71d3b737f5d93f6c3984412a4910b5810156c5ca /src/backend/commands/functioncmds.c | |
parent | 18d0d105635fbc7e476063e662b449f296953a04 (diff) | |
download | postgresql-d0b4399d81f39decccb23fa38f772b71b51bf96a.tar.gz postgresql-d0b4399d81f39decccb23fa38f772b71b51bf96a.zip |
Reimplement the linked list data structure used throughout the backend.
In the past, we used a 'Lispy' linked list implementation: a "list" was
merely a pointer to the head node of the list. The problem with that
design is that it makes lappend() and length() linear time. This patch
fixes that problem (and others) by maintaining a count of the list
length and a pointer to the tail node along with each head node pointer.
A "list" is now a pointer to a structure containing some meta-data
about the list; the head and tail pointers in that structure refer
to ListCell structures that maintain the actual linked list of nodes.
The function names of the list API have also been changed to, I hope,
be more logically consistent. By default, the old function names are
still available; they will be disabled-by-default once the rest of
the tree has been updated to use the new API names.
Diffstat (limited to 'src/backend/commands/functioncmds.c')
-rw-r--r-- | src/backend/commands/functioncmds.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c index c118e8e3b5e..757869a925a 100644 --- a/src/backend/commands/functioncmds.c +++ b/src/backend/commands/functioncmds.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.46 2004/05/14 16:11:25 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.47 2004/05/26 04:41:11 neilc Exp $ * * DESCRIPTION * These routines take the parse tree and pick out the @@ -137,7 +137,7 @@ examine_parameter_list(List *parameter, Oid languageOid, Oid *parameterTypes, const char *parameterNames[]) { int parameterCount = 0; - List *x; + ListCell *x; MemSet(parameterTypes, 0, FUNC_MAX_ARGS * sizeof(Oid)); MemSet(parameterNames, 0, FUNC_MAX_ARGS * sizeof(char *)); @@ -202,14 +202,14 @@ examine_parameter_list(List *parameter, Oid languageOid, */ static void -compute_attributes_sql_style(const List *options, +compute_attributes_sql_style(List *options, List **as, char **language, char *volatility_p, bool *strict_p, bool *security_definer) { - const List *option; + ListCell *option; DefElem *as_item = NULL; DefElem *language_item = NULL; DefElem *volatility_item = NULL; @@ -322,7 +322,7 @@ compute_attributes_sql_style(const List *options, static void compute_attributes_with_style(List *parameters, bool *isStrict_p, char *volatility_p) { - List *pl; + ListCell *pl; foreach(pl, parameters) { @@ -357,7 +357,7 @@ compute_attributes_with_style(List *parameters, bool *isStrict_p, char *volatili */ static void -interpret_AS_clause(Oid languageOid, const char *languageName, const List *as, +interpret_AS_clause(Oid languageOid, const char *languageName, List *as, char **prosrc_str_p, char **probin_str_p) { Assert(as != NIL); @@ -368,8 +368,8 @@ interpret_AS_clause(Oid languageOid, const char *languageName, const List *as, * For "C" language, store the file name in probin and, when * given, the link symbol name in prosrc. */ - *probin_str_p = strVal(lfirst(as)); - if (lnext(as) == NULL) + *probin_str_p = strVal(linitial(as)); + if (list_length(as) == 1) *prosrc_str_p = "-"; else *prosrc_str_p = strVal(lsecond(as)); @@ -377,10 +377,10 @@ interpret_AS_clause(Oid languageOid, const char *languageName, const List *as, else { /* Everything else wants the given string in prosrc. */ - *prosrc_str_p = strVal(lfirst(as)); + *prosrc_str_p = strVal(linitial(as)); *probin_str_p = "-"; - if (lnext(as) != NIL) + if (list_length(as) != 1) ereport(ERROR, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), errmsg("only one AS item needed for language \"%s\"", |