psql: bogus descriptions displayed by \d+ - Mailing list pgsql-hackers

From Josh Kupershmidt
Subject psql: bogus descriptions displayed by \d+
Date
Msg-id CAK3UJRHzL+C3YgS-JcZHPxD+tqem2Esh6AxL6qgoCzJnrnMRhg@mail.gmail.com
Whole thread Raw
Responses Re: psql: bogus descriptions displayed by \d+
List pgsql-hackers
Hi all,

The psql output for \d+ on indexes, sequences, and views is rather
bogus. Examples below from the SQL at bottom.

So, if you look at \d+ newtbl, the right-most column named Description
should display any comments attached to newtbl's columns. You should
see "bcol column comment" as the Description for column bcol. That
works OK.

Now, try this:

test=# \d+ newtbl_idx_bcol           Index "public.newtbl_idx_bcol"Column |  Type   | Definition | Storage |
Description
--------+---------+------------+---------+-------------bcol   | integer | bcol       | plain   |

What's the Description displayed in that table? Well, right now it's
totally broken (not displaying anything). I'm not sure if we should
try to display the comment attached to column bcol in this case: if
so, what would we do for e.g. functional indexes?

A similar situation exists for sequences and views displayed by \d+.
I'd be OK with just ripping out "Description" entirely in these cases;
if you want to see the comment attached to the index or sequence
itself, you can use \di+ or \ds+. Although now might also be a good
time to think about properly displaying sequence or index comments via
\d+, and how they should be displayed.

Thoughts?

Josh

-- Example SQL creating a few objects with comments. --
CREATE TABLE newtbl (acol  serial PRIMARY KEY,bcol int NOT NULL,ccol text DEFAULT NULL,dcol text NOT NULL);

COMMENT ON TABLE newtbl IS 'newtbl table comment';
COMMENT ON COLUMN newtbl.bcol IS 'bcol column comment';
COMMENT ON SEQUENCE newtbl_acol_seq IS 'sequence comment';

CREATE INDEX newtbl_idx_bcol ON newtbl (bcol);
COMMENT ON INDEX newtbl_idx_bcol IS 'single-column index on newtbl';

CREATE VIEW myview AS SELECT * FROM newtbl;
COMMENT ON VIEW myview IS 'view comment';


pgsql-hackers by date:

Previous
From: Florian Pflug
Date:
Subject: Re: Commitfest Status: Sudden Death Overtime
Next
From: Tom Lane
Date:
Subject: Re: psql: bogus descriptions displayed by \d+