pgsql: Improve and simplify CREATE EXTENSION's management of GUC variab

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Improve and simplify CREATE EXTENSION's management of GUC variab
Date: 2011-10-06 00:44:35
Message-ID: E1RBc4h-0001Sb-Sa@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Improve and simplify CREATE EXTENSION's management of GUC variables.

CREATE EXTENSION needs to transiently set search_path, as well as
client_min_messages and log_min_messages. We were doing this by the
expedient of saving the current string value of each variable, doing a
SET LOCAL, and then doing another SET LOCAL with the previous value at
the end of the command. This is a bit expensive though, and it also fails
badly if there is anything funny about the existing search_path value,
as seen in a recent report from Roger Niederland. Fortunately, there's a
much better way, which is to piggyback on the GUC infrastructure previously
developed for functions with SET options. We just open a new GUC nesting
level, do our assignments with GUC_ACTION_SAVE, and then close the nesting
level when done. This automatically restores the prior settings without a
re-parsing pass, so (in principle anyway) there can't be an error. And
guc.c still takes care of cleanup in event of an error abort.

The CREATE EXTENSION code for this was modeled on some much older code in
ri_triggers.c, which I also changed to use the better method, even though
there wasn't really much risk of failure there. Also improve the comments
in guc.c to reflect this additional usage.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/ba6f629326be365a3124dc80aa5d303e2b0bf46b

Modified Files
--------------
src/backend/commands/extension.c | 40 +++++++++++-----------------------
src/backend/utils/adt/ri_triggers.c | 20 +++++++---------
src/backend/utils/misc/guc.c | 20 +++++++++-------
src/include/utils/guc.h | 2 +-
4 files changed, 34 insertions(+), 48 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2011-10-06 00:44:36 pgsql: Improve and simplify CREATE EXTENSION's management of GUC variab
Previous Message Alex Hunsaker 2011-10-05 21:03:41 Re: Re: [COMMITTERS] pgsql: Force strings passed to and from plperl to be in UTF8 encoding.