Re: Why forbid "INSERT INTO t () VALUES ();"

Поиск
Список
Период
Сортировка
От Fabien COELHO
Тема Re: Why forbid "INSERT INTO t () VALUES ();"
Дата
Msg-id alpine.DEB.2.22.394.2006250636050.2665420@pseudo
обсуждение исходный текст
Ответ на Re: Why forbid "INSERT INTO t () VALUES ();"  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Why forbid "INSERT INTO t () VALUES ();"  (Vik Fearing <vik@postgresfriends.org>)
Re: Why forbid "INSERT INTO t () VALUES ();"  (David Rowley <dgrowleyml@gmail.com>)
Re: Why forbid "INSERT INTO t () VALUES ();"  (Robert Haas <robertmhaas@gmail.com>)
Список pgsql-hackers
Hello Tom,

>>>>   INSERT INTO t() VALUES ();
>
>> I'm still unclear why it would be forbidden though, it seems logical to
>> try that, whereas the working one is quite away from the usual syntax.
>
> It's forbidden because the SQL standard forbids it.

Ok, that is definitely a reason. I'm not sure it is a good reason, though.

Why would the standard forbid it? From the language design point of view, 
it is basically having a syntax for lists which would not work for empty 
lists, or a syntax for strings which would not work for empty strings.

It also means that if for some reason someone wants to insert several such 
all-default rows, they have to repeat the insert, as "VALUES (), ();" 
would not work, so it is also losing a corner-corner case capability 
without obvious reason.

> We allow zero-column syntaxes in some other places where SQL forbids
> them,

Then forbidding there it just adds awkwardness: the same thing works in 
one place but not in another. That does not help users.

> but that's only because there is no reasonable alternative. In this 
> case, there's a perfectly good, standards-compliant alternative. So why 
> encourage people to write unportable code?

I doubt that people look at the (costly) standard when writing corner case 
queries, they just try something logical as I did.

As some other databases accepts it, and if it is already allowed elsewhere 
in pg, encouraging portability is not the main issue here. I'd rather have 
logic and uniformity accross commands.

If I'm annoyed enough to send a patch some day, would you veto it because 
it departs from the standard?

Anyway, thanks for the answer!

-- 
Fabien.



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Michael Paquier
Дата:
Сообщение: Re: should libpq also require TLSv1.2 by default?
Следующее
От: Fujii Masao
Дата:
Сообщение: Re: Review for GetWALAvailability()