pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>
Cc: pavel.stehule@gmail.com
Cc: a.zakirov@postgrespro.ru
Cc: pgsql-hackers@postgresql.org
Subject: Re: pg_get_functiondef forgets about most GUC_LIST_INPUT GUCs
Date: Wed, 21 Mar 2018 14:01:03 +0900
Message-ID: <20180321050103.GD2288@paquier.xyz> (raw)
In-Reply-To: <32403.1521566855@sss.pgh.pa.us>
References: <2637.1521501336@sss.pgh.pa.us>
	<20180320003951.GA4963@paquier.xyz>
	<10037.1521515233@sss.pgh.pa.us>
	<20180320.123747.43512160.horiguchi.kyotaro@lab.ntt.co.jp>
	<32403.1521566855@sss.pgh.pa.us>

On Tue, Mar 20, 2018 at 01:27:35PM -0400, Tom Lane wrote:
> 1. Only GUC_LIST_QUOTE variables need to be special-cased.  It works
> fine to treat plain LIST variables (e.g. datestyle) with the regular
> code path.  This is good because there are so few of them.

Check.

> 2. We should make an effort to minimize the number of places that know
> explicitly which variables are GUC_LIST_QUOTE.  In the backend, the
> right thing to do is ask guc.c.  In pg_dump, there's no convenient
> way to ask the backend (and certainly nothing that would work against
> old servers), but we should at least make sure there's only one place
> to fix not two.

The only way I can think about for that would be to provide this
information in pg_settings using a text[] array or such which lists all
the GUC flags of a parameter.  That's a hell lot of infrastructure
though which can be easily replaced with the maintenance of a small
hardcoded parameter list.

> 3. We need to prevent extensions from trying to create GUC_LIST_QUOTE
> variables, because those are not going to work correctly if they're
> set before the extension is loaded, nor is there any hope of pg_dump
> dumping them correctly.

This really depends on the elements of the list involved here, so
pg_dump may be able to dump them correctly, though not reliably as that
would be fully application-dependent.  At the end I think that I am on
board with what you are proposing here.

> The attached 0001 patch does the first two things, and could be
> back-patched.  The 0002 patch, which I'd only propose for HEAD,
> is one way we could address point 3.  A different way would be
> to throw a WARNING rather than ERROR and then just mask off the
> problematic bit.  Or we could decide that either of these cures
> is worse than the disease, but I don't really agree with that.

Looks roughly sane to me.

+       if (flags & GUC_LIST_QUOTE)
+               elog(FATAL, "extensions cannot define GUC_LIST_QUOTE
variables");
This would be better as an ereport with ERRCODE_FEATURE_NOT_SUPPORTED I
think.  An ERROR is better in my opinion.

-    if (pg_strcasecmp(configitem, "DateStyle") == 0
-        || pg_strcasecmp(configitem, "search_path") == 0)
+    if (GetConfigOptionFlags(configitem, true) & GUC_LIST_QUOTE)
For boolean-based comparisons, I would recommend using a comparison with
zero.

+   record = find_option(name, false, WARNING);
+   if (record == NULL)
LOG instead of WARNING?
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

view thread (35+ messages)  latest in thread

Message-ID: <20180321050103.GD2288@paquier.xyz>
Permalink:  ../20180321050103.GD2288@paquier.xyz/
Also on:    postgresql.org/message-id/20180321050103.GD2288@paquier.xyz

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: michael@paquier.xyz, tgl@sss.pgh.pa.us, horiguchi.kyotaro@lab.ntt.co.jp, pavel.stehule@gmail.com, a.zakirov@postgrespro.ru
  Subject: Re: pg_get_functiondef forgets about most GUC_LIST_INPUT GUCs
  In-Reply-To: <20180321050103.GD2288@paquier.xyz>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox