Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
summaryrefslogtreecommitdiff
path: root/src/pl
diff options
context:
space:
mode:
authorNeil Conway2004-05-26 04:41:50 +0000
committerNeil Conway2004-05-26 04:41:50 +0000
commitd0b4399d81f39decccb23fa38f772b71b51bf96a (patch)
tree71d3b737f5d93f6c3984412a4910b5810156c5ca /src/pl
parent18d0d105635fbc7e476063e662b449f296953a04 (diff)
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/pl')
-rw-r--r--src/pl/plpgsql/src/pl_exec.c8
-rw-r--r--src/pl/tcl/pltcl.c8
2 files changed, 8 insertions, 8 deletions
diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c
index 3a90b464851..b9bb7f65ab4 100644
--- a/src/pl/plpgsql/src/pl_exec.c
+++ b/src/pl/plpgsql/src/pl_exec.c
@@ -3,7 +3,7 @@
* procedural language
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.100 2004/05/10 22:44:49 tgl Exp $
+ * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.101 2004/05/26 04:41:48 neilc Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
@@ -3799,7 +3799,7 @@ exec_simple_check_node(Node *node)
case T_List:
{
List *expr = (List *) node;
- List *l;
+ ListCell *l;
foreach(l, expr)
{
@@ -3838,7 +3838,7 @@ exec_simple_check_plan(PLpgSQL_expr * expr)
if (length(spi_plan->ptlist) != 1)
return;
- plan = (Plan *) lfirst(spi_plan->ptlist);
+ plan = (Plan *) linitial(spi_plan->ptlist);
/*
* 2. It must be a RESULT plan --> no scan's required
@@ -3865,7 +3865,7 @@ exec_simple_check_plan(PLpgSQL_expr * expr)
if (length(plan->targetlist) != 1)
return;
- tle = (TargetEntry *) lfirst(plan->targetlist);
+ tle = (TargetEntry *) linitial(plan->targetlist);
/*
* 5. Check that all the nodes in the expression are non-scary.
diff --git a/src/pl/tcl/pltcl.c b/src/pl/tcl/pltcl.c
index d9382aff83b..d30d3cd7c20 100644
--- a/src/pl/tcl/pltcl.c
+++ b/src/pl/tcl/pltcl.c
@@ -31,7 +31,7 @@
* ENHANCEMENTS, OR MODIFICATIONS.
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/pl/tcl/pltcl.c,v 1.83 2004/04/01 21:28:46 tgl Exp $
+ * $PostgreSQL: pgsql/src/pl/tcl/pltcl.c,v 1.84 2004/05/26 04:41:50 neilc Exp $
*
**********************************************************************/
@@ -1847,7 +1847,7 @@ pltcl_SPI_prepare(ClientData cdata, Tcl_Interp *interp,
{
char *argcopy;
List *names = NIL;
- List *lp;
+ ListCell *l;
TypeName *typename;
/************************************************************
@@ -1858,8 +1858,8 @@ pltcl_SPI_prepare(ClientData cdata, Tcl_Interp *interp,
argcopy = pstrdup(args[i]);
SplitIdentifierString(argcopy, '.', &names);
typename = makeNode(TypeName);
- foreach (lp, names)
- typename->names = lappend(typename->names, makeString(lfirst(lp)));
+ foreach (l, names)
+ typename->names = lappend(typename->names, makeString(lfirst(l)));
typeTup = typenameType(typename);
qdesc->argtypes[i] = HeapTupleGetOid(typeTup);