1/*-------------------------------------------------------------------------
4 * Core support for relation and tablespace options (pg_class.reloptions
5 * and pg_tablespace.spcoptions)
7 * Note: the functions dealing with text-array reloptions values declare
8 * them as Datum, not ArrayType *, to avoid needing to include array.h
9 * into a lot of low-level code.
12 * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
13 * Portions Copyright (c) 1994, Regents of the University of California
15 * src/include/access/reloptions.h
17 *-------------------------------------------------------------------------
28/* types supported by reloptions */
38/* kinds supported by reloptions */
54 /* if you add a new kind, make sure you update "last_default" too */
56 /* some compilers treat enums as signed ints, so we can't use 1 << 31 */
60/* reloption namespaces allowed for heaps -- currently only TOAST */
61 #define HEAP_RELOPT_NAMESPACES { "toast", NULL }
63/* generic struct to hold shared data */
66 const char *
name;
/* must be first (used as list termination
75/* holds a parsed value */
90/* reloptions records for specific variable types */
114 * relopt_enum_elt_def -- One member of the array of acceptable values
115 * of an enum reloption.
129 /* null-terminated array of members */
132/* validation routines for strings */
136/* validation routine for the whole option set */
149/* This is the table datatype for build_reloptions() */
154 int offset;
/* offset of field in result struct */
157 * isset_offset is an optional offset of a field in the result struct that
158 * stores whether the option is explicitly set for the relation or if it
159 * just picked up the default value. In most cases, this can be
160 * accomplished by giving the reloption a special out-of-range default
161 * value (e.g., some integer reloptions use -2), but this isn't always
162 * possible. For example, a Boolean reloption cannot be given an
163 * out-of-range default, so we need another way to discover the source of
164 * its value. This offset is only used if given a value greater than
170/* Local reloption definition */
174 int offset;
/* offset of parsed value in bytea structure */
177/* Structure to hold local reloption data for build_local_reloptions() */
186 * Utility macro to get a value for a string reloption once the options
187 * are parsed. This gets a pointer to the string value itself. "optstruct"
188 * is the StdRdOptions struct or equivalent, "member" is the struct member
189 * corresponding to the string option.
191 #define GET_STRING_RELOPTION(optstruct, member) \
192 ((optstruct)->member == 0 ? NULL : \
193 (char *)(optstruct) + (optstruct)->member)
197 bool default_val,
LOCKMODE lockmode);
199 int default_val,
int min_val,
int max_val,
202 double default_val,
double min_val,
double max_val,
206 const char *detailmsg,
LOCKMODE lockmode);
215 const char *desc,
bool default_val,
218 const char *desc,
int default_val,
219 int min_val,
int max_val,
int offset);
221 const char *desc,
double default_val,
222 double min_val,
double max_val,
225 const char *
name,
const char *desc,
227 int default_val,
const char *detailmsg,
231 const char *default_val,
236 const char *nameSpace,
const char *
const validnsps[],
237 bool acceptOidsOff,
bool isReset);
243 Size relopt_struct_size,
245 int num_relopt_elems);
260#endif /* RELOPTIONS_H */
bytea *(* amoptions_function)(Datum reloptions, bool validate)
static bool validate(Port *port, const char *auth)
void add_local_string_reloption(local_relopts *relopts, const char *name, const char *desc, const char *default_val, validate_string_relopt validator, fill_string_relopt filler, int offset)
void add_int_reloption(bits32 kinds, const char *name, const char *desc, int default_val, int min_val, int max_val, LOCKMODE lockmode)
struct relopt_gen relopt_gen
bytea * default_reloptions(Datum reloptions, bool validate, relopt_kind kind)
bytea * tablespace_reloptions(Datum reloptions, bool validate)
void add_string_reloption(bits32 kinds, const char *name, const char *desc, const char *default_val, validate_string_relopt validator, LOCKMODE lockmode)
struct relopt_real relopt_real
List * untransformRelOptions(Datum options)
Size(* fill_string_relopt)(const char *value, void *ptr)
struct relopt_bool relopt_bool
bytea * view_reloptions(Datum reloptions, bool validate)
@ RELOPT_KIND_LAST_DEFAULT
@ RELOPT_KIND_PARTITIONED
bytea * index_reloptions(amoptions_function amoptions, Datum reloptions, bool validate)
void add_enum_reloption(bits32 kinds, const char *name, const char *desc, relopt_enum_elt_def *members, int default_val, const char *detailmsg, LOCKMODE lockmode)
void * build_reloptions(Datum reloptions, bool validate, relopt_kind kind, Size relopt_struct_size, const relopt_parse_elt *relopt_elems, int num_relopt_elems)
bytea * partitioned_table_reloptions(Datum reloptions, bool validate)
void add_real_reloption(bits32 kinds, const char *name, const char *desc, double default_val, double min_val, double max_val, LOCKMODE lockmode)
struct relopt_string relopt_string
void add_local_bool_reloption(local_relopts *relopts, const char *name, const char *desc, bool default_val, int offset)
void init_local_reloptions(local_relopts *relopts, Size relopt_struct_size)
void add_local_real_reloption(local_relopts *relopts, const char *name, const char *desc, double default_val, double min_val, double max_val, int offset)
void(* validate_string_relopt)(const char *value)
void add_bool_reloption(bits32 kinds, const char *name, const char *desc, bool default_val, LOCKMODE lockmode)
Datum transformRelOptions(Datum oldOptions, List *defList, const char *nameSpace, const char *const validnsps[], bool acceptOidsOff, bool isReset)
void add_local_enum_reloption(local_relopts *relopts, const char *name, const char *desc, relopt_enum_elt_def *members, int default_val, const char *detailmsg, int offset)
bytea * extractRelOptions(HeapTuple tuple, TupleDesc tupdesc, amoptions_function amoptions)
struct local_relopts local_relopts
relopt_kind add_reloption_kind(void)
struct relopt_enum relopt_enum
void * build_local_reloptions(local_relopts *relopts, Datum options, bool validate)
void register_reloptions_validator(local_relopts *relopts, relopts_validator validator)
LOCKMODE AlterTableGetRelOptionsLockLevel(List *defList)
bytea * attribute_reloptions(Datum reloptions, bool validate)
void add_local_int_reloption(local_relopts *relopts, const char *name, const char *desc, int default_val, int min_val, int max_val, int offset)
struct relopt_value relopt_value
void(* relopts_validator)(void *parsed_options, relopt_value *vals, int nvals)
struct relopt_enum_elt_def relopt_enum_elt_def
struct relopt_int relopt_int
bytea * heap_reloptions(char relkind, Datum reloptions, bool validate)
struct local_relopt local_relopt
relopt_enum_elt_def * members
validate_string_relopt validate_cb
fill_string_relopt fill_cb
union relopt_value::@52 values