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

Commit2baf4ef

Browse files
committed
Code review for recent GUC changes --- try to make it less obvious that
these things were added at different times by different people ;-).Includes Aizaz Ahmed's patch to remove duplicate array in help_config.c.
1 parentaad71b4 commit2baf4ef

File tree

4 files changed

+152
-132
lines changed

4 files changed

+152
-132
lines changed

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

Lines changed: 116 additions & 77 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-
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.142 2003/07/2816:22:02 momjian Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.143 2003/07/2819:31:32 tgl Exp $
1414
*
1515
*--------------------------------------------------------------------
1616
*/
@@ -155,49 +155,6 @@ static char *timezone_string;
155155
staticchar*XactIsoLevel_string;
156156

157157

158-
/*
159-
* Used for pg_settings. Keep in sync with config_type enum in guc_tables.h
160-
*/
161-
staticchar*config_type_name[]=
162-
{
163-
"bool",
164-
"integer",
165-
"real",
166-
"string"
167-
};
168-
169-
/*
170-
* Used for pg_settings. Keep in sync with GucContext enum in guc.h
171-
*/
172-
staticchar*GucContextName[]=
173-
{
174-
"internal",
175-
"postmaster",
176-
"sighup",
177-
"backend",
178-
"super-user",
179-
"userlimit",
180-
"user"
181-
};
182-
183-
/*
184-
* Used for pg_settings. Keep in sync with GucSource enum in guc.h
185-
*/
186-
staticchar*GucSourceName[]=
187-
{
188-
"default",
189-
"environment variable",
190-
"configuration file",
191-
"command line",
192-
"userstart",
193-
"database",
194-
"user",
195-
"client",
196-
"override",
197-
"session"
198-
};
199-
200-
201158
/* Macros for freeing malloc'd pointers only if appropriate to do so */
202159
/* Some of these tests are probably redundant, but be safe ... */
203160
#defineSET_STRING_VARIABLE(rec,newval) \
@@ -239,46 +196,126 @@ static char *GucSourceName[] =
239196

240197

241198
/*
242-
*The display nameforeach of the groupings defined inenumconfig_group
243-
* This array needs to be kept in sync with enum config_group.
244-
*This array however needs to be NULL terminated.
199+
*Displayable namesforcontext types (enumGucContext)
200+
*
201+
*Note: these strings are deliberately not localized.
245202
*/
246-
constchar*constconfig_group_names[]= {
203+
constchar*constGucContext_Names[]=
204+
{
205+
/* PGC_INTERNAL */"internal",
206+
/* PGC_POSTMASTER */"postmaster",
207+
/* PGC_SIGHUP */"sighup",
208+
/* PGC_BACKEND */"backend",
209+
/* PGC_SUSET */"superuser",
210+
/* PGC_USERLIMIT */"userlimit",
211+
/* PGC_USERSET */"user"
212+
};
213+
214+
/*
215+
* Displayable names for source types (enum GucSource)
216+
*
217+
* Note: these strings are deliberately not localized.
218+
*/
219+
constchar*constGucSource_Names[]=
220+
{
221+
/* PGC_S_DEFAULT */"default",
222+
/* PGC_S_ENV_VAR */"environment variable",
223+
/* PGC_S_FILE */"configuration file",
224+
/* PGC_S_ARGV */"command line",
225+
/* PGC_S_UNPRIVILEGED */"unprivileged",
226+
/* PGC_S_DATABASE */"database",
227+
/* PGC_S_USER */"user",
228+
/* PGC_S_CLIENT */"client",
229+
/* PGC_S_OVERRIDE */"override",
230+
/* PGC_S_SESSION */"session"
231+
};
232+
233+
/*
234+
* Displayable names for the groupings defined in enum config_group
235+
*/
236+
constchar*constconfig_group_names[]=
237+
{
238+
/* UNGROUPED */
247239
gettext_noop("Ungrouped"),
240+
/* CONN_AUTH */
248241
gettext_noop("Connections & Authentication"),
242+
/* CONN_AUTH_SETTINGS */
249243
gettext_noop("Connections & Authentication / Connection Settings"),
244+
/* CONN_AUTH_SECURITY */
250245
gettext_noop("Connections & Authentication / Security & Authentication"),
246+
/* RESOURCES */
251247
gettext_noop("Resource Usage"),
248+
/* RESOURCES_MEM */
252249
gettext_noop("Resource Usage / Memory"),
250+
/* RESOURCES_FSM */
253251
gettext_noop("Resource Usage / Free Space Map"),
252+
/* RESOURCES_KERNEL */
254253
gettext_noop("Resource Usage / Kernel Resources"),
254+
/* WAL */
255255
gettext_noop("Write Ahead Log"),
256+
/* WAL_SETTINGS */
256257
gettext_noop("Write Ahead Log / Settings"),
258+
/* WAL_CHECKPOINTS */
257259
gettext_noop("Write Ahead Log / Checkpoints"),
260+
/* QUERY_TUNING */
258261
gettext_noop("Query Tuning"),
262+
/* QUERY_TUNING_METHOD */
259263
gettext_noop("Query Tuning / Planner Method Enabling"),
264+
/* QUERY_TUNING_COST */
260265
gettext_noop("Query Tuning / Planner Cost Constants"),
266+
/* QUERY_TUNING_GEQO */
261267
gettext_noop("Query Tuning / Genetic Query Optimizer"),
268+
/* QUERY_TUNING_OTHER */
262269
gettext_noop("Query Tuning / Other Planner Options"),
270+
/* LOGGING */
263271
gettext_noop("Reporting & Logging"),
272+
/* LOGGING_SYSLOG */
264273
gettext_noop("Reporting & Logging / Syslog"),
274+
/* LOGGING_WHEN */
265275
gettext_noop("Reporting & Logging / When To Log"),
276+
/* LOGGING_WHAT */
266277
gettext_noop("Reporting & Logging / What To Log"),
278+
/* STATS */
267279
gettext_noop("Statistics"),
280+
/* STATS_MONITORING */
268281
gettext_noop("Statistics / Monitoring"),
282+
/* STATS_COLLECTOR */
269283
gettext_noop("Statistics / Query & Index Statistics Collector"),
284+
/* CLIENT_CONN */
270285
gettext_noop("Client Connection Defaults"),
286+
/* CLIENT_CONN_STATEMENT */
271287
gettext_noop("Client Connection Defaults / Statement Behavior"),
288+
/* CLIENT_CONN_LOCALE */
272289
gettext_noop("Client Connection Defaults / Locale and Formatting"),
290+
/* CLIENT_CONN_OTHER */
273291
gettext_noop("Client Connection Defaults / Other Defaults"),
292+
/* LOCK_MANAGEMENT */
274293
gettext_noop("Lock Management"),
294+
/* COMPAT_OPTIONS */
275295
gettext_noop("Version & Platform Compatibility"),
296+
/* COMPAT_OPTIONS_PREVIOUS */
276297
gettext_noop("Version & Platform Compatibility / Previous Postgres Versions"),
298+
/* COMPAT_OPTIONS_CLIENT */
277299
gettext_noop("Version & Platform Compatibility / Other Platforms & Clients"),
300+
/* DEVELOPER_OPTIONS */
278301
gettext_noop("Developer Options"),
302+
/* help_config wants this array to be null-terminated */
279303
NULL
280304
};
281305

306+
/*
307+
* Displayable names for GUC variable types (enum config_type)
308+
*
309+
* Note: these strings are deliberately not localized.
310+
*/
311+
constchar*constconfig_type_names[]=
312+
{
313+
/* PGC_BOOL */"bool",
314+
/* PGC_INT */"integer",
315+
/* PGC_REAL */"real",
316+
/* PGC_STRING */"string"
317+
};
318+
282319

283320
/*
284321
* Contents of GUC tables
@@ -2509,9 +2546,9 @@ set_config_option(const char *name, const char *value,
25092546
name)));
25102547
return false;
25112548
}
2512-
/* Limit non-super user changes */
2549+
/* Limit non-superuser changes */
25132550
if (record->context==PGC_USERLIMIT&&
2514-
source>PGC_S_USERSTART&&
2551+
source>PGC_S_UNPRIVILEGED&&
25152552
newval<conf->session_val&&
25162553
!superuser())
25172554
{
@@ -2522,10 +2559,10 @@ set_config_option(const char *name, const char *value,
25222559
errhint("Must be superuser to change this value to false.")));
25232560
return false;
25242561
}
2525-
/* Allow admin to override non-super user setting */
2562+
/* Allow admin to override non-superuser setting */
25262563
if (record->context==PGC_USERLIMIT&&
2527-
source<PGC_S_USERSTART&&
2528-
record->session_source>PGC_S_USERSTART&&
2564+
source<PGC_S_UNPRIVILEGED&&
2565+
record->session_source>PGC_S_UNPRIVILEGED&&
25292566
newval>conf->session_val&&
25302567
!superuser())
25312568
DoIt=DoIt_orig;
@@ -2605,9 +2642,9 @@ set_config_option(const char *name, const char *value,
26052642
newval,name,conf->min,conf->max)));
26062643
return false;
26072644
}
2608-
/* Limit non-super user changes */
2645+
/* Limit non-superuser changes */
26092646
if (record->context==PGC_USERLIMIT&&
2610-
source>PGC_S_USERSTART&&
2647+
source>PGC_S_UNPRIVILEGED&&
26112648
conf->session_val!=0&&
26122649
(newval>conf->session_val||newval==0)&&
26132650
!superuser())
@@ -2619,10 +2656,10 @@ set_config_option(const char *name, const char *value,
26192656
errhint("Must be superuser to increase this value or set it to zero.")));
26202657
return false;
26212658
}
2622-
/* Allow admin to override non-super user setting */
2659+
/* Allow admin to override non-superuser setting */
26232660
if (record->context==PGC_USERLIMIT&&
2624-
source<PGC_S_USERSTART&&
2625-
record->session_source>PGC_S_USERSTART&&
2661+
source<PGC_S_UNPRIVILEGED&&
2662+
record->session_source>PGC_S_UNPRIVILEGED&&
26262663
newval<conf->session_val&&
26272664
!superuser())
26282665
DoIt=DoIt_orig;
@@ -2702,9 +2739,9 @@ set_config_option(const char *name, const char *value,
27022739
newval,name,conf->min,conf->max)));
27032740
return false;
27042741
}
2705-
/* Limit non-super user changes */
2742+
/* Limit non-superuser changes */
27062743
if (record->context==PGC_USERLIMIT&&
2707-
source>PGC_S_USERSTART&&
2744+
source>PGC_S_UNPRIVILEGED&&
27082745
newval>conf->session_val&&
27092746
!superuser())
27102747
{
@@ -2715,10 +2752,10 @@ set_config_option(const char *name, const char *value,
27152752
errhint("Must be superuser to increase this value.")));
27162753
return false;
27172754
}
2718-
/* Allow admin to override non-super user setting */
2755+
/* Allow admin to override non-superuser setting */
27192756
if (record->context==PGC_USERLIMIT&&
2720-
source<PGC_S_USERSTART&&
2721-
record->session_source>PGC_S_USERSTART&&
2757+
source<PGC_S_UNPRIVILEGED&&
2758+
record->session_source>PGC_S_UNPRIVILEGED&&
27222759
newval<conf->session_val&&
27232760
!superuser())
27242761
DoIt=DoIt_orig;
@@ -2791,15 +2828,18 @@ set_config_option(const char *name, const char *value,
27912828
return false;
27922829
}
27932830

2794-
if (*conf->variable)
2831+
if (record->context==PGC_USERLIMIT&&
2832+
*conf->variable)
27952833
{
27962834
intold_int_value,new_int_value;
27972835

2798-
/* Limit non-super user changes */
2799-
assign_msglvl(&old_int_value,conf->reset_val, true,interactive);
2800-
assign_msglvl(&new_int_value,newval, true,interactive);
2801-
if (record->context==PGC_USERLIMIT&&
2802-
source>PGC_S_USERSTART&&
2836+
/* all USERLIMIT strings are message levels */
2837+
assign_msglvl(&old_int_value,conf->reset_val,
2838+
true,interactive);
2839+
assign_msglvl(&new_int_value,newval,
2840+
true,interactive);
2841+
/* Limit non-superuser changes */
2842+
if (source>PGC_S_UNPRIVILEGED&&
28032843
new_int_value>old_int_value&&
28042844
!superuser())
28052845
{
@@ -2810,14 +2850,13 @@ set_config_option(const char *name, const char *value,
28102850
errhint("Must be superuser to increase this value.")));
28112851
return false;
28122852
}
2813-
/* Allow admin to override non-super user setting */
2814-
if (record->context==PGC_USERLIMIT&&
2815-
source<PGC_S_USERSTART&&
2816-
record->session_source>PGC_S_USERSTART&&
2853+
/* Allow admin to override non-superuser setting */
2854+
if (source<PGC_S_UNPRIVILEGED&&
2855+
record->session_source>PGC_S_UNPRIVILEGED&&
28172856
newval<conf->session_val&&
28182857
!superuser())
28192858
DoIt=DoIt_orig;
2820-
}
2859+
}
28212860
}
28222861
elseif (conf->reset_val)
28232862
{
@@ -3389,13 +3428,13 @@ GetConfigOptionByNum(int varnum, const char **values, bool *noshow)
33893428
values[1]=_ShowOption(conf);
33903429

33913430
/* context */
3392-
values[2]=GucContextName[conf->context];
3431+
values[2]=GucContext_Names[conf->context];
33933432

33943433
/* vartype */
3395-
values[3]=config_type_name[conf->vartype];
3434+
values[3]=config_type_names[conf->vartype];
33963435

33973436
/* source */
3398-
values[4]=GucSourceName[conf->source];
3437+
values[4]=GucSource_Names[conf->source];
33993438

34003439
/* now get the type specifc attributes */
34013440
switch (conf->vartype)

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

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
2626
*
2727
* IDENTIFICATION
28-
* $Header: /cvsroot/pgsql/src/backend/utils/misc/help_config.c,v 1.2 2003/07/09 17:57:47 momjian Exp $
28+
* $Header: /cvsroot/pgsql/src/backend/utils/misc/help_config.c,v 1.3 2003/07/28 19:31:32 tgl Exp $
2929
*
3030
*-------------------------------------------------------------------------
3131
*/
@@ -132,20 +132,6 @@ static void printGenericFoot(struct config_generic structToPrint);
132132
staticvoidprintMixedStruct(mixedStruct*structToPrint);
133133
staticbooldisplayStruct(mixedStruct*structToDisplay);
134134

135-
/*
136-
* This array contains the display names for each of the GucContexts available
137-
*
138-
* Note: these strings are deliberately not localized.
139-
*/
140-
staticconstchar*constGucContext_names[]= {
141-
"INTERNAL",
142-
"POSTMASTER",
143-
"SIGHUP",
144-
"BACKEND",
145-
"SUSET",
146-
"USERLIMIT",
147-
"USERSET"
148-
};
149135

150136
/*
151137
* Reads in the the command line options and sets the state of the program
@@ -406,7 +392,7 @@ printGenericHead(struct config_generic structToPrint)
406392
{
407393
printf(gettext(GENERIC_FORMAT[outFormat]),
408394
structToPrint.name,
409-
GucContext_names[structToPrint.context],
395+
GucContext_Names[structToPrint.context],
410396
gettext(config_group_names[structToPrint.group]));
411397
}
412398

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp