public inbox for [email protected]  
help / color / mirror / Atom feed
Fix projection of pg_type for Greenplum query
2+ messages / 2 participants
[nested] [flat]

* Fix projection of pg_type for Greenplum query
@ 2019-07-23 08:13  Daniel Gustafsson <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: Daniel Gustafsson @ 2019-07-23 08:13 UTC (permalink / raw)
  To: [email protected]

The bug in https://redmine.postgresql.org/issues/4179 seems to be due to
pg_type being projected from but not selected, the attached patch adds a FROM
clause entry and also adds projection of typname.  This makes the query work on
5X_STABLE for me.

cheers ./daniel



Attachments:

  [application/octet-stream] from_pg_type.patch (2.2K, 2-from_pg_type.patch)
  download | inline diff:
From a18d1948d845f1a7b6a3603543d0b951f93b5839 Mon Sep 17 00:00:00 2001
From: Daniel Gustafsson <[email protected]>
Date: Tue, 23 Jul 2019 10:08:59 +0200
Subject: [PATCH] Fix properties query for Greenplum

The query projected a column from pg_catalog.pg_class but didn't
include it in the FROM clause. Fix by adding a LEFT OUTER JOIN on
the catalog relation and also promote typname to a projection as
it might be available.

Fixes https://redmine.postgresql.org/issues/4179
---
 .../schemas/tables/templates/tables/sql/gpdb_5.0_plus/properties.sql   | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/gpdb_5.0_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/gpdb_5.0_plus/properties.sql
index c690a1b8..ca7231ac 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/gpdb_5.0_plus/properties.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/gpdb_5.0_plus/properties.sql
@@ -59,7 +59,7 @@ FROM (
 		substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_freeze_table_age=([0-9]*)') AS toast_autovacuum_freeze_table_age,
 		array_to_string(rel.reloptions, ',') AS table_vacuum_settings_str,
 		array_to_string(tst.reloptions, ',') AS toast_table_vacuum_settings_str,
-		rel.reloptions AS reloptions, tst.reloptions AS toast_reloptions, NULL AS reloftype, NULL AS typname,
+		rel.reloptions AS reloptions, tst.reloptions AS toast_reloptions, NULL AS reloftype, typ.typname AS typname,
 		typ.typrelid AS typoid,
 		(CASE WHEN rel.reltoastrelid = 0 THEN false ELSE true END) AS hastoasttable,
 			-- Added for pgAdmin4
@@ -79,6 +79,7 @@ FROM (
 		LEFT OUTER JOIN pg_constraint con ON con.conrelid=rel.oid AND con.contype='p'
 		LEFT OUTER JOIN pg_class tst ON tst.oid = rel.reltoastrelid
 		LEFT OUTER JOIN gp_distribution_policy gdp ON gdp.localoid = rel.oid
+		LEFT OUTER JOIN pg_type typ ON typ.oid = rel.reltype
 
 	 WHERE rel.relkind IN ('r','s','t') AND rel.relnamespace = {{ scid }}
 	{% if tid %}  AND rel.oid = {{ tid }}::oid {% endif %}
-- 
2.14.1.145.gb3622a4ee



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Fix projection of pg_type for Greenplum query
@ 2019-07-25 15:17  Dave Page <[email protected]>
  parent: Daniel Gustafsson <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Dave Page @ 2019-07-25 15:17 UTC (permalink / raw)
  To: Daniel Gustafsson <[email protected]>; +Cc: pgadmin-hackers <[email protected]>

Thanks, patch applied.

On Tue, Jul 23, 2019 at 9:13 AM Daniel Gustafsson <[email protected]> wrote:

> The bug in https://redmine.postgresql.org/issues/4179 seems to be due to
> pg_type being projected from but not selected, the attached patch adds a
> FROM
> clause entry and also adds projection of typname.  This makes the query
> work on
> 5X_STABLE for me.
>
> cheers ./daniel
>
>

-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2019-07-25 15:17 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-07-23 08:13 Fix projection of pg_type for Greenplum query Daniel Gustafsson <[email protected]>
2019-07-25 15:17 ` Dave Page <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox