PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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 "miscadmin.h"
#include "parser/parse_type.h"
#include "utils/acl.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)
 
bool ConfigOptionIsVisible (const struct config_generic *conf)
 
static void GetConfigOptionValues (const struct config_generic *conf, const char **values)
 
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 872 of file guc_funcs.c.

Function Documentation

◆ ConfigOptionIsVisible()

bool ConfigOptionIsVisible ( const struct config_generic conf)

Definition at line 607 of file guc_funcs.c.

608{
609 if ((conf->flags & GUC_SUPERUSER_ONLY) &&
610 !has_privs_of_role(GetUserId(), ROLE_PG_READ_ALL_SETTINGS))
611 return false;
612 else
613 return true;
614}
bool has_privs_of_role(Oid member, Oid role)
Definition: acl.c:5284
#define GUC_SUPERUSER_ONLY
Definition: guc.h:224
Oid GetUserId(void)
Definition: miscinit.c:469

References config_generic::flags, GetUserId(), GUC_SUPERUSER_ONLY, and has_privs_of_role().

Referenced by get_explain_guc_options(), GetConfigOption(), GetConfigOptionByName(), GetConfigOptionResetString(), show_all_settings(), and ShowAllGUCConfig().

◆ 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())
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)
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:
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:863
int errmsg(const char *fmt,...)
Definition: elog.c:1080
#define ERROR
Definition: elog.h:39
#define elog(elevel,...)
Definition: elog.h:226
#define ereport(elevel,...)
Definition: elog.h:150
void ResetAllOptions(void)
Definition: guc.c:1878
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:3205
GucAction
Definition: guc.h:201
@ GUC_ACTION_SET
Definition: guc.h:203
@ GUC_ACTION_LOCAL
Definition: guc.h:204
@ PGC_S_SESSION
Definition: guc.h:126
@ PGC_SUSET
Definition: guc.h:78
@ PGC_USERSET
Definition: guc.h:79
char * ExtractSetVariableArgs(VariableSetStmt *stmt)
Definition: guc_funcs.c:167
void SetPGVariable(const char *name, List *args, bool is_local)
Definition: guc_funcs.c:341
#define stmt
Definition: indent_codes.h:59
#define InvokeObjectPostAlterHookArgStr(classId, objectName, subId, auxiliaryId, is_internal)
Definition: objectaccess.h:247
#define ACL_SET
Definition: parsenodes.h:88
@ VAR_SET_DEFAULT
Definition: parsenodes.h:2695
@ VAR_RESET
Definition: parsenodes.h:2698
@ VAR_SET_MULTI
Definition: parsenodes.h:2697
@ VAR_SET_VALUE
Definition: parsenodes.h:2694
@ VAR_SET_CURRENT
Definition: parsenodes.h:2696
@ VAR_RESET_ALL
Definition: parsenodes.h:2699
#define lfirst(lc)
Definition: pg_list.h:172
#define linitial_node(type, l)
Definition: pg_list.h:181
#define list_make1(x1)
Definition: pg_list.h:212
void ImportSnapshot(const char *idstr)
Definition: snapmgr.c:1385
union ValUnion val
Definition: parsenodes.h:387
char * defname
Definition: parsenodes.h:843
Node * arg
Definition: parsenodes.h:844
bool superuser(void)
Definition: superuser.c:46
#define strVal(v)
Definition: value.h:82
void WarnNoTransactionBlock(bool isTopLevel, const char *stmtType)
Definition: xact.c:3728
bool IsInParallelMode(void)
Definition: xact.c:1090

References ACL_SET, generate_unaccent_rules::action, DefElem::arg, DefElem::defname, elog, ereport, errcode(), errmsg(), ERROR, ExtractSetVariableArgs(), GUC_ACTION_LOCAL, GUC_ACTION_SET, ImportSnapshot(), InvokeObjectPostAlterHookArgStr, IsInParallelMode(), lfirst, linitial_node, list_make1, PGC_S_SESSION, PGC_SUSET, PGC_USERSET, ResetAllOptions(), set_config_option(), SetPGVariable(), stmt, 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:5290
static char * flatten_set_variable_args(const char *name, List *args)
Definition: guc_funcs.c:192

References flatten_set_variable_args(), GetConfigOptionByName(), stmt, 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 /*
214 * Handle special cases for list input.
215 */
216 if (flags & GUC_LIST_INPUT)
217 {
218 /* NULL represents an empty list. */
219 if (list_length(args) == 1)
220 {
221 Node *arg = (Node *) linitial(args);
222
223 if (IsA(arg, A_Const) &&
224 ((A_Const *) arg)->isnull)
225 return pstrdup("");
226 }
227 }
228 else
229 {
230 /* Complain if list input and non-list variable. */
231 if (list_length(args) != 1)
233 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
234 errmsg("SET %s takes only one argument", name)));
235 }
236
238
239 /*
240 * Each list member may be a plain A_Const node, or an A_Const within a
241 * TypeCast; the latter case is supported only for ConstInterval arguments
242 * (for SET TIME ZONE).
243 */
244 foreach(l, args)
245 {
246 Node *arg = (Node *) lfirst(l);
247 char *val;
248 TypeName *typeName = NULL;
249 A_Const *con;
250
251 if (l != list_head(args))
253
254 if (IsA(arg, TypeCast))
255 {
256 TypeCast *tc = (TypeCast *) arg;
257
258 arg = tc->arg;
259 typeName = tc->typeName;
260 }
261
262 if (!IsA(arg, A_Const))
263 elog(ERROR, "unrecognized node type: %d", (int) nodeTag(arg));
264 con = (A_Const *) arg;
265
266 /* Complain if NULL is used with a non-list variable. */
267 if (con->isnull)
269 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
270 errmsg("NULL is an invalid value for %s", name)));
271
272 switch (nodeTag(&con->val))
273 {
274 case T_Integer:
275 appendStringInfo(&buf, "%d", intVal(&con->val));
276 break;
277 case T_Float:
278 /* represented as a string, so just copy it */
280 break;
281 case T_String:
282 val = strVal(&con->val);
283 if (typeName != NULL)
284 {
285 /*
286 * Must be a ConstInterval argument for TIME ZONE. Coerce
287 * to interval and back to normalize the value and account
288 * for any typmod.
289 */
290 Oid typoid;
291 int32 typmod;
293 char *intervalout;
294
295 /* gram.y ensures this is only reachable for TIME ZONE */
297
298 typenameTypeIdAndMod(NULL, typeName, &typoid, &typmod);
299 Assert(typoid == INTERVALOID);
300
301 interval =
305 Int32GetDatum(typmod));
306
307 intervalout =
309 interval));
310 appendStringInfo(&buf, "INTERVAL '%s'", intervalout);
311 }
312 else
313 {
314 /*
315 * Plain string literal or identifier. For quote mode,
316 * quote it if it's not a vanilla identifier.
317 */
318 if (flags & GUC_LIST_QUOTE)
320 else
322 }
323 break;
324 default:
325 elog(ERROR, "unrecognized node type: %d",
326 (int) nodeTag(&con->val));
327 break;
328 }
329 }
330
331 return buf.data;
332}
Datum interval_out(PG_FUNCTION_ARGS)
Definition: timestamp.c:973
Datum interval_in(PG_FUNCTION_ARGS)
Definition: timestamp.c:891
int32_t int32
Definition: c.h:538
#define WARNING
Definition: elog.h:36
#define DirectFunctionCall1(func, arg1)
Definition: fmgr.h:682
#define DirectFunctionCall3(func, arg1, arg2, arg3)
Definition: fmgr.h:686
struct config_generic * find_option(const char *name, bool create_placeholders, bool skip_errors, int elevel)
Definition: guc.c:1113
#define GUC_LIST_QUOTE
Definition: guc.h:215
#define GUC_LIST_INPUT
Definition: guc.h:214
Assert(PointerIsAligned(start, uint64))
long val
Definition: informix.c:689
char * pstrdup(const char *in)
Definition: mcxt.c:1759
#define IsA(nodeptr, _type_)
Definition: nodes.h:164
#define nodeTag(nodeptr)
Definition: nodes.h:139
#define castNode(_type_, nodeptr)
Definition: nodes.h:182
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:152
#define NIL
Definition: pg_list.h:68
#define linitial(l)
Definition: pg_list.h:178
static ListCell * list_head(const List *l)
Definition: pg_list.h:128
static char * buf
Definition: pg_test_fsync.c:72
static Datum ObjectIdGetDatum(Oid X)
Definition: postgres.h:262
static char * DatumGetCString(Datum X)
Definition: postgres.h:345
uint64_t Datum
Definition: postgres.h:70
static Datum CStringGetDatum(const char *X)
Definition: postgres.h:360
static Datum Int32GetDatum(int32 X)
Definition: postgres.h:222
#define InvalidOid
Definition: postgres_ext.h:37
unsigned int Oid
Definition: postgres_ext.h:32
const char * quote_identifier(const char *ident)
Definition: ruleutils.c:13062
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:145
void appendStringInfoString(StringInfo str, const char *s)
Definition: stringinfo.c:230
void initStringInfo(StringInfo str)
Definition: stringinfo.c:97
bool isnull
Definition: parsenodes.h:388
Definition: value.h:48
Definition: nodes.h:135
TypeName * typeName
Definition: parsenodes.h:399
Node * arg
Definition: parsenodes.h:398
#define intVal(v)
Definition: value.h:79
const char * name

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, A_Const::isnull, lfirst, linitial, list_head(), list_length(), name, NIL, nodeTag, ObjectIdGetDatum(), pstrdup(), quote_identifier(), strVal, TypeCast::typeName, typenameTypeIdAndMod(), A_Const::val, val, and WARNING.

Referenced by ExtractSetVariableArgs(), and SetPGVariable().

◆ GetConfigOptionValues()

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

Definition at line 620 of file guc_funcs.c.

621{
622 char buffer[256];
623
624 /* first get the generic attributes */
625
626 /* name */
627 values[0] = conf->name;
628
629 /* setting: use ShowGUCOption in order to avoid duplicating the logic */
630 values[1] = ShowGUCOption(conf, false);
631
632 /* unit, if any (NULL is fine) */
634
635 /* group */
636 values[3] = _(config_group_names[conf->group]);
637
638 /* short_desc */
639 values[4] = conf->short_desc != NULL ? _(conf->short_desc) : NULL;
640
641 /* extra_desc */
642 values[5] = conf->long_desc != NULL ? _(conf->long_desc) : NULL;
643
644 /* context */
645 values[6] = GucContext_Names[conf->context];
646
647 /* vartype */
648 values[7] = config_type_names[conf->vartype];
649
650 /* source */
651 values[8] = GucSource_Names[conf->source];
652
653 /* now get the type specific attributes */
654 switch (conf->vartype)
655 {
656 case PGC_BOOL:
657 {
658 const struct config_bool *lconf = &conf->_bool;
659
660 /* min_val */
661 values[9] = NULL;
662
663 /* max_val */
664 values[10] = NULL;
665
666 /* enumvals */
667 values[11] = NULL;
668
669 /* boot_val */
670 values[12] = pstrdup(lconf->boot_val ? "on" : "off");
671
672 /* reset_val */
673 values[13] = pstrdup(lconf->reset_val ? "on" : "off");
674 }
675 break;
676
677 case PGC_INT:
678 {
679 const struct config_int *lconf = &conf->_int;
680
681 /* min_val */
682 snprintf(buffer, sizeof(buffer), "%d", lconf->min);
683 values[9] = pstrdup(buffer);
684
685 /* max_val */
686 snprintf(buffer, sizeof(buffer), "%d", lconf->max);
687 values[10] = pstrdup(buffer);
688
689 /* enumvals */
690 values[11] = NULL;
691
692 /* boot_val */
693 snprintf(buffer, sizeof(buffer), "%d", lconf->boot_val);
694 values[12] = pstrdup(buffer);
695
696 /* reset_val */
697 snprintf(buffer, sizeof(buffer), "%d", lconf->reset_val);
698 values[13] = pstrdup(buffer);
699 }
700 break;
701
702 case PGC_REAL:
703 {
704 const struct config_real *lconf = &conf->_real;
705
706 /* min_val */
707 snprintf(buffer, sizeof(buffer), "%g", lconf->min);
708 values[9] = pstrdup(buffer);
709
710 /* max_val */
711 snprintf(buffer, sizeof(buffer), "%g", lconf->max);
712 values[10] = pstrdup(buffer);
713
714 /* enumvals */
715 values[11] = NULL;
716
717 /* boot_val */
718 snprintf(buffer, sizeof(buffer), "%g", lconf->boot_val);
719 values[12] = pstrdup(buffer);
720
721 /* reset_val */
722 snprintf(buffer, sizeof(buffer), "%g", lconf->reset_val);
723 values[13] = pstrdup(buffer);
724 }
725 break;
726
727 case PGC_STRING:
728 {
729 const struct config_string *lconf = &conf->_string;
730
731 /* min_val */
732 values[9] = NULL;
733
734 /* max_val */
735 values[10] = NULL;
736
737 /* enumvals */
738 values[11] = NULL;
739
740 /* boot_val */
741 if (lconf->boot_val == NULL)
742 values[12] = NULL;
743 else
744 values[12] = pstrdup(lconf->boot_val);
745
746 /* reset_val */
747 if (lconf->reset_val == NULL)
748 values[13] = NULL;
749 else
750 values[13] = pstrdup(lconf->reset_val);
751 }
752 break;
753
754 case PGC_ENUM:
755 {
756 const struct config_enum *lconf = &conf->_enum;
757
758 /* min_val */
759 values[9] = NULL;
760
761 /* max_val */
762 values[10] = NULL;
763
764 /* enumvals */
765
766 /*
767 * NOTE! enumvals with double quotes in them are not
768 * supported!
769 */
771 "{\"", "\"}", "\",\"");
772
773 /* boot_val */
775 lconf->boot_val));
776
777 /* reset_val */
779 lconf->reset_val));
780 }
781 break;
782
783 default:
784 {
785 /*
786 * should never get here, but in case we do, set 'em to NULL
787 */
788
789 /* min_val */
790 values[9] = NULL;
791
792 /* max_val */
793 values[10] = NULL;
794
795 /* enumvals */
796 values[11] = NULL;
797
798 /* boot_val */
799 values[12] = NULL;
800
801 /* reset_val */
802 values[13] = NULL;
803 }
804 break;
805 }
806
807 /*
808 * If the setting came from a config file, set the source location. For
809 * security reasons, we don't show source file/line number for
810 * insufficiently-privileged users.
811 */
812 if (conf->source == PGC_S_FILE &&
813 has_privs_of_role(GetUserId(), ROLE_PG_READ_ALL_SETTINGS))
814 {
815 values[14] = conf->sourcefile;
816 snprintf(buffer, sizeof(buffer), "%d", conf->sourceline);
817 values[15] = pstrdup(buffer);
818 }
819 else
820 {
821 values[14] = NULL;
822 values[15] = NULL;
823 }
824
825 values[16] = (conf->status & GUC_PENDING_RESTART) ? "t" : "f";
826}
static Datum values[MAXATTR]
Definition: bootstrap.c:153
#define _(x)
Definition: elog.c:91
const char * config_enum_lookup_by_value(const struct config_generic *record, int val)
Definition: guc.c:2895
char * config_enum_get_options(const struct config_enum *record, const char *prefix, const char *suffix, const char *separator)
Definition: guc.c:2940
const char * get_config_unit_name(int flags)
Definition: guc.c:2686
char * ShowGUCOption(const struct config_generic *record, bool use_units)
Definition: guc.c:5323
@ PGC_S_FILE
Definition: guc.h:116
const char *const GucContext_Names[]
Definition: guc_tables.c:648
const char *const GucSource_Names[]
Definition: guc_tables.c:667
const char *const config_type_names[]
Definition: guc_tables.c:751
const char *const config_group_names[]
Definition: guc_tables.c:691
@ 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:299
#define snprintf
Definition: port.h:239
bool reset_val
Definition: guc_tables.h:147
bool boot_val
Definition: guc_tables.h:142
enum config_group group
Definition: guc_tables.h:254
GucContext context
Definition: guc_tables.h:253
const char * long_desc
Definition: guc_tables.h:256
struct config_bool _bool
Definition: guc_tables.h:285
struct config_string _string
Definition: guc_tables.h:288
const char * name
Definition: guc_tables.h:252
struct config_real _real
Definition: guc_tables.h:287
const char * short_desc
Definition: guc_tables.h:255
char * sourcefile
Definition: guc_tables.h:278
struct config_int _int
Definition: guc_tables.h:286
enum config_type vartype
Definition: guc_tables.h:258
GucSource source
Definition: guc_tables.h:261
struct config_enum _enum
Definition: guc_tables.h:289
int reset_val
Definition: guc_tables.h:161
int boot_val
Definition: guc_tables.h:154
double boot_val
Definition: guc_tables.h:168
double reset_val
Definition: guc_tables.h:175
double min
Definition: guc_tables.h:169
double max
Definition: guc_tables.h:170
char * reset_val
Definition: guc_tables.h:197
const char * boot_val
Definition: guc_tables.h:192

References _, config_generic::_bool, config_generic::_enum, config_generic::_int, config_generic::_real, config_generic::_string, 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_PENDING_RESTART, 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 408 of file guc_funcs.c.

409{
410 if (guc_name_compare(name, "all") == 0)
412 else
414}
int guc_name_compare(const char *namea, const char *nameb)
Definition: guc.c:1177
static void ShowGUCConfigOption(const char *name, DestReceiver *dest)
Definition: guc_funcs.c:454
static void ShowAllGUCConfig(DestReceiver *dest)
Definition: guc_funcs.c:482

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 420 of file guc_funcs.c.

421{
422 TupleDesc tupdesc;
423
424 if (guc_name_compare(name, "all") == 0)
425 {
426 /* need a tuple descriptor representing three TEXT columns */
427 tupdesc = CreateTemplateTupleDesc(3);
428 TupleDescInitEntry(tupdesc, (AttrNumber) 1, "name",
429 TEXTOID, -1, 0);
430 TupleDescInitEntry(tupdesc, (AttrNumber) 2, "setting",
431 TEXTOID, -1, 0);
432 TupleDescInitEntry(tupdesc, (AttrNumber) 3, "description",
433 TEXTOID, -1, 0);
434 }
435 else
436 {
437 const char *varname;
438
439 /* Get the canonical spelling of name */
440 (void) GetConfigOptionByName(name, &varname, false);
441
442 /* need a tuple descriptor representing a single TEXT column */
443 tupdesc = CreateTemplateTupleDesc(1);
444 TupleDescInitEntry(tupdesc, (AttrNumber) 1, varname,
445 TEXTOID, -1, 0);
446 }
447 return tupdesc;
448}
int16 AttrNumber
Definition: attnum.h:21
TupleDesc CreateTemplateTupleDesc(int natts)
Definition: tupdesc.c:182
void TupleDescInitEntry(TupleDesc desc, AttrNumber attributeNumber, const char *attributeName, Oid oidtypeid, int32 typmod, int attdim)
Definition: tupdesc.c:842

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 568 of file guc_funcs.c.

569{
570#define MAX_GUC_FLAGS 6
571 char *varname = TextDatumGetCString(PG_GETARG_DATUM(0));
572 struct config_generic *record;
573 int cnt = 0;
575 ArrayType *a;
576
577 record = find_option(varname, false, true, ERROR);
578
579 /* return NULL if no such variable */
580 if (record == NULL)
582
583 if (record->flags & GUC_EXPLAIN)
584 flags[cnt++] = CStringGetTextDatum("EXPLAIN");
585 if (record->flags & GUC_NO_RESET)
586 flags[cnt++] = CStringGetTextDatum("NO_RESET");
587 if (record->flags & GUC_NO_RESET_ALL)
588 flags[cnt++] = CStringGetTextDatum("NO_RESET_ALL");
589 if (record->flags & GUC_NO_SHOW_ALL)
590 flags[cnt++] = CStringGetTextDatum("NO_SHOW_ALL");
591 if (record->flags & GUC_NOT_IN_SAMPLE)
592 flags[cnt++] = CStringGetTextDatum("NOT_IN_SAMPLE");
593 if (record->flags & GUC_RUNTIME_COMPUTED)
594 flags[cnt++] = CStringGetTextDatum("RUNTIME_COMPUTED");
595
596 Assert(cnt <= MAX_GUC_FLAGS);
597
598 /* Returns the record as Datum */
599 a = construct_array_builtin(flags, cnt, TEXTOID);
601}
#define PG_RETURN_ARRAYTYPE_P(x)
Definition: array.h:265
ArrayType * construct_array_builtin(Datum *elems, int nelems, Oid elmtype)
Definition: arrayfuncs.c:3382
#define CStringGetTextDatum(s)
Definition: builtins.h:97
#define TextDatumGetCString(d)
Definition: builtins.h:98
#define PG_GETARG_DATUM(n)
Definition: fmgr.h:268
#define PG_RETURN_NULL()
Definition: fmgr.h:345
#define GUC_EXPLAIN
Definition: guc.h:219
#define GUC_NO_RESET_ALL
Definition: guc.h:218
#define GUC_NO_RESET
Definition: guc.h:217
#define GUC_RUNTIME_COMPUTED
Definition: guc.h:229
#define GUC_NO_SHOW_ALL
Definition: guc.h:216
#define GUC_NOT_IN_SAMPLE
Definition: guc.h:221
#define MAX_GUC_FLAGS
int a
Definition: isn.c:73

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 358 of file guc_funcs.c.

359{
360 char *name;
361 char *value;
362 char *new_value;
363 bool is_local;
364
365 if (PG_ARGISNULL(0))
367 (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
368 errmsg("SET requires parameter name")));
369
370 /* Get the GUC variable name */
372
373 /* Get the desired value or set to NULL for a reset request */
374 if (PG_ARGISNULL(1))
375 value = NULL;
376 else
378
379 /*
380 * Get the desired state of is_local. Default to false if provided value
381 * is NULL
382 */
383 if (PG_ARGISNULL(2))
384 is_local = false;
385 else
386 is_local = PG_GETARG_BOOL(2);
387
388 /* Note SET DEFAULT (argstring == NULL) is equivalent to RESET */
389 (void) set_config_option(name,
390 value,
393 is_local ? GUC_ACTION_LOCAL : GUC_ACTION_SET,
394 true, 0, false);
395
396 /* get the new current value */
397 new_value = GetConfigOptionByName(name, NULL, false);
398
399 /* Convert return string to text */
401}
#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 @171 value
text * cstring_to_text(const char *s)
Definition: varlena.c:181

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 341 of file guc_funcs.c.

342{
343 char *argstring = flatten_set_variable_args(name, args);
344
345 /* Note SET DEFAULT (argstring == NULL) is equivalent to RESET */
346 (void) set_config_option(name,
347 argstring,
350 is_local ? GUC_ACTION_LOCAL : GUC_ACTION_SET,
351 true, 0, false);
352}

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 1010 of file guc_funcs.c.

1011{
1012#define NUM_PG_FILE_SETTINGS_ATTS 7
1013 ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
1014 ConfigVariable *conf;
1015
1016 /* Scan the config files using current context as workspace */
1018
1019 /* Build a tuplestore to return our results in */
1020 InitMaterializedSRF(fcinfo, 0);
1021
1022 /* Process the results and create a tuplestore */
1023 for (int seqno = 1; conf != NULL; conf = conf->next, seqno++)
1024 {
1026 bool nulls[NUM_PG_FILE_SETTINGS_ATTS];
1027
1028 memset(values, 0, sizeof(values));
1029 memset(nulls, 0, sizeof(nulls));
1030
1031 /* sourcefile */
1032 if (conf->filename)
1033 values[0] = PointerGetDatum(cstring_to_text(conf->filename));
1034 else
1035 nulls[0] = true;
1036
1037 /* sourceline (not meaningful if no sourcefile) */
1038 if (conf->filename)
1039 values[1] = Int32GetDatum(conf->sourceline);
1040 else
1041 nulls[1] = true;
1042
1043 /* seqno */
1044 values[2] = Int32GetDatum(seqno);
1045
1046 /* name */
1047 if (conf->name)
1048 values[3] = PointerGetDatum(cstring_to_text(conf->name));
1049 else
1050 nulls[3] = true;
1051
1052 /* setting */
1053 if (conf->value)
1054 values[4] = PointerGetDatum(cstring_to_text(conf->value));
1055 else
1056 nulls[4] = true;
1057
1058 /* applied */
1059 values[5] = BoolGetDatum(conf->applied);
1060
1061 /* error */
1062 if (conf->errmsg)
1063 values[6] = PointerGetDatum(cstring_to_text(conf->errmsg));
1064 else
1065 nulls[6] = true;
1066
1067 /* shove row into tuplestore */
1068 tuplestore_putvalues(rsinfo->setResult, rsinfo->setDesc, values, nulls);
1069 }
1070
1071 return (Datum) 0;
1072}
#define DEBUG3
Definition: elog.h:28
void InitMaterializedSRF(FunctionCallInfo fcinfo, bits32 flags)
Definition: funcapi.c:76
ConfigVariable * ProcessConfigFileInternal(GucContext context, bool applySettings, int elevel)
Definition: guc.c:284
@ PGC_SIGHUP
Definition: guc.h:75
#define NUM_PG_FILE_SETTINGS_ATTS
static Datum PointerGetDatum(const void *X)
Definition: postgres.h:332
static Datum BoolGetDatum(bool X)
Definition: postgres.h:112
TupleDesc setDesc
Definition: execnodes.h:364
Tuplestorestate * setResult
Definition: execnodes.h:363
void tuplestore_putvalues(Tuplestorestate *state, TupleDesc tdesc, const Datum *values, const bool *isnull)
Definition: tuplestore.c:784

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 875 of file guc_funcs.c.

876{
877 FuncCallContext *funcctx;
878 struct config_generic **guc_vars;
879 int num_vars;
880 TupleDesc tupdesc;
881 int call_cntr;
882 int max_calls;
883 AttInMetadata *attinmeta;
884 MemoryContext oldcontext;
885
886 /* stuff done only on the first call of the function */
887 if (SRF_IS_FIRSTCALL())
888 {
889 /* create a function context for cross-call persistence */
890 funcctx = SRF_FIRSTCALL_INIT();
891
892 /*
893 * switch to memory context appropriate for multiple function calls
894 */
895 oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
896
897 /*
898 * need a tuple descriptor representing NUM_PG_SETTINGS_ATTS columns
899 * of the appropriate types
900 */
902 TupleDescInitEntry(tupdesc, (AttrNumber) 1, "name",
903 TEXTOID, -1, 0);
904 TupleDescInitEntry(tupdesc, (AttrNumber) 2, "setting",
905 TEXTOID, -1, 0);
906 TupleDescInitEntry(tupdesc, (AttrNumber) 3, "unit",
907 TEXTOID, -1, 0);
908 TupleDescInitEntry(tupdesc, (AttrNumber) 4, "category",
909 TEXTOID, -1, 0);
910 TupleDescInitEntry(tupdesc, (AttrNumber) 5, "short_desc",
911 TEXTOID, -1, 0);
912 TupleDescInitEntry(tupdesc, (AttrNumber) 6, "extra_desc",
913 TEXTOID, -1, 0);
914 TupleDescInitEntry(tupdesc, (AttrNumber) 7, "context",
915 TEXTOID, -1, 0);
916 TupleDescInitEntry(tupdesc, (AttrNumber) 8, "vartype",
917 TEXTOID, -1, 0);
918 TupleDescInitEntry(tupdesc, (AttrNumber) 9, "source",
919 TEXTOID, -1, 0);
920 TupleDescInitEntry(tupdesc, (AttrNumber) 10, "min_val",
921 TEXTOID, -1, 0);
922 TupleDescInitEntry(tupdesc, (AttrNumber) 11, "max_val",
923 TEXTOID, -1, 0);
924 TupleDescInitEntry(tupdesc, (AttrNumber) 12, "enumvals",
925 TEXTARRAYOID, -1, 0);
926 TupleDescInitEntry(tupdesc, (AttrNumber) 13, "boot_val",
927 TEXTOID, -1, 0);
928 TupleDescInitEntry(tupdesc, (AttrNumber) 14, "reset_val",
929 TEXTOID, -1, 0);
930 TupleDescInitEntry(tupdesc, (AttrNumber) 15, "sourcefile",
931 TEXTOID, -1, 0);
932 TupleDescInitEntry(tupdesc, (AttrNumber) 16, "sourceline",
933 INT4OID, -1, 0);
934 TupleDescInitEntry(tupdesc, (AttrNumber) 17, "pending_restart",
935 BOOLOID, -1, 0);
936
937 /*
938 * Generate attribute metadata needed later to produce tuples from raw
939 * C strings
940 */
941 attinmeta = TupleDescGetAttInMetadata(tupdesc);
942 funcctx->attinmeta = attinmeta;
943
944 /* collect the variables, in sorted order */
945 guc_vars = get_guc_variables(&num_vars);
946
947 /* use user_fctx to remember the array location */
948 funcctx->user_fctx = guc_vars;
949
950 /* total number of tuples to be returned */
951 funcctx->max_calls = num_vars;
952
953 MemoryContextSwitchTo(oldcontext);
954 }
955
956 /* stuff done on every call of the function */
957 funcctx = SRF_PERCALL_SETUP();
958
959 guc_vars = (struct config_generic **) funcctx->user_fctx;
960 call_cntr = funcctx->call_cntr;
961 max_calls = funcctx->max_calls;
962 attinmeta = funcctx->attinmeta;
963
964 while (call_cntr < max_calls) /* do when there is more left to send */
965 {
966 struct config_generic *conf = guc_vars[call_cntr];
968 HeapTuple tuple;
969 Datum result;
970
971 /* skip if marked NO_SHOW_ALL or if not visible to current user */
972 if ((conf->flags & GUC_NO_SHOW_ALL) ||
974 {
975 call_cntr = ++funcctx->call_cntr;
976 continue;
977 }
978
979 /* extract values for the current variable */
980 GetConfigOptionValues(conf, (const char **) values);
981
982 /* build a tuple */
983 tuple = BuildTupleFromCStrings(attinmeta, values);
984
985 /* make the tuple into a datum */
986 result = HeapTupleGetDatum(tuple);
987
988 SRF_RETURN_NEXT(funcctx, result);
989 }
990
991 /* do when there is no more left */
992 SRF_RETURN_DONE(funcctx);
993}
HeapTuple BuildTupleFromCStrings(AttInMetadata *attinmeta, char **values)
Definition: execTuples.c:2324
AttInMetadata * TupleDescGetAttInMetadata(TupleDesc tupdesc)
Definition: execTuples.c:2275
#define SRF_IS_FIRSTCALL()
Definition: funcapi.h:304
#define SRF_PERCALL_SETUP()
Definition: funcapi.h:308
#define SRF_RETURN_NEXT(_funcctx, _result)
Definition: funcapi.h:310
#define SRF_FIRSTCALL_INIT()
Definition: funcapi.h:306
static Datum HeapTupleGetDatum(const HeapTupleData *tuple)
Definition: funcapi.h:230
#define SRF_RETURN_DONE(_funcctx)
Definition: funcapi.h:328
struct config_generic ** get_guc_variables(int *num_vars)
Definition: guc.c:839
static void GetConfigOptionValues(const struct config_generic *conf, const char **values)
Definition: guc_funcs.c:620
#define NUM_PG_SETTINGS_ATTS
Definition: guc_funcs.c:872
bool ConfigOptionIsVisible(const struct config_generic *conf)
Definition: guc_funcs.c:607
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:124
while(p+4<=pend)
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, ConfigOptionIsVisible(), CreateTemplateTupleDesc(), config_generic::flags, get_guc_variables(), GetConfigOptionValues(), GUC_NO_SHOW_ALL, HeapTupleGetDatum(), 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, values, and while().

◆ show_config_by_name()

Datum show_config_by_name ( PG_FUNCTION_ARGS  )

Definition at line 833 of file guc_funcs.c.

834{
835 char *varname = TextDatumGetCString(PG_GETARG_DATUM(0));
836 char *varval;
837
838 /* Get the value */
839 varval = GetConfigOptionByName(varname, NULL, false);
840
841 /* Convert to text */
843}

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 851 of file guc_funcs.c.

852{
853 char *varname = TextDatumGetCString(PG_GETARG_DATUM(0));
854 bool missing_ok = PG_GETARG_BOOL(1);
855 char *varval;
856
857 /* Get the value */
858 varval = GetConfigOptionByName(varname, NULL, missing_ok);
859
860 /* return NULL if no such variable */
861 if (varval == NULL)
863
864 /* Convert to text */
866}

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 482 of file guc_funcs.c.

483{
484 struct config_generic **guc_vars;
485 int num_vars;
486 TupOutputState *tstate;
487 TupleDesc tupdesc;
488 Datum values[3];
489 bool isnull[3] = {false, false, false};
490
491 /* collect the variables, in sorted order */
492 guc_vars = get_guc_variables(&num_vars);
493
494 /* need a tuple descriptor representing three TEXT columns */
495 tupdesc = CreateTemplateTupleDesc(3);
496 TupleDescInitBuiltinEntry(tupdesc, (AttrNumber) 1, "name",
497 TEXTOID, -1, 0);
498 TupleDescInitBuiltinEntry(tupdesc, (AttrNumber) 2, "setting",
499 TEXTOID, -1, 0);
500 TupleDescInitBuiltinEntry(tupdesc, (AttrNumber) 3, "description",
501 TEXTOID, -1, 0);
502
503 /* prepare for projection of tuples */
504 tstate = begin_tup_output_tupdesc(dest, tupdesc, &TTSOpsVirtual);
505
506 for (int i = 0; i < num_vars; i++)
507 {
508 struct config_generic *conf = guc_vars[i];
509 char *setting;
510
511 /* skip if marked NO_SHOW_ALL */
512 if (conf->flags & GUC_NO_SHOW_ALL)
513 continue;
514
515 /* return only options visible to the current user */
516 if (!ConfigOptionIsVisible(conf))
517 continue;
518
519 /* assign to the values array */
521
522 setting = ShowGUCOption(conf, true);
523 if (setting)
524 {
526 isnull[1] = false;
527 }
528 else
529 {
530 values[1] = PointerGetDatum(NULL);
531 isnull[1] = true;
532 }
533
534 if (conf->short_desc)
535 {
537 isnull[2] = false;
538 }
539 else
540 {
541 values[2] = PointerGetDatum(NULL);
542 isnull[2] = true;
543 }
544
545 /* send it to dest */
546 do_tup_output(tstate, values, isnull);
547
548 /* clean up */
550 if (setting)
551 {
552 pfree(setting);
554 }
555 if (conf->short_desc)
557 }
558
559 end_tup_output(tstate);
560}
void do_tup_output(TupOutputState *tstate, const Datum *values, const bool *isnull)
Definition: execTuples.c:2464
const TupleTableSlotOps TTSOpsVirtual
Definition: execTuples.c:84
void end_tup_output(TupOutputState *tstate)
Definition: execTuples.c:2522
TupOutputState * begin_tup_output_tupdesc(DestReceiver *dest, TupleDesc tupdesc, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:2444
int i
Definition: isn.c:77
void pfree(void *pointer)
Definition: mcxt.c:1594
static Pointer DatumGetPointer(Datum X)
Definition: postgres.h:322
void TupleDescInitBuiltinEntry(TupleDesc desc, AttrNumber attributeNumber, const char *attributeName, Oid oidtypeid, int32 typmod, int attdim)
Definition: tupdesc.c:918

References begin_tup_output_tupdesc(), ConfigOptionIsVisible(), CreateTemplateTupleDesc(), cstring_to_text(), DatumGetPointer(), generate_unaccent_rules::dest, do_tup_output(), end_tup_output(), config_generic::flags, get_guc_variables(), GUC_NO_SHOW_ALL, 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 454 of file guc_funcs.c.

455{
456 TupOutputState *tstate;
457 TupleDesc tupdesc;
458 const char *varname;
459 char *value;
460
461 /* Get the value and canonical spelling of name */
462 value = GetConfigOptionByName(name, &varname, false);
463
464 /* need a tuple descriptor representing a single TEXT column */
465 tupdesc = CreateTemplateTupleDesc(1);
466 TupleDescInitBuiltinEntry(tupdesc, (AttrNumber) 1, varname,
467 TEXTOID, -1, 0);
468
469 /* prepare for projection of tuples */
470 tstate = begin_tup_output_tupdesc(dest, tupdesc, &TTSOpsVirtual);
471
472 /* Send it */
474
475 end_tup_output(tstate);
476}
#define do_text_output_oneline(tstate, str_to_emit)
Definition: executor.h:628

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