From b7b78d24f7fc8d621af40b2e404b6a3f3420e89e Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Mon, 3 Jul 2006 22:45:41 +0000 Subject: 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. --- doc/src/sgml/catalogs.sgml | 18 ++++++++++++- doc/src/sgml/indexam.sgml | 65 +++++++++++++++++++++++++++++++++------------- 2 files changed, 64 insertions(+), 19 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml index 7aeb9f8b64b..cd3789f4ed2 100644 --- a/doc/src/sgml/catalogs.sgml +++ b/doc/src/sgml/catalogs.sgml @@ -1,4 +1,4 @@ - + @@ -499,6 +499,13 @@ Function to estimate cost of an index scan + + amoptions + regproc + pg_proc.oid + Function to parse and validate reloptions for an index + + @@ -1643,6 +1650,15 @@ for details + + + reloptions + text[] + + + Access-method-specific options, as keyword=value strings + + diff --git a/doc/src/sgml/indexam.sgml b/doc/src/sgml/indexam.sgml index a001cd4e33a..7febd0c9072 100644 --- a/doc/src/sgml/indexam.sgml +++ b/doc/src/sgml/indexam.sgml @@ -1,4 +1,4 @@ - + Index Access Method Interface Definition @@ -233,6 +233,47 @@ amvacuumcleanup (IndexVacuumInfo *info, be returned. + + +void +amcostestimate (PlannerInfo *root, + IndexOptInfo *index, + List *indexQuals, + RelOptInfo *outer_rel, + Cost *indexStartupCost, + Cost *indexTotalCost, + Selectivity *indexSelectivity, + double *indexCorrelation); + + Estimate the costs of an index scan. This function is described fully + in , below. + + + + +bytea * +amoptions (ArrayType *reloptions, + bool validate); + + Parse and validate the reloptions array for an index. This is called only + when a non-null reloptions array exists for the index. + reloptions is a text array containing entries of the + form name=value. + The function should construct a bytea value, which will be copied + into the rd_options field of the index's relcache entry. + The data contents of the bytea value are open for the access + method to define, but the standard access methods currently all use struct + StdRdOptions. + When validate is true, the function should report a suitable + error message if any of the options are unrecognized or have invalid + values; when validate is false, invalid entries should be + silently ignored. (validate is false when loading options + already stored in pg_catalog; an invalid entry could only + be found if the access method has changed its rules for options, and in + that case ignoring obsolete entries is appropriate.) + It is OK to return NULL if default behavior is wanted. + + The purpose of an index, of course, is to support scans for tuples matching an indexable WHERE condition, often called a @@ -339,28 +380,16 @@ amrestrpos (IndexScanDesc scan); - -void -amcostestimate (PlannerInfo *root, - IndexOptInfo *index, - List *indexQuals, - RelOptInfo *outer_rel, - Cost *indexStartupCost, - Cost *indexTotalCost, - Selectivity *indexSelectivity, - double *indexCorrelation); - - Estimate the costs of an index scan. This function is described fully - in , below. - - - - By convention, the pg_proc entry for any index + By convention, the pg_proc entry for an index access method function should show the correct number of arguments, but declare them all as type internal (since most of the arguments have types that are not known to SQL, and we don't want users calling the functions directly anyway). The return type is declared as void, internal, or boolean as appropriate. + The only exception is amoptions, which should be correctly + declared as taking text[] and bool and returning + bytea. This provision allows client code to execute + amoptions to test validity of options settings. -- cgit v1.2.3