Re: 9.5.4: Segfault (signal 11) while running ALTER TABLE

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Devrim Gündüz <devrim(at)gunduz(dot)org>
Cc: PostgreSQL Hackers ML <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: 9.5.4: Segfault (signal 11) while running ALTER TABLE
Date: 2016-08-30 12:18:37
Message-ID: 22548.1472559517@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Devrim =?ISO-8859-1?Q?G=FCnd=FCz?= <devrim(at)gunduz(dot)org> writes:
> They wanted to change id column from uuid to int, so created this func first:

> CREATE FUNCTION foofunc_id_uuidtoint(chartoconvert uuid) RETURNS integer
> LANGUAGE sql IMMUTABLE STRICT
> AS $_$
> SELECT newid FROM foo1 WHERE tempuuid = $1 LIMIT 1;
> $_$;

> and ran this:

> ALTER TABLE foo1 ALTER COLUMN id TYPE INTEGER USING
> foofunc_id_uuidtoint(tempuuid);

> This command crashed postmaster.

The above isn't ever likely to work for any large value of "work",
because the function would be confused about what the table rowtype
is. I thought we had adequate defenses in there to throw an error
if you try to access a table that's in the middle of being altered,
but apparently this case isn't covered.

Why didn't they just do
ALTER TABLE foo1 ALTER COLUMN id TYPE INTEGER USING newid;
? The intermediate function sure seems like the hard way.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2016-08-30 12:46:48 sequences and pg_upgrade
Previous Message Kevin Grittner 2016-08-30 11:44:19 Re: old_snapshot_threshold documentation