Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit ea23ec8

Browse files
committed
Remove GUC USERLIMIT variable category, making the affected variables
plain SUSET instead. Also delay processing of options received in client connection request until after we know if the user is a superuser, so that SUSET values can be set that way by legitimate superusers. Per recent discussion.
1 parent 1c7a47c commit ea23ec8

File tree

9 files changed

+193
-389
lines changed

9 files changed

+193
-389
lines changed

doc/src/sgml/runtime.sgml

+22-25
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.291 2004/11/05 19:15:49 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.292 2004/11/14 19:35:28 tgl Exp $
33
-->
44

55
<Chapter Id="runtime">
@@ -2150,7 +2150,7 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Win32
21502150
to the log. The default is <literal>NOTICE</>. Note that
21512151
<literal>LOG</> has a different rank here than in
21522152
<varname>client_min_messages</>.
2153-
Only superusers can increase this option.
2153+
Only superusers can change this setting.
21542154
</para>
21552155
</listitem>
21562156
</varlistentry>
@@ -2186,7 +2186,7 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Win32
21862186
SQL statements causing errors, fatal errors, or panics will be
21872187
logged. Enabling this option can be helpful in tracking down
21882188
the source of any errors that appear in the server log.
2189-
Only superusers can increase this option.
2189+
Only superusers can change this setting.
21902190
</para>
21912191
</listitem>
21922192
</varlistentry>
@@ -2204,8 +2204,7 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Win32
22042204
<literal>250</literal> then all SQL statements that run 250ms
22052205
or longer will be logged. Enabling this option can be
22062206
useful in tracking down unoptimized queries in your applications.
2207-
Only superusers can increase this or set it to minus-one if this
2208-
option is set by the administrator.
2207+
Only superusers can change this setting.
22092208
</para>
22102209
</listitem>
22112210
</varlistentry>
@@ -2332,7 +2331,7 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Win32
23322331
these displays to produce a more readable but much longer
23332332
output format. <varname>client_min_messages</varname> or
23342333
<varname>log_min_messages</varname> must be
2335-
<literal>DEBUG1</literal> or lower to send output to the
2334+
<literal>DEBUG1</literal> or lower to send the output to the
23362335
client or server logs. These options are off by default.
23372336
</para>
23382337
</listitem>
@@ -2372,10 +2371,9 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Win32
23722371
<varname>log_statement</> to be logged. When using this option,
23732372
if you are not using <application>syslog</>, it is recommended
23742373
that you log the PID or session ID using <varname>log_line_prefix</>
2375-
or log the session ID so that you can link the statement to the
2374+
so that you can link the statement to the
23762375
duration using the process ID or session ID. The default is off.
2377-
Only superusers can turn off this option if it is enabled by the
2378-
administrator.
2376+
Only superusers can change this setting.
23792377
</para>
23802378
</listitem>
23812379
</varlistentry>
@@ -2487,35 +2485,35 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Win32
24872485
<listitem>
24882486
<para>
24892487
Controls which SQL statements are logged. Valid values are
2490-
<literal>all</>, <literal>ddl</>, <literal>mod</>, and
2491-
<literal>none</>. <literal>ddl</> logs all data definition
2488+
<literal>none</>, <literal>ddl</>, <literal>mod</>, and
2489+
<literal>all</>. <literal>ddl</> logs all data definition
24922490
commands like <literal>CREATE</>, <literal>ALTER</>, and
24932491
<literal>DROP</> commands. <literal>mod</> logs all
24942492
<literal>ddl</> statements, plus <literal>INSERT</>,
24952493
<literal>UPDATE</>, <literal>DELETE</>, <literal>TRUNCATE</>,
24962494
and <literal>COPY FROM</>. <literal>PREPARE</> and
2497-
<literal>EXPLAIN ANALYZE</> statements are also considered for
2498-
appropriate commands.
2495+
<literal>EXPLAIN ANALYZE</> statements are also logged if their
2496+
contained command is of an appropriate type.
24992497
</para>
25002498
<para>
2501-
The default is <literal>none</>. Only superusers can reduce
2502-
the detail of this option if it has been set by an administrator.
2499+
The default is <literal>none</>. Only superusers can change this
2500+
setting.
25032501
</para>
25042502

25052503
<note>
25062504
<para>
2507-
The <command>EXECUTE</command> statement not considered a
2505+
The <command>EXECUTE</command> statement is not considered a
25082506
<literal>ddl</> or <literal>mod</> statement. When it is logged,
25092507
only the name of the prepared statement is reported, not the
25102508
actual prepared statement.
25112509
</para>
25122510

25132511
<para>
2514-
When a function is defined in a server-side language like
2515-
<application>PL/pgSQL</application>, any queries executed by
2516-
the function will only be logged the first time that the
2512+
When a function is defined in the
2513+
<application>PL/pgSQL</application>server-side language, any queries
2514+
executed by the function will only be logged the first time that the
25172515
function is invoked in a particular session. This is because
2518-
the <application>PL/pgSQL</application> keeps a cache of the
2516+
<application>PL/pgSQL</application> keeps a cache of the
25192517
query plans produced for the SQL statements in the function.
25202518
</para>
25212519
</note>
@@ -2556,11 +2554,10 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Win32
25562554
For each query, write performance statistics of the respective
25572555
module to the server log. This is a crude profiling
25582556
instrument. <varname>log_statement_stats</varname> reports total
2559-
statement statistics, while the others report per-state statistics.
2560-
<varname>log_statement_stats</varname> can not be enabled with
2561-
the other options. All of these options are disabled by default.
2562-
Only superusers can turn off any of these options if they have
2563-
been enabled by the administrator.
2557+
statement statistics, while the others report per-module statistics.
2558+
<varname>log_statement_stats</varname> cannot be enabled together with
2559+
any of the per-module options. All of these options are disabled by
2560+
default. Only superusers can change these settings.
25642561
</para>
25652562
</listitem>
25662563
</varlistentry>

src/backend/bootstrap/bootstrap.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.195 2004/10/10 23:37:16 neilc Exp $
11+
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.196 2004/11/14 19:35:29 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -424,7 +424,7 @@ BootstrapMain(int argc, char *argv[])
424424
/*
425425
* backend initialization
426426
*/
427-
InitPostgres(dbname, NULL);
427+
(void) InitPostgres(dbname, NULL);
428428

429429
/*
430430
* In NOP mode, all we really want to do is create shared memory and

src/backend/postmaster/postmaster.c

+3-26
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.437 2004/11/09 13:01:26 petere Exp $
40+
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.438 2004/11/14 19:35:30 tgl Exp $
4141
*
4242
* NOTES
4343
*
@@ -223,8 +223,6 @@ bool ClientAuthInProgress = false; /* T during new-client
223223
*/
224224
static unsigned int random_seed = 0;
225225

226-
static int debug_flag = 0;
227-
228226
extern char *optarg;
229227
extern int optind,
230228
opterr;
@@ -401,17 +399,8 @@ PostmasterMain(int argc, char *argv[])
401399
userDoption = optarg;
402400
break;
403401
case 'd':
404-
{
405-
/* Turn on debugging for the postmaster. */
406-
char *debugstr = palloc(strlen("debug") + strlen(optarg) + 1);
407-
408-
sprintf(debugstr, "debug%s", optarg);
409-
SetConfigOption("log_min_messages", debugstr,
410-
PGC_POSTMASTER, PGC_S_ARGV);
411-
pfree(debugstr);
412-
debug_flag = atoi(optarg);
413-
break;
414-
}
402+
set_debug_options(atoi(optarg), PGC_POSTMASTER, PGC_S_ARGV);
403+
break;
415404
case 'F':
416405
SetConfigOption("fsync", "false", PGC_POSTMASTER, PGC_S_ARGV);
417406
break;
@@ -2511,7 +2500,6 @@ BackendRun(Port *port)
25112500
char **av;
25122501
int maxac;
25132502
int ac;
2514-
char debugbuf[32];
25152503
char protobuf[32];
25162504
int i;
25172505

@@ -2707,15 +2695,6 @@ BackendRun(Port *port)
27072695

27082696
av[ac++] = "postgres";
27092697

2710-
/*
2711-
* Pass the requested debugging level along to the backend.
2712-
*/
2713-
if (debug_flag > 0)
2714-
{
2715-
snprintf(debugbuf, sizeof(debugbuf), "-d%d", debug_flag);
2716-
av[ac++] = debugbuf;
2717-
}
2718-
27192698
/*
27202699
* Pass any backend switches specified with -o in the postmaster's own
27212700
* command line. We assume these are secure. (It's OK to mangle
@@ -3404,7 +3383,6 @@ write_backend_variables(char *filename, Port *port)
34043383
write_var(ProcStructLock, fp);
34053384
write_var(pgStatSock, fp);
34063385

3407-
write_var(debug_flag, fp);
34083386
write_var(PostmasterPid, fp);
34093387
#ifdef WIN32
34103388
write_var(PostmasterHandle, fp);
@@ -3478,7 +3456,6 @@ read_backend_variables(char *filename, Port *port)
34783456
read_var(ProcStructLock, fp);
34793457
read_var(pgStatSock, fp);
34803458

3481-
read_var(debug_flag, fp);
34823459
read_var(PostmasterPid, fp);
34833460
#ifdef WIN32
34843461
read_var(PostmasterHandle, fp);

0 commit comments

Comments
 (0)