-
由 Heikki Linnakangas 提交于
This is mostly in preparation for changes soon to be merged from PostgreSQL 8.4, commit a77eaa6a to be more precise. Currently GPDB's ExecInsert uses ExecSlotFetch*() functions to get the tuple from the slot, while in the upstream, it makes a modifiable copy with ExecMaterializeSlot(). That's OK as the code stands, because there's always a "junk filter" that ensures that the slot doesn't point directly to an on-disk tuple. But commit a77eaa6a will change that, so we have to start being more careful. This does fix an existing bug, namely that if you UPDATE an AO table with OIDs, the OIDs currently change (github issue #3732). Add a test case for that. More detailed breakdown of the changes: * In ExecInsert, create a writeable copy of the tuple when we're about to modify it, so that we don't accidentally modify an existing on-disk tuple. By calling ExecMaterializeSlot(). * In ExecInsert, track the OID of the tuple we're about to insert in a local variable, when we call the BEFORE ROW triggers, because we don't have a "tuple" yet. * Add ExecMaterializeSlot() function, like in the upstream, because we now need it in ExecInsert. Refactor ExecFetchSlotHeapTuple to use ExecMaterializeSlot(), like in upstream. * Cherry-pick bug fix commit 3d02cae3 from upstream. We would get that soon anyway as part of the merge, but we'll soon have test failures if we don't fix it immediately. * Change the API of appendonly_insert(), so that it takes the new OID as argument, instead of extracting it from the passed-in MemTuple. With this change, appendonly_insert() is guaranteed to not modify the passed-in MemTuple, so we don't need the equivalent of ExecMaterializeSlot() for MemTuples. * Also change the API of appendonly_insert() so that it returns the new OID of the inserted tuple, like heap_insert() does. Most callers ignore the return value, so this way they don't need to pass a dummy pointer argument. * Add test case for the case that a BEFORE ROW trigger sets the OID of a tuple we're about to insert. This is based on earlier patches against the 8.4 merge iteration3 branch by Jacob and Max.
d0fbecf6