Re: BUG #15446: Crash on ALTER TABLE

From: Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com>
To: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
Cc: Andres Freund <andres(at)anarazel(dot)de>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Dmitry Molotkov <aldarund(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: BUG #15446: Crash on ALTER TABLE
Date: 2019-01-09 00:41:55
Message-ID: 9e4caaa2-e2af-fd7f-e864-ae67e9560579@2ndQuadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers


On 1/8/19 4:48 PM, Dean Rasheed wrote:
> On Tue, 8 Jan 2019 at 19:34, Andrew Dunstan
> <andrew(dot)dunstan(at)2ndquadrant(dot)com> wrote:
>> Here's a patch that I think cures the problem.
>>
> Hmm, that doesn't quite work because the table might not actually be
> rewritten as a result of the type change. For example:
>
> DROP TABLE IF EXISTS foo;
> CREATE TABLE foo (a int);
> INSERT INTO foo VALUES (1);
> ALTER TABLE foo ADD COLUMN b varchar(10) DEFAULT 'xxx';
> ALTER TABLE foo ALTER COLUMN b SET DEFAULT 'yyy';
> INSERT INTO foo VALUES (2);
> SELECT * FROM foo;
> a | b
> ---+-----
> 1 | xxx
> 2 | yyy
> (2 rows)
>
> ALTER TABLE foo ALTER COLUMN b TYPE varchar(20) USING b::varchar(20);
> SELECT * FROM foo;
> a | b
> ---+-----
> 1 |
> 2 | yyy
> (2 rows)
>

Ouch, OK, looks like we need something more complex.

cheers

andrew

--
Andrew Dunstan https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Thomas Munro 2019-01-09 01:52:45 Re: BUG #15577: Query returns different results when executed multiple times
Previous Message Tom Lane 2019-01-09 00:36:06 Re: BUG #15572: Misleading message reported by "Drop function operation" on DB with functions having same name

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2019-01-09 00:47:55 Re: Making all nbtree entries unique by having heap TIDs participate in comparisons
Previous Message Tom Lane 2019-01-09 00:36:06 Re: BUG #15572: Misleading message reported by "Drop function operation" on DB with functions having same name