aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/indexcmds.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2006-07-03 22:45:41 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2006-07-03 22:45:41 +0000
commitb7b78d24f7fc8d621af40b2e404b6a3f3420e89e (patch)
treeda6b05ca5779ad812557b5d4cd38be79bf524825 /src/backend/commands/indexcmds.c
parentfeed07350b63e32ba2fbe50181df7d40ca2ee33e (diff)
downloadpostgresql-b7b78d24f7fc8d621af40b2e404b6a3f3420e89e.tar.gz
postgresql-b7b78d24f7fc8d621af40b2e404b6a3f3420e89e.zip
Code review for FILLFACTOR patch. Change WITH grammar as per earlier
discussion (including making def_arg allow reserved words), add missed opt_definition for UNIQUE case. Put the reloptions support code in a less random place (I chose to make a new file access/common/reloptions.c). Eliminate header inclusion creep. Make the index options functions safely user-callable (seems like client apps might like to be able to test validity of options before trying to make an index). Reduce overhead for normal case with no options by allowing rd_options to be NULL. Fix some unmaintainably klugy code, including getting rid of Natts_pg_class_fixed at long last. Some stylistic cleanup too, and pay attention to keeping comments in sync with code. Documentation still needs work, though I did fix the omissions in catalogs.sgml and indexam.sgml.
Diffstat (limited to 'src/backend/commands/indexcmds.c')
-rw-r--r--src/backend/commands/indexcmds.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c
index 7e35258ac09..d2c4bf89059 100644
--- a/src/backend/commands/indexcmds.c
+++ b/src/backend/commands/indexcmds.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/indexcmds.c,v 1.142 2006/07/02 02:23:19 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/indexcmds.c,v 1.143 2006/07/03 22:45:38 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -17,6 +17,7 @@
#include "access/genam.h"
#include "access/heapam.h"
+#include "access/reloptions.h"
#include "catalog/catalog.h"
#include "catalog/dependency.h"
#include "catalog/heap.h"
@@ -72,12 +73,12 @@ static bool relationHasPrimaryKey(Relation rel);
* to index on.
* 'predicate': the partial-index condition, or NULL if none.
* 'rangetable': needed to interpret the predicate.
+ * 'options': reloptions from WITH (in list-of-DefElem form).
* 'unique': make the index enforce uniqueness.
* 'primary': mark the index as a primary key in the catalogs.
* 'isconstraint': index is for a PRIMARY KEY or UNIQUE constraint,
* so build a pg_constraint entry for it.
* 'is_alter_table': this is due to an ALTER rather than a CREATE operation.
- * 'options': options passed by WITH.
* 'check_rights': check for CREATE rights in the namespace. (This should
* be true except when ALTER is deleting/recreating an index.)
* 'skip_build': make the catalog entries but leave the index file empty;
@@ -110,6 +111,8 @@ DefineIndex(RangeVar *heapRelation,
Relation rel;
HeapTuple tuple;
Form_pg_am accessMethodForm;
+ RegProcedure amoptions;
+ Datum reloptions;
IndexInfo *indexInfo;
int numberOfAttributes;
@@ -261,6 +264,8 @@ DefineIndex(RangeVar *heapRelation,
errmsg("access method \"%s\" does not support multicolumn indexes",
accessMethodName)));
+ amoptions = accessMethodForm->amoptions;
+
ReleaseSysCache(tuple);
/*
@@ -368,6 +373,13 @@ DefineIndex(RangeVar *heapRelation,
}
/*
+ * Parse AM-specific options, convert to text array form, validate.
+ */
+ reloptions = transformRelOptions((Datum) 0, options, false, false);
+
+ (void) index_reloptions(amoptions, reloptions, true);
+
+ /*
* Prepare arguments for index_create, primarily an IndexInfo structure.
* Note that ii_Predicate must be in implicit-AND format.
*/
@@ -399,7 +411,7 @@ DefineIndex(RangeVar *heapRelation,
index_create(relationId, indexRelationName, indexRelationId,
indexInfo, accessMethodId, tablespaceId, classObjectId,
- options, primary, false, isconstraint,
+ reloptions, primary, false, isconstraint,
allowSystemTableMods, skip_build);
}