Re: Attribute has wrong type in ALTER TABLE - Mailing list pgsql-bugs

From Tom Lane
Subject Re: Attribute has wrong type in ALTER TABLE
Date
Msg-id 518.1563991343@sss.pgh.pa.us
Whole thread Raw
In response to Attribute has wrong type in ALTER TABLE  (Manuel Rigger <rigger.manuel@gmail.com>)
Responses Re: Attribute has wrong type in ALTER TABLE  (Manuel Rigger <rigger.manuel@gmail.com>)
List pgsql-bugs
Manuel Rigger <rigger.manuel@gmail.com> writes:
> the statements below result in an error "ERROR:  attribute 1 of type
> t0 has wrong type":

> CREATE TABLE t0(c0 VARCHAR(10));
> INSERT INTO t0(c0) VALUES('');
> ALTER TABLE t0 ALTER c0 SET DATA TYPE TEXT, ADD EXCLUDE (('a' LIKE
> t0.c0) WITH =); -- unexpected: ERROR:  attribute 1 of type t0 has
> wrong type

Yeah, this is another variant of the problems with doing
transformIndexStmt too early, like your previous report
https://www.postgresql.org/message-id/CA%2Bu7OA4hkFSV_Y%3DsW_vNcYgKFEoq0WL5GtrBWEHUZnCqSqjhAA%40mail.gmail.com
The index expression is parse-analyzed while c0 is still varchar,
and then it's wrong by the time we go to create the index.

We need to fix things so that ALTER TABLE doesn't do any of that
work until after it's finished with ALTER COLUMN TYPE subcommands.

            regards, tom lane



pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #15922: Simple select with multiple exists filters returns duplicates from a primary key field
Next
From: David Raymond
Date:
Subject: RE: BUG #15922: Simple select with multiple exists filters returnsduplicates from a primary key field