Re: bug when apply fast default mechanism for adding new column over domain with default value
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: jian he <jian.universality@gmail.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2025-03-02T22:08:39Z
Lists: pgsql-hackers
Attachments
- v3-0001-Fix-broken-handling-of-domains-in-atthasmissing-l.patch (text/x-diff) patch v3-0001
- v3-0002-Remove-now-dead-code-in-StoreAttrDefault.patch (text/x-diff) patch v3-0002
jian he <jian.universality@gmail.com> writes: > On Sun, Mar 2, 2025 at 7:54 AM Tom Lane <tgl@sss.pgh.pa.us> wrote: >> I think the fundamental problem here is that StoreAttrDefault >> shouldn't be involved in this in the first place. > i've split missingval related code into StoreAttrMissingVal. Hm, this does nothing to improve the modularity of the affected code; if anything it's worse than before. (Fools around for awhile...) I had something more like the attached in mind. The idea here is to centralize the control of whether we are storing a missingval or doing a table rewrite in ATExecAddColumn. StoreAttrMissingVal has nothing to do with pg_attrdef nor does StoreAttrDefault have anything to do with attmissingval. I looked briefly at determining the presence of a default earlier so we could avoid the extra update of pg_attribute when both those changes need to happen, but I concluded that it'd take more refactoring than it's worth. The problem is the logic way down inside AddRelationNewConstraints that checks for the eventually-cooked default expression just being a null constant. regards, tom lane
Commits
-
Need to do CommandCounterIncrement after StoreAttrMissingVal.
- dd34cbfce296 13.21 landed
- d31d39cfe4f5 14.18 landed
- bd178960c69b 18.0 landed
- 2d6cfb0cddd3 15.13 landed
- 0941aadcd55b 17.5 landed
- 053222a97b13 16.9 landed
-
Simplify some logic around setting pg_attribute.atthasdef.
- 35c8dd9e1176 18.0 landed
-
Remove now-dead code in StoreAttrDefault().
- 4528768d98f8 18.0 landed
-
Fix broken handling of domains in atthasmissing logic.
- 95f650674d2c 18.0 landed
- edc3bccd0dc7 16.9 landed
- d6dd2a02bae0 17.5 landed
- c75c830e2392 14.18 landed
- aac07b56256e 13.21 landed
- 1d180931cc3b 15.13 landed