Visitar URL original
[Bug] UPDATE of the distribution key fails with "can't split update for inherit table" after the child table is dropped · Issue #2048 · apache/cloudberry · GitHub
Skip to content

[Bug] UPDATE of the distribution key fails with "can't split update for inherit table" after the child table is dropped #2048

Description

@Alena0704

Apache Cloudberry version

main; REL_2_STABLE

What happened

UPDATE of a distribution-key column is rejected for a table that has inheritance children:

ERROR:  can't split update for inherit table: pinh (preptlist.c:140)

The error persists after all child tables are dropped. The check relies on pg_class.relhassubclass, which PostgreSQL does not clear when the last child is dropped; only ANALYZE or VACUUM clears it lazily. As a result, a plain table with no children refuses to update its distribution key until somebody runs ANALYZE on it.

On REL_2_STABLE, this happens with the Postgres planner (optimizer = off). With GPORCA, the same UPDATE after DROP TABLE cinh succeeds.

What you think should happen instead

Once the table has no inheritance children, updating its distribution key should work as it does for any other table. The check should look at the actual children (for example find_inheritance_children() / pg_inherits), not at relhassubclass, which is only a hint.

How to reproduce

create table pinh(a int, b int) distributed by (b);
create table cinh() inherits (pinh);
insert into pinh values (1,1);

update pinh set a = a + 1;   -- OK, not a distribution key
update pinh set b = b + 1;   -- ERROR: can't split update for inherit table: pinh

drop table cinh;
select count(*) from pg_inherits where inhparent = 'pinh'::regclass;   -- 0, no children
select relhassubclass from pg_class where oid = 'pinh'::regclass;      -- t, stale flag

update pinh set b = b + 1;   -- still ERROR: can't split update for inherit table: pinh

analyze pinh;
select relhassubclass from pg_class where oid = 'pinh'::regclass;      -- f
update pinh set b = b + 1;   -- UPDATE 1

Operating System

any

Anything else

No response

Are you willing to submit PR?

  • Yes, I am willing to submit a PR!

Code of Conduct

Activity

  1. aryan9948 commented on Sep 27, 2026

    @aryan9948

    Hi @Alena0704, I'd like to work on this issue. Could you please assign it to me?

    My initial approach would be to locate the can't split update for inherit table check and inspect how relhassubclass is currently being used. Since relhassubclass can remain stale after the last child is dropped, I would investigate using the actual inheritance information, such as find_inheritance_children() / pg_inherits, and add a regression test covering the child-table drop case.

    Thanks!

  2. Alena0704 commented on Sep 27, 2026

    @Alena0704
    CollaboratorAuthor

    Hi @Alena0704, I'd like to work on this issue. Could you please assign it to me?

    My initial approach would be to locate the can't split update for inherit table check and inspect how relhassubclass is currently being used. Since relhassubclass can remain stale after the last child is dropped, I would investigate using the actual inheritance information, such as find_inheritance_children() / pg_inherits, and add a regression test covering the child-table drop case.

    Thanks!

    okay

  3. aryan9948 commented on Sep 27, 2026

    @aryan9948

    @Alena0704, Could you please assign it to me?

  4. tuhaihe commented on Sep 28, 2026

    @tuhaihe
    Member

    @Alena0704, Could you please assign it to me?

    Done. PTAL. Thanks for your interest!

  5. Alena0704 commented on Sep 28, 2026

    @Alena0704
    CollaboratorAuthor

    @Alena0704, Could you please assign it to me?

    Sorry, I didn't know that it is possible to assign issue on somebody. I thought it was only checkbox. But now I see everything is fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

type: BugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions