Generated column and string concatenation issue - Mailing list pgsql-bugs

From Manuel Rigger
Subject Generated column and string concatenation issue
Date
Msg-id CA+u7OA6AD9OLziFW+io1HgN8q_XH0o1Y5RyufXYO5=0fnhG5zQ@mail.gmail.com
Whole thread Raw
Responses Re: Generated column and string concatenation issue
List pgsql-bugs
Hi everyone,

Consider the following statement:

CREATE TABLE t0(c0 TEXT GENERATED ALWAYS AS (('abc' || 1)) STORED); --
unexpected: generation expression is not immutable

I would expect that this table can be created. However, I get the
following error message: "ERROR:  generation expression is not
immutable". The documentation [1] mentions several restrictions for
generated columns, but I did not see any restrictions on operators (or
is string concatenation considered to be a function?).

Adding an explicit cast to string on the non-string argument results
in no error being shown:

CREATE TABLE t0(c0 TEXT GENERATED ALWAYS AS (('abc' || 1::TEXT))
STORED); -- expected: no error

I'm using the following Postgres version: 12beta2 (Debian 12~beta2-1.pgdg90+1)

Best,
Manuel


[1] https://www.postgresql.org/docs/devel/ddl-generated-columns.html



pgsql-bugs by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: BUG #15903: Getting error
Next
From: Tom Lane
Date:
Subject: Re: Generated column and string concatenation issue