aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/index/genam.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/access/index/genam.c')
-rw-r--r--src/backend/access/index/genam.c47
1 files changed, 46 insertions, 1 deletions
diff --git a/src/backend/access/index/genam.c b/src/backend/access/index/genam.c
index 56eabbaf421..cfc2a833cd3 100644
--- a/src/backend/access/index/genam.c
+++ b/src/backend/access/index/genam.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/index/genam.c,v 1.55 2006/05/07 01:21:30 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/index/genam.c,v 1.56 2006/07/02 02:23:18 momjian Exp $
*
* NOTES
* many of the old access method routines have been turned into
@@ -21,8 +21,12 @@
#include "access/genam.h"
#include "access/heapam.h"
+#include "commands/defrem.h"
#include "miscadmin.h"
+#include "nodes/parsenodes.h"
+#include "parser/parse_clause.h"
#include "pgstat.h"
+#include "utils/catcache.h"
/* ----------------------------------------------------------------
@@ -260,3 +264,44 @@ systable_endscan(SysScanDesc sysscan)
pfree(sysscan);
}
+
+/*
+ * Parse options for generic indexes.
+ */
+bytea *
+genam_option(ArrayType *options,
+ int minFillfactor, int defaultFillfactor)
+{
+ int fillfactor;
+ IndexOption *result;
+
+ DefElem kwds[] =
+ {
+ { T_DefElem, "fillfactor" },
+ };
+
+ /*
+ * parse options
+ */
+ OptionParse(options, lengthof(kwds), kwds, true);
+
+ /* 0: fillfactor */
+ if (kwds[0].arg)
+ fillfactor = (int) defGetInt64(&kwds[0]);
+ else
+ fillfactor = defaultFillfactor;
+ if (fillfactor < minFillfactor || 100 < fillfactor)
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("fillfactor=%d should be between %d and 100",
+ fillfactor, minFillfactor)));
+
+ /*
+ * build options
+ */
+ result = (IndexOption *)
+ MemoryContextAlloc(CacheMemoryContext, sizeof(IndexOption));
+ VARATT_SIZEP(result) = sizeof(IndexOption);
+ result->fillfactor = fillfactor;
+ return (bytea *) result;
+}