comments on columns

Show the comments in the list of columns of a table.
Generate SQL to set them.
This commit is contained in:
eelke 2021-03-08 17:23:34 +01:00
parent 9d58af8cd2
commit d6aeef492d
5 changed files with 23 additions and 3 deletions

View file

@ -12,14 +12,16 @@ std::string PgAttributeContainer::getLoadQuery() const
std::string q = R"__(
SELECT attrelid, attname, atttypid, attstattarget,
attnum, attndims, atttypmod, attnotnull, atthasdef, attisdropped,
attislocal, attcollation, attacl, attoptions, pg_get_expr(def.adbin, def.adrelid) AS def_value, cs.relname AS sername, ns.nspname AS serschema)__";
attislocal, attcollation, attacl, attoptions, pg_get_expr(def.adbin, def.adrelid) AS def_value,
cs.relname AS sername, ns.nspname AS serschema, d.description)__";
if (m_catalog.serverVersion() >= 100000)
q += ", attidentity";
q += R"__(
FROM pg_catalog.pg_attribute AS att
LEFT JOIN pg_attrdef AS def ON attrelid=adrelid AND attnum=adnum
LEFT JOIN (pg_depend JOIN pg_class cs ON classid='pg_class'::regclass AND objid=cs.oid AND cs.relkind='S') ON refobjid=att.attrelid AND refobjsubid=att.attnum
LEFT JOIN pg_namespace ns ON ns.oid=cs.relnamespace)__";
LEFT JOIN pg_namespace ns ON ns.oid=cs.relnamespace
LEFT JOIN pg_catalog.pg_description AS d ON (objoid=attrelid AND d.objsubid=attnum))__";
return q;
}
@ -31,7 +33,7 @@ PgAttribute PgAttributeContainer::loadElem(const Pgsql::Row &row)
col >> v.relid >> v.name >> v.typid >> v.stattarget
>> v.num >> v.ndims >> v.typmod >> v.notnull >> v.hasdef >> v.isdropped
>> v.islocal >> v.collation >> v.acl >> v.options >> v.defaultValue
>> v.sername >> v.serschema;
>> v.sername >> v.serschema >> v.description;
if (m_catalog.serverVersion() >= 100000)
col >> v.identity;