PostgreSQL Source Code  git master
guc_funcs.c File Reference
#include "postgres.h"
#include <sys/stat.h>
#include <unistd.h>
#include "access/xact.h"
#include "catalog/objectaccess.h"
#include "catalog/pg_authid.h"
#include "catalog/pg_parameter_acl.h"
#include "funcapi.h"
#include "guc_internal.h"
#include "parser/parse_type.h"
#include "utils/acl.h"
#include "utils/backend_status.h"
#include "utils/builtins.h"
#include "utils/guc_tables.h"
#include "utils/snapmgr.h"
Include dependency graph for guc_funcs.c:

Go to the source code of this file.

Macros

#define MAX_GUC_FLAGS   6
 
#define NUM_PG_SETTINGS_ATTS   17
 
#define NUM_PG_FILE_SETTINGS_ATTS   7
 

Functions

static char * flatten_set_variable_args (const char *name, List *args)
 
static void ShowGUCConfigOption (const char *name, DestReceiver *dest)
 
static void ShowAllGUCConfig (DestReceiver *dest)
 
void ExecSetVariableStmt (VariableSetStmt *stmt, bool isTopLevel)
 
char * ExtractSetVariableArgs (VariableSetStmt *stmt)
 
void SetPGVariable (const char *name, List *args, bool is_local)
 
Datum set_config_by_name (PG_FUNCTION_ARGS)
 
void GetPGVariable (const char *name, DestReceiver *dest)
 
TupleDesc GetPGVariableResultDesc (const char *name)
 
Datum pg_settings_get_flags (PG_FUNCTION_ARGS)
 
static void GetConfigOptionValues (struct config_generic *conf, const char **values, bool *noshow)
 
Datum show_config_by_name (PG_FUNCTION_ARGS)
 
Datum show_config_by_name_missing_ok (PG_FUNCTION_ARGS)
 
Datum show_all_settings (PG_FUNCTION_ARGS)
 
Datum show_all_file_settings (PG_FUNCTION_ARGS)
 

Macro Definition Documentation

◆ MAX_GUC_FLAGS

#define MAX_GUC_FLAGS   6

◆ NUM_PG_FILE_SETTINGS_ATTS

#define NUM_PG_FILE_SETTINGS_ATTS   7

◆ NUM_PG_SETTINGS_ATTS

#define NUM_PG_SETTINGS_ATTS   17

Definition at line 841 of file guc_funcs.c.

Function Documentation

◆ ExecSetVariableStmt()

void ExecSetVariableStmt ( VariableSetStmt stmt,
bool  isTopLevel 
)

Definition at line 43 of file guc_funcs.c.

44 {
46 
47  /*
48  * Workers synchronize these parameters at the start of the parallel
49  * operation; then, we block SET during the operation.
50  */
51  if (IsInParallelMode())
52  ereport(ERROR,
53  (errcode(ERRCODE_INVALID_TRANSACTION_STATE),
54  errmsg("cannot set parameters during a parallel operation")));
55 
56  switch (stmt->kind)
57  {
58  case VAR_SET_VALUE:
59  case VAR_SET_CURRENT:
60  if (stmt->is_local)
61  WarnNoTransactionBlock(isTopLevel, "SET LOCAL");
62  (void) set_config_option(stmt->name,
66  action, true, 0, false);
67  break;
68  case VAR_SET_MULTI:
69 
70  /*
71  * Special-case SQL syntaxes. The TRANSACTION and SESSION
72  * CHARACTERISTICS cases effectively set more than one variable
73  * per statement. TRANSACTION SNAPSHOT only takes one argument,
74  * but we put it here anyway since it's a special case and not
75  * related to any GUC variable.
76  */
77  if (strcmp(stmt->name, "TRANSACTION") == 0)
78  {
79  ListCell *head;
80 
81  WarnNoTransactionBlock(isTopLevel, "SET TRANSACTION");
82 
83  foreach(head, stmt->args)
84  {
85  DefElem *item = (DefElem *) lfirst(head);
86 
87  if (strcmp(item->defname, "transaction_isolation") == 0)
88  SetPGVariable("transaction_isolation",
89  list_make1(item->arg), stmt->is_local);
90  else if (strcmp(item->defname, "transaction_read_only") == 0)
91  SetPGVariable("transaction_read_only",
92  list_make1(item->arg), stmt->is_local);
93  else if (strcmp(item->defname, "transaction_deferrable") == 0)
94  SetPGVariable("transaction_deferrable",
95  list_make1(item->arg), stmt->is_local);
96  else
97  elog(ERROR, "unexpected SET TRANSACTION element: %s",
98  item->defname);
99  }
100  }
101  else if (strcmp(stmt->name, "SESSION CHARACTERISTICS") == 0)
102  {
103  ListCell *head;
104 
105  foreach(head, stmt->args)
106  {
107  DefElem *item = (DefElem *) lfirst(head);
108 
109  if (strcmp(item->defname, "transaction_isolation") == 0)
110  SetPGVariable("default_transaction_isolation",
111  list_make1(item->arg), stmt->is_local);
112  else if (strcmp(item->defname, "transaction_read_only") == 0)
113  SetPGVariable("default_transaction_read_only",
114  list_make1(item->arg), stmt->is_local);
115  else if (strcmp(item->defname, "transaction_deferrable") == 0)
116  SetPGVariable("default_transaction_deferrable",
117  list_make1(item->arg), stmt->is_local);
118  else
119  elog(ERROR, "unexpected SET SESSION element: %s",
120  item->defname);
121  }
122  }
123  else if (strcmp(stmt->name, "TRANSACTION SNAPSHOT") == 0)
124  {
125  A_Const *con = linitial_node(A_Const, stmt->args);
126 
127  if (stmt->is_local)
128  ereport(ERROR,
129  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
130  errmsg("SET LOCAL TRANSACTION SNAPSHOT is not implemented")));
131 
132  WarnNoTransactionBlock(isTopLevel, "SET TRANSACTION");
133  ImportSnapshot(strVal(&con->val));
134  }
135  else
136  elog(ERROR, "unexpected SET MULTI element: %s",
137  stmt->name);
138  break;
139  case VAR_SET_DEFAULT:
140  if (stmt->is_local)
141  WarnNoTransactionBlock(isTopLevel, "SET LOCAL");
142  /* fall through */
143  case VAR_RESET:
144  (void) set_config_option(stmt->name,
145  NULL,
148  action, true, 0, false);
149  break;
150  case VAR_RESET_ALL:
151  ResetAllOptions();
152  break;
153  }
154 
155  /* Invoke the post-alter hook for setting this GUC variable, by name. */
156  InvokeObjectPostAlterHookArgStr(ParameterAclRelationId, stmt->name,
157  ACL_SET, stmt->kind, false);
158 }
int errcode(int sqlerrcode)
Definition: elog.c:695
int errmsg(const char *fmt,...)
Definition: elog.c:906
#define ERROR
Definition: elog.h:35
#define ereport(elevel,...)
Definition: elog.h:145
void ResetAllOptions(void)
Definition: guc.c:1951
int set_config_option(const char *name, const char *value, GucContext context, GucSource source, GucAction action, bool changeVal, int elevel, bool is_reload)
Definition: guc.c:3266
GucAction
Definition: guc.h:195
@ GUC_ACTION_SET
Definition: guc.h:197
@ GUC_ACTION_LOCAL
Definition: guc.h:198
@ PGC_S_SESSION
Definition: guc.h:122
@ PGC_SUSET
Definition: guc.h:74
@ PGC_USERSET
Definition: guc.h:75
void SetPGVariable(const char *name, List *args, bool is_local)
Definition: guc_funcs.c:315
char * ExtractSetVariableArgs(VariableSetStmt *stmt)
Definition: guc_funcs.c:167
#define InvokeObjectPostAlterHookArgStr(classId, objectName, subId, auxiliaryId, is_internal)
Definition: objectaccess.h:247
#define ACL_SET
Definition: parsenodes.h:95
@ VAR_SET_DEFAULT
Definition: parsenodes.h:2245
@ VAR_RESET
Definition: parsenodes.h:2248
@ VAR_SET_MULTI
Definition: parsenodes.h:2247
@ VAR_SET_VALUE
Definition: parsenodes.h:2244
@ VAR_SET_CURRENT
Definition: parsenodes.h:2246
@ VAR_RESET_ALL
Definition: parsenodes.h:2249
#define lfirst(lc)
Definition: pg_list.h:170
#define linitial_node(type, l)
Definition: pg_list.h:179
#define list_make1(x1)
Definition: pg_list.h:210
void ImportSnapshot(const char *idstr)
Definition: snapmgr.c:1396
union ValUnion val
Definition: parsenodes.h:329
char * defname
Definition: parsenodes.h:779
Node * arg
Definition: parsenodes.h:780
VariableSetKind kind
Definition: parsenodes.h:2255
bool superuser(void)
Definition: superuser.c:46
#define strVal(v)
Definition: value.h:82
void WarnNoTransactionBlock(bool isTopLevel, const char *stmtType)
Definition: xact.c:3531
bool IsInParallelMode(void)
Definition: xact.c:1068

References ACL_SET, generate_unaccent_rules::action, DefElem::arg, VariableSetStmt::args, DefElem::defname, elog(), ereport, errcode(), errmsg(), ERROR, ExtractSetVariableArgs(), GUC_ACTION_LOCAL, GUC_ACTION_SET, ImportSnapshot(), InvokeObjectPostAlterHookArgStr, VariableSetStmt::is_local, IsInParallelMode(), VariableSetStmt::kind, lfirst, linitial_node, list_make1, VariableSetStmt::name, PGC_S_SESSION, PGC_SUSET, PGC_USERSET, ResetAllOptions(), set_config_option(), SetPGVariable(), strVal, superuser(), A_Const::val, VAR_RESET, VAR_RESET_ALL, VAR_SET_CURRENT, VAR_SET_DEFAULT, VAR_SET_MULTI, VAR_SET_VALUE, and WarnNoTransactionBlock().

Referenced by standard_ProcessUtility().

◆ ExtractSetVariableArgs()

char* ExtractSetVariableArgs ( VariableSetStmt stmt)

Definition at line 167 of file guc_funcs.c.

168 {
169  switch (stmt->kind)
170  {
171  case VAR_SET_VALUE:
172  return flatten_set_variable_args(stmt->name, stmt->args);
173  case VAR_SET_CURRENT:
174  return GetConfigOptionByName(stmt->name, NULL, false);
175  default:
176  return NULL;
177  }
178 }
char * GetConfigOptionByName(const char *name, const char **varname, bool missing_ok)
Definition: guc.c:5235
static char * flatten_set_variable_args(const char *name, List *args)
Definition: guc_funcs.c:192

References VariableSetStmt::args, flatten_set_variable_args(), GetConfigOptionByName(), VariableSetStmt::kind, VariableSetStmt::name, VAR_SET_CURRENT, and VAR_SET_VALUE.

Referenced by AlterSetting(), AlterSystemSetConfigFile(), ExecSetVariableStmt(), and update_proconfig_value().

◆ flatten_set_variable_args()

static char * flatten_set_variable_args ( const char *  name,
List args 
)
static

Definition at line 192 of file guc_funcs.c.

193 {
194  struct config_generic *record;
195  int flags;
197  ListCell *l;
198 
199  /* Fast path if just DEFAULT */
200  if (args == NIL)
201  return NULL;
202 
203  /*
204  * Get flags for the variable; if it's not known, use default flags.
205  * (Caller might throw error later, but not our business to do so here.)
206  */
207  record = find_option(name, false, true, WARNING);
208  if (record)
209  flags = record->flags;
210  else
211  flags = 0;
212 
213  /* Complain if list input and non-list variable */
214  if ((flags & GUC_LIST_INPUT) == 0 &&
215  list_length(args) != 1)
216  ereport(ERROR,
217  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
218  errmsg("SET %s takes only one argument", name)));
219 
221 
222  /*
223  * Each list member may be a plain A_Const node, or an A_Const within a
224  * TypeCast; the latter case is supported only for ConstInterval arguments
225  * (for SET TIME ZONE).
226  */
227  foreach(l, args)
228  {
229  Node *arg = (Node *) lfirst(l);
230  char *val;
231  TypeName *typeName = NULL;
232  A_Const *con;
233 
234  if (l != list_head(args))
235  appendStringInfoString(&buf, ", ");
236 
237  if (IsA(arg, TypeCast))
238  {
239  TypeCast *tc = (TypeCast *) arg;
240 
241  arg = tc->arg;
242  typeName = tc->typeName;
243  }
244 
245  if (!IsA(arg, A_Const))
246  elog(ERROR, "unrecognized node type: %d", (int) nodeTag(arg));
247  con = (A_Const *) arg;
248 
249  switch (nodeTag(&con->val))
250  {
251  case T_Integer:
252  appendStringInfo(&buf, "%d", intVal(&con->val));
253  break;
254  case T_Float:
255  /* represented as a string, so just copy it */
256  appendStringInfoString(&buf, castNode(Float, &con->val)->fval);
257  break;
258  case T_String:
259  val = strVal(&con->val);
260  if (typeName != NULL)
261  {
262  /*
263  * Must be a ConstInterval argument for TIME ZONE. Coerce
264  * to interval and back to normalize the value and account
265  * for any typmod.
266  */
267  Oid typoid;
268  int32 typmod;
269  Datum interval;
270  char *intervalout;
271 
272  typenameTypeIdAndMod(NULL, typeName, &typoid, &typmod);
273  Assert(typoid == INTERVALOID);
274 
275  interval =
279  Int32GetDatum(typmod));
280 
281  intervalout =
283  interval));
284  appendStringInfo(&buf, "INTERVAL '%s'", intervalout);
285  }
286  else
287  {
288  /*
289  * Plain string literal or identifier. For quote mode,
290  * quote it if it's not a vanilla identifier.
291  */
292  if (flags & GUC_LIST_QUOTE)
294  else
296  }
297  break;
298  default:
299  elog(ERROR, "unrecognized node type: %d",
300  (int) nodeTag(&con->val));
301  break;
302  }
303  }
304 
305  return buf.data;
306 }
Datum interval_out(PG_FUNCTION_ARGS)
Definition: timestamp.c:954
Datum interval_in(PG_FUNCTION_ARGS)
Definition: timestamp.c:882
signed int int32
Definition: c.h:430
#define WARNING
Definition: elog.h:32
const char * name
Definition: encode.c:561
#define DirectFunctionCall1(func, arg1)
Definition: fmgr.h:642
#define DirectFunctionCall3(func, arg1, arg2, arg3)
Definition: fmgr.h:646
struct config_generic * find_option(const char *name, bool create_placeholders, bool skip_errors, int elevel)
Definition: guc.c:1163
#define GUC_LIST_QUOTE
Definition: guc.h:209
#define GUC_LIST_INPUT
Definition: guc.h:208
long val
Definition: informix.c:664
Assert(fmt[strlen(fmt) - 1] !='\n')
#define IsA(nodeptr, _type_)
Definition: nodes.h:168
#define nodeTag(nodeptr)
Definition: nodes.h:122
#define castNode(_type_, nodeptr)
Definition: nodes.h:186
void typenameTypeIdAndMod(ParseState *pstate, const TypeName *typeName, Oid *typeid_p, int32 *typmod_p)
Definition: parse_type.c:310
void * arg
static int list_length(const List *l)
Definition: pg_list.h:150
#define NIL
Definition: pg_list.h:66
static ListCell * list_head(const List *l)
Definition: pg_list.h:126
static char * buf
Definition: pg_test_fsync.c:67
static char * DatumGetCString(Datum X)
Definition: postgres.h:683
uintptr_t Datum
Definition: postgres.h:412
static Datum ObjectIdGetDatum(Oid X)
Definition: postgres.h:600
static Datum CStringGetDatum(const char *X)
Definition: postgres.h:698
static Datum Int32GetDatum(int32 X)
Definition: postgres.h:560
#define InvalidOid
Definition: postgres_ext.h:36
unsigned int Oid
Definition: postgres_ext.h:31
const char * quote_identifier(const char *ident)
Definition: ruleutils.c:11529
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:91
void appendStringInfoString(StringInfo str, const char *s)
Definition: stringinfo.c:176
void initStringInfo(StringInfo str)
Definition: stringinfo.c:59
Definition: value.h:48
Definition: nodes.h:118
TypeName * typeName
Definition: parsenodes.h:341
Node * arg
Definition: parsenodes.h:340
#define intVal(v)
Definition: value.h:79

References appendStringInfo(), appendStringInfoString(), arg, TypeCast::arg, generate_unaccent_rules::args, Assert(), buf, castNode, CStringGetDatum(), DatumGetCString(), DirectFunctionCall1, DirectFunctionCall3, elog(), ereport, errcode(), errmsg(), ERROR, find_option(), config_generic::flags, GUC_LIST_INPUT, GUC_LIST_QUOTE, initStringInfo(), Int32GetDatum(), interval_in(), interval_out(), intVal, InvalidOid, IsA, lfirst, list_head(), list_length(), name, NIL, nodeTag, ObjectIdGetDatum(), quote_identifier(), strVal, TypeCast::typeName, typenameTypeIdAndMod(), A_Const::val, val, and WARNING.

Referenced by ExtractSetVariableArgs(), and SetPGVariable().

◆ GetConfigOptionValues()

static void GetConfigOptionValues ( struct config_generic conf,
const char **  values,
bool noshow 
)
static

Definition at line 578 of file guc_funcs.c.

580 {
581  char buffer[256];
582 
583  if (noshow)
584  {
585  if ((conf->flags & GUC_NO_SHOW_ALL) ||
586  ((conf->flags & GUC_SUPERUSER_ONLY) &&
587  !has_privs_of_role(GetUserId(), ROLE_PG_READ_ALL_SETTINGS)))
588  *noshow = true;
589  else
590  *noshow = false;
591  }
592 
593  /* first get the generic attributes */
594 
595  /* name */
596  values[0] = conf->name;
597 
598  /* setting: use ShowGUCOption in order to avoid duplicating the logic */
599  values[1] = ShowGUCOption(conf, false);
600 
601  /* unit, if any (NULL is fine) */
602  values[2] = get_config_unit_name(conf->flags);
603 
604  /* group */
605  values[3] = _(config_group_names[conf->group]);
606 
607  /* short_desc */
608  values[4] = conf->short_desc != NULL ? _(conf->short_desc) : NULL;
609 
610  /* extra_desc */
611  values[5] = conf->long_desc != NULL ? _(conf->long_desc) : NULL;
612 
613  /* context */
614  values[6] = GucContext_Names[conf->context];
615 
616  /* vartype */
617  values[7] = config_type_names[conf->vartype];
618 
619  /* source */
620  values[8] = GucSource_Names[conf->source];
621 
622  /* now get the type specific attributes */
623  switch (conf->vartype)
624  {
625  case PGC_BOOL:
626  {
627  struct config_bool *lconf = (struct config_bool *) conf;
628 
629  /* min_val */
630  values[9] = NULL;
631 
632  /* max_val */
633  values[10] = NULL;
634 
635  /* enumvals */
636  values[11] = NULL;
637 
638  /* boot_val */
639  values[12] = pstrdup(lconf->boot_val ? "on" : "off");
640 
641  /* reset_val */
642  values[13] = pstrdup(lconf->reset_val ? "on" : "off");
643  }
644  break;
645 
646  case PGC_INT:
647  {
648  struct config_int *lconf = (struct config_int *) conf;
649 
650  /* min_val */
651  snprintf(buffer, sizeof(buffer), "%d", lconf->min);
652  values[9] = pstrdup(buffer);
653 
654  /* max_val */
655  snprintf(buffer, sizeof(buffer), "%d", lconf->max);
656  values[10] = pstrdup(buffer);
657 
658  /* enumvals */
659  values[11] = NULL;
660 
661  /* boot_val */
662  snprintf(buffer, sizeof(buffer), "%d", lconf->boot_val);
663  values[12] = pstrdup(buffer);
664 
665  /* reset_val */
666  snprintf(buffer, sizeof(buffer), "%d", lconf->reset_val);
667  values[13] = pstrdup(buffer);
668  }
669  break;
670 
671  case PGC_REAL:
672  {
673  struct config_real *lconf = (struct config_real *) conf;
674 
675  /* min_val */
676  snprintf(buffer, sizeof(buffer), "%g", lconf->min);
677  values[9] = pstrdup(buffer);
678 
679  /* max_val */
680  snprintf(buffer, sizeof(buffer), "%g", lconf->max);
681  values[10] = pstrdup(buffer);
682 
683  /* enumvals */
684  values[11] = NULL;
685 
686  /* boot_val */
687  snprintf(buffer, sizeof(buffer), "%g", lconf->boot_val);
688  values[12] = pstrdup(buffer);
689 
690  /* reset_val */
691  snprintf(buffer, sizeof(buffer), "%g", lconf->reset_val);
692  values[13] = pstrdup(buffer);
693  }
694  break;
695 
696  case PGC_STRING:
697  {
698  struct config_string *lconf = (struct config_string *) conf;
699 
700  /* min_val */
701  values[9] = NULL;
702 
703  /* max_val */
704  values[10] = NULL;
705 
706  /* enumvals */
707  values[11] = NULL;
708 
709  /* boot_val */
710  if (lconf->boot_val == NULL)
711  values[12] = NULL;
712  else
713  values[12] = pstrdup(lconf->boot_val);
714 
715  /* reset_val */
716  if (lconf->reset_val == NULL)
717  values[13] = NULL;
718  else
719  values[13] = pstrdup(lconf->reset_val);
720  }
721  break;
722 
723  case PGC_ENUM:
724  {
725  struct config_enum *lconf = (struct config_enum *) conf;
726 
727  /* min_val */
728  values[9] = NULL;
729 
730  /* max_val */
731  values[10] = NULL;
732 
733  /* enumvals */
734 
735  /*
736  * NOTE! enumvals with double quotes in them are not
737  * supported!
738  */
739  values[11] = config_enum_get_options((struct config_enum *) conf,
740  "{\"", "\"}", "\",\"");
741 
742  /* boot_val */
744  lconf->boot_val));
745 
746  /* reset_val */
748  lconf->reset_val));
749  }
750  break;
751 
752  default:
753  {
754  /*
755  * should never get here, but in case we do, set 'em to NULL
756  */
757 
758  /* min_val */
759  values[9] = NULL;
760 
761  /* max_val */
762  values[10] = NULL;
763 
764  /* enumvals */
765  values[11] = NULL;
766 
767  /* boot_val */
768  values[12] = NULL;
769 
770  /* reset_val */
771  values[13] = NULL;
772  }
773  break;
774  }
775 
776  /*
777  * If the setting came from a config file, set the source location. For
778  * security reasons, we don't show source file/line number for
779  * insufficiently-privileged users.
780  */
781  if (conf->source == PGC_S_FILE &&
782  has_privs_of_role(GetUserId(), ROLE_PG_READ_ALL_SETTINGS))
783  {
784  values[14] = conf->sourcefile;
785  snprintf(buffer, sizeof(buffer), "%d", conf->sourceline);
786  values[15] = pstrdup(buffer);
787  }
788  else
789  {
790  values[14] = NULL;
791  values[15] = NULL;
792  }
793 
794  values[16] = (conf->status & GUC_PENDING_RESTART) ? "t" : "f";
795 }
bool has_privs_of_role(Oid member, Oid role)
Definition: acl.c:4949
static Datum values[MAXATTR]
Definition: bootstrap.c:156
#define _(x)
Definition: elog.c:90
const char * config_enum_lookup_by_value(struct config_enum *record, int val)
Definition: guc.c:2958
char * ShowGUCOption(struct config_generic *record, bool use_units)
Definition: guc.c:5268
const char * get_config_unit_name(int flags)
Definition: guc.c:2749
char * config_enum_get_options(struct config_enum *record, const char *prefix, const char *suffix, const char *separator)
Definition: guc.c:3007
#define GUC_SUPERUSER_ONLY
Definition: guc.h:218
@ PGC_S_FILE
Definition: guc.h:112
#define GUC_NO_SHOW_ALL
Definition: guc.h:210
const char *const GucContext_Names[]
Definition: guc_tables.c:595
const char *const GucSource_Names[]
Definition: guc_tables.c:614
const char *const config_type_names[]
Definition: guc_tables.c:740
const char *const config_group_names[]
Definition: guc_tables.c:638
@ PGC_BOOL
Definition: guc_tables.h:25
@ PGC_STRING
Definition: guc_tables.h:28
@ PGC_ENUM
Definition: guc_tables.h:29
@ PGC_REAL
Definition: guc_tables.h:27
@ PGC_INT
Definition: guc_tables.h:26
#define GUC_PENDING_RESTART
Definition: guc_tables.h:191
char * pstrdup(const char *in)
Definition: mcxt.c:1483
Oid GetUserId(void)
Definition: miscinit.c:497
#define snprintf
Definition: port.h:238
bool reset_val
Definition: guc_tables.h:207
bool boot_val
Definition: guc_tables.h:202
enum config_group group
Definition: guc_tables.h:157
GucContext context
Definition: guc_tables.h:156
const char * long_desc
Definition: guc_tables.h:159
const char * name
Definition: guc_tables.h:155
const char * short_desc
Definition: guc_tables.h:158
char * sourcefile
Definition: guc_tables.h:180
enum config_type vartype
Definition: guc_tables.h:162
GucSource source
Definition: guc_tables.h:164
int reset_val
Definition: guc_tables.h:223
int boot_val
Definition: guc_tables.h:216
double boot_val
Definition: guc_tables.h:232
double reset_val
Definition: guc_tables.h:239
double min
Definition: guc_tables.h:233
double max
Definition: guc_tables.h:234
char * reset_val
Definition: guc_tables.h:253
const char * boot_val
Definition: guc_tables.h:248

References _, config_bool::boot_val, config_int::boot_val, config_real::boot_val, config_string::boot_val, config_enum::boot_val, config_enum_get_options(), config_enum_lookup_by_value(), config_group_names, config_type_names, config_generic::context, config_generic::flags, get_config_unit_name(), GetUserId(), config_generic::group, GUC_NO_SHOW_ALL, GUC_PENDING_RESTART, GUC_SUPERUSER_ONLY, GucContext_Names, GucSource_Names, has_privs_of_role(), config_generic::long_desc, config_int::max, config_real::max, config_int::min, config_real::min, config_generic::name, PGC_BOOL, PGC_ENUM, PGC_INT, PGC_REAL, PGC_S_FILE, PGC_STRING, pstrdup(), config_bool::reset_val, config_int::reset_val, config_real::reset_val, config_string::reset_val, config_enum::reset_val, config_generic::short_desc, ShowGUCOption(), snprintf, config_generic::source, config_generic::sourcefile, config_generic::sourceline, config_generic::status, values, and config_generic::vartype.

Referenced by show_all_settings().

◆ GetPGVariable()

void GetPGVariable ( const char *  name,
DestReceiver dest 
)

Definition at line 382 of file guc_funcs.c.

383 {
384  if (guc_name_compare(name, "all") == 0)
386  else
388 }
int guc_name_compare(const char *namea, const char *nameb)
Definition: guc.c:1265
static void ShowGUCConfigOption(const char *name, DestReceiver *dest)
Definition: guc_funcs.c:428
static void ShowAllGUCConfig(DestReceiver *dest)
Definition: guc_funcs.c:456

References generate_unaccent_rules::dest, guc_name_compare(), name, ShowAllGUCConfig(), and ShowGUCConfigOption().

Referenced by exec_replication_command(), and standard_ProcessUtility().

◆ GetPGVariableResultDesc()

TupleDesc GetPGVariableResultDesc ( const char *  name)

Definition at line 394 of file guc_funcs.c.

395 {
396  TupleDesc tupdesc;
397 
398  if (guc_name_compare(name, "all") == 0)
399  {
400  /* need a tuple descriptor representing three TEXT columns */
401  tupdesc = CreateTemplateTupleDesc(3);
402  TupleDescInitEntry(tupdesc, (AttrNumber) 1, "name",
403  TEXTOID, -1, 0);
404  TupleDescInitEntry(tupdesc, (AttrNumber) 2, "setting",
405  TEXTOID, -1, 0);
406  TupleDescInitEntry(tupdesc, (AttrNumber) 3, "description",
407  TEXTOID, -1, 0);
408  }
409  else
410  {
411  const char *varname;
412 
413  /* Get the canonical spelling of name */
414  (void) GetConfigOptionByName(name, &varname, false);
415 
416  /* need a tuple descriptor representing a single TEXT column */
417  tupdesc = CreateTemplateTupleDesc(1);
418  TupleDescInitEntry(tupdesc, (AttrNumber) 1, varname,
419  TEXTOID, -1, 0);
420  }
421  return tupdesc;
422 }
int16 AttrNumber
Definition: attnum.h:21
TupleDesc CreateTemplateTupleDesc(int natts)
Definition: tupdesc.c:45
void TupleDescInitEntry(TupleDesc desc, AttrNumber attributeNumber, const char *attributeName, Oid oidtypeid, int32 typmod, int attdim)
Definition: tupdesc.c:583

References CreateTemplateTupleDesc(), GetConfigOptionByName(), guc_name_compare(), name, and TupleDescInitEntry().

Referenced by UtilityTupleDescriptor().

◆ pg_settings_get_flags()

Datum pg_settings_get_flags ( PG_FUNCTION_ARGS  )

Definition at line 539 of file guc_funcs.c.

540 {
541 #define MAX_GUC_FLAGS 6
542  char *varname = TextDatumGetCString(PG_GETARG_DATUM(0));
543  struct config_generic *record;
544  int cnt = 0;
546  ArrayType *a;
547 
548  record = find_option(varname, false, true, ERROR);
549 
550  /* return NULL if no such variable */
551  if (record == NULL)
552  PG_RETURN_NULL();
553 
554  if (record->flags & GUC_EXPLAIN)
555  flags[cnt++] = CStringGetTextDatum("EXPLAIN");
556  if (record->flags & GUC_NO_RESET)
557  flags[cnt++] = CStringGetTextDatum("NO_RESET");
558  if (record->flags & GUC_NO_RESET_ALL)
559  flags[cnt++] = CStringGetTextDatum("NO_RESET_ALL");
560  if (record->flags & GUC_NO_SHOW_ALL)
561  flags[cnt++] = CStringGetTextDatum("NO_SHOW_ALL");
562  if (record->flags & GUC_NOT_IN_SAMPLE)
563  flags[cnt++] = CStringGetTextDatum("NOT_IN_SAMPLE");
564  if (record->flags & GUC_RUNTIME_COMPUTED)
565  flags[cnt++] = CStringGetTextDatum("RUNTIME_COMPUTED");
566 
567  Assert(cnt <= MAX_GUC_FLAGS);
568 
569  /* Returns the record as Datum */
570  a = construct_array_builtin(flags, cnt, TEXTOID);
572 }
#define PG_RETURN_ARRAYTYPE_P(x)
Definition: array.h:258
ArrayType * construct_array_builtin(Datum *elems, int nelems, Oid elmtype)
Definition: arrayfuncs.c:3338
#define CStringGetTextDatum(s)
Definition: builtins.h:85
#define TextDatumGetCString(d)
Definition: builtins.h:86
#define PG_GETARG_DATUM(n)
Definition: fmgr.h:268
#define PG_RETURN_NULL()
Definition: fmgr.h:345
#define GUC_EXPLAIN
Definition: guc.h:213
#define GUC_NO_RESET_ALL
Definition: guc.h:212
#define GUC_NO_RESET
Definition: guc.h:211
#define GUC_RUNTIME_COMPUTED
Definition: guc.h:223
#define GUC_NOT_IN_SAMPLE
Definition: guc.h:215
#define MAX_GUC_FLAGS
int a
Definition: isn.c:69

References a, Assert(), construct_array_builtin(), CStringGetTextDatum, ERROR, find_option(), config_generic::flags, GUC_EXPLAIN, GUC_NO_RESET, GUC_NO_RESET_ALL, GUC_NO_SHOW_ALL, GUC_NOT_IN_SAMPLE, GUC_RUNTIME_COMPUTED, MAX_GUC_FLAGS, PG_GETARG_DATUM, PG_RETURN_ARRAYTYPE_P, PG_RETURN_NULL, and TextDatumGetCString.

◆ set_config_by_name()

Datum set_config_by_name ( PG_FUNCTION_ARGS  )

Definition at line 332 of file guc_funcs.c.

333 {
334  char *name;
335  char *value;
336  char *new_value;
337  bool is_local;
338 
339  if (PG_ARGISNULL(0))
340  ereport(ERROR,
341  (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
342  errmsg("SET requires parameter name")));
343 
344  /* Get the GUC variable name */
346 
347  /* Get the desired value or set to NULL for a reset request */
348  if (PG_ARGISNULL(1))
349  value = NULL;
350  else
352 
353  /*
354  * Get the desired state of is_local. Default to false if provided value
355  * is NULL
356  */
357  if (PG_ARGISNULL(2))
358  is_local = false;
359  else
360  is_local = PG_GETARG_BOOL(2);
361 
362  /* Note SET DEFAULT (argstring == NULL) is equivalent to RESET */
363  (void) set_config_option(name,
364  value,
367  is_local ? GUC_ACTION_LOCAL : GUC_ACTION_SET,
368  true, 0, false);
369 
370  /* get the new current value */
371  new_value = GetConfigOptionByName(name, NULL, false);
372 
373  /* Convert return string to text */
374  PG_RETURN_TEXT_P(cstring_to_text(new_value));
375 }
#define PG_ARGISNULL(n)
Definition: fmgr.h:209
#define PG_RETURN_TEXT_P(x)
Definition: fmgr.h:372
#define PG_GETARG_BOOL(n)
Definition: fmgr.h:274
static struct @143 value
text * cstring_to_text(const char *s)
Definition: varlena.c:189

References cstring_to_text(), ereport, errcode(), errmsg(), ERROR, GetConfigOptionByName(), GUC_ACTION_LOCAL, GUC_ACTION_SET, name, PG_ARGISNULL, PG_GETARG_BOOL, PG_GETARG_DATUM, PG_RETURN_TEXT_P, PGC_S_SESSION, PGC_SUSET, PGC_USERSET, set_config_option(), superuser(), TextDatumGetCString, and value.

◆ SetPGVariable()

void SetPGVariable ( const char *  name,
List args,
bool  is_local 
)

Definition at line 315 of file guc_funcs.c.

316 {
317  char *argstring = flatten_set_variable_args(name, args);
318 
319  /* Note SET DEFAULT (argstring == NULL) is equivalent to RESET */
320  (void) set_config_option(name,
321  argstring,
324  is_local ? GUC_ACTION_LOCAL : GUC_ACTION_SET,
325  true, 0, false);
326 }

References generate_unaccent_rules::args, flatten_set_variable_args(), GUC_ACTION_LOCAL, GUC_ACTION_SET, name, PGC_S_SESSION, PGC_SUSET, PGC_USERSET, set_config_option(), and superuser().

Referenced by DiscardAll(), ExecSetVariableStmt(), and standard_ProcessUtility().

◆ show_all_file_settings()

Datum show_all_file_settings ( PG_FUNCTION_ARGS  )

Definition at line 988 of file guc_funcs.c.

989 {
990 #define NUM_PG_FILE_SETTINGS_ATTS 7
991  ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
992  ConfigVariable *conf;
993  int seqno;
994 
995  /* Scan the config files using current context as workspace */
997 
998  /* Build a tuplestore to return our results in */
999  InitMaterializedSRF(fcinfo, 0);
1000 
1001  /* Process the results and create a tuplestore */
1002  for (seqno = 1; conf != NULL; conf = conf->next, seqno++)
1003  {
1005  bool nulls[NUM_PG_FILE_SETTINGS_ATTS];
1006 
1007  memset(values, 0, sizeof(values));
1008  memset(nulls, 0, sizeof(nulls));
1009 
1010  /* sourcefile */
1011  if (conf->filename)
1012  values[0] = PointerGetDatum(cstring_to_text(conf->filename));
1013  else
1014  nulls[0] = true;
1015 
1016  /* sourceline (not meaningful if no sourcefile) */
1017  if (conf->filename)
1018  values[1] = Int32GetDatum(conf->sourceline);
1019  else
1020  nulls[1] = true;
1021 
1022  /* seqno */
1023  values[2] = Int32GetDatum(seqno);
1024 
1025  /* name */
1026  if (conf->name)
1027  values[3] = PointerGetDatum(cstring_to_text(conf->name));
1028  else
1029  nulls[3] = true;
1030 
1031  /* setting */
1032  if (conf->value)
1033  values[4] = PointerGetDatum(cstring_to_text(conf->value));
1034  else
1035  nulls[4] = true;
1036 
1037  /* applied */
1038  values[5] = BoolGetDatum(conf->applied);
1039 
1040  /* error */
1041  if (conf->errmsg)
1042  values[6] = PointerGetDatum(cstring_to_text(conf->errmsg));
1043  else
1044  nulls[6] = true;
1045 
1046  /* shove row into tuplestore */
1047  tuplestore_putvalues(rsinfo->setResult, rsinfo->setDesc, values, nulls);
1048  }
1049 
1050  return (Datum) 0;
1051 }
#define DEBUG3
Definition: elog.h:24
void InitMaterializedSRF(FunctionCallInfo fcinfo, bits32 flags)
Definition: funcapi.c:76
ConfigVariable * ProcessConfigFileInternal(GucContext context, bool applySettings, int elevel)
Definition: guc.c:275
@ PGC_SIGHUP
Definition: guc.h:71
#define NUM_PG_FILE_SETTINGS_ATTS
static Datum PointerGetDatum(const void *X)
Definition: postgres.h:670
static Datum BoolGetDatum(bool X)
Definition: postgres.h:450
TupleDesc setDesc
Definition: execnodes.h:332
Tuplestorestate * setResult
Definition: execnodes.h:331
void tuplestore_putvalues(Tuplestorestate *state, TupleDesc tdesc, Datum *values, bool *isnull)
Definition: tuplestore.c:750

References BoolGetDatum(), cstring_to_text(), DEBUG3, InitMaterializedSRF(), Int32GetDatum(), NUM_PG_FILE_SETTINGS_ATTS, PGC_SIGHUP, PointerGetDatum(), ProcessConfigFileInternal(), ReturnSetInfo::setDesc, ReturnSetInfo::setResult, tuplestore_putvalues(), and values.

◆ show_all_settings()

Datum show_all_settings ( PG_FUNCTION_ARGS  )

Definition at line 844 of file guc_funcs.c.

845 {
846  FuncCallContext *funcctx;
847  struct config_generic **guc_vars;
848  int num_vars;
849  TupleDesc tupdesc;
850  int call_cntr;
851  int max_calls;
852  AttInMetadata *attinmeta;
853  MemoryContext oldcontext;
854 
855  /* stuff done only on the first call of the function */
856  if (SRF_IS_FIRSTCALL())
857  {
858  /* create a function context for cross-call persistence */
859  funcctx = SRF_FIRSTCALL_INIT();
860 
861  /*
862  * switch to memory context appropriate for multiple function calls
863  */
864  oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
865 
866  /*
867  * need a tuple descriptor representing NUM_PG_SETTINGS_ATTS columns
868  * of the appropriate types
869  */
871  TupleDescInitEntry(tupdesc, (AttrNumber) 1, "name",
872  TEXTOID, -1, 0);
873  TupleDescInitEntry(tupdesc, (AttrNumber) 2, "setting",
874  TEXTOID, -1, 0);
875  TupleDescInitEntry(tupdesc, (AttrNumber) 3, "unit",
876  TEXTOID, -1, 0);
877  TupleDescInitEntry(tupdesc, (AttrNumber) 4, "category",
878  TEXTOID, -1, 0);
879  TupleDescInitEntry(tupdesc, (AttrNumber) 5, "short_desc",
880  TEXTOID, -1, 0);
881  TupleDescInitEntry(tupdesc, (AttrNumber) 6, "extra_desc",
882  TEXTOID, -1, 0);
883  TupleDescInitEntry(tupdesc, (AttrNumber) 7, "context",
884  TEXTOID, -1, 0);
885  TupleDescInitEntry(tupdesc, (AttrNumber) 8, "vartype",
886  TEXTOID, -1, 0);
887  TupleDescInitEntry(tupdesc, (AttrNumber) 9, "source",
888  TEXTOID, -1, 0);
889  TupleDescInitEntry(tupdesc, (AttrNumber) 10, "min_val",
890  TEXTOID, -1, 0);
891  TupleDescInitEntry(tupdesc, (AttrNumber) 11, "max_val",
892  TEXTOID, -1, 0);
893  TupleDescInitEntry(tupdesc, (AttrNumber) 12, "enumvals",
894  TEXTARRAYOID, -1, 0);
895  TupleDescInitEntry(tupdesc, (AttrNumber) 13, "boot_val",
896  TEXTOID, -1, 0);
897  TupleDescInitEntry(tupdesc, (AttrNumber) 14, "reset_val",
898  TEXTOID, -1, 0);
899  TupleDescInitEntry(tupdesc, (AttrNumber) 15, "sourcefile",
900  TEXTOID, -1, 0);
901  TupleDescInitEntry(tupdesc, (AttrNumber) 16, "sourceline",
902  INT4OID, -1, 0);
903  TupleDescInitEntry(tupdesc, (AttrNumber) 17, "pending_restart",
904  BOOLOID, -1, 0);
905 
906  /*
907  * Generate attribute metadata needed later to produce tuples from raw
908  * C strings
909  */
910  attinmeta = TupleDescGetAttInMetadata(tupdesc);
911  funcctx->attinmeta = attinmeta;
912 
913  /* collect the variables, in sorted order */
914  guc_vars = get_guc_variables(&num_vars);
915 
916  /* use user_fctx to remember the array location */
917  funcctx->user_fctx = guc_vars;
918 
919  /* total number of tuples to be returned */
920  funcctx->max_calls = num_vars;
921 
922  MemoryContextSwitchTo(oldcontext);
923  }
924 
925  /* stuff done on every call of the function */
926  funcctx = SRF_PERCALL_SETUP();
927 
928  guc_vars = (struct config_generic **) funcctx->user_fctx;
929  call_cntr = funcctx->call_cntr;
930  max_calls = funcctx->max_calls;
931  attinmeta = funcctx->attinmeta;
932 
933  if (call_cntr < max_calls) /* do when there is more left to send */
934  {
936  bool noshow;
937  HeapTuple tuple;
938  Datum result;
939 
940  /*
941  * Get the next visible GUC variable name and value
942  */
943  do
944  {
945  GetConfigOptionValues(guc_vars[call_cntr], (const char **) values,
946  &noshow);
947  if (noshow)
948  {
949  /* bump the counter and get the next config setting */
950  call_cntr = ++funcctx->call_cntr;
951 
952  /* make sure we haven't gone too far now */
953  if (call_cntr >= max_calls)
954  SRF_RETURN_DONE(funcctx);
955  }
956  } while (noshow);
957 
958  /* build a tuple */
959  tuple = BuildTupleFromCStrings(attinmeta, values);
960 
961  /* make the tuple into a datum */
962  result = HeapTupleGetDatum(tuple);
963 
964  SRF_RETURN_NEXT(funcctx, result);
965  }
966  else
967  {
968  /* do when there is no more left */
969  SRF_RETURN_DONE(funcctx);
970  }
971 }
HeapTuple BuildTupleFromCStrings(AttInMetadata *attinmeta, char **values)
Definition: execTuples.c:2135
AttInMetadata * TupleDescGetAttInMetadata(TupleDesc tupdesc)
Definition: execTuples.c:2086
#define SRF_IS_FIRSTCALL()
Definition: funcapi.h:303
#define SRF_PERCALL_SETUP()
Definition: funcapi.h:307
#define SRF_RETURN_NEXT(_funcctx, _result)
Definition: funcapi.h:309
#define SRF_FIRSTCALL_INIT()
Definition: funcapi.h:305
static Datum HeapTupleGetDatum(const HeapTupleData *tuple)
Definition: funcapi.h:230
#define SRF_RETURN_DONE(_funcctx)
Definition: funcapi.h:327
struct config_generic ** get_guc_variables(int *num_vars)
Definition: guc.c:865
#define NUM_PG_SETTINGS_ATTS
Definition: guc_funcs.c:841
static void GetConfigOptionValues(struct config_generic *conf, const char **values, bool *noshow)
Definition: guc_funcs.c:578
if(TABLE==NULL||TABLE_index==NULL)
Definition: isn.c:77
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:135
void * user_fctx
Definition: funcapi.h:82
uint64 max_calls
Definition: funcapi.h:74
uint64 call_cntr
Definition: funcapi.h:65
AttInMetadata * attinmeta
Definition: funcapi.h:91
MemoryContext multi_call_memory_ctx
Definition: funcapi.h:101

References FuncCallContext::attinmeta, BuildTupleFromCStrings(), FuncCallContext::call_cntr, CreateTemplateTupleDesc(), get_guc_variables(), GetConfigOptionValues(), HeapTupleGetDatum(), if(), FuncCallContext::max_calls, MemoryContextSwitchTo(), FuncCallContext::multi_call_memory_ctx, NUM_PG_SETTINGS_ATTS, SRF_FIRSTCALL_INIT, SRF_IS_FIRSTCALL, SRF_PERCALL_SETUP, SRF_RETURN_DONE, SRF_RETURN_NEXT, TupleDescGetAttInMetadata(), TupleDescInitEntry(), FuncCallContext::user_fctx, and values.

◆ show_config_by_name()

Datum show_config_by_name ( PG_FUNCTION_ARGS  )

Definition at line 802 of file guc_funcs.c.

803 {
804  char *varname = TextDatumGetCString(PG_GETARG_DATUM(0));
805  char *varval;
806 
807  /* Get the value */
808  varval = GetConfigOptionByName(varname, NULL, false);
809 
810  /* Convert to text */
812 }

References cstring_to_text(), GetConfigOptionByName(), PG_GETARG_DATUM, PG_RETURN_TEXT_P, and TextDatumGetCString.

◆ show_config_by_name_missing_ok()

Datum show_config_by_name_missing_ok ( PG_FUNCTION_ARGS  )

Definition at line 820 of file guc_funcs.c.

821 {
822  char *varname = TextDatumGetCString(PG_GETARG_DATUM(0));
823  bool missing_ok = PG_GETARG_BOOL(1);
824  char *varval;
825 
826  /* Get the value */
827  varval = GetConfigOptionByName(varname, NULL, missing_ok);
828 
829  /* return NULL if no such variable */
830  if (varval == NULL)
831  PG_RETURN_NULL();
832 
833  /* Convert to text */
835 }

References cstring_to_text(), GetConfigOptionByName(), PG_GETARG_BOOL, PG_GETARG_DATUM, PG_RETURN_NULL, PG_RETURN_TEXT_P, and TextDatumGetCString.

◆ ShowAllGUCConfig()

static void ShowAllGUCConfig ( DestReceiver dest)
static

Definition at line 456 of file guc_funcs.c.

457 {
458  struct config_generic **guc_vars;
459  int num_vars;
460  TupOutputState *tstate;
461  TupleDesc tupdesc;
462  Datum values[3];
463  bool isnull[3] = {false, false, false};
464 
465  /* collect the variables, in sorted order */
466  guc_vars = get_guc_variables(&num_vars);
467 
468  /* need a tuple descriptor representing three TEXT columns */
469  tupdesc = CreateTemplateTupleDesc(3);
470  TupleDescInitBuiltinEntry(tupdesc, (AttrNumber) 1, "name",
471  TEXTOID, -1, 0);
472  TupleDescInitBuiltinEntry(tupdesc, (AttrNumber) 2, "setting",
473  TEXTOID, -1, 0);
474  TupleDescInitBuiltinEntry(tupdesc, (AttrNumber) 3, "description",
475  TEXTOID, -1, 0);
476 
477  /* prepare for projection of tuples */
478  tstate = begin_tup_output_tupdesc(dest, tupdesc, &TTSOpsVirtual);
479 
480  for (int i = 0; i < num_vars; i++)
481  {
482  struct config_generic *conf = guc_vars[i];
483  char *setting;
484 
485  if ((conf->flags & GUC_NO_SHOW_ALL) ||
486  ((conf->flags & GUC_SUPERUSER_ONLY) &&
487  !has_privs_of_role(GetUserId(), ROLE_PG_READ_ALL_SETTINGS)))
488  continue;
489 
490  /* assign to the values array */
492 
493  setting = ShowGUCOption(conf, true);
494  if (setting)
495  {
496  values[1] = PointerGetDatum(cstring_to_text(setting));
497  isnull[1] = false;
498  }
499  else
500  {
501  values[1] = PointerGetDatum(NULL);
502  isnull[1] = true;
503  }
504 
505  if (conf->short_desc)
506  {
508  isnull[2] = false;
509  }
510  else
511  {
512  values[2] = PointerGetDatum(NULL);
513  isnull[2] = true;
514  }
515 
516  /* send it to dest */
517  do_tup_output(tstate, values, isnull);
518 
519  /* clean up */
521  if (setting)
522  {
523  pfree(setting);
525  }
526  if (conf->short_desc)
528  }
529 
530  end_tup_output(tstate);
531 }
const TupleTableSlotOps TTSOpsVirtual
Definition: execTuples.c:83
void end_tup_output(TupOutputState *tstate)
Definition: execTuples.c:2333
void do_tup_output(TupOutputState *tstate, Datum *values, bool *isnull)
Definition: execTuples.c:2275
TupOutputState * begin_tup_output_tupdesc(DestReceiver *dest, TupleDesc tupdesc, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:2255
int i
Definition: isn.c:73
void pfree(void *pointer)
Definition: mcxt.c:1306
static Pointer DatumGetPointer(Datum X)
Definition: postgres.h:660
void TupleDescInitBuiltinEntry(TupleDesc desc, AttrNumber attributeNumber, const char *attributeName, Oid oidtypeid, int32 typmod, int attdim)
Definition: tupdesc.c:657

References begin_tup_output_tupdesc(), CreateTemplateTupleDesc(), cstring_to_text(), DatumGetPointer(), generate_unaccent_rules::dest, do_tup_output(), end_tup_output(), config_generic::flags, get_guc_variables(), GetUserId(), GUC_NO_SHOW_ALL, GUC_SUPERUSER_ONLY, has_privs_of_role(), i, config_generic::name, pfree(), PointerGetDatum(), config_generic::short_desc, ShowGUCOption(), TTSOpsVirtual, TupleDescInitBuiltinEntry(), and values.

Referenced by GetPGVariable().

◆ ShowGUCConfigOption()

static void ShowGUCConfigOption ( const char *  name,
DestReceiver dest 
)
static

Definition at line 428 of file guc_funcs.c.

429 {
430  TupOutputState *tstate;
431  TupleDesc tupdesc;
432  const char *varname;
433  char *value;
434 
435  /* Get the value and canonical spelling of name */
436  value = GetConfigOptionByName(name, &varname, false);
437 
438  /* need a tuple descriptor representing a single TEXT column */
439  tupdesc = CreateTemplateTupleDesc(1);
440  TupleDescInitBuiltinEntry(tupdesc, (AttrNumber) 1, varname,
441  TEXTOID, -1, 0);
442 
443  /* prepare for projection of tuples */
444  tstate = begin_tup_output_tupdesc(dest, tupdesc, &TTSOpsVirtual);
445 
446  /* Send it */
447  do_text_output_oneline(tstate, value);
448 
449  end_tup_output(tstate);
450 }
#define do_text_output_oneline(tstate, str_to_emit)
Definition: executor.h:510

References begin_tup_output_tupdesc(), CreateTemplateTupleDesc(), generate_unaccent_rules::dest, do_text_output_oneline, end_tup_output(), GetConfigOptionByName(), name, TTSOpsVirtual, TupleDescInitBuiltinEntry(), and value.

Referenced by GetPGVariable().