Skip to content

Commit 532b5b5

Browse files
committed
Fixed unique_key_recheck for postgres relations
1 parent 1b7e7ca commit 532b5b5

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
@@ -42,6 +42,7 @@ unique_key_recheck(PG_FUNCTION_ARGS)
4242
const char *funcname = "unique_key_recheck";
4343
Datum checktidDatum;
4444
Datum tmptidDatum;
45+
ItemPointerData tmptid;
4546
Relation indexRel;
4647
IndexInfo *indexInfo;
4748
EState *estate;
@@ -126,7 +127,16 @@ unique_key_recheck(PG_FUNCTION_ARGS)
126127
* it's possible the index entry has also been marked dead, and even
127128
* removed.
128129
*/
129-
tmptidDatum = checktidDatum;
130+
if (table_get_row_ref_type(trigdata->tg_relation) == ROW_REF_ROWID)
131+
{
132+
/* FIX: Probably wrong assumption */
133+
tmptidDatum = checktidDatum;
134+
}
135+
else
136+
{
137+
tmptid = *DatumGetItemPointer(checktidDatum);
138+
tmptidDatum = ItemPointerGetDatum(&tmptid);
139+
}
130140
{
131141
IndexFetchTableData *scan;
132142
bool call_again = false;

0 commit comments

Comments
 (0)