Re: Bogus EXPLAIN results with column aliases for mismatched partitions
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-hackers@lists.postgresql.org
Date: 2019-12-01T21:34:38Z
Lists: pgsql-hackers
Attachments
- fix-alias-usage-in-postgres_fdw-explain-2.patch (text/x-diff) patch
I wrote: > Now, there is another thing that set_rtable_names() is doing that > postgres_fdw doesn't do, which is to unique-ify the chosen alias > names by adding "_NN" if the querytree contains multiple uses of > the same table alias. I don't see any practical way for postgres_fdw > to match that behavior, since it lacks global information about the > query. If we wanted to fix it, what we'd likely need to do is > postpone creation of the relation_name strings until EXPLAIN, > providing some way for postgres_fdw to ask ruleutils.c what alias > it'd assigned to a particular RTE. Hmmm ... so actually, that isn't *quite* as bad as I thought: ExplainState does already expose that information, so we just need to rearrange how postgres_fdw does things. Here's a revised proposed patch, which exposes (and fixes) several additional test cases where the Relations: string was previously visibly out of sync with what ruleutils was using for Var names. BTW, the existing code always schema-qualifies the relation names, on the rather lame grounds that it's producing the string without knowing whether EXPLAIN VERBOSE will be specified. In this code, the verbose flag is available so it would be trivial to make the output conform to EXPLAIN's normal policy. I didn't change that here because there'd be a bunch more test output diffs of no intellectual interest. Should we change it, or leave well enough alone? regards, tom lane
Commits
-
Further sync postgres_fdw's "Relations" output with the rest of EXPLAIN.
- bf39b3af6a9c 13.0 landed
-
Fix EXPLAIN's column alias output for mismatched child tables.
- 55a1954da16e 13.0 landed
-
Add a reverse-translation column number array to struct AppendRelInfo.
- ce76c0ba53e4 13.0 landed
-
Make postgres_fdw's "Relations" output agree with the rest of EXPLAIN.
- 4526951d564a 13.0 landed
-
Allow access to child table statistics if user can read parent table.
- 553d2ec2710b 13.0 cited