2424#include "access/nbtree.h"
2525#include "access/reloptions.h"
2626#include "access/spgist_private.h"
27- #include "access/tableam.h"
2827#include "catalog/pg_type.h"
2928#include "commands/defrem.h"
3029#include "commands/tablespace.h"
4544 * value, upper and lower bounds (if applicable); for strings, consider a
4645 * validation routine.
4746 * (ii) add a record below (or use add_<type>_reloption).
48- * (iii) add it to the appropriate options struct (perhaps HeapRdOptions )
47+ * (iii) add it to the appropriate options struct (perhaps StdRdOptions )
4948 * (iv) add it to the appropriate handling routine (perhaps
5049 * default_reloptions)
5150 * (v) make sure the lock level is set correctly for that operation
@@ -1375,16 +1374,10 @@ untransformRelOptions(Datum options)
13751374 * tupdesc is pg_class' tuple descriptor. amoptions is a pointer to the index
13761375 * AM's options parser function in the case of a tuple corresponding to an
13771376 * index, or NULL otherwise.
1378- *
1379- * If common pointer is provided, then the corresponding struct will be
1380- * filled with options that table AM exposes for external usage. That must
1381- * be filled with defaults before passing here.
13821377 */
1383-
13841378bytea *
13851379extractRelOptions (HeapTuple tuple , TupleDesc tupdesc ,
1386- const TableAmRoutine * tableam , amoptions_function amoptions ,
1387- CommonRdOptions * common )
1380+ amoptions_function amoptions )
13881381{
13891382 bytea * options ;
13901383 bool isnull ;
@@ -1406,8 +1399,7 @@ extractRelOptions(HeapTuple tuple, TupleDesc tupdesc,
14061399 case RELKIND_RELATION :
14071400 case RELKIND_TOASTVALUE :
14081401 case RELKIND_MATVIEW :
1409- options = tableam_reloptions (tableam , classForm -> relkind ,
1410- datum , common , false);
1402+ options = heap_reloptions (classForm -> relkind , datum , false);
14111403 break ;
14121404 case RELKIND_PARTITIONED_TABLE :
14131405 options = partitioned_table_reloptions (datum , false);
@@ -1703,7 +1695,7 @@ parse_one_reloption(relopt_value *option, char *text_str, int text_len,
17031695 * Given the result from parseRelOptions, allocate a struct that's of the
17041696 * specified base size plus any extra space that's needed for string variables.
17051697 *
1706- * "base" should be sizeof(struct) of the reloptions struct (HeapRdOptions or
1698+ * "base" should be sizeof(struct) of the reloptions struct (StdRdOptions or
17071699 * equivalent).
17081700 */
17091701static void *
@@ -1840,95 +1832,59 @@ fillRelOptions(void *rdopts, Size basesize,
18401832
18411833
18421834/*
1843- * Option parser for anything that uses HeapRdOptions .
1835+ * Option parser for anything that uses StdRdOptions .
18441836 */
1845- static bytea *
1837+ bytea *
18461838default_reloptions (Datum reloptions , bool validate , relopt_kind kind )
18471839{
18481840 static const relopt_parse_elt tab [] = {
1849- {"fillfactor" , RELOPT_TYPE_INT , offsetof(HeapRdOptions , fillfactor )},
1841+ {"fillfactor" , RELOPT_TYPE_INT , offsetof(StdRdOptions , fillfactor )},
18501842 {"autovacuum_enabled" , RELOPT_TYPE_BOOL ,
1851- offsetof(HeapRdOptions , common ) +
1852- offsetof(CommonRdOptions , autovacuum ) +
1853- offsetof(AutoVacOpts , enabled )},
1843+ offsetof(StdRdOptions , autovacuum ) + offsetof(AutoVacOpts , enabled )},
18541844 {"autovacuum_vacuum_threshold" , RELOPT_TYPE_INT ,
1855- offsetof(HeapRdOptions , common ) +
1856- offsetof(CommonRdOptions , autovacuum ) +
1857- offsetof(AutoVacOpts , vacuum_threshold )},
1845+ offsetof(StdRdOptions , autovacuum ) + offsetof(AutoVacOpts , vacuum_threshold )},
18581846 {"autovacuum_vacuum_insert_threshold" , RELOPT_TYPE_INT ,
1859- offsetof(HeapRdOptions , common ) +
1860- offsetof(CommonRdOptions , autovacuum ) +
1861- offsetof(AutoVacOpts , vacuum_ins_threshold )},
1847+ offsetof(StdRdOptions , autovacuum ) + offsetof(AutoVacOpts , vacuum_ins_threshold )},
18621848 {"autovacuum_analyze_threshold" , RELOPT_TYPE_INT ,
1863- offsetof(HeapRdOptions , common ) +
1864- offsetof(CommonRdOptions , autovacuum ) +
1865- offsetof(AutoVacOpts , analyze_threshold )},
1849+ offsetof(StdRdOptions , autovacuum ) + offsetof(AutoVacOpts , analyze_threshold )},
18661850 {"autovacuum_vacuum_cost_limit" , RELOPT_TYPE_INT ,
1867- offsetof(HeapRdOptions , common ) +
1868- offsetof(CommonRdOptions , autovacuum ) +
1869- offsetof(AutoVacOpts , vacuum_cost_limit )},
1851+ offsetof(StdRdOptions , autovacuum ) + offsetof(AutoVacOpts , vacuum_cost_limit )},
18701852 {"autovacuum_freeze_min_age" , RELOPT_TYPE_INT ,
1871- offsetof(HeapRdOptions , common ) +
1872- offsetof(CommonRdOptions , autovacuum ) +
1873- offsetof(AutoVacOpts , freeze_min_age )},
1853+ offsetof(StdRdOptions , autovacuum ) + offsetof(AutoVacOpts , freeze_min_age )},
18741854 {"autovacuum_freeze_max_age" , RELOPT_TYPE_INT ,
1875- offsetof(HeapRdOptions , common ) +
1876- offsetof(CommonRdOptions , autovacuum ) +
1877- offsetof(AutoVacOpts , freeze_max_age )},
1855+ offsetof(StdRdOptions , autovacuum ) + offsetof(AutoVacOpts , freeze_max_age )},
18781856 {"autovacuum_freeze_table_age" , RELOPT_TYPE_INT ,
1879- offsetof(HeapRdOptions , common ) +
1880- offsetof(CommonRdOptions , autovacuum ) +
1881- offsetof(AutoVacOpts , freeze_table_age )},
1857+ offsetof(StdRdOptions , autovacuum ) + offsetof(AutoVacOpts , freeze_table_age )},
18821858 {"autovacuum_multixact_freeze_min_age" , RELOPT_TYPE_INT ,
1883- offsetof(HeapRdOptions , common ) +
1884- offsetof(CommonRdOptions , autovacuum ) +
1885- offsetof(AutoVacOpts , multixact_freeze_min_age )},
1859+ offsetof(StdRdOptions , autovacuum ) + offsetof(AutoVacOpts , multixact_freeze_min_age )},
18861860 {"autovacuum_multixact_freeze_max_age" , RELOPT_TYPE_INT ,
1887- offsetof(HeapRdOptions , common ) +
1888- offsetof(CommonRdOptions , autovacuum ) +
1889- offsetof(AutoVacOpts , multixact_freeze_max_age )},
1861+ offsetof(StdRdOptions , autovacuum ) + offsetof(AutoVacOpts , multixact_freeze_max_age )},
18901862 {"autovacuum_multixact_freeze_table_age" , RELOPT_TYPE_INT ,
1891- offsetof(HeapRdOptions , common ) +
1892- offsetof(CommonRdOptions , autovacuum ) +
1893- offsetof(AutoVacOpts , multixact_freeze_table_age )},
1863+ offsetof(StdRdOptions , autovacuum ) + offsetof(AutoVacOpts , multixact_freeze_table_age )},
18941864 {"log_autovacuum_min_duration" , RELOPT_TYPE_INT ,
1895- offsetof(HeapRdOptions , common ) +
1896- offsetof(CommonRdOptions , autovacuum ) +
1897- offsetof(AutoVacOpts , log_min_duration )},
1865+ offsetof(StdRdOptions , autovacuum ) + offsetof(AutoVacOpts , log_min_duration )},
18981866 {"toast_tuple_target" , RELOPT_TYPE_INT ,
1899- offsetof(HeapRdOptions , toast_tuple_target )},
1867+ offsetof(StdRdOptions , toast_tuple_target )},
19001868 {"autovacuum_vacuum_cost_delay" , RELOPT_TYPE_REAL ,
1901- offsetof(HeapRdOptions , common ) +
1902- offsetof(CommonRdOptions , autovacuum ) +
1903- offsetof(AutoVacOpts , vacuum_cost_delay )},
1869+ offsetof(StdRdOptions , autovacuum ) + offsetof(AutoVacOpts , vacuum_cost_delay )},
19041870 {"autovacuum_vacuum_scale_factor" , RELOPT_TYPE_REAL ,
1905- offsetof(HeapRdOptions , common ) +
1906- offsetof(CommonRdOptions , autovacuum ) +
1907- offsetof(AutoVacOpts , vacuum_scale_factor )},
1871+ offsetof(StdRdOptions , autovacuum ) + offsetof(AutoVacOpts , vacuum_scale_factor )},
19081872 {"autovacuum_vacuum_insert_scale_factor" , RELOPT_TYPE_REAL ,
1909- offsetof(HeapRdOptions , common ) +
1910- offsetof(CommonRdOptions , autovacuum ) +
1911- offsetof(AutoVacOpts , vacuum_ins_scale_factor )},
1873+ offsetof(StdRdOptions , autovacuum ) + offsetof(AutoVacOpts , vacuum_ins_scale_factor )},
19121874 {"autovacuum_analyze_scale_factor" , RELOPT_TYPE_REAL ,
1913- offsetof(HeapRdOptions , common ) +
1914- offsetof(CommonRdOptions , autovacuum ) +
1915- offsetof(AutoVacOpts , analyze_scale_factor )},
1875+ offsetof(StdRdOptions , autovacuum ) + offsetof(AutoVacOpts , analyze_scale_factor )},
19161876 {"user_catalog_table" , RELOPT_TYPE_BOOL ,
1917- offsetof(HeapRdOptions , common ) +
1918- offsetof(CommonRdOptions , user_catalog_table )},
1877+ offsetof(StdRdOptions , user_catalog_table )},
19191878 {"parallel_workers" , RELOPT_TYPE_INT ,
1920- offsetof(HeapRdOptions , common ) +
1921- offsetof(CommonRdOptions , parallel_workers )},
1879+ offsetof(StdRdOptions , parallel_workers )},
19221880 {"vacuum_index_cleanup" , RELOPT_TYPE_ENUM ,
1923- offsetof(HeapRdOptions , common ) +
1924- offsetof(CommonRdOptions , vacuum_index_cleanup )},
1881+ offsetof(StdRdOptions , vacuum_index_cleanup )},
19251882 {"vacuum_truncate" , RELOPT_TYPE_BOOL ,
1926- offsetof(HeapRdOptions , common ) +
1927- offsetof(CommonRdOptions , vacuum_truncate )}
1883+ offsetof(StdRdOptions , vacuum_truncate )}
19281884 };
19291885
19301886 return (bytea * ) build_reloptions (reloptions , validate , kind ,
1931- sizeof (HeapRdOptions ),
1887+ sizeof (StdRdOptions ),
19321888 tab , lengthof (tab ));
19331889}
19341890
@@ -2056,65 +2012,30 @@ view_reloptions(Datum reloptions, bool validate)
20562012 tab , lengthof (tab ));
20572013}
20582014
2059- /*
2060- * Fill CommonRdOptions with the default values.
2061- */
2062- void
2063- fill_default_common_reloptions (CommonRdOptions * common )
2064- {
2065- common -> autovacuum .enabled = true;
2066- common -> autovacuum .vacuum_threshold = -1 ;
2067- common -> autovacuum .vacuum_ins_threshold = -2 ;
2068- common -> autovacuum .analyze_threshold = -1 ;
2069- common -> autovacuum .vacuum_cost_limit = -1 ;
2070- common -> autovacuum .freeze_min_age = -1 ;
2071- common -> autovacuum .freeze_max_age = -1 ;
2072- common -> autovacuum .freeze_table_age = -1 ;
2073- common -> autovacuum .multixact_freeze_min_age = -1 ;
2074- common -> autovacuum .multixact_freeze_max_age = -1 ;
2075- common -> autovacuum .multixact_freeze_table_age = -1 ;
2076- common -> autovacuum .log_min_duration = -1 ;
2077- common -> autovacuum .vacuum_cost_delay = -1 ;
2078- common -> autovacuum .vacuum_scale_factor = -1 ;
2079- common -> autovacuum .vacuum_ins_scale_factor = -1 ;
2080- common -> autovacuum .analyze_scale_factor = -1 ;
2081- common -> parallel_workers = -1 ;
2082- common -> user_catalog_table = false;
2083- common -> vacuum_index_cleanup = STDRD_OPTION_VACUUM_INDEX_CLEANUP_AUTO ;
2084- common -> vacuum_truncate = true;
2085- }
2086-
20872015/*
20882016 * Parse options for heaps, views and toast tables.
20892017 */
20902018bytea *
2091- heap_reloptions (char relkind , Datum reloptions ,
2092- CommonRdOptions * common , bool validate )
2019+ heap_reloptions (char relkind , Datum reloptions , bool validate )
20932020{
2094- HeapRdOptions * rdopts ;
2021+ StdRdOptions * rdopts ;
20952022
20962023 switch (relkind )
20972024 {
20982025 case RELKIND_TOASTVALUE :
2099- rdopts = (HeapRdOptions * )
2026+ rdopts = (StdRdOptions * )
21002027 default_reloptions (reloptions , validate , RELOPT_KIND_TOAST );
21012028 if (rdopts != NULL )
21022029 {
21032030 /* adjust default-only parameters for TOAST relations */
21042031 rdopts -> fillfactor = 100 ;
2105- rdopts -> common . autovacuum .analyze_threshold = -1 ;
2106- rdopts -> common . autovacuum .analyze_scale_factor = -1 ;
2032+ rdopts -> autovacuum .analyze_threshold = -1 ;
2033+ rdopts -> autovacuum .analyze_scale_factor = -1 ;
21072034 }
2108- if (rdopts != NULL && common != NULL )
2109- * common = rdopts -> common ;
21102035 return (bytea * ) rdopts ;
21112036 case RELKIND_RELATION :
21122037 case RELKIND_MATVIEW :
2113- rdopts = (HeapRdOptions * )
2114- default_reloptions (reloptions , validate , RELOPT_KIND_HEAP );
2115- if (rdopts != NULL && common != NULL )
2116- * common = rdopts -> common ;
2117- return (bytea * ) rdopts ;
2038+ return default_reloptions (reloptions , validate , RELOPT_KIND_HEAP );
21182039 default :
21192040 /* other relkinds are not supported */
21202041 return NULL ;
0 commit comments