Commit c9220483 authored by Jan Lindström's avatar Jan Lindström

MDEV-6191: row_search_for_mysql comment and code consistency about isolation level

and gap locks
parent 838977e5
...@@ -877,16 +877,15 @@ row_sel_get_clust_rec( ...@@ -877,16 +877,15 @@ row_sel_get_clust_rec(
if (!node->read_view) { if (!node->read_view) {
/* Try to place a lock on the index record */ /* Try to place a lock on the index record */
/* If innodb_locks_unsafe_for_binlog option is used
or this session is using READ COMMITTED isolation level
we lock only the record, i.e., next-key locking is
not used. */
ulint lock_type; ulint lock_type;
trx_t* trx; trx_t* trx;
trx = thr_get_trx(thr); trx = thr_get_trx(thr);
/* If innodb_locks_unsafe_for_binlog option is used
or this session is using READ COMMITTED or lower isolation level
we lock only the record, i.e., next-key locking is
not used. */
if (srv_locks_unsafe_for_binlog if (srv_locks_unsafe_for_binlog
|| trx->isolation_level <= TRX_ISO_READ_COMMITTED) { || trx->isolation_level <= TRX_ISO_READ_COMMITTED) {
lock_type = LOCK_REC_NOT_GAP; lock_type = LOCK_REC_NOT_GAP;
...@@ -1491,12 +1490,6 @@ row_sel( ...@@ -1491,12 +1490,6 @@ row_sel(
search result set, resulting in the phantom problem. */ search result set, resulting in the phantom problem. */
if (!consistent_read) { if (!consistent_read) {
/* If innodb_locks_unsafe_for_binlog option is used
or this session is using READ COMMITTED isolation
level, we lock only the record, i.e., next-key
locking is not used. */
rec_t* next_rec = page_rec_get_next(rec); rec_t* next_rec = page_rec_get_next(rec);
ulint lock_type; ulint lock_type;
trx_t* trx; trx_t* trx;
...@@ -1506,6 +1499,10 @@ row_sel( ...@@ -1506,6 +1499,10 @@ row_sel(
offsets = rec_get_offsets(next_rec, index, offsets, offsets = rec_get_offsets(next_rec, index, offsets,
ULINT_UNDEFINED, &heap); ULINT_UNDEFINED, &heap);
/* If innodb_locks_unsafe_for_binlog option is used
or this session is using READ COMMITTED or lower isolation
level, we lock only the record, i.e., next-key
locking is not used. */
if (srv_locks_unsafe_for_binlog if (srv_locks_unsafe_for_binlog
|| trx->isolation_level || trx->isolation_level
<= TRX_ISO_READ_COMMITTED) { <= TRX_ISO_READ_COMMITTED) {
...@@ -1554,12 +1551,6 @@ row_sel( ...@@ -1554,12 +1551,6 @@ row_sel(
if (!consistent_read) { if (!consistent_read) {
/* Try to place a lock on the index record */ /* Try to place a lock on the index record */
/* If innodb_locks_unsafe_for_binlog option is used
or this session is using READ COMMITTED isolation level,
we lock only the record, i.e., next-key locking is
not used. */
ulint lock_type; ulint lock_type;
trx_t* trx; trx_t* trx;
...@@ -1568,6 +1559,10 @@ row_sel( ...@@ -1568,6 +1559,10 @@ row_sel(
trx = thr_get_trx(thr); trx = thr_get_trx(thr);
/* If innodb_locks_unsafe_for_binlog option is used
or this session is using READ COMMITTED or lower isolation level,
we lock only the record, i.e., next-key locking is
not used. */
if (srv_locks_unsafe_for_binlog if (srv_locks_unsafe_for_binlog
|| trx->isolation_level <= TRX_ISO_READ_COMMITTED) { || trx->isolation_level <= TRX_ISO_READ_COMMITTED) {
...@@ -3992,7 +3987,7 @@ row_search_for_mysql( ...@@ -3992,7 +3987,7 @@ row_search_for_mysql(
/* Try to place a lock on the index record */ /* Try to place a lock on the index record */
/* If innodb_locks_unsafe_for_binlog option is used /* If innodb_locks_unsafe_for_binlog option is used
or this session is using a READ COMMITTED isolation or this session is using a READ COMMITTED or lower isolation
level we do not lock gaps. Supremum record is really level we do not lock gaps. Supremum record is really
a gap and therefore we do not set locks there. */ a gap and therefore we do not set locks there. */
...@@ -4131,7 +4126,7 @@ row_search_for_mysql( ...@@ -4131,7 +4126,7 @@ row_search_for_mysql(
/* Try to place a gap lock on the index /* Try to place a gap lock on the index
record only if innodb_locks_unsafe_for_binlog record only if innodb_locks_unsafe_for_binlog
option is not set or this session is not option is not set or this session is not
using a READ COMMITTED isolation level. */ using a READ COMMITTED or lower isolation level. */
err = sel_set_rec_lock( err = sel_set_rec_lock(
btr_pcur_get_block(pcur), btr_pcur_get_block(pcur),
...@@ -4178,7 +4173,7 @@ row_search_for_mysql( ...@@ -4178,7 +4173,7 @@ row_search_for_mysql(
/* Try to place a gap lock on the index /* Try to place a gap lock on the index
record only if innodb_locks_unsafe_for_binlog record only if innodb_locks_unsafe_for_binlog
option is not set or this session is not option is not set or this session is not
using a READ COMMITTED isolation level. */ using a READ COMMITTED or lower isolation level. */
err = sel_set_rec_lock( err = sel_set_rec_lock(
btr_pcur_get_block(pcur), btr_pcur_get_block(pcur),
......
...@@ -879,16 +879,15 @@ row_sel_get_clust_rec( ...@@ -879,16 +879,15 @@ row_sel_get_clust_rec(
if (!node->read_view) { if (!node->read_view) {
/* Try to place a lock on the index record */ /* Try to place a lock on the index record */
/* If innodb_locks_unsafe_for_binlog option is used
or this session is using READ COMMITTED isolation level
we lock only the record, i.e., next-key locking is
not used. */
ulint lock_type; ulint lock_type;
trx_t* trx; trx_t* trx;
trx = thr_get_trx(thr); trx = thr_get_trx(thr);
/* If innodb_locks_unsafe_for_binlog option is used
or this session is using READ COMMITTED or lower isolation level
we lock only the record, i.e., next-key locking is
not used. */
if (srv_locks_unsafe_for_binlog if (srv_locks_unsafe_for_binlog
|| trx->isolation_level <= TRX_ISO_READ_COMMITTED) { || trx->isolation_level <= TRX_ISO_READ_COMMITTED) {
lock_type = LOCK_REC_NOT_GAP; lock_type = LOCK_REC_NOT_GAP;
...@@ -1494,12 +1493,6 @@ row_sel( ...@@ -1494,12 +1493,6 @@ row_sel(
search result set, resulting in the phantom problem. */ search result set, resulting in the phantom problem. */
if (!consistent_read) { if (!consistent_read) {
/* If innodb_locks_unsafe_for_binlog option is used
or this session is using READ COMMITTED isolation
level, we lock only the record, i.e., next-key
locking is not used. */
rec_t* next_rec = page_rec_get_next(rec); rec_t* next_rec = page_rec_get_next(rec);
ulint lock_type; ulint lock_type;
trx_t* trx; trx_t* trx;
...@@ -1509,6 +1502,10 @@ row_sel( ...@@ -1509,6 +1502,10 @@ row_sel(
offsets = rec_get_offsets(next_rec, index, offsets, offsets = rec_get_offsets(next_rec, index, offsets,
ULINT_UNDEFINED, &heap); ULINT_UNDEFINED, &heap);
/* If innodb_locks_unsafe_for_binlog option is used
or this session is using READ COMMITTED or lower isolation
level, we lock only the record, i.e., next-key
locking is not used. */
if (srv_locks_unsafe_for_binlog if (srv_locks_unsafe_for_binlog
|| trx->isolation_level || trx->isolation_level
<= TRX_ISO_READ_COMMITTED) { <= TRX_ISO_READ_COMMITTED) {
...@@ -1557,12 +1554,6 @@ row_sel( ...@@ -1557,12 +1554,6 @@ row_sel(
if (!consistent_read) { if (!consistent_read) {
/* Try to place a lock on the index record */ /* Try to place a lock on the index record */
/* If innodb_locks_unsafe_for_binlog option is used
or this session is using READ COMMITTED isolation level,
we lock only the record, i.e., next-key locking is
not used. */
ulint lock_type; ulint lock_type;
trx_t* trx; trx_t* trx;
...@@ -1571,6 +1562,10 @@ row_sel( ...@@ -1571,6 +1562,10 @@ row_sel(
trx = thr_get_trx(thr); trx = thr_get_trx(thr);
/* If innodb_locks_unsafe_for_binlog option is used
or this session is using READ COMMITTED or lower isolation level,
we lock only the record, i.e., next-key locking is
not used. */
if (srv_locks_unsafe_for_binlog if (srv_locks_unsafe_for_binlog
|| trx->isolation_level <= TRX_ISO_READ_COMMITTED) { || trx->isolation_level <= TRX_ISO_READ_COMMITTED) {
...@@ -4142,7 +4137,7 @@ row_search_for_mysql( ...@@ -4142,7 +4137,7 @@ row_search_for_mysql(
/* Try to place a lock on the index record */ /* Try to place a lock on the index record */
/* If innodb_locks_unsafe_for_binlog option is used /* If innodb_locks_unsafe_for_binlog option is used
or this session is using a READ COMMITTED isolation or this session is using a READ COMMITTED or lower isolation
level we do not lock gaps. Supremum record is really level we do not lock gaps. Supremum record is really
a gap and therefore we do not set locks there. */ a gap and therefore we do not set locks there. */
...@@ -4289,7 +4284,7 @@ row_search_for_mysql( ...@@ -4289,7 +4284,7 @@ row_search_for_mysql(
/* Try to place a gap lock on the index /* Try to place a gap lock on the index
record only if innodb_locks_unsafe_for_binlog record only if innodb_locks_unsafe_for_binlog
option is not set or this session is not option is not set or this session is not
using a READ COMMITTED isolation level. */ using a READ COMMITTED or lower isolation level. */
err = sel_set_rec_lock( err = sel_set_rec_lock(
btr_pcur_get_block(pcur), btr_pcur_get_block(pcur),
...@@ -4336,7 +4331,7 @@ row_search_for_mysql( ...@@ -4336,7 +4331,7 @@ row_search_for_mysql(
/* Try to place a gap lock on the index /* Try to place a gap lock on the index
record only if innodb_locks_unsafe_for_binlog record only if innodb_locks_unsafe_for_binlog
option is not set or this session is not option is not set or this session is not
using a READ COMMITTED isolation level. */ using a READ COMMITTED or lower isolation level. */
err = sel_set_rec_lock( err = sel_set_rec_lock(
btr_pcur_get_block(pcur), btr_pcur_get_block(pcur),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment