Hi,

Currently we have CREATE TABLE statements in a git repository that look roughly like this:

CREATE TABLE foo(
  -- the first field
  f1 int NOT NULL,
  -- the second field
  f2 int NOT NULL,
...
);

But the problem is that those comments don't obviously make it all the way to the database, so e.g. \d+ tblname won't show you that precious information. If you want them to make it all the way to the database, you'd have to add COMMENT ON statements *after* the CREATE TABLE, which means that either column comments have to be maintained twice, or the CREATE TABLE statement won't have them, so you have to go back and forth in your text editor to see the comments. Both solutions are suboptimal.

What I would prefer is something like this:

CREATE TABLE foo(
  f1 int NOT NULL COMMENT
    'the first field',
  f2 int NOT NULL COMMENT
    'the second field',
...
);

which would ensure the comments are both next to the field definition they're documenting and that they make it all the way to the database. I looked into the biggest products, and MySQL supports this syntax. I couldn't find any similar syntax in any other product.

The downside is that this would require us to make COMMENT a fully reserved keyword, which would quite likely break at least one application out in the wild. Another option would be to make the syntax something like [ COLUMN COMMENT '...' ], but that's not exactly a beautiful solution either.

I still think this would be a really valuable feature if we can come up with a decent syntax for it. Does anyone have any ideas? Or does anybody want to shoot this proposal down right off the bat?


.m


--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to