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