24
24
#include "access/nbtree.h"
25
25
#include "access/reloptions.h"
26
26
#include "access/spgist_private.h"
27
- #include "access/tableam.h"
28
27
#include "catalog/pg_type.h"
29
28
#include "commands/defrem.h"
30
29
#include "commands/tablespace.h"
45
44
* value, upper and lower bounds (if applicable); for strings, consider a
46
45
* validation routine.
47
46
* (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 )
49
48
* (iv) add it to the appropriate handling routine (perhaps
50
49
* default_reloptions)
51
50
* (v) make sure the lock level is set correctly for that operation
@@ -1375,16 +1374,10 @@ untransformRelOptions(Datum options)
1375
1374
* tupdesc is pg_class' tuple descriptor. amoptions is a pointer to the index
1376
1375
* AM's options parser function in the case of a tuple corresponding to an
1377
1376
* 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.
1382
1377
*/
1383
-
1384
1378
bytea *
1385
1379
extractRelOptions (HeapTuple tuple , TupleDesc tupdesc ,
1386
- const TableAmRoutine * tableam , amoptions_function amoptions ,
1387
- CommonRdOptions * common )
1380
+ amoptions_function amoptions )
1388
1381
{
1389
1382
bytea * options ;
1390
1383
bool isnull ;
@@ -1406,8 +1399,7 @@ extractRelOptions(HeapTuple tuple, TupleDesc tupdesc,
1406
1399
case RELKIND_RELATION :
1407
1400
case RELKIND_TOASTVALUE :
1408
1401
case RELKIND_MATVIEW :
1409
- options = tableam_reloptions (tableam , classForm -> relkind ,
1410
- datum , common , false);
1402
+ options = heap_reloptions (classForm -> relkind , datum , false);
1411
1403
break ;
1412
1404
case RELKIND_PARTITIONED_TABLE :
1413
1405
options = partitioned_table_reloptions (datum , false);
@@ -1703,7 +1695,7 @@ parse_one_reloption(relopt_value *option, char *text_str, int text_len,
1703
1695
* Given the result from parseRelOptions, allocate a struct that's of the
1704
1696
* specified base size plus any extra space that's needed for string variables.
1705
1697
*
1706
- * "base" should be sizeof(struct) of the reloptions struct (HeapRdOptions or
1698
+ * "base" should be sizeof(struct) of the reloptions struct (StdRdOptions or
1707
1699
* equivalent).
1708
1700
*/
1709
1701
static void *
@@ -1840,95 +1832,59 @@ fillRelOptions(void *rdopts, Size basesize,
1840
1832
1841
1833
1842
1834
/*
1843
- * Option parser for anything that uses HeapRdOptions .
1835
+ * Option parser for anything that uses StdRdOptions .
1844
1836
*/
1845
- static bytea *
1837
+ bytea *
1846
1838
default_reloptions (Datum reloptions , bool validate , relopt_kind kind )
1847
1839
{
1848
1840
static const relopt_parse_elt tab [] = {
1849
- {"fillfactor" , RELOPT_TYPE_INT , offsetof(HeapRdOptions , fillfactor )},
1841
+ {"fillfactor" , RELOPT_TYPE_INT , offsetof(StdRdOptions , fillfactor )},
1850
1842
{"autovacuum_enabled" , RELOPT_TYPE_BOOL ,
1851
- offsetof(HeapRdOptions , common ) +
1852
- offsetof(CommonRdOptions , autovacuum ) +
1853
- offsetof(AutoVacOpts , enabled )},
1843
+ offsetof(StdRdOptions , autovacuum ) + offsetof(AutoVacOpts , enabled )},
1854
1844
{"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 )},
1858
1846
{"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 )},
1862
1848
{"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 )},
1866
1850
{"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 )},
1870
1852
{"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 )},
1874
1854
{"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 )},
1878
1856
{"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 )},
1882
1858
{"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 )},
1886
1860
{"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 )},
1890
1862
{"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 )},
1894
1864
{"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 )},
1898
1866
{"toast_tuple_target" , RELOPT_TYPE_INT ,
1899
- offsetof(HeapRdOptions , toast_tuple_target )},
1867
+ offsetof(StdRdOptions , toast_tuple_target )},
1900
1868
{"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 )},
1904
1870
{"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 )},
1908
1872
{"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 )},
1912
1874
{"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 )},
1916
1876
{"user_catalog_table" , RELOPT_TYPE_BOOL ,
1917
- offsetof(HeapRdOptions , common ) +
1918
- offsetof(CommonRdOptions , user_catalog_table )},
1877
+ offsetof(StdRdOptions , user_catalog_table )},
1919
1878
{"parallel_workers" , RELOPT_TYPE_INT ,
1920
- offsetof(HeapRdOptions , common ) +
1921
- offsetof(CommonRdOptions , parallel_workers )},
1879
+ offsetof(StdRdOptions , parallel_workers )},
1922
1880
{"vacuum_index_cleanup" , RELOPT_TYPE_ENUM ,
1923
- offsetof(HeapRdOptions , common ) +
1924
- offsetof(CommonRdOptions , vacuum_index_cleanup )},
1881
+ offsetof(StdRdOptions , vacuum_index_cleanup )},
1925
1882
{"vacuum_truncate" , RELOPT_TYPE_BOOL ,
1926
- offsetof(HeapRdOptions , common ) +
1927
- offsetof(CommonRdOptions , vacuum_truncate )}
1883
+ offsetof(StdRdOptions , vacuum_truncate )}
1928
1884
};
1929
1885
1930
1886
return (bytea * ) build_reloptions (reloptions , validate , kind ,
1931
- sizeof (HeapRdOptions ),
1887
+ sizeof (StdRdOptions ),
1932
1888
tab , lengthof (tab ));
1933
1889
}
1934
1890
@@ -2056,65 +2012,30 @@ view_reloptions(Datum reloptions, bool validate)
2056
2012
tab , lengthof (tab ));
2057
2013
}
2058
2014
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
-
2087
2015
/*
2088
2016
* Parse options for heaps, views and toast tables.
2089
2017
*/
2090
2018
bytea *
2091
- heap_reloptions (char relkind , Datum reloptions ,
2092
- CommonRdOptions * common , bool validate )
2019
+ heap_reloptions (char relkind , Datum reloptions , bool validate )
2093
2020
{
2094
- HeapRdOptions * rdopts ;
2021
+ StdRdOptions * rdopts ;
2095
2022
2096
2023
switch (relkind )
2097
2024
{
2098
2025
case RELKIND_TOASTVALUE :
2099
- rdopts = (HeapRdOptions * )
2026
+ rdopts = (StdRdOptions * )
2100
2027
default_reloptions (reloptions , validate , RELOPT_KIND_TOAST );
2101
2028
if (rdopts != NULL )
2102
2029
{
2103
2030
/* adjust default-only parameters for TOAST relations */
2104
2031
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 ;
2107
2034
}
2108
- if (rdopts != NULL && common != NULL )
2109
- * common = rdopts -> common ;
2110
2035
return (bytea * ) rdopts ;
2111
2036
case RELKIND_RELATION :
2112
2037
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 );
2118
2039
default :
2119
2040
/* other relkinds are not supported */
2120
2041
return NULL ;
0 commit comments