8
8
*
9
9
*
10
10
* IDENTIFICATION
11
- * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.438 2004/11/20 00:48:58 tgl Exp $
11
+ * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.439 2004/11/24 19:50:59 tgl Exp $
12
12
*
13
13
* NOTES
14
14
* this is the "main" module of the postgres backend and
@@ -2205,7 +2205,7 @@ PostgresMain(int argc, char *argv[], const char *username)
2205
2205
bool secure ;
2206
2206
int errs = 0 ;
2207
2207
int debug_flag = -1 ; /* -1 means not given */
2208
- List * guc_names = NIL ; /* for possibly- SUSET options */
2208
+ List * guc_names = NIL ; /* for SUSET options */
2209
2209
List * guc_values = NIL ;
2210
2210
GucContext ctx ;
2211
2211
GucSource gucsource ;
@@ -2456,8 +2456,15 @@ PostgresMain(int argc, char *argv[], const char *username)
2456
2456
2457
2457
/*
2458
2458
* s - report usage statistics (timings) after each query
2459
+ *
2460
+ * Since log options are SUSET, we need to postpone unless
2461
+ * still in secure context
2459
2462
*/
2460
- PendingConfigOption ("log_statement_stats" , "true" );
2463
+ if (ctx == PGC_BACKEND )
2464
+ PendingConfigOption ("log_statement_stats" , "true" );
2465
+ else
2466
+ SetConfigOption ("log_statement_stats" , "true" ,
2467
+ ctx , gucsource );
2461
2468
break ;
2462
2469
2463
2470
case 't' :
@@ -2490,7 +2497,12 @@ PostgresMain(int argc, char *argv[], const char *username)
2490
2497
break ;
2491
2498
}
2492
2499
if (tmp )
2493
- PendingConfigOption (tmp , "true" );
2500
+ {
2501
+ if (ctx == PGC_BACKEND )
2502
+ PendingConfigOption (tmp , "true" );
2503
+ else
2504
+ SetConfigOption (tmp , "true" , ctx , gucsource );
2505
+ }
2494
2506
break ;
2495
2507
2496
2508
case 'v' :
@@ -2527,7 +2539,14 @@ PostgresMain(int argc, char *argv[], const char *username)
2527
2539
optarg )));
2528
2540
}
2529
2541
2530
- PendingConfigOption (name , value );
2542
+ /*
2543
+ * If a SUSET option, must postpone evaluation, unless
2544
+ * we are still reading secure switches.
2545
+ */
2546
+ if (ctx == PGC_BACKEND && IsSuperuserConfigOption (name ))
2547
+ PendingConfigOption (name , value );
2548
+ else
2549
+ SetConfigOption (name , value , ctx , gucsource );
2531
2550
free (name );
2532
2551
if (value )
2533
2552
free (value );
@@ -2540,6 +2559,32 @@ PostgresMain(int argc, char *argv[], const char *username)
2540
2559
}
2541
2560
}
2542
2561
2562
+ /*
2563
+ * Process any additional GUC variable settings passed in startup
2564
+ * packet. These are handled exactly like command-line variables.
2565
+ */
2566
+ if (MyProcPort != NULL )
2567
+ {
2568
+ ListCell * gucopts = list_head (MyProcPort -> guc_options );
2569
+
2570
+ while (gucopts )
2571
+ {
2572
+ char * name ;
2573
+ char * value ;
2574
+
2575
+ name = lfirst (gucopts );
2576
+ gucopts = lnext (gucopts );
2577
+
2578
+ value = lfirst (gucopts );
2579
+ gucopts = lnext (gucopts );
2580
+
2581
+ if (IsSuperuserConfigOption (name ))
2582
+ PendingConfigOption (name , value );
2583
+ else
2584
+ SetConfigOption (name , value , PGC_BACKEND , PGC_S_CLIENT );
2585
+ }
2586
+ }
2587
+
2543
2588
/* Acquire configuration parameters, unless inherited from postmaster */
2544
2589
if (!IsUnderPostmaster )
2545
2590
{
@@ -2677,10 +2722,8 @@ PostgresMain(int argc, char *argv[], const char *username)
2677
2722
SetProcessingMode (NormalProcessing );
2678
2723
2679
2724
/*
2680
- * Now that we know if client is a superuser, we can apply GUC options
2681
- * that came from the client. (For option switches that are definitely
2682
- * not SUSET, we just went ahead and applied them above, but anything
2683
- * that is or might be SUSET has to be postponed to here.)
2725
+ * Now that we know if client is a superuser, we can try to apply SUSET
2726
+ * GUC options that came from the client.
2684
2727
*/
2685
2728
ctx = am_superuser ? PGC_SUSET : PGC_USERSET ;
2686
2729
@@ -2703,41 +2746,19 @@ PostgresMain(int argc, char *argv[], const char *username)
2703
2746
}
2704
2747
}
2705
2748
2706
- /*
2707
- * Process any additional GUC variable settings passed in startup
2708
- * packet.
2709
- */
2710
- if (MyProcPort != NULL )
2711
- {
2712
- ListCell * gucopts = list_head (MyProcPort -> guc_options );
2713
-
2714
- while (gucopts )
2715
- {
2716
- char * name ;
2717
- char * value ;
2718
-
2719
- name = lfirst (gucopts );
2720
- gucopts = lnext (gucopts );
2721
-
2722
- value = lfirst (gucopts );
2723
- gucopts = lnext (gucopts );
2724
-
2725
- SetConfigOption (name , value , ctx , PGC_S_CLIENT );
2726
- }
2727
-
2728
- /*
2729
- * set up handler to log session end.
2730
- */
2731
- if (IsUnderPostmaster && Log_disconnections )
2732
- on_proc_exit (log_disconnections , 0 );
2733
- }
2734
-
2735
2749
/*
2736
2750
* Now all GUC states are fully set up. Report them to client if
2737
2751
* appropriate.
2738
2752
*/
2739
2753
BeginReportingGUCOptions ();
2740
2754
2755
+ /*
2756
+ * Also set up handler to log session end; we have to wait till now
2757
+ * to be sure Log_disconnections has its final value.
2758
+ */
2759
+ if (IsUnderPostmaster && Log_disconnections )
2760
+ on_proc_exit (log_disconnections , 0 );
2761
+
2741
2762
/*
2742
2763
* Send this backend's cancellation info to the frontend.
2743
2764
*/
0 commit comments