Re: Alias collision in `refresh materialized view concurrently` - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: Alias collision in `refresh materialized view concurrently`
Date
Msg-id YQ3knwhS3yWoiruo@paquier.xyz
Whole thread Raw
In response to Re: Alias collision in `refresh materialized view concurrently`  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Alias collision in `refresh materialized view concurrently`  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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

Attachment

pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: ECPG bug fix: DECALRE STATEMENT and DEALLOCATE, DESCRIBE
Next
From: Tom Lane
Date:
Subject: Re: Alias collision in `refresh materialized view concurrently`