aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/copy.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2009-07-29 20:56:21 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2009-07-29 20:56:21 +0000
commit25d9bf2e3e66ee2e546c5c523d148ecab6ee1dcc (patch)
treeb0dee0f1d6111fd6658d432ec30e5ddb88adc02f /src/backend/commands/copy.c
parent850490579318ff52097eec92ce535357dd0c7a3a (diff)
downloadpostgresql-25d9bf2e3e66ee2e546c5c523d148ecab6ee1dcc.tar.gz
postgresql-25d9bf2e3e66ee2e546c5c523d148ecab6ee1dcc.zip
Support deferrable uniqueness constraints.
The current implementation fires an AFTER ROW trigger for each tuple that looks like it might be non-unique according to the index contents at the time of insertion. This works well as long as there aren't many conflicts, but won't scale to massive unique-key reassignments. Improving that case is a TODO item. Dean Rasheed
Diffstat (limited to 'src/backend/commands/copy.c')
-rw-r--r--src/backend/commands/copy.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index b41da6385db..21f7b94d546 100644
--- a/src/backend/commands/copy.c
+++ b/src/backend/commands/copy.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.315 2009/07/25 17:04:19 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.316 2009/07/29 20:56:18 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -2130,6 +2130,8 @@ CopyFrom(CopyState cstate)
if (!skip_tuple)
{
+ List *recheckIndexes = NIL;
+
/* Place tuple in tuple slot */
ExecStoreTuple(tuple, slot, InvalidBuffer, false);
@@ -2141,10 +2143,12 @@ CopyFrom(CopyState cstate)
heap_insert(cstate->rel, tuple, mycid, hi_options, bistate);
if (resultRelInfo->ri_NumIndices > 0)
- ExecInsertIndexTuples(slot, &(tuple->t_self), estate, false);
+ recheckIndexes = ExecInsertIndexTuples(slot, &(tuple->t_self),
+ estate, false);
/* AFTER ROW INSERT Triggers */
- ExecARInsertTriggers(estate, resultRelInfo, tuple);
+ ExecARInsertTriggers(estate, resultRelInfo, tuple,
+ recheckIndexes);
/*
* We count only tuples not suppressed by a BEFORE INSERT trigger;