model-writtenrun 7009 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Fei Changhong reported that concurrently detaching a hash partition and dropping its former parent makes subsequent inserts fail because a generated CHECK constraint still references the parent's OID in #1.
- Fei corrected his initial claim that the hash constraint was ineffective and supplied the only attached patch in #2, which recorded the generated constraint's identity, dropped it during detach, and tested insertion after dropping the parent.
- Michael Paquier criticized the constraint-name lookup and create-then-drop approach in #3, proposing that the constraint never be created; Fei verified that the original partition constraint remains effective through the second transaction and endorsed skipping hash constraints in #5.
- Álvaro Herrera revisited the issue in #7, found that removing constraint creation caused only expected-output failures, and questioned the original assumption that saved query plans required substitute constraints for any partitioning strategy.
- Fei explained why the transaction waits and locking protect existing queries in #8, identifying faster reattachment as the remaining benefit of substitute constraints; Tender Wang raised a partition-pruning consistency concern in #9, then resolved it through code inspection and endorsed removing all substitute constraints in #10.
- The eventual development-branch fix, credited to Haiyang Li, removed substitute-constraint creation entirely in 3231fd0455, implementing the broader removal discussed here rather than the attached create-then-drop patch.
- The stable-branch implementation in b753be38a4 came from the later patchset #693798 in thread #73330, with light comment and test edits; it skipped constraint creation only for hash partitions to preserve potentially relied-upon behavior for other strategies, correcting the previous attribution to this thread's discussion.
- Álvaro announced that the fix had been pushed following another bug report in #11; the commit messages specify backpatching through PostgreSQL 14, and the thread ended with the issue fixed and no revised attachment awaiting review.