Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7cbfa75

Browse files
committed
Fix postgres --describe-config for guc enums, breakage noted by Alvaro.
While at it, rename option lookup functions to make names clearer, perdiscussion with Tom.
1 parent164899d commit7cbfa75

File tree

3 files changed

+28
-18
lines changed

3 files changed

+28
-18
lines changed

‎src/backend/utils/misc/guc.c

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Written by Peter Eisentraut <peter_e@gmx.net>.
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.438 2008/03/16 16:42:44 mha Exp $
13+
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.439 2008/03/17 17:45:09 mha Exp $
1414
*
1515
*--------------------------------------------------------------------
1616
*/
@@ -168,9 +168,6 @@ static const char *show_tcp_keepalives_count(void);
168168
staticboolassign_autovacuum_max_workers(intnewval,booldoit,GucSourcesource);
169169
staticboolassign_maxconnections(intnewval,booldoit,GucSourcesource);
170170

171-
staticconstchar*config_enum_lookup_value(structconfig_enum*record,intval);
172-
staticboolconfig_enum_lookup_name(structconfig_enum*record,
173-
constchar*value,int*retval);
174171
staticchar*config_enum_get_options(structconfig_enum*record,
175172
constchar*prefix,constchar*suffix);
176173

@@ -3144,7 +3141,7 @@ InitializeGUCOptions(void)
31443141
PGC_S_DEFAULT))
31453142
elog(FATAL,"failed to initialize %s to %s",
31463143
conf->gen.name,
3147-
config_enum_lookup_value(conf,conf->boot_val));
3144+
config_enum_lookup_by_value(conf,conf->boot_val));
31483145
*conf->variable=conf->reset_val=conf->boot_val;
31493146
break;
31503147
}
@@ -4219,8 +4216,8 @@ parse_real(const char *value, double *result)
42194216
* The returned string is a pointer to static data and not
42204217
* allocated for modification.
42214218
*/
4222-
staticconstchar*
4223-
config_enum_lookup_value(structconfig_enum*record,intval)
4219+
constchar*
4220+
config_enum_lookup_by_value(structconfig_enum*record,intval)
42244221
{
42254222
conststructconfig_enum_entry*entry=record->options;
42264223
while (entry&&entry->name)
@@ -4242,8 +4239,8 @@ config_enum_lookup_value(struct config_enum *record, int val)
42424239
* true. If it's not found, return FALSE and retval is set to 0.
42434240
*
42444241
*/
4245-
staticbool
4246-
config_enum_lookup_name(structconfig_enum*record,constchar*value,int*retval)
4242+
bool
4243+
config_enum_lookup_by_name(structconfig_enum*record,constchar*value,int*retval)
42474244
{
42484245
conststructconfig_enum_entry*entry=record->options;
42494246

@@ -4876,7 +4873,7 @@ set_config_option(const char *name, const char *value,
48764873

48774874
if (value)
48784875
{
4879-
if (!config_enum_lookup_name(conf,value,&newval))
4876+
if (!config_enum_lookup_by_name(conf,value,&newval))
48804877
{
48814878
char*hintmsg=config_enum_get_options(conf,"Available values: ",".");
48824879

@@ -4906,7 +4903,7 @@ set_config_option(const char *name, const char *value,
49064903
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
49074904
errmsg("invalid value for parameter \"%s\": \"%s\"",
49084905
name,
4909-
config_enum_lookup_value(conf,newval))));
4906+
config_enum_lookup_by_value(conf,newval))));
49104907
return false;
49114908
}
49124909

@@ -5007,7 +5004,7 @@ GetConfigOption(const char *name)
50075004
return*((structconfig_string*)record)->variable;
50085005

50095006
casePGC_ENUM:
5010-
returnconfig_enum_lookup_value((structconfig_enum*)record,
5007+
returnconfig_enum_lookup_by_value((structconfig_enum*)record,
50115008
*((structconfig_enum*)record)->variable);
50125009
}
50135010
returnNULL;
@@ -5055,7 +5052,7 @@ GetConfigOptionResetString(const char *name)
50555052
return ((structconfig_string*)record)->reset_val;
50565053

50575054
casePGC_ENUM:
5058-
returnconfig_enum_lookup_value((structconfig_enum*)record,
5055+
returnconfig_enum_lookup_by_value((structconfig_enum*)record,
50595056
((structconfig_enum*)record)->reset_val);
50605057
}
50615058
returnNULL;
@@ -6265,7 +6262,7 @@ _ShowOption(struct config_generic * record, bool use_units)
62656262
if(conf->show_hook)
62666263
val= (*conf->show_hook) ();
62676264
else
6268-
val=config_enum_lookup_value(conf,*conf->variable);
6265+
val=config_enum_lookup_by_value(conf,*conf->variable);
62696266
}
62706267
break;
62716268

@@ -6331,7 +6328,7 @@ is_newvalue_equal(struct config_generic * record, const char *newvalue)
63316328
structconfig_enum*conf= (structconfig_enum*)record;
63326329
intnewval;
63336330

6334-
returnconfig_enum_lookup_name(conf,newvalue,&newval)
6331+
returnconfig_enum_lookup_by_name(conf,newvalue,&newval)
63356332
&&*conf->variable==newval;
63366333
}
63376334
}
@@ -6425,7 +6422,7 @@ write_nondefault_variables(GucContext context)
64256422
{
64266423
structconfig_enum*conf= (structconfig_enum*)gconf;
64276424

6428-
fprintf(fp,"%s",config_enum_lookup_value(conf,*conf->variable));
6425+
fprintf(fp,"%s",config_enum_lookup_by_value(conf,*conf->variable));
64296426
}
64306427
break;
64316428
}

‎src/backend/utils/misc/help_config.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/utils/misc/help_config.c,v 1.20 2008/02/23 19:23:33 tgl Exp $
13+
* $PostgreSQL: pgsql/src/backend/utils/misc/help_config.c,v 1.21 2008/03/17 17:45:09 mha Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -35,6 +35,7 @@ typedef union
3535
structconfig_realreal;
3636
structconfig_intinteger;
3737
structconfig_stringstring;
38+
structconfig_enum_enum;
3839
}mixedStruct;
3940

4041

@@ -120,6 +121,12 @@ printMixedStruct(mixedStruct *structToPrint)
120121
structToPrint->string.boot_val ?structToPrint->string.boot_val :"");
121122
break;
122123

124+
casePGC_ENUM:
125+
printf("ENUM\t%s\t\t\t",
126+
config_enum_lookup_by_value(&structToPrint->_enum,
127+
structToPrint->_enum.boot_val));
128+
break;
129+
123130
default:
124131
write_stderr("internal error: unrecognized run-time parameter type\n");
125132
break;

‎src/include/utils/guc_tables.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
99
*
10-
* $PostgreSQL: pgsql/src/include/utils/guc_tables.h,v 1.40 2008/03/16 16:42:44 mha Exp $
10+
* $PostgreSQL: pgsql/src/include/utils/guc_tables.h,v 1.41 2008/03/17 17:45:09 mha Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -236,4 +236,10 @@ extern struct config_generic **get_guc_variables(void);
236236

237237
externvoidbuild_guc_variables(void);
238238

239+
/* search in enum options */
240+
externconstchar*config_enum_lookup_by_value(structconfig_enum*record,intval);
241+
externboolconfig_enum_lookup_by_name(structconfig_enum*record,
242+
constchar*value,int*retval);
243+
244+
239245
#endif/* GUC_TABLES_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp