PostgreSQL Source Code git master
Loading...
Searching...
No Matches
reloptions.c File Reference
#include "postgres.h"
#include <float.h>
#include "access/gist_private.h"
#include "access/hash.h"
#include "access/heaptoast.h"
#include "access/htup_details.h"
#include "access/nbtree.h"
#include "access/reloptions.h"
#include "access/spgist_private.h"
#include "catalog/pg_type.h"
#include "commands/defrem.h"
#include "commands/tablespace.h"
#include "nodes/makefuncs.h"
#include "storage/lock.h"
#include "utils/array.h"
#include "utils/attoptcache.h"
#include "utils/builtins.h"
#include "utils/guc.h"
#include "utils/memutils.h"
#include "utils/rel.h"
Include dependency graph for reloptions.c:

Go to the source code of this file.

Macros

#define GET_STRING_RELOPTION_LEN(option)
 

Functions

static void initialize_reloptions (void)
 
static void parse_one_reloption (relopt_value *option, char *text_str, int text_len, bool validate)
 
relopt_kind add_reloption_kind (void)
 
static void add_reloption (relopt_gen *newoption)
 
void init_local_reloptions (local_relopts *relopts, Size relopt_struct_size)
 
void register_reloptions_validator (local_relopts *relopts, relopts_validator validator)
 
static void add_local_reloption (local_relopts *relopts, relopt_gen *newoption, int offset)
 
static relopt_genallocate_reloption (bits32 kinds, int type, const char *name, const char *desc, LOCKMODE lockmode)
 
static relopt_boolinit_bool_reloption (bits32 kinds, const char *name, const char *desc, bool default_val, LOCKMODE lockmode)
 
void add_bool_reloption (bits32 kinds, const char *name, const char *desc, bool default_val, LOCKMODE lockmode)
 
void add_local_bool_reloption (local_relopts *relopts, const char *name, const char *desc, bool default_val, int offset)
 
static relopt_ternaryinit_ternary_reloption (bits32 kinds, const char *name, const char *desc, LOCKMODE lockmode)
 
void add_ternary_reloption (bits32 kinds, const char *name, const char *desc, LOCKMODE lockmode)
 
void add_local_ternary_reloption (local_relopts *relopts, const char *name, const char *desc, int offset)
 
static relopt_intinit_int_reloption (bits32 kinds, const char *name, const char *desc, int default_val, int min_val, int max_val, LOCKMODE lockmode)
 
void add_int_reloption (bits32 kinds, const char *name, const char *desc, int default_val, int min_val, int max_val, LOCKMODE lockmode)
 
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)
 
static relopt_realinit_real_reloption (bits32 kinds, const char *name, const char *desc, double default_val, double min_val, double max_val, LOCKMODE lockmode)
 
void add_real_reloption (bits32 kinds, const char *name, const char *desc, double default_val, double min_val, double max_val, LOCKMODE lockmode)
 
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)
 
static relopt_enuminit_enum_reloption (bits32 kinds, const char *name, const char *desc, relopt_enum_elt_def *members, int default_val, const char *detailmsg, LOCKMODE lockmode)
 
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 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)
 
static relopt_stringinit_string_reloption (bits32 kinds, const char *name, const char *desc, const char *default_val, validate_string_relopt validator, fill_string_relopt filler, LOCKMODE lockmode)
 
void add_string_reloption (bits32 kinds, const char *name, const char *desc, const char *default_val, validate_string_relopt validator, LOCKMODE lockmode)
 
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)
 
Datum transformRelOptions (Datum oldOptions, List *defList, const char *nameSpace, const char *const validnsps[], bool acceptOidsOff, bool isReset)
 
ListuntransformRelOptions (Datum options)
 
byteaextractRelOptions (HeapTuple tuple, TupleDesc tupdesc, amoptions_function amoptions)
 
static void parseRelOptionsInternal (Datum options, bool validate, relopt_value *reloptions, int numoptions)
 
static relopt_valueparseRelOptions (Datum options, bool validate, relopt_kind kind, int *numrelopts)
 
static relopt_valueparseLocalRelOptions (local_relopts *relopts, Datum options, bool validate)
 
static voidallocateReloptStruct (Size base, relopt_value *options, int numoptions)
 
static void fillRelOptions (void *rdopts, Size basesize, relopt_value *options, int numoptions, bool validate, const relopt_parse_elt *elems, int numelems)
 
byteadefault_reloptions (Datum reloptions, bool validate, relopt_kind kind)
 
voidbuild_reloptions (Datum reloptions, bool validate, relopt_kind kind, Size relopt_struct_size, const relopt_parse_elt *relopt_elems, int num_relopt_elems)
 
voidbuild_local_reloptions (local_relopts *relopts, Datum options, bool validate)
 
byteapartitioned_table_reloptions (Datum reloptions, bool validate)
 
byteaview_reloptions (Datum reloptions, bool validate)
 
byteaheap_reloptions (char relkind, Datum reloptions, bool validate)
 
byteaindex_reloptions (amoptions_function amoptions, Datum reloptions, bool validate)
 
byteaattribute_reloptions (Datum reloptions, bool validate)
 
byteatablespace_reloptions (Datum reloptions, bool validate)
 
LOCKMODE AlterTableGetRelOptionsLockLevel (List *defList)
 

Variables

static relopt_bool boolRelOpts []
 
static relopt_ternary ternaryRelOpts []
 
static relopt_int intRelOpts []
 
static relopt_real realRelOpts []
 
static relopt_enum_elt_def StdRdOptIndexCleanupValues []
 
static relopt_enum_elt_def gistBufferingOptValues []
 
static relopt_enum_elt_def viewCheckOptValues []
 
static relopt_enum enumRelOpts []
 
static relopt_string stringRelOpts []
 
static relopt_gen ** relOpts = NULL
 
static bits32 last_assigned_kind = RELOPT_KIND_LAST_DEFAULT
 
static int num_custom_options = 0
 
static relopt_gen ** custom_options = NULL
 
static bool need_initialization = true
 

Macro Definition Documentation

◆ GET_STRING_RELOPTION_LEN

#define GET_STRING_RELOPTION_LEN (   option)
Value:
((option).isset ? strlen((option).string_val) : \
((relopt_string *) (option).gen)->default_len)
static int fb(int x)

Definition at line 603 of file reloptions.c.

604 : \
605 ((relopt_string *) (option).gen)->default_len)

Function Documentation

◆ add_bool_reloption()

void add_bool_reloption ( bits32  kinds,
const char name,
const char desc,
bool  default_val,
LOCKMODE  lockmode 
)

Definition at line 901 of file reloptions.c.

903{
905 default_val, lockmode);
906
908}
static void add_reloption(relopt_gen *newoption)
Definition reloptions.c:749
static relopt_bool * init_bool_reloption(bits32 kinds, const char *name, const char *desc, bool default_val, LOCKMODE lockmode)
Definition reloptions.c:884
const char * name

References add_reloption(), fb(), init_bool_reloption(), and name.

Referenced by create_reloptions_table().

◆ add_enum_reloption()

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 
)

Definition at line 1119 of file reloptions.c.

1122{
1124 members, default_val,
1125 detailmsg, lockmode);
1126
1128}
static relopt_enum * init_enum_reloption(bits32 kinds, const char *name, const char *desc, relopt_enum_elt_def *members, int default_val, const char *detailmsg, LOCKMODE lockmode)

References add_reloption(), fb(), init_enum_reloption(), and name.

Referenced by create_reloptions_table().

◆ add_int_reloption()

void add_int_reloption ( bits32  kinds,
const char name,
const char desc,
int  default_val,
int  min_val,
int  max_val,
LOCKMODE  lockmode 
)

Definition at line 1002 of file reloptions.c.

1004{
1006 default_val, min_val,
1007 max_val, lockmode);
1008
1010}
tree ctl max_val
Definition radixtree.h:1859
static relopt_int * init_int_reloption(bits32 kinds, const char *name, const char *desc, int default_val, int min_val, int max_val, LOCKMODE lockmode)
Definition reloptions.c:982

References add_reloption(), fb(), init_int_reloption(), max_val, and name.

Referenced by _PG_init(), and create_reloptions_table().

◆ add_local_bool_reloption()

void add_local_bool_reloption ( local_relopts relopts,
const char name,
const char desc,
bool  default_val,
int  offset 
)

Definition at line 917 of file reloptions.c.

919{
921 name, desc,
922 default_val, 0);
923
925}
static void add_local_reloption(local_relopts *relopts, relopt_gen *newoption, int offset)
Definition reloptions.c:806
@ RELOPT_KIND_LOCAL
Definition reloptions.h:41

References add_local_reloption(), fb(), init_bool_reloption(), name, and RELOPT_KIND_LOCAL.

◆ add_local_enum_reloption()

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 
)

Definition at line 1137 of file reloptions.c.

1140{
1142 name, desc,
1143 members, default_val,
1144 detailmsg, 0);
1145
1147}

References add_local_reloption(), fb(), init_enum_reloption(), name, and RELOPT_KIND_LOCAL.

◆ add_local_int_reloption()

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 
)

◆ add_local_real_reloption()

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 
)

Definition at line 1073 of file reloptions.c.

1076{
1078 name, desc,
1079 default_val, min_val,
1080 max_val, 0);
1081
1083}
static relopt_real * init_real_reloption(bits32 kinds, const char *name, const char *desc, double default_val, double min_val, double max_val, LOCKMODE lockmode)

References add_local_reloption(), fb(), init_real_reloption(), max_val, name, and RELOPT_KIND_LOCAL.

Referenced by brin_bloom_options().

◆ add_local_reloption()

static void add_local_reloption ( local_relopts relopts,
relopt_gen newoption,
int  offset 
)
static

Definition at line 806 of file reloptions.c.

807{
809
810 Assert(offset < relopts->relopt_struct_size);
811
812 opt->option = newoption;
813 opt->offset = offset;
814
815 relopts->options = lappend(relopts->options, opt);
816}
#define Assert(condition)
Definition c.h:945
#define palloc_object(type)
Definition fe_memutils.h:74
List * lappend(List *list, void *datum)
Definition list.c:339
relopt_gen * option
Definition reloptions.h:167

References Assert, fb(), lappend(), local_relopt::offset, local_relopt::option, and palloc_object.

Referenced by add_local_bool_reloption(), add_local_enum_reloption(), add_local_int_reloption(), add_local_real_reloption(), add_local_string_reloption(), and add_local_ternary_reloption().

◆ add_local_string_reloption()

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 
)

Definition at line 1219 of file reloptions.c.

1223{
1225 name, desc,
1226 default_val,
1227 validator, filler,
1228 0);
1229
1231}
static relopt_string * init_string_reloption(bits32 kinds, const char *name, const char *desc, const char *default_val, validate_string_relopt validator, fill_string_relopt filler, LOCKMODE lockmode)

References add_local_reloption(), fb(), init_string_reloption(), name, and RELOPT_KIND_LOCAL.

◆ add_local_ternary_reloption()

void add_local_ternary_reloption ( local_relopts relopts,
const char name,
const char desc,
int  offset 
)

Definition at line 966 of file reloptions.c.

968{
970
971 newoption =
973
975}
static relopt_ternary * init_ternary_reloption(bits32 kinds, const char *name, const char *desc, LOCKMODE lockmode)
Definition reloptions.c:932

References add_local_reloption(), fb(), init_ternary_reloption(), name, and RELOPT_KIND_LOCAL.

◆ add_real_reloption()

void add_real_reloption ( bits32  kinds,
const char name,
const char desc,
double  default_val,
double  min_val,
double  max_val,
LOCKMODE  lockmode 
)

Definition at line 1055 of file reloptions.c.

1058{
1060 default_val, min_val,
1061 max_val, lockmode);
1062
1064}

References add_reloption(), fb(), init_real_reloption(), max_val, and name.

Referenced by create_reloptions_table().

◆ add_reloption()

static void add_reloption ( relopt_gen newoption)
static

Definition at line 749 of file reloptions.c.

750{
751 static int max_custom_options = 0;
752
754 {
756
758
759 if (max_custom_options == 0)
760 {
763 }
764 else
765 {
768 max_custom_options * sizeof(relopt_gen *));
769 }
771 }
773
774 need_initialization = true;
775}
void * repalloc(void *pointer, Size size)
Definition mcxt.c:1632
MemoryContext TopMemoryContext
Definition mcxt.c:166
void * palloc(Size size)
Definition mcxt.c:1387
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition palloc.h:124
static int num_custom_options
Definition reloptions.c:590
static bool need_initialization
Definition reloptions.c:592
static relopt_gen ** custom_options
Definition reloptions.c:591

References custom_options, fb(), MemoryContextSwitchTo(), need_initialization, num_custom_options, palloc(), repalloc(), and TopMemoryContext.

Referenced by add_bool_reloption(), add_enum_reloption(), add_int_reloption(), add_real_reloption(), add_string_reloption(), and add_ternary_reloption().

◆ add_reloption_kind()

relopt_kind add_reloption_kind ( void  )

Definition at line 732 of file reloptions.c.

733{
734 /* don't hand out the last bit so that the enum's behavior is portable */
738 errmsg("user-defined relation parameter types limit exceeded")));
739 last_assigned_kind <<= 1;
741}
int errcode(int sqlerrcode)
Definition elog.c:874
#define ERROR
Definition elog.h:39
#define ereport(elevel,...)
Definition elog.h:150
static char * errmsg
static bits32 last_assigned_kind
Definition reloptions.c:588
relopt_kind
Definition reloptions.h:40
@ RELOPT_KIND_MAX
Definition reloptions.h:57

References ereport, errcode(), errmsg, ERROR, fb(), last_assigned_kind, and RELOPT_KIND_MAX.

Referenced by _PG_init(), and create_reloptions_table().

◆ add_string_reloption()

void add_string_reloption ( bits32  kinds,
const char name,
const char desc,
const char default_val,
validate_string_relopt  validator,
LOCKMODE  lockmode 
)

Definition at line 1199 of file reloptions.c.

1202{
1204 default_val,
1205 validator, NULL,
1206 lockmode);
1207
1209}

References add_reloption(), fb(), init_string_reloption(), and name.

Referenced by create_reloptions_table().

◆ add_ternary_reloption()

void add_ternary_reloption ( bits32  kinds,
const char name,
const char desc,
LOCKMODE  lockmode 
)

Definition at line 948 of file reloptions.c.

950{
952
953 newoption =
954 init_ternary_reloption(kinds, name, desc, lockmode);
955
957}

References add_reloption(), fb(), init_ternary_reloption(), and name.

Referenced by create_reloptions_table().

◆ allocate_reloption()

static relopt_gen * allocate_reloption ( bits32  kinds,
int  type,
const char name,
const char desc,
LOCKMODE  lockmode 
)
static

Definition at line 824 of file reloptions.c.

826{
828 size_t size;
830
831 if (kinds != RELOPT_KIND_LOCAL)
833 else
834 oldcxt = NULL;
835
836 switch (type)
837 {
838 case RELOPT_TYPE_BOOL:
839 size = sizeof(relopt_bool);
840 break;
842 size = sizeof(relopt_ternary);
843 break;
844 case RELOPT_TYPE_INT:
845 size = sizeof(relopt_int);
846 break;
847 case RELOPT_TYPE_REAL:
848 size = sizeof(relopt_real);
849 break;
850 case RELOPT_TYPE_ENUM:
851 size = sizeof(relopt_enum);
852 break;
854 size = sizeof(relopt_string);
855 break;
856 default:
857 elog(ERROR, "unsupported reloption type %d", type);
858 return NULL; /* keep compiler quiet */
859 }
860
861 newoption = palloc(size);
862
863 newoption->name = pstrdup(name);
864 if (desc)
865 newoption->desc = pstrdup(desc);
866 else
867 newoption->desc = NULL;
868 newoption->kinds = kinds;
869 newoption->namelen = strlen(name);
870 newoption->type = type;
871 newoption->lockmode = lockmode;
872
873 if (oldcxt != NULL)
875
876 return newoption;
877}
#define elog(elevel,...)
Definition elog.h:226
char * pstrdup(const char *in)
Definition mcxt.c:1781
@ RELOPT_TYPE_ENUM
Definition reloptions.h:34
@ RELOPT_TYPE_INT
Definition reloptions.h:32
@ RELOPT_TYPE_TERNARY
Definition reloptions.h:31
@ RELOPT_TYPE_BOOL
Definition reloptions.h:30
@ RELOPT_TYPE_REAL
Definition reloptions.h:33
@ RELOPT_TYPE_STRING
Definition reloptions.h:35
const char * type

References elog, ERROR, fb(), MemoryContextSwitchTo(), name, palloc(), pstrdup(), RELOPT_KIND_LOCAL, RELOPT_TYPE_BOOL, RELOPT_TYPE_ENUM, RELOPT_TYPE_INT, RELOPT_TYPE_REAL, RELOPT_TYPE_STRING, RELOPT_TYPE_TERNARY, TopMemoryContext, and type.

Referenced by init_bool_reloption(), init_enum_reloption(), init_int_reloption(), init_real_reloption(), init_string_reloption(), and init_ternary_reloption().

◆ allocateReloptStruct()

static void * allocateReloptStruct ( Size  base,
relopt_value options,
int  numoptions 
)
static

Definition at line 1826 of file reloptions.c.

1827{
1828 Size size = base;
1829 int i;
1830
1831 for (i = 0; i < numoptions; i++)
1832 {
1834
1835 if (optval->gen->type == RELOPT_TYPE_STRING)
1836 {
1838
1839 if (optstr->fill_cb)
1840 {
1841 const char *val = optval->isset ? optval->string_val :
1842 optstr->default_isnull ? NULL : optstr->default_val;
1843
1844 size += optstr->fill_cb(val, NULL);
1845 }
1846 else
1847 size += GET_STRING_RELOPTION_LEN(*optval) + 1;
1848 }
1849 }
1850
1851 return palloc0(size);
1852}
size_t Size
Definition c.h:691
long val
Definition informix.c:689
int i
Definition isn.c:77
void * palloc0(Size size)
Definition mcxt.c:1417
#define GET_STRING_RELOPTION_LEN(option)
Definition reloptions.c:603
relopt_gen gen
Definition reloptions.h:148

References fb(), relopt_string::gen, GET_STRING_RELOPTION_LEN, i, palloc0(), RELOPT_TYPE_STRING, and val.

Referenced by build_local_reloptions(), and build_reloptions().

◆ AlterTableGetRelOptionsLockLevel()

LOCKMODE AlterTableGetRelOptionsLockLevel ( List defList)

Definition at line 2242 of file reloptions.c.

2243{
2244 LOCKMODE lockmode = NoLock;
2245 ListCell *cell;
2246
2247 if (defList == NIL)
2248 return AccessExclusiveLock;
2249
2252
2253 foreach(cell, defList)
2254 {
2255 DefElem *def = (DefElem *) lfirst(cell);
2256 int i;
2257
2258 for (i = 0; relOpts[i]; i++)
2259 {
2260 if (strncmp(relOpts[i]->name,
2261 def->defname,
2262 relOpts[i]->namelen + 1) == 0)
2263 {
2264 if (lockmode < relOpts[i]->lockmode)
2265 lockmode = relOpts[i]->lockmode;
2266 }
2267 }
2268 }
2269
2270 return lockmode;
2271}
int LOCKMODE
Definition lockdefs.h:26
#define NoLock
Definition lockdefs.h:34
#define AccessExclusiveLock
Definition lockdefs.h:43
#define lfirst(lc)
Definition pg_list.h:172
#define NIL
Definition pg_list.h:68
static void initialize_reloptions(void)
Definition reloptions.c:614
static relopt_gen ** relOpts
Definition reloptions.c:587
char * defname
Definition parsenodes.h:857
LOCKMODE lockmode
Definition reloptions.h:70

References AccessExclusiveLock, DefElem::defname, fb(), i, initialize_reloptions(), lfirst, relopt_gen::lockmode, name, relopt_gen::namelen, need_initialization, NIL, NoLock, and relOpts.

Referenced by AlterTableGetLockLevel().

◆ attribute_reloptions()

bytea * attribute_reloptions ( Datum  reloptions,
bool  validate 
)

Definition at line 2203 of file reloptions.c.

2204{
2205 static const relopt_parse_elt tab[] = {
2206 {"n_distinct", RELOPT_TYPE_REAL, offsetof(AttributeOpts, n_distinct)},
2207 {"n_distinct_inherited", RELOPT_TYPE_REAL, offsetof(AttributeOpts, n_distinct_inherited)}
2208 };
2209
2210 return (bytea *) build_reloptions(reloptions, validate,
2212 sizeof(AttributeOpts),
2213 tab, lengthof(tab));
2214}
static bool validate(Port *port, const char *auth)
Definition auth-oauth.c:638
#define lengthof(array)
Definition c.h:875
void * build_reloptions(Datum reloptions, bool validate, relopt_kind kind, Size relopt_struct_size, const relopt_parse_elt *relopt_elems, int num_relopt_elems)
@ RELOPT_KIND_ATTRIBUTE
Definition reloptions.h:48
Definition c.h:778

References build_reloptions(), fb(), lengthof, RELOPT_KIND_ATTRIBUTE, RELOPT_TYPE_REAL, and validate().

Referenced by ATExecSetOptions(), and get_attribute_options().

◆ build_local_reloptions()

void * build_local_reloptions ( local_relopts relopts,
Datum  options,
bool  validate 
)

Definition at line 2079 of file reloptions.c.

2080{
2081 int noptions = list_length(relopts->options);
2083 relopt_value *vals;
2084 void *opts;
2085 int i = 0;
2086 ListCell *lc;
2087
2088 foreach(lc, relopts->options)
2089 {
2090 local_relopt *opt = lfirst(lc);
2091
2092 elems[i].optname = opt->option->name;
2093 elems[i].opttype = opt->option->type;
2094 elems[i].offset = opt->offset;
2095
2096 i++;
2097 }
2098
2100 opts = allocateReloptStruct(relopts->relopt_struct_size, vals, noptions);
2101 fillRelOptions(opts, relopts->relopt_struct_size, vals, noptions, validate,
2102 elems, noptions);
2103
2104 if (validate)
2105 foreach(lc, relopts->validators)
2106 ((relopts_validator) lfirst(lc)) (opts, vals, noptions);
2107
2108 if (elems)
2109 pfree(elems);
2110
2111 return opts;
2112}
#define palloc_array(type, count)
Definition fe_memutils.h:76
void pfree(void *pointer)
Definition mcxt.c:1616
static AmcheckOptions opts
Definition pg_amcheck.c:112
static int list_length(const List *l)
Definition pg_list.h:152
static size_t noptions
static relopt_value * parseLocalRelOptions(local_relopts *relopts, Datum options, bool validate)
static void fillRelOptions(void *rdopts, Size basesize, relopt_value *options, int numoptions, bool validate, const relopt_parse_elt *elems, int numelems)
static void * allocateReloptStruct(Size base, relopt_value *options, int numoptions)
void(* relopts_validator)(void *parsed_options, relopt_value *vals, int nvals)
Definition reloptions.h:144
const char * name
Definition reloptions.h:66
relopt_type type
Definition reloptions.h:72
const char * optname
Definition reloptions.h:159
relopt_type opttype
Definition reloptions.h:160

References allocateReloptStruct(), fb(), fillRelOptions(), i, lfirst, list_length(), relopt_gen::name, noptions, relopt_parse_elt::offset, local_relopt::offset, local_relopt::option, relopt_parse_elt::optname, opts, relopt_parse_elt::opttype, palloc_array, parseLocalRelOptions(), pfree(), relopt_gen::type, and validate().

Referenced by index_opclass_options().

◆ build_reloptions()

void * build_reloptions ( Datum  reloptions,
bool  validate,
relopt_kind  kind,
Size  relopt_struct_size,
const relopt_parse_elt relopt_elems,
int  num_relopt_elems 
)

Definition at line 2042 of file reloptions.c.

2047{
2048 int numoptions;
2050 void *rdopts;
2051
2052 /* parse options specific to given relation option kind */
2053 options = parseRelOptions(reloptions, validate, kind, &numoptions);
2055
2056 /* if none set, we're done */
2057 if (numoptions == 0)
2058 {
2059 Assert(options == NULL);
2060 return NULL;
2061 }
2062
2063 /* allocate and fill the structure */
2064 rdopts = allocateReloptStruct(relopt_struct_size, options, numoptions);
2065 fillRelOptions(rdopts, relopt_struct_size, options, numoptions,
2067
2068 pfree(options);
2069
2070 return rdopts;
2071}
static relopt_value * parseRelOptions(Datum options, bool validate, relopt_kind kind, int *numrelopts)

References allocateReloptStruct(), Assert, fb(), fillRelOptions(), parseRelOptions(), pfree(), and validate().

Referenced by attribute_reloptions(), bloptions(), brinoptions(), btoptions(), default_reloptions(), dioptions(), ginoptions(), gistoptions(), hashoptions(), spgoptions(), tablespace_reloptions(), and view_reloptions().

◆ default_reloptions()

bytea * default_reloptions ( Datum  reloptions,
bool  validate,
relopt_kind  kind 
)

Definition at line 1966 of file reloptions.c.

1967{
1968 static const relopt_parse_elt tab[] = {
1970 {"autovacuum_enabled", RELOPT_TYPE_BOOL,
1971 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, enabled)},
1972 {"autovacuum_vacuum_threshold", RELOPT_TYPE_INT,
1973 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, vacuum_threshold)},
1974 {"autovacuum_vacuum_max_threshold", RELOPT_TYPE_INT,
1975 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, vacuum_max_threshold)},
1976 {"autovacuum_vacuum_insert_threshold", RELOPT_TYPE_INT,
1977 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, vacuum_ins_threshold)},
1978 {"autovacuum_analyze_threshold", RELOPT_TYPE_INT,
1979 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, analyze_threshold)},
1980 {"autovacuum_vacuum_cost_limit", RELOPT_TYPE_INT,
1982 {"autovacuum_freeze_min_age", RELOPT_TYPE_INT,
1983 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, freeze_min_age)},
1984 {"autovacuum_freeze_max_age", RELOPT_TYPE_INT,
1985 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, freeze_max_age)},
1986 {"autovacuum_freeze_table_age", RELOPT_TYPE_INT,
1987 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, freeze_table_age)},
1988 {"autovacuum_multixact_freeze_min_age", RELOPT_TYPE_INT,
1989 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, multixact_freeze_min_age)},
1990 {"autovacuum_multixact_freeze_max_age", RELOPT_TYPE_INT,
1991 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, multixact_freeze_max_age)},
1992 {"autovacuum_multixact_freeze_table_age", RELOPT_TYPE_INT,
1993 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, multixact_freeze_table_age)},
1994 {"log_autovacuum_min_duration", RELOPT_TYPE_INT,
1995 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, log_vacuum_min_duration)},
1996 {"log_autoanalyze_min_duration", RELOPT_TYPE_INT,
1997 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, log_analyze_min_duration)},
1998 {"toast_tuple_target", RELOPT_TYPE_INT,
1999 offsetof(StdRdOptions, toast_tuple_target)},
2000 {"autovacuum_vacuum_cost_delay", RELOPT_TYPE_REAL,
2002 {"autovacuum_vacuum_scale_factor", RELOPT_TYPE_REAL,
2003 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, vacuum_scale_factor)},
2004 {"autovacuum_vacuum_insert_scale_factor", RELOPT_TYPE_REAL,
2005 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, vacuum_ins_scale_factor)},
2006 {"autovacuum_analyze_scale_factor", RELOPT_TYPE_REAL,
2007 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, analyze_scale_factor)},
2008 {"user_catalog_table", RELOPT_TYPE_BOOL,
2009 offsetof(StdRdOptions, user_catalog_table)},
2010 {"parallel_workers", RELOPT_TYPE_INT,
2011 offsetof(StdRdOptions, parallel_workers)},
2012 {"vacuum_index_cleanup", RELOPT_TYPE_ENUM,
2013 offsetof(StdRdOptions, vacuum_index_cleanup)},
2014 {"vacuum_truncate", RELOPT_TYPE_TERNARY,
2016 {"vacuum_max_eager_freeze_failure_rate", RELOPT_TYPE_REAL,
2018 };
2019
2020 return (bytea *) build_reloptions(reloptions, validate, kind,
2021 sizeof(StdRdOptions),
2022 tab, lengthof(tab));
2023}
static int fillfactor
Definition pgbench.c:188
double vacuum_max_eager_freeze_failure_rate
Definition vacuum.c:82
double vacuum_cost_delay
Definition vacuum.c:92
int vacuum_cost_limit
Definition vacuum.c:93
bool vacuum_truncate
Definition vacuum.c:84

References build_reloptions(), fb(), fillfactor, lengthof, RELOPT_TYPE_BOOL, RELOPT_TYPE_ENUM, RELOPT_TYPE_INT, RELOPT_TYPE_REAL, RELOPT_TYPE_TERNARY, vacuum_cost_delay, vacuum_cost_limit, vacuum_max_eager_freeze_failure_rate, vacuum_truncate, and validate().

Referenced by heap_reloptions().

◆ extractRelOptions()

bytea * extractRelOptions ( HeapTuple  tuple,
TupleDesc  tupdesc,
amoptions_function  amoptions 
)

Definition at line 1489 of file reloptions.c.

1491{
1492 bytea *options;
1493 bool isnull;
1494 Datum datum;
1496
1497 datum = fastgetattr(tuple,
1499 tupdesc,
1500 &isnull);
1501 if (isnull)
1502 return NULL;
1503
1505
1506 /* Parse into appropriate format; don't error out here */
1507 switch (classForm->relkind)
1508 {
1509 case RELKIND_RELATION:
1510 case RELKIND_TOASTVALUE:
1511 case RELKIND_MATVIEW:
1512 options = heap_reloptions(classForm->relkind, datum, false);
1513 break;
1515 options = partitioned_table_reloptions(datum, false);
1516 break;
1517 case RELKIND_VIEW:
1518 options = view_reloptions(datum, false);
1519 break;
1520 case RELKIND_INDEX:
1522 options = index_reloptions(amoptions, datum, false);
1523 break;
1525 options = NULL;
1526 break;
1527 default:
1528 Assert(false); /* can't get here */
1529 options = NULL; /* keep compiler quiet */
1530 break;
1531 }
1532
1533 return options;
1534}
static void * GETSTRUCT(const HeapTupleData *tuple)
static Datum fastgetattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
FormData_pg_class * Form_pg_class
Definition pg_class.h:160
uint64_t Datum
Definition postgres.h:70
bytea * view_reloptions(Datum reloptions, bool validate)
bytea * index_reloptions(amoptions_function amoptions, Datum reloptions, bool validate)
bytea * partitioned_table_reloptions(Datum reloptions, bool validate)
bytea * heap_reloptions(char relkind, Datum reloptions, bool validate)

References Assert, fastgetattr(), fb(), GETSTRUCT(), heap_reloptions(), index_reloptions(), partitioned_table_reloptions(), and view_reloptions().

Referenced by extract_autovac_opts(), and RelationParseRelOptions().

◆ fillRelOptions()

static void fillRelOptions ( void rdopts,
Size  basesize,
relopt_value options,
int  numoptions,
bool  validate,
const relopt_parse_elt elems,
int  numelems 
)
static

Definition at line 1866 of file reloptions.c.

1870{
1871 int i;
1872 int offset = basesize;
1873
1874 for (i = 0; i < numoptions; i++)
1875 {
1876 int j;
1877 bool found = false;
1878
1879 for (j = 0; j < numelems; j++)
1880 {
1881 if (strcmp(options[i].gen->name, elems[j].optname) == 0)
1882 {
1884 char *itempos = ((char *) rdopts) + elems[j].offset;
1885 char *string_val;
1886
1887 switch (options[i].gen->type)
1888 {
1889 case RELOPT_TYPE_BOOL:
1890 *(bool *) itempos = options[i].isset ?
1891 options[i].bool_val :
1892 ((relopt_bool *) options[i].gen)->default_val;
1893 break;
1895 *(pg_ternary *) itempos = options[i].isset ?
1896 options[i].ternary_val : PG_TERNARY_UNSET;
1897 break;
1898 case RELOPT_TYPE_INT:
1899 *(int *) itempos = options[i].isset ?
1900 options[i].int_val :
1901 ((relopt_int *) options[i].gen)->default_val;
1902 break;
1903 case RELOPT_TYPE_REAL:
1904 *(double *) itempos = options[i].isset ?
1905 options[i].real_val :
1906 ((relopt_real *) options[i].gen)->default_val;
1907 break;
1908 case RELOPT_TYPE_ENUM:
1909 *(int *) itempos = options[i].isset ?
1910 options[i].enum_val :
1911 ((relopt_enum *) options[i].gen)->default_val;
1912 break;
1913 case RELOPT_TYPE_STRING:
1914 optstring = (relopt_string *) options[i].gen;
1915 if (options[i].isset)
1916 string_val = options[i].string_val;
1917 else if (!optstring->default_isnull)
1918 string_val = optstring->default_val;
1919 else
1920 string_val = NULL;
1921
1922 if (optstring->fill_cb)
1923 {
1924 Size size =
1925 optstring->fill_cb(string_val,
1926 (char *) rdopts + offset);
1927
1928 if (size)
1929 {
1930 *(int *) itempos = offset;
1931 offset += size;
1932 }
1933 else
1934 *(int *) itempos = 0;
1935 }
1936 else if (string_val == NULL)
1937 *(int *) itempos = 0;
1938 else
1939 {
1940 strcpy((char *) rdopts + offset, string_val);
1941 *(int *) itempos = offset;
1942 offset += strlen(string_val) + 1;
1943 }
1944 break;
1945 default:
1946 elog(ERROR, "unsupported reloption type %d",
1947 options[i].gen->type);
1948 break;
1949 }
1950 found = true;
1951 break;
1952 }
1953 }
1954 if (validate && !found)
1955 elog(ERROR, "reloption \"%s\" not found in parse table",
1956 options[i].gen->name);
1957 }
1958 SET_VARSIZE(rdopts, offset);
1959}
int j
Definition isn.c:78
pg_ternary
Definition postgres.h:544
@ PG_TERNARY_UNSET
Definition postgres.h:547
static void SET_VARSIZE(void *PTR, Size len)
Definition varatt.h:432

References elog, ERROR, fb(), i, j, relopt_parse_elt::offset, relopt_parse_elt::optname, PG_TERNARY_UNSET, RELOPT_TYPE_BOOL, RELOPT_TYPE_ENUM, RELOPT_TYPE_INT, RELOPT_TYPE_REAL, RELOPT_TYPE_STRING, RELOPT_TYPE_TERNARY, SET_VARSIZE(), and validate().

Referenced by build_local_reloptions(), and build_reloptions().

◆ heap_reloptions()

bytea * heap_reloptions ( char  relkind,
Datum  reloptions,
bool  validate 
)

Definition at line 2153 of file reloptions.c.

2154{
2156
2157 switch (relkind)
2158 {
2159 case RELKIND_TOASTVALUE:
2160 rdopts = (StdRdOptions *)
2162 if (rdopts != NULL)
2163 {
2164 /* adjust default-only parameters for TOAST relations */
2165 rdopts->fillfactor = 100;
2166 rdopts->autovacuum.analyze_threshold = -1;
2167 rdopts->autovacuum.analyze_scale_factor = -1;
2168 }
2169 return (bytea *) rdopts;
2170 case RELKIND_RELATION:
2171 case RELKIND_MATVIEW:
2172 return default_reloptions(reloptions, validate, RELOPT_KIND_HEAP);
2173 default:
2174 /* other relkinds are not supported */
2175 return NULL;
2176 }
2177}
bytea * default_reloptions(Datum reloptions, bool validate, relopt_kind kind)
@ RELOPT_KIND_TOAST
Definition reloptions.h:43
@ RELOPT_KIND_HEAP
Definition reloptions.h:42

References default_reloptions(), fb(), RELOPT_KIND_HEAP, RELOPT_KIND_TOAST, and validate().

Referenced by ATExecSetRelOptions(), create_ctas_internal(), DefineRelation(), extractRelOptions(), and ProcessUtilitySlow().

◆ index_reloptions()

bytea * index_reloptions ( amoptions_function  amoptions,
Datum  reloptions,
bool  validate 
)

Definition at line 2188 of file reloptions.c.

2189{
2190 Assert(amoptions != NULL);
2191
2192 /* Assume function is strict */
2193 if (DatumGetPointer(reloptions) == NULL)
2194 return NULL;
2195
2196 return amoptions(reloptions, validate);
2197}
static Pointer DatumGetPointer(Datum X)
Definition postgres.h:332

References Assert, DatumGetPointer(), fb(), and validate().

Referenced by ATExecSetRelOptions(), DefineIndex(), and extractRelOptions().

◆ init_bool_reloption()

static relopt_bool * init_bool_reloption ( bits32  kinds,
const char name,
const char desc,
bool  default_val,
LOCKMODE  lockmode 
)
static

Definition at line 884 of file reloptions.c.

886{
888
890 name, desc, lockmode);
891 newoption->default_val = default_val;
892
893 return newoption;
894}
static relopt_gen * allocate_reloption(bits32 kinds, int type, const char *name, const char *desc, LOCKMODE lockmode)
Definition reloptions.c:824

References allocate_reloption(), fb(), name, and RELOPT_TYPE_BOOL.

Referenced by add_bool_reloption(), and add_local_bool_reloption().

◆ init_enum_reloption()

static relopt_enum * init_enum_reloption ( bits32  kinds,
const char name,
const char desc,
relopt_enum_elt_def members,
int  default_val,
const char detailmsg,
LOCKMODE  lockmode 
)
static

Definition at line 1090 of file reloptions.c.

1093{
1095
1097 name, desc, lockmode);
1098 newoption->members = members;
1099 newoption->default_val = default_val;
1100 newoption->detailmsg = detailmsg;
1101
1102 return newoption;
1103}

References allocate_reloption(), fb(), name, and RELOPT_TYPE_ENUM.

Referenced by add_enum_reloption(), and add_local_enum_reloption().

◆ init_int_reloption()

static relopt_int * init_int_reloption ( bits32  kinds,
const char name,
const char desc,
int  default_val,
int  min_val,
int  max_val,
LOCKMODE  lockmode 
)
static

Definition at line 982 of file reloptions.c.

985{
987
989 name, desc, lockmode);
990 newoption->default_val = default_val;
991 newoption->min = min_val;
992 newoption->max = max_val;
993
994 return newoption;
995}

References allocate_reloption(), fb(), max_val, name, and RELOPT_TYPE_INT.

Referenced by add_int_reloption(), and add_local_int_reloption().

◆ init_local_reloptions()

void init_local_reloptions ( local_relopts relopts,
Size  relopt_struct_size 
)

Definition at line 783 of file reloptions.c.

784{
785 relopts->options = NIL;
786 relopts->validators = NIL;
787 relopts->relopt_struct_size = relopt_struct_size;
788}

References fb(), and NIL.

Referenced by _ltree_gist_options(), brin_bloom_options(), brin_minmax_multi_options(), g_int_options(), g_intbig_options(), ghstore_options(), gtrgm_options(), gtsvector_options(), index_opclass_options(), and ltree_gist_options().

◆ init_real_reloption()

static relopt_real * init_real_reloption ( bits32  kinds,
const char name,
const char desc,
double  default_val,
double  min_val,
double  max_val,
LOCKMODE  lockmode 
)
static

Definition at line 1035 of file reloptions.c.

1038{
1040
1042 name, desc, lockmode);
1043 newoption->default_val = default_val;
1044 newoption->min = min_val;
1045 newoption->max = max_val;
1046
1047 return newoption;
1048}

References allocate_reloption(), fb(), max_val, name, and RELOPT_TYPE_REAL.

Referenced by add_local_real_reloption(), and add_real_reloption().

◆ init_string_reloption()

static relopt_string * init_string_reloption ( bits32  kinds,
const char name,
const char desc,
const char default_val,
validate_string_relopt  validator,
fill_string_relopt  filler,
LOCKMODE  lockmode 
)
static

Definition at line 1154 of file reloptions.c.

1159{
1161
1162 /* make sure the validator/default combination is sane */
1163 if (validator)
1164 (validator) (default_val);
1165
1167 name, desc, lockmode);
1168 newoption->validate_cb = validator;
1169 newoption->fill_cb = filler;
1170 if (default_val)
1171 {
1172 if (kinds == RELOPT_KIND_LOCAL)
1173 newoption->default_val = strdup(default_val);
1174 else
1175 newoption->default_val = MemoryContextStrdup(TopMemoryContext, default_val);
1176 newoption->default_len = strlen(default_val);
1177 newoption->default_isnull = false;
1178 }
1179 else
1180 {
1181 newoption->default_val = "";
1182 newoption->default_len = 0;
1183 newoption->default_isnull = true;
1184 }
1185
1186 return newoption;
1187}
char * MemoryContextStrdup(MemoryContext context, const char *string)
Definition mcxt.c:1768

References allocate_reloption(), fb(), MemoryContextStrdup(), name, RELOPT_KIND_LOCAL, RELOPT_TYPE_STRING, and TopMemoryContext.

Referenced by add_local_string_reloption(), and add_string_reloption().

◆ init_ternary_reloption()

static relopt_ternary * init_ternary_reloption ( bits32  kinds,
const char name,
const char desc,
LOCKMODE  lockmode 
)
static

Definition at line 932 of file reloptions.c.

934{
936
938 allocate_reloption(kinds, RELOPT_TYPE_TERNARY, name, desc, lockmode);
939
940 return newoption;
941}

References allocate_reloption(), fb(), name, and RELOPT_TYPE_TERNARY.

Referenced by add_local_ternary_reloption(), and add_ternary_reloption().

◆ initialize_reloptions()

static void initialize_reloptions ( void  )
static

Definition at line 614 of file reloptions.c.

615{
616 int i;
617 int j;
618
619 j = 0;
620 for (i = 0; boolRelOpts[i].gen.name; i++)
621 {
624 j++;
625 }
626 for (i = 0; ternaryRelOpts[i].gen.name; i++)
627 {
630 j++;
631 }
632
633 for (i = 0; intRelOpts[i].gen.name; i++)
634 {
637 j++;
638 }
639 for (i = 0; realRelOpts[i].gen.name; i++)
640 {
643 j++;
644 }
645 for (i = 0; enumRelOpts[i].gen.name; i++)
646 {
649 j++;
650 }
651 for (i = 0; stringRelOpts[i].gen.name; i++)
652 {
655 j++;
656 }
658
659 if (relOpts)
660 pfree(relOpts);
662 (j + 1) * sizeof(relopt_gen *));
663
664 j = 0;
665 for (i = 0; boolRelOpts[i].gen.name; i++)
666 {
670 j++;
671 }
672
673 for (i = 0; ternaryRelOpts[i].gen.name; i++)
674 {
678 j++;
679 }
680
681 for (i = 0; intRelOpts[i].gen.name; i++)
682 {
683 relOpts[j] = &intRelOpts[i].gen;
686 j++;
687 }
688
689 for (i = 0; realRelOpts[i].gen.name; i++)
690 {
694 j++;
695 }
696
697 for (i = 0; enumRelOpts[i].gen.name; i++)
698 {
702 j++;
703 }
704
705 for (i = 0; stringRelOpts[i].gen.name; i++)
706 {
710 j++;
711 }
712
713 for (i = 0; i < num_custom_options; i++)
714 {
716 j++;
717 }
718
719 /* add a list terminator */
720 relOpts[j] = NULL;
721
722 /* flag the work is complete */
723 need_initialization = false;
724}
bool DoLockModesConflict(LOCKMODE mode1, LOCKMODE mode2)
Definition lock.c:624
void * MemoryContextAlloc(MemoryContext context, Size size)
Definition mcxt.c:1232
static relopt_real realRelOpts[]
Definition reloptions.c:412
static relopt_int intRelOpts[]
Definition reloptions.c:187
static relopt_enum enumRelOpts[]
Definition reloptions.c:542
static relopt_string stringRelOpts[]
Definition reloptions.c:581
static relopt_bool boolRelOpts[]
Definition reloptions.c:99
static relopt_ternary ternaryRelOpts[]
Definition reloptions.c:169
relopt_gen gen
Definition reloptions.h:94
relopt_gen gen
Definition reloptions.h:132
relopt_gen gen
Definition reloptions.h:106
relopt_gen gen
Definition reloptions.h:114
relopt_gen gen
Definition reloptions.h:100

References Assert, boolRelOpts, custom_options, DoLockModesConflict(), enumRelOpts, fb(), relopt_bool::gen, relopt_ternary::gen, relopt_int::gen, relopt_real::gen, relopt_enum::gen, relopt_string::gen, i, intRelOpts, j, relopt_gen::lockmode, MemoryContextAlloc(), name, relopt_gen::name, relopt_gen::namelen, need_initialization, num_custom_options, pfree(), realRelOpts, RELOPT_TYPE_BOOL, RELOPT_TYPE_ENUM, RELOPT_TYPE_INT, RELOPT_TYPE_REAL, RELOPT_TYPE_STRING, RELOPT_TYPE_TERNARY, relOpts, stringRelOpts, ternaryRelOpts, TopMemoryContext, and relopt_gen::type.

Referenced by AlterTableGetRelOptionsLockLevel(), and parseRelOptions().

◆ parse_one_reloption()

static void parse_one_reloption ( relopt_value option,
char text_str,
int  text_len,
bool  validate 
)
static

Definition at line 1679 of file reloptions.c.

1681{
1682 char *value;
1683 int value_len;
1684 bool parsed;
1685 bool nofree = false;
1686
1687 if (option->isset && validate)
1688 ereport(ERROR,
1690 errmsg("parameter \"%s\" specified more than once",
1691 option->gen->name)));
1692
1693 value_len = text_len - option->gen->namelen - 1;
1694 value = (char *) palloc(value_len + 1);
1695 memcpy(value, text_str + option->gen->namelen + 1, value_len);
1696 value[value_len] = '\0';
1697
1698 switch (option->gen->type)
1699 {
1700 case RELOPT_TYPE_BOOL:
1701 {
1702 parsed = parse_bool(value, &option->bool_val);
1703 if (validate && !parsed)
1704 ereport(ERROR,
1706 errmsg("invalid value for boolean option \"%s\": %s",
1707 option->gen->name, value)));
1708 }
1709 break;
1711 {
1712 bool b;
1713
1714 parsed = parse_bool(value, &b);
1715 option->ternary_val = b ? PG_TERNARY_TRUE :
1717 if (validate && !parsed)
1718 ereport(ERROR,
1720 errmsg("invalid value for boolean option \"%s\": %s",
1721 option->gen->name, value));
1722 }
1723 break;
1724 case RELOPT_TYPE_INT:
1725 {
1726 relopt_int *optint = (relopt_int *) option->gen;
1727
1728 parsed = parse_int(value, &option->int_val, 0, NULL);
1729 if (validate && !parsed)
1730 ereport(ERROR,
1732 errmsg("invalid value for integer option \"%s\": %s",
1733 option->gen->name, value)));
1734 if (validate && (option->int_val < optint->min ||
1735 option->int_val > optint->max))
1736 ereport(ERROR,
1738 errmsg("value %s out of bounds for option \"%s\"",
1739 value, option->gen->name),
1740 errdetail("Valid values are between \"%d\" and \"%d\".",
1741 optint->min, optint->max)));
1742 }
1743 break;
1744 case RELOPT_TYPE_REAL:
1745 {
1747
1748 parsed = parse_real(value, &option->real_val, 0, NULL);
1749 if (validate && !parsed)
1750 ereport(ERROR,
1752 errmsg("invalid value for floating point option \"%s\": %s",
1753 option->gen->name, value)));
1754 if (validate && (option->real_val < optreal->min ||
1755 option->real_val > optreal->max))
1756 ereport(ERROR,
1758 errmsg("value %s out of bounds for option \"%s\"",
1759 value, option->gen->name),
1760 errdetail("Valid values are between \"%f\" and \"%f\".",
1761 optreal->min, optreal->max)));
1762 }
1763 break;
1764 case RELOPT_TYPE_ENUM:
1765 {
1768
1769 parsed = false;
1770 for (elt = optenum->members; elt->string_val; elt++)
1771 {
1772 if (pg_strcasecmp(value, elt->string_val) == 0)
1773 {
1774 option->enum_val = elt->symbol_val;
1775 parsed = true;
1776 break;
1777 }
1778 }
1779 if (validate && !parsed)
1780 ereport(ERROR,
1782 errmsg("invalid value for enum option \"%s\": %s",
1783 option->gen->name, value),
1784 optenum->detailmsg ?
1785 errdetail_internal("%s", _(optenum->detailmsg)) : 0));
1786
1787 /*
1788 * If value is not among the allowed string values, but we are
1789 * not asked to validate, just use the default numeric value.
1790 */
1791 if (!parsed)
1792 option->enum_val = optenum->default_val;
1793 }
1794 break;
1795 case RELOPT_TYPE_STRING:
1796 {
1798
1799 option->string_val = value;
1800 nofree = true;
1801 if (validate && optstring->validate_cb)
1802 (optstring->validate_cb) (value);
1803 parsed = true;
1804 }
1805 break;
1806 default:
1807 elog(ERROR, "unsupported reloption type %d", option->gen->type);
1808 parsed = true; /* quiet compiler */
1809 break;
1810 }
1811
1812 if (parsed)
1813 option->isset = true;
1814 if (!nofree)
1815 pfree(value);
1816}
bool parse_bool(const char *value, bool *result)
Definition bool.c:31
#define _(x)
Definition elog.c:95
int int errdetail_internal(const char *fmt,...) pg_attribute_printf(1
int errdetail(const char *fmt,...) pg_attribute_printf(1
bool parse_int(const char *value, int *result, int flags, const char **hintmsg)
Definition guc.c:2775
bool parse_real(const char *value, double *result, int flags, const char **hintmsg)
Definition guc.c:2865
static struct @175 value
int b
Definition isn.c:74
int pg_strcasecmp(const char *s1, const char *s2)
@ PG_TERNARY_FALSE
Definition postgres.h:545
@ PG_TERNARY_TRUE
Definition postgres.h:546
const char * name
Definition getopt_long.h:19

References _, b, elog, ereport, errcode(), errdetail(), errdetail_internal(), errmsg, ERROR, fb(), option::name, palloc(), parse_bool(), parse_int(), parse_real(), pfree(), pg_strcasecmp(), PG_TERNARY_FALSE, PG_TERNARY_TRUE, RELOPT_TYPE_BOOL, RELOPT_TYPE_ENUM, RELOPT_TYPE_INT, RELOPT_TYPE_REAL, RELOPT_TYPE_STRING, RELOPT_TYPE_TERNARY, validate(), and value.

Referenced by parseRelOptionsInternal().

◆ parseLocalRelOptions()

static relopt_value * parseLocalRelOptions ( local_relopts relopts,
Datum  options,
bool  validate 
)
static

Definition at line 1651 of file reloptions.c.

1652{
1653 int nopts = list_length(relopts->options);
1655 ListCell *lc;
1656 int i = 0;
1657
1658 foreach(lc, relopts->options)
1659 {
1660 local_relopt *opt = lfirst(lc);
1661
1662 values[i].gen = opt->option;
1663 values[i].isset = false;
1664
1665 i++;
1666 }
1667
1668 if (options != (Datum) 0)
1670
1671 return values;
1672}
static Datum values[MAXATTR]
Definition bootstrap.c:188
static void parseRelOptionsInternal(Datum options, bool validate, relopt_value *reloptions, int numoptions)

References fb(), i, lfirst, list_length(), local_relopt::option, palloc_array, parseRelOptionsInternal(), validate(), and values.

Referenced by build_local_reloptions().

◆ parseRelOptions()

static relopt_value * parseRelOptions ( Datum  options,
bool  validate,
relopt_kind  kind,
int numrelopts 
)
static

Definition at line 1609 of file reloptions.c.

1611{
1612 relopt_value *reloptions = NULL;
1613 int numoptions = 0;
1614 int i;
1615 int j;
1616
1619
1620 /* Build a list of expected options, based on kind */
1621
1622 for (i = 0; relOpts[i]; i++)
1623 if (relOpts[i]->kinds & kind)
1624 numoptions++;
1625
1626 if (numoptions > 0)
1627 {
1628 reloptions = palloc(numoptions * sizeof(relopt_value));
1629
1630 for (i = 0, j = 0; relOpts[i]; i++)
1631 {
1632 if (relOpts[i]->kinds & kind)
1633 {
1634 reloptions[j].gen = relOpts[i];
1635 reloptions[j].isset = false;
1636 j++;
1637 }
1638 }
1639 }
1640
1641 /* Done if no options */
1644
1646 return reloptions;
1647}
relopt_gen * gen
Definition reloptions.h:78

References DatumGetPointer(), fb(), relopt_value::gen, i, initialize_reloptions(), relopt_value::isset, j, need_initialization, palloc(), parseRelOptionsInternal(), relOpts, and validate().

Referenced by build_reloptions().

◆ parseRelOptionsInternal()

static void parseRelOptionsInternal ( Datum  options,
bool  validate,
relopt_value reloptions,
int  numoptions 
)
static

Definition at line 1537 of file reloptions.c.

1539{
1542 int noptions;
1543 int i;
1544
1546
1547 for (i = 0; i < noptions; i++)
1548 {
1551 int j;
1552
1553 /* Search for a match in reloptions */
1554 for (j = 0; j < numoptions; j++)
1555 {
1556 int kw_len = reloptions[j].gen->namelen;
1557
1558 if (text_len > kw_len && text_str[kw_len] == '=' &&
1559 strncmp(text_str, reloptions[j].gen->name, kw_len) == 0)
1560 {
1561 parse_one_reloption(&reloptions[j], text_str, text_len,
1562 validate);
1563 break;
1564 }
1565 }
1566
1567 if (j >= numoptions && validate)
1568 {
1569 char *s;
1570 char *p;
1571
1573 p = strchr(s, '=');
1574 if (p)
1575 *p = '\0';
1576 ereport(ERROR,
1578 errmsg("unrecognized parameter \"%s\"", s)));
1579 }
1580 }
1581
1582 /* It's worth avoiding memory leaks in this function */
1584
1585 if (((void *) array) != DatumGetPointer(options))
1586 pfree(array);
1587}
#define DatumGetArrayTypeP(X)
Definition array.h:261
void deconstruct_array_builtin(const ArrayType *array, Oid elmtype, Datum **elemsp, bool **nullsp, int *nelemsp)
#define TextDatumGetCString(d)
Definition builtins.h:99
#define VARHDRSZ
Definition c.h:783
static void parse_one_reloption(relopt_value *option, char *text_str, int text_len, bool validate)
static Size VARSIZE(const void *PTR)
Definition varatt.h:298
static char * VARDATA(const void *PTR)
Definition varatt.h:305

References DatumGetArrayTypeP, DatumGetPointer(), deconstruct_array_builtin(), ereport, errcode(), errmsg, ERROR, fb(), relopt_value::gen, i, j, relopt_gen::namelen, noptions, parse_one_reloption(), pfree(), TextDatumGetCString, validate(), VARDATA(), VARHDRSZ, and VARSIZE().

Referenced by parseLocalRelOptions(), and parseRelOptions().

◆ partitioned_table_reloptions()

bytea * partitioned_table_reloptions ( Datum  reloptions,
bool  validate 
)

Definition at line 2118 of file reloptions.c.

2119{
2120 if (validate && reloptions)
2121 ereport(ERROR,
2123 errmsg("cannot specify storage parameters for a partitioned table"),
2124 errhint("Specify storage parameters for its leaf partitions instead."));
2125 return NULL;
2126}
int errhint(const char *fmt,...) pg_attribute_printf(1

References ereport, errcode(), errhint(), errmsg, ERROR, fb(), and validate().

Referenced by ATExecSetRelOptions(), DefineRelation(), and extractRelOptions().

◆ register_reloptions_validator()

void register_reloptions_validator ( local_relopts relopts,
relopts_validator  validator 
)

Definition at line 796 of file reloptions.c.

797{
798 relopts->validators = lappend(relopts->validators, validator);
799}

References fb(), and lappend().

Referenced by ltree_gist_options().

◆ tablespace_reloptions()

bytea * tablespace_reloptions ( Datum  reloptions,
bool  validate 
)

Definition at line 2220 of file reloptions.c.

2221{
2222 static const relopt_parse_elt tab[] = {
2225 {"effective_io_concurrency", RELOPT_TYPE_INT, offsetof(TableSpaceOpts, effective_io_concurrency)},
2226 {"maintenance_io_concurrency", RELOPT_TYPE_INT, offsetof(TableSpaceOpts, maintenance_io_concurrency)}
2227 };
2228
2229 return (bytea *) build_reloptions(reloptions, validate,
2231 sizeof(TableSpaceOpts),
2232 tab, lengthof(tab));
2233}
int maintenance_io_concurrency
Definition bufmgr.c:207
int effective_io_concurrency
Definition bufmgr.c:200
double random_page_cost
Definition costsize.c:132
double seq_page_cost
Definition costsize.c:131
@ RELOPT_KIND_TABLESPACE
Definition reloptions.h:49

References build_reloptions(), effective_io_concurrency, fb(), lengthof, maintenance_io_concurrency, random_page_cost, RELOPT_KIND_TABLESPACE, RELOPT_TYPE_INT, RELOPT_TYPE_REAL, seq_page_cost, and validate().

Referenced by AlterTableSpaceOptions(), CreateTableSpace(), and get_tablespace().

◆ transformRelOptions()

Datum transformRelOptions ( Datum  oldOptions,
List defList,
const char nameSpace,
const char *const  validnsps[],
bool  acceptOidsOff,
bool  isReset 
)

Definition at line 1257 of file reloptions.c.

1259{
1260 Datum result;
1261 ArrayBuildState *astate;
1262 ListCell *cell;
1263
1264 /* no change if empty list */
1265 if (defList == NIL)
1266 return oldOptions;
1267
1268 /* We build new array using accumArrayResult */
1269 astate = NULL;
1270
1271 /* Copy any oldOptions that aren't to be replaced */
1273 {
1276 int noldoptions;
1277 int i;
1278
1280
1281 for (i = 0; i < noldoptions; i++)
1282 {
1285
1286 /* Search for a match in defList */
1287 foreach(cell, defList)
1288 {
1289 DefElem *def = (DefElem *) lfirst(cell);
1290 int kw_len;
1291
1292 /* ignore if not in the same namespace */
1293 if (nameSpace == NULL)
1294 {
1295 if (def->defnamespace != NULL)
1296 continue;
1297 }
1298 else if (def->defnamespace == NULL)
1299 continue;
1300 else if (strcmp(def->defnamespace, nameSpace) != 0)
1301 continue;
1302
1303 kw_len = strlen(def->defname);
1304 if (text_len > kw_len && text_str[kw_len] == '=' &&
1305 strncmp(text_str, def->defname, kw_len) == 0)
1306 break;
1307 }
1308 if (!cell)
1309 {
1310 /* No match, so keep old option */
1311 astate = accumArrayResult(astate, oldoptions[i],
1312 false, TEXTOID,
1314 }
1315 }
1316 }
1317
1318 /*
1319 * If CREATE/SET, add new options to array; if RESET, just check that the
1320 * user didn't say RESET (option=val). (Must do this because the grammar
1321 * doesn't enforce it.)
1322 */
1323 foreach(cell, defList)
1324 {
1325 DefElem *def = (DefElem *) lfirst(cell);
1326
1327 if (isReset)
1328 {
1329 if (def->arg != NULL)
1330 ereport(ERROR,
1332 errmsg("RESET must not include values for parameters")));
1333 }
1334 else
1335 {
1336 const char *name;
1337 const char *value;
1338 text *t;
1339 Size len;
1340
1341 /*
1342 * Error out if the namespace is not valid. A NULL namespace is
1343 * always valid.
1344 */
1345 if (def->defnamespace != NULL)
1346 {
1347 bool valid = false;
1348 int i;
1349
1350 if (validnsps)
1351 {
1352 for (i = 0; validnsps[i]; i++)
1353 {
1354 if (strcmp(def->defnamespace, validnsps[i]) == 0)
1355 {
1356 valid = true;
1357 break;
1358 }
1359 }
1360 }
1361
1362 if (!valid)
1363 ereport(ERROR,
1365 errmsg("unrecognized parameter namespace \"%s\"",
1366 def->defnamespace)));
1367 }
1368
1369 /* ignore if not in the same namespace */
1370 if (nameSpace == NULL)
1371 {
1372 if (def->defnamespace != NULL)
1373 continue;
1374 }
1375 else if (def->defnamespace == NULL)
1376 continue;
1377 else if (strcmp(def->defnamespace, nameSpace) != 0)
1378 continue;
1379
1380 /*
1381 * Flatten the DefElem into a text string like "name=arg". If we
1382 * have just "name", assume "name=true" is meant. Note: the
1383 * namespace is not output.
1384 */
1385 name = def->defname;
1386 if (def->arg != NULL)
1387 value = defGetString(def);
1388 else
1389 value = "true";
1390
1391 /* Insist that name not contain "=", else "a=b=c" is ambiguous */
1392 if (strchr(name, '=') != NULL)
1393 ereport(ERROR,
1395 errmsg("invalid option name \"%s\": must not contain \"=\"",
1396 name)));
1397
1398 /*
1399 * This is not a great place for this test, but there's no other
1400 * convenient place to filter the option out. As WITH (oids =
1401 * false) will be removed someday, this seems like an acceptable
1402 * amount of ugly.
1403 */
1404 if (acceptOidsOff && def->defnamespace == NULL &&
1405 strcmp(name, "oids") == 0)
1406 {
1407 if (defGetBoolean(def))
1408 ereport(ERROR,
1410 errmsg("tables declared WITH OIDS are not supported")));
1411 /* skip over option, reloptions machinery doesn't know it */
1412 continue;
1413 }
1414
1415 len = VARHDRSZ + strlen(name) + 1 + strlen(value);
1416 /* +1 leaves room for sprintf's trailing null */
1417 t = (text *) palloc(len + 1);
1418 SET_VARSIZE(t, len);
1419 sprintf(VARDATA(t), "%s=%s", name, value);
1420
1421 astate = accumArrayResult(astate, PointerGetDatum(t),
1422 false, TEXTOID,
1424 }
1425 }
1426
1427 if (astate)
1428 result = makeArrayResult(astate, CurrentMemoryContext);
1429 else
1430 result = (Datum) 0;
1431
1432 return result;
1433}
ArrayBuildState * accumArrayResult(ArrayBuildState *astate, Datum dvalue, bool disnull, Oid element_type, MemoryContext rcontext)
Datum makeArrayResult(ArrayBuildState *astate, MemoryContext rcontext)
char * defGetString(DefElem *def)
Definition define.c:34
bool defGetBoolean(DefElem *def)
Definition define.c:93
MemoryContext CurrentMemoryContext
Definition mcxt.c:160
const void size_t len
#define sprintf
Definition port.h:262
static Datum PointerGetDatum(const void *X)
Definition postgres.h:342
char * defnamespace
Definition parsenodes.h:856
Node * arg
Definition parsenodes.h:858

References accumArrayResult(), DefElem::arg, CurrentMemoryContext, DatumGetArrayTypeP, DatumGetPointer(), deconstruct_array_builtin(), defGetBoolean(), defGetString(), DefElem::defname, DefElem::defnamespace, ereport, errcode(), errmsg, ERROR, fb(), i, len, lfirst, makeArrayResult(), name, NIL, palloc(), PointerGetDatum(), SET_VARSIZE(), sprintf, value, VARDATA(), VARHDRSZ, and VARSIZE().

Referenced by AlterTableSpaceOptions(), ATExecSetOptions(), ATExecSetRelOptions(), ComputeIndexAttrs(), create_ctas_internal(), CreateTableSpace(), DefineIndex(), DefineRelation(), and ProcessUtilitySlow().

◆ untransformRelOptions()

List * untransformRelOptions ( Datum  options)

Definition at line 1441 of file reloptions.c.

1442{
1443 List *result = NIL;
1444 ArrayType *array;
1446 int noptions;
1447 int i;
1448
1449 /* Nothing to do if no options */
1451 return result;
1452
1453 array = DatumGetArrayTypeP(options);
1454
1456
1457 for (i = 0; i < noptions; i++)
1458 {
1459 char *s;
1460 char *p;
1461 Node *val = NULL;
1462
1464 p = strchr(s, '=');
1465 if (p)
1466 {
1467 *p++ = '\0';
1468 val = (Node *) makeString(p);
1469 }
1470 result = lappend(result, makeDefElem(s, val, -1));
1471 }
1472
1473 return result;
1474}
DefElem * makeDefElem(char *name, Node *arg, int location)
Definition makefuncs.c:637
Definition pg_list.h:54
Definition nodes.h:135
String * makeString(char *str)
Definition value.c:63

References DatumGetArrayTypeP, DatumGetPointer(), deconstruct_array_builtin(), fb(), i, lappend(), makeDefElem(), makeString(), NIL, noptions, TextDatumGetCString, and val.

Referenced by ATExecSetRelOptions(), dblink_fdw_validator(), file_fdw_validator(), generateClonedIndexStmt(), GetForeignColumnOptions(), GetForeignDataWrapperExtended(), GetForeignServerExtended(), GetForeignTable(), GetUserMapping(), pg_options_to_table(), postgres_fdw_validator(), postgresql_fdw_validator(), and transformGenericOptions().

◆ view_reloptions()

bytea * view_reloptions ( Datum  reloptions,
bool  validate 
)

Definition at line 2132 of file reloptions.c.

2133{
2134 static const relopt_parse_elt tab[] = {
2135 {"security_barrier", RELOPT_TYPE_BOOL,
2136 offsetof(ViewOptions, security_barrier)},
2137 {"security_invoker", RELOPT_TYPE_BOOL,
2138 offsetof(ViewOptions, security_invoker)},
2139 {"check_option", RELOPT_TYPE_ENUM,
2140 offsetof(ViewOptions, check_option)}
2141 };
2142
2143 return (bytea *) build_reloptions(reloptions, validate,
2145 sizeof(ViewOptions),
2146 tab, lengthof(tab));
2147}
@ RELOPT_KIND_VIEW
Definition reloptions.h:51

References build_reloptions(), fb(), lengthof, RELOPT_KIND_VIEW, RELOPT_TYPE_BOOL, RELOPT_TYPE_ENUM, and validate().

Referenced by ATExecSetRelOptions(), DefineRelation(), and extractRelOptions().

Variable Documentation

◆ boolRelOpts

relopt_bool boolRelOpts[]
static

Definition at line 99 of file reloptions.c.

100{
101 {
102 {
103 "autosummarize",
104 "Enables automatic summarization on this BRIN index",
107 },
108 false
109 },
110 {
111 {
112 "autovacuum_enabled",
113 "Enables autovacuum in this relation",
116 },
117 true
118 },
119 {
120 {
121 "user_catalog_table",
122 "Declare a table as an additional catalog table, e.g. for the purpose of logical replication",
125 },
126 false
127 },
128 {
129 {
130 "fastupdate",
131 "Enables \"fast update\" feature for this GIN index",
134 },
135 true
136 },
137 {
138 {
139 "security_barrier",
140 "View acts as a row security barrier",
143 },
144 false
145 },
146 {
147 {
148 "security_invoker",
149 "Privileges on underlying relations are checked as the invoking user, not the view owner",
152 },
153 false
154 },
155 {
156 {
157 "deduplicate_items",
158 "Enables \"deduplicate items\" feature for this btree index",
160 ShareUpdateExclusiveLock /* since it applies only to later
161 * inserts */
162 },
163 true
164 },
165 /* list terminator */
166 {{NULL}}
167};
#define ShareUpdateExclusiveLock
Definition lockdefs.h:39
@ RELOPT_KIND_GIN
Definition reloptions.h:46
@ RELOPT_KIND_BRIN
Definition reloptions.h:52
@ RELOPT_KIND_BTREE
Definition reloptions.h:44

Referenced by initialize_reloptions().

◆ custom_options

relopt_gen** custom_options = NULL
static

Definition at line 591 of file reloptions.c.

Referenced by add_reloption(), and initialize_reloptions().

◆ enumRelOpts

relopt_enum enumRelOpts[]
static

Definition at line 542 of file reloptions.c.

543{
544 {
545 {
546 "vacuum_index_cleanup",
547 "Controls index vacuuming and index cleanup",
550 },
553 gettext_noop("Valid values are \"on\", \"off\", and \"auto\".")
554 },
555 {
556 {
557 "buffering",
558 "Enables buffering build for this GiST index",
561 },
564 gettext_noop("Valid values are \"on\", \"off\", and \"auto\".")
565 },
566 {
567 {
568 "check_option",
569 "View has WITH CHECK OPTION defined (local or cascaded).",
572 },
575 gettext_noop("Valid values are \"local\" and \"cascaded\".")
576 },
577 /* list terminator */
578 {{NULL}}
579};
#define gettext_noop(x)
Definition c.h:1287
@ GIST_OPTION_BUFFERING_AUTO
@ VIEW_OPTION_CHECK_OPTION_NOT_SET
Definition rel.h:415
@ STDRD_OPTION_VACUUM_INDEX_CLEANUP_AUTO
Definition rel.h:336
static relopt_enum_elt_def gistBufferingOptValues[]
Definition reloptions.c:525
static relopt_enum_elt_def StdRdOptIndexCleanupValues[]
Definition reloptions.c:510
static relopt_enum_elt_def viewCheckOptValues[]
Definition reloptions.c:534
@ RELOPT_KIND_GIST
Definition reloptions.h:47

Referenced by initialize_reloptions().

◆ gistBufferingOptValues

relopt_enum_elt_def gistBufferingOptValues[]
static
Initial value:
=
{
{(const char *) NULL}
}
@ GIST_OPTION_BUFFERING_OFF
@ GIST_OPTION_BUFFERING_ON

Definition at line 525 of file reloptions.c.

526{
530 {(const char *) NULL} /* list terminator */
531};

◆ intRelOpts

relopt_int intRelOpts[]
static

Definition at line 187 of file reloptions.c.

188{
189 {
190 {
191 "fillfactor",
192 "Packs table pages only to this percentage",
194 ShareUpdateExclusiveLock /* since it applies only to later
195 * inserts */
196 },
198 },
199 {
200 {
201 "fillfactor",
202 "Packs btree index pages only to this percentage",
204 ShareUpdateExclusiveLock /* since it applies only to later
205 * inserts */
206 },
208 },
209 {
210 {
211 "fillfactor",
212 "Packs hash index pages only to this percentage",
214 ShareUpdateExclusiveLock /* since it applies only to later
215 * inserts */
216 },
218 },
219 {
220 {
221 "fillfactor",
222 "Packs gist index pages only to this percentage",
224 ShareUpdateExclusiveLock /* since it applies only to later
225 * inserts */
226 },
228 },
229 {
230 {
231 "fillfactor",
232 "Packs spgist index pages only to this percentage",
234 ShareUpdateExclusiveLock /* since it applies only to later
235 * inserts */
236 },
238 },
239 {
240 {
241 "autovacuum_vacuum_threshold",
242 "Minimum number of tuple updates or deletes prior to vacuum",
245 },
246 -1, 0, INT_MAX
247 },
248 {
249 {
250 "autovacuum_vacuum_max_threshold",
251 "Maximum number of tuple updates or deletes prior to vacuum",
254 },
255 -2, -1, INT_MAX
256 },
257 {
258 {
259 "autovacuum_vacuum_insert_threshold",
260 "Minimum number of tuple inserts prior to vacuum, or -1 to disable insert vacuums",
263 },
264 -2, -1, INT_MAX
265 },
266 {
267 {
268 "autovacuum_analyze_threshold",
269 "Minimum number of tuple inserts, updates or deletes prior to analyze",
272 },
273 -1, 0, INT_MAX
274 },
275 {
276 {
277 "autovacuum_vacuum_cost_limit",
278 "Vacuum cost amount available before napping, for autovacuum",
281 },
282 -1, 1, 10000
283 },
284 {
285 {
286 "autovacuum_freeze_min_age",
287 "Minimum age at which VACUUM should freeze a table row, for autovacuum",
290 },
291 -1, 0, 1000000000
292 },
293 {
294 {
295 "autovacuum_multixact_freeze_min_age",
296 "Minimum multixact age at which VACUUM should freeze a row multixact's, for autovacuum",
299 },
300 -1, 0, 1000000000
301 },
302 {
303 {
304 "autovacuum_freeze_max_age",
305 "Age at which to autovacuum a table to prevent transaction ID wraparound",
308 },
309 -1, 100000, 2000000000
310 },
311 {
312 {
313 "autovacuum_multixact_freeze_max_age",
314 "Multixact age at which to autovacuum a table to prevent multixact wraparound",
317 },
318 -1, 10000, 2000000000
319 },
320 {
321 {
322 "autovacuum_freeze_table_age",
323 "Age at which VACUUM should perform a full table sweep to freeze row versions",
326 }, -1, 0, 2000000000
327 },
328 {
329 {
330 "autovacuum_multixact_freeze_table_age",
331 "Age of multixact at which VACUUM should perform a full table sweep to freeze row versions",
334 }, -1, 0, 2000000000
335 },
336 {
337 {
338 "log_autovacuum_min_duration",
339 "Sets the minimum execution time above which vacuum actions by autovacuum will be logged",
342 },
343 -1, -1, INT_MAX
344 },
345 {
346 {
347 "log_autoanalyze_min_duration",
348 "Sets the minimum execution time above which analyze actions by autovacuum will be logged",
351 },
352 -1, -1, INT_MAX
353 },
354 {
355 {
356 "toast_tuple_target",
357 "Sets the target tuple length at which external columns will be toasted",
360 },
362 },
363 {
364 {
365 "pages_per_range",
366 "Number of pages that each page range covers in a BRIN index",
369 }, 128, 1, 131072
370 },
371 {
372 {
373 "gin_pending_list_limit",
374 "Maximum size of the pending list for this GIN index, in kilobytes.",
377 },
378 -1, 64, MAX_KILOBYTES
379 },
380 {
381 {
382 "effective_io_concurrency",
383 "Number of simultaneous requests that can be handled efficiently by the disk subsystem.",
386 },
387 -1, 0, MAX_IO_CONCURRENCY
388 },
389 {
390 {
391 "maintenance_io_concurrency",
392 "Number of simultaneous requests that can be handled efficiently by the disk subsystem for maintenance work.",
395 },
396 -1, 0, MAX_IO_CONCURRENCY
397 },
398 {
399 {
400 "parallel_workers",
401 "Number of parallel processes that can be used per executor node for this relation.",
404 },
405 -1, 0, 1024
406 },
407
408 /* list terminator */
409 {{NULL}}
410};
#define MAX_IO_CONCURRENCY
Definition bufmgr.h:197
#define GIST_MIN_FILLFACTOR
#define GIST_DEFAULT_FILLFACTOR
#define MAX_KILOBYTES
Definition guc.h:29
#define HASH_DEFAULT_FILLFACTOR
Definition hash.h:296
#define HASH_MIN_FILLFACTOR
Definition hash.h:295
#define TOAST_TUPLE_TARGET
Definition heaptoast.h:50
#define TOAST_TUPLE_TARGET_MAIN
Definition heaptoast.h:61
#define BTREE_MIN_FILLFACTOR
Definition nbtree.h:200
#define BTREE_DEFAULT_FILLFACTOR
Definition nbtree.h:201
#define HEAP_MIN_FILLFACTOR
Definition rel.h:359
#define HEAP_DEFAULT_FILLFACTOR
Definition rel.h:360
@ RELOPT_KIND_SPGIST
Definition reloptions.h:50
@ RELOPT_KIND_HASH
Definition reloptions.h:45
#define SPGIST_DEFAULT_FILLFACTOR
#define SPGIST_MIN_FILLFACTOR

Referenced by initialize_reloptions().

◆ last_assigned_kind

bits32 last_assigned_kind = RELOPT_KIND_LAST_DEFAULT
static

Definition at line 588 of file reloptions.c.

Referenced by add_reloption_kind().

◆ need_initialization

bool need_initialization = true
static

◆ num_custom_options

int num_custom_options = 0
static

Definition at line 590 of file reloptions.c.

Referenced by add_reloption(), and initialize_reloptions().

◆ realRelOpts

relopt_real realRelOpts[]
static

Definition at line 412 of file reloptions.c.

413{
414 {
415 {
416 "autovacuum_vacuum_cost_delay",
417 "Vacuum cost delay in milliseconds, for autovacuum",
420 },
421 -1, 0.0, 100.0
422 },
423 {
424 {
425 "autovacuum_vacuum_scale_factor",
426 "Number of tuple updates or deletes prior to vacuum as a fraction of reltuples",
429 },
430 -1, 0.0, 100.0
431 },
432 {
433 {
434 "autovacuum_vacuum_insert_scale_factor",
435 "Number of tuple inserts prior to vacuum as a fraction of reltuples",
438 },
439 -1, 0.0, 100.0
440 },
441 {
442 {
443 "autovacuum_analyze_scale_factor",
444 "Number of tuple inserts, updates or deletes prior to analyze as a fraction of reltuples",
447 },
448 -1, 0.0, 100.0
449 },
450 {
451 {
452 "vacuum_max_eager_freeze_failure_rate",
453 "Fraction of pages in a relation vacuum can scan and fail to freeze before disabling eager scanning.",
456 },
457 -1, 0.0, 1.0
458 },
459
460 {
461 {
462 "seq_page_cost",
463 "Sets the planner's estimate of the cost of a sequentially fetched disk page.",
466 },
467 -1, 0.0, DBL_MAX
468 },
469 {
470 {
471 "random_page_cost",
472 "Sets the planner's estimate of the cost of a nonsequentially fetched disk page.",
475 },
476 -1, 0.0, DBL_MAX
477 },
478 {
479 {
480 "n_distinct",
481 "Sets the planner's estimate of the number of distinct values appearing in a column (excluding child relations).",
484 },
485 0, -1.0, DBL_MAX
486 },
487 {
488 {
489 "n_distinct_inherited",
490 "Sets the planner's estimate of the number of distinct values appearing in a column (including child relations).",
493 },
494 0, -1.0, DBL_MAX
495 },
496 {
497 {
498 "vacuum_cleanup_index_scale_factor",
499 "Deprecated B-Tree parameter.",
502 },
503 -1, 0.0, 1e10
504 },
505 /* list terminator */
506 {{NULL}}
507};

Referenced by initialize_reloptions().

◆ relOpts

relopt_gen** relOpts = NULL
static

◆ StdRdOptIndexCleanupValues

◆ stringRelOpts

relopt_string stringRelOpts[]
static
Initial value:
=
{
{{NULL}}
}

Definition at line 581 of file reloptions.c.

582{
583 /* list terminator */
584 {{NULL}}
585};

Referenced by initialize_reloptions().

◆ ternaryRelOpts

relopt_ternary ternaryRelOpts[]
static
Initial value:
=
{
{
{
"vacuum_truncate",
"Enables vacuum to truncate empty pages at the end of this table",
}
},
{
{
}
}
}

Definition at line 169 of file reloptions.c.

170{
171 {
172 {
173 "vacuum_truncate",
174 "Enables vacuum to truncate empty pages at the end of this table",
177 }
178 },
179 /* list terminator */
180 {
181 {
182 NULL
183 }
184 }
185};

Referenced by initialize_reloptions().

◆ viewCheckOptValues

relopt_enum_elt_def viewCheckOptValues[]
static
Initial value:
=
{
{(const char *) NULL}
}
@ VIEW_OPTION_CHECK_OPTION_LOCAL
Definition rel.h:416
@ VIEW_OPTION_CHECK_OPTION_CASCADED
Definition rel.h:417

Definition at line 534 of file reloptions.c.

535{
536 /* no value for NOT_SET */
539 {(const char *) NULL} /* list terminator */
540};