aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/execUtils.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2010-01-02 17:53:57 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2010-01-02 17:53:57 +0000
commit2b59274c0925ca980748edf57723f3c3e026f619 (patch)
tree28936ebb570052fcf84879aff813bbeedf36af84 /src/backend/executor/execUtils.c
parent0239800893ef4901e3c085e06534934a485d3bf0 (diff)
downloadpostgresql-2b59274c0925ca980748edf57723f3c3e026f619.tar.gz
postgresql-2b59274c0925ca980748edf57723f3c3e026f619.zip
check_exclusion_constraint didn't actually work correctly for index
expressions: FormIndexDatum requires the estate's scantuple to already point at the tuple the values are supposedly being extracted from. Adjust test case so that this type of confusion will be exposed. Per report from hubert depesz lubaczewski.
Diffstat (limited to 'src/backend/executor/execUtils.c')
-rw-r--r--src/backend/executor/execUtils.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/backend/executor/execUtils.c b/src/backend/executor/execUtils.c
index c6ae2d4296f..5d6473dfc69 100644
--- a/src/backend/executor/execUtils.c
+++ b/src/backend/executor/execUtils.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/executor/execUtils.c,v 1.168 2010/01/02 16:57:41 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/executor/execUtils.c,v 1.169 2010/01/02 17:53:56 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1167,7 +1167,9 @@ check_exclusion_constraint(Relation heap, Relation index, IndexInfo *indexInfo,
int i;
bool conflict;
bool found_self;
+ ExprContext *econtext;
TupleTableSlot *existing_slot;
+ TupleTableSlot *save_scantuple;
/*
* If any of the input values are NULL, the constraint check is assumed
@@ -1194,9 +1196,19 @@ check_exclusion_constraint(Relation heap, Relation index, IndexInfo *indexInfo,
values[i]);
}
- /* Need a TupleTableSlot to put existing tuples in */
+ /*
+ * Need a TupleTableSlot to put existing tuples in.
+ *
+ * To use FormIndexDatum, we have to make the econtext's scantuple point
+ * to this slot. Be sure to save and restore caller's value for
+ * scantuple.
+ */
existing_slot = MakeSingleTupleTableSlot(RelationGetDescr(heap));
+ econtext = GetPerTupleExprContext(estate);
+ save_scantuple = econtext->ecxt_scantuple;
+ econtext->ecxt_scantuple = existing_slot;
+
/*
* May have to restart scan from this point if a potential
* conflict is found.
@@ -1311,6 +1323,8 @@ retry:
RelationGetRelationName(index)),
errhint("This may be because of a non-immutable index expression.")));
+ econtext->ecxt_scantuple = save_scantuple;
+
ExecDropSingleTupleTableSlot(existing_slot);
return !conflict;