Allowing additional commas between columns, and at the end of the SELECT clause

From: Artur Formella <artur(dot)formella3(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Allowing additional commas between columns, and at the end of the SELECT clause
Date: 2024-05-12 22:15:14
Message-ID: 0368c60f-abe2-4f5f-972d-7cd1e6db2382@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello!
I have created a patch to allow additional commas between columns, and
at the end of the SELECT clause.

Motivation:
Commas of this type are allowed in many programming languages, in some
it is even recommended to use them at the ends of lists or objects. A
new generation of programmers expects a more forgiving language just as
our generation enjoyed LIMIT and the ability to write `select` in lowercase.

Accepted:
    SELECT 1,;
    SELECT 1,,,,,;
    SELECT *, from information_schema.sql_features;
    (...) RETURNING a,,b,c,;

Not accepted:
    SELECT ,;
    SELECT ,1;
    SELECT ,,,;

Advantages:
- simplifies the creation and debugging of queries by reducing the most
common syntax error,
- eliminates the need to use the popular `1::int as dummy` at the end of
a SELECT list,
- simplifies query generators,
- the query is still deterministic,

Disadvantages:
- counting of returned columns can be difficult,
- syntax checkers will still report errors,
- probably not SQL standard compliant,
- functionality can be controversial,

I attach the patch along with the tests.

What do you think?

Your opinions are very much welcome!

Attachment Content-Type Size
0001-additional_commas.patch text/plain 5.3 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2024-05-12 22:35:48 Re: Weird test mixup
Previous Message Thomas Munro 2024-05-12 22:05:25 Re: Why is citext/regress failing on hamerkop?