PostgreSQL Source Code git master
Loading...
Searching...
No Matches
reloptions.h File Reference
#include "access/amapi.h"
#include "access/htup.h"
#include "access/tupdesc.h"
#include "nodes/pg_list.h"
Include dependency graph for reloptions.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  relopt_gen
 
struct  relopt_value
 
struct  relopt_bool
 
struct  relopt_ternary
 
struct  relopt_int
 
struct  relopt_real
 
struct  relopt_enum_elt_def
 
struct  relopt_enum
 
struct  relopt_string
 
struct  relopt_parse_elt
 
struct  local_relopt
 
struct  local_relopts
 

Macros

#define HEAP_RELOPT_NAMESPACES   { "toast", NULL }
 
#define GET_STRING_RELOPTION(optstruct, member)
 

Typedefs

typedef enum relopt_type relopt_type
 
typedef enum relopt_kind relopt_kind
 
typedef struct relopt_gen relopt_gen
 
typedef struct relopt_value relopt_value
 
typedef struct relopt_bool relopt_bool
 
typedef struct relopt_ternary relopt_ternary
 
typedef struct relopt_int relopt_int
 
typedef struct relopt_real relopt_real
 
typedef struct relopt_enum_elt_def relopt_enum_elt_def
 
typedef struct relopt_enum relopt_enum
 
typedef void(* validate_string_relopt) (const char *value)
 
typedef Size(* fill_string_relopt) (const char *value, void *ptr)
 
typedef void(* relopts_validator) (void *parsed_options, relopt_value *vals, int nvals)
 
typedef struct relopt_string relopt_string
 
typedef struct local_relopt local_relopt
 
typedef struct local_relopts local_relopts
 

Enumerations

enum  relopt_type {
  RELOPT_TYPE_BOOL , RELOPT_TYPE_TERNARY , RELOPT_TYPE_INT , RELOPT_TYPE_REAL ,
  RELOPT_TYPE_ENUM , RELOPT_TYPE_STRING
}
 
enum  relopt_kind {
  RELOPT_KIND_LOCAL = 0 , RELOPT_KIND_HEAP = (1 << 0) , RELOPT_KIND_TOAST = (1 << 1) , RELOPT_KIND_BTREE = (1 << 2) ,
  RELOPT_KIND_HASH = (1 << 3) , RELOPT_KIND_GIN = (1 << 4) , RELOPT_KIND_GIST = (1 << 5) , RELOPT_KIND_ATTRIBUTE = (1 << 6) ,
  RELOPT_KIND_TABLESPACE = (1 << 7) , RELOPT_KIND_SPGIST = (1 << 8) , RELOPT_KIND_VIEW = (1 << 9) , RELOPT_KIND_BRIN = (1 << 10) ,
  RELOPT_KIND_PARTITIONED = (1 << 11) , RELOPT_KIND_LAST_DEFAULT = RELOPT_KIND_PARTITIONED , RELOPT_KIND_MAX = (1 << 30)
}
 

Functions

relopt_kind add_reloption_kind (void)
 
void add_bool_reloption (bits32 kinds, const char *name, const char *desc, bool default_val, LOCKMODE lockmode)
 
void add_ternary_reloption (bits32 kinds, const char *name, const char *desc, 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_real_reloption (bits32 kinds, const char *name, const char *desc, double default_val, double min_val, double max_val, 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_string_reloption (bits32 kinds, const char *name, const char *desc, const char *default_val, validate_string_relopt validator, LOCKMODE lockmode)
 
void init_local_reloptions (local_relopts *relopts, Size relopt_struct_size)
 
void register_reloptions_validator (local_relopts *relopts, relopts_validator validator)
 
void add_local_bool_reloption (local_relopts *relopts, const char *name, const char *desc, bool default_val, int offset)
 
void add_local_ternary_reloption (local_relopts *relopts, const char *name, const char *desc, int offset)
 
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)
 
void add_local_real_reloption (local_relopts *relopts, const char *name, const char *desc, double default_val, double min_val, double max_val, int offset)
 
void 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)
 
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)
 
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)
 
byteadefault_reloptions (Datum reloptions, bool validate, relopt_kind kind)
 
byteaheap_reloptions (char relkind, Datum reloptions, bool validate)
 
byteaview_reloptions (Datum reloptions, bool validate)
 
byteapartitioned_table_reloptions (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)
 

Macro Definition Documentation

◆ GET_STRING_RELOPTION

#define GET_STRING_RELOPTION (   optstruct,
  member 
)
Value:
((optstruct)->member == 0 ? NULL : \
(char *)(optstruct) + (optstruct)->member)
static int fb(int x)

Definition at line 185 of file reloptions.h.

186 : \
187 (char *)(optstruct) + (optstruct)->member)

◆ HEAP_RELOPT_NAMESPACES

#define HEAP_RELOPT_NAMESPACES   { "toast", NULL }

Definition at line 61 of file reloptions.h.

Typedef Documentation

◆ fill_string_relopt

typedef Size(* fill_string_relopt) (const char *value, void *ptr)

Definition at line 141 of file reloptions.h.

◆ local_relopt

◆ local_relopts

◆ relopt_bool

◆ relopt_enum

◆ relopt_enum_elt_def

◆ relopt_gen

◆ relopt_int

◆ relopt_kind

◆ relopt_real

◆ relopt_string

◆ relopt_ternary

◆ relopt_type

◆ relopt_value

◆ relopts_validator

typedef void(* relopts_validator) (void *parsed_options, relopt_value *vals, int nvals)

Definition at line 144 of file reloptions.h.

◆ validate_string_relopt

typedef void(* validate_string_relopt) (const char *value)

Definition at line 140 of file reloptions.h.

Enumeration Type Documentation

◆ relopt_kind

Enumerator
RELOPT_KIND_LOCAL 
RELOPT_KIND_HEAP 
RELOPT_KIND_TOAST 
RELOPT_KIND_BTREE 
RELOPT_KIND_HASH 
RELOPT_KIND_GIN 
RELOPT_KIND_GIST 
RELOPT_KIND_ATTRIBUTE 
RELOPT_KIND_TABLESPACE 
RELOPT_KIND_SPGIST 
RELOPT_KIND_VIEW 
RELOPT_KIND_BRIN 
RELOPT_KIND_PARTITIONED 
RELOPT_KIND_LAST_DEFAULT 
RELOPT_KIND_MAX 

Definition at line 39 of file reloptions.h.

40{
42 RELOPT_KIND_HEAP = (1 << 0),
43 RELOPT_KIND_TOAST = (1 << 1),
44 RELOPT_KIND_BTREE = (1 << 2),
45 RELOPT_KIND_HASH = (1 << 3),
46 RELOPT_KIND_GIN = (1 << 4),
47 RELOPT_KIND_GIST = (1 << 5),
48 RELOPT_KIND_ATTRIBUTE = (1 << 6),
49 RELOPT_KIND_TABLESPACE = (1 << 7),
50 RELOPT_KIND_SPGIST = (1 << 8),
51 RELOPT_KIND_VIEW = (1 << 9),
52 RELOPT_KIND_BRIN = (1 << 10),
53 RELOPT_KIND_PARTITIONED = (1 << 11),
54 /* if you add a new kind, make sure you update "last_default" too */
56 /* some compilers treat enums as signed ints, so we can't use 1 << 31 */
57 RELOPT_KIND_MAX = (1 << 30)
relopt_kind
Definition reloptions.h:40
@ RELOPT_KIND_LAST_DEFAULT
Definition reloptions.h:55
@ RELOPT_KIND_ATTRIBUTE
Definition reloptions.h:48
@ RELOPT_KIND_TOAST
Definition reloptions.h:43
@ RELOPT_KIND_LOCAL
Definition reloptions.h:41
@ RELOPT_KIND_SPGIST
Definition reloptions.h:50
@ RELOPT_KIND_MAX
Definition reloptions.h:57
@ RELOPT_KIND_GIST
Definition reloptions.h:47
@ RELOPT_KIND_VIEW
Definition reloptions.h:51
@ RELOPT_KIND_HEAP
Definition reloptions.h:42
@ RELOPT_KIND_TABLESPACE
Definition reloptions.h:49
@ RELOPT_KIND_GIN
Definition reloptions.h:46
@ RELOPT_KIND_HASH
Definition reloptions.h:45
@ RELOPT_KIND_PARTITIONED
Definition reloptions.h:53
@ RELOPT_KIND_BRIN
Definition reloptions.h:52
@ RELOPT_KIND_BTREE
Definition reloptions.h:44

◆ relopt_type

Enumerator
RELOPT_TYPE_BOOL 
RELOPT_TYPE_TERNARY 
RELOPT_TYPE_INT 
RELOPT_TYPE_REAL 
RELOPT_TYPE_ENUM 
RELOPT_TYPE_STRING 

Definition at line 28 of file reloptions.h.

29{
31 RELOPT_TYPE_TERNARY, /* on, off, unset */
relopt_type
Definition reloptions.h:29
@ 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

Function Documentation

◆ add_bool_reloption()

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

Definition at line 901 of file reloptions.c.

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

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

Referenced by create_reloptions_table().

◆ add_enum_reloption()

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

Definition at line 1119 of file reloptions.c.

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

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

Referenced by create_reloptions_table().

◆ add_int_reloption()

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

Definition at line 1002 of file reloptions.c.

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

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

Referenced by _PG_init(), and create_reloptions_table().

◆ add_local_bool_reloption()

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

Definition at line 917 of file reloptions.c.

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

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 
)
extern

Definition at line 1137 of file reloptions.c.

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

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

◆ add_local_int_reloption()

void add_local_int_reloption ( local_relopts relopts,
const char name,
const char desc,
int  default_val,
int  min_val,
int  max_val,
int  offset 
)
extern

◆ 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 
)
extern

Definition at line 1073 of file reloptions.c.

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

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

Referenced by brin_bloom_options().

◆ add_local_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 
)
extern

Definition at line 1219 of file reloptions.c.

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

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

◆ add_local_ternary_reloption()

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

Definition at line 966 of file reloptions.c.

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

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

◆ add_real_reloption()

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

Definition at line 1055 of file reloptions.c.

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

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

Referenced by create_reloptions_table().

◆ add_reloption_kind()

relopt_kind add_reloption_kind ( void  )
extern

Definition at line 732 of file reloptions.c.

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

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 
)
extern

Definition at line 1199 of file reloptions.c.

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

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

Referenced by create_reloptions_table().

◆ add_ternary_reloption()

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

Definition at line 948 of file reloptions.c.

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

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

Referenced by create_reloptions_table().

◆ AlterTableGetRelOptionsLockLevel()

LOCKMODE AlterTableGetRelOptionsLockLevel ( List defList)
extern

Definition at line 2242 of file reloptions.c.

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

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

Referenced by AlterTableGetLockLevel().

◆ attribute_reloptions()

bytea * attribute_reloptions ( Datum  reloptions,
bool  validate 
)
extern

Definition at line 2203 of file reloptions.c.

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

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

Referenced by ATExecSetOptions(), and get_attribute_options().

◆ build_local_reloptions()

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

Definition at line 2079 of file reloptions.c.

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

Definition at line 2042 of file reloptions.c.

2047{
2048 int numoptions;
2050 void *rdopts;
2051
2052 /* parse options specific to given relation option kind */
2053 options = parseRelOptions(reloptions, validate, kind, &numoptions);
2055
2056 /* if none set, we're done */
2057 if (numoptions == 0)
2058 {
2059 Assert(options == NULL);
2060 return NULL;
2061 }
2062
2063 /* allocate and fill the structure */
2064 rdopts = allocateReloptStruct(relopt_struct_size, options, numoptions);
2065 fillRelOptions(rdopts, relopt_struct_size, options, numoptions,
2067
2068 pfree(options);
2069
2070 return rdopts;
2071}
#define Assert(condition)
Definition c.h:945
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 
)
extern

Definition at line 1966 of file reloptions.c.

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

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

Referenced by heap_reloptions().

◆ extractRelOptions()

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

Definition at line 1489 of file reloptions.c.

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

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

Referenced by extract_autovac_opts(), and RelationParseRelOptions().

◆ heap_reloptions()

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

Definition at line 2153 of file reloptions.c.

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

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 
)
extern

Definition at line 2188 of file reloptions.c.

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

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

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

◆ init_local_reloptions()

void init_local_reloptions ( local_relopts relopts,
Size  relopt_struct_size 
)
extern

Definition at line 783 of file reloptions.c.

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

References fb(), and NIL.

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

◆ partitioned_table_reloptions()

bytea * partitioned_table_reloptions ( Datum  reloptions,
bool  validate 
)
extern

Definition at line 2118 of file reloptions.c.

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

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

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

◆ register_reloptions_validator()

void register_reloptions_validator ( local_relopts relopts,
relopts_validator  validator 
)
extern

Definition at line 796 of file reloptions.c.

797{
798 relopts->validators = lappend(relopts->validators, validator);
799}
List * lappend(List *list, void *datum)
Definition list.c:339

References fb(), and lappend().

Referenced by ltree_gist_options().

◆ tablespace_reloptions()

bytea * tablespace_reloptions ( Datum  reloptions,
bool  validate 
)
extern

Definition at line 2220 of file reloptions.c.

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

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 
)
extern

Definition at line 1257 of file reloptions.c.

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

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)
extern

Definition at line 1441 of file reloptions.c.

1442{
1443 List *result = NIL;
1444 ArrayType *array;
1446 int noptions;
1447 int i;
1448
1449 /* Nothing to do if no options */
1451 return result;
1452
1453 array = DatumGetArrayTypeP(options);
1454
1456
1457 for (i = 0; i < noptions; i++)
1458 {
1459 char *s;
1460 char *p;
1461 Node *val = NULL;
1462
1464 p = strchr(s, '=');
1465 if (p)
1466 {
1467 *p++ = '\0';
1468 val = (Node *) makeString(p);
1469 }
1470 result = lappend(result, makeDefElem(s, val, -1));
1471 }
1472
1473 return result;
1474}
#define TextDatumGetCString(d)
Definition builtins.h:99
long val
Definition informix.c:689
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 
)
extern

Definition at line 2132 of file reloptions.c.

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

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

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