|
10 | 10 | * Written by Peter Eisentraut <peter_e@gmx.net>.
|
11 | 11 | *
|
12 | 12 | * IDENTIFICATION
|
13 |
| - * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.334 2006/08/11 20:08:28 momjian Exp $ |
| 13 | + * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.335 2006/08/11 20:15:16 momjian Exp $ |
14 | 14 | *
|
15 | 15 | *--------------------------------------------------------------------
|
16 | 16 | */
|
@@ -2694,39 +2694,39 @@ InitializeGUCOptions(void)
|
2694 | 2694 | struct config_bool *conf = (struct config_bool *) gconf;
|
2695 | 2695 |
|
2696 | 2696 | if (conf->assign_hook)
|
2697 |
| - if (!(*conf->assign_hook) (conf->reset_val, true, |
| 2697 | + if (!(*conf->assign_hook) (conf->boot_val, true, |
2698 | 2698 | PGC_S_DEFAULT))
|
2699 | 2699 | elog(FATAL, "failed to initialize %s to %d",
|
2700 |
| - conf->gen.name, (int) conf->reset_val); |
2701 |
| - *conf->variable = conf->reset_val; |
| 2700 | + conf->gen.name, (int) conf->boot_val); |
| 2701 | + *conf->variable = conf->reset_val = conf->boot_val; |
2702 | 2702 | break;
|
2703 | 2703 | }
|
2704 | 2704 | case PGC_INT:
|
2705 | 2705 | {
|
2706 | 2706 | struct config_int *conf = (struct config_int *) gconf;
|
2707 | 2707 |
|
2708 |
| - Assert(conf->reset_val >= conf->min); |
2709 |
| - Assert(conf->reset_val <= conf->max); |
| 2708 | + Assert(conf->boot_val >= conf->min); |
| 2709 | + Assert(conf->boot_val <= conf->max); |
2710 | 2710 | if (conf->assign_hook)
|
2711 |
| - if (!(*conf->assign_hook) (conf->reset_val, true, |
| 2711 | + if (!(*conf->assign_hook) (conf->boot_val, true, |
2712 | 2712 | PGC_S_DEFAULT))
|
2713 | 2713 | elog(FATAL, "failed to initialize %s to %d",
|
2714 |
| - conf->gen.name, conf->reset_val); |
2715 |
| - *conf->variable = conf->reset_val; |
| 2714 | + conf->gen.name, conf->boot_val); |
| 2715 | + *conf->variable = conf->reset_val = conf->boot_val; |
2716 | 2716 | break;
|
2717 | 2717 | }
|
2718 | 2718 | case PGC_REAL:
|
2719 | 2719 | {
|
2720 | 2720 | struct config_real *conf = (struct config_real *) gconf;
|
2721 | 2721 |
|
2722 |
| - Assert(conf->reset_val >= conf->min); |
2723 |
| - Assert(conf->reset_val <= conf->max); |
| 2722 | + Assert(conf->boot_val >= conf->min); |
| 2723 | + Assert(conf->boot_val <= conf->max); |
2724 | 2724 | if (conf->assign_hook)
|
2725 |
| - if (!(*conf->assign_hook) (conf->reset_val, true, |
| 2725 | + if (!(*conf->assign_hook) (conf->boot_val, true, |
2726 | 2726 | PGC_S_DEFAULT))
|
2727 | 2727 | elog(FATAL, "failed to initialize %s to %g",
|
2728 |
| - conf->gen.name, conf->reset_val); |
2729 |
| - *conf->variable = conf->reset_val; |
| 2728 | + conf->gen.name, conf->boot_val); |
| 2729 | + *conf->variable = conf->reset_val = conf->boot_val; |
2730 | 2730 | break;
|
2731 | 2731 | }
|
2732 | 2732 | case PGC_STRING:
|
@@ -3179,7 +3179,7 @@ AtEOXact_GUC(bool isCommit, bool isSubXact)
|
3179 | 3179 | for (i = 0; i < num_guc_variables; i++)
|
3180 | 3180 | {
|
3181 | 3181 | struct config_generic *gconf = guc_variables[i];
|
3182 |
| - int my_status = gconf->status; |
| 3182 | + int my_status = gconf->status & (~GUC_IN_CONFFILE); |
3183 | 3183 | GucStack *stack = gconf->stack;
|
3184 | 3184 | bool useTentative;
|
3185 | 3185 | bool changed;
|
@@ -3726,8 +3726,19 @@ parse_value(int elevel, const struct config_generic *record,
|
3726 | 3726 | }
|
3727 | 3727 | else
|
3728 | 3728 | {
|
3729 |
| - newval = conf->reset_val; |
3730 |
| - *source = conf->gen.reset_source; |
| 3729 | + /* Revert value to default if source is configuration file. It is used when |
| 3730 | + * configuration parameter is removed/commented out in the config file. Else |
| 3731 | + * RESET or SET TO DEFAULT command is called and reset_val is used. |
| 3732 | + */ |
| 3733 | + if( *source == PGC_S_FILE ) |
| 3734 | + { |
| 3735 | + newval = conf->boot_val; |
| 3736 | + } |
| 3737 | + else |
| 3738 | + { |
| 3739 | + newval = conf->reset_val; |
| 3740 | + *source = conf->gen.reset_source; |
| 3741 | + } |
3731 | 3742 | }
|
3732 | 3743 |
|
3733 | 3744 | if (conf->assign_hook)
|
@@ -3770,8 +3781,19 @@ parse_value(int elevel, const struct config_generic *record,
|
3770 | 3781 | }
|
3771 | 3782 | else
|
3772 | 3783 | {
|
3773 |
| - newval = conf->reset_val; |
3774 |
| - *source = conf->gen.reset_source; |
| 3784 | + /* Revert value to default if source is configuration file. It is used when |
| 3785 | + * configuration parameter is removed/commented out in the config file. Else |
| 3786 | + * RESET or SET TO DEFAULT command is called and reset_val is used. |
| 3787 | + */ |
| 3788 | + if( *source == PGC_S_FILE ) |
| 3789 | + { |
| 3790 | + newval = conf->boot_val; |
| 3791 | + } |
| 3792 | + else |
| 3793 | + { |
| 3794 | + newval = conf->reset_val; |
| 3795 | + *source = conf->gen.reset_source; |
| 3796 | + } |
3775 | 3797 | }
|
3776 | 3798 |
|
3777 | 3799 | if (conf->assign_hook)
|
@@ -3814,8 +3836,19 @@ parse_value(int elevel, const struct config_generic *record,
|
3814 | 3836 | }
|
3815 | 3837 | else
|
3816 | 3838 | {
|
3817 |
| - newval = conf->reset_val; |
3818 |
| - *source = conf->gen.reset_source; |
| 3839 | + /* Revert value to default if source is configuration file. It is used when |
| 3840 | + * configuration parameter is removed/commented out in the config file. Else |
| 3841 | + * RESET or SET TO DEFAULT command is called and reset_val is used. |
| 3842 | + */ |
| 3843 | + if( *source == PGC_S_FILE ) |
| 3844 | + { |
| 3845 | + newval = conf->boot_val; |
| 3846 | + } |
| 3847 | + else |
| 3848 | + { |
| 3849 | + newval = conf->reset_val; |
| 3850 | + *source = conf->gen.reset_source; |
| 3851 | + } |
3819 | 3852 | }
|
3820 | 3853 |
|
3821 | 3854 | if (conf->assign_hook)
|
@@ -3849,6 +3882,20 @@ parse_value(int elevel, const struct config_generic *record,
|
3849 | 3882 | if (conf->gen.flags & GUC_IS_NAME)
|
3850 | 3883 | truncate_identifier(newval, strlen(newval), true);
|
3851 | 3884 | }
|
| 3885 | + else if (*source == PGC_S_FILE) |
| 3886 | + { |
| 3887 | + /* Revert value to default when item is removed from config file. */ |
| 3888 | + if ( conf->boot_val != NULL ) |
| 3889 | + { |
| 3890 | + newval = guc_strdup(elevel, conf->boot_val); |
| 3891 | + if (newval == NULL) |
| 3892 | + return false; |
| 3893 | + } |
| 3894 | + else |
| 3895 | + { |
| 3896 | + return false; |
| 3897 | + } |
| 3898 | + } |
3852 | 3899 | else if (conf->reset_val)
|
3853 | 3900 | {
|
3854 | 3901 | /*
|
@@ -4053,6 +4100,11 @@ verify_config_option(const char *name, const char *value,
|
4053 | 4100 |
|
4054 | 4101 | if( parse_value(elevel, record, value, &source, false, &newval) )
|
4055 | 4102 | {
|
| 4103 | + /* Mark record like presented in the config file. Be carefull if |
| 4104 | + * you use this function for another purpose than config file |
| 4105 | + * verification. It causes confusion configfile parser. */ |
| 4106 | + record->status |= GUC_IN_CONFFILE; |
| 4107 | + |
4056 | 4108 | if( isNewEqual != NULL)
|
4057 | 4109 | *isNewEqual = is_newvalue_equal(record, value);
|
4058 | 4110 | if( isContextOK != NULL)
|
@@ -4115,7 +4167,7 @@ set_config_option(const char *name, const char *value,
|
4115 | 4167 | * Should we set reset/stacked values? (If so, the behavior is not
|
4116 | 4168 | * transactional.)
|
4117 | 4169 | */
|
4118 |
| - makeDefault = changeVal && (source <= PGC_S_OVERRIDE) && (value != NULL); |
| 4170 | + makeDefault = changeVal && (source <= PGC_S_OVERRIDE) && (value != NULL || source == PGC_S_FILE); |
4119 | 4171 |
|
4120 | 4172 | /*
|
4121 | 4173 | * Ignore attempted set if overridden by previously processed setting.
|
|
0 commit comments