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 (uint32 kinds, int type, const char *name, const char *desc, LOCKMODE lockmode)
 
static relopt_boolinit_bool_reloption (uint32 kinds, const char *name, const char *desc, bool default_val, LOCKMODE lockmode)
 
void add_bool_reloption (uint32 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 (uint32 kinds, const char *name, const char *desc, LOCKMODE lockmode)
 
void add_ternary_reloption (uint32 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 (uint32 kinds, const char *name, const char *desc, int default_val, int min_val, int max_val, LOCKMODE lockmode)
 
void add_int_reloption (uint32 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 (uint32 kinds, const char *name, const char *desc, double default_val, double min_val, double max_val, LOCKMODE lockmode)
 
void add_real_reloption (uint32 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 (uint32 kinds, const char *name, const char *desc, relopt_enum_elt_def *members, int default_val, const char *detailmsg, LOCKMODE lockmode)
 
void add_enum_reloption (uint32 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 (uint32 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 (uint32 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 uint32 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 612 of file reloptions.c.

613 : \
614 ((relopt_string *) (option).gen)->default_len)

Function Documentation

◆ add_bool_reloption()

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

Definition at line 910 of file reloptions.c.

912{
914 default_val, lockmode);
915
917}
static void add_reloption(relopt_gen *newoption)
Definition reloptions.c:758
static relopt_bool * init_bool_reloption(uint32 kinds, const char *name, const char *desc, bool default_val, LOCKMODE lockmode)
Definition reloptions.c:893
const char * name

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

Referenced by create_reloptions_table().

◆ add_enum_reloption()

void add_enum_reloption ( uint32  kinds,
const char name,
const char desc,
relopt_enum_elt_def members,
int  default_val,
const char detailmsg,
LOCKMODE  lockmode 
)

Definition at line 1128 of file reloptions.c.

1131{
1133 members, default_val,
1134 detailmsg, lockmode);
1135
1137}
static relopt_enum * init_enum_reloption(uint32 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 ( uint32  kinds,
const char name,
const char desc,
int  default_val,
int  min_val,
int  max_val,
LOCKMODE  lockmode 
)

Definition at line 1011 of file reloptions.c.

1013{
1015 default_val, min_val,
1016 max_val, lockmode);
1017
1019}
tree ctl max_val
Definition radixtree.h:1859
static relopt_int * init_int_reloption(uint32 kinds, const char *name, const char *desc, int default_val, int min_val, int max_val, LOCKMODE lockmode)
Definition reloptions.c:991

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 926 of file reloptions.c.

928{
930 name, desc,
931 default_val, 0);
932
934}
static void add_local_reloption(local_relopts *relopts, relopt_gen *newoption, int offset)
Definition reloptions.c:815
@ 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 1146 of file reloptions.c.

1149{
1151 name, desc,
1152 members, default_val,
1153 detailmsg, 0);
1154
1156}

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 1082 of file reloptions.c.

1085{
1087 name, desc,
1088 default_val, min_val,
1089 max_val, 0);
1090
1092}
static relopt_real * init_real_reloption(uint32 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 815 of file reloptions.c.

816{
818
819 Assert(offset < relopts->relopt_struct_size);
820
821 opt->option = newoption;
822 opt->offset = offset;
823
824 relopts->options = lappend(relopts->options, opt);
825}
#define Assert(condition)
Definition c.h:943
#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 1228 of file reloptions.c.

1232{
1234 name, desc,
1235 default_val,
1236 validator, filler,
1237 0);
1238
1240}
static relopt_string * init_string_reloption(uint32 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 975 of file reloptions.c.

977{
979
980 newoption =
982
984}
static relopt_ternary * init_ternary_reloption(uint32 kinds, const char *name, const char *desc, LOCKMODE lockmode)
Definition reloptions.c:941

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

◆ add_real_reloption()

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

Definition at line 1064 of file reloptions.c.

1067{
1069 default_val, min_val,
1070 max_val, lockmode);
1071
1073}

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 758 of file reloptions.c.

759{
760 static int max_custom_options = 0;
761
763 {
765
767
768 if (max_custom_options == 0)
769 {
772 }
773 else
774 {
777 max_custom_options * sizeof(relopt_gen *));
778 }
780 }
782
783 need_initialization = true;
784}
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:599
static bool need_initialization
Definition reloptions.c:601
static relopt_gen ** custom_options
Definition reloptions.c:600

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 741 of file reloptions.c.

742{
743 /* don't hand out the last bit so that the enum's behavior is portable */
747 errmsg("user-defined relation parameter types limit exceeded")));
748 last_assigned_kind <<= 1;
750}
int errcode(int sqlerrcode)
Definition elog.c:875
#define ERROR
Definition elog.h:40
#define ereport(elevel,...)
Definition elog.h:152
static char * errmsg
static uint32 last_assigned_kind
Definition reloptions.c:597
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 ( uint32  kinds,
const char name,
const char desc,
const char default_val,
validate_string_relopt  validator,
LOCKMODE  lockmode 
)

Definition at line 1208 of file reloptions.c.

1211{
1213 default_val,
1214 validator, NULL,
1215 lockmode);
1216
1218}

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

Referenced by create_reloptions_table().

◆ add_ternary_reloption()

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

Definition at line 957 of file reloptions.c.

959{
961
962 newoption =
963 init_ternary_reloption(kinds, name, desc, lockmode);
964
966}

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

Referenced by create_reloptions_table().

◆ allocate_reloption()

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

Definition at line 833 of file reloptions.c.

835{
837 size_t size;
839
840 if (kinds != RELOPT_KIND_LOCAL)
842 else
843 oldcxt = NULL;
844
845 switch (type)
846 {
847 case RELOPT_TYPE_BOOL:
848 size = sizeof(relopt_bool);
849 break;
851 size = sizeof(relopt_ternary);
852 break;
853 case RELOPT_TYPE_INT:
854 size = sizeof(relopt_int);
855 break;
856 case RELOPT_TYPE_REAL:
857 size = sizeof(relopt_real);
858 break;
859 case RELOPT_TYPE_ENUM:
860 size = sizeof(relopt_enum);
861 break;
863 size = sizeof(relopt_string);
864 break;
865 default:
866 elog(ERROR, "unsupported reloption type %d", type);
867 return NULL; /* keep compiler quiet */
868 }
869
870 newoption = palloc(size);
871
872 newoption->name = pstrdup(name);
873 if (desc)
874 newoption->desc = pstrdup(desc);
875 else
876 newoption->desc = NULL;
877 newoption->kinds = kinds;
878 newoption->namelen = strlen(name);
879 newoption->type = type;
880 newoption->lockmode = lockmode;
881
882 if (oldcxt != NULL)
884
885 return newoption;
886}
#define elog(elevel,...)
Definition elog.h:228
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 1835 of file reloptions.c.

1836{
1837 Size size = base;
1838 int i;
1839
1840 for (i = 0; i < numoptions; i++)
1841 {
1843
1844 if (optval->gen->type == RELOPT_TYPE_STRING)
1845 {
1847
1848 if (optstr->fill_cb)
1849 {
1850 const char *val = optval->isset ? optval->string_val :
1851 optstr->default_isnull ? NULL : optstr->default_val;
1852
1853 size += optstr->fill_cb(val, NULL);
1854 }
1855 else
1856 size += GET_STRING_RELOPTION_LEN(*optval) + 1;
1857 }
1858 }
1859
1860 return palloc0(size);
1861}
size_t Size
Definition c.h:689
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:612
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 2253 of file reloptions.c.

2254{
2255 LOCKMODE lockmode = NoLock;
2256 ListCell *cell;
2257
2258 if (defList == NIL)
2259 return AccessExclusiveLock;
2260
2263
2264 foreach(cell, defList)
2265 {
2266 DefElem *def = (DefElem *) lfirst(cell);
2267 int i;
2268
2269 for (i = 0; relOpts[i]; i++)
2270 {
2271 if (strncmp(relOpts[i]->name,
2272 def->defname,
2273 relOpts[i]->namelen + 1) == 0)
2274 {
2275 if (lockmode < relOpts[i]->lockmode)
2276 lockmode = relOpts[i]->lockmode;
2277 }
2278 }
2279 }
2280
2281 return lockmode;
2282}
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:623
static relopt_gen ** relOpts
Definition reloptions.c:596
char * defname
Definition parsenodes.h:860
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 2214 of file reloptions.c.

2215{
2216 static const relopt_parse_elt tab[] = {
2217 {"n_distinct", RELOPT_TYPE_REAL, offsetof(AttributeOpts, n_distinct)},
2218 {"n_distinct_inherited", RELOPT_TYPE_REAL, offsetof(AttributeOpts, n_distinct_inherited)}
2219 };
2220
2221 return (bytea *) build_reloptions(reloptions, validate,
2223 sizeof(AttributeOpts),
2224 tab, lengthof(tab));
2225}
static bool validate(Port *port, const char *auth, const char **logdetail)
Definition auth-oauth.c:672
#define lengthof(array)
Definition c.h:873
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:776

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 2090 of file reloptions.c.

2091{
2092 int noptions = list_length(relopts->options);
2094 relopt_value *vals;
2095 void *opts;
2096 int i = 0;
2097 ListCell *lc;
2098
2099 foreach(lc, relopts->options)
2100 {
2101 local_relopt *opt = lfirst(lc);
2102
2103 elems[i].optname = opt->option->name;
2104 elems[i].opttype = opt->option->type;
2105 elems[i].offset = opt->offset;
2106
2107 i++;
2108 }
2109
2111 opts = allocateReloptStruct(relopts->relopt_struct_size, vals, noptions);
2112 fillRelOptions(opts, relopts->relopt_struct_size, vals, noptions, validate,
2113 elems, noptions);
2114
2115 if (validate)
2116 foreach(lc, relopts->validators)
2117 ((relopts_validator) lfirst(lc)) (opts, vals, noptions);
2118
2119 if (elems)
2120 pfree(elems);
2121
2122 return opts;
2123}
#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 2053 of file reloptions.c.

2058{
2059 int numoptions;
2061 void *rdopts;
2062
2063 /* parse options specific to given relation option kind */
2064 options = parseRelOptions(reloptions, validate, kind, &numoptions);
2066
2067 /* if none set, we're done */
2068 if (numoptions == 0)
2069 {
2070 Assert(options == NULL);
2071 return NULL;
2072 }
2073
2074 /* allocate and fill the structure */
2075 rdopts = allocateReloptStruct(relopt_struct_size, options, numoptions);
2076 fillRelOptions(rdopts, relopt_struct_size, options, numoptions,
2078
2079 pfree(options);
2080
2081 return rdopts;
2082}
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 1975 of file reloptions.c.

1976{
1977 static const relopt_parse_elt tab[] = {
1979 {"autovacuum_enabled", RELOPT_TYPE_BOOL,
1980 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, enabled)},
1981 {"autovacuum_parallel_workers", RELOPT_TYPE_INT,
1982 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, autovacuum_parallel_workers)},
1983 {"autovacuum_vacuum_threshold", RELOPT_TYPE_INT,
1984 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, vacuum_threshold)},
1985 {"autovacuum_vacuum_max_threshold", RELOPT_TYPE_INT,
1986 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, vacuum_max_threshold)},
1987 {"autovacuum_vacuum_insert_threshold", RELOPT_TYPE_INT,
1988 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, vacuum_ins_threshold)},
1989 {"autovacuum_analyze_threshold", RELOPT_TYPE_INT,
1990 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, analyze_threshold)},
1991 {"autovacuum_vacuum_cost_limit", RELOPT_TYPE_INT,
1993 {"autovacuum_freeze_min_age", RELOPT_TYPE_INT,
1994 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, freeze_min_age)},
1995 {"autovacuum_freeze_max_age", RELOPT_TYPE_INT,
1996 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, freeze_max_age)},
1997 {"autovacuum_freeze_table_age", RELOPT_TYPE_INT,
1998 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, freeze_table_age)},
1999 {"autovacuum_multixact_freeze_min_age", RELOPT_TYPE_INT,
2000 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, multixact_freeze_min_age)},
2001 {"autovacuum_multixact_freeze_max_age", RELOPT_TYPE_INT,
2002 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, multixact_freeze_max_age)},
2003 {"autovacuum_multixact_freeze_table_age", RELOPT_TYPE_INT,
2004 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, multixact_freeze_table_age)},
2005 {"log_autovacuum_min_duration", RELOPT_TYPE_INT,
2006 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, log_vacuum_min_duration)},
2007 {"log_autoanalyze_min_duration", RELOPT_TYPE_INT,
2008 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, log_analyze_min_duration)},
2009 {"toast_tuple_target", RELOPT_TYPE_INT,
2010 offsetof(StdRdOptions, toast_tuple_target)},
2011 {"autovacuum_vacuum_cost_delay", RELOPT_TYPE_REAL,
2013 {"autovacuum_vacuum_scale_factor", RELOPT_TYPE_REAL,
2014 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, vacuum_scale_factor)},
2015 {"autovacuum_vacuum_insert_scale_factor", RELOPT_TYPE_REAL,
2016 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, vacuum_ins_scale_factor)},
2017 {"autovacuum_analyze_scale_factor", RELOPT_TYPE_REAL,
2018 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, analyze_scale_factor)},
2019 {"user_catalog_table", RELOPT_TYPE_BOOL,
2020 offsetof(StdRdOptions, user_catalog_table)},
2021 {"parallel_workers", RELOPT_TYPE_INT,
2022 offsetof(StdRdOptions, parallel_workers)},
2023 {"vacuum_index_cleanup", RELOPT_TYPE_ENUM,
2024 offsetof(StdRdOptions, vacuum_index_cleanup)},
2025 {"vacuum_truncate", RELOPT_TYPE_TERNARY,
2027 {"vacuum_max_eager_freeze_failure_rate", RELOPT_TYPE_REAL,
2029 };
2030
2031 return (bytea *) build_reloptions(reloptions, validate, kind,
2032 sizeof(StdRdOptions),
2033 tab, lengthof(tab));
2034}
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 1498 of file reloptions.c.

1500{
1501 bytea *options;
1502 bool isnull;
1503 Datum datum;
1505
1506 datum = fastgetattr(tuple,
1508 tupdesc,
1509 &isnull);
1510 if (isnull)
1511 return NULL;
1512
1514
1515 /* Parse into appropriate format; don't error out here */
1516 switch (classForm->relkind)
1517 {
1518 case RELKIND_RELATION:
1519 case RELKIND_TOASTVALUE:
1520 case RELKIND_MATVIEW:
1521 options = heap_reloptions(classForm->relkind, datum, false);
1522 break;
1524 options = partitioned_table_reloptions(datum, false);
1525 break;
1526 case RELKIND_VIEW:
1527 options = view_reloptions(datum, false);
1528 break;
1529 case RELKIND_INDEX:
1531 options = index_reloptions(amoptions, datum, false);
1532 break;
1534 options = NULL;
1535 break;
1536 default:
1537 Assert(false); /* can't get here */
1538 options = NULL; /* keep compiler quiet */
1539 break;
1540 }
1541
1542 return options;
1543}
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 1875 of file reloptions.c.

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

2165{
2167
2168 switch (relkind)
2169 {
2170 case RELKIND_TOASTVALUE:
2171 rdopts = (StdRdOptions *)
2173 if (rdopts != NULL)
2174 {
2175 /* adjust default-only parameters for TOAST relations */
2176 rdopts->fillfactor = 100;
2177 rdopts->autovacuum.analyze_threshold = -1;
2178 rdopts->autovacuum.analyze_scale_factor = -1;
2179 }
2180 return (bytea *) rdopts;
2181 case RELKIND_RELATION:
2182 case RELKIND_MATVIEW:
2183 return default_reloptions(reloptions, validate, RELOPT_KIND_HEAP);
2184 default:
2185 /* other relkinds are not supported */
2186 return NULL;
2187 }
2188}
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 2199 of file reloptions.c.

2200{
2201 Assert(amoptions != NULL);
2202
2203 /* Assume function is strict */
2204 if (DatumGetPointer(reloptions) == NULL)
2205 return NULL;
2206
2207 return amoptions(reloptions, validate);
2208}
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 ( uint32  kinds,
const char name,
const char desc,
bool  default_val,
LOCKMODE  lockmode 
)
static

Definition at line 893 of file reloptions.c.

895{
897
899 name, desc, lockmode);
900 newoption->default_val = default_val;
901
902 return newoption;
903}
static relopt_gen * allocate_reloption(uint32 kinds, int type, const char *name, const char *desc, LOCKMODE lockmode)
Definition reloptions.c:833

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 ( uint32  kinds,
const char name,
const char desc,
relopt_enum_elt_def members,
int  default_val,
const char detailmsg,
LOCKMODE  lockmode 
)
static

Definition at line 1099 of file reloptions.c.

1102{
1104
1106 name, desc, lockmode);
1107 newoption->members = members;
1108 newoption->default_val = default_val;
1109 newoption->detailmsg = detailmsg;
1110
1111 return newoption;
1112}

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 ( uint32  kinds,
const char name,
const char desc,
int  default_val,
int  min_val,
int  max_val,
LOCKMODE  lockmode 
)
static

Definition at line 991 of file reloptions.c.

994{
996
998 name, desc, lockmode);
999 newoption->default_val = default_val;
1000 newoption->min = min_val;
1001 newoption->max = max_val;
1002
1003 return newoption;
1004}

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 792 of file reloptions.c.

793{
794 relopts->options = NIL;
795 relopts->validators = NIL;
796 relopts->relopt_struct_size = relopt_struct_size;
797}

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 ( uint32  kinds,
const char name,
const char desc,
double  default_val,
double  min_val,
double  max_val,
LOCKMODE  lockmode 
)
static

Definition at line 1044 of file reloptions.c.

1047{
1049
1051 name, desc, lockmode);
1052 newoption->default_val = default_val;
1053 newoption->min = min_val;
1054 newoption->max = max_val;
1055
1056 return newoption;
1057}

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 ( uint32  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 1163 of file reloptions.c.

1168{
1170
1171 /* make sure the validator/default combination is sane */
1172 if (validator)
1173 (validator) (default_val);
1174
1176 name, desc, lockmode);
1177 newoption->validate_cb = validator;
1178 newoption->fill_cb = filler;
1179 if (default_val)
1180 {
1181 if (kinds == RELOPT_KIND_LOCAL)
1182 newoption->default_val = strdup(default_val);
1183 else
1184 newoption->default_val = MemoryContextStrdup(TopMemoryContext, default_val);
1185 newoption->default_len = strlen(default_val);
1186 newoption->default_isnull = false;
1187 }
1188 else
1189 {
1190 newoption->default_val = "";
1191 newoption->default_len = 0;
1192 newoption->default_isnull = true;
1193 }
1194
1195 return newoption;
1196}
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 ( uint32  kinds,
const char name,
const char desc,
LOCKMODE  lockmode 
)
static

Definition at line 941 of file reloptions.c.

943{
945
947 allocate_reloption(kinds, RELOPT_TYPE_TERNARY, name, desc, lockmode);
948
949 return newoption;
950}

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 623 of file reloptions.c.

624{
625 int i;
626 int j;
627
628 j = 0;
629 for (i = 0; boolRelOpts[i].gen.name; i++)
630 {
633 j++;
634 }
635 for (i = 0; ternaryRelOpts[i].gen.name; i++)
636 {
639 j++;
640 }
641
642 for (i = 0; intRelOpts[i].gen.name; i++)
643 {
646 j++;
647 }
648 for (i = 0; realRelOpts[i].gen.name; i++)
649 {
652 j++;
653 }
654 for (i = 0; enumRelOpts[i].gen.name; i++)
655 {
658 j++;
659 }
660 for (i = 0; stringRelOpts[i].gen.name; i++)
661 {
664 j++;
665 }
667
668 if (relOpts)
669 pfree(relOpts);
671 (j + 1) * sizeof(relopt_gen *));
672
673 j = 0;
674 for (i = 0; boolRelOpts[i].gen.name; i++)
675 {
679 j++;
680 }
681
682 for (i = 0; ternaryRelOpts[i].gen.name; i++)
683 {
687 j++;
688 }
689
690 for (i = 0; intRelOpts[i].gen.name; i++)
691 {
692 relOpts[j] = &intRelOpts[i].gen;
695 j++;
696 }
697
698 for (i = 0; realRelOpts[i].gen.name; i++)
699 {
703 j++;
704 }
705
706 for (i = 0; enumRelOpts[i].gen.name; i++)
707 {
711 j++;
712 }
713
714 for (i = 0; stringRelOpts[i].gen.name; i++)
715 {
719 j++;
720 }
721
722 for (i = 0; i < num_custom_options; i++)
723 {
725 j++;
726 }
727
728 /* add a list terminator */
729 relOpts[j] = NULL;
730
731 /* flag the work is complete */
732 need_initialization = false;
733}
bool DoLockModesConflict(LOCKMODE mode1, LOCKMODE mode2)
Definition lock.c:621
void * MemoryContextAlloc(MemoryContext context, Size size)
Definition mcxt.c:1232
static relopt_real realRelOpts[]
Definition reloptions.c:421
static relopt_int intRelOpts[]
Definition reloptions.c:187
static relopt_enum enumRelOpts[]
Definition reloptions.c:551
static relopt_string stringRelOpts[]
Definition reloptions.c:590
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 1688 of file reloptions.c.

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

References _, b, elog, ereport, errcode(), errdetail(), errdetail_internal(), errmsg, ERROR, fb(), memcpy(), 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 1660 of file reloptions.c.

1661{
1662 int nopts = list_length(relopts->options);
1664 ListCell *lc;
1665 int i = 0;
1666
1667 foreach(lc, relopts->options)
1668 {
1669 local_relopt *opt = lfirst(lc);
1670
1671 values[i].gen = opt->option;
1672 values[i].isset = false;
1673
1674 i++;
1675 }
1676
1677 if (options != (Datum) 0)
1679
1680 return values;
1681}
static Datum values[MAXATTR]
Definition bootstrap.c:190
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 1618 of file reloptions.c.

1620{
1621 relopt_value *reloptions = NULL;
1622 int numoptions = 0;
1623 int i;
1624 int j;
1625
1628
1629 /* Build a list of expected options, based on kind */
1630
1631 for (i = 0; relOpts[i]; i++)
1632 if (relOpts[i]->kinds & kind)
1633 numoptions++;
1634
1635 if (numoptions > 0)
1636 {
1637 reloptions = palloc(numoptions * sizeof(relopt_value));
1638
1639 for (i = 0, j = 0; relOpts[i]; i++)
1640 {
1641 if (relOpts[i]->kinds & kind)
1642 {
1643 reloptions[j].gen = relOpts[i];
1644 reloptions[j].isset = false;
1645 j++;
1646 }
1647 }
1648 }
1649
1650 /* Done if no options */
1653
1655 return reloptions;
1656}
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 1546 of file reloptions.c.

1548{
1551 int noptions;
1552 int i;
1553
1555
1556 for (i = 0; i < noptions; i++)
1557 {
1560 int j;
1561
1562 /* Search for a match in reloptions */
1563 for (j = 0; j < numoptions; j++)
1564 {
1565 int kw_len = reloptions[j].gen->namelen;
1566
1567 if (text_len > kw_len && text_str[kw_len] == '=' &&
1568 strncmp(text_str, reloptions[j].gen->name, kw_len) == 0)
1569 {
1570 parse_one_reloption(&reloptions[j], text_str, text_len,
1571 validate);
1572 break;
1573 }
1574 }
1575
1576 if (j >= numoptions && validate)
1577 {
1578 char *s;
1579 char *p;
1580
1582 p = strchr(s, '=');
1583 if (p)
1584 *p = '\0';
1585 ereport(ERROR,
1587 errmsg("unrecognized parameter \"%s\"", s)));
1588 }
1589 }
1590
1591 /* It's worth avoiding memory leaks in this function */
1593
1594 if (((void *) array) != DatumGetPointer(options))
1595 pfree(array);
1596}
#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:781
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 2129 of file reloptions.c.

2130{
2131 if (validate && reloptions)
2132 ereport(ERROR,
2134 errmsg("cannot specify storage parameters for a partitioned table"),
2135 errhint("Specify storage parameters for its leaf partitions instead."));
2136 return NULL;
2137}
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 805 of file reloptions.c.

806{
807 relopts->validators = lappend(relopts->validators, validator);
808}

References fb(), and lappend().

Referenced by ltree_gist_options().

◆ tablespace_reloptions()

bytea * tablespace_reloptions ( Datum  reloptions,
bool  validate 
)

Definition at line 2231 of file reloptions.c.

2232{
2233 static const relopt_parse_elt tab[] = {
2236 {"effective_io_concurrency", RELOPT_TYPE_INT, offsetof(TableSpaceOpts, effective_io_concurrency)},
2237 {"maintenance_io_concurrency", RELOPT_TYPE_INT, offsetof(TableSpaceOpts, maintenance_io_concurrency)}
2238 };
2239
2240 return (bytea *) build_reloptions(reloptions, validate,
2242 sizeof(TableSpaceOpts),
2243 tab, lengthof(tab));
2244}
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 1266 of file reloptions.c.

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

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, result, 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 1450 of file reloptions.c.

1451{
1452 List *result = NIL;
1453 ArrayType *array;
1455 int noptions;
1456 int i;
1457
1458 /* Nothing to do if no options */
1460 return result;
1461
1462 array = DatumGetArrayTypeP(options);
1463
1465
1466 for (i = 0; i < noptions; i++)
1467 {
1468 char *s;
1469 char *p;
1470 Node *val = NULL;
1471
1473 p = strchr(s, '=');
1474 if (p)
1475 {
1476 *p++ = '\0';
1477 val = (Node *) makeString(p);
1478 }
1479 result = lappend(result, makeDefElem(s, val, -1));
1480 }
1481
1482 return result;
1483}
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, result, 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 2143 of file reloptions.c.

2144{
2145 static const relopt_parse_elt tab[] = {
2146 {"security_barrier", RELOPT_TYPE_BOOL,
2147 offsetof(ViewOptions, security_barrier)},
2148 {"security_invoker", RELOPT_TYPE_BOOL,
2149 offsetof(ViewOptions, security_invoker)},
2150 {"check_option", RELOPT_TYPE_ENUM,
2151 offsetof(ViewOptions, check_option)}
2152 };
2153
2154 return (bytea *) build_reloptions(reloptions, validate,
2156 sizeof(ViewOptions),
2157 tab, lengthof(tab));
2158}
@ 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 600 of file reloptions.c.

Referenced by add_reloption(), and initialize_reloptions().

◆ enumRelOpts

relopt_enum enumRelOpts[]
static

Definition at line 551 of file reloptions.c.

552{
553 {
554 {
555 "vacuum_index_cleanup",
556 "Controls index vacuuming and index cleanup",
559 },
562 gettext_noop("Valid values are \"on\", \"off\", and \"auto\".")
563 },
564 {
565 {
566 "buffering",
567 "Enables buffering build for this GiST index",
570 },
573 gettext_noop("Valid values are \"on\", \"off\", and \"auto\".")
574 },
575 {
576 {
577 "check_option",
578 "View has WITH CHECK OPTION defined (local or cascaded).",
581 },
584 gettext_noop("Valid values are \"local\" and \"cascaded\".")
585 },
586 /* list terminator */
587 {{NULL}}
588};
#define gettext_noop(x)
Definition c.h:1285
@ GIST_OPTION_BUFFERING_AUTO
@ VIEW_OPTION_CHECK_OPTION_NOT_SET
Definition rel.h:417
@ STDRD_OPTION_VACUUM_INDEX_CLEANUP_AUTO
Definition rel.h:338
static relopt_enum_elt_def gistBufferingOptValues[]
Definition reloptions.c:534
static relopt_enum_elt_def StdRdOptIndexCleanupValues[]
Definition reloptions.c:519
static relopt_enum_elt_def viewCheckOptValues[]
Definition reloptions.c:543
@ 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 534 of file reloptions.c.

535{
539 {(const char *) NULL} /* list terminator */
540};

◆ 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_parallel_workers",
242 "Maximum number of parallel autovacuum workers that can be used for processing this table.",
245 },
246 -1, -1, 1024
247 },
248 {
249 {
250 "autovacuum_vacuum_threshold",
251 "Minimum number of tuple updates or deletes prior to vacuum",
254 },
255 -1, 0, INT_MAX
256 },
257 {
258 {
259 "autovacuum_vacuum_max_threshold",
260 "Maximum number of tuple updates or deletes prior to vacuum",
263 },
264 -2, -1, INT_MAX
265 },
266 {
267 {
268 "autovacuum_vacuum_insert_threshold",
269 "Minimum number of tuple inserts prior to vacuum, or -1 to disable insert vacuums",
272 },
273 -2, -1, INT_MAX
274 },
275 {
276 {
277 "autovacuum_analyze_threshold",
278 "Minimum number of tuple inserts, updates or deletes prior to analyze",
281 },
282 -1, 0, INT_MAX
283 },
284 {
285 {
286 "autovacuum_vacuum_cost_limit",
287 "Vacuum cost amount available before napping, for autovacuum",
290 },
291 -1, 1, 10000
292 },
293 {
294 {
295 "autovacuum_freeze_min_age",
296 "Minimum age at which VACUUM should freeze a table row, for autovacuum",
299 },
300 -1, 0, 1000000000
301 },
302 {
303 {
304 "autovacuum_multixact_freeze_min_age",
305 "Minimum multixact age at which VACUUM should freeze a row multixact's, for autovacuum",
308 },
309 -1, 0, 1000000000
310 },
311 {
312 {
313 "autovacuum_freeze_max_age",
314 "Age at which to autovacuum a table to prevent transaction ID wraparound",
317 },
318 -1, 100000, 2000000000
319 },
320 {
321 {
322 "autovacuum_multixact_freeze_max_age",
323 "Multixact age at which to autovacuum a table to prevent multixact wraparound",
326 },
327 -1, 10000, 2000000000
328 },
329 {
330 {
331 "autovacuum_freeze_table_age",
332 "Age at which VACUUM should perform a full table sweep to freeze row versions",
335 }, -1, 0, 2000000000
336 },
337 {
338 {
339 "autovacuum_multixact_freeze_table_age",
340 "Age of multixact at which VACUUM should perform a full table sweep to freeze row versions",
343 }, -1, 0, 2000000000
344 },
345 {
346 {
347 "log_autovacuum_min_duration",
348 "Sets the minimum execution time above which vacuum actions by autovacuum will be logged",
351 },
352 -1, -1, INT_MAX
353 },
354 {
355 {
356 "log_autoanalyze_min_duration",
357 "Sets the minimum execution time above which analyze actions by autovacuum will be logged",
360 },
361 -1, -1, INT_MAX
362 },
363 {
364 {
365 "toast_tuple_target",
366 "Sets the target tuple length at which external columns will be toasted",
369 },
371 },
372 {
373 {
374 "pages_per_range",
375 "Number of pages that each page range covers in a BRIN index",
378 }, 128, 1, 131072
379 },
380 {
381 {
382 "gin_pending_list_limit",
383 "Maximum size of the pending list for this GIN index, in kilobytes.",
386 },
387 -1, 64, MAX_KILOBYTES
388 },
389 {
390 {
391 "effective_io_concurrency",
392 "Number of simultaneous requests that can be handled efficiently by the disk subsystem.",
395 },
396 -1, 0, MAX_IO_CONCURRENCY
397 },
398 {
399 {
400 "maintenance_io_concurrency",
401 "Number of simultaneous requests that can be handled efficiently by the disk subsystem for maintenance work.",
404 },
405 -1, 0, MAX_IO_CONCURRENCY
406 },
407 {
408 {
409 "parallel_workers",
410 "Number of parallel processes that can be used per executor node for this relation.",
413 },
414 -1, 0, 1024
415 },
416
417 /* list terminator */
418 {{NULL}}
419};
#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:361
#define HEAP_DEFAULT_FILLFACTOR
Definition rel.h:362
@ 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

uint32 last_assigned_kind = RELOPT_KIND_LAST_DEFAULT
static

Definition at line 597 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 599 of file reloptions.c.

Referenced by add_reloption(), and initialize_reloptions().

◆ realRelOpts

relopt_real realRelOpts[]
static

Definition at line 421 of file reloptions.c.

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

Referenced by initialize_reloptions().

◆ relOpts

relopt_gen** relOpts = NULL
static

◆ StdRdOptIndexCleanupValues

◆ stringRelOpts

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

Definition at line 590 of file reloptions.c.

591{
592 /* list terminator */
593 {{NULL}}
594};

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:418
@ VIEW_OPTION_CHECK_OPTION_CASCADED
Definition rel.h:419

Definition at line 543 of file reloptions.c.

544{
545 /* no value for NOT_SET */
548 {(const char *) NULL} /* list terminator */
549};