pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jonathan Zacharuk <jonathan.zacharuk@ascentech.ca>
To: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Subject: Error when using unquoted identifier that contains the word end in a begin atomic block
Date: Thu, 24 Aug 2023 19:53:03 +0000
Message-ID: <YT2PR01MB4318B3BD0B4D84546C3EAC169C1DA@YT2PR01MB4318.CANPRD01.PROD.OUTLOOK.COM> (raw)

PostgreSQL 15.2 (Debian 15.2-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
Run via Docker 15.4 image

It seems to me that within a BEGIN ATOMIC block the use of the word "end" within an unquoted identifier is causing an error.
The word "end" is a reserved keyword. However, it is my understanding from the documentation that keywords cannot be used *as* an identifier, but they should be able to be used within an identifier.
For instance, the "end" in effective_end_date is a valid identifier.

-- Create a data set with the word end in it.
CREATE VIEW test_view AS
SELECT CURRENT_TIMESTAMP as effective_end_date
> OK
> Query Time: 0.002s

-- This function is successfully created (note the quoted "effective_end_date").
CREATE OR REPLACE FUNCTION test_function_success() RETURNS TIMESTAMP
LANGUAGE SQL
BEGIN ATOMIC
  SELECT DISTINCT "effective_end_date"
                FROM test_view;
END
> Affected rows: 0
> Query Time: 0.001s

-- This function fails to be created. I would expect this to work.
CREATE OR REPLACE FUNCTION test_function_fail() RETURNS TIMESTAMP
LANGUAGE SQL
BEGIN ATOMIC
  SELECT DISTINCT effective_end_date
                FROM test_view
> ERROR:  syntax error at end of input
LINE 6:  FROM test_view
                       ^

> Query Time: 0s

view thread (3+ messages)  latest in thread

Message-ID: <YT2PR01MB4318B3BD0B4D84546C3EAC169C1DA@YT2PR01MB4318.CANPRD01.PROD.OUTLOOK.COM>
Permalink:  ../YT2PR01MB4318B3BD0B4D84546C3EAC169C1DA@YT2PR01MB4318.CANPRD01.PROD.OUTLOOK.COM/
Also on:    postgresql.org/message-id/YT2PR01MB4318B3BD0B4D84546C3EAC169C1DA@YT2PR01MB4318.CANPRD01.PROD.OUTLOOK.COM

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: jonathan.zacharuk@ascentech.ca
  Subject: Re: Error when using unquoted identifier that contains the word end in a begin atomic block
  In-Reply-To: <YT2PR01MB4318B3BD0B4D84546C3EAC169C1DA@YT2PR01MB4318.CANPRD01.PROD.OUTLOOK.COM>
  References: <YT2PR01MB4318B3BD0B4D84546C3EAC169C1DA@YT2PR01MB4318.CANPRD01.PROD.OUTLOOK.COM>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox