Re: Alias collision in `refresh materialized view concurrently`

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, 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-08-07 01:40:47
Message-ID: YQ3knwhS3yWoiruo@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Aug 06, 2021 at 10:48:40AM -0400, Tom Lane wrote:
> AFAICT that works and generates the identical parse tree to the original
> coding. The only place touched by the patch where it's a bit difficult to
> make the syntax unambiguous this way is
>
> "CREATE TEMP TABLE %s AS "
> "SELECT _$mv.ctid AS tid, _$newdata "
> "FROM %s _$mv FULL JOIN %s _$newdata ON (",
>
> because newdata.* would ordinarily get expanded to multiple columns
> if it's at the top level of a SELECT list, and that's not what we want.
> However, that's easily fixed using the same hack as in ruleutils.c's
> get_variable: add a no-op cast to the table's rowtype. So this
> would look like
>
> appendStringInfo(&querybuf,
> "CREATE TEMP TABLE %s AS "
> "SELECT mv.ctid AS tid, newdata.*::%s "
> "FROM %s mv FULL JOIN %s newdata ON (",
> diffname, matviewname, matviewname, tempname);

Smart piece. I haven't thought of that.

> Given that it took this long to notice the problem at all, maybe
> this is not a fix to cram in on the weekend before the release wrap.
> But I don't see why we need to settle for "mostly works" when
> "always works" is barely any harder.

Yes, I would vote to delay that for a couple of days. That's not
worth taking a risk for.
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2021-08-07 02:30:26 pgsql: pgstat: Bring up pgstat in BaseInit() to fix uninitialized use o
Previous Message Peter Geoghegan 2021-08-07 01:30:44 Re: ECPG bug fix: DECALRE STATEMENT and DEALLOCATE, DESCRIBE