Re: last comma inside "CREATE TABLE ()" statements

From: "Oliver Elphick" <olly(at)lfix(dot)co(dot)uk>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Louis-David Mitterrand <vindex(at)apartia(dot)ch>, pgsql-general(at)postgresql(dot)org
Subject: Re: last comma inside "CREATE TABLE ()" statements
Date: 2001-04-22 18:44:46
Message-ID: 200104221844.f3MIilU22323@linda.lfix.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tom Lane wrote:
>Louis-David Mitterrand <vindex(at)apartia(dot)ch> writes:
>> Is it against the SQL standard to accept a trailing comma in a table
>> declaration?
>
>Yes ...
>
>> CREATE TABLE "currency" (
>> currency_id varchar(3),
>> rate float, <-------------------- BOOM! parse error
>> );
>
>> As in perl, it would make life easier to simply ignore/accept a trailing
>> comma on table declarations.
>
>... however, this seems like a reasonable idea that would not introduce
>any major problems. I have no objections, if someone wants to submit
>a grammar patch.

I suppose it isn't a major problem, but enforcing strict grammar
helps to show up inadvertent errors. Suppose I have a set of schema
building files for a whole system; the way I do things, there may be fifty
or more files, one per table. If one of these gets corrupted in editing
(perhaps a line gets deleted by mistake) it would be nice to know about it
through a parser error. Of course, an error may be such that the parser
won't detect it, but why remove protection by gratuitously departing from
the standard?

--
Oliver Elphick Oliver(dot)Elphick(at)lfix(dot)co(dot)uk
Isle of Wight http://www.lfix.co.uk/oliver
PGP: 1024R/32B8FAA1: 97 EA 1D 47 72 3F 28 47 6B 7E 39 CC 56 E4 C1 47
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C
========================================
"If my people, which are called by my name, shall
humble themselves, and pray, and seek my face, and
turn from their wicked ways; then will I hear from
heaven, and will forgive their sin, and will heal
their land." II Chronicles 7:14

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Mitch Vincent 2001-04-22 18:48:36 Re: last comma inside "CREATE TABLE ()" statements
Previous Message Joel Burton 2001-04-22 18:19:55 Re: CAST doesn't work :-(