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 "storage/lock.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 186 of file reloptions.h.

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

◆ HEAP_RELOPT_NAMESPACES

#define HEAP_RELOPT_NAMESPACES   { "toast", NULL }

Definition at line 62 of file reloptions.h.

Typedef Documentation

◆ fill_string_relopt

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

Definition at line 142 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 145 of file reloptions.h.

◆ validate_string_relopt

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

Definition at line 141 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 40 of file reloptions.h.

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

◆ relopt_type

Enumerator
RELOPT_TYPE_BOOL 
RELOPT_TYPE_TERNARY 
RELOPT_TYPE_INT 
RELOPT_TYPE_REAL 
RELOPT_TYPE_ENUM 
RELOPT_TYPE_STRING 

Definition at line 29 of file reloptions.h.

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

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

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

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

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

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

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

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_kind()

relopt_kind add_reloption_kind ( void  )
extern

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

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

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().

◆ AlterTableGetRelOptionsLockLevel()

LOCKMODE AlterTableGetRelOptionsLockLevel ( List defList)
extern

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 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:613
static bool need_initialization
Definition reloptions.c:591
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 
)
extern

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

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
relopt_gen * option
Definition reloptions.h:168
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 
)
extern

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}
#define Assert(condition)
Definition c.h:873
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 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 
)
extern

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().

◆ heap_reloptions()

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

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)

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 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_local_reloptions()

void init_local_reloptions ( local_relopts relopts,
Size  relopt_struct_size 
)
extern

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().

◆ partitioned_table_reloptions()

bytea * partitioned_table_reloptions ( Datum  reloptions,
bool  validate 
)
extern

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

Definition at line 795 of file reloptions.c.

796{
797 relopts->validators = lappend(relopts->validators, validator);
798}
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 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

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 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}
#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:711
size_t Size
Definition c.h:619
char * defGetString(DefElem *def)
Definition define.c:34
bool defGetBoolean(DefElem *def)
Definition define.c:93
static struct @172 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:352
char * defnamespace
Definition parsenodes.h:843
Node * arg
Definition parsenodes.h:845
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 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}
#define TextDatumGetCString(d)
Definition builtins.h:98
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 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}

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

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