]> granicus.if.org Git - postgresql/commitdiff
Use ereport not elog for some corrupt-HOT-chain reports.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 1 Mar 2018 21:23:29 +0000 (16:23 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 1 Mar 2018 21:23:45 +0000 (16:23 -0500)
These errors have been seen in the field in corrupted-data situations.
It seems worthwhile to report them with ERRCODE_DATA_CORRUPTED, rather
than the generic ERRCODE_INTERNAL_ERROR, for the benefit of log monitoring
and tools like amcheck.  However, use errmsg_internal so that the text
strings still aren't translated; it seems unlikely to be worth
translators' time to do so.

Back-patch to 9.3, like the predecessor commit d70cf811f that introduced
these elog calls originally (replacing Asserts).

Peter Geoghegan

Discussion: https://postgr.es/m/CAH2-Wzmn4-Pg-UGFwyuyK-wiTih9j32pwg_7T9iwqXpAUZr=Mg@mail.gmail.com

src/backend/catalog/index.c

index 564f2069cf48501b923d41ec082e0cdd28676052..431bc3196999371252fcdcbf3f9848461e71bb8a 100644 (file)
@@ -2862,9 +2862,12 @@ IndexBuildHeapRangeScan(Relation heapRelation,
                        offnum = ItemPointerGetOffsetNumber(&heapTuple->t_self);
 
                        if (!OffsetNumberIsValid(root_offsets[offnum - 1]))
-                               elog(ERROR, "failed to find parent tuple for heap-only tuple at (%u,%u) in table \"%s\"",
-                                        ItemPointerGetBlockNumber(&heapTuple->t_self),
-                                        offnum, RelationGetRelationName(heapRelation));
+                               ereport(ERROR,
+                                               (errcode(ERRCODE_DATA_CORRUPTED),
+                                                errmsg_internal("failed to find parent tuple for heap-only tuple at (%u,%u) in table \"%s\"",
+                                                                                ItemPointerGetBlockNumber(&heapTuple->t_self),
+                                                                                offnum,
+                                                                                RelationGetRelationName(heapRelation))));
 
                        ItemPointerSetOffsetNumber(&rootTuple.t_self,
                                                                           root_offsets[offnum - 1]);
@@ -3327,10 +3330,12 @@ validate_index_heapscan(Relation heapRelation,
                {
                        root_offnum = root_offsets[root_offnum - 1];
                        if (!OffsetNumberIsValid(root_offnum))
-                               elog(ERROR, "failed to find parent tuple for heap-only tuple at (%u,%u) in table \"%s\"",
-                                        ItemPointerGetBlockNumber(heapcursor),
-                                        ItemPointerGetOffsetNumber(heapcursor),
-                                        RelationGetRelationName(heapRelation));
+                               ereport(ERROR,
+                                               (errcode(ERRCODE_DATA_CORRUPTED),
+                                                errmsg_internal("failed to find parent tuple for heap-only tuple at (%u,%u) in table \"%s\"",
+                                                                                ItemPointerGetBlockNumber(heapcursor),
+                                                                                ItemPointerGetOffsetNumber(heapcursor),
+                                                                                RelationGetRelationName(heapRelation))));
                        ItemPointerSetOffsetNumber(&rootTuple, root_offnum);
                }