Bug in psql (\dd query)

From: Ivan Radovanovic <radovanovic(at)gmail(dot)com>
To: PostgreSQL mailing lists <pgsql-general(at)postgresql(dot)org>
Subject: Bug in psql (\dd query)
Date: 2013-08-21 09:32:10
Message-ID: 5214891A.3000804@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

I was checking for way to get object comments, and it seems that \dd has
bug when it comes to extracting descriptions for constraints. Relevant
part of query psql is executing is:

SELECT DISTINCT tt.nspname AS "Schema", tt.name AS "Name", tt.object AS
"Object", d.description AS "Description"
FROM (
SELECT pgc.oid as oid, pgc.tableoid AS tableoid,
n.nspname as nspname,
CAST(pgc.conname AS pg_catalog.text) as name, CAST('constraint' AS
pg_catalog.text) as object
FROM pg_catalog.pg_constraint pgc
JOIN pg_catalog.pg_class c ON c.oid = pgc.conrelid
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE n.nspname <> 'pg_catalog'
AND n.nspname <> 'information_schema'
AND pg_catalog.pg_table_is_visible(c.oid)
/* more unions here */
) AS tt
JOIN pg_catalog.pg_description d ON (tt.oid = d.objoid AND
tt.tableoid = d.classoid AND d.objsubid = 0)
ORDER BY 1, 2, 3;

obviously it is trying to get description for (table_oid,
constraint_oid, 0), while in fact it should read description for (oid of
pg_catalog.pg_constaint, constraint_oid, 0).

At least last tuple is what comment statement is inserting into
pg_description table

Regards,
Ivan

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Don Parris 2013-08-21 09:55:02 Locale Issue
Previous Message S H 2013-08-21 09:14:28 Re: Commit hung bug