Re: ORACLE COMMENT statement - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: ORACLE COMMENT statement
Date
Msg-id Pine.LNX.4.10.9910172158480.366-100000@peter-e.yi.org
Whole thread Raw
In response to Re: ORACLE COMMENT statement  (Mike Mascari <mascarim@yahoo.com>)
List pgsql-hackers
On Oct 16, Mike Mascari mentioned:

> Hopefully, I'll have the other forms done in the next
> few days. As Bruce pointed out, \dd already displays
> comments for any type. I was hoping for a single 
> psql '\' command to display the table, its comments,
> its column definitions, and any comments associated 
> with the columns...(an outer join SURE would be 
> nice for that -- altough one could always do a 
> SELECT ... WHERE join UNION SELECT WHERE NOT EXISTS..)

I tell you, outer joins will be nice for a lot of things in psql. At this
point I'm not sure if I should break backwards compatibility like that,
but then psql is supposed to be sort of the example application, so the
latest technology ought to be used.

Anyway, the \dd command was kind of odd in that it only displayed comments
but not what the comments went with.

The way I currently have implemented the comments is like this:
(Ignoring the actual output format, which is currently under _heavy_
development.)

peter@localhost:5432 play=> \d foobar
Table "foobar"
Attribute |     Type     |   Info
----------+--------------+---------
a         | numeric(9,2) | not null
b         | varchar(5)   |
c         | char(10)     |
d         | char(1)      |

peter@localhost:5432 play=> \set description ""
peter@localhost:5432 play=> \d foobar
Table "foobar"
Attribute |     Type     |   Info   | Description
----------+--------------+----------+------------
a         | numeric(9,2) | not null |
b         | varchar(5)   |          |
c         | char(10)     |          |
d         | char(1)      |          |

peter@localhost:5432 play=> \l
List of databases
Database  |  Owner   | Encoding |              Description
----------+----------+----------+---------------------------------------
play      | postgres |        0 |
pwdb      | peter    |        0 |
template1 | postgres |        0 |
twig      | httpd    |        0 | This is for that Twig mailer under PHP
(4 rows)

peter@localhost:5432 play=> \unset description
peter@localhost:5432 play=> \l
List of databases
Database  |  Owner   | Encoding
----------+----------+---------
play      | postgres |        0
pwdb      | peter    |        0
template1 | postgres |        0
twig      | httpd    |        0
(4 rows)

peter@localhost:5432 play=> \dd
Object descriptions
      Name        |   What   | Description
-------------------+----------+------------------------------------------
!                  | operator | fraction
!!                 | operator | fraction
!!=                | operator | not in
!~                 | operator | does not match regex., case-sensitive
!~*                | operator | does not match regex., case-insensitive
!~~                | operator | does not match LIKE expression
#                  | operator | intersection point
--<snip>--
varcharne          | function | not equal
varcharoctetlen    | function | octet length
version            | function | PostgreSQL version string
width              | function | box width
xid                | type     | transaction id
xideq              | function | equal
|                  | operator | start of interval
|/                 | operator | square root
||                 | operator | concatenate
||/                | operator | cube root
~                  | operator | contains
~                  | operator | matches regex., case-sensitive
~                  | operator | path contains point?
~                  | operator | polygon contains point?
~*                 | operator | matches regex., case-insensitive
~=                 | operator | same as
~~                 | operator | matches LIKE expression
(973 rows)

peter@localhost:5432 play=> \dd version
Object descriptionsName   |   What   |        Description
--------+----------+--------------------------
version | function | PostgreSQL version string
(1 row)


Now if we just put a description on every pre-installed entity (in
particular system tables), this is almost like a built-in quick reference!

The \dd doesn't do rules yet, I think. But I'll put that in soon.

So do you see that as a feasible solution?
-Peter

-- 
Peter Eisentraut                  Sernanders vaeg 10:115
peter_e@gmx.net                   75262 Uppsala
http://yi.org/peter-e/            Sweden



pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: [HACKERS] pg_type questions
Next
From: Mike Mascari
Date:
Subject: Re: [HACKERS] Re: ORACLE COMMENT statement