On Sun, Jul 17, 2011 at 10:54 AM, Josh Kupershmidt <schmi...@gmail.com> wrote: > On Sat, Jul 16, 2011 at 12:49 PM, Tom Lane <t...@sss.pgh.pa.us> wrote: >> After a bit of review of the archives, the somebody was me: >> http://git.postgresql.org/gitweb/?p=postgresql.git&a=commitdiff&h=b7d67954456f15762c04e5269b64adc88dcd0860 >> >> and this thread was the discussion about it: >> http://archives.postgresql.org/pgsql-hackers/2009-12/msg01982.php >> >> It looks like we thought about pg_dump, but did not think about psql. > > Ah, interesting. I didn't even know this functionality existed. And I > think there is some documentation lacking; in the 8.4 doc page:
Here's a small patch against branch 8.4 to mention support for COMMENT ON index_name.column_name. Also, a patch against master to: * get rid of the bogus "Description" outputs for \d+ sequence_name and \d+ index_name * clarify in the COMMENT ON doc page that a table _or view_ name may be used for comments on columns, rules, and triggers. If we allowed constraints on views, we could have just put in a note explaining that "table_name.column_name" applies to tables and views, but constraints are the odd man out. * slightly reordered the listing of the first bunch of Parameters on that page so that agg_name comes first, as it does in the Synopsis section I noticed that the synopsis for CREATE RULE: http://www.postgresql.org/docs/9.1/static/sql-createrule.html uses the term "table", which could be a similar omission. However, on that page the first sentence of the description specifies "table or view" so it might be fine as-is. And while I'm messing with this, some further nitpicks about psql not addressed by these patches: * The "Storage" column for \d+ sequence_name is correct, I suppose, but repetitive * The "Type" column for \dv+ view_name, \di+ index_name, \ds+ sequence_name , etc. seems borderline useless.. shouldn't you know what type you're looking at based on the backslash command you're using? Plus the table heading could be more specific than "List of relations", e.g. "List of views". Josh
diff --git a/doc/src/sgml/ref/comment.sgml b/doc/src/sgml/ref/comment.sgml index ab12614..58a2f02 100644 *** a/doc/src/sgml/ref/comment.sgml --- b/doc/src/sgml/ref/comment.sgml *************** COMMENT ON *** 26,32 **** AGGREGATE <replaceable class="PARAMETER">agg_name</replaceable> (<replaceable class="PARAMETER">agg_type</replaceable> [, ...] ) | CAST (<replaceable>source_type</replaceable> AS <replaceable>target_type</replaceable>) | COLLATION <replaceable class="PARAMETER">object_name</replaceable> | ! COLUMN <replaceable class="PARAMETER">table_name</replaceable>.<replaceable class="PARAMETER">column_name</replaceable> | CONSTRAINT <replaceable class="PARAMETER">constraint_name</replaceable> ON <replaceable class="PARAMETER">table_name</replaceable> | CONVERSION <replaceable class="PARAMETER">object_name</replaceable> | DATABASE <replaceable class="PARAMETER">object_name</replaceable> | --- 26,32 ---- AGGREGATE <replaceable class="PARAMETER">agg_name</replaceable> (<replaceable class="PARAMETER">agg_type</replaceable> [, ...] ) | CAST (<replaceable>source_type</replaceable> AS <replaceable>target_type</replaceable>) | COLLATION <replaceable class="PARAMETER">object_name</replaceable> | ! COLUMN <replaceable class="PARAMETER">table_or_view_name</replaceable>.<replaceable class="PARAMETER">column_name</replaceable> | CONSTRAINT <replaceable class="PARAMETER">constraint_name</replaceable> ON <replaceable class="PARAMETER">table_name</replaceable> | CONVERSION <replaceable class="PARAMETER">object_name</replaceable> | DATABASE <replaceable class="PARAMETER">object_name</replaceable> | *************** COMMENT ON *** 42,48 **** OPERATOR FAMILY <replaceable class="PARAMETER">object_name</replaceable> USING <replaceable class="parameter">index_method</replaceable> | [ PROCEDURAL ] LANGUAGE <replaceable class="PARAMETER">object_name</replaceable> | ROLE <replaceable class="PARAMETER">object_name</replaceable> | ! RULE <replaceable class="PARAMETER">rule_name</replaceable> ON <replaceable class="PARAMETER">table_name</replaceable> | SCHEMA <replaceable class="PARAMETER">object_name</replaceable> | SEQUENCE <replaceable class="PARAMETER">object_name</replaceable> | SERVER <replaceable class="PARAMETER">object_name</replaceable> | --- 42,48 ---- OPERATOR FAMILY <replaceable class="PARAMETER">object_name</replaceable> USING <replaceable class="parameter">index_method</replaceable> | [ PROCEDURAL ] LANGUAGE <replaceable class="PARAMETER">object_name</replaceable> | ROLE <replaceable class="PARAMETER">object_name</replaceable> | ! RULE <replaceable class="PARAMETER">rule_name</replaceable> ON <replaceable class="PARAMETER">table_or_view_name</replaceable> | SCHEMA <replaceable class="PARAMETER">object_name</replaceable> | SEQUENCE <replaceable class="PARAMETER">object_name</replaceable> | SERVER <replaceable class="PARAMETER">object_name</replaceable> | *************** COMMENT ON *** 52,58 **** TEXT SEARCH DICTIONARY <replaceable class="PARAMETER">object_name</replaceable> | TEXT SEARCH PARSER <replaceable class="PARAMETER">object_name</replaceable> | TEXT SEARCH TEMPLATE <replaceable class="PARAMETER">object_name</replaceable> | ! TRIGGER <replaceable class="PARAMETER">trigger_name</replaceable> ON <replaceable class="PARAMETER">table_name</replaceable> | TYPE <replaceable class="PARAMETER">object_name</replaceable> | VIEW <replaceable class="PARAMETER">object_name</replaceable> } IS '<replaceable class="PARAMETER">text</replaceable>' --- 52,58 ---- TEXT SEARCH DICTIONARY <replaceable class="PARAMETER">object_name</replaceable> | TEXT SEARCH PARSER <replaceable class="PARAMETER">object_name</replaceable> | TEXT SEARCH TEMPLATE <replaceable class="PARAMETER">object_name</replaceable> | ! TRIGGER <replaceable class="PARAMETER">trigger_name</replaceable> ON <replaceable class="PARAMETER">table_or_view_name</replaceable> | TYPE <replaceable class="PARAMETER">object_name</replaceable> | VIEW <replaceable class="PARAMETER">object_name</replaceable> } IS '<replaceable class="PARAMETER">text</replaceable>' *************** COMMENT ON *** 97,105 **** <variablelist> <varlistentry> <term><replaceable class="parameter">object_name</replaceable></term> <term><replaceable class="parameter">table_name.column_name</replaceable></term> - <term><replaceable class="parameter">agg_name</replaceable></term> <term><replaceable class="parameter">constraint_name</replaceable></term> <term><replaceable class="parameter">function_name</replaceable></term> <term><replaceable class="parameter">operator_name</replaceable></term> --- 97,106 ---- <variablelist> <varlistentry> + <term><replaceable class="parameter">agg_name</replaceable></term> <term><replaceable class="parameter">object_name</replaceable></term> + <term><replaceable class="parameter">table_or_view_name.column_name</replaceable></term> <term><replaceable class="parameter">table_name.column_name</replaceable></term> <term><replaceable class="parameter">constraint_name</replaceable></term> <term><replaceable class="parameter">function_name</replaceable></term> <term><replaceable class="parameter">operator_name</replaceable></term> diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 682cf8a..46aae54 100644 *** a/src/bin/psql/describe.c --- b/src/bin/psql/describe.c *************** describeOneTableDetails(const char *sche *** 1295,1302 **** appendPQExpBuffer(&buf, "\n NULL AS attcollation"); if (tableinfo.relkind == 'i') appendPQExpBuffer(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); ! if (verbose) ! appendPQExpBuffer(&buf, ",\n a.attstorage, pg_catalog.col_description(a.attrelid, a.attnum)"); appendPQExpBuffer(&buf, "\nFROM pg_catalog.pg_attribute a"); appendPQExpBuffer(&buf, "\nWHERE a.attrelid = '%s' AND a.attnum > 0 AND NOT a.attisdropped", oid); appendPQExpBuffer(&buf, "\nORDER BY a.attnum;"); --- 1295,1309 ---- appendPQExpBuffer(&buf, "\n NULL AS attcollation"); if (tableinfo.relkind == 'i') appendPQExpBuffer(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); ! if (verbose) { ! appendPQExpBuffer(&buf, ",\n a.attstorage"); ! /* No descriptions on an index's columns in 9.0+, and column ! * descriptions for sequences don't make sense. ! */ ! if (tableinfo.relkind != 'i' && tableinfo.relkind != 'S') ! appendPQExpBuffer(&buf, ", pg_catalog.col_description(a.attrelid, a.attnum)"); ! } ! appendPQExpBuffer(&buf, "\nFROM pg_catalog.pg_attribute a"); appendPQExpBuffer(&buf, "\nWHERE a.attrelid = '%s' AND a.attnum > 0 AND NOT a.attisdropped", oid); appendPQExpBuffer(&buf, "\nORDER BY a.attnum;"); *************** describeOneTableDetails(const char *sche *** 1379,1385 **** if (verbose) { headers[cols++] = gettext_noop("Storage"); ! headers[cols++] = gettext_noop("Description"); } printTableInit(&cont, &myopt, title.data, cols, numrows); --- 1386,1393 ---- if (verbose) { headers[cols++] = gettext_noop("Storage"); ! if (tableinfo.relkind != 'i' && tableinfo.relkind != 'S') ! headers[cols++] = gettext_noop("Description"); } printTableInit(&cont, &myopt, title.data, cols, numrows); *************** describeOneTableDetails(const char *sche *** 1471,1478 **** (storage[0] == 'e' ? "external" : "???")))), false, false); ! printTableAddCell(&cont, PQgetvalue(res, i, firstvcol + 1), ! false, false); } } --- 1479,1487 ---- (storage[0] == 'e' ? "external" : "???")))), false, false); ! if (tableinfo.relkind != 'i' && tableinfo.relkind != 'S') ! printTableAddCell(&cont, PQgetvalue(res, i, firstvcol + 1), ! false, false); } }
diff --git a/doc/src/sgml/ref/comment.sgml b/doc/src/sgml/ref/comment.sgml index 7bbfd01..44e2dbf 100644 *** a/doc/src/sgml/ref/comment.sgml --- b/doc/src/sgml/ref/comment.sgml *************** COMMENT ON *** 25,30 **** --- 25,31 ---- { TABLE <replaceable class="PARAMETER">object_name</replaceable> | COLUMN <replaceable class="PARAMETER">table_name</replaceable>.<replaceable class="PARAMETER">column_name</replaceable> | + COLUMN <replaceable class="PARAMETER">index_name</replaceable>.<replaceable class="PARAMETER">column_name</replaceable> | AGGREGATE <replaceable class="PARAMETER">agg_name</replaceable> (<replaceable class="PARAMETER">agg_type</replaceable> [, ...] ) | CAST (<replaceable>sourcetype</replaceable> AS <replaceable>targettype</replaceable>) | CONSTRAINT <replaceable class="PARAMETER">constraint_name</replaceable> ON <replaceable class="PARAMETER">table_name</replaceable> | *************** COMMENT ON *** 87,92 **** --- 88,94 ---- <varlistentry> <term><replaceable class="parameter">object_name</replaceable></term> <term><replaceable class="parameter">table_name.column_name</replaceable></term> + <term><replaceable class="parameter">index_name.column_name</replaceable></term> <term><replaceable class="parameter">agg_name</replaceable></term> <term><replaceable class="parameter">constraint_name</replaceable></term> <term><replaceable class="parameter">func_name</replaceable></term>
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers