diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2022-09-06 18:00:32 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2022-09-06 18:00:32 -0400 |
commit | 20b6847176976da9cae6103475b967e6c2971898 (patch) | |
tree | c0a92c69263428af839fbc63c4f13e4371601795 /src/backend | |
parent | cec2754fbebee0a40aaf905947deb823cca4fe39 (diff) | |
download | postgresql-20b6847176976da9cae6103475b967e6c2971898.tar.gz postgresql-20b6847176976da9cae6103475b967e6c2971898.zip |
Fix new pg_publication_tables query.
The addition of published column names forgot to filter on attisdropped,
leading to cases where you could see "........pg.dropped.1........"
or the like as a reportedly-published column.
While we're here, rewrite the new subquery to get a more efficient plan
for it.
Hou Zhijie, per report from Jaime Casanova. Back-patch to v15 where
the bug was introduced. (Sadly, this means we need a post-beta4
catversion bump before beta4 has even hit the streets. I see no
good alternative though.)
Discussion: https://postgr.es/m/Yxa1SU4nH2HfN3/i@ahch-to
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/catalog/system_views.sql | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/backend/catalog/system_views.sql b/src/backend/catalog/system_views.sql index 5a844b63a1c..55f7ec79e05 100644 --- a/src/backend/catalog/system_views.sql +++ b/src/backend/catalog/system_views.sql @@ -370,11 +370,10 @@ CREATE VIEW pg_publication_tables AS N.nspname AS schemaname, C.relname AS tablename, ( SELECT array_agg(a.attname ORDER BY a.attnum) - FROM unnest(CASE WHEN GPT.attrs IS NOT NULL THEN GPT.attrs - ELSE (SELECT array_agg(g) FROM generate_series(1, C.relnatts) g) - END) k - JOIN pg_attribute a - ON (a.attrelid = GPT.relid AND a.attnum = k) + FROM pg_attribute a + WHERE a.attrelid = GPT.relid AND a.attnum > 0 AND + NOT a.attisdropped AND + (a.attnum = ANY(GPT.attrs) OR GPT.attrs IS NULL) ) AS attnames, pg_get_expr(GPT.qual, GPT.relid) AS rowfilter FROM pg_publication P, |