postgresql/src/backend/catalog
Tom Lane c75c830e23 Fix broken handling of domains in atthasmissing logic.
If a domain type has a default, adding a column of that type (without
any explicit DEFAULT clause) failed to install the domain's default
value in existing rows, instead leaving the new column null.  This
is unexpected, and it used to work correctly before v11.  The cause
is confusion in the atthasmissing mechanism about which default value
to install: we'd only consider installing an explicitly-specified
default, and then we'd decide that no table rewrite is needed.

To fix, take the responsibility for filling attmissingval out of
StoreAttrDefault, and instead put it into ATExecAddColumn's existing
logic that derives the correct value to fill the new column with.
Also, centralize the logic that determines the need for
default-related table rewriting there, instead of spreading it over
four or five places.

In the back branches, we'll leave the attmissingval-filling code
in StoreAttrDefault even though it's now dead, for fear that some
extension may be depending on that functionality to exist there.
A separate HEAD-only patch will clean up the now-useless code.

Reported-by: jian he <jian.universality@gmail.com>
Author: jian he <jian.universality@gmail.com>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CACJufxHFssPvkP1we7WMhPD_1kwgbG52o=kQgL+TnVoX5LOyCQ@mail.gmail.com
Backpatch-through: 13
2025-03-03 12:43:29 -05:00
..
.gitignore Build in some knowledge about foreign-key relationships in the catalogs. 2021-02-02 17:11:55 -05:00
aclchk.c For inplace update durability, make heap_update() callers wait. 2024-09-24 15:25:23 -07:00
catalog.c For inplace update durability, make heap_update() callers wait. 2024-09-24 15:25:23 -07:00
Catalog.pm Initial pgindent and pgperltidy run for v14. 2021-05-12 13:14:10 -04:00
dependency.c Clean out column-level pg_init_privs entries when dropping tables. 2024-06-14 16:20:35 -04:00
fix-CVE-2024-4317.sql Fix privilege checks in pg_stats_ext and pg_stats_ext_exprs. 2024-05-06 09:00:19 -05:00
genbki.pl Pre branch pgindent / pgperltidy run 2021-06-28 11:05:54 -04:00
heap.c Fix broken handling of domains in atthasmissing logic. 2025-03-03 12:43:29 -05:00
index.c Suppress new "may be used uninitialized" warning. 2024-11-02 19:42:57 -07:00
indexing.c Fix comment in indexing.c 2021-03-17 18:07:00 +09:00
information_schema.sql Add DISTINCT to information schema usage views 2021-04-21 11:54:47 +02:00
Makefile Fix privilege checks in pg_stats_ext and pg_stats_ext_exprs. 2024-05-06 09:00:19 -05:00
namespace.c Recalculate search_path after ALTER ROLE. 2023-08-07 15:12:33 -07:00
objectaccess.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
objectaddress.c In REASSIGN OWNED of a database, lock the tuple as mandated. 2024-12-28 07:16:27 -08:00
partition.c ALTER TABLE ... DETACH PARTITION ... CONCURRENTLY 2021-03-25 18:00:28 -03:00
pg_aggregate.c Reconsider the handling of procedure OUT parameters. 2021-06-10 17:11:36 -04:00
pg_cast.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
pg_collation.c In extensions, don't replace objects not belonging to the extension. 2022-08-08 11:12:31 -04:00
pg_constraint.c Fix self-referencing foreign keys with partitioned tables 2022-10-07 19:37:48 +02:00
pg_conversion.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
pg_db_role_setting.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
pg_depend.c In extensions, don't replace objects not belonging to the extension. 2022-08-08 11:12:31 -04:00
pg_enum.c Rename "enum blacklist" to "uncommitted enums". 2021-01-05 12:38:48 +13:00
pg_inherits.c Message style improvements 2021-06-28 08:36:44 +02:00
pg_largeobject.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
pg_namespace.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
pg_operator.c In extensions, don't replace objects not belonging to the extension. 2022-08-08 11:12:31 -04:00
pg_proc.c Fix confusion about the return rowtype of SQL-language procedures. 2024-03-12 18:16:10 -04:00
pg_publication.c Fix double publish of child table's data. 2021-12-09 08:49:50 +05:30
pg_range.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
pg_shdepend.c Avoid leaking memory during large-scale REASSIGN OWNED BY operations. 2021-12-01 13:44:47 -05:00
pg_subscription.c Initial pgindent and pgperltidy run for v14. 2021-05-12 13:14:10 -04:00
pg_type.c In extensions, don't replace objects not belonging to the extension. 2022-08-08 11:12:31 -04:00
sql_feature_packages.txt Cleanup in SQL features files 2020-03-28 08:46:18 +01:00
sql_features.txt Fix use of cursor sensitivity terminology 2021-04-07 08:05:55 +02:00
storage.c Avoid integer overflow while testing wal_skip_threshold condition. 2025-01-30 15:36:07 -05:00
system_functions.sql Remove pg_wait_for_backend_termination(). 2021-06-14 17:29:37 -07:00
system_views.sql Fix privilege checks in pg_stats_ext and pg_stats_ext_exprs. 2024-05-06 09:00:19 -05:00
toasting.c Fix data loss at inplace update after heap_update(). 2024-09-24 15:25:23 -07:00