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 (uint32 kinds, const char *name, const char *desc, bool default_val, LOCKMODE lockmode)
 
void add_ternary_reloption (uint32 kinds, const char *name, const char *desc, LOCKMODE lockmode)
 
void add_int_reloption (uint32 kinds, const char *name, const char *desc, int default_val, int min_val, int max_val, LOCKMODE lockmode)
 
void add_real_reloption (uint32 kinds, const char *name, const char *desc, double default_val, double min_val, double max_val, LOCKMODE lockmode)
 
void add_enum_reloption (uint32 kinds, const char *name, const char *desc, relopt_enum_elt_def *members, int default_val, const char *detailmsg, LOCKMODE lockmode)
 
void add_string_reloption (uint32 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 ( uint32  kinds,
const char name,
const char desc,
bool  default_val,
LOCKMODE  lockmode 
)
extern

Definition at line 910 of file reloptions.c.

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

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

Referenced by create_reloptions_table().

◆ add_enum_reloption()

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

Definition at line 1128 of file reloptions.c.

1131{
1133 members, default_val,
1134 detailmsg, lockmode);
1135
1137}
static relopt_enum * init_enum_reloption(uint32 kinds, const char *name, const char *desc, relopt_enum_elt_def *members, int default_val, const char *detailmsg, LOCKMODE lockmode)

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

Referenced by create_reloptions_table().

◆ add_int_reloption()

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

Definition at line 1011 of file reloptions.c.

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

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

Referenced by _PG_init(), and create_reloptions_table().

◆ add_local_bool_reloption()

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

Definition at line 926 of file reloptions.c.

928{
930 name, desc,
931 default_val, 0);
932
934}
static void add_local_reloption(local_relopts *relopts, relopt_gen *newoption, int offset)
Definition reloptions.c:815

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

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

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

◆ add_local_int_reloption()

void add_local_int_reloption ( local_relopts relopts,
const char name,
const char desc,
int  default_val,
int  min_val,
int  max_val,
int  offset 
)
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 1082 of file reloptions.c.

1085{
1087 name, desc,
1088 default_val, min_val,
1089 max_val, 0);
1090
1092}
static relopt_real * init_real_reloption(uint32 kinds, const char *name, const char *desc, double default_val, double min_val, double max_val, LOCKMODE lockmode)

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

Referenced by brin_bloom_options().

◆ add_local_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 1228 of file reloptions.c.

1232{
1234 name, desc,
1235 default_val,
1236 validator, filler,
1237 0);
1238
1240}
static relopt_string * init_string_reloption(uint32 kinds, const char *name, const char *desc, const char *default_val, validate_string_relopt validator, fill_string_relopt filler, LOCKMODE lockmode)

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

◆ add_local_ternary_reloption()

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

Definition at line 975 of file reloptions.c.

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

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

◆ add_real_reloption()

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

Definition at line 1064 of file reloptions.c.

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

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

Referenced by create_reloptions_table().

◆ add_reloption_kind()

relopt_kind add_reloption_kind ( void  )
extern

Definition at line 741 of file reloptions.c.

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

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

Referenced by _PG_init(), and create_reloptions_table().

◆ add_string_reloption()

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

Definition at line 1208 of file reloptions.c.

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

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

Referenced by create_reloptions_table().

◆ add_ternary_reloption()

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

Definition at line 957 of file reloptions.c.

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

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

Referenced by create_reloptions_table().

◆ AlterTableGetRelOptionsLockLevel()

LOCKMODE AlterTableGetRelOptionsLockLevel ( List defList)
extern

Definition at line 2253 of file reloptions.c.

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

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

Referenced by AlterTableGetLockLevel().

◆ attribute_reloptions()

bytea * attribute_reloptions ( Datum  reloptions,
bool  validate 
)
extern

Definition at line 2214 of file reloptions.c.

2215{
2216 static const relopt_parse_elt tab[] = {
2217 {"n_distinct", RELOPT_TYPE_REAL, offsetof(AttributeOpts, n_distinct)},
2218 {"n_distinct_inherited", RELOPT_TYPE_REAL, offsetof(AttributeOpts, n_distinct_inherited)}
2219 };
2220
2221 return (bytea *) build_reloptions(reloptions, validate,
2223 sizeof(AttributeOpts),
2224 tab, lengthof(tab));
2225}
static bool validate(Port *port, const char *auth, const char **logdetail)
Definition auth-oauth.c:672
#define lengthof(array)
Definition c.h:873
void * build_reloptions(Datum reloptions, bool validate, relopt_kind kind, Size relopt_struct_size, const relopt_parse_elt *relopt_elems, int num_relopt_elems)
Definition c.h:776

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

Referenced by ATExecSetOptions(), and get_attribute_options().

◆ build_local_reloptions()

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

Definition at line 2090 of file reloptions.c.

2091{
2092 int noptions = list_length(relopts->options);
2094 relopt_value *vals;
2095 void *opts;
2096 int i = 0;
2097 ListCell *lc;
2098
2099 foreach(lc, relopts->options)
2100 {
2101 local_relopt *opt = lfirst(lc);
2102
2103 elems[i].optname = opt->option->name;
2104 elems[i].opttype = opt->option->type;
2105 elems[i].offset = opt->offset;
2106
2107 i++;
2108 }
2109
2111 opts = allocateReloptStruct(relopts->relopt_struct_size, vals, noptions);
2112 fillRelOptions(opts, relopts->relopt_struct_size, vals, noptions, validate,
2113 elems, noptions);
2114
2115 if (validate)
2116 foreach(lc, relopts->validators)
2117 ((relopts_validator) lfirst(lc)) (opts, vals, noptions);
2118
2119 if (elems)
2120 pfree(elems);
2121
2122 return opts;
2123}
#define palloc_array(type, count)
Definition fe_memutils.h:76
void pfree(void *pointer)
Definition mcxt.c:1616
static AmcheckOptions opts
Definition pg_amcheck.c:112
static int list_length(const List *l)
Definition pg_list.h:152
static size_t noptions
static relopt_value * parseLocalRelOptions(local_relopts *relopts, Datum options, bool validate)
static void fillRelOptions(void *rdopts, Size basesize, relopt_value *options, int numoptions, bool validate, const relopt_parse_elt *elems, int numelems)
static void * allocateReloptStruct(Size base, relopt_value *options, int numoptions)
void(* relopts_validator)(void *parsed_options, relopt_value *vals, int nvals)
Definition reloptions.h:144
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 2053 of file reloptions.c.

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

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

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

Referenced by heap_reloptions().

◆ extractRelOptions()

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

Definition at line 1498 of file reloptions.c.

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

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

Referenced by extract_autovac_opts(), and RelationParseRelOptions().

◆ heap_reloptions()

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

Definition at line 2164 of file reloptions.c.

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

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

2200{
2201 Assert(amoptions != NULL);
2202
2203 /* Assume function is strict */
2204 if (DatumGetPointer(reloptions) == NULL)
2205 return NULL;
2206
2207 return amoptions(reloptions, validate);
2208}
static Pointer DatumGetPointer(Datum X)
Definition postgres.h:332

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

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

◆ init_local_reloptions()

void init_local_reloptions ( local_relopts relopts,
Size  relopt_struct_size 
)
extern

Definition at line 792 of file reloptions.c.

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

References fb(), and NIL.

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

◆ partitioned_table_reloptions()

bytea * partitioned_table_reloptions ( Datum  reloptions,
bool  validate 
)
extern

Definition at line 2129 of file reloptions.c.

2130{
2131 if (validate && reloptions)
2132 ereport(ERROR,
2134 errmsg("cannot specify storage parameters for a partitioned table"),
2135 errhint("Specify storage parameters for its leaf partitions instead."));
2136 return NULL;
2137}
int errhint(const char *fmt,...) pg_attribute_printf(1

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

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

◆ register_reloptions_validator()

void register_reloptions_validator ( local_relopts relopts,
relopts_validator  validator 
)
extern

Definition at line 805 of file reloptions.c.

806{
807 relopts->validators = lappend(relopts->validators, validator);
808}
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 2231 of file reloptions.c.

2232{
2233 static const relopt_parse_elt tab[] = {
2236 {"effective_io_concurrency", RELOPT_TYPE_INT, offsetof(TableSpaceOpts, effective_io_concurrency)},
2237 {"maintenance_io_concurrency", RELOPT_TYPE_INT, offsetof(TableSpaceOpts, maintenance_io_concurrency)}
2238 };
2239
2240 return (bytea *) build_reloptions(reloptions, validate,
2242 sizeof(TableSpaceOpts),
2243 tab, lengthof(tab));
2244}
int maintenance_io_concurrency
Definition bufmgr.c:207
int effective_io_concurrency
Definition bufmgr.c:200
double random_page_cost
Definition costsize.c:132
double seq_page_cost
Definition costsize.c:131

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

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

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

◆ untransformRelOptions()

List * untransformRelOptions ( Datum  options)
extern

Definition at line 1450 of file reloptions.c.

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

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

◆ view_reloptions()

bytea * view_reloptions ( Datum  reloptions,
bool  validate 
)
extern

Definition at line 2143 of file reloptions.c.

2144{
2145 static const relopt_parse_elt tab[] = {
2146 {"security_barrier", RELOPT_TYPE_BOOL,
2147 offsetof(ViewOptions, security_barrier)},
2148 {"security_invoker", RELOPT_TYPE_BOOL,
2149 offsetof(ViewOptions, security_invoker)},
2150 {"check_option", RELOPT_TYPE_ENUM,
2151 offsetof(ViewOptions, check_option)}
2152 };
2153
2154 return (bytea *) build_reloptions(reloptions, validate,
2156 sizeof(ViewOptions),
2157 tab, lengthof(tab));
2158}

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

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