MCPcopy Create free account
hub / github.com/apache/cloudberry / CrossCheckTuple

Function CrossCheckTuple

src/backend/utils/cache/catcache.c:1139–1184  ·  view source on GitHub ↗

* This function performs checks for certain system tables to validate tuple * fetched from table has the key, using which it was fetched from index. */

Source from the content-addressed store, hash-verified

1137 * fetched from table has the key, using which it was fetched from index.
1138 */
1139static void
1140CrossCheckTuple(int cacheId,
1141 Datum key1,
1142 Datum key2,
1143 Datum key3,
1144 Datum key4,
1145 HeapTuple tuple)
1146{
1147 Form_pg_class rd_rel;
1148 Form_pg_type rd_type;
1149
1150 switch (cacheId)
1151 {
1152 case RELOID:
1153 rd_rel = (Form_pg_class) GETSTRUCT(tuple);
1154 if (rd_rel->oid != DatumGetObjectId(key1))
1155 {
1156 elog(ERROR, "pg_class_oid_index is broken, oid=%d is pointing to tuple with oid=%d (xmin:%u xmax:%u)",
1157 DatumGetObjectId(key1), rd_rel->oid,
1158 HeapTupleHeaderGetXmin((tuple)->t_data),
1159 HeapTupleHeaderGetRawXmax((tuple)->t_data));
1160 }
1161 break;
1162 case RELNAMENSP:
1163 rd_rel = (Form_pg_class) GETSTRUCT(tuple);
1164 if (strncmp(rd_rel->relname.data, DatumGetCString(key1), NAMEDATALEN) != 0)
1165 {
1166 elog(ERROR, "pg_class_relname_nsp_index is broken, intended tuple with name \"%s\" fetched \"%s\""
1167 " (xmin:%u xmax:%u)",
1168 DatumGetCString(key1), rd_rel->relname.data,
1169 HeapTupleHeaderGetXmin((tuple)->t_data),
1170 HeapTupleHeaderGetRawXmax((tuple)->t_data));
1171 }
1172 break;
1173 case TYPEOID:
1174 rd_type = (Form_pg_type) GETSTRUCT(tuple);
1175 if (rd_type->oid != DatumGetObjectId(key1))
1176 {
1177 elog(ERROR, "pg_type_oid_index is broken, oid=%d is pointing to tuple with oid=%d (xmin:%u xmax:%u)",
1178 DatumGetObjectId(key1), rd_type->oid,
1179 HeapTupleHeaderGetXmin((tuple)->t_data),
1180 HeapTupleHeaderGetRawXmax((tuple)->t_data));
1181 }
1182 break;
1183 }
1184}
1185
1186/*
1187 * SearchCatCache

Callers 1

SearchCatCacheMissFunction · 0.85

Calls 2

DatumGetObjectIdFunction · 0.85
DatumGetCStringFunction · 0.85

Tested by

no test coverage detected