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

603 : \
604 ((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 900 of file reloptions.c.

902{
904 default_val, lockmode);
905
907}
static void add_reloption(relopt_gen *newoption)
Definition reloptions.c:748
static relopt_bool * init_bool_reloption(bits32 kinds, const char *name, const char *desc, bool default_val, LOCKMODE lockmode)
Definition reloptions.c:883
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 1118 of file reloptions.c.

1121{
1123 members, default_val,
1124 detailmsg, lockmode);
1125
1127}
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 1001 of file reloptions.c.

1003{
1005 default_val, min_val,
1006 max_val, lockmode);
1007
1009}
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:981

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

918{
920 name, desc,
921 default_val, 0);
922
924}
static void add_local_reloption(local_relopts *relopts, relopt_gen *newoption, int offset)
Definition reloptions.c:805
@ RELOPT_KIND_LOCAL
Definition reloptions.h:42

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

1139{
1141 name, desc,
1142 members, default_val,
1143 detailmsg, 0);
1144
1146}

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

1075{
1077 name, desc,
1078 default_val, min_val,
1079 max_val, 0);
1080
1082}
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 805 of file reloptions.c.

806{
808
809 Assert(offset < relopts->relopt_struct_size);
810
811 opt->option = newoption;
812 opt->offset = offset;
813
814 relopts->options = lappend(relopts->options, opt);
815}
#define Assert(condition)
Definition c.h:873
#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:168

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

1222{
1224 name, desc,
1225 default_val,
1226 validator, filler,
1227 0);
1228
1230}
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 965 of file reloptions.c.

967{
969
970 newoption =
972
974}
static relopt_ternary * init_ternary_reloption(bits32 kinds, const char *name, const char *desc, LOCKMODE lockmode)
Definition reloptions.c:931

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

1057{
1059 default_val, min_val,
1060 max_val, lockmode);
1061
1063}

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

749{
750 static int max_custom_options = 0;
751
753 {
755
757
758 if (max_custom_options == 0)
759 {
762 }
763 else
764 {
767 max_custom_options * sizeof(relopt_gen *));
768 }
770 }
772
773 need_initialization = true;
774}
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:589
static bool need_initialization
Definition reloptions.c:591
static relopt_gen ** custom_options
Definition reloptions.c:590

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

732{
733 /* don't hand out the last bit so that the enum's behavior is portable */
737 errmsg("user-defined relation parameter types limit exceeded")));
738 last_assigned_kind <<= 1;
740}
int errcode(int sqlerrcode)
Definition elog.c:863
int errmsg(const char *fmt,...)
Definition elog.c:1080
#define ERROR
Definition elog.h:39
#define ereport(elevel,...)
Definition elog.h:150
static bits32 last_assigned_kind
Definition reloptions.c:587
relopt_kind
Definition reloptions.h:41
@ RELOPT_KIND_MAX
Definition reloptions.h:58

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

1201{
1203 default_val,
1204 validator, NULL,
1205 lockmode);
1206
1208}

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

949{
951
952 newoption =
953 init_ternary_reloption(kinds, name, desc, lockmode);
954
956}

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

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

1826{
1827 Size size = base;
1828 int i;
1829
1830 for (i = 0; i < numoptions; i++)
1831 {
1833
1834 if (optval->gen->type == RELOPT_TYPE_STRING)
1835 {
1837
1838 if (optstr->fill_cb)
1839 {
1840 const char *val = optval->isset ? optval->string_val :
1841 optstr->default_isnull ? NULL : optstr->default_val;
1842
1843 size += optstr->fill_cb(val, NULL);
1844 }
1845 else
1846 size += GET_STRING_RELOPTION_LEN(*optval) + 1;
1847 }
1848 }
1849
1850 return palloc0(size);
1851}
size_t Size
Definition c.h:619
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:602
relopt_gen gen
Definition reloptions.h:149

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

2242{
2243 LOCKMODE lockmode = NoLock;
2244 ListCell *cell;
2245
2246 if (defList == NIL)
2247 return AccessExclusiveLock;
2248
2251
2252 foreach(cell, defList)
2253 {
2254 DefElem *def = (DefElem *) lfirst(cell);
2255 int i;
2256
2257 for (i = 0; relOpts[i]; i++)
2258 {
2259 if (strncmp(relOpts[i]->name,
2260 def->defname,
2261 relOpts[i]->namelen + 1) == 0)
2262 {
2263 if (lockmode < relOpts[i]->lockmode)
2264 lockmode = relOpts[i]->lockmode;
2265 }
2266 }
2267 }
2268
2269 return lockmode;
2270}
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:613
static relopt_gen ** relOpts
Definition reloptions.c:586
char * defname
Definition parsenodes.h:844
LOCKMODE lockmode
Definition reloptions.h:71

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

2203{
2204 static const relopt_parse_elt tab[] = {
2205 {"n_distinct", RELOPT_TYPE_REAL, offsetof(AttributeOpts, n_distinct)},
2206 {"n_distinct_inherited", RELOPT_TYPE_REAL, offsetof(AttributeOpts, n_distinct_inherited)}
2207 };
2208
2209 return (bytea *) build_reloptions(reloptions, validate,
2211 sizeof(AttributeOpts),
2212 tab, lengthof(tab));
2213}
static bool validate(Port *port, const char *auth)
Definition auth-oauth.c:638
#define lengthof(array)
Definition c.h:803
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:49
Definition c.h:706

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

2079{
2080 int noptions = list_length(relopts->options);
2082 relopt_value *vals;
2083 void *opts;
2084 int i = 0;
2085 ListCell *lc;
2086
2087 foreach(lc, relopts->options)
2088 {
2089 local_relopt *opt = lfirst(lc);
2090
2091 elems[i].optname = opt->option->name;
2092 elems[i].opttype = opt->option->type;
2093 elems[i].offset = opt->offset;
2094
2095 i++;
2096 }
2097
2099 opts = allocateReloptStruct(relopts->relopt_struct_size, vals, noptions);
2100 fillRelOptions(opts, relopts->relopt_struct_size, vals, noptions, validate,
2101 elems, noptions);
2102
2103 if (validate)
2104 foreach(lc, relopts->validators)
2105 ((relopts_validator) lfirst(lc)) (opts, vals, noptions);
2106
2107 if (elems)
2108 pfree(elems);
2109
2110 return opts;
2111}
#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:145
const char * name
Definition reloptions.h:67
relopt_type type
Definition reloptions.h:73
const char * optname
Definition reloptions.h:160
relopt_type opttype
Definition reloptions.h:161

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

2046{
2047 int numoptions;
2049 void *rdopts;
2050
2051 /* parse options specific to given relation option kind */
2052 options = parseRelOptions(reloptions, validate, kind, &numoptions);
2054
2055 /* if none set, we're done */
2056 if (numoptions == 0)
2057 {
2058 Assert(options == NULL);
2059 return NULL;
2060 }
2061
2062 /* allocate and fill the structure */
2063 rdopts = allocateReloptStruct(relopt_struct_size, options, numoptions);
2064 fillRelOptions(rdopts, relopt_struct_size, options, numoptions,
2066
2067 pfree(options);
2068
2069 return rdopts;
2070}
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 1965 of file reloptions.c.

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

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

1490{
1491 bytea *options;
1492 bool isnull;
1493 Datum datum;
1495
1496 datum = fastgetattr(tuple,
1498 tupdesc,
1499 &isnull);
1500 if (isnull)
1501 return NULL;
1502
1504
1505 /* Parse into appropriate format; don't error out here */
1506 switch (classForm->relkind)
1507 {
1508 case RELKIND_RELATION:
1509 case RELKIND_TOASTVALUE:
1510 case RELKIND_MATVIEW:
1511 options = heap_reloptions(classForm->relkind, datum, false);
1512 break;
1514 options = partitioned_table_reloptions(datum, false);
1515 break;
1516 case RELKIND_VIEW:
1517 options = view_reloptions(datum, false);
1518 break;
1519 case RELKIND_INDEX:
1521 options = index_reloptions(amoptions, datum, false);
1522 break;
1524 options = NULL;
1525 break;
1526 default:
1527 Assert(false); /* can't get here */
1528 options = NULL; /* keep compiler quiet */
1529 break;
1530 }
1531
1532 return options;
1533}
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:156
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 1865 of file reloptions.c.

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

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

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

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

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

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

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

1092{
1094
1096 name, desc, lockmode);
1097 newoption->members = members;
1098 newoption->default_val = default_val;
1099 newoption->detailmsg = detailmsg;
1100
1101 return newoption;
1102}

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

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

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

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

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

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

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

1158{
1160
1161 /* make sure the validator/default combination is sane */
1162 if (validator)
1163 (validator) (default_val);
1164
1166 name, desc, lockmode);
1167 newoption->validate_cb = validator;
1168 newoption->fill_cb = filler;
1169 if (default_val)
1170 {
1171 if (kinds == RELOPT_KIND_LOCAL)
1172 newoption->default_val = strdup(default_val);
1173 else
1174 newoption->default_val = MemoryContextStrdup(TopMemoryContext, default_val);
1175 newoption->default_len = strlen(default_val);
1176 newoption->default_isnull = false;
1177 }
1178 else
1179 {
1180 newoption->default_val = "";
1181 newoption->default_len = 0;
1182 newoption->default_isnull = true;
1183 }
1184
1185 return newoption;
1186}
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 931 of file reloptions.c.

933{
935
937 allocate_reloption(kinds, RELOPT_TYPE_TERNARY, name, desc, lockmode);
938
939 return newoption;
940}

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

614{
615 int i;
616 int j;
617
618 j = 0;
619 for (i = 0; boolRelOpts[i].gen.name; i++)
620 {
623 j++;
624 }
625 for (i = 0; ternaryRelOpts[i].gen.name; i++)
626 {
629 j++;
630 }
631
632 for (i = 0; intRelOpts[i].gen.name; i++)
633 {
636 j++;
637 }
638 for (i = 0; realRelOpts[i].gen.name; i++)
639 {
642 j++;
643 }
644 for (i = 0; enumRelOpts[i].gen.name; i++)
645 {
648 j++;
649 }
650 for (i = 0; stringRelOpts[i].gen.name; i++)
651 {
654 j++;
655 }
657
658 if (relOpts)
659 pfree(relOpts);
661 (j + 1) * sizeof(relopt_gen *));
662
663 j = 0;
664 for (i = 0; boolRelOpts[i].gen.name; i++)
665 {
669 j++;
670 }
671
672 for (i = 0; ternaryRelOpts[i].gen.name; i++)
673 {
677 j++;
678 }
679
680 for (i = 0; intRelOpts[i].gen.name; i++)
681 {
682 relOpts[j] = &intRelOpts[i].gen;
685 j++;
686 }
687
688 for (i = 0; realRelOpts[i].gen.name; i++)
689 {
693 j++;
694 }
695
696 for (i = 0; enumRelOpts[i].gen.name; i++)
697 {
701 j++;
702 }
703
704 for (i = 0; stringRelOpts[i].gen.name; i++)
705 {
709 j++;
710 }
711
712 for (i = 0; i < num_custom_options; i++)
713 {
715 j++;
716 }
717
718 /* add a list terminator */
719 relOpts[j] = NULL;
720
721 /* flag the work is complete */
722 need_initialization = false;
723}
bool DoLockModesConflict(LOCKMODE mode1, LOCKMODE mode2)
Definition lock.c:623
void * MemoryContextAlloc(MemoryContext context, Size size)
Definition mcxt.c:1232
static relopt_real realRelOpts[]
Definition reloptions.c:411
static relopt_int intRelOpts[]
Definition reloptions.c:186
static relopt_enum enumRelOpts[]
Definition reloptions.c:541
static relopt_string stringRelOpts[]
Definition reloptions.c:580
static relopt_bool boolRelOpts[]
Definition reloptions.c:98
static relopt_ternary ternaryRelOpts[]
Definition reloptions.c:168
relopt_gen gen
Definition reloptions.h:95
relopt_gen gen
Definition reloptions.h:133
relopt_gen gen
Definition reloptions.h:107
relopt_gen gen
Definition reloptions.h:115
relopt_gen gen
Definition reloptions.h:101

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

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

1651{
1652 int nopts = list_length(relopts->options);
1654 ListCell *lc;
1655 int i = 0;
1656
1657 foreach(lc, relopts->options)
1658 {
1659 local_relopt *opt = lfirst(lc);
1660
1661 values[i].gen = opt->option;
1662 values[i].isset = false;
1663
1664 i++;
1665 }
1666
1667 if (options != (Datum) 0)
1669
1670 return values;
1671}
static Datum values[MAXATTR]
Definition bootstrap.c:155
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 1608 of file reloptions.c.

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

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

1538{
1541 int noptions;
1542 int i;
1543
1545
1546 for (i = 0; i < noptions; i++)
1547 {
1550 int j;
1551
1552 /* Search for a match in reloptions */
1553 for (j = 0; j < numoptions; j++)
1554 {
1555 int kw_len = reloptions[j].gen->namelen;
1556
1557 if (text_len > kw_len && text_str[kw_len] == '=' &&
1558 strncmp(text_str, reloptions[j].gen->name, kw_len) == 0)
1559 {
1560 parse_one_reloption(&reloptions[j], text_str, text_len,
1561 validate);
1562 break;
1563 }
1564 }
1565
1566 if (j >= numoptions && validate)
1567 {
1568 char *s;
1569 char *p;
1570
1572 p = strchr(s, '=');
1573 if (p)
1574 *p = '\0';
1575 ereport(ERROR,
1577 errmsg("unrecognized parameter \"%s\"", s)));
1578 }
1579 }
1580
1581 /* It's worth avoiding memory leaks in this function */
1583
1584 if (((void *) array) != DatumGetPointer(options))
1585 pfree(array);
1586}
#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:98
#define VARHDRSZ
Definition c.h:711
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 2117 of file reloptions.c.

2118{
2119 if (validate && reloptions)
2120 ereport(ERROR,
2122 errmsg("cannot specify storage parameters for a partitioned table"),
2123 errhint("Specify storage parameters for its leaf partitions instead."));
2124 return NULL;
2125}
int errhint(const char *fmt,...)
Definition elog.c:1330

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

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

References fb(), and lappend().

Referenced by ltree_gist_options().

◆ tablespace_reloptions()

bytea * tablespace_reloptions ( Datum  reloptions,
bool  validate 
)

Definition at line 2219 of file reloptions.c.

2220{
2221 static const relopt_parse_elt tab[] = {
2224 {"effective_io_concurrency", RELOPT_TYPE_INT, offsetof(TableSpaceOpts, effective_io_concurrency)},
2225 {"maintenance_io_concurrency", RELOPT_TYPE_INT, offsetof(TableSpaceOpts, maintenance_io_concurrency)}
2226 };
2227
2228 return (bytea *) build_reloptions(reloptions, validate,
2230 sizeof(TableSpaceOpts),
2231 tab, lengthof(tab));
2232}
int maintenance_io_concurrency
Definition bufmgr.c:191
int effective_io_concurrency
Definition bufmgr.c:184
double random_page_cost
Definition costsize.c:131
double seq_page_cost
Definition costsize.c:130
@ RELOPT_KIND_TABLESPACE
Definition reloptions.h:50

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

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

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

1441{
1442 List *result = NIL;
1443 ArrayType *array;
1445 int noptions;
1446 int i;
1447
1448 /* Nothing to do if no options */
1450 return result;
1451
1452 array = DatumGetArrayTypeP(options);
1453
1455
1456 for (i = 0; i < noptions; i++)
1457 {
1458 char *s;
1459 char *p;
1460 Node *val = NULL;
1461
1463 p = strchr(s, '=');
1464 if (p)
1465 {
1466 *p++ = '\0';
1467 val = (Node *) makeString(p);
1468 }
1469 result = lappend(result, makeDefElem(s, val, -1));
1470 }
1471
1472 return result;
1473}
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 2131 of file reloptions.c.

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

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

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

Referenced by initialize_reloptions().

◆ custom_options

relopt_gen** custom_options = NULL
static

Definition at line 590 of file reloptions.c.

Referenced by add_reloption(), and initialize_reloptions().

◆ enumRelOpts

relopt_enum enumRelOpts[]
static

Definition at line 541 of file reloptions.c.

542{
543 {
544 {
545 "vacuum_index_cleanup",
546 "Controls index vacuuming and index cleanup",
549 },
552 gettext_noop("Valid values are \"on\", \"off\", and \"auto\".")
553 },
554 {
555 {
556 "buffering",
557 "Enables buffering build for this GiST index",
560 },
563 gettext_noop("Valid values are \"on\", \"off\", and \"auto\".")
564 },
565 {
566 {
567 "check_option",
568 "View has WITH CHECK OPTION defined (local or cascaded).",
571 },
574 gettext_noop("Valid values are \"local\" and \"cascaded\".")
575 },
576 /* list terminator */
577 {{NULL}}
578};
#define gettext_noop(x)
Definition c.h:1185
@ 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:524
static relopt_enum_elt_def StdRdOptIndexCleanupValues[]
Definition reloptions.c:509
static relopt_enum_elt_def viewCheckOptValues[]
Definition reloptions.c:533
@ RELOPT_KIND_GIST
Definition reloptions.h:48

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

525{
529 {(const char *) NULL} /* list terminator */
530};

◆ intRelOpts

relopt_int intRelOpts[]
static

Definition at line 186 of file reloptions.c.

187{
188 {
189 {
190 "fillfactor",
191 "Packs table pages only to this percentage",
193 ShareUpdateExclusiveLock /* since it applies only to later
194 * inserts */
195 },
197 },
198 {
199 {
200 "fillfactor",
201 "Packs btree index pages only to this percentage",
203 ShareUpdateExclusiveLock /* since it applies only to later
204 * inserts */
205 },
207 },
208 {
209 {
210 "fillfactor",
211 "Packs hash index pages only to this percentage",
213 ShareUpdateExclusiveLock /* since it applies only to later
214 * inserts */
215 },
217 },
218 {
219 {
220 "fillfactor",
221 "Packs gist index pages only to this percentage",
223 ShareUpdateExclusiveLock /* since it applies only to later
224 * inserts */
225 },
227 },
228 {
229 {
230 "fillfactor",
231 "Packs spgist index pages only to this percentage",
233 ShareUpdateExclusiveLock /* since it applies only to later
234 * inserts */
235 },
237 },
238 {
239 {
240 "autovacuum_vacuum_threshold",
241 "Minimum number of tuple updates or deletes prior to vacuum",
244 },
245 -1, 0, INT_MAX
246 },
247 {
248 {
249 "autovacuum_vacuum_max_threshold",
250 "Maximum number of tuple updates or deletes prior to vacuum",
253 },
254 -2, -1, INT_MAX
255 },
256 {
257 {
258 "autovacuum_vacuum_insert_threshold",
259 "Minimum number of tuple inserts prior to vacuum, or -1 to disable insert vacuums",
262 },
263 -2, -1, INT_MAX
264 },
265 {
266 {
267 "autovacuum_analyze_threshold",
268 "Minimum number of tuple inserts, updates or deletes prior to analyze",
271 },
272 -1, 0, INT_MAX
273 },
274 {
275 {
276 "autovacuum_vacuum_cost_limit",
277 "Vacuum cost amount available before napping, for autovacuum",
280 },
281 -1, 1, 10000
282 },
283 {
284 {
285 "autovacuum_freeze_min_age",
286 "Minimum age at which VACUUM should freeze a table row, for autovacuum",
289 },
290 -1, 0, 1000000000
291 },
292 {
293 {
294 "autovacuum_multixact_freeze_min_age",
295 "Minimum multixact age at which VACUUM should freeze a row multixact's, for autovacuum",
298 },
299 -1, 0, 1000000000
300 },
301 {
302 {
303 "autovacuum_freeze_max_age",
304 "Age at which to autovacuum a table to prevent transaction ID wraparound",
307 },
308 -1, 100000, 2000000000
309 },
310 {
311 {
312 "autovacuum_multixact_freeze_max_age",
313 "Multixact age at which to autovacuum a table to prevent multixact wraparound",
316 },
317 -1, 10000, 2000000000
318 },
319 {
320 {
321 "autovacuum_freeze_table_age",
322 "Age at which VACUUM should perform a full table sweep to freeze row versions",
325 }, -1, 0, 2000000000
326 },
327 {
328 {
329 "autovacuum_multixact_freeze_table_age",
330 "Age of multixact at which VACUUM should perform a full table sweep to freeze row versions",
333 }, -1, 0, 2000000000
334 },
335 {
336 {
337 "log_autovacuum_min_duration",
338 "Sets the minimum execution time above which vacuum actions by autovacuum will be logged",
341 },
342 -1, -1, INT_MAX
343 },
344 {
345 {
346 "log_autoanalyze_min_duration",
347 "Sets the minimum execution time above which analyze actions by autovacuum will be logged",
350 },
351 -1, -1, INT_MAX
352 },
353 {
354 {
355 "toast_tuple_target",
356 "Sets the target tuple length at which external columns will be toasted",
359 },
361 },
362 {
363 {
364 "pages_per_range",
365 "Number of pages that each page range covers in a BRIN index",
368 }, 128, 1, 131072
369 },
370 {
371 {
372 "gin_pending_list_limit",
373 "Maximum size of the pending list for this GIN index, in kilobytes.",
376 },
377 -1, 64, MAX_KILOBYTES
378 },
379 {
380 {
381 "effective_io_concurrency",
382 "Number of simultaneous requests that can be handled efficiently by the disk subsystem.",
385 },
386 -1, 0, MAX_IO_CONCURRENCY
387 },
388 {
389 {
390 "maintenance_io_concurrency",
391 "Number of simultaneous requests that can be handled efficiently by the disk subsystem for maintenance work.",
394 },
395 -1, 0, MAX_IO_CONCURRENCY
396 },
397 {
398 {
399 "parallel_workers",
400 "Number of parallel processes that can be used per executor node for this relation.",
403 },
404 -1, 0, 1024
405 },
406
407 /* list terminator */
408 {{NULL}}
409};
#define MAX_IO_CONCURRENCY
Definition bufmgr.h:195
#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:51
@ RELOPT_KIND_HASH
Definition reloptions.h:46
#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 587 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 589 of file reloptions.c.

Referenced by add_reloption(), and initialize_reloptions().

◆ realRelOpts

relopt_real realRelOpts[]
static

Definition at line 411 of file reloptions.c.

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

Referenced by initialize_reloptions().

◆ relOpts

relopt_gen** relOpts = NULL
static

◆ StdRdOptIndexCleanupValues

◆ stringRelOpts

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

Definition at line 580 of file reloptions.c.

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

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

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

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

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