Fix an old corner-case bug in set_config_option: push_old_value has to be
called before, not after, calling the assign_hook if any. This is because push_old_value might fail (due to palloc out-of-memory), and in that case there would be no stack entry to tell transaction abort to undo the GUC assignment. Of course the actual assignment to the GUC variable hasn't happened yet --- but the assign_hook might have altered subsidiary state. Without a stack entry we won't call it again to make it undo such actions. So this is necessary to make the world safe for assign_hooks with side effects. Per a discussion a couple weeks ago with Magnus. Back-patch to 8.0. 7.x did not have the problem because it did not have allocatable stacks of GUC values.
This commit is contained in:
parent
888706a883
commit
ed91252bc2
@ -10,7 +10,7 @@
|
|||||||
* Written by Peter Eisentraut <peter_e@gmx.net>.
|
* Written by Peter Eisentraut <peter_e@gmx.net>.
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.432 2008/01/30 18:35:55 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.432.2.1 2008/05/26 18:54:36 tgl Exp $
|
||||||
*
|
*
|
||||||
*--------------------------------------------------------------------
|
*--------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -4370,6 +4370,10 @@ set_config_option(const char *name, const char *value,
|
|||||||
source = conf->gen.reset_source;
|
source = conf->gen.reset_source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Save old value to support transaction abort */
|
||||||
|
if (changeVal && !makeDefault)
|
||||||
|
push_old_value(&conf->gen, action);
|
||||||
|
|
||||||
if (conf->assign_hook)
|
if (conf->assign_hook)
|
||||||
if (!(*conf->assign_hook) (newval, changeVal, source))
|
if (!(*conf->assign_hook) (newval, changeVal, source))
|
||||||
{
|
{
|
||||||
@ -4380,11 +4384,6 @@ set_config_option(const char *name, const char *value,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changeVal || makeDefault)
|
|
||||||
{
|
|
||||||
/* Save old value to support transaction abort */
|
|
||||||
if (!makeDefault)
|
|
||||||
push_old_value(&conf->gen, action);
|
|
||||||
if (changeVal)
|
if (changeVal)
|
||||||
{
|
{
|
||||||
*conf->variable = newval;
|
*conf->variable = newval;
|
||||||
@ -4408,7 +4407,6 @@ set_config_option(const char *name, const char *value,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4447,6 +4445,10 @@ set_config_option(const char *name, const char *value,
|
|||||||
source = conf->gen.reset_source;
|
source = conf->gen.reset_source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Save old value to support transaction abort */
|
||||||
|
if (changeVal && !makeDefault)
|
||||||
|
push_old_value(&conf->gen, action);
|
||||||
|
|
||||||
if (conf->assign_hook)
|
if (conf->assign_hook)
|
||||||
if (!(*conf->assign_hook) (newval, changeVal, source))
|
if (!(*conf->assign_hook) (newval, changeVal, source))
|
||||||
{
|
{
|
||||||
@ -4457,11 +4459,6 @@ set_config_option(const char *name, const char *value,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changeVal || makeDefault)
|
|
||||||
{
|
|
||||||
/* Save old value to support transaction abort */
|
|
||||||
if (!makeDefault)
|
|
||||||
push_old_value(&conf->gen, action);
|
|
||||||
if (changeVal)
|
if (changeVal)
|
||||||
{
|
{
|
||||||
*conf->variable = newval;
|
*conf->variable = newval;
|
||||||
@ -4485,7 +4482,6 @@ set_config_option(const char *name, const char *value,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4521,6 +4517,10 @@ set_config_option(const char *name, const char *value,
|
|||||||
source = conf->gen.reset_source;
|
source = conf->gen.reset_source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Save old value to support transaction abort */
|
||||||
|
if (changeVal && !makeDefault)
|
||||||
|
push_old_value(&conf->gen, action);
|
||||||
|
|
||||||
if (conf->assign_hook)
|
if (conf->assign_hook)
|
||||||
if (!(*conf->assign_hook) (newval, changeVal, source))
|
if (!(*conf->assign_hook) (newval, changeVal, source))
|
||||||
{
|
{
|
||||||
@ -4531,11 +4531,6 @@ set_config_option(const char *name, const char *value,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changeVal || makeDefault)
|
|
||||||
{
|
|
||||||
/* Save old value to support transaction abort */
|
|
||||||
if (!makeDefault)
|
|
||||||
push_old_value(&conf->gen, action);
|
|
||||||
if (changeVal)
|
if (changeVal)
|
||||||
{
|
{
|
||||||
*conf->variable = newval;
|
*conf->variable = newval;
|
||||||
@ -4559,7 +4554,6 @@ set_config_option(const char *name, const char *value,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4610,6 +4604,10 @@ set_config_option(const char *name, const char *value,
|
|||||||
source = conf->gen.reset_source;
|
source = conf->gen.reset_source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Save old value to support transaction abort */
|
||||||
|
if (changeVal && !makeDefault)
|
||||||
|
push_old_value(&conf->gen, action);
|
||||||
|
|
||||||
if (conf->assign_hook && newval)
|
if (conf->assign_hook && newval)
|
||||||
{
|
{
|
||||||
const char *hookresult;
|
const char *hookresult;
|
||||||
@ -4647,11 +4645,6 @@ set_config_option(const char *name, const char *value,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changeVal || makeDefault)
|
|
||||||
{
|
|
||||||
/* Save old value to support transaction abort */
|
|
||||||
if (!makeDefault)
|
|
||||||
push_old_value(&conf->gen, action);
|
|
||||||
if (changeVal)
|
if (changeVal)
|
||||||
{
|
{
|
||||||
set_string_field(conf, conf->variable, newval);
|
set_string_field(conf, conf->variable, newval);
|
||||||
@ -4675,13 +4668,10 @@ set_config_option(const char *name, const char *value,
|
|||||||
stack->source = source;
|
stack->source = source;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/* Perhaps we didn't install newval anywhere */
|
/* Perhaps we didn't install newval anywhere */
|
||||||
if (newval && !string_field_used(conf, newval))
|
if (newval && !string_field_used(conf, newval))
|
||||||
free(newval);
|
free(newval);
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (newval)
|
|
||||||
free(newval);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user