mirror of
https://github.com/postgres/postgres.git
synced 2025-07-03 20:02:46 +03:00
Fix table rewrites that include a column without a default.
Inc2fe139c20
I made ATRewriteTable() use tuple slots. Unfortunately I did not notice that columns can be added in a rewrite that do not have a default, when another column is added/altered requiring one. Initialize columns to NULL again, and add tests. Bug: #16038 Reported-By: anonymous Author: Andres Freund Discussion: https://postgr.es/m/16038-5c974541f2bf6749@postgresql.org Backpatch: 12, where the bug was introduced inc2fe139c20
This commit is contained in:
@ -4890,6 +4890,16 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
|
||||
table_slot_callbacks(oldrel));
|
||||
newslot = MakeSingleTupleTableSlot(newTupDesc,
|
||||
table_slot_callbacks(newrel));
|
||||
|
||||
/*
|
||||
* Set all columns in the new slot to NULL initially, to ensure
|
||||
* columns added as part of the rewrite are initialized to
|
||||
* NULL. That is necessary as tab->newvals will not contain an
|
||||
* expression for columns with a NULL default, e.g. when adding a
|
||||
* column without a default together with a column with a default
|
||||
* requiring an actual rewrite.
|
||||
*/
|
||||
ExecStoreAllNullTuple(newslot);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user