Thanks to visit codestin.com
Credit goes to doxygen.postgresql.org

PostgreSQL Source Code git master
reloptions.c File Reference
#include "postgres.h"
#include <float.h>
#include "access/gist_private.h"
#include "access/hash.h"
#include "access/heaptoast.h"
#include "access/htup_details.h"
#include "access/nbtree.h"
#include "access/reloptions.h"
#include "access/spgist_private.h"
#include "catalog/pg_type.h"
#include "commands/defrem.h"
#include "commands/tablespace.h"
#include "nodes/makefuncs.h"
#include "utils/array.h"
#include "utils/attoptcache.h"
#include "utils/builtins.h"
#include "utils/guc.h"
#include "utils/memutils.h"
#include "utils/rel.h"
Include dependency graph for reloptions.c:

Go to the source code of this file.

Macros

#define GET_STRING_RELOPTION_LEN(option)
 

Functions

static void initialize_reloptions (void)
 
static void parse_one_reloption (relopt_value *option, char *text_str, int text_len, bool validate)
 
relopt_kind add_reloption_kind (void)
 
static void add_reloption (relopt_gen *newoption)
 
void init_local_reloptions (local_relopts *relopts, Size relopt_struct_size)
 
void register_reloptions_validator (local_relopts *relopts, relopts_validator validator)
 
static void add_local_reloption (local_relopts *relopts, relopt_gen *newoption, int offset)
 
static relopt_genallocate_reloption (bits32 kinds, int type, const char *name, const char *desc, LOCKMODE lockmode)
 
static relopt_boolinit_bool_reloption (bits32 kinds, const char *name, const char *desc, bool default_val, LOCKMODE lockmode)
 
void add_bool_reloption (bits32 kinds, const char *name, const char *desc, bool default_val, LOCKMODE lockmode)
 
void add_local_bool_reloption (local_relopts *relopts, const char *name, const char *desc, bool default_val, int offset)
 
static relopt_intinit_int_reloption (bits32 kinds, const char *name, const char *desc, int default_val, int min_val, int max_val, LOCKMODE lockmode)
 
void add_int_reloption (bits32 kinds, const char *name, const char *desc, int default_val, int min_val, int max_val, LOCKMODE lockmode)
 
void add_local_int_reloption (local_relopts *relopts, const char *name, const char *desc, int default_val, int min_val, int max_val, int offset)
 
static relopt_realinit_real_reloption (bits32 kinds, const char *name, const char *desc, double default_val, double min_val, double max_val, LOCKMODE lockmode)
 
void add_real_reloption (bits32 kinds, const char *name, const char *desc, double default_val, double min_val, double max_val, LOCKMODE lockmode)
 
void add_local_real_reloption (local_relopts *relopts, const char *name, const char *desc, double default_val, double min_val, double max_val, int offset)
 
static relopt_enuminit_enum_reloption (bits32 kinds, const char *name, const char *desc, relopt_enum_elt_def *members, int default_val, const char *detailmsg, LOCKMODE lockmode)
 
void add_enum_reloption (bits32 kinds, const char *name, const char *desc, relopt_enum_elt_def *members, int default_val, const char *detailmsg, LOCKMODE lockmode)
 
void add_local_enum_reloption (local_relopts *relopts, const char *name, const char *desc, relopt_enum_elt_def *members, int default_val, const char *detailmsg, int offset)
 
static relopt_stringinit_string_reloption (bits32 kinds, const char *name, const char *desc, const char *default_val, validate_string_relopt validator, fill_string_relopt filler, LOCKMODE lockmode)
 
void add_string_reloption (bits32 kinds, const char *name, const char *desc, const char *default_val, validate_string_relopt validator, LOCKMODE lockmode)
 
void add_local_string_reloption (local_relopts *relopts, const char *name, const char *desc, const char *default_val, validate_string_relopt validator, fill_string_relopt filler, int offset)
 
Datum transformRelOptions (Datum oldOptions, List *defList, const char *nameSpace, const char *const validnsps[], bool acceptOidsOff, bool isReset)
 
ListuntransformRelOptions (Datum options)
 
byteaextractRelOptions (HeapTuple tuple, TupleDesc tupdesc, amoptions_function amoptions)
 
static void parseRelOptionsInternal (Datum options, bool validate, relopt_value *reloptions, int numoptions)
 
static relopt_valueparseRelOptions (Datum options, bool validate, relopt_kind kind, int *numrelopts)
 
static relopt_valueparseLocalRelOptions (local_relopts *relopts, Datum options, bool validate)
 
static void * allocateReloptStruct (Size base, relopt_value *options, int numoptions)
 
static void fillRelOptions (void *rdopts, Size basesize, relopt_value *options, int numoptions, bool validate, const relopt_parse_elt *elems, int numelems)
 
byteadefault_reloptions (Datum reloptions, bool validate, relopt_kind kind)
 
void * build_reloptions (Datum reloptions, bool validate, relopt_kind kind, Size relopt_struct_size, const relopt_parse_elt *relopt_elems, int num_relopt_elems)
 
void * build_local_reloptions (local_relopts *relopts, Datum options, bool validate)
 
byteapartitioned_table_reloptions (Datum reloptions, bool validate)
 
byteaview_reloptions (Datum reloptions, bool validate)
 
byteaheap_reloptions (char relkind, Datum reloptions, bool validate)
 
byteaindex_reloptions (amoptions_function amoptions, Datum reloptions, bool validate)
 
byteaattribute_reloptions (Datum reloptions, bool validate)
 
byteatablespace_reloptions (Datum reloptions, bool validate)
 
LOCKMODE AlterTableGetRelOptionsLockLevel (List *defList)
 

Variables

static relopt_bool boolRelOpts []
 
static relopt_int intRelOpts []
 
static relopt_real realRelOpts []
 
static relopt_enum_elt_def StdRdOptIndexCleanupValues []
 
static relopt_enum_elt_def gistBufferingOptValues []
 
static relopt_enum_elt_def viewCheckOptValues []
 
static relopt_enum enumRelOpts []
 
static relopt_string stringRelOpts []
 
static relopt_gen ** relOpts = NULL
 
static bits32 last_assigned_kind = RELOPT_KIND_LAST_DEFAULT
 
static int num_custom_options = 0
 
static relopt_gen ** custom_options = NULL
 
static bool need_initialization = true
 

Macro Definition Documentation

◆ GET_STRING_RELOPTION_LEN

#define GET_STRING_RELOPTION_LEN (   option)
Value:
((option).isset ? strlen((option).values.string_val) : \
((relopt_string *) (option).gen)->default_len)

Definition at line 580 of file reloptions.c.

Function Documentation

◆ add_bool_reloption()

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

Definition at line 860 of file reloptions.c.

862{
863 relopt_bool *newoption = init_bool_reloption(kinds, name, desc,
864 default_val, lockmode);
865
866 add_reloption((relopt_gen *) newoption);
867}
static void add_reloption(relopt_gen *newoption)
Definition: reloptions.c:711
static relopt_bool * init_bool_reloption(bits32 kinds, const char *name, const char *desc, bool default_val, LOCKMODE lockmode)
Definition: reloptions.c:843
const char * name

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

Referenced by create_reloptions_table().

◆ add_enum_reloption()

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

Definition at line 1029 of file reloptions.c.

1032{
1033 relopt_enum *newoption = init_enum_reloption(kinds, name, desc,
1034 members, default_val,
1035 detailmsg, lockmode);
1036
1037 add_reloption((relopt_gen *) newoption);
1038}
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)
Definition: reloptions.c:1000

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

Referenced by create_reloptions_table().

◆ add_int_reloption()

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

Definition at line 912 of file reloptions.c.

914{
915 relopt_int *newoption = init_int_reloption(kinds, name, desc,
916 default_val, min_val,
917 max_val, lockmode);
918
919 add_reloption((relopt_gen *) newoption);
920}
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:892

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

Referenced by _PG_init(), and create_reloptions_table().

◆ add_local_bool_reloption()

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

Definition at line 876 of file reloptions.c.

878{
880 name, desc,
881 default_val, 0);
882
883 add_local_reloption(relopts, (relopt_gen *) newoption, offset);
884}
static void add_local_reloption(local_relopts *relopts, relopt_gen *newoption, int offset)
Definition: reloptions.c:768
@ RELOPT_KIND_LOCAL
Definition: reloptions.h:41

References add_local_reloption(), init_bool_reloption(), name, and RELOPT_KIND_LOCAL.

◆ add_local_enum_reloption()

void add_local_enum_reloption ( local_relopts relopts,
const char *  name,
const char *  desc,
relopt_enum_elt_def members,
int  default_val,
const char *  detailmsg,
int  offset 
)

Definition at line 1047 of file reloptions.c.

1050{
1052 name, desc,
1053 members, default_val,
1054 detailmsg, 0);
1055
1056 add_local_reloption(relopts, (relopt_gen *) newoption, offset);
1057}

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

◆ add_local_int_reloption()

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

◆ add_local_real_reloption()

void add_local_real_reloption ( local_relopts relopts,
const char *  name,
const char *  desc,
double  default_val,
double  min_val,
double  max_val,
int  offset 
)

Definition at line 983 of file reloptions.c.

986{
988 name, desc,
989 default_val, min_val,
990 max_val, 0);
991
992 add_local_reloption(relopts, (relopt_gen *) newoption, offset);
993}
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)
Definition: reloptions.c:945

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

Referenced by brin_bloom_options().

◆ add_local_reloption()

static void add_local_reloption ( local_relopts relopts,
relopt_gen newoption,
int  offset 
)
static

Definition at line 768 of file reloptions.c.

769{
770 local_relopt *opt = palloc(sizeof(*opt));
771
772 Assert(offset < relopts->relopt_struct_size);
773
774 opt->option = newoption;
775 opt->offset = offset;
776
777 relopts->options = lappend(relopts->options, opt);
778}
Assert(PointerIsAligned(start, uint64))
List * lappend(List *list, void *datum)
Definition: list.c:339
void * palloc(Size size)
Definition: mcxt.c:1365
relopt_gen * option
Definition: reloptions.h:173
List * options
Definition: reloptions.h:180

References Assert(), lappend(), local_relopt::offset, local_relopt::option, local_relopts::options, and palloc().

Referenced by add_local_bool_reloption(), add_local_enum_reloption(), add_local_int_reloption(), add_local_real_reloption(), and add_local_string_reloption().

◆ add_local_string_reloption()

void add_local_string_reloption ( local_relopts relopts,
const char *  name,
const char *  desc,
const char *  default_val,
validate_string_relopt  validator,
fill_string_relopt  filler,
int  offset 
)

Definition at line 1129 of file reloptions.c.

1133{
1135 name, desc,
1136 default_val,
1137 validator, filler,
1138 0);
1139
1140 add_local_reloption(relopts, (relopt_gen *) newoption, offset);
1141}
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)
Definition: reloptions.c:1064

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

◆ add_real_reloption()

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

Definition at line 965 of file reloptions.c.

968{
969 relopt_real *newoption = init_real_reloption(kinds, name, desc,
970 default_val, min_val,
971 max_val, lockmode);
972
973 add_reloption((relopt_gen *) newoption);
974}

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

Referenced by create_reloptions_table().

◆ add_reloption()

static void add_reloption ( relopt_gen newoption)
static

Definition at line 711 of file reloptions.c.

712{
713 static int max_custom_options = 0;
714
715 if (num_custom_options >= max_custom_options)
716 {
717 MemoryContext oldcxt;
718
720
721 if (max_custom_options == 0)
722 {
723 max_custom_options = 8;
724 custom_options = palloc(max_custom_options * sizeof(relopt_gen *));
725 }
726 else
727 {
728 max_custom_options *= 2;
730 max_custom_options * sizeof(relopt_gen *));
731 }
732 MemoryContextSwitchTo(oldcxt);
733 }
734 custom_options[num_custom_options++] = newoption;
735
736 need_initialization = true;
737}
void * repalloc(void *pointer, Size size)
Definition: mcxt.c:1610
MemoryContext TopMemoryContext
Definition: mcxt.c:166
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:124
static int num_custom_options
Definition: reloptions.c:567
static bool need_initialization
Definition: reloptions.c:569
static relopt_gen ** custom_options
Definition: reloptions.c:568

References custom_options, MemoryContextSwitchTo(), need_initialization, num_custom_options, palloc(), repalloc(), and TopMemoryContext.

Referenced by add_bool_reloption(), add_enum_reloption(), add_int_reloption(), add_real_reloption(), and add_string_reloption().

◆ add_reloption_kind()

relopt_kind add_reloption_kind ( void  )

Definition at line 694 of file reloptions.c.

695{
696 /* don't hand out the last bit so that the enum's behavior is portable */
699 (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
700 errmsg("user-defined relation parameter types limit exceeded")));
701 last_assigned_kind <<= 1;
703}
int errcode(int sqlerrcode)
Definition: elog.c:854
int errmsg(const char *fmt,...)
Definition: elog.c:1071
#define ERROR
Definition: elog.h:39
#define ereport(elevel,...)
Definition: elog.h:150
static bits32 last_assigned_kind
Definition: reloptions.c:565
relopt_kind
Definition: reloptions.h:40
@ RELOPT_KIND_MAX
Definition: reloptions.h:57

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

Referenced by _PG_init(), and create_reloptions_table().

◆ add_string_reloption()

void add_string_reloption ( bits32  kinds,
const char *  name,
const char *  desc,
const char *  default_val,
validate_string_relopt  validator,
LOCKMODE  lockmode 
)

Definition at line 1109 of file reloptions.c.

1112{
1113 relopt_string *newoption = init_string_reloption(kinds, name, desc,
1114 default_val,
1115 validator, NULL,
1116 lockmode);
1117
1118 add_reloption((relopt_gen *) newoption);
1119}

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

Referenced by create_reloptions_table().

◆ allocate_reloption()

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

Definition at line 786 of file reloptions.c.

788{
789 MemoryContext oldcxt;
790 size_t size;
791 relopt_gen *newoption;
792
793 if (kinds != RELOPT_KIND_LOCAL)
795 else
796 oldcxt = NULL;
797
798 switch (type)
799 {
800 case RELOPT_TYPE_BOOL:
801 size = sizeof(relopt_bool);
802 break;
803 case RELOPT_TYPE_INT:
804 size = sizeof(relopt_int);
805 break;
806 case RELOPT_TYPE_REAL:
807 size = sizeof(relopt_real);
808 break;
809 case RELOPT_TYPE_ENUM:
810 size = sizeof(relopt_enum);
811 break;
813 size = sizeof(relopt_string);
814 break;
815 default:
816 elog(ERROR, "unsupported reloption type %d", type);
817 return NULL; /* keep compiler quiet */
818 }
819
820 newoption = palloc(size);
821
822 newoption->name = pstrdup(name);
823 if (desc)
824 newoption->desc = pstrdup(desc);
825 else
826 newoption->desc = NULL;
827 newoption->kinds = kinds;
828 newoption->namelen = strlen(name);
829 newoption->type = type;
830 newoption->lockmode = lockmode;
831
832 if (oldcxt != NULL)
833 MemoryContextSwitchTo(oldcxt);
834
835 return newoption;
836}
#define elog(elevel,...)
Definition: elog.h:226
char * pstrdup(const char *in)
Definition: mcxt.c:1759
struct relopt_real relopt_real
struct relopt_bool relopt_bool
struct relopt_string relopt_string
struct relopt_enum relopt_enum
struct relopt_int relopt_int
@ RELOPT_TYPE_ENUM
Definition: reloptions.h:34
@ RELOPT_TYPE_INT
Definition: reloptions.h:32
@ RELOPT_TYPE_BOOL
Definition: reloptions.h:31
@ RELOPT_TYPE_REAL
Definition: reloptions.h:33
@ RELOPT_TYPE_STRING
Definition: reloptions.h:35
const char * desc
Definition: reloptions.h:68
bits32 kinds
Definition: reloptions.h:69
const char * name
Definition: reloptions.h:66
LOCKMODE lockmode
Definition: reloptions.h:70
relopt_type type
Definition: reloptions.h:72
int namelen
Definition: reloptions.h:71
const char * type

References relopt_gen::desc, elog, ERROR, relopt_gen::kinds, relopt_gen::lockmode, MemoryContextSwitchTo(), name, relopt_gen::name, relopt_gen::namelen, palloc(), pstrdup(), RELOPT_KIND_LOCAL, RELOPT_TYPE_BOOL, RELOPT_TYPE_ENUM, RELOPT_TYPE_INT, RELOPT_TYPE_REAL, RELOPT_TYPE_STRING, TopMemoryContext, type, and relopt_gen::type.

Referenced by init_bool_reloption(), init_enum_reloption(), init_int_reloption(), init_real_reloption(), and init_string_reloption().

◆ allocateReloptStruct()

static void * allocateReloptStruct ( Size  base,
relopt_value options,
int  numoptions 
)
static

Definition at line 1722 of file reloptions.c.

1723{
1724 Size size = base;
1725 int i;
1726
1727 for (i = 0; i < numoptions; i++)
1728 {
1729 relopt_value *optval = &options[i];
1730
1731 if (optval->gen->type == RELOPT_TYPE_STRING)
1732 {
1733 relopt_string *optstr = (relopt_string *) optval->gen;
1734
1735 if (optstr->fill_cb)
1736 {
1737 const char *val = optval->isset ? optval->values.string_val :
1738 optstr->default_isnull ? NULL : optstr->default_val;
1739
1740 size += optstr->fill_cb(val, NULL);
1741 }
1742 else
1743 size += GET_STRING_RELOPTION_LEN(*optval) + 1;
1744 }
1745 }
1746
1747 return palloc0(size);
1748}
size_t Size
Definition: c.h:611
long val
Definition: informix.c:689
int i
Definition: isn.c:77
if(TABLE==NULL||TABLE_index==NULL)
Definition: isn.c:81
void * palloc0(Size size)
Definition: mcxt.c:1395
#define GET_STRING_RELOPTION_LEN(option)
Definition: reloptions.c:580
char * default_val
Definition: reloptions.h:146
fill_string_relopt fill_cb
Definition: reloptions.h:145
bool default_isnull
Definition: reloptions.h:143
union relopt_value::@51 values
relopt_gen * gen
Definition: reloptions.h:78
char * string_val
Definition: reloptions.h:86

References relopt_string::default_isnull, relopt_string::default_val, relopt_string::fill_cb, relopt_value::gen, GET_STRING_RELOPTION_LEN, i, if(), relopt_value::isset, palloc0(), RELOPT_TYPE_STRING, relopt_value::string_val, relopt_gen::type, val, and relopt_value::values.

Referenced by build_local_reloptions(), and build_reloptions().

◆ AlterTableGetRelOptionsLockLevel()

LOCKMODE AlterTableGetRelOptionsLockLevel ( List defList)

Definition at line 2144 of file reloptions.c.

2145{
2146 LOCKMODE lockmode = NoLock;
2147 ListCell *cell;
2148
2149 if (defList == NIL)
2150 return AccessExclusiveLock;
2151
2154
2155 foreach(cell, defList)
2156 {
2157 DefElem *def = (DefElem *) lfirst(cell);
2158 int i;
2159
2160 for (i = 0; relOpts[i]; i++)
2161 {
2162 if (strncmp(relOpts[i]->name,
2163 def->defname,
2164 relOpts[i]->namelen + 1) == 0)
2165 {
2166 if (lockmode < relOpts[i]->lockmode)
2167 lockmode = relOpts[i]->lockmode;
2168 }
2169 }
2170 }
2171
2172 return lockmode;
2173}
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:591
static relopt_gen ** relOpts
Definition: reloptions.c:564
char * defname
Definition: parsenodes.h:842

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

Referenced by AlterTableGetLockLevel().

◆ attribute_reloptions()

bytea * attribute_reloptions ( Datum  reloptions,
bool  validate 
)

Definition at line 2105 of file reloptions.c.

2106{
2107 static const relopt_parse_elt tab[] = {
2108 {"n_distinct", RELOPT_TYPE_REAL, offsetof(AttributeOpts, n_distinct)},
2109 {"n_distinct_inherited", RELOPT_TYPE_REAL, offsetof(AttributeOpts, n_distinct_inherited)}
2110 };
2111
2112 return (bytea *) build_reloptions(reloptions, validate,
2114 sizeof(AttributeOpts),
2115 tab, lengthof(tab));
2116}
static bool validate(Port *port, const char *auth)
Definition: auth-oauth.c:638
#define lengthof(array)
Definition: c.h:788
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: reloptions.c:1943
@ RELOPT_KIND_ATTRIBUTE
Definition: reloptions.h:48
Definition: c.h:693

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

Referenced by ATExecSetOptions(), and get_attribute_options().

◆ build_local_reloptions()

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

Definition at line 1980 of file reloptions.c.

1981{
1982 int noptions = list_length(relopts->options);
1983 relopt_parse_elt *elems = palloc(sizeof(*elems) * noptions);
1984 relopt_value *vals;
1985 void *opts;
1986 int i = 0;
1987 ListCell *lc;
1988
1989 foreach(lc, relopts->options)
1990 {
1991 local_relopt *opt = lfirst(lc);
1992
1993 elems[i].optname = opt->option->name;
1994 elems[i].opttype = opt->option->type;
1995 elems[i].offset = opt->offset;
1996 elems[i].isset_offset = 0; /* not supported for local relopts yet */
1997
1998 i++;
1999 }
2000
2001 vals = parseLocalRelOptions(relopts, options, validate);
2004 elems, noptions);
2005
2006 if (validate)
2007 foreach(lc, relopts->validators)
2008 ((relopts_validator) lfirst(lc)) (opts, vals, noptions);
2009
2010 if (elems)
2011 pfree(elems);
2012
2013 return opts;
2014}
void pfree(void *pointer)
Definition: mcxt.c:1594
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)
Definition: reloptions.c:1561
static void fillRelOptions(void *rdopts, Size basesize, relopt_value *options, int numoptions, bool validate, const relopt_parse_elt *elems, int numelems)
Definition: reloptions.c:1762
static void * allocateReloptStruct(Size base, relopt_value *options, int numoptions)
Definition: reloptions.c:1722
void(* relopts_validator)(void *parsed_options, relopt_value *vals, int nvals)
Definition: reloptions.h:137
List * validators
Definition: reloptions.h:181
Size relopt_struct_size
Definition: reloptions.h:182
const char * optname
Definition: reloptions.h:152
relopt_type opttype
Definition: reloptions.h:153

References allocateReloptStruct(), fillRelOptions(), i, relopt_parse_elt::isset_offset, lfirst, list_length(), relopt_gen::name, noptions, relopt_parse_elt::offset, local_relopt::offset, local_relopt::option, local_relopts::options, relopt_parse_elt::optname, opts, relopt_parse_elt::opttype, palloc(), parseLocalRelOptions(), pfree(), local_relopts::relopt_struct_size, relopt_gen::type, validate(), and local_relopts::validators.

Referenced by index_opclass_options().

◆ build_reloptions()

void * build_reloptions ( Datum  reloptions,
bool  validate,
relopt_kind  kind,
Size  relopt_struct_size,
const relopt_parse_elt relopt_elems,
int  num_relopt_elems 
)

Definition at line 1943 of file reloptions.c.

1948{
1949 int numoptions;
1951 void *rdopts;
1952
1953 /* parse options specific to given relation option kind */
1954 options = parseRelOptions(reloptions, validate, kind, &numoptions);
1955 Assert(numoptions <= num_relopt_elems);
1956
1957 /* if none set, we're done */
1958 if (numoptions == 0)
1959 {
1960 Assert(options == NULL);
1961 return NULL;
1962 }
1963
1964 /* allocate and fill the structure */
1965 rdopts = allocateReloptStruct(relopt_struct_size, options, numoptions);
1966 fillRelOptions(rdopts, relopt_struct_size, options, numoptions,
1967 validate, relopt_elems, num_relopt_elems);
1968
1969 pfree(options);
1970
1971 return rdopts;
1972}
static char ** options
static relopt_value * parseRelOptions(Datum options, bool validate, relopt_kind kind, int *numrelopts)
Definition: reloptions.c:1519

References allocateReloptStruct(), Assert(), fillRelOptions(), options, parseRelOptions(), pfree(), and validate().

Referenced by attribute_reloptions(), bloptions(), brinoptions(), btoptions(), default_reloptions(), dioptions(), ginoptions(), gistoptions(), hashoptions(), spgoptions(), tablespace_reloptions(), and view_reloptions().

◆ default_reloptions()

bytea * default_reloptions ( Datum  reloptions,
bool  validate,
relopt_kind  kind 
)

Definition at line 1869 of file reloptions.c.

1870{
1871 static const relopt_parse_elt tab[] = {
1872 {"fillfactor", RELOPT_TYPE_INT, offsetof(StdRdOptions, fillfactor)},
1873 {"autovacuum_enabled", RELOPT_TYPE_BOOL,
1874 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, enabled)},
1875 {"autovacuum_vacuum_threshold", RELOPT_TYPE_INT,
1876 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, vacuum_threshold)},
1877 {"autovacuum_vacuum_max_threshold", RELOPT_TYPE_INT,
1878 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, vacuum_max_threshold)},
1879 {"autovacuum_vacuum_insert_threshold", RELOPT_TYPE_INT,
1880 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, vacuum_ins_threshold)},
1881 {"autovacuum_analyze_threshold", RELOPT_TYPE_INT,
1882 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, analyze_threshold)},
1883 {"autovacuum_vacuum_cost_limit", RELOPT_TYPE_INT,
1884 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, vacuum_cost_limit)},
1885 {"autovacuum_freeze_min_age", RELOPT_TYPE_INT,
1886 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, freeze_min_age)},
1887 {"autovacuum_freeze_max_age", RELOPT_TYPE_INT,
1888 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, freeze_max_age)},
1889 {"autovacuum_freeze_table_age", RELOPT_TYPE_INT,
1890 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, freeze_table_age)},
1891 {"autovacuum_multixact_freeze_min_age", RELOPT_TYPE_INT,
1892 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, multixact_freeze_min_age)},
1893 {"autovacuum_multixact_freeze_max_age", RELOPT_TYPE_INT,
1894 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, multixact_freeze_max_age)},
1895 {"autovacuum_multixact_freeze_table_age", RELOPT_TYPE_INT,
1896 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, multixact_freeze_table_age)},
1897 {"log_autovacuum_min_duration", RELOPT_TYPE_INT,
1898 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, log_min_duration)},
1899 {"toast_tuple_target", RELOPT_TYPE_INT,
1900 offsetof(StdRdOptions, toast_tuple_target)},
1901 {"autovacuum_vacuum_cost_delay", RELOPT_TYPE_REAL,
1902 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, vacuum_cost_delay)},
1903 {"autovacuum_vacuum_scale_factor", RELOPT_TYPE_REAL,
1904 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, vacuum_scale_factor)},
1905 {"autovacuum_vacuum_insert_scale_factor", RELOPT_TYPE_REAL,
1906 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, vacuum_ins_scale_factor)},
1907 {"autovacuum_analyze_scale_factor", RELOPT_TYPE_REAL,
1908 offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, analyze_scale_factor)},
1909 {"user_catalog_table", RELOPT_TYPE_BOOL,
1910 offsetof(StdRdOptions, user_catalog_table)},
1911 {"parallel_workers", RELOPT_TYPE_INT,
1912 offsetof(StdRdOptions, parallel_workers)},
1913 {"vacuum_index_cleanup", RELOPT_TYPE_ENUM,
1914 offsetof(StdRdOptions, vacuum_index_cleanup)},
1915 {"vacuum_truncate", RELOPT_TYPE_BOOL,
1916 offsetof(StdRdOptions, vacuum_truncate), offsetof(StdRdOptions, vacuum_truncate_set)},
1917 {"vacuum_max_eager_freeze_failure_rate", RELOPT_TYPE_REAL,
1919 };
1920
1921 return (bytea *) build_reloptions(reloptions, validate, kind,
1922 sizeof(StdRdOptions),
1923 tab, lengthof(tab));
1924}
static int fillfactor
Definition: pgbench.c:188
double vacuum_max_eager_freeze_failure_rate
Definition: vacuum.c:80
double vacuum_cost_delay
Definition: vacuum.c:90
int vacuum_cost_limit
Definition: vacuum.c:91
bool vacuum_truncate
Definition: vacuum.c:82

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

Referenced by heap_reloptions().

◆ extractRelOptions()

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

Definition at line 1399 of file reloptions.c.

1401{
1402 bytea *options;
1403 bool isnull;
1404 Datum datum;
1405 Form_pg_class classForm;
1406
1407 datum = fastgetattr(tuple,
1408 Anum_pg_class_reloptions,
1409 tupdesc,
1410 &isnull);
1411 if (isnull)
1412 return NULL;
1413
1414 classForm = (Form_pg_class) GETSTRUCT(tuple);
1415
1416 /* Parse into appropriate format; don't error out here */
1417 switch (classForm->relkind)
1418 {
1419 case RELKIND_RELATION:
1420 case RELKIND_TOASTVALUE:
1421 case RELKIND_MATVIEW:
1422 options = heap_reloptions(classForm->relkind, datum, false);
1423 break;
1424 case RELKIND_PARTITIONED_TABLE:
1425 options = partitioned_table_reloptions(datum, false);
1426 break;
1427 case RELKIND_VIEW:
1428 options = view_reloptions(datum, false);
1429 break;
1430 case RELKIND_INDEX:
1431 case RELKIND_PARTITIONED_INDEX:
1432 options = index_reloptions(amoptions, datum, false);
1433 break;
1434 case RELKIND_FOREIGN_TABLE:
1435 options = NULL;
1436 break;
1437 default:
1438 Assert(false); /* can't get here */
1439 options = NULL; /* keep compiler quiet */
1440 break;
1441 }
1442
1443 return options;
1444}
static void * GETSTRUCT(const HeapTupleData *tuple)
Definition: htup_details.h:728
static Datum fastgetattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
Definition: htup_details.h:861
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)
Definition: reloptions.c:2034
bytea * index_reloptions(amoptions_function amoptions, Datum reloptions, bool validate)
Definition: reloptions.c:2090
bytea * partitioned_table_reloptions(Datum reloptions, bool validate)
Definition: reloptions.c:2020
bytea * heap_reloptions(char relkind, Datum reloptions, bool validate)
Definition: reloptions.c:2055

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

Referenced by extract_autovac_opts(), and RelationParseRelOptions().

◆ fillRelOptions()

static void fillRelOptions ( void *  rdopts,
Size  basesize,
relopt_value options,
int  numoptions,
bool  validate,
const relopt_parse_elt elems,
int  numelems 
)
static

Definition at line 1762 of file reloptions.c.

1766{
1767 int i;
1768 int offset = basesize;
1769
1770 for (i = 0; i < numoptions; i++)
1771 {
1772 int j;
1773 bool found = false;
1774
1775 for (j = 0; j < numelems; j++)
1776 {
1777 if (strcmp(options[i].gen->name, elems[j].optname) == 0)
1778 {
1779 relopt_string *optstring;
1780 char *itempos = ((char *) rdopts) + elems[j].offset;
1781 char *string_val;
1782
1783 /*
1784 * If isset_offset is provided, store whether the reloption is
1785 * set there.
1786 */
1787 if (elems[j].isset_offset > 0)
1788 {
1789 char *setpos = ((char *) rdopts) + elems[j].isset_offset;
1790
1791 *(bool *) setpos = options[i].isset;
1792 }
1793
1794 switch (options[i].gen->type)
1795 {
1796 case RELOPT_TYPE_BOOL:
1797 *(bool *) itempos = options[i].isset ?
1798 options[i].values.bool_val :
1799 ((relopt_bool *) options[i].gen)->default_val;
1800 break;
1801 case RELOPT_TYPE_INT:
1802 *(int *) itempos = options[i].isset ?
1803 options[i].values.int_val :
1804 ((relopt_int *) options[i].gen)->default_val;
1805 break;
1806 case RELOPT_TYPE_REAL:
1807 *(double *) itempos = options[i].isset ?
1808 options[i].values.real_val :
1809 ((relopt_real *) options[i].gen)->default_val;
1810 break;
1811 case RELOPT_TYPE_ENUM:
1812 *(int *) itempos = options[i].isset ?
1813 options[i].values.enum_val :
1814 ((relopt_enum *) options[i].gen)->default_val;
1815 break;
1816 case RELOPT_TYPE_STRING:
1817 optstring = (relopt_string *) options[i].gen;
1818 if (options[i].isset)
1819 string_val = options[i].values.string_val;
1820 else if (!optstring->default_isnull)
1821 string_val = optstring->default_val;
1822 else
1823 string_val = NULL;
1824
1825 if (optstring->fill_cb)
1826 {
1827 Size size =
1828 optstring->fill_cb(string_val,
1829 (char *) rdopts + offset);
1830
1831 if (size)
1832 {
1833 *(int *) itempos = offset;
1834 offset += size;
1835 }
1836 else
1837 *(int *) itempos = 0;
1838 }
1839 else if (string_val == NULL)
1840 *(int *) itempos = 0;
1841 else
1842 {
1843 strcpy((char *) rdopts + offset, string_val);
1844 *(int *) itempos = offset;
1845 offset += strlen(string_val) + 1;
1846 }
1847 break;
1848 default:
1849 elog(ERROR, "unsupported reloption type %d",
1850 options[i].gen->type);
1851 break;
1852 }
1853 found = true;
1854 break;
1855 }
1856 }
1857 if (validate && !found)
1858 elog(ERROR, "reloption \"%s\" not found in parse table",
1859 options[i].gen->name);
1860 }
1861 SET_VARSIZE(rdopts, offset);
1862}
static Datum values[MAXATTR]
Definition: bootstrap.c:153
int j
Definition: isn.c:78
static void SET_VARSIZE(void *PTR, Size len)
Definition: varatt.h:432

References relopt_string::default_isnull, relopt_string::default_val, elog, ERROR, relopt_string::fill_cb, i, relopt_parse_elt::isset_offset, j, relopt_parse_elt::offset, relopt_parse_elt::optname, RELOPT_TYPE_BOOL, RELOPT_TYPE_ENUM, RELOPT_TYPE_INT, RELOPT_TYPE_REAL, RELOPT_TYPE_STRING, SET_VARSIZE(), validate(), and values.

Referenced by build_local_reloptions(), and build_reloptions().

◆ heap_reloptions()

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

Definition at line 2055 of file reloptions.c.

2056{
2057 StdRdOptions *rdopts;
2058
2059 switch (relkind)
2060 {
2061 case RELKIND_TOASTVALUE:
2062 rdopts = (StdRdOptions *)
2064 if (rdopts != NULL)
2065 {
2066 /* adjust default-only parameters for TOAST relations */
2067 rdopts->fillfactor = 100;
2068 rdopts->autovacuum.analyze_threshold = -1;
2069 rdopts->autovacuum.analyze_scale_factor = -1;
2070 }
2071 return (bytea *) rdopts;
2072 case RELKIND_RELATION:
2073 case RELKIND_MATVIEW:
2074 return default_reloptions(reloptions, validate, RELOPT_KIND_HEAP);
2075 default:
2076 /* other relkinds are not supported */
2077 return NULL;
2078 }
2079}
bytea * default_reloptions(Datum reloptions, bool validate, relopt_kind kind)
Definition: reloptions.c:1869
@ RELOPT_KIND_TOAST
Definition: reloptions.h:43
@ RELOPT_KIND_HEAP
Definition: reloptions.h:42
int analyze_threshold
Definition: rel.h:317
float8 analyze_scale_factor
Definition: rel.h:329
int fillfactor
Definition: rel.h:343
AutoVacOpts autovacuum
Definition: rel.h:345

References AutoVacOpts::analyze_scale_factor, AutoVacOpts::analyze_threshold, StdRdOptions::autovacuum, default_reloptions(), StdRdOptions::fillfactor, RELOPT_KIND_HEAP, RELOPT_KIND_TOAST, and validate().

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

◆ index_reloptions()

bytea * index_reloptions ( amoptions_function  amoptions,
Datum  reloptions,
bool  validate 
)

Definition at line 2090 of file reloptions.c.

2091{
2092 Assert(amoptions != NULL);
2093
2094 /* Assume function is strict */
2095 if (DatumGetPointer(reloptions) == NULL)
2096 return NULL;
2097
2098 return amoptions(reloptions, validate);
2099}
static Pointer DatumGetPointer(Datum X)
Definition: postgres.h:322

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

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

◆ init_bool_reloption()

static relopt_bool * init_bool_reloption ( bits32  kinds,
const char *  name,
const char *  desc,
bool  default_val,
LOCKMODE  lockmode 
)
static

Definition at line 843 of file reloptions.c.

845{
846 relopt_bool *newoption;
847
848 newoption = (relopt_bool *) allocate_reloption(kinds, RELOPT_TYPE_BOOL,
849 name, desc, lockmode);
850 newoption->default_val = default_val;
851
852 return newoption;
853}
static relopt_gen * allocate_reloption(bits32 kinds, int type, const char *name, const char *desc, LOCKMODE lockmode)
Definition: reloptions.c:786
bool default_val
Definition: reloptions.h:94

References allocate_reloption(), relopt_bool::default_val, name, and RELOPT_TYPE_BOOL.

Referenced by add_bool_reloption(), and add_local_bool_reloption().

◆ init_enum_reloption()

static relopt_enum * init_enum_reloption ( bits32  kinds,
const char *  name,
const char *  desc,
relopt_enum_elt_def members,
int  default_val,
const char *  detailmsg,
LOCKMODE  lockmode 
)
static

Definition at line 1000 of file reloptions.c.

1003{
1004 relopt_enum *newoption;
1005
1006 newoption = (relopt_enum *) allocate_reloption(kinds, RELOPT_TYPE_ENUM,
1007 name, desc, lockmode);
1008 newoption->members = members;
1009 newoption->default_val = default_val;
1010 newoption->detailmsg = detailmsg;
1011
1012 return newoption;
1013}
int default_val
Definition: reloptions.h:127
const char * detailmsg
Definition: reloptions.h:128
relopt_enum_elt_def * members
Definition: reloptions.h:126

References allocate_reloption(), relopt_enum::default_val, relopt_enum::detailmsg, relopt_enum::members, name, and RELOPT_TYPE_ENUM.

Referenced by add_enum_reloption(), and add_local_enum_reloption().

◆ init_int_reloption()

static relopt_int * init_int_reloption ( bits32  kinds,
const char *  name,
const char *  desc,
int  default_val,
int  min_val,
int  max_val,
LOCKMODE  lockmode 
)
static

Definition at line 892 of file reloptions.c.

895{
896 relopt_int *newoption;
897
898 newoption = (relopt_int *) allocate_reloption(kinds, RELOPT_TYPE_INT,
899 name, desc, lockmode);
900 newoption->default_val = default_val;
901 newoption->min = min_val;
902 newoption->max = max_val;
903
904 return newoption;
905}
int default_val
Definition: reloptions.h:100

References allocate_reloption(), relopt_int::default_val, relopt_int::max, max_val, relopt_int::min, name, and RELOPT_TYPE_INT.

Referenced by add_int_reloption(), and add_local_int_reloption().

◆ init_local_reloptions()

void init_local_reloptions ( local_relopts relopts,
Size  relopt_struct_size 
)

◆ init_real_reloption()

static relopt_real * init_real_reloption ( bits32  kinds,
const char *  name,
const char *  desc,
double  default_val,
double  min_val,
double  max_val,
LOCKMODE  lockmode 
)
static

Definition at line 945 of file reloptions.c.

948{
949 relopt_real *newoption;
950
951 newoption = (relopt_real *) allocate_reloption(kinds, RELOPT_TYPE_REAL,
952 name, desc, lockmode);
953 newoption->default_val = default_val;
954 newoption->min = min_val;
955 newoption->max = max_val;
956
957 return newoption;
958}
double min
Definition: reloptions.h:109
double max
Definition: reloptions.h:110
double default_val
Definition: reloptions.h:108

References allocate_reloption(), relopt_real::default_val, relopt_real::max, max_val, relopt_real::min, name, and RELOPT_TYPE_REAL.

Referenced by add_local_real_reloption(), and add_real_reloption().

◆ init_string_reloption()

static relopt_string * init_string_reloption ( bits32  kinds,
const char *  name,
const char *  desc,
const char *  default_val,
validate_string_relopt  validator,
fill_string_relopt  filler,
LOCKMODE  lockmode 
)
static

Definition at line 1064 of file reloptions.c.

1069{
1070 relopt_string *newoption;
1071
1072 /* make sure the validator/default combination is sane */
1073 if (validator)
1074 (validator) (default_val);
1075
1077 name, desc, lockmode);
1078 newoption->validate_cb = validator;
1079 newoption->fill_cb = filler;
1080 if (default_val)
1081 {
1082 if (kinds == RELOPT_KIND_LOCAL)
1083 newoption->default_val = strdup(default_val);
1084 else
1085 newoption->default_val = MemoryContextStrdup(TopMemoryContext, default_val);
1086 newoption->default_len = strlen(default_val);
1087 newoption->default_isnull = false;
1088 }
1089 else
1090 {
1091 newoption->default_val = "";
1092 newoption->default_len = 0;
1093 newoption->default_isnull = true;
1094 }
1095
1096 return newoption;
1097}
char * MemoryContextStrdup(MemoryContext context, const char *string)
Definition: mcxt.c:1746
validate_string_relopt validate_cb
Definition: reloptions.h:144

References allocate_reloption(), relopt_string::default_isnull, relopt_string::default_len, relopt_string::default_val, relopt_string::fill_cb, MemoryContextStrdup(), name, RELOPT_KIND_LOCAL, RELOPT_TYPE_STRING, TopMemoryContext, and relopt_string::validate_cb.

Referenced by add_local_string_reloption(), and add_string_reloption().

◆ initialize_reloptions()

static void initialize_reloptions ( void  )
static

Definition at line 591 of file reloptions.c.

592{
593 int i;
594 int j;
595
596 j = 0;
597 for (i = 0; boolRelOpts[i].gen.name; i++)
598 {
601 j++;
602 }
603 for (i = 0; intRelOpts[i].gen.name; i++)
604 {
607 j++;
608 }
609 for (i = 0; realRelOpts[i].gen.name; i++)
610 {
613 j++;
614 }
615 for (i = 0; enumRelOpts[i].gen.name; i++)
616 {
619 j++;
620 }
621 for (i = 0; stringRelOpts[i].gen.name; i++)
622 {
625 j++;
626 }
628
629 if (relOpts)
630 pfree(relOpts);
632 (j + 1) * sizeof(relopt_gen *));
633
634 j = 0;
635 for (i = 0; boolRelOpts[i].gen.name; i++)
636 {
639 relOpts[j]->namelen = strlen(relOpts[j]->name);
640 j++;
641 }
642
643 for (i = 0; intRelOpts[i].gen.name; i++)
644 {
645 relOpts[j] = &intRelOpts[i].gen;
647 relOpts[j]->namelen = strlen(relOpts[j]->name);
648 j++;
649 }
650
651 for (i = 0; realRelOpts[i].gen.name; i++)
652 {
655 relOpts[j]->namelen = strlen(relOpts[j]->name);
656 j++;
657 }
658
659 for (i = 0; enumRelOpts[i].gen.name; i++)
660 {
663 relOpts[j]->namelen = strlen(relOpts[j]->name);
664 j++;
665 }
666
667 for (i = 0; stringRelOpts[i].gen.name; i++)
668 {
671 relOpts[j]->namelen = strlen(relOpts[j]->name);
672 j++;
673 }
674
675 for (i = 0; i < num_custom_options; i++)
676 {
678 j++;
679 }
680
681 /* add a list terminator */
682 relOpts[j] = NULL;
683
684 /* flag the work is complete */
685 need_initialization = false;
686}
bool DoLockModesConflict(LOCKMODE mode1, LOCKMODE mode2)
Definition: lock.c:623
void * MemoryContextAlloc(MemoryContext context, Size size)
Definition: mcxt.c:1229
static relopt_real realRelOpts[]
Definition: reloptions.c:389
static relopt_int intRelOpts[]
Definition: reloptions.c:173
static relopt_enum enumRelOpts[]
Definition: reloptions.c:519
static relopt_string stringRelOpts[]
Definition: reloptions.c:558
static relopt_bool boolRelOpts[]
Definition: reloptions.c:94
relopt_gen gen
Definition: reloptions.h:93
relopt_gen gen
Definition: reloptions.h:125
relopt_gen gen
Definition: reloptions.h:99
relopt_gen gen
Definition: reloptions.h:107
relopt_gen gen
Definition: reloptions.h:141

References Assert(), boolRelOpts, custom_options, DoLockModesConflict(), enumRelOpts, relopt_bool::gen, relopt_int::gen, relopt_real::gen, relopt_enum::gen, relopt_string::gen, i, intRelOpts, j, relopt_gen::lockmode, MemoryContextAlloc(), name, relopt_gen::name, relopt_gen::namelen, need_initialization, num_custom_options, pfree(), realRelOpts, RELOPT_TYPE_BOOL, RELOPT_TYPE_ENUM, RELOPT_TYPE_INT, RELOPT_TYPE_REAL, RELOPT_TYPE_STRING, relOpts, stringRelOpts, TopMemoryContext, and relopt_gen::type.

Referenced by AlterTableGetRelOptionsLockLevel(), and parseRelOptions().

◆ parse_one_reloption()

static void parse_one_reloption ( relopt_value option,
char *  text_str,
int  text_len,
bool  validate 
)
static

Definition at line 1589 of file reloptions.c.

1591{
1592 char *value;
1593 int value_len;
1594 bool parsed;
1595 bool nofree = false;
1596
1597 if (option->isset && validate)
1598 ereport(ERROR,
1599 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1600 errmsg("parameter \"%s\" specified more than once",
1601 option->gen->name)));
1602
1603 value_len = text_len - option->gen->namelen - 1;
1604 value = (char *) palloc(value_len + 1);
1605 memcpy(value, text_str + option->gen->namelen + 1, value_len);
1606 value[value_len] = '\0';
1607
1608 switch (option->gen->type)
1609 {
1610 case RELOPT_TYPE_BOOL:
1611 {
1612 parsed = parse_bool(value, &option->values.bool_val);
1613 if (validate && !parsed)
1614 ereport(ERROR,
1615 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1616 errmsg("invalid value for boolean option \"%s\": %s",
1617 option->gen->name, value)));
1618 }
1619 break;
1620 case RELOPT_TYPE_INT:
1621 {
1622 relopt_int *optint = (relopt_int *) option->gen;
1623
1624 parsed = parse_int(value, &option->values.int_val, 0, NULL);
1625 if (validate && !parsed)
1626 ereport(ERROR,
1627 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1628 errmsg("invalid value for integer option \"%s\": %s",
1629 option->gen->name, value)));
1630 if (validate && (option->values.int_val < optint->min ||
1631 option->values.int_val > optint->max))
1632 ereport(ERROR,
1633 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1634 errmsg("value %s out of bounds for option \"%s\"",
1635 value, option->gen->name),
1636 errdetail("Valid values are between \"%d\" and \"%d\".",
1637 optint->min, optint->max)));
1638 }
1639 break;
1640 case RELOPT_TYPE_REAL:
1641 {
1642 relopt_real *optreal = (relopt_real *) option->gen;
1643
1644 parsed = parse_real(value, &option->values.real_val, 0, NULL);
1645 if (validate && !parsed)
1646 ereport(ERROR,
1647 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1648 errmsg("invalid value for floating point option \"%s\": %s",
1649 option->gen->name, value)));
1650 if (validate && (option->values.real_val < optreal->min ||
1651 option->values.real_val > optreal->max))
1652 ereport(ERROR,
1653 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1654 errmsg("value %s out of bounds for option \"%s\"",
1655 value, option->gen->name),
1656 errdetail("Valid values are between \"%f\" and \"%f\".",
1657 optreal->min, optreal->max)));
1658 }
1659 break;
1660 case RELOPT_TYPE_ENUM:
1661 {
1662 relopt_enum *optenum = (relopt_enum *) option->gen;
1664
1665 parsed = false;
1666 for (elt = optenum->members; elt->string_val; elt++)
1667 {
1668 if (pg_strcasecmp(value, elt->string_val) == 0)
1669 {
1670 option->values.enum_val = elt->symbol_val;
1671 parsed = true;
1672 break;
1673 }
1674 }
1675 if (validate && !parsed)
1676 ereport(ERROR,
1677 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1678 errmsg("invalid value for enum option \"%s\": %s",
1679 option->gen->name, value),
1680 optenum->detailmsg ?
1681 errdetail_internal("%s", _(optenum->detailmsg)) : 0));
1682
1683 /*
1684 * If value is not among the allowed string values, but we are
1685 * not asked to validate, just use the default numeric value.
1686 */
1687 if (!parsed)
1688 option->values.enum_val = optenum->default_val;
1689 }
1690 break;
1691 case RELOPT_TYPE_STRING:
1692 {
1693 relopt_string *optstring = (relopt_string *) option->gen;
1694
1695 option->values.string_val = value;
1696 nofree = true;
1697 if (validate && optstring->validate_cb)
1698 (optstring->validate_cb) (value);
1699 parsed = true;
1700 }
1701 break;
1702 default:
1703 elog(ERROR, "unsupported reloption type %d", option->gen->type);
1704 parsed = true; /* quiet compiler */
1705 break;
1706 }
1707
1708 if (parsed)
1709 option->isset = true;
1710 if (!nofree)
1711 pfree(value);
1712}
bool parse_bool(const char *value, bool *result)
Definition: bool.c:31
int errdetail_internal(const char *fmt,...)
Definition: elog.c:1234
int errdetail(const char *fmt,...)
Definition: elog.c:1207
#define _(x)
Definition: elog.c:91
bool parse_int(const char *value, int *result, int flags, const char **hintmsg)
Definition: guc.c:2876
bool parse_real(const char *value, double *result, int flags, const char **hintmsg)
Definition: guc.c:2966
for(;;)
static struct @166 value
int pg_strcasecmp(const char *s1, const char *s2)
Definition: pgstrcasecmp.c:36
const char * name
Definition: getopt_long.h:19
const char * string_val
Definition: reloptions.h:119

References _, relopt_enum::default_val, relopt_enum::detailmsg, elog, ereport, errcode(), errdetail(), errdetail_internal(), errmsg(), ERROR, for(), if(), relopt_int::max, relopt_real::max, relopt_enum::members, relopt_int::min, relopt_real::min, option::name, palloc(), parse_bool(), parse_int(), parse_real(), pfree(), pg_strcasecmp(), RELOPT_TYPE_BOOL, RELOPT_TYPE_ENUM, RELOPT_TYPE_INT, RELOPT_TYPE_REAL, RELOPT_TYPE_STRING, relopt_enum_elt_def::string_val, validate(), relopt_string::validate_cb, and value.

Referenced by parseRelOptionsInternal().

◆ parseLocalRelOptions()

static relopt_value * parseLocalRelOptions ( local_relopts relopts,
Datum  options,
bool  validate 
)
static

Definition at line 1561 of file reloptions.c.

1562{
1563 int nopts = list_length(relopts->options);
1564 relopt_value *values = palloc(sizeof(*values) * nopts);
1565 ListCell *lc;
1566 int i = 0;
1567
1568 foreach(lc, relopts->options)
1569 {
1570 local_relopt *opt = lfirst(lc);
1571
1572 values[i].gen = opt->option;
1573 values[i].isset = false;
1574
1575 i++;
1576 }
1577
1578 if (options != (Datum) 0)
1580
1581 return values;
1582}
static void parseRelOptionsInternal(Datum options, bool validate, relopt_value *reloptions, int numoptions)
Definition: reloptions.c:1447

References i, lfirst, list_length(), local_relopt::option, local_relopts::options, palloc(), parseRelOptionsInternal(), validate(), and values.

Referenced by build_local_reloptions().

◆ parseRelOptions()

static relopt_value * parseRelOptions ( Datum  options,
bool  validate,
relopt_kind  kind,
int *  numrelopts 
)
static

Definition at line 1519 of file reloptions.c.

1521{
1522 relopt_value *reloptions = NULL;
1523 int numoptions = 0;
1524 int i;
1525 int j;
1526
1529
1530 /* Build a list of expected options, based on kind */
1531
1532 for (i = 0; relOpts[i]; i++)
1533 if (relOpts[i]->kinds & kind)
1534 numoptions++;
1535
1536 if (numoptions > 0)
1537 {
1538 reloptions = palloc(numoptions * sizeof(relopt_value));
1539
1540 for (i = 0, j = 0; relOpts[i]; i++)
1541 {
1542 if (relOpts[i]->kinds & kind)
1543 {
1544 reloptions[j].gen = relOpts[i];
1545 reloptions[j].isset = false;
1546 j++;
1547 }
1548 }
1549 }
1550
1551 /* Done if no options */
1552 if (DatumGetPointer(options) != NULL)
1553 parseRelOptionsInternal(options, validate, reloptions, numoptions);
1554
1555 *numrelopts = numoptions;
1556 return reloptions;
1557}

References DatumGetPointer(), relopt_value::gen, i, initialize_reloptions(), relopt_value::isset, j, need_initialization, palloc(), parseRelOptionsInternal(), relOpts, and validate().

Referenced by build_reloptions().

◆ parseRelOptionsInternal()

static void parseRelOptionsInternal ( Datum  options,
bool  validate,
relopt_value reloptions,
int  numoptions 
)
static

Definition at line 1447 of file reloptions.c.

1449{
1451 Datum *optiondatums;
1452 int noptions;
1453 int i;
1454
1455 deconstruct_array_builtin(array, TEXTOID, &optiondatums, NULL, &noptions);
1456
1457 for (i = 0; i < noptions; i++)
1458 {
1459 char *text_str = VARDATA(DatumGetPointer(optiondatums[i]));
1460 int text_len = VARSIZE(DatumGetPointer(optiondatums[i])) - VARHDRSZ;
1461 int j;
1462
1463 /* Search for a match in reloptions */
1464 for (j = 0; j < numoptions; j++)
1465 {
1466 int kw_len = reloptions[j].gen->namelen;
1467
1468 if (text_len > kw_len && text_str[kw_len] == '=' &&
1469 strncmp(text_str, reloptions[j].gen->name, kw_len) == 0)
1470 {
1471 parse_one_reloption(&reloptions[j], text_str, text_len,
1472 validate);
1473 break;
1474 }
1475 }
1476
1477 if (j >= numoptions && validate)
1478 {
1479 char *s;
1480 char *p;
1481
1482 s = TextDatumGetCString(optiondatums[i]);
1483 p = strchr(s, '=');
1484 if (p)
1485 *p = '\0';
1486 ereport(ERROR,
1487 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1488 errmsg("unrecognized parameter \"%s\"", s)));
1489 }
1490 }
1491
1492 /* It's worth avoiding memory leaks in this function */
1493 pfree(optiondatums);
1494
1495 if (((void *) array) != DatumGetPointer(options))
1496 pfree(array);
1497}
#define DatumGetArrayTypeP(X)
Definition: array.h:261
void deconstruct_array_builtin(ArrayType *array, Oid elmtype, Datum **elemsp, bool **nullsp, int *nelemsp)
Definition: arrayfuncs.c:3697
#define TextDatumGetCString(d)
Definition: builtins.h:98
#define VARHDRSZ
Definition: c.h:698
static void parse_one_reloption(relopt_value *option, char *text_str, int text_len, bool validate)
Definition: reloptions.c:1589
static Size VARSIZE(const void *PTR)
Definition: varatt.h:298
static char * VARDATA(const void *PTR)
Definition: varatt.h:305

References DatumGetArrayTypeP, DatumGetPointer(), deconstruct_array_builtin(), ereport, errcode(), errmsg(), ERROR, relopt_value::gen, i, j, relopt_gen::namelen, noptions, parse_one_reloption(), pfree(), TextDatumGetCString, validate(), VARDATA(), VARHDRSZ, and VARSIZE().

Referenced by parseLocalRelOptions(), and parseRelOptions().

◆ partitioned_table_reloptions()

bytea * partitioned_table_reloptions ( Datum  reloptions,
bool  validate 
)

Definition at line 2020 of file reloptions.c.

2021{
2022 if (validate && reloptions)
2023 ereport(ERROR,
2024 errcode(ERRCODE_WRONG_OBJECT_TYPE),
2025 errmsg("cannot specify storage parameters for a partitioned table"),
2026 errhint("Specify storage parameters for its leaf partitions instead."));
2027 return NULL;
2028}
int errhint(const char *fmt,...)
Definition: elog.c:1321

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

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

◆ register_reloptions_validator()

void register_reloptions_validator ( local_relopts relopts,
relopts_validator  validator 
)

Definition at line 758 of file reloptions.c.

759{
760 relopts->validators = lappend(relopts->validators, validator);
761}

References lappend(), and local_relopts::validators.

Referenced by ltree_gist_options().

◆ tablespace_reloptions()

bytea * tablespace_reloptions ( Datum  reloptions,
bool  validate 
)

Definition at line 2122 of file reloptions.c.

2123{
2124 static const relopt_parse_elt tab[] = {
2125 {"random_page_cost", RELOPT_TYPE_REAL, offsetof(TableSpaceOpts, random_page_cost)},
2126 {"seq_page_cost", RELOPT_TYPE_REAL, offsetof(TableSpaceOpts, seq_page_cost)},
2127 {"effective_io_concurrency", RELOPT_TYPE_INT, offsetof(TableSpaceOpts, effective_io_concurrency)},
2128 {"maintenance_io_concurrency", RELOPT_TYPE_INT, offsetof(TableSpaceOpts, maintenance_io_concurrency)}
2129 };
2130
2131 return (bytea *) build_reloptions(reloptions, validate,
2133 sizeof(TableSpaceOpts),
2134 tab, lengthof(tab));
2135}
int maintenance_io_concurrency
Definition: bufmgr.c:162
int effective_io_concurrency
Definition: bufmgr.c:155
double random_page_cost
Definition: costsize.c:131
double seq_page_cost
Definition: costsize.c:130
@ RELOPT_KIND_TABLESPACE
Definition: reloptions.h:49

References build_reloptions(), effective_io_concurrency, lengthof, maintenance_io_concurrency, random_page_cost, RELOPT_KIND_TABLESPACE, RELOPT_TYPE_INT, RELOPT_TYPE_REAL, seq_page_cost, and validate().

Referenced by AlterTableSpaceOptions(), CreateTableSpace(), and get_tablespace().

◆ transformRelOptions()

Datum transformRelOptions ( Datum  oldOptions,
List defList,
const char *  nameSpace,
const char *const  validnsps[],
bool  acceptOidsOff,
bool  isReset 
)

Definition at line 1167 of file reloptions.c.

1169{
1170 Datum result;
1171 ArrayBuildState *astate;
1172 ListCell *cell;
1173
1174 /* no change if empty list */
1175 if (defList == NIL)
1176 return oldOptions;
1177
1178 /* We build new array using accumArrayResult */
1179 astate = NULL;
1180
1181 /* Copy any oldOptions that aren't to be replaced */
1182 if (DatumGetPointer(oldOptions) != NULL)
1183 {
1184 ArrayType *array = DatumGetArrayTypeP(oldOptions);
1185 Datum *oldoptions;
1186 int noldoptions;
1187 int i;
1188
1189 deconstruct_array_builtin(array, TEXTOID, &oldoptions, NULL, &noldoptions);
1190
1191 for (i = 0; i < noldoptions; i++)
1192 {
1193 char *text_str = VARDATA(DatumGetPointer(oldoptions[i]));
1194 int text_len = VARSIZE(DatumGetPointer(oldoptions[i])) - VARHDRSZ;
1195
1196 /* Search for a match in defList */
1197 foreach(cell, defList)
1198 {
1199 DefElem *def = (DefElem *) lfirst(cell);
1200 int kw_len;
1201
1202 /* ignore if not in the same namespace */
1203 if (nameSpace == NULL)
1204 {
1205 if (def->defnamespace != NULL)
1206 continue;
1207 }
1208 else if (def->defnamespace == NULL)
1209 continue;
1210 else if (strcmp(def->defnamespace, nameSpace) != 0)
1211 continue;
1212
1213 kw_len = strlen(def->defname);
1214 if (text_len > kw_len && text_str[kw_len] == '=' &&
1215 strncmp(text_str, def->defname, kw_len) == 0)
1216 break;
1217 }
1218 if (!cell)
1219 {
1220 /* No match, so keep old option */
1221 astate = accumArrayResult(astate, oldoptions[i],
1222 false, TEXTOID,
1224 }
1225 }
1226 }
1227
1228 /*
1229 * If CREATE/SET, add new options to array; if RESET, just check that the
1230 * user didn't say RESET (option=val). (Must do this because the grammar
1231 * doesn't enforce it.)
1232 */
1233 foreach(cell, defList)
1234 {
1235 DefElem *def = (DefElem *) lfirst(cell);
1236
1237 if (isReset)
1238 {
1239 if (def->arg != NULL)
1240 ereport(ERROR,
1241 (errcode(ERRCODE_SYNTAX_ERROR),
1242 errmsg("RESET must not include values for parameters")));
1243 }
1244 else
1245 {
1246 const char *name;
1247 const char *value;
1248 text *t;
1249 Size len;
1250
1251 /*
1252 * Error out if the namespace is not valid. A NULL namespace is
1253 * always valid.
1254 */
1255 if (def->defnamespace != NULL)
1256 {
1257 bool valid = false;
1258 int i;
1259
1260 if (validnsps)
1261 {
1262 for (i = 0; validnsps[i]; i++)
1263 {
1264 if (strcmp(def->defnamespace, validnsps[i]) == 0)
1265 {
1266 valid = true;
1267 break;
1268 }
1269 }
1270 }
1271
1272 if (!valid)
1273 ereport(ERROR,
1274 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1275 errmsg("unrecognized parameter namespace \"%s\"",
1276 def->defnamespace)));
1277 }
1278
1279 /* ignore if not in the same namespace */
1280 if (nameSpace == NULL)
1281 {
1282 if (def->defnamespace != NULL)
1283 continue;
1284 }
1285 else if (def->defnamespace == NULL)
1286 continue;
1287 else if (strcmp(def->defnamespace, nameSpace) != 0)
1288 continue;
1289
1290 /*
1291 * Flatten the DefElem into a text string like "name=arg". If we
1292 * have just "name", assume "name=true" is meant. Note: the
1293 * namespace is not output.
1294 */
1295 name = def->defname;
1296 if (def->arg != NULL)
1297 value = defGetString(def);
1298 else
1299 value = "true";
1300
1301 /* Insist that name not contain "=", else "a=b=c" is ambiguous */
1302 if (strchr(name, '=') != NULL)
1303 ereport(ERROR,
1304 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1305 errmsg("invalid option name \"%s\": must not contain \"=\"",
1306 name)));
1307
1308 /*
1309 * This is not a great place for this test, but there's no other
1310 * convenient place to filter the option out. As WITH (oids =
1311 * false) will be removed someday, this seems like an acceptable
1312 * amount of ugly.
1313 */
1314 if (acceptOidsOff && def->defnamespace == NULL &&
1315 strcmp(name, "oids") == 0)
1316 {
1317 if (defGetBoolean(def))
1318 ereport(ERROR,
1319 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1320 errmsg("tables declared WITH OIDS are not supported")));
1321 /* skip over option, reloptions machinery doesn't know it */
1322 continue;
1323 }
1324
1325 len = VARHDRSZ + strlen(name) + 1 + strlen(value);
1326 /* +1 leaves room for sprintf's trailing null */
1327 t = (text *) palloc(len + 1);
1328 SET_VARSIZE(t, len);
1329 sprintf(VARDATA(t), "%s=%s", name, value);
1330
1331 astate = accumArrayResult(astate, PointerGetDatum(t),
1332 false, TEXTOID,
1334 }
1335 }
1336
1337 if (astate)
1338 result = makeArrayResult(astate, CurrentMemoryContext);
1339 else
1340 result = (Datum) 0;
1341
1342 return result;
1343}
ArrayBuildState * accumArrayResult(ArrayBuildState *astate, Datum dvalue, bool disnull, Oid element_type, MemoryContext rcontext)
Definition: arrayfuncs.c:5350
Datum makeArrayResult(ArrayBuildState *astate, MemoryContext rcontext)
Definition: arrayfuncs.c:5420
char * defGetString(DefElem *def)
Definition: define.c:35
bool defGetBoolean(DefElem *def)
Definition: define.c:94
MemoryContext CurrentMemoryContext
Definition: mcxt.c:160
const void size_t len
#define sprintf
Definition: port.h:241
static Datum PointerGetDatum(const void *X)
Definition: postgres.h:332
char * defnamespace
Definition: parsenodes.h:841
Node * arg
Definition: parsenodes.h:843

References accumArrayResult(), DefElem::arg, CurrentMemoryContext, DatumGetArrayTypeP, DatumGetPointer(), deconstruct_array_builtin(), defGetBoolean(), defGetString(), DefElem::defname, DefElem::defnamespace, ereport, errcode(), errmsg(), ERROR, i, len, lfirst, makeArrayResult(), name, NIL, palloc(), PointerGetDatum(), SET_VARSIZE(), sprintf, value, VARDATA(), VARHDRSZ, and VARSIZE().

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

◆ untransformRelOptions()

List * untransformRelOptions ( Datum  options)

Definition at line 1351 of file reloptions.c.

1352{
1353 List *result = NIL;
1354 ArrayType *array;
1355 Datum *optiondatums;
1356 int noptions;
1357 int i;
1358
1359 /* Nothing to do if no options */
1360 if (DatumGetPointer(options) == NULL)
1361 return result;
1362
1363 array = DatumGetArrayTypeP(options);
1364
1365 deconstruct_array_builtin(array, TEXTOID, &optiondatums, NULL, &noptions);
1366
1367 for (i = 0; i < noptions; i++)
1368 {
1369 char *s;
1370 char *p;
1371 Node *val = NULL;
1372
1373 s = TextDatumGetCString(optiondatums[i]);
1374 p = strchr(s, '=');
1375 if (p)
1376 {
1377 *p++ = '\0';
1378 val = (Node *) makeString(p);
1379 }
1380 result = lappend(result, makeDefElem(s, val, -1));
1381 }
1382
1383 return result;
1384}
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(), i, lappend(), makeDefElem(), makeString(), NIL, noptions, TextDatumGetCString, and val.

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

◆ view_reloptions()

bytea * view_reloptions ( Datum  reloptions,
bool  validate 
)

Definition at line 2034 of file reloptions.c.

2035{
2036 static const relopt_parse_elt tab[] = {
2037 {"security_barrier", RELOPT_TYPE_BOOL,
2038 offsetof(ViewOptions, security_barrier)},
2039 {"security_invoker", RELOPT_TYPE_BOOL,
2040 offsetof(ViewOptions, security_invoker)},
2041 {"check_option", RELOPT_TYPE_ENUM,
2042 offsetof(ViewOptions, check_option)}
2043 };
2044
2045 return (bytea *) build_reloptions(reloptions, validate,
2047 sizeof(ViewOptions),
2048 tab, lengthof(tab));
2049}
@ RELOPT_KIND_VIEW
Definition: reloptions.h:51

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

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

Variable Documentation

◆ boolRelOpts

relopt_bool boolRelOpts[]
static

Definition at line 94 of file reloptions.c.

Referenced by initialize_reloptions().

◆ custom_options

relopt_gen** custom_options = NULL
static

Definition at line 568 of file reloptions.c.

Referenced by add_reloption(), and initialize_reloptions().

◆ enumRelOpts

relopt_enum enumRelOpts[]
static

Definition at line 519 of file reloptions.c.

Referenced by initialize_reloptions().

◆ gistBufferingOptValues

relopt_enum_elt_def gistBufferingOptValues[]
static
Initial value:
=
{
{(const char *) NULL}
}
@ GIST_OPTION_BUFFERING_OFF
Definition: gist_private.h:388
@ GIST_OPTION_BUFFERING_AUTO
Definition: gist_private.h:386
@ GIST_OPTION_BUFFERING_ON
Definition: gist_private.h:387

Definition at line 502 of file reloptions.c.

◆ intRelOpts

relopt_int intRelOpts[]
static

Definition at line 173 of file reloptions.c.

Referenced by initialize_reloptions().

◆ last_assigned_kind

bits32 last_assigned_kind = RELOPT_KIND_LAST_DEFAULT
static

Definition at line 565 of file reloptions.c.

Referenced by add_reloption_kind().

◆ need_initialization

bool need_initialization = true
static

◆ num_custom_options

int num_custom_options = 0
static

Definition at line 567 of file reloptions.c.

Referenced by add_reloption(), and initialize_reloptions().

◆ realRelOpts

relopt_real realRelOpts[]
static

Definition at line 389 of file reloptions.c.

Referenced by initialize_reloptions().

◆ relOpts

relopt_gen** relOpts = NULL
static

◆ StdRdOptIndexCleanupValues

relopt_enum_elt_def StdRdOptIndexCleanupValues[]
static
Initial value:

Definition at line 487 of file reloptions.c.

◆ stringRelOpts

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

Definition at line 558 of file reloptions.c.

Referenced by initialize_reloptions().

◆ viewCheckOptValues

relopt_enum_elt_def viewCheckOptValues[]
static
Initial value:
=
{
{(const char *) NULL}
}
@ VIEW_OPTION_CHECK_OPTION_LOCAL
Definition: rel.h:416
@ VIEW_OPTION_CHECK_OPTION_CASCADED
Definition: rel.h:417

Definition at line 511 of file reloptions.c.