Report tuple address in data-corruption error message
authorAlvaro Herrera <[email protected]>
Mon, 30 Aug 2021 20:29:12 +0000 (16:29 -0400)
committerAlvaro Herrera <[email protected]>
Mon, 30 Aug 2021 20:29:12 +0000 (16:29 -0400)
Most data-corruption reports mention the location of the problem, but
this one failed to.  Add it.

Backpatch all the way back.  In 12 and older, also assign the
ERRCODE_DATA_CORRUPTED error code as was done in commit fd6ec93bf890 for
13 and later.

Discussion: https://postgr.es/m/202108191637[email protected]

src/backend/executor/execMain.c

index 9ce8c87d99505e0fb6d22fda53bd3d8425a6f394..795d58a1067a742069c8b3da4e160530630f6b22 100644 (file)
@@ -2621,7 +2621,13 @@ EvalPlanQualFetch(EState *estate, Relation relation, int lockmode,
 
            /* otherwise xmin should not be dirty... */
            if (TransactionIdIsValid(SnapshotDirty.xmin))
-               elog(ERROR, "t_xmin is uncommitted in tuple to be updated");
+               ereport(ERROR,
+                       (errcode(ERRCODE_DATA_CORRUPTED),
+                        errmsg_internal("t_xmin %u is uncommitted in tuple (%u,%u) to be updated in table \"%s\"",
+                                        SnapshotDirty.xmin,
+                                        ItemPointerGetBlockNumber(&tuple.t_self),
+                                        ItemPointerGetOffsetNumber(&tuple.t_self),
+                                        RelationGetRelationName(relation))));
 
            /*
             * If tuple is being updated by other transaction then we have to