[bug] keyword commit being accepted for column name

Started by Vinícius Abrahão10 months ago3 messagesbugs
Jump to latest
#1Vinícius Abrahão
vinnix.bsd@gmail.com

postgres=# create table postgres_git_repository(commit text,
first_line_commit text);
CREATE TABLE
postgres=# create table postgres_git_repository2("commit" text,
first_line_commit text);
CREATE TABLE
postgres=# create table postgres_git_repository3("COMMIT" text,
first_line_commit text);
CREATE TABLE

postgres=# select version();
version

--------------------------------------------------------------------------------------------------------
PostgreSQL 17.4 on x86_64-pc-linux-gnu, compiled by clang version 19.1.7
(CentOS 19.1.7-1.el9), 64-bit

postgres=# \d postgres_git_repository
Table "public.postgres_git_repository"
Column | Type | Collation | Nullable | Default
-------------------+------+-----------+----------+---------
commit | text | | |
first_line_commit | text | | |

postgres=# \h commit
Command: COMMIT
Description: commit the current transaction
Syntax:
COMMIT [ WORK | TRANSACTION ] [ AND [ NO ] CHAIN ]

URL: https://www.postgresql.org/docs/17/sql-commit.html

#2Kirk Parker
khp@equatoria.us
In reply to: Vinícius Abrahão (#1)
Re: [bug] keyword commit being accepted for column name

On Sat, May 31, 2025, 11:03 Vinícius Abrahão <vinnix.bsd@gmail.com> wrote:

postgres=# create table postgres_git_repository(commit text,
first_line_commit text);
CREATE TABLE
postgres=# create table postgres_git_repository2("commit" text,
first_line_commit text);
CREATE TABLE
postgres=# create table postgres_git_repository3("COMMIT" text,
first_line_commit text);
CREATE TABLE

postgres=# select version();
version

--------------------------------------------------------------------------------------------------------
PostgreSQL 17.4 on x86_64-pc-linux-gnu, compiled by clang version 19.1.7
(CentOS 19.1.7-1.el9), 64-bit

postgres=# \d postgres_git_repository
Table "public.postgres_git_repository"
Column | Type | Collation | Nullable | Default
-------------------+------+-----------+----------+---------
commit | text | | |
first_line_commit | text | | |

postgres=# \h commit
Command: COMMIT
Description: commit the current transaction
Syntax:
COMMIT [ WORK | TRANSACTION ] [ AND [ NO ] CHAIN ]

URL: https://www.postgresql.org/docs/17/sql-commit.html

This is one of those cases where PostgreSQL diverges from the SQL standard
(and documents that it does so):

https://www.postgresql.org/docs/current/sql-keywords-appendix.html#KEYWORDS-TABLE

Show quoted text
#3David G. Johnston
david.g.johnston@gmail.com
In reply to: Vinícius Abrahão (#1)
Re: [bug] keyword commit being accepted for column name

On Saturday, May 31, 2025, Vinícius Abrahão <vinnix.bsd@gmail.com> wrote:

postgres=# create table postgres_git_repository(commit text,
first_line_commit text);
CREATE TABLE
postgres=# create table postgres_git_repository2("commit" text,
first_line_commit text);
CREATE TABLE
postgres=# create table postgres_git_repository3("COMMIT" text,
first_line_commit text);
CREATE TABLE

Only the first of those is even valid here, if you double-quote an
identifier it never is even possibly considered a keyword that could
conflict. As for the first one, our reserved words specification doesn’t
claim commit as one of them. Bugs need to things where we claim one thing
and implement something different. Not relative to some external
specification.

David J.