diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2001-07-15 22:48:19 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2001-07-15 22:48:19 +0000 |
commit | c8076f09d2eb82a28f27f97230be470fffe7a1e0 (patch) | |
tree | 1e357e7e28313386f9d2e789d3905b37ce2d58f6 /src/backend/commands/indexcmds.c | |
parent | 997439f59e1d487cb2bfa1384f6479fda0c4dd4c (diff) | |
download | postgresql-c8076f09d2eb82a28f27f97230be470fffe7a1e0.tar.gz postgresql-c8076f09d2eb82a28f27f97230be470fffe7a1e0.zip |
Restructure index AM interface for index building and index tuple deletion,
per previous discussion on pghackers. Most of the duplicate code in
different AMs' ambuild routines has been moved out to a common routine
in index.c; this means that all index types now do the right things about
inserting recently-dead tuples, etc. (I also removed support for EXTEND
INDEX in the ambuild routines, since that's about to go away anyway, and
it cluttered the code a lot.) The retail indextuple deletion routines have
been replaced by a "bulk delete" routine in which the indexscan is inside
the access method. I haven't pushed this change as far as it should go yet,
but it should allow considerable simplification of the internal bookkeeping
for deletions. Also, add flag columns to pg_am to eliminate various
hardcoded tests on AM OIDs, and remove unused pg_am columns.
Fix rtree and gist index types to not attempt to store NULLs; before this,
gist usually crashed, while rtree managed not to crash but computed wacko
bounding boxes for NULL entries (which might have had something to do with
the performance problems we've heard about occasionally).
Add AtEOXact routines to hash, rtree, and gist, all of which have static
state that needs to be reset after an error. We discovered this need long
ago for btree, but missed the other guys.
Oh, one more thing: concurrent VACUUM is now the default.
Diffstat (limited to 'src/backend/commands/indexcmds.c')
-rw-r--r-- | src/backend/commands/indexcmds.c | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 108c4ea3780..7398b0b0ce5 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.50 2001/06/13 21:44:40 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.51 2001/07/15 22:48:17 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -83,6 +83,8 @@ DefineIndex(char *heapRelationName, Oid *classObjectId; Oid accessMethodId; Oid relationId; + HeapTuple tuple; + Form_pg_am accessMethodForm; IndexInfo *indexInfo; int numberOfAttributes; List *cnfPred = NIL; @@ -107,27 +109,25 @@ DefineIndex(char *heapRelationName, heapRelationName); /* - * compute access method id + * look up the access method, verify it can handle the requested features */ - accessMethodId = GetSysCacheOid(AMNAME, - PointerGetDatum(accessMethodName), - 0, 0, 0); - if (!OidIsValid(accessMethodId)) + tuple = SearchSysCache(AMNAME, + PointerGetDatum(accessMethodName), + 0, 0, 0); + if (!HeapTupleIsValid(tuple)) elog(ERROR, "DefineIndex: access method \"%s\" not found", accessMethodName); + accessMethodId = tuple->t_data->t_oid; + accessMethodForm = (Form_pg_am) GETSTRUCT(tuple); - /* - * XXX Hardwired hacks to check for limitations on supported index - * types. We really ought to be learning this info from entries in the - * pg_am table, instead of having it wired-in here! - */ - if (unique && accessMethodId != BTREE_AM_OID) - elog(ERROR, "DefineIndex: unique indices are only available with the btree access method"); + if (unique && ! accessMethodForm->amcanunique) + elog(ERROR, "DefineIndex: access method \"%s\" does not support UNIQUE indexes", + accessMethodName); + if (numberOfAttributes > 1 && ! accessMethodForm->amcanmulticol) + elog(ERROR, "DefineIndex: access method \"%s\" does not support multi-column indexes", + accessMethodName); - if (numberOfAttributes > 1 && - !( accessMethodId == BTREE_AM_OID || - accessMethodId == GIST_AM_OID)) - elog(ERROR, "DefineIndex: multi-column indices are only available with the btree or GiST access methods"); + ReleaseSysCache(tuple); /* * WITH clause reinstated to handle lossy indices. -- JMH, 7/22/96 @@ -298,7 +298,15 @@ ExtendIndex(char *indexRelationName, Expr *predicate, List *rangetable) InitIndexStrategy(indexInfo->ii_NumIndexAttrs, indexRelation, accessMethodId); - index_build(heapRelation, indexRelation, indexInfo, oldPred); + /* + * XXX currently BROKEN: if we want to support EXTEND INDEX, oldPred + * needs to be passed through to IndexBuildHeapScan. We could do this + * without help from the index AMs if we added an oldPred field to the + * IndexInfo struct. Currently I'm expecting that EXTEND INDEX will + * get removed, so I'm not going to do that --- tgl 7/14/01 + */ + + index_build(heapRelation, indexRelation, indexInfo); /* heap and index rels are closed as a side-effect of index_build */ } |