diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 1999-11-21 23:25:47 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 1999-11-21 23:25:47 +0000 |
commit | 610dfa6d5560ebcd72ecca82c64c91503efc9bc5 (patch) | |
tree | 79b676d6133877f8e790e5324005666c92e96b00 /src/backend/optimizer/util/indexnode.c | |
parent | 40d3e9254101d23c4f70b95d621277d306c7baf1 (diff) | |
download | postgresql-610dfa6d5560ebcd72ecca82c64c91503efc9bc5.tar.gz postgresql-610dfa6d5560ebcd72ecca82c64c91503efc9bc5.zip |
Combine index_info and find_secondary_indexes into a single routine that
returns a list of RelOptInfos, eliminating the need for static state
in index_info. That static state was a direct cause of coredumps; if
anything decided to elog(ERROR) partway through an index_info search of
pg_index, the next query would try to close a scan pointer that was
pointing at no-longer-valid memory. Another example of the reasons to
avoid static state variables...
Diffstat (limited to 'src/backend/optimizer/util/indexnode.c')
-rw-r--r-- | src/backend/optimizer/util/indexnode.c | 58 |
1 files changed, 2 insertions, 56 deletions
diff --git a/src/backend/optimizer/util/indexnode.c b/src/backend/optimizer/util/indexnode.c index 4817232f2fb..350209690b7 100644 --- a/src/backend/optimizer/util/indexnode.c +++ b/src/backend/optimizer/util/indexnode.c @@ -7,21 +7,16 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/indexnode.c,v 1.20 1999/08/16 02:17:57 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/indexnode.c,v 1.21 1999/11/21 23:25:47 tgl Exp $ * *------------------------------------------------------------------------- */ -#include <sys/types.h> - #include "postgres.h" - #include "optimizer/pathnode.h" #include "optimizer/plancat.h" -static List *find_secondary_index(Query *root, Oid relid); - /* * find_relation_indices * Returns a list of index nodes containing appropriate information for @@ -32,56 +27,7 @@ List * find_relation_indices(Query *root, RelOptInfo *rel) { if (rel->indexed) - return find_secondary_index(root, lfirsti(rel->relids)); + return find_secondary_indexes(root, lfirsti(rel->relids)); else return NIL; } - -/* - * find_secondary_index - * Creates a list of RelOptInfo nodes containing information for each - * secondary index defined on a relation by searching through the index - * catalog. - * - * 'relid' is the OID of the relation for which indices are being located - * - * Returns a list of new index RelOptInfo nodes. - */ -static List * -find_secondary_index(Query *root, Oid relid) -{ - IdxInfoRetval indexinfo; - List *indexes = NIL; - bool first = true; - - while (index_info(root, first, relid, &indexinfo)) - { - RelOptInfo *indexnode = makeNode(RelOptInfo); - - indexnode->relids = lconsi(indexinfo.relid, NIL); - indexnode->relam = indexinfo.relam; - indexnode->pages = indexinfo.pages; - indexnode->tuples = indexinfo.tuples; - indexnode->classlist = indexinfo.classlist; - indexnode->indexkeys = indexinfo.indexkeys; - indexnode->ordering = indexinfo.orderOprs; - indexnode->indproc = indexinfo.indproc; - indexnode->indpred = (List *) indexinfo.indpred; - - indexnode->indexed = false; /* not indexed itself */ - indexnode->size = 0; - indexnode->width = 0; - indexnode->targetlist = NIL; - indexnode->pathlist = NIL; - indexnode->cheapestpath = NULL; - indexnode->pruneable = true; - indexnode->restrictinfo = NIL; - indexnode->joininfo = NIL; - indexnode->innerjoin = NIL; - - indexes = lcons(indexnode, indexes); - first = false; - } - - return indexes; -} |