pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: hackerzheng666@gmail.com
Subject: BUG #19903: ALTER COLUMN TYPE: "unexpected object depending on column" internal error via partition key
Date: Sun, 15 Nov 2026 04:47:59 +0000
Message-ID: <19903-06341b8535c78fc1@postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      19903
Logged by:          Zheng Hacker
Email address:      hackerzheng666@gmail.com
PostgreSQL version: 19rc2
Operating system:   Linux x86_64 (Ubuntu 22.04)
Description:        

Tested on git master (20devel, commit 70c4a57b64d3; the code in question is
unchanged at master 81b2179 as of 2026-11-14). Not tested on 19rc2 or older
branches; the version selected in the form is only the closest listed one.

ALTER COLUMN TYPE on a column of a table that is also used as a composite
type raises an internal (XX000) error if the partition key expression of
another table selects a field of that composite type:

create table attbl(a numeric);
create table atref(b text) partition by range ((('(1)'::attbl).a +
length(b)));
alter table attbl alter column a type bigint;
ERROR:  unexpected object depending on column: table atref

The same dependency through an index expression or a CHECK constraint gives
the expected user error:

  index expression : ERROR:  cannot alter table "attbl" because index
atref_1_numeric_length_b_idx uses its row type
  CHECK constraint : ERROR:  cannot alter table "attbl" because constraint
atref_check on table atref uses its row type

In ATExecAlterColumnType() (tablecmds.c), the scan over the column's
pg_depend entries has a "case RelationRelationId" branch that handles
indexes and sequences and raises elog(ERROR, "unexpected object depending on
column: %s") for every other relation kind. A partitioned table whose
partition key expression selects a field of the altered composite type
depends on that column through its pg_depend entry for the relation itself,
so it ends up in that branch.

Expected: a user-facing error in the same style as the index and constraint
cases, for example "cannot alter table "attbl" because partition key of
table "atref" uses its row type".

(Found with a fuzzer; reduced by hand. Checked on current master only. A
bare partition key (('(1)'::attbl).a) is rejected earlier with "cannot use
constant expression as partition key", hence the "+ length(b)".)

Related: BUG #19559 reports the same "unexpected object depending on column"
elog from the same dependency scan for a property graph; this report is the
partition-key-expression case, which falls in the RelationRelationId branch.








view thread (5+ messages)  latest in thread

Message-ID: <19903-06341b8535c78fc1@postgresql.org>
Permalink:  ../19903-06341b8535c78fc1@postgresql.org/
Also on:    postgresql.org/message-id/19903-06341b8535c78fc1@postgresql.org

 · 

reply

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: noreply@postgresql.org, hackerzheng666@gmail.com
  Subject: Re: BUG #19903: ALTER COLUMN TYPE: "unexpected object depending on column" internal error via partition key
  In-Reply-To: <19903-06341b8535c78fc1@postgresql.org>
  References: <19903-06341b8535c78fc1@postgresql.org>

* 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