Re: Attribute has wrong type in ALTER TABLE

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Manuel Rigger <rigger(dot)manuel(at)gmail(dot)com>
Cc: PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: Attribute has wrong type in ALTER TABLE
Date: 2019-07-24 18:02:23
Message-ID: 518.1563991343@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Manuel Rigger <rigger(dot)manuel(at)gmail(dot)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David Raymond 2019-07-24 18:15:32 RE: BUG #15922: Simple select with multiple exists filters returns duplicates from a primary key field
Previous Message Tom Lane 2019-07-24 17:06:38 Re: BUG #15922: Simple select with multiple exists filters returns duplicates from a primary key field