Skip to content

Commit 6a8d659

Browse files
committed
Fixed unique_key_recheck for postgres relations
1 parent 3cda080 commit 6a8d659

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/backend/commands/constraint.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ unique_key_recheck(PG_FUNCTION_ARGS)
4444
const char *funcname = "unique_key_recheck";
4545
Datum checktidDatum;
4646
Datum tmptidDatum;
47+
ItemPointerData tmptid;
4748
Relation indexRel;
4849
IndexInfo *indexInfo;
4950
EState *estate;
@@ -128,7 +129,16 @@ unique_key_recheck(PG_FUNCTION_ARGS)
128129
* it's possible the index entry has also been marked dead, and even
129130
* removed.
130131
*/
131-
tmptidDatum = checktidDatum;
132+
if (table_get_row_ref_type(trigdata->tg_relation) == ROW_REF_ROWID)
133+
{
134+
/* FIX: Probably wrong assumption */
135+
tmptidDatum = checktidDatum;
136+
}
137+
else
138+
{
139+
tmptid = *DatumGetItemPointer(checktidDatum);
140+
tmptidDatum = ItemPointerGetDatum(&tmptid);
141+
}
132142
{
133143
IndexFetchTableData *scan;
134144
bool call_again = false;

0 commit comments

Comments
 (0)