Skip to content

Commit 1c9caba

Browse files
committed
MDEV-37659 CHECK TABLE…EXTENDED error on a column prefix index
trx_undo_prev_version(): Prevent unsafe BLOB access. Tested by: Saahil Alam Reviewed by: Thirunarayanan Balathandayuthapani
1 parent 8258b2f commit 1c9caba

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

storage/innobase/include/trx0purge.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,9 @@ class purge_sys_t
451451

452452
/** @return purge_sys.view or purge_sys.end_view */
453453
inline const ReadViewBase &view() const;
454+
455+
/** @return whether this is part of CHECK TABLE ... EXTENDED */
456+
bool is_extended() const noexcept { return latch < END_VIEW; }
454457
};
455458

456459
struct end_view_guard

storage/innobase/trx/trx0rec.cc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2229,6 +2229,21 @@ static dberr_t trx_undo_prev_version(const rec_t *rec, dict_index_t *index,
22292229
byte* buf;
22302230

22312231
if (row_upd_changes_field_size_or_external(index, offsets, update)) {
2232+
/* When CHECK TABLE ... EXTENDED checks for orphan
2233+
records in secondary indexes, it normally covers some
2234+
history that is already being purged. This is safe as
2235+
long as the undo log records have not been freed yet.
2236+
2237+
However, BLOBs are only safe to access as long as the
2238+
purge_sys.view does not permit them to be freed. The
2239+
check.latch will freeze the purge_sys.view by blocking
2240+
purge_sys.clone_oldest_view() at the start of
2241+
trx_purge() or by blocking purge_sys.batch_cleanup()
2242+
at the end of trx_purge(). */
2243+
if (check.is_extended() && purge_sys.is_purgeable(trx_id)) {
2244+
return DB_SUCCESS;
2245+
}
2246+
22322247
/* We should confirm the existence of disowned external data,
22332248
if the previous version record is delete marked. If the trx_id
22342249
of the previous record is seen by purge view, we should treat

0 commit comments

Comments
 (0)