Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4573f6a

Browse files
committed
amcheck: Remove duplicate XID/MXID bounds checks.
Commit3b6c125 resulted in the samexmin and xmax bounds checking being performed in both check_tuple()and check_tuple_visibility(). Remove the duplication.While at it, adjust some code comments that were overlooked in thatcommit.Mark DilgerDiscussion:http://postgr.es/m/AC5479E4-6321-473D-AC92-5EC36299FBC2@enterprisedb.com
1 parent3c3b8a4 commit4573f6a

File tree

1 file changed

+6
-124
lines changed

1 file changed

+6
-124
lines changed

‎contrib/amcheck/verify_heapam.c

Lines changed: 6 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,136 +1390,18 @@ check_tuple_attribute(HeapCheckContext *ctx)
13901390
staticvoid
13911391
check_tuple(HeapCheckContext*ctx)
13921392
{
1393-
TransactionIdxmin;
1394-
TransactionIdxmax;
1395-
boolfatal= false;
1396-
uint16infomask=ctx->tuphdr->t_infomask;
1397-
1398-
/* If xmin is normal, it should be within valid range */
1399-
xmin=HeapTupleHeaderGetXmin(ctx->tuphdr);
1400-
switch (get_xid_status(xmin,ctx,NULL))
1401-
{
1402-
caseXID_INVALID:
1403-
caseXID_BOUNDS_OK:
1404-
break;
1405-
caseXID_IN_FUTURE:
1406-
report_corruption(ctx,
1407-
psprintf("xmin %u equals or exceeds next valid transaction ID %u:%u",
1408-
xmin,
1409-
EpochFromFullTransactionId(ctx->next_fxid),
1410-
XidFromFullTransactionId(ctx->next_fxid)));
1411-
fatal= true;
1412-
break;
1413-
caseXID_PRECEDES_CLUSTERMIN:
1414-
report_corruption(ctx,
1415-
psprintf("xmin %u precedes oldest valid transaction ID %u:%u",
1416-
xmin,
1417-
EpochFromFullTransactionId(ctx->oldest_fxid),
1418-
XidFromFullTransactionId(ctx->oldest_fxid)));
1419-
fatal= true;
1420-
break;
1421-
caseXID_PRECEDES_RELMIN:
1422-
report_corruption(ctx,
1423-
psprintf("xmin %u precedes relation freeze threshold %u:%u",
1424-
xmin,
1425-
EpochFromFullTransactionId(ctx->relfrozenfxid),
1426-
XidFromFullTransactionId(ctx->relfrozenfxid)));
1427-
fatal= true;
1428-
break;
1429-
}
1430-
1431-
xmax=HeapTupleHeaderGetRawXmax(ctx->tuphdr);
1432-
1433-
if (infomask&HEAP_XMAX_IS_MULTI)
1434-
{
1435-
/* xmax is a multixact, so it should be within valid MXID range */
1436-
switch (check_mxid_valid_in_rel(xmax,ctx))
1437-
{
1438-
caseXID_INVALID:
1439-
report_corruption(ctx,
1440-
pstrdup("multitransaction ID is invalid"));
1441-
fatal= true;
1442-
break;
1443-
caseXID_PRECEDES_RELMIN:
1444-
report_corruption(ctx,
1445-
psprintf("multitransaction ID %u precedes relation minimum multitransaction ID threshold %u",
1446-
xmax,ctx->relminmxid));
1447-
fatal= true;
1448-
break;
1449-
caseXID_PRECEDES_CLUSTERMIN:
1450-
report_corruption(ctx,
1451-
psprintf("multitransaction ID %u precedes oldest valid multitransaction ID threshold %u",
1452-
xmax,ctx->oldest_mxact));
1453-
fatal= true;
1454-
break;
1455-
caseXID_IN_FUTURE:
1456-
report_corruption(ctx,
1457-
psprintf("multitransaction ID %u equals or exceeds next valid multitransaction ID %u",
1458-
xmax,
1459-
ctx->next_mxact));
1460-
fatal= true;
1461-
break;
1462-
caseXID_BOUNDS_OK:
1463-
break;
1464-
}
1465-
}
1466-
else
1467-
{
1468-
/*
1469-
* xmax is not a multixact and is normal, so it should be within the
1470-
* valid XID range.
1471-
*/
1472-
switch (get_xid_status(xmax,ctx,NULL))
1473-
{
1474-
caseXID_INVALID:
1475-
caseXID_BOUNDS_OK:
1476-
break;
1477-
caseXID_IN_FUTURE:
1478-
report_corruption(ctx,
1479-
psprintf("xmax %u equals or exceeds next valid transaction ID %u:%u",
1480-
xmax,
1481-
EpochFromFullTransactionId(ctx->next_fxid),
1482-
XidFromFullTransactionId(ctx->next_fxid)));
1483-
fatal= true;
1484-
break;
1485-
caseXID_PRECEDES_CLUSTERMIN:
1486-
report_corruption(ctx,
1487-
psprintf("xmax %u precedes oldest valid transaction ID %u:%u",
1488-
xmax,
1489-
EpochFromFullTransactionId(ctx->oldest_fxid),
1490-
XidFromFullTransactionId(ctx->oldest_fxid)));
1491-
fatal= true;
1492-
break;
1493-
caseXID_PRECEDES_RELMIN:
1494-
report_corruption(ctx,
1495-
psprintf("xmax %u precedes relation freeze threshold %u:%u",
1496-
xmax,
1497-
EpochFromFullTransactionId(ctx->relfrozenfxid),
1498-
XidFromFullTransactionId(ctx->relfrozenfxid)));
1499-
fatal= true;
1500-
}
1501-
}
1502-
15031393
/*
1504-
* Cannot process tuple data if tuple header was corrupt, as the offsets
1505-
* within the page cannot be trusted, leaving too much risk of reading
1506-
* garbage if we continue.
1507-
*
1508-
* We also cannot process the tuple if the xmin or xmax were invalid
1509-
* relative to relfrozenxid or relminmxid, as clog entries for the xids
1510-
* may already be gone.
1394+
* Check various forms of tuple header corruption, and if the header is too
1395+
* corrupt, do not continue with other checks.
15111396
*/
1512-
if (fatal)
1397+
if (!check_tuple_header(ctx))
15131398
return;
15141399

15151400
/*
1516-
* Checkvarious forms oftupleheader corruption. If theheader is too
1517-
*corrupt to continue checking, or if the tupleis not visible to anyone,
1518-
*we cannotcontinue with other checks.
1401+
* Check tuplevisibility. If theinserting transaction aborted, we
1402+
*cannot assume our relation description matches the tuplestructure, and
1403+
*therefore cannotcheck it.
15191404
*/
1520-
if (!check_tuple_header(ctx))
1521-
return;
1522-
15231405
if (!check_tuple_visibility(ctx))
15241406
return;
15251407

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp