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: ALTER TABLE results in "ERROR: could not open relation with OID 43707388"
Date: Sat, 02 Nov 2019 12:04:19 -0400
Message-ID: <31328.1572710659@sss.pgh.pa.us> (raw)
In-Reply-To: <28152.1562692038@sss.pgh.pa.us>
References: <CA+u7OA4hkFSV_Y=sW_vNcYgKFEoq0WL5GtrBWEHUZnCqSqjhAA@mail.gmail.com>
<28152.1562692038@sss.pgh.pa.us>
I wrote:
> Manuel Rigger <rigger.manuel@gmail.com> writes:
>> CREATE TABLE t0(c0 INT);
>> CREATE UNIQUE INDEX i0 ON t0(c0);
>> ALTER TABLE t0 ADD PRIMARY KEY USING INDEX i0, ALTER c0 TYPE BIGINT;
>> -- unexpected: ERROR: could not open relation with OID 43707388
> The sequence of events here is that:
> 1. transformIndexConstraint looks up the index "i0" and saves its OID
> in the IndexStmt's indexOid field.
> 2. ALTER c0 TYPE BIGINT executes first, because of ALTER TABLE's
> pass design. It rebuilds the i0 index --- with a new OID.
> 3. ATExecAddIndexConstraint tries to look up i0 using the old OID.
> Kaboom.
FYI, the patch I posted at
https://www.postgresql.org/message-id/24573.1572647175%40sss.pgh.pa.us
fixes this (as well as your other similar complaint). I forgot to
add a regression test matching this case, but will do so later.
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: ALTER TABLE results in "ERROR: could not open relation with OID 43707388"
In-Reply-To: <31328.1572710659@sss.pgh.pa.us>
References: <CA+u7OA4hkFSV_Y=sW_vNcYgKFEoq0WL5GtrBWEHUZnCqSqjhAA@mail.gmail.com> <28152.1562692038@sss.pgh.pa.us> <31328.1572710659@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