BUG #15555: Syntax errors when using the COMMENT command in plpgsql and a "comment" variable

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: feikesteenbergen(at)gmail(dot)com
Subject: BUG #15555: Syntax errors when using the COMMENT command in plpgsql and a "comment" variable
Date: 2018-12-17 09:10:12
Message-ID: 15555-149bbd70ddc7b4b6@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 15555
Logged by: Feike Steenbergen
Email address: feikesteenbergen(at)gmail(dot)com
PostgreSQL version: 11.1
Operating system: CentOS Linux release 7.5.1804 (Core)
Description:

Recently, I ran into an issue when trying to put comments on objects in
plpgsql DO block, for example the following:

DO $$
DECLARE
"comment" text := 'This is a comment';
BEGIN
COMMENT ON TABLE abc IS 'This is another comment';
END;
$$;

Generates the following error message:

ERROR: 42601: syntax error at or near "ON"
LINE 5: COMMENT ON TABLE abc IS 'This is another comment';

Renaming the variable from "comment" to something else makes the problem go
away,
as well as wrapping the COMMENT command in an EXECUTE call;
It happens both when double quoting the identifier, or when omitting the
double
quotes.

For now I'll just avoid using comment as a variable name altogether, but I
was
surprised by this behaviour.

Kind regards,

Feike

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message amul sul 2018-12-17 09:14:32 Re: ALTER INDEX ... ALTER COLUMN not present in dump
Previous Message PG Bug reporting form 2018-12-17 08:57:16 BUG #15554: Broken pipe when doing a COPY of a parallel query