From: Tom Lane <tgl@sss.pgh.pa.us>
To: Manuel Rigger <rigger.manuel@gmail.com>
Cc: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Subject: Re: Attribute has wrong type in ALTER TABLE
Date: Wed, 24 Jul 2019 14:02:23 -0400
Message-ID: <518.1563991343@sss.pgh.pa.us> (raw)
In-Reply-To: <CA+u7OA6RmQLwvXGxx0nGt3T79Ka5MkOJs4_qcdx6X5c-rR_yNg@mail.gmail.com>
References: <CA+u7OA6RmQLwvXGxx0nGt3T79Ka5MkOJs4_qcdx6X5c-rR_yNg@mail.gmail.com>
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...
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, rigger.manuel@gmail.com
Subject: Re: Attribute has wrong type in ALTER TABLE
In-Reply-To: <518.1563991343@sss.pgh.pa.us>
References: <CA+u7OA6RmQLwvXGxx0nGt3T79Ka5MkOJs4_qcdx6X5c-rR_yNg@mail.gmail.com> <518.1563991343@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox