Re: Alias collision in `refresh materialized view concurrently`

From: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, Bernd Helmle <mailings(at)oopsware(dot)de>, Mathis Rudolf <mathis(dot)rudolf(at)credativ(dot)de>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Alias collision in `refresh materialized view concurrently`
Date: 2021-06-02 05:23:22
Message-ID: CALj2ACV5Ox8Py-n5EtY9j7_TGGU1p+xBDL2TrtDTpPEafLTr7w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Jun 2, 2021 at 6:33 AM Michael Paquier <michael(at)paquier(dot)xyz> wrote:
>
> On Wed, Jun 02, 2021 at 12:30:55PM +1200, Thomas Munro wrote:
> > I wondered if we could find a way to make identifiers that regular
> > queries are prohibited from using, at least by documentation. You
> > could take advantage of the various constraints on unquoted
> > identifiers in the standard (for example, something involving $), but
> > it does seem a shame to remove the ability for users to put absolutely
> > anything except NUL in quoted identifiers. I do wonder if at least
> > using something like _$mv would be slightly more principled than
> > pg_mv_1234, since nothing says pg_XXX is reserved (except in some very
> > specific places like schema names), and the number on the end seems a
> > bit cargo-cultish.
>
> Yeah, using an underscore at the beginning of the name would have the
> advantage to mark the relation as an internal thing.
>
> + "(SELECT %s.tid FROM %s %s "
> + "WHERE %s.tid IS NOT NULL "
> + "AND %s.%s IS NULL)",
> Anyway, I have another problem with the patch: readability. It
> becomes really hard for one to guess to which object or alias portions
> of the internal queries refer to, especially with a total of five
> temporary names lying around. I think that you should drop the
> business with make_temptable_name_n(), and just append those extra
> underscores and uses of MyProcPid directly in the query string. The
> surroundings of quote_qualified_identifier() require two extra printf
> calls, but that does not sound bad to me compared to the long-term
> maintenance of those queries.

Thanks. PSA v4.

With Regards,
Bharath Rupireddy.

Attachment Content-Type Size
v4-0001-Avoid-alias-name-collisions-in-REFRESH-MATERIALIZ.patch application/octet-stream 8.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bharath Rupireddy 2021-06-02 05:33:46 Re: Refactor "mutually exclusive options" error reporting code in parse_subscription_options
Previous Message Michael Paquier 2021-06-02 05:20:10 Re: Two patches to speed up pg_rewind.