Review
Provide support for trailing commas
- Base commit
- 412848dac37f2e4455e1505f83f0af0f3d28a67d
Assessment
The patch proposes allowing trailing commas in SQL SELECT target lists (e.g. "SELECT 1, 2, 3, FROM pg_class;"). The implementation modifies src/backend/parser/gram.y by splitting target_list into target_list_items and an optional opt_trailing_comma production.
From a technical standpoint, while the grammar modification is small and regression tests pass on base commit 412848dac37f2e4455e1505f83f0af0f3d28a67d:
- It introduces non-standard SQL syntax without a compelling justification.
- Permitting arbitrary trailing commas in list productions creates ambiguities and significantly restricts future grammar extensions when implementing upcoming SQL standard clauses.
- Providing trailing comma support in only one arbitrary syntactic position (target lists) creates an inconsistent developer experience.
Discussion and Consensus
The proposal met with immediate and decisive opposition from multiple core developers and committers, including Tom Lane, David Rowley, and Bruce Momjian. The consensus is overwhelmingly against adopting trailing commas due to grammar complexity and future standards conflicts. There is no viable path forward for this patch in core PostgreSQL.