Skip to content

Commit 29dc7a6

Browse files
committed
Add some const qualifiers
in guc-related source files, in anticipation of some further restructuring. Reviewed-by: Chao Li <li.evan.chao@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/8fdfb91e-60fb-44fa-8df6-f5dea47353c9@eisentraut.org
1 parent 1a79518 commit 29dc7a6

File tree

3 files changed

+44
-44
lines changed

3 files changed

+44
-44
lines changed

src/backend/utils/misc/guc.c

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -261,15 +261,15 @@ static bool assignable_custom_variable_name(const char *name, bool skip_errors,
261261
int elevel);
262262
static void do_serialize(char **destptr, Size *maxbytes,
263263
const char *fmt,...) pg_attribute_printf(3, 4);
264-
static bool call_bool_check_hook(struct config_bool *conf, bool *newval,
264+
static bool call_bool_check_hook(const struct config_bool *conf, bool *newval,
265265
void **extra, GucSource source, int elevel);
266-
static bool call_int_check_hook(struct config_int *conf, int *newval,
266+
static bool call_int_check_hook(const struct config_int *conf, int *newval,
267267
void **extra, GucSource source, int elevel);
268-
static bool call_real_check_hook(struct config_real *conf, double *newval,
268+
static bool call_real_check_hook(const struct config_real *conf, double *newval,
269269
void **extra, GucSource source, int elevel);
270-
static bool call_string_check_hook(struct config_string *conf, char **newval,
270+
static bool call_string_check_hook(const struct config_string *conf, char **newval,
271271
void **extra, GucSource source, int elevel);
272-
static bool call_enum_check_hook(struct config_enum *conf, int *newval,
272+
static bool call_enum_check_hook(const struct config_enum *conf, int *newval,
273273
void **extra, GucSource source, int elevel);
274274

275275

@@ -1425,14 +1425,14 @@ check_GUC_name_for_parameter_acl(const char *name)
14251425
*/
14261426
#ifdef USE_ASSERT_CHECKING
14271427
static bool
1428-
check_GUC_init(struct config_generic *gconf)
1428+
check_GUC_init(const struct config_generic *gconf)
14291429
{
14301430
/* Checks on values */
14311431
switch (gconf->vartype)
14321432
{
14331433
case PGC_BOOL:
14341434
{
1435-
struct config_bool *conf = (struct config_bool *) gconf;
1435+
const struct config_bool *conf = (const struct config_bool *) gconf;
14361436

14371437
if (*conf->variable && !conf->boot_val)
14381438
{
@@ -1444,7 +1444,7 @@ check_GUC_init(struct config_generic *gconf)
14441444
}
14451445
case PGC_INT:
14461446
{
1447-
struct config_int *conf = (struct config_int *) gconf;
1447+
const struct config_int *conf = (const struct config_int *) gconf;
14481448

14491449
if (*conf->variable != 0 && *conf->variable != conf->boot_val)
14501450
{
@@ -1456,7 +1456,7 @@ check_GUC_init(struct config_generic *gconf)
14561456
}
14571457
case PGC_REAL:
14581458
{
1459-
struct config_real *conf = (struct config_real *) gconf;
1459+
const struct config_real *conf = (const struct config_real *) gconf;
14601460

14611461
if (*conf->variable != 0.0 && *conf->variable != conf->boot_val)
14621462
{
@@ -1468,7 +1468,7 @@ check_GUC_init(struct config_generic *gconf)
14681468
}
14691469
case PGC_STRING:
14701470
{
1471-
struct config_string *conf = (struct config_string *) gconf;
1471+
const struct config_string *conf = (const struct config_string *) gconf;
14721472

14731473
if (*conf->variable != NULL &&
14741474
(conf->boot_val == NULL ||
@@ -1482,7 +1482,7 @@ check_GUC_init(struct config_generic *gconf)
14821482
}
14831483
case PGC_ENUM:
14841484
{
1485-
struct config_enum *conf = (struct config_enum *) gconf;
1485+
const struct config_enum *conf = (const struct config_enum *) gconf;
14861486

14871487
if (*conf->variable != conf->boot_val)
14881488
{
@@ -3013,7 +3013,7 @@ parse_real(const char *value, double *result, int flags, const char **hintmsg)
30133013
* allocated for modification.
30143014
*/
30153015
const char *
3016-
config_enum_lookup_by_value(struct config_enum *record, int val)
3016+
config_enum_lookup_by_value(const struct config_enum *record, int val)
30173017
{
30183018
for (const struct config_enum_entry *entry = record->options; entry && entry->name; entry++)
30193019
{
@@ -3034,7 +3034,7 @@ config_enum_lookup_by_value(struct config_enum *record, int val)
30343034
* true. If it's not found, return false and retval is set to 0.
30353035
*/
30363036
bool
3037-
config_enum_lookup_by_name(struct config_enum *record, const char *value,
3037+
config_enum_lookup_by_name(const struct config_enum *record, const char *value,
30383038
int *retval)
30393039
{
30403040
for (const struct config_enum_entry *entry = record->options; entry && entry->name; entry++)
@@ -3058,7 +3058,7 @@ config_enum_lookup_by_name(struct config_enum *record, const char *value,
30583058
* If suffix is non-NULL, it is added to the end of the string.
30593059
*/
30603060
char *
3061-
config_enum_get_options(struct config_enum *record, const char *prefix,
3061+
config_enum_get_options(const struct config_enum *record, const char *prefix,
30623062
const char *suffix, const char *separator)
30633063
{
30643064
StringInfoData retstr;
@@ -3114,7 +3114,7 @@ config_enum_get_options(struct config_enum *record, const char *prefix,
31143114
* Returns true if OK, false if not (or throws error, if elevel >= ERROR)
31153115
*/
31163116
static bool
3117-
parse_and_validate_value(struct config_generic *record,
3117+
parse_and_validate_value(const struct config_generic *record,
31183118
const char *value,
31193119
GucSource source, int elevel,
31203120
union config_var_val *newval, void **newextra)
@@ -3123,7 +3123,7 @@ parse_and_validate_value(struct config_generic *record,
31233123
{
31243124
case PGC_BOOL:
31253125
{
3126-
struct config_bool *conf = (struct config_bool *) record;
3126+
const struct config_bool *conf = (const struct config_bool *) record;
31273127

31283128
if (!parse_bool(value, &newval->boolval))
31293129
{
@@ -3141,7 +3141,7 @@ parse_and_validate_value(struct config_generic *record,
31413141
break;
31423142
case PGC_INT:
31433143
{
3144-
struct config_int *conf = (struct config_int *) record;
3144+
const struct config_int *conf = (const struct config_int *) record;
31453145
const char *hintmsg;
31463146

31473147
if (!parse_int(value, &newval->intval,
@@ -3182,7 +3182,7 @@ parse_and_validate_value(struct config_generic *record,
31823182
break;
31833183
case PGC_REAL:
31843184
{
3185-
struct config_real *conf = (struct config_real *) record;
3185+
const struct config_real *conf = (const struct config_real *) record;
31863186
const char *hintmsg;
31873187

31883188
if (!parse_real(value, &newval->realval,
@@ -3223,7 +3223,7 @@ parse_and_validate_value(struct config_generic *record,
32233223
break;
32243224
case PGC_STRING:
32253225
{
3226-
struct config_string *conf = (struct config_string *) record;
3226+
const struct config_string *conf = (const struct config_string *) record;
32273227

32283228
/*
32293229
* The value passed by the caller could be transient, so we
@@ -3253,7 +3253,7 @@ parse_and_validate_value(struct config_generic *record,
32533253
break;
32543254
case PGC_ENUM:
32553255
{
3256-
struct config_enum *conf = (struct config_enum *) record;
3256+
const struct config_enum *conf = (const struct config_enum *) record;
32573257

32583258
if (!config_enum_lookup_by_name(conf, value, &newval->enumval))
32593259
{
@@ -5456,7 +5456,7 @@ GetConfigOptionByName(const char *name, const char **varname, bool missing_ok)
54565456
* The result string is palloc'd.
54575457
*/
54585458
char *
5459-
ShowGUCOption(struct config_generic *record, bool use_units)
5459+
ShowGUCOption(const struct config_generic *record, bool use_units)
54605460
{
54615461
char buffer[256];
54625462
const char *val;
@@ -5465,7 +5465,7 @@ ShowGUCOption(struct config_generic *record, bool use_units)
54655465
{
54665466
case PGC_BOOL:
54675467
{
5468-
struct config_bool *conf = (struct config_bool *) record;
5468+
const struct config_bool *conf = (const struct config_bool *) record;
54695469

54705470
if (conf->show_hook)
54715471
val = conf->show_hook();
@@ -5476,7 +5476,7 @@ ShowGUCOption(struct config_generic *record, bool use_units)
54765476

54775477
case PGC_INT:
54785478
{
5479-
struct config_int *conf = (struct config_int *) record;
5479+
const struct config_int *conf = (const struct config_int *) record;
54805480

54815481
if (conf->show_hook)
54825482
val = conf->show_hook();
@@ -5505,7 +5505,7 @@ ShowGUCOption(struct config_generic *record, bool use_units)
55055505

55065506
case PGC_REAL:
55075507
{
5508-
struct config_real *conf = (struct config_real *) record;
5508+
const struct config_real *conf = (const struct config_real *) record;
55095509

55105510
if (conf->show_hook)
55115511
val = conf->show_hook();
@@ -5530,7 +5530,7 @@ ShowGUCOption(struct config_generic *record, bool use_units)
55305530

55315531
case PGC_STRING:
55325532
{
5533-
struct config_string *conf = (struct config_string *) record;
5533+
const struct config_string *conf = (const struct config_string *) record;
55345534

55355535
if (conf->show_hook)
55365536
val = conf->show_hook();
@@ -5543,7 +5543,7 @@ ShowGUCOption(struct config_generic *record, bool use_units)
55435543

55445544
case PGC_ENUM:
55455545
{
5546-
struct config_enum *conf = (struct config_enum *) record;
5546+
const struct config_enum *conf = (const struct config_enum *) record;
55475547

55485548
if (conf->show_hook)
55495549
val = conf->show_hook();
@@ -6789,7 +6789,7 @@ GUC_check_errcode(int sqlerrcode)
67896789
*/
67906790

67916791
static bool
6792-
call_bool_check_hook(struct config_bool *conf, bool *newval, void **extra,
6792+
call_bool_check_hook(const struct config_bool *conf, bool *newval, void **extra,
67936793
GucSource source, int elevel)
67946794
{
67956795
/* Quick success if no hook */
@@ -6823,7 +6823,7 @@ call_bool_check_hook(struct config_bool *conf, bool *newval, void **extra,
68236823
}
68246824

68256825
static bool
6826-
call_int_check_hook(struct config_int *conf, int *newval, void **extra,
6826+
call_int_check_hook(const struct config_int *conf, int *newval, void **extra,
68276827
GucSource source, int elevel)
68286828
{
68296829
/* Quick success if no hook */
@@ -6857,7 +6857,7 @@ call_int_check_hook(struct config_int *conf, int *newval, void **extra,
68576857
}
68586858

68596859
static bool
6860-
call_real_check_hook(struct config_real *conf, double *newval, void **extra,
6860+
call_real_check_hook(const struct config_real *conf, double *newval, void **extra,
68616861
GucSource source, int elevel)
68626862
{
68636863
/* Quick success if no hook */
@@ -6891,7 +6891,7 @@ call_real_check_hook(struct config_real *conf, double *newval, void **extra,
68916891
}
68926892

68936893
static bool
6894-
call_string_check_hook(struct config_string *conf, char **newval, void **extra,
6894+
call_string_check_hook(const struct config_string *conf, char **newval, void **extra,
68956895
GucSource source, int elevel)
68966896
{
68976897
volatile bool result = true;
@@ -6941,7 +6941,7 @@ call_string_check_hook(struct config_string *conf, char **newval, void **extra,
69416941
}
69426942

69436943
static bool
6944-
call_enum_check_hook(struct config_enum *conf, int *newval, void **extra,
6944+
call_enum_check_hook(const struct config_enum *conf, int *newval, void **extra,
69456945
GucSource source, int elevel)
69466946
{
69476947
/* Quick success if no hook */

src/backend/utils/misc/guc_funcs.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ pg_settings_get_flags(PG_FUNCTION_ARGS)
578578
* Return whether or not the GUC variable is visible to the current user.
579579
*/
580580
bool
581-
ConfigOptionIsVisible(struct config_generic *conf)
581+
ConfigOptionIsVisible(const struct config_generic *conf)
582582
{
583583
if ((conf->flags & GUC_SUPERUSER_ONLY) &&
584584
!has_privs_of_role(GetUserId(), ROLE_PG_READ_ALL_SETTINGS))
@@ -591,7 +591,7 @@ ConfigOptionIsVisible(struct config_generic *conf)
591591
* Extract fields to show in pg_settings for given variable.
592592
*/
593593
static void
594-
GetConfigOptionValues(struct config_generic *conf, const char **values)
594+
GetConfigOptionValues(const struct config_generic *conf, const char **values)
595595
{
596596
char buffer[256];
597597

@@ -629,7 +629,7 @@ GetConfigOptionValues(struct config_generic *conf, const char **values)
629629
{
630630
case PGC_BOOL:
631631
{
632-
struct config_bool *lconf = (struct config_bool *) conf;
632+
const struct config_bool *lconf = (const struct config_bool *) conf;
633633

634634
/* min_val */
635635
values[9] = NULL;
@@ -650,7 +650,7 @@ GetConfigOptionValues(struct config_generic *conf, const char **values)
650650

651651
case PGC_INT:
652652
{
653-
struct config_int *lconf = (struct config_int *) conf;
653+
const struct config_int *lconf = (const struct config_int *) conf;
654654

655655
/* min_val */
656656
snprintf(buffer, sizeof(buffer), "%d", lconf->min);
@@ -675,7 +675,7 @@ GetConfigOptionValues(struct config_generic *conf, const char **values)
675675

676676
case PGC_REAL:
677677
{
678-
struct config_real *lconf = (struct config_real *) conf;
678+
const struct config_real *lconf = (const struct config_real *) conf;
679679

680680
/* min_val */
681681
snprintf(buffer, sizeof(buffer), "%g", lconf->min);
@@ -700,7 +700,7 @@ GetConfigOptionValues(struct config_generic *conf, const char **values)
700700

701701
case PGC_STRING:
702702
{
703-
struct config_string *lconf = (struct config_string *) conf;
703+
const struct config_string *lconf = (const struct config_string *) conf;
704704

705705
/* min_val */
706706
values[9] = NULL;
@@ -727,7 +727,7 @@ GetConfigOptionValues(struct config_generic *conf, const char **values)
727727

728728
case PGC_ENUM:
729729
{
730-
struct config_enum *lconf = (struct config_enum *) conf;
730+
const struct config_enum *lconf = (const struct config_enum *) conf;
731731

732732
/* min_val */
733733
values[9] = NULL;
@@ -741,7 +741,7 @@ GetConfigOptionValues(struct config_generic *conf, const char **values)
741741
* NOTE! enumvals with double quotes in them are not
742742
* supported!
743743
*/
744-
values[11] = config_enum_get_options((struct config_enum *) conf,
744+
values[11] = config_enum_get_options(lconf,
745745
"{\"", "\"}", "\",\"");
746746

747747
/* boot_val */

src/include/utils/guc_tables.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -319,21 +319,21 @@ extern struct config_generic *find_option(const char *name,
319319
extern struct config_generic **get_explain_guc_options(int *num);
320320

321321
/* get string value of variable */
322-
extern char *ShowGUCOption(struct config_generic *record, bool use_units);
322+
extern char *ShowGUCOption(const struct config_generic *record, bool use_units);
323323

324324
/* get whether or not the GUC variable is visible to current user */
325-
extern bool ConfigOptionIsVisible(struct config_generic *conf);
325+
extern bool ConfigOptionIsVisible(const struct config_generic *conf);
326326

327327
/* get the current set of variables */
328328
extern struct config_generic **get_guc_variables(int *num_vars);
329329

330330
extern void build_guc_variables(void);
331331

332332
/* search in enum options */
333-
extern const char *config_enum_lookup_by_value(struct config_enum *record, int val);
334-
extern bool config_enum_lookup_by_name(struct config_enum *record,
333+
extern const char *config_enum_lookup_by_value(const struct config_enum *record, int val);
334+
extern bool config_enum_lookup_by_name(const struct config_enum *record,
335335
const char *value, int *retval);
336-
extern char *config_enum_get_options(struct config_enum *record,
336+
extern char *config_enum_get_options(const struct config_enum *record,
337337
const char *prefix,
338338
const char *suffix,
339339
const char *separator);

0 commit comments

Comments
 (0)