Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

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

Open
#2,048 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
65/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
c, postgresql
Domain
databases

Research direction

The bug is in the Postgres planner code, likely in preptlist.c line 140. Start by examining the function that checks for inheritance children before splitting an UPDATE on a distribution key. Look at how relhassubclass is used versus find_inheritance_children() or pg_inherits. The fix should replace the hint check with a direct lookup of actual children. Run the provided reproduction script to verify the error and that ANALYZE clears it. Test with optimizer=off to ensure the fix works for the Postgres planner.

Written by the indexing model from the issue text.

Description

type: Bug
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
Dominant language
C
Stars
1.4k
Forks
248
Avg merge
4d 10h
Merged PRs (30d)
40

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/cloudberry

All issues in apache/cloudberry

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.