Fix GUC's reports of assign_hook failure to always include the parameter value
authorTom Lane
Thu, 2 Apr 2009 03:51:43 +0000 (03:51 +0000)
committerTom Lane
Thu, 2 Apr 2009 03:51:43 +0000 (03:51 +0000)
we failed to assign, even in "can't happen" cases.  Motivated by wondering
what's going on in a recent trouble report where "failed to commit" did
happen.

src/backend/utils/misc/guc.c

index 8bf2305736c49a8a55f0a4076f343534fd34a2eb..ecb9505aea7e5c1afa0dfc5a2de347901eaa1a75 100644 (file)
@@ -10,7 +10,7 @@
  * Written by Peter Eisentraut .
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.497 2009/03/09 14:34:34 petere Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.498 2009/04/02 03:51:43 tgl Exp $
  *
  *--------------------------------------------------------------------
  */
@@ -3578,7 +3578,8 @@ ResetAllOptions(void)
                    if (conf->assign_hook)
                        if (!(*conf->assign_hook) (conf->reset_val, true,
                                                   PGC_S_SESSION))
-                           elog(ERROR, "failed to reset %s", conf->gen.name);
+                           elog(ERROR, "failed to reset %s to %d",
+                                conf->gen.name, (int) conf->reset_val);
                    *conf->variable = conf->reset_val;
                    break;
                }
@@ -3589,7 +3590,8 @@ ResetAllOptions(void)
                    if (conf->assign_hook)
                        if (!(*conf->assign_hook) (conf->reset_val, true,
                                                   PGC_S_SESSION))
-                           elog(ERROR, "failed to reset %s", conf->gen.name);
+                           elog(ERROR, "failed to reset %s to %d",
+                                conf->gen.name, conf->reset_val);
                    *conf->variable = conf->reset_val;
                    break;
                }
@@ -3600,7 +3602,8 @@ ResetAllOptions(void)
                    if (conf->assign_hook)
                        if (!(*conf->assign_hook) (conf->reset_val, true,
                                                   PGC_S_SESSION))
-                           elog(ERROR, "failed to reset %s", conf->gen.name);
+                           elog(ERROR, "failed to reset %s to %g",
+                                conf->gen.name, conf->reset_val);
                    *conf->variable = conf->reset_val;
                    break;
                }
@@ -3619,7 +3622,8 @@ ResetAllOptions(void)
                        newstr = (*conf->assign_hook) (str, true,
                                                       PGC_S_SESSION);
                        if (newstr == NULL)
-                           elog(ERROR, "failed to reset %s", conf->gen.name);
+                           elog(ERROR, "failed to reset %s to \"%s\"",
+                                conf->gen.name, str);
                        else if (newstr != str)
                        {
                            /*
@@ -3639,7 +3643,9 @@ ResetAllOptions(void)
                    if (conf->assign_hook)
                        if (!(*conf->assign_hook) (conf->reset_val, true,
                                                   PGC_S_SESSION))
-                           elog(ERROR, "failed to reset %s", conf->gen.name);
+                           elog(ERROR, "failed to reset %s to %s",
+                                conf->gen.name,
+                                config_enum_lookup_by_value(conf, conf->reset_val));
                    *conf->variable = conf->reset_val;
                    break;
                }
@@ -3910,8 +3916,8 @@ AtEOXact_GUC(bool isCommit, int nestLevel)
                                if (conf->assign_hook)
                                    if (!(*conf->assign_hook) (newval,
                                                       true, PGC_S_OVERRIDE))
-                                       elog(LOG, "failed to commit %s",
-                                            conf->gen.name);
+                                       elog(LOG, "failed to commit %s as %d",
+                                            conf->gen.name, (int) newval);
                                *conf->variable = newval;
                                changed = true;
                            }
@@ -3927,8 +3933,8 @@ AtEOXact_GUC(bool isCommit, int nestLevel)
                                if (conf->assign_hook)
                                    if (!(*conf->assign_hook) (newval,
                                                       true, PGC_S_OVERRIDE))
-                                       elog(LOG, "failed to commit %s",
-                                            conf->gen.name);
+                                       elog(LOG, "failed to commit %s as %d",
+                                            conf->gen.name, newval);
                                *conf->variable = newval;
                                changed = true;
                            }
@@ -3944,8 +3950,8 @@ AtEOXact_GUC(bool isCommit, int nestLevel)
                                if (conf->assign_hook)
                                    if (!(*conf->assign_hook) (newval,
                                                       true, PGC_S_OVERRIDE))
-                                       elog(LOG, "failed to commit %s",
-                                            conf->gen.name);
+                                       elog(LOG, "failed to commit %s as %g",
+                                            conf->gen.name, newval);
                                *conf->variable = newval;
                                changed = true;
                            }
@@ -3965,8 +3971,8 @@ AtEOXact_GUC(bool isCommit, int nestLevel)
                                    newstr = (*conf->assign_hook) (newval, true,
                                                             PGC_S_OVERRIDE);
                                    if (newstr == NULL)
-                                       elog(LOG, "failed to commit %s",
-                                            conf->gen.name);
+                                       elog(LOG, "failed to commit %s as \"%s\"",
+                                            conf->gen.name, newval);
                                    else if (newstr != newval)
                                    {
                                        /*
@@ -4004,8 +4010,9 @@ AtEOXact_GUC(bool isCommit, int nestLevel)
                                if (conf->assign_hook)
                                    if (!(*conf->assign_hook) (newval,
                                                               true, PGC_S_OVERRIDE))
-                                       elog(LOG, "failed to commit %s",
-                                            conf->gen.name);
+                                       elog(LOG, "failed to commit %s as %s",
+                                            conf->gen.name,
+                                            config_enum_lookup_by_value(conf, newval));
                                *conf->variable = newval;
                                changed = true;
                            }