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 "commands/view.h"
#include "nodes/makefuncs.h"
#include "postmaster/postmaster.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 *namspace, char *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 571 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 851 of file reloptions.c.

853 {
854  relopt_bool *newoption = init_bool_reloption(kinds, name, desc,
855  default_val, lockmode);
856 
857  add_reloption((relopt_gen *) newoption);
858 }
static void add_reloption(relopt_gen *newoption)
Definition: reloptions.c:702
static relopt_bool * init_bool_reloption(bits32 kinds, const char *name, const char *desc, bool default_val, LOCKMODE lockmode)
Definition: reloptions.c:834
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 1020 of file reloptions.c.

1023 {
1024  relopt_enum *newoption = init_enum_reloption(kinds, name, desc,
1025  members, default_val,
1026  detailmsg, lockmode);
1027 
1028  add_reloption((relopt_gen *) newoption);
1029 }
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:991

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

905 {
906  relopt_int *newoption = init_int_reloption(kinds, name, desc,
907  default_val, min_val,
908  max_val, lockmode);
909 
910  add_reloption((relopt_gen *) newoption);
911 }
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:883

References add_reloption(), init_int_reloption(), 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 867 of file reloptions.c.

869 {
871  name, desc,
872  default_val, 0);
873 
874  add_local_reloption(relopts, (relopt_gen *) newoption, offset);
875 }
static void add_local_reloption(local_relopts *relopts, relopt_gen *newoption, int offset)
Definition: reloptions.c:759
@ 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 1038 of file reloptions.c.

1041 {
1043  name, desc,
1044  members, default_val,
1045  detailmsg, 0);
1046 
1047  add_local_reloption(relopts, (relopt_gen *) newoption, offset);
1048 }

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 
)

Definition at line 920 of file reloptions.c.

923 {
925  name, desc, default_val,
926  min_val, max_val, 0);
927 
928  add_local_reloption(relopts, (relopt_gen *) newoption, offset);
929 }

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

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

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

977 {
979  name, desc,
980  default_val, min_val,
981  max_val, 0);
982 
983  add_local_reloption(relopts, (relopt_gen *) newoption, offset);
984 }
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:936

References add_local_reloption(), init_real_reloption(), 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 759 of file reloptions.c.

760 {
761  local_relopt *opt = palloc(sizeof(*opt));
762 
763  Assert(offset < relopts->relopt_struct_size);
764 
765  opt->option = newoption;
766  opt->offset = offset;
767 
768  relopts->options = lappend(relopts->options, opt);
769 }
Assert(fmt[strlen(fmt) - 1] !='\n')
List * lappend(List *list, void *datum)
Definition: list.c:338
void * palloc(Size size)
Definition: mcxt.c:1226
relopt_gen * option
Definition: reloptions.h:160
List * options
Definition: reloptions.h:167

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

1124 {
1126  name, desc,
1127  default_val,
1128  validator, filler,
1129  0);
1130 
1131  add_local_reloption(relopts, (relopt_gen *) newoption, offset);
1132 }
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:1055

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

959 {
960  relopt_real *newoption = init_real_reloption(kinds, name, desc,
961  default_val, min_val,
962  max_val, lockmode);
963 
964  add_reloption((relopt_gen *) newoption);
965 }

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

Referenced by create_reloptions_table().

◆ add_reloption()

static void add_reloption ( relopt_gen newoption)
static

Definition at line 702 of file reloptions.c.

703 {
704  static int max_custom_options = 0;
705 
706  if (num_custom_options >= max_custom_options)
707  {
708  MemoryContext oldcxt;
709 
711 
712  if (max_custom_options == 0)
713  {
714  max_custom_options = 8;
715  custom_options = palloc(max_custom_options * sizeof(relopt_gen *));
716  }
717  else
718  {
719  max_custom_options *= 2;
721  max_custom_options * sizeof(relopt_gen *));
722  }
723  MemoryContextSwitchTo(oldcxt);
724  }
725  custom_options[num_custom_options++] = newoption;
726 
727  need_initialization = true;
728 }
MemoryContext TopMemoryContext
Definition: mcxt.c:141
void * repalloc(void *pointer, Size size)
Definition: mcxt.c:1476
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:138
static int num_custom_options
Definition: reloptions.c:558
static bool need_initialization
Definition: reloptions.c:560
static relopt_gen ** custom_options
Definition: reloptions.c:559

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

686 {
687  /* don't hand out the last bit so that the enum's behavior is portable */
689  ereport(ERROR,
690  (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
691  errmsg("user-defined relation parameter types limit exceeded")));
692  last_assigned_kind <<= 1;
694 }
int errcode(int sqlerrcode)
Definition: elog.c:858
int errmsg(const char *fmt,...)
Definition: elog.c:1069
#define ERROR
Definition: elog.h:39
#define ereport(elevel,...)
Definition: elog.h:149
static bits32 last_assigned_kind
Definition: reloptions.c:556
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 1100 of file reloptions.c.

1103 {
1104  relopt_string *newoption = init_string_reloption(kinds, name, desc,
1105  default_val,
1106  validator, NULL,
1107  lockmode);
1108 
1109  add_reloption((relopt_gen *) newoption);
1110 }

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

779 {
780  MemoryContext oldcxt;
781  size_t size;
782  relopt_gen *newoption;
783 
784  if (kinds != RELOPT_KIND_LOCAL)
786  else
787  oldcxt = NULL;
788 
789  switch (type)
790  {
791  case RELOPT_TYPE_BOOL:
792  size = sizeof(relopt_bool);
793  break;
794  case RELOPT_TYPE_INT:
795  size = sizeof(relopt_int);
796  break;
797  case RELOPT_TYPE_REAL:
798  size = sizeof(relopt_real);
799  break;
800  case RELOPT_TYPE_ENUM:
801  size = sizeof(relopt_enum);
802  break;
803  case RELOPT_TYPE_STRING:
804  size = sizeof(relopt_string);
805  break;
806  default:
807  elog(ERROR, "unsupported reloption type %d", type);
808  return NULL; /* keep compiler quiet */
809  }
810 
811  newoption = palloc(size);
812 
813  newoption->name = pstrdup(name);
814  if (desc)
815  newoption->desc = pstrdup(desc);
816  else
817  newoption->desc = NULL;
818  newoption->kinds = kinds;
819  newoption->namelen = strlen(name);
820  newoption->type = type;
821  newoption->lockmode = lockmode;
822 
823  if (oldcxt != NULL)
824  MemoryContextSwitchTo(oldcxt);
825 
826  return newoption;
827 }
char * pstrdup(const char *in)
Definition: mcxt.c:1644
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 1704 of file reloptions.c.

1705 {
1706  Size size = base;
1707  int i;
1708 
1709  for (i = 0; i < numoptions; i++)
1710  {
1711  relopt_value *optval = &options[i];
1712 
1713  if (optval->gen->type == RELOPT_TYPE_STRING)
1714  {
1715  relopt_string *optstr = (relopt_string *) optval->gen;
1716 
1717  if (optstr->fill_cb)
1718  {
1719  const char *val = optval->isset ? optval->values.string_val :
1720  optstr->default_isnull ? NULL : optstr->default_val;
1721 
1722  size += optstr->fill_cb(val, NULL);
1723  }
1724  else
1725  size += GET_STRING_RELOPTION_LEN(*optval) + 1;
1726  }
1727  }
1728 
1729  return palloc0(size);
1730 }
size_t Size
Definition: c.h:594
long val
Definition: informix.c:664
int i
Definition: isn.c:73
if(TABLE==NULL||TABLE_index==NULL)
Definition: isn.c:77
void * palloc0(Size size)
Definition: mcxt.c:1257
#define GET_STRING_RELOPTION_LEN(option)
Definition: reloptions.c:571
char * default_val
Definition: reloptions.h:146
fill_string_relopt fill_cb
Definition: reloptions.h:145
bool default_isnull
Definition: reloptions.h:143
relopt_gen * gen
Definition: reloptions.h:78
union relopt_value::@46 values
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 2110 of file reloptions.c.

2111 {
2112  LOCKMODE lockmode = NoLock;
2113  ListCell *cell;
2114 
2115  if (defList == NIL)
2116  return AccessExclusiveLock;
2117 
2118  if (need_initialization)
2120 
2121  foreach(cell, defList)
2122  {
2123  DefElem *def = (DefElem *) lfirst(cell);
2124  int i;
2125 
2126  for (i = 0; relOpts[i]; i++)
2127  {
2128  if (strncmp(relOpts[i]->name,
2129  def->defname,
2130  relOpts[i]->namelen + 1) == 0)
2131  {
2132  if (lockmode < relOpts[i]->lockmode)
2133  lockmode = relOpts[i]->lockmode;
2134  }
2135  }
2136  }
2137 
2138  return lockmode;
2139 }
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:582
static relopt_gen ** relOpts
Definition: reloptions.c:555
char * defname
Definition: parsenodes.h:809

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

2072 {
2073  static const relopt_parse_elt tab[] = {
2074  {"n_distinct", RELOPT_TYPE_REAL, offsetof(AttributeOpts, n_distinct)},
2075  {"n_distinct_inherited", RELOPT_TYPE_REAL, offsetof(AttributeOpts, n_distinct_inherited)}
2076  };
2077 
2078  return (bytea *) build_reloptions(reloptions, validate,
2080  sizeof(AttributeOpts),
2081  tab, lengthof(tab));
2082 }
#define lengthof(array)
Definition: c.h:777
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:1910
@ RELOPT_KIND_ATTRIBUTE
Definition: reloptions.h:48
Definition: c.h:676

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

Referenced by ATExecSetOptions(), and get_attribute_options().

◆ build_local_reloptions()

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

Definition at line 1947 of file reloptions.c.

1948 {
1949  int noptions = list_length(relopts->options);
1950  relopt_parse_elt *elems = palloc(sizeof(*elems) * noptions);
1951  relopt_value *vals;
1952  void *opts;
1953  int i = 0;
1954  ListCell *lc;
1955 
1956  foreach(lc, relopts->options)
1957  {
1958  local_relopt *opt = lfirst(lc);
1959 
1960  elems[i].optname = opt->option->name;
1961  elems[i].opttype = opt->option->type;
1962  elems[i].offset = opt->offset;
1963 
1964  i++;
1965  }
1966 
1967  vals = parseLocalRelOptions(relopts, options, validate);
1969  fillRelOptions(opts, relopts->relopt_struct_size, vals, noptions, validate,
1970  elems, noptions);
1971 
1972  if (validate)
1973  foreach(lc, relopts->validators)
1974  ((relopts_validator) lfirst(lc)) (opts, vals, noptions);
1975 
1976  if (elems)
1977  pfree(elems);
1978 
1979  return opts;
1980 }
void pfree(void *pointer)
Definition: mcxt.c:1456
static AmcheckOptions opts
Definition: pg_amcheck.c:110
static int list_length(const List *l)
Definition: pg_list.h:152
static size_t noptions
static void * allocateReloptStruct(Size base, relopt_value *options, int numoptions)
Definition: reloptions.c:1704
static void fillRelOptions(void *rdopts, Size basesize, relopt_value *options, int numoptions, bool validate, const relopt_parse_elt *elems, int numelems)
Definition: reloptions.c:1744
static relopt_value * parseLocalRelOptions(local_relopts *relopts, Datum options, bool validate)
Definition: reloptions.c:1543
void(* relopts_validator)(void *parsed_options, relopt_value *vals, int nvals)
Definition: reloptions.h:137
List * validators
Definition: reloptions.h:168
Size relopt_struct_size
Definition: reloptions.h:169
const char * optname
Definition: reloptions.h:152
relopt_type opttype
Definition: reloptions.h:153

References allocateReloptStruct(), fillRelOptions(), i, 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, 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 1910 of file reloptions.c.

1915 {
1916  int numoptions;
1918  void *rdopts;
1919 
1920  /* parse options specific to given relation option kind */
1921  options = parseRelOptions(reloptions, validate, kind, &numoptions);
1922  Assert(numoptions <= num_relopt_elems);
1923 
1924  /* if none set, we're done */
1925  if (numoptions == 0)
1926  {
1927  Assert(options == NULL);
1928  return NULL;
1929  }
1930 
1931  /* allocate and fill the structure */
1932  rdopts = allocateReloptStruct(relopt_struct_size, options, numoptions);
1933  fillRelOptions(rdopts, relopt_struct_size, options, numoptions,
1934  validate, relopt_elems, num_relopt_elems);
1935 
1936  pfree(options);
1937 
1938  return rdopts;
1939 }
static char ** options
static relopt_value * parseRelOptions(Datum options, bool validate, relopt_kind kind, int *numrelopts)
Definition: reloptions.c:1501

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

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

1841 {
1842  static const relopt_parse_elt tab[] = {
1843  {"fillfactor", RELOPT_TYPE_INT, offsetof(StdRdOptions, fillfactor)},
1844  {"autovacuum_enabled", RELOPT_TYPE_BOOL,
1845  offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, enabled)},
1846  {"autovacuum_vacuum_threshold", RELOPT_TYPE_INT,
1847  offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, vacuum_threshold)},
1848  {"autovacuum_vacuum_insert_threshold", RELOPT_TYPE_INT,
1849  offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, vacuum_ins_threshold)},
1850  {"autovacuum_analyze_threshold", RELOPT_TYPE_INT,
1851  offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, analyze_threshold)},
1852  {"autovacuum_vacuum_cost_limit", RELOPT_TYPE_INT,
1853  offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, vacuum_cost_limit)},
1854  {"autovacuum_freeze_min_age", RELOPT_TYPE_INT,
1855  offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, freeze_min_age)},
1856  {"autovacuum_freeze_max_age", RELOPT_TYPE_INT,
1857  offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, freeze_max_age)},
1858  {"autovacuum_freeze_table_age", RELOPT_TYPE_INT,
1859  offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, freeze_table_age)},
1860  {"autovacuum_multixact_freeze_min_age", RELOPT_TYPE_INT,
1861  offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, multixact_freeze_min_age)},
1862  {"autovacuum_multixact_freeze_max_age", RELOPT_TYPE_INT,
1863  offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, multixact_freeze_max_age)},
1864  {"autovacuum_multixact_freeze_table_age", RELOPT_TYPE_INT,
1865  offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, multixact_freeze_table_age)},
1866  {"log_autovacuum_min_duration", RELOPT_TYPE_INT,
1867  offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, log_min_duration)},
1868  {"toast_tuple_target", RELOPT_TYPE_INT,
1869  offsetof(StdRdOptions, toast_tuple_target)},
1870  {"autovacuum_vacuum_cost_delay", RELOPT_TYPE_REAL,
1871  offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, vacuum_cost_delay)},
1872  {"autovacuum_vacuum_scale_factor", RELOPT_TYPE_REAL,
1873  offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, vacuum_scale_factor)},
1874  {"autovacuum_vacuum_insert_scale_factor", RELOPT_TYPE_REAL,
1875  offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, vacuum_ins_scale_factor)},
1876  {"autovacuum_analyze_scale_factor", RELOPT_TYPE_REAL,
1877  offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, analyze_scale_factor)},
1878  {"user_catalog_table", RELOPT_TYPE_BOOL,
1879  offsetof(StdRdOptions, user_catalog_table)},
1880  {"parallel_workers", RELOPT_TYPE_INT,
1881  offsetof(StdRdOptions, parallel_workers)},
1882  {"vacuum_index_cleanup", RELOPT_TYPE_ENUM,
1883  offsetof(StdRdOptions, vacuum_index_cleanup)},
1884  {"vacuum_truncate", RELOPT_TYPE_BOOL,
1885  offsetof(StdRdOptions, vacuum_truncate)}
1886  };
1887 
1888  return (bytea *) build_reloptions(reloptions, validate, kind,
1889  sizeof(StdRdOptions),
1890  tab, lengthof(tab));
1891 }
int fillfactor
Definition: pgbench.c:187
double vacuum_cost_delay
Definition: vacuum.c:82
int vacuum_cost_limit
Definition: vacuum.c:83

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

Referenced by heap_reloptions().

◆ extractRelOptions()

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

Definition at line 1381 of file reloptions.c.

1383 {
1384  bytea *options;
1385  bool isnull;
1386  Datum datum;
1387  Form_pg_class classForm;
1388 
1389  datum = fastgetattr(tuple,
1390  Anum_pg_class_reloptions,
1391  tupdesc,
1392  &isnull);
1393  if (isnull)
1394  return NULL;
1395 
1396  classForm = (Form_pg_class) GETSTRUCT(tuple);
1397 
1398  /* Parse into appropriate format; don't error out here */
1399  switch (classForm->relkind)
1400  {
1401  case RELKIND_RELATION:
1402  case RELKIND_TOASTVALUE:
1403  case RELKIND_MATVIEW:
1404  options = heap_reloptions(classForm->relkind, datum, false);
1405  break;
1406  case RELKIND_PARTITIONED_TABLE:
1407  options = partitioned_table_reloptions(datum, false);
1408  break;
1409  case RELKIND_VIEW:
1410  options = view_reloptions(datum, false);
1411  break;
1412  case RELKIND_INDEX:
1413  case RELKIND_PARTITIONED_INDEX:
1414  options = index_reloptions(amoptions, datum, false);
1415  break;
1416  case RELKIND_FOREIGN_TABLE:
1417  options = NULL;
1418  break;
1419  default:
1420  Assert(false); /* can't get here */
1421  options = NULL; /* keep compiler quiet */
1422  break;
1423  }
1424 
1425  return options;
1426 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:653
static Datum fastgetattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
Definition: htup_details.h:749
FormData_pg_class * Form_pg_class
Definition: pg_class.h:153
uintptr_t Datum
Definition: postgres.h:64
bytea * index_reloptions(amoptions_function amoptions, Datum reloptions, bool validate)
Definition: reloptions.c:2056
bytea * heap_reloptions(char relkind, Datum reloptions, bool validate)
Definition: reloptions.c:2021
bytea * view_reloptions(Datum reloptions, bool validate)
Definition: reloptions.c:2000
bytea * partitioned_table_reloptions(Datum reloptions, bool validate)
Definition: reloptions.c:1986

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

1748 {
1749  int i;
1750  int offset = basesize;
1751 
1752  for (i = 0; i < numoptions; i++)
1753  {
1754  int j;
1755  bool found = false;
1756 
1757  for (j = 0; j < numelems; j++)
1758  {
1759  if (strcmp(options[i].gen->name, elems[j].optname) == 0)
1760  {
1761  relopt_string *optstring;
1762  char *itempos = ((char *) rdopts) + elems[j].offset;
1763  char *string_val;
1764 
1765  switch (options[i].gen->type)
1766  {
1767  case RELOPT_TYPE_BOOL:
1768  *(bool *) itempos = options[i].isset ?
1769  options[i].values.bool_val :
1770  ((relopt_bool *) options[i].gen)->default_val;
1771  break;
1772  case RELOPT_TYPE_INT:
1773  *(int *) itempos = options[i].isset ?
1774  options[i].values.int_val :
1775  ((relopt_int *) options[i].gen)->default_val;
1776  break;
1777  case RELOPT_TYPE_REAL:
1778  *(double *) itempos = options[i].isset ?
1779  options[i].values.real_val :
1780  ((relopt_real *) options[i].gen)->default_val;
1781  break;
1782  case RELOPT_TYPE_ENUM:
1783  *(int *) itempos = options[i].isset ?
1784  options[i].values.enum_val :
1785  ((relopt_enum *) options[i].gen)->default_val;
1786  break;
1787  case RELOPT_TYPE_STRING:
1788  optstring = (relopt_string *) options[i].gen;
1789  if (options[i].isset)
1790  string_val = options[i].values.string_val;
1791  else if (!optstring->default_isnull)
1792  string_val = optstring->default_val;
1793  else
1794  string_val = NULL;
1795 
1796  if (optstring->fill_cb)
1797  {
1798  Size size =
1799  optstring->fill_cb(string_val,
1800  (char *) rdopts + offset);
1801 
1802  if (size)
1803  {
1804  *(int *) itempos = offset;
1805  offset += size;
1806  }
1807  else
1808  *(int *) itempos = 0;
1809  }
1810  else if (string_val == NULL)
1811  *(int *) itempos = 0;
1812  else
1813  {
1814  strcpy((char *) rdopts + offset, string_val);
1815  *(int *) itempos = offset;
1816  offset += strlen(string_val) + 1;
1817  }
1818  break;
1819  default:
1820  elog(ERROR, "unsupported reloption type %d",
1821  options[i].gen->type);
1822  break;
1823  }
1824  found = true;
1825  break;
1826  }
1827  }
1828  if (validate && !found)
1829  elog(ERROR, "reloption \"%s\" not found in parse table",
1830  options[i].gen->name);
1831  }
1832  SET_VARSIZE(rdopts, offset);
1833 }
static Datum values[MAXATTR]
Definition: bootstrap.c:156
int j
Definition: isn.c:74
#define SET_VARSIZE(PTR, len)
Definition: varatt.h:305

References relopt_string::default_isnull, relopt_string::default_val, elog(), ERROR, relopt_string::fill_cb, i, 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, and values.

Referenced by build_local_reloptions(), and build_reloptions().

◆ heap_reloptions()

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

Definition at line 2021 of file reloptions.c.

2022 {
2023  StdRdOptions *rdopts;
2024 
2025  switch (relkind)
2026  {
2027  case RELKIND_TOASTVALUE:
2028  rdopts = (StdRdOptions *)
2029  default_reloptions(reloptions, validate, RELOPT_KIND_TOAST);
2030  if (rdopts != NULL)
2031  {
2032  /* adjust default-only parameters for TOAST relations */
2033  rdopts->fillfactor = 100;
2034  rdopts->autovacuum.analyze_threshold = -1;
2035  rdopts->autovacuum.analyze_scale_factor = -1;
2036  }
2037  return (bytea *) rdopts;
2038  case RELKIND_RELATION:
2039  case RELKIND_MATVIEW:
2040  return default_reloptions(reloptions, validate, RELOPT_KIND_HEAP);
2041  default:
2042  /* other relkinds are not supported */
2043  return NULL;
2044  }
2045 }
bytea * default_reloptions(Datum reloptions, bool validate, relopt_kind kind)
Definition: reloptions.c:1840
@ RELOPT_KIND_TOAST
Definition: reloptions.h:43
@ RELOPT_KIND_HEAP
Definition: reloptions.h:42
int analyze_threshold
Definition: rel.h:312
float8 analyze_scale_factor
Definition: rel.h:324
int fillfactor
Definition: rel.h:338
AutoVacOpts autovacuum
Definition: rel.h:340

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

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

2057 {
2058  Assert(amoptions != NULL);
2059 
2060  /* Assume function is strict */
2061  if (!PointerIsValid(DatumGetPointer(reloptions)))
2062  return NULL;
2063 
2064  return amoptions(reloptions, validate);
2065 }
#define PointerIsValid(pointer)
Definition: c.h:752
static Pointer DatumGetPointer(Datum X)
Definition: postgres.h:312

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

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

836 {
837  relopt_bool *newoption;
838 
839  newoption = (relopt_bool *) allocate_reloption(kinds, RELOPT_TYPE_BOOL,
840  name, desc, lockmode);
841  newoption->default_val = default_val;
842 
843  return newoption;
844 }
static relopt_gen * allocate_reloption(bits32 kinds, int type, const char *name, const char *desc, LOCKMODE lockmode)
Definition: reloptions.c:777
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 991 of file reloptions.c.

994 {
995  relopt_enum *newoption;
996 
997  newoption = (relopt_enum *) allocate_reloption(kinds, RELOPT_TYPE_ENUM,
998  name, desc, lockmode);
999  newoption->members = members;
1000  newoption->default_val = default_val;
1001  newoption->detailmsg = detailmsg;
1002 
1003  return newoption;
1004 }
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 883 of file reloptions.c.

886 {
887  relopt_int *newoption;
888 
889  newoption = (relopt_int *) allocate_reloption(kinds, RELOPT_TYPE_INT,
890  name, desc, lockmode);
891  newoption->default_val = default_val;
892  newoption->min = min_val;
893  newoption->max = max_val;
894 
895  return newoption;
896 }
int default_val
Definition: reloptions.h:100

References allocate_reloption(), relopt_int::default_val, relopt_int::max, 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 936 of file reloptions.c.

939 {
940  relopt_real *newoption;
941 
942  newoption = (relopt_real *) allocate_reloption(kinds, RELOPT_TYPE_REAL,
943  name, desc, lockmode);
944  newoption->default_val = default_val;
945  newoption->min = min_val;
946  newoption->max = max_val;
947 
948  return newoption;
949 }
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, 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 1055 of file reloptions.c.

1060 {
1061  relopt_string *newoption;
1062 
1063  /* make sure the validator/default combination is sane */
1064  if (validator)
1065  (validator) (default_val);
1066 
1067  newoption = (relopt_string *) allocate_reloption(kinds, RELOPT_TYPE_STRING,
1068  name, desc, lockmode);
1069  newoption->validate_cb = validator;
1070  newoption->fill_cb = filler;
1071  if (default_val)
1072  {
1073  if (kinds == RELOPT_KIND_LOCAL)
1074  newoption->default_val = strdup(default_val);
1075  else
1076  newoption->default_val = MemoryContextStrdup(TopMemoryContext, default_val);
1077  newoption->default_len = strlen(default_val);
1078  newoption->default_isnull = false;
1079  }
1080  else
1081  {
1082  newoption->default_val = "";
1083  newoption->default_len = 0;
1084  newoption->default_isnull = true;
1085  }
1086 
1087  return newoption;
1088 }
char * MemoryContextStrdup(MemoryContext context, const char *string)
Definition: mcxt.c:1631
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 582 of file reloptions.c.

583 {
584  int i;
585  int j;
586 
587  j = 0;
588  for (i = 0; boolRelOpts[i].gen.name; i++)
589  {
590  Assert(DoLockModesConflict(boolRelOpts[i].gen.lockmode,
592  j++;
593  }
594  for (i = 0; intRelOpts[i].gen.name; i++)
595  {
596  Assert(DoLockModesConflict(intRelOpts[i].gen.lockmode,
598  j++;
599  }
600  for (i = 0; realRelOpts[i].gen.name; i++)
601  {
602  Assert(DoLockModesConflict(realRelOpts[i].gen.lockmode,
604  j++;
605  }
606  for (i = 0; enumRelOpts[i].gen.name; i++)
607  {
608  Assert(DoLockModesConflict(enumRelOpts[i].gen.lockmode,
610  j++;
611  }
612  for (i = 0; stringRelOpts[i].gen.name; i++)
613  {
616  j++;
617  }
619 
620  if (relOpts)
621  pfree(relOpts);
623  (j + 1) * sizeof(relopt_gen *));
624 
625  j = 0;
626  for (i = 0; boolRelOpts[i].gen.name; i++)
627  {
628  relOpts[j] = &boolRelOpts[i].gen;
630  relOpts[j]->namelen = strlen(relOpts[j]->name);
631  j++;
632  }
633 
634  for (i = 0; intRelOpts[i].gen.name; i++)
635  {
636  relOpts[j] = &intRelOpts[i].gen;
638  relOpts[j]->namelen = strlen(relOpts[j]->name);
639  j++;
640  }
641 
642  for (i = 0; realRelOpts[i].gen.name; i++)
643  {
644  relOpts[j] = &realRelOpts[i].gen;
646  relOpts[j]->namelen = strlen(relOpts[j]->name);
647  j++;
648  }
649 
650  for (i = 0; enumRelOpts[i].gen.name; i++)
651  {
652  relOpts[j] = &enumRelOpts[i].gen;
654  relOpts[j]->namelen = strlen(relOpts[j]->name);
655  j++;
656  }
657 
658  for (i = 0; stringRelOpts[i].gen.name; i++)
659  {
660  relOpts[j] = &stringRelOpts[i].gen;
662  relOpts[j]->namelen = strlen(relOpts[j]->name);
663  j++;
664  }
665 
666  for (i = 0; i < num_custom_options; i++)
667  {
669  j++;
670  }
671 
672  /* add a list terminator */
673  relOpts[j] = NULL;
674 
675  /* flag the work is complete */
676  need_initialization = false;
677 }
bool DoLockModesConflict(LOCKMODE mode1, LOCKMODE mode2)
Definition: lock.c:571
void * MemoryContextAlloc(MemoryContext context, Size size)
Definition: mcxt.c:1021
static relopt_real realRelOpts[]
Definition: reloptions.c:390
static relopt_int intRelOpts[]
Definition: reloptions.c:175
static relopt_enum enumRelOpts[]
Definition: reloptions.c:510
static relopt_string stringRelOpts[]
Definition: reloptions.c:549
static relopt_bool boolRelOpts[]
Definition: reloptions.c:96
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 1571 of file reloptions.c.

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

References _, relopt_enum::default_val, relopt_enum::detailmsg, elog(), ereport, errcode(), errdetail(), errdetail_internal(), errmsg(), ERROR, 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, 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 1543 of file reloptions.c.

1544 {
1545  int nopts = list_length(relopts->options);
1546  relopt_value *values = palloc(sizeof(*values) * nopts);
1547  ListCell *lc;
1548  int i = 0;
1549 
1550  foreach(lc, relopts->options)
1551  {
1552  local_relopt *opt = lfirst(lc);
1553 
1554  values[i].gen = opt->option;
1555  values[i].isset = false;
1556 
1557  i++;
1558  }
1559 
1560  if (options != (Datum) 0)
1561  parseRelOptionsInternal(options, validate, values, nopts);
1562 
1563  return values;
1564 }
static void parseRelOptionsInternal(Datum options, bool validate, relopt_value *reloptions, int numoptions)
Definition: reloptions.c:1429

References i, lfirst, list_length(), local_relopt::option, local_relopts::options, palloc(), parseRelOptionsInternal(), 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 1501 of file reloptions.c.

1503 {
1504  relopt_value *reloptions = NULL;
1505  int numoptions = 0;
1506  int i;
1507  int j;
1508 
1509  if (need_initialization)
1511 
1512  /* Build a list of expected options, based on kind */
1513 
1514  for (i = 0; relOpts[i]; i++)
1515  if (relOpts[i]->kinds & kind)
1516  numoptions++;
1517 
1518  if (numoptions > 0)
1519  {
1520  reloptions = palloc(numoptions * sizeof(relopt_value));
1521 
1522  for (i = 0, j = 0; relOpts[i]; i++)
1523  {
1524  if (relOpts[i]->kinds & kind)
1525  {
1526  reloptions[j].gen = relOpts[i];
1527  reloptions[j].isset = false;
1528  j++;
1529  }
1530  }
1531  }
1532 
1533  /* Done if no options */
1535  parseRelOptionsInternal(options, validate, reloptions, numoptions);
1536 
1537  *numrelopts = numoptions;
1538  return reloptions;
1539 }

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

Referenced by build_reloptions().

◆ parseRelOptionsInternal()

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

Definition at line 1429 of file reloptions.c.

1431 {
1433  Datum *optiondatums;
1434  int noptions;
1435  int i;
1436 
1437  deconstruct_array_builtin(array, TEXTOID, &optiondatums, NULL, &noptions);
1438 
1439  for (i = 0; i < noptions; i++)
1440  {
1441  char *text_str = VARDATA(optiondatums[i]);
1442  int text_len = VARSIZE(optiondatums[i]) - VARHDRSZ;
1443  int j;
1444 
1445  /* Search for a match in reloptions */
1446  for (j = 0; j < numoptions; j++)
1447  {
1448  int kw_len = reloptions[j].gen->namelen;
1449 
1450  if (text_len > kw_len && text_str[kw_len] == '=' &&
1451  strncmp(text_str, reloptions[j].gen->name, kw_len) == 0)
1452  {
1453  parse_one_reloption(&reloptions[j], text_str, text_len,
1454  validate);
1455  break;
1456  }
1457  }
1458 
1459  if (j >= numoptions && validate)
1460  {
1461  char *s;
1462  char *p;
1463 
1464  s = TextDatumGetCString(optiondatums[i]);
1465  p = strchr(s, '=');
1466  if (p)
1467  *p = '\0';
1468  ereport(ERROR,
1469  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1470  errmsg("unrecognized parameter \"%s\"", s)));
1471  }
1472  }
1473 
1474  /* It's worth avoiding memory leaks in this function */
1475  pfree(optiondatums);
1476 
1477  if (((void *) array) != DatumGetPointer(options))
1478  pfree(array);
1479 }
#define DatumGetArrayTypeP(X)
Definition: array.h:254
void deconstruct_array_builtin(ArrayType *array, Oid elmtype, Datum **elemsp, bool **nullsp, int *nelemsp)
Definition: arrayfuncs.c:3644
#define TextDatumGetCString(d)
Definition: builtins.h:95
#define VARHDRSZ
Definition: c.h:681
static void parse_one_reloption(relopt_value *option, char *text_str, int text_len, bool validate)
Definition: reloptions.c:1571
#define VARDATA(PTR)
Definition: varatt.h:278
#define VARSIZE(PTR)
Definition: varatt.h:279

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

Referenced by parseLocalRelOptions(), and parseRelOptions().

◆ partitioned_table_reloptions()

bytea* partitioned_table_reloptions ( Datum  reloptions,
bool  validate 
)

Definition at line 1986 of file reloptions.c.

1987 {
1988  if (validate && reloptions)
1989  ereport(ERROR,
1990  errcode(ERRCODE_WRONG_OBJECT_TYPE),
1991  errmsg("cannot specify storage parameters for a partitioned table"),
1992  errhint("Specify storage parameters for its leaf partitions instead."));
1993  return NULL;
1994 }
int errhint(const char *fmt,...)
Definition: elog.c:1316

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

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

◆ register_reloptions_validator()

void register_reloptions_validator ( local_relopts relopts,
relopts_validator  validator 
)

Definition at line 749 of file reloptions.c.

750 {
751  relopts->validators = lappend(relopts->validators, validator);
752 }

References lappend(), and local_relopts::validators.

Referenced by ltree_gist_options().

◆ tablespace_reloptions()

bytea* tablespace_reloptions ( Datum  reloptions,
bool  validate 
)

Definition at line 2088 of file reloptions.c.

2089 {
2090  static const relopt_parse_elt tab[] = {
2091  {"random_page_cost", RELOPT_TYPE_REAL, offsetof(TableSpaceOpts, random_page_cost)},
2092  {"seq_page_cost", RELOPT_TYPE_REAL, offsetof(TableSpaceOpts, seq_page_cost)},
2093  {"effective_io_concurrency", RELOPT_TYPE_INT, offsetof(TableSpaceOpts, effective_io_concurrency)},
2094  {"maintenance_io_concurrency", RELOPT_TYPE_INT, offsetof(TableSpaceOpts, maintenance_io_concurrency)}
2095  };
2096 
2097  return (bytea *) build_reloptions(reloptions, validate,
2099  sizeof(TableSpaceOpts),
2100  tab, lengthof(tab));
2101 }
int maintenance_io_concurrency
Definition: bufmgr.c:153
int effective_io_concurrency
Definition: bufmgr.c:146
double random_page_cost
Definition: costsize.c:121
double seq_page_cost
Definition: costsize.c:120
@ 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, and seq_page_cost.

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

◆ transformRelOptions()

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

Definition at line 1158 of file reloptions.c.

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

References accumArrayResult(), DefElem::arg, CurrentMemoryContext, DatumGetArrayTypeP, DatumGetPointer(), deconstruct_array_builtin(), defGetBoolean(), defGetString(), DefElem::defname, DefElem::defnamespace, ereport, errcode(), errmsg(), ERROR, i, len, lfirst, makeArrayResult(), NIL, palloc(), PointerGetDatum(), PointerIsValid, 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 1333 of file reloptions.c.

1334 {
1335  List *result = NIL;
1336  ArrayType *array;
1337  Datum *optiondatums;
1338  int noptions;
1339  int i;
1340 
1341  /* Nothing to do if no options */
1343  return result;
1344 
1345  array = DatumGetArrayTypeP(options);
1346 
1347  deconstruct_array_builtin(array, TEXTOID, &optiondatums, NULL, &noptions);
1348 
1349  for (i = 0; i < noptions; i++)
1350  {
1351  char *s;
1352  char *p;
1353  Node *val = NULL;
1354 
1355  s = TextDatumGetCString(optiondatums[i]);
1356  p = strchr(s, '=');
1357  if (p)
1358  {
1359  *p++ = '\0';
1360  val = (Node *) makeString(p);
1361  }
1362  result = lappend(result, makeDefElem(s, val, -1));
1363  }
1364 
1365  return result;
1366 }
DefElem * makeDefElem(char *name, Node *arg, int location)
Definition: makefuncs.c:549
Definition: pg_list.h:54
Definition: nodes.h:129
String * makeString(char *str)
Definition: value.c:63

References DatumGetArrayTypeP, DatumGetPointer(), deconstruct_array_builtin(), i, lappend(), makeDefElem(), makeString(), NIL, noptions, PointerIsValid, TextDatumGetCString, and val.

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

◆ view_reloptions()

bytea* view_reloptions ( Datum  reloptions,
bool  validate 
)

Definition at line 2000 of file reloptions.c.

2001 {
2002  static const relopt_parse_elt tab[] = {
2003  {"security_barrier", RELOPT_TYPE_BOOL,
2004  offsetof(ViewOptions, security_barrier)},
2005  {"security_invoker", RELOPT_TYPE_BOOL,
2006  offsetof(ViewOptions, security_invoker)},
2007  {"check_option", RELOPT_TYPE_ENUM,
2008  offsetof(ViewOptions, check_option)}
2009  };
2010 
2011  return (bytea *) build_reloptions(reloptions, validate,
2013  sizeof(ViewOptions),
2014  tab, lengthof(tab));
2015 }
@ RELOPT_KIND_VIEW
Definition: reloptions.h:51

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

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

Variable Documentation

◆ boolRelOpts

relopt_bool boolRelOpts[]
static

Definition at line 96 of file reloptions.c.

Referenced by initialize_reloptions().

◆ custom_options

relopt_gen** custom_options = NULL
static

Definition at line 559 of file reloptions.c.

Referenced by add_reloption(), and initialize_reloptions().

◆ enumRelOpts

relopt_enum enumRelOpts[]
static

Definition at line 510 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 493 of file reloptions.c.

◆ intRelOpts

relopt_int intRelOpts[]
static

Definition at line 175 of file reloptions.c.

Referenced by initialize_reloptions().

◆ last_assigned_kind

bits32 last_assigned_kind = RELOPT_KIND_LAST_DEFAULT
static

Definition at line 556 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 558 of file reloptions.c.

Referenced by add_reloption(), and initialize_reloptions().

◆ realRelOpts

relopt_real realRelOpts[]
static

Definition at line 390 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 478 of file reloptions.c.

◆ stringRelOpts

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

Definition at line 549 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:404
@ VIEW_OPTION_CHECK_OPTION_CASCADED
Definition: rel.h:405

Definition at line 502 of file reloptions.c.