Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Table comments are not displayed in postgresql #859
Steps to reproduce this issue
Column comments are not shown.
Column comments are shown in both places.
Yes, I used to retrieve PG table columns with their comments from
SELECT DISTINCT a.attname AS column_name, a.attnum, a.atttypid, FORMAT_TYPE(a.atttypid, a.atttypmod) AS data_type, CASE a.attnotnull WHEN false THEN 'YES' ELSE 'NO' END AS IS_NULLABLE, com.description AS column_comment, pg_get_expr(def.adbin, def.adrelid) AS column_default, NULL AS character_maximum_length FROM pg_attribute AS a JOIN pg_class AS pgc ON pgc.oid = a.attrelid LEFT JOIN pg_description AS com ON (pgc.oid = com.objoid AND a.attnum = com.objsubid) LEFT JOIN pg_attrdef AS def ON (a.attrelid = def.adrelid AND a.attnum = def.adnum) WHERE a.attnum > 0 AND pgc.oid = a.attrelid AND pg_table_is_visible(pgc.oid) AND NOT a.attisdropped AND pgc.relname = 'mytable' ORDER BY a.attnum
I will have to override
I just simplified the above query and used that to retrieve column comments. I just wonder if I need some "schema='currentschema'" WHERE filter?
SELECT a.attname AS colname, des.description FROM pg_attribute AS a, pg_description AS des, pg_class AS pgc WHERE pgc.oid = a.attrelid AND des.objoid = pgc.oid AND pg_table_is_visible(pgc.oid) AND pgc.relname = 'mytable' AND a.attnum = des.objsubid
Hi Angsar, thanks a lot for the quick response. :)
I created a one-column table in the
Unfortunately, none of your queries returns the comment of the column of the second table. Both queries work in the current schema only. I am not sure whether this is an issue or not, maybe HeidiSQL sets the schema accordingly, in which case this is exactly the desired behavior.
Here is what I did:
then executed both your shorter and longer queries. Both returned
If HeidiSQL sets the search path accordingly for each schema then this will be fine.