| From: | PG Bug reporting form <noreply(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
| Cc: | hackerzheng666(at)gmail(dot)com |
| Subject: | BUG #19903: ALTER COLUMN TYPE: "unexpected object depending on column" internal error via partition key |
| Date: | 2026-11-15 04:47:59 |
| Message-ID: | 19903-06341b8535c78fc1@postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
The following bug has been logged on the website:
Bug reference: 19903
Logged by: Zheng Hacker
Email address: hackerzheng666(at)gmail(dot)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.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | PG Bug reporting form | 2026-11-15 04:48:38 | BUG #19904: pg_column_is_updatable(): "negative bitmapset member not allowed" for large attnum (int16 overflow) |
| Previous Message | shihao zhong | 2026-11-15 03:59:05 | Re: BUG #19703: information_schema.usage_privileges omits a sequence owner's implicit USAGE privilege |