DISCARD TEMP results in "ERROR: cache lookup failed for type 0"

Manuel Rigger <rigger.manuel@gmail.com>

From: Manuel Rigger <rigger.manuel@gmail.com>
To: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Date: 2019-07-04T12:59:37Z
Lists: pgsql-bugs
Hi everyone,

the test case below fails with "ERROR:  cache lookup failed for type
0", which is unexpected.

CREATE TEMP TABLE t0(c0 INT GENERATED ALWAYS AS IDENTITY) PARTITION BY
HASH((t0.c0));
VACUUM FULL;
DISCARD TEMP; -- unexpected: ERROR: cache lookup failed for type 0

The error only occurs for TEMP tables. I can reproduce it when
partitioning by HASH, RANGE, or LIST. It occurs with GENERATED BY
DEFAULT and also with GENERATED BY ALWAYS.

I found this bug on Ubuntu 11.4-1.pgdg19.04+1.

Best,
Manuel



Commits

  1. Install dependencies to prevent dropping partition key columns.

  2. Sort the dependent objects before recursing in findDependentObjects().