Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3d02cae

Browse files
committed
Ensure that INSERT ... SELECT into a table with OIDs never copies row OIDs
from the source table. This could never happen anyway before 8.4 becausethe executor invariably applied a "junk filter" to rows due to be inserted;but now that we skip doing that when it's not necessary, the case can occur.Problem noted 2008-11-27 by KaiGai Kohei, though I misunderstood what hewas on about at the time (the opacity of the patch he proposed didn't help).
1 parent053835d commit3d02cae

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

‎src/backend/executor/execMain.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*
2727
*
2828
* IDENTIFICATION
29-
* $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.322 2009/02/02 19:31:39 alvherre Exp $
29+
* $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.323 2009/02/08 18:02:27 tgl Exp $
3030
*
3131
*-------------------------------------------------------------------------
3232
*/
@@ -1766,6 +1766,21 @@ ExecInsert(TupleTableSlot *slot,
17661766
resultRelInfo=estate->es_result_relation_info;
17671767
resultRelationDesc=resultRelInfo->ri_RelationDesc;
17681768

1769+
/*
1770+
* If the result relation has OIDs, force the tuple's OID to zero so that
1771+
* heap_insert will assign a fresh OID. Usually the OID already will be
1772+
* zero at this point, but there are corner cases where the plan tree can
1773+
* return a tuple extracted literally from some table with the same
1774+
* rowtype.
1775+
*
1776+
* XXX if we ever wanted to allow users to assign their own OIDs to new
1777+
* rows, this'd be the place to do it. For the moment, we make a point
1778+
* of doing this before calling triggers, so that a user-supplied trigger
1779+
* could hack the OID if desired.
1780+
*/
1781+
if (resultRelationDesc->rd_rel->relhasoids)
1782+
HeapTupleSetOid(tuple,InvalidOid);
1783+
17691784
/* BEFORE ROW INSERT Triggers */
17701785
if (resultRelInfo->ri_TrigDesc&&
17711786
resultRelInfo->ri_TrigDesc->n_before_row[TRIGGER_EVENT_INSERT]>0)
@@ -3033,6 +3048,12 @@ intorel_receive(TupleTableSlot *slot, DestReceiver *self)
30333048
*/
30343049
tuple=ExecMaterializeSlot(slot);
30353050

3051+
/*
3052+
* force assignment of new OID (see comments in ExecInsert)
3053+
*/
3054+
if (myState->rel->rd_rel->relhasoids)
3055+
HeapTupleSetOid(tuple,InvalidOid);
3056+
30363057
heap_insert(myState->rel,
30373058
tuple,
30383059
myState->estate->es_output_cid,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp