diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/access/reloptions.h | 11 | ||||
-rw-r--r-- | src/include/access/tableam.h | 50 | ||||
-rw-r--r-- | src/include/utils/rel.h | 148 |
3 files changed, 74 insertions, 135 deletions
diff --git a/src/include/access/reloptions.h b/src/include/access/reloptions.h index a3560500f36..81829b8270a 100644 --- a/src/include/access/reloptions.h +++ b/src/include/access/reloptions.h @@ -21,7 +21,6 @@ #include "access/amapi.h" #include "access/htup.h" -#include "access/tableam.h" #include "access/tupdesc.h" #include "nodes/pg_list.h" #include "storage/lock.h" @@ -225,9 +224,7 @@ extern Datum transformRelOptions(Datum oldOptions, List *defList, bool acceptOidsOff, bool isReset); extern List *untransformRelOptions(Datum options); extern bytea *extractRelOptions(HeapTuple tuple, TupleDesc tupdesc, - const TableAmRoutine *tableam, - amoptions_function amoptions, - CommonRdOptions *common); + amoptions_function amoptions); extern void *build_reloptions(Datum reloptions, bool validate, relopt_kind kind, Size relopt_struct_size, @@ -236,9 +233,9 @@ extern void *build_reloptions(Datum reloptions, bool validate, extern void *build_local_reloptions(local_relopts *relopts, Datum options, bool validate); -extern void fill_default_common_reloptions(CommonRdOptions *common); -extern bytea *heap_reloptions(char relkind, Datum reloptions, - CommonRdOptions *common, bool validate); +extern bytea *default_reloptions(Datum reloptions, bool validate, + relopt_kind kind); +extern bytea *heap_reloptions(char relkind, Datum reloptions, bool validate); extern bytea *view_reloptions(Datum reloptions, bool validate); extern bytea *partitioned_table_reloptions(Datum reloptions, bool validate); extern bytea *index_reloptions(amoptions_function amoptions, Datum reloptions, diff --git a/src/include/access/tableam.h b/src/include/access/tableam.h index d1cd71b7a17..a07f250b462 100644 --- a/src/include/access/tableam.h +++ b/src/include/access/tableam.h @@ -746,34 +746,6 @@ typedef struct TableAmRoutine int32 slicelength, struct varlena *result); - /* - * This callback parses and validates the reloptions array for a table. - * - * This is called only when a non-null reloptions array exists for the - * table. '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 table's relcache entry. The - * data contents of the bytea value are open for the access method to - * define. - * - * The '*common' represents the common values, which the table access - * method exposes for autovacuum, query planner, and others. The caller - * should fill them with default values. The table access method may - * modify them on the base of options specified by a user. - * - * 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. - */ - bytea *(*reloptions) (char relkind, Datum reloptions, - CommonRdOptions *common, bool validate); - /* ------------------------------------------------------------------------ * Planner related functions. @@ -1986,27 +1958,6 @@ table_relation_fetch_toast_slice(Relation toastrel, Oid valueid, result); } -/* - * Parse table options without knowledge of particular table. - */ -static inline bytea * -tableam_reloptions(const TableAmRoutine *tableam, char relkind, - Datum reloptions, CommonRdOptions *common, bool validate) -{ - return tableam->reloptions(relkind, reloptions, common, validate); -} - -/* - * Parse options for given table. - */ -static inline bytea * -table_reloptions(Relation rel, char relkind, - Datum reloptions, CommonRdOptions *common, bool validate) -{ - return tableam_reloptions(rel->rd_tableam, relkind, reloptions, - common, validate); -} - /* ---------------------------------------------------------------------------- * Planner related functionality @@ -2185,7 +2136,6 @@ extern void table_block_relation_estimate_size(Relation rel, */ extern const TableAmRoutine *GetTableAmRoutine(Oid amhandler); -extern const TableAmRoutine *GetTableAmRoutineByAmOid(Oid amoid); /* ---------------------------------------------------------------------------- * Functions in heapam_handler.c diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h index 56e3e782d27..f25f769af2b 100644 --- a/src/include/utils/rel.h +++ b/src/include/utils/rel.h @@ -48,52 +48,6 @@ typedef struct LockInfoData typedef LockInfoData *LockInfo; - /* autovacuum-related reloptions. */ -typedef struct AutoVacOpts -{ - bool enabled; - int vacuum_threshold; - int vacuum_ins_threshold; - int analyze_threshold; - int vacuum_cost_limit; - int freeze_min_age; - int freeze_max_age; - int freeze_table_age; - int multixact_freeze_min_age; - int multixact_freeze_max_age; - int multixact_freeze_table_age; - int log_min_duration; - float8 vacuum_cost_delay; - float8 vacuum_scale_factor; - float8 vacuum_ins_scale_factor; - float8 analyze_scale_factor; -} AutoVacOpts; - -/* StdRdOptions->vacuum_index_cleanup values */ -typedef enum StdRdOptIndexCleanup -{ - STDRD_OPTION_VACUUM_INDEX_CLEANUP_AUTO = 0, - STDRD_OPTION_VACUUM_INDEX_CLEANUP_OFF, - STDRD_OPTION_VACUUM_INDEX_CLEANUP_ON, -} StdRdOptIndexCleanup; - -/* - * CommonRdOptions - * Contents of rd_common_options for tables. It contains the options, - * which the table access method exposes for autovacuum, query planner, - * and others. These options could be by decision of table AM directly - * specified by a user or calculated in some way. - */ -typedef struct CommonRdOptions -{ - AutoVacOpts autovacuum; /* autovacuum-related options */ - bool user_catalog_table; /* use as an additional catalog relation */ - int parallel_workers; /* max number of parallel workers */ - StdRdOptIndexCleanup vacuum_index_cleanup; /* controls index vacuuming */ - bool vacuum_truncate; /* enables vacuum to truncate a relation */ -} CommonRdOptions; - - /* * Here are the contents of a relation cache entry. */ @@ -214,19 +168,11 @@ typedef struct RelationData PublicationDesc *rd_pubdesc; /* publication descriptor, or NULL */ /* - * rd_options and rd_common_options are set whenever rd_rel is loaded into - * the relcache entry. Note that you can NOT look into rd_rel for this - * data. NULLs means "use defaults". - */ - CommonRdOptions *rd_common_options; /* the options, which table AM exposes - * for external usage */ - - /* - * am-specific part of pg_class.reloptions parsed by table am specific - * structure (e.g. struct HeapRdOptions) Contents are not to be accessed - * outside of table am + * rd_options is set whenever rd_rel is loaded into the relcache entry. + * Note that you can NOT look into rd_rel for this data. NULL means "use + * defaults". */ - bytea *rd_options; + bytea *rd_options; /* parsed pg_class.reloptions */ /* * Oid of the handler for this relation. For an index this is a function @@ -351,42 +297,88 @@ typedef struct ForeignKeyCacheInfo Oid conpfeqop[INDEX_MAX_KEYS] pg_node_attr(array_size(nkeys)); } ForeignKeyCacheInfo; + /* - * HeapRdOptions - * Contents of rd_options specific for heap tables. + * StdRdOptions + * Standard contents of rd_options for heaps. + * + * RelationGetFillFactor() and RelationGetTargetPageFreeSpace() can only + * be applied to relations that use this format or a superset for + * private options data. */ -typedef struct HeapRdOptions + /* autovacuum-related reloptions. */ +typedef struct AutoVacOpts +{ + bool enabled; + int vacuum_threshold; + int vacuum_ins_threshold; + int analyze_threshold; + int vacuum_cost_limit; + int freeze_min_age; + int freeze_max_age; + int freeze_table_age; + int multixact_freeze_min_age; + int multixact_freeze_max_age; + int multixact_freeze_table_age; + int log_min_duration; + float8 vacuum_cost_delay; + float8 vacuum_scale_factor; + float8 vacuum_ins_scale_factor; + float8 analyze_scale_factor; +} AutoVacOpts; + +/* StdRdOptions->vacuum_index_cleanup values */ +typedef enum StdRdOptIndexCleanup +{ + STDRD_OPTION_VACUUM_INDEX_CLEANUP_AUTO = 0, + STDRD_OPTION_VACUUM_INDEX_CLEANUP_OFF, + STDRD_OPTION_VACUUM_INDEX_CLEANUP_ON, +} StdRdOptIndexCleanup; + +typedef struct StdRdOptions { int32 vl_len_; /* varlena header (do not touch directly!) */ - CommonRdOptions common; int fillfactor; /* page fill factor in percent (0..100) */ int toast_tuple_target; /* target for tuple toasting */ -} HeapRdOptions; + AutoVacOpts autovacuum; /* autovacuum-related options */ + bool user_catalog_table; /* use as an additional catalog relation */ + int parallel_workers; /* max number of parallel workers */ + StdRdOptIndexCleanup vacuum_index_cleanup; /* controls index vacuuming */ + bool vacuum_truncate; /* enables vacuum to truncate a relation */ +} StdRdOptions; #define HEAP_MIN_FILLFACTOR 10 #define HEAP_DEFAULT_FILLFACTOR 100 /* - * HeapGetFillFactor - * Returns the heap relation's fillfactor. Note multiple eval of argument! + * RelationGetToastTupleTarget + * Returns the relation's toast_tuple_target. Note multiple eval of argument! */ -#define HeapGetFillFactor(relation, defaultff) \ +#define RelationGetToastTupleTarget(relation, defaulttarg) \ ((relation)->rd_options ? \ - ((HeapRdOptions *) (relation)->rd_options)->fillfactor : (defaultff)) + ((StdRdOptions *) (relation)->rd_options)->toast_tuple_target : (defaulttarg)) /* - * HeapGetTargetPageUsage + * RelationGetFillFactor + * Returns the relation's fillfactor. Note multiple eval of argument! + */ +#define RelationGetFillFactor(relation, defaultff) \ + ((relation)->rd_options ? \ + ((StdRdOptions *) (relation)->rd_options)->fillfactor : (defaultff)) + +/* + * RelationGetTargetPageUsage * Returns the relation's desired space usage per page in bytes. */ -#define HeapGetTargetPageUsage(relation, defaultff) \ - (BLCKSZ * HeapGetFillFactor(relation, defaultff) / 100) +#define RelationGetTargetPageUsage(relation, defaultff) \ + (BLCKSZ * RelationGetFillFactor(relation, defaultff) / 100) /* - * HeapGetTargetPageFreeSpace + * RelationGetTargetPageFreeSpace * Returns the relation's desired freespace per page in bytes. */ -#define HeapGetTargetPageFreeSpace(relation, defaultff) \ - (BLCKSZ * (100 - HeapGetFillFactor(relation, defaultff)) / 100) +#define RelationGetTargetPageFreeSpace(relation, defaultff) \ + (BLCKSZ * (100 - RelationGetFillFactor(relation, defaultff)) / 100) /* * RelationIsUsedAsCatalogTable @@ -394,10 +386,10 @@ typedef struct HeapRdOptions * from the pov of logical decoding. Note multiple eval of argument! */ #define RelationIsUsedAsCatalogTable(relation) \ - ((relation)->rd_common_options && \ - ((relation)->rd_rel->relkind == RELKIND_RELATION || \ + ((relation)->rd_options && \ + ((relation)->rd_rel->relkind == RELKIND_RELATION || \ (relation)->rd_rel->relkind == RELKIND_MATVIEW) ? \ - (relation)->rd_common_options->user_catalog_table : false) + ((StdRdOptions *) (relation)->rd_options)->user_catalog_table : false) /* * RelationGetParallelWorkers @@ -405,8 +397,8 @@ typedef struct HeapRdOptions * Note multiple eval of argument! */ #define RelationGetParallelWorkers(relation, defaultpw) \ - ((relation)->rd_common_options ? \ - (relation)->rd_common_options->parallel_workers : (defaultpw)) + ((relation)->rd_options ? \ + ((StdRdOptions *) (relation)->rd_options)->parallel_workers : (defaultpw)) /* ViewOptions->check_option values */ typedef enum ViewOptCheckOption |