diff options
author | Andrew Dunstan <andrew@dunslane.net> | 2019-01-11 17:12:54 -0500 |
---|---|---|
committer | Andrew Dunstan <andrew@dunslane.net> | 2019-01-11 17:12:54 -0500 |
commit | e33884d4122b56fc0dbff3d8cedd8177334db838 (patch) | |
tree | d0326360b973d38f4273da9d22722c88b8904a35 /src/backend/commands/tablecmds.c | |
parent | 1db5667bac63d0be825c375c4aeb8fb29b9a50bd (diff) | |
download | postgresql-e33884d4122b56fc0dbff3d8cedd8177334db838.tar.gz postgresql-e33884d4122b56fc0dbff3d8cedd8177334db838.zip |
Free pre-modification HeapTuple in ALTER TABLE ... TYPE ...
This was an oversight in commit 3b174b1a3.
Per offline gripe from Alvaro Herrera
Backpatch to release 11.
Diffstat (limited to 'src/backend/commands/tablecmds.c')
-rw-r--r-- | src/backend/commands/tablecmds.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index e7017e90d10..d2781cbf194 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -9648,6 +9648,7 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel, Datum valuesAtt[Natts_pg_attribute]; bool nullsAtt[Natts_pg_attribute]; bool replacesAtt[Natts_pg_attribute]; + HeapTuple newTup; MemSet(valuesAtt, 0, sizeof(valuesAtt)); MemSet(nullsAtt, false, sizeof(nullsAtt)); @@ -9673,8 +9674,10 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel, replacesAtt[Anum_pg_attribute_attmissingval - 1] = true; nullsAtt[Anum_pg_attribute_attmissingval - 1] = false; - heapTup = heap_modify_tuple(heapTup, RelationGetDescr(attrelation), - valuesAtt, nullsAtt, replacesAtt); + newTup = heap_modify_tuple(heapTup, RelationGetDescr(attrelation), + valuesAtt, nullsAtt, replacesAtt); + heap_freetuple(heapTup); + heapTup = newTup; attTup = (Form_pg_attribute) GETSTRUCT(heapTup); } } |