Re: Disallow USING clause when altering type of generated column
jian he <jian.universality@gmail.com>
From: jian he <jian.universality@gmail.com>
To: Peter Eisentraut <peter@eisentraut.org>
Cc: Yugo Nagata <nagata@sraoss.co.jp>,
pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2024-08-22T03:38:49Z
Lists: pgsql-hackers
On Wed, Aug 21, 2024 at 4:57 PM Peter Eisentraut <peter@eisentraut.org> wrote:
>
+ /*
+ * Cannot specify USING when altering type of a generated column, because
+ * that would violate the generation expression.
+ */
+ if (attTup->attgenerated && def->cooked_default)
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_TABLE_DEFINITION),
+ errmsg("cannot specify USING when altering type of generated column"),
+ errdetail("Column \"%s\" is a generated column.", colName)));
+
errcode should be ERRCODE_FEATURE_NOT_SUPPORTED?
also
CREATE TABLE gtest27 (
a int,
b text collate "C",
x text GENERATED ALWAYS AS ( b || '_2') STORED
);
ALTER TABLE gtest27 ALTER COLUMN x TYPE int;
ERROR: column "x" cannot be cast automatically to type integer
HINT: You might need to specify "USING x::integer".
should we do something for the errhint, since this specific errhint is wrong?
Commits
-
Disallow USING clause when altering type of generated column
- 4d68a043245a 18.0 landed
- 1c57ae795b3c 12.21 landed
- 7589d5c5b98d 13.17 landed
- ecd19a3cc187 14.14 landed
- cf49a606c416 15.9 landed
- 5867ee0056a2 16.5 landed
- fdbf7e46a46d 17.0 landed