Loading innobase/include/row0mysql.h +5 −3 Original line number Diff line number Diff line Loading @@ -508,9 +508,11 @@ struct row_prebuilt_struct { dtuple_t* clust_ref; /* prebuilt dtuple used in sel/upd/del */ ulint select_lock_type;/* LOCK_NONE, LOCK_S, or LOCK_X */ ulint stored_select_lock_type;/* inside LOCK TABLES, either LOCK_S or LOCK_X depending on the lock type */ ulint stored_select_lock_type;/* this field is used to remember the original select_lock_type that was decided in ha_innodb.cc, ::store_lock(), ::external_lock(), etc. */ ulint mysql_row_len; /* length in bytes of a row in the MySQL format */ ulint n_rows_fetched; /* number of rows fetched after Loading innobase/sync/sync0arr.c +1 −4 Original line number Diff line number Diff line Loading @@ -61,10 +61,7 @@ struct sync_cell_struct { thread */ ibool waiting; /* TRUE if the thread has already called sync_array_event_wait on this cell but not yet sync_array_free_cell (which actually resets wait_object and thus whole cell) */ on this cell */ ibool event_set; /* TRUE if the event is set */ os_event_t event; /* operating system event semaphore handle */ Loading sql/ha_innodb.cc +38 −27 Original line number Diff line number Diff line Loading @@ -767,6 +767,7 @@ ha_innobase::init_table_handle_for_HANDLER(void) if the trx isolation level would have been specified as SERIALIZABLE */ prebuilt->select_lock_type = LOCK_NONE; prebuilt->stored_select_lock_type = LOCK_NONE; /* Always fetch all columns in the index record */ Loading Loading @@ -4562,38 +4563,38 @@ ha_innobase::start_stmt( prebuilt->select_lock_type = LOCK_X; } else { /* When we first come here after LOCK TABLES, select_lock_type is set to LOCK_S or LOCK_X. Store the value in case we run also consistent reads and need to restore the value later. */ if (prebuilt->select_lock_type != LOCK_NONE) { prebuilt->stored_select_lock_type = prebuilt->select_lock_type; } if (prebuilt->stored_select_lock_type != LOCK_S && prebuilt->stored_select_lock_type != LOCK_X) { fprintf(stderr, "InnoDB: Error: select_lock_type is %lu inside ::start_stmt()!\n", prebuilt->stored_select_lock_type); ut_error; } if (thd->lex.sql_command == SQLCOM_SELECT if (trx->isolation_level != TRX_ISO_SERIALIZABLE && thd->lex.sql_command == SQLCOM_SELECT && thd->lex.lock_option == TL_READ) { /* For other than temporary tables, we obtain no lock for consistent read (plain SELECT) */ no lock for consistent read (plain SELECT). */ prebuilt->select_lock_type = LOCK_NONE; } else { /* Not a consistent read: restore the select_lock_type value */ select_lock_type value. The value of stored_select_lock_type was decided in: 1) ::store_lock(), 2) ::external_lock(), and 3) ::init_table_handle_for_HANDLER(). */ prebuilt->select_lock_type = prebuilt->stored_select_lock_type; } if (prebuilt->stored_select_lock_type != LOCK_S && prebuilt->stored_select_lock_type != LOCK_X) { fprintf(stderr, "InnoDB: Error: stored_select_lock_type is %lu inside ::start_stmt()!\n", prebuilt->stored_select_lock_type); /* Set the value to LOCK_X: this is just fault tolerance, we do not know what the correct value should be! */ prebuilt->select_lock_type = LOCK_X; } } /* Set the MySQL flag to mark that there is an active transaction */ Loading Loading @@ -4656,6 +4657,7 @@ ha_innobase::external_lock( /* If this is a SELECT, then it is in UPDATE TABLE ... or SELECT ... FOR UPDATE */ prebuilt->select_lock_type = LOCK_X; prebuilt->stored_select_lock_type = LOCK_X; } if (lock_type != F_UNLCK) { Loading Loading @@ -4910,14 +4912,22 @@ ha_innobase::store_lock( { row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt; if (lock_type == TL_READ_WITH_SHARED_LOCKS || if ((lock_type == TL_READ && thd->in_lock_tables) || (lock_type == TL_READ_HIGH_PRIORITY && thd->in_lock_tables) || lock_type == TL_READ_WITH_SHARED_LOCKS || lock_type == TL_READ_NO_INSERT) { /* This is a SELECT ... IN SHARE MODE, or we are doing a complex SQL statement like /* The OR cases above are in this order: 1) MySQL is doing LOCK TABLES ... READ LOCAL, or 2) (we do not know when TL_READ_HIGH_PRIORITY is used), or 3) this is a SELECT ... IN SHARE MODE, or 4) we are doing a complex SQL statement like INSERT INTO ... SELECT ... and the logical logging (MySQL binlog) requires the use of a locking read */ binlog) requires the use of a locking read, or MySQL is doing LOCK TABLES ... READ. */ prebuilt->select_lock_type = LOCK_S; prebuilt->stored_select_lock_type = LOCK_S; } else if (lock_type != TL_IGNORE) { /* In ha_berkeley.cc there is a comment that MySQL Loading @@ -4928,6 +4938,7 @@ ha_innobase::store_lock( here even if this would be SELECT ... FOR UPDATE */ prebuilt->select_lock_type = LOCK_NONE; prebuilt->stored_select_lock_type = LOCK_NONE; } if (lock_type != TL_IGNORE && lock.type == TL_UNLOCK) { Loading Loading
innobase/include/row0mysql.h +5 −3 Original line number Diff line number Diff line Loading @@ -508,9 +508,11 @@ struct row_prebuilt_struct { dtuple_t* clust_ref; /* prebuilt dtuple used in sel/upd/del */ ulint select_lock_type;/* LOCK_NONE, LOCK_S, or LOCK_X */ ulint stored_select_lock_type;/* inside LOCK TABLES, either LOCK_S or LOCK_X depending on the lock type */ ulint stored_select_lock_type;/* this field is used to remember the original select_lock_type that was decided in ha_innodb.cc, ::store_lock(), ::external_lock(), etc. */ ulint mysql_row_len; /* length in bytes of a row in the MySQL format */ ulint n_rows_fetched; /* number of rows fetched after Loading
innobase/sync/sync0arr.c +1 −4 Original line number Diff line number Diff line Loading @@ -61,10 +61,7 @@ struct sync_cell_struct { thread */ ibool waiting; /* TRUE if the thread has already called sync_array_event_wait on this cell but not yet sync_array_free_cell (which actually resets wait_object and thus whole cell) */ on this cell */ ibool event_set; /* TRUE if the event is set */ os_event_t event; /* operating system event semaphore handle */ Loading
sql/ha_innodb.cc +38 −27 Original line number Diff line number Diff line Loading @@ -767,6 +767,7 @@ ha_innobase::init_table_handle_for_HANDLER(void) if the trx isolation level would have been specified as SERIALIZABLE */ prebuilt->select_lock_type = LOCK_NONE; prebuilt->stored_select_lock_type = LOCK_NONE; /* Always fetch all columns in the index record */ Loading Loading @@ -4562,38 +4563,38 @@ ha_innobase::start_stmt( prebuilt->select_lock_type = LOCK_X; } else { /* When we first come here after LOCK TABLES, select_lock_type is set to LOCK_S or LOCK_X. Store the value in case we run also consistent reads and need to restore the value later. */ if (prebuilt->select_lock_type != LOCK_NONE) { prebuilt->stored_select_lock_type = prebuilt->select_lock_type; } if (prebuilt->stored_select_lock_type != LOCK_S && prebuilt->stored_select_lock_type != LOCK_X) { fprintf(stderr, "InnoDB: Error: select_lock_type is %lu inside ::start_stmt()!\n", prebuilt->stored_select_lock_type); ut_error; } if (thd->lex.sql_command == SQLCOM_SELECT if (trx->isolation_level != TRX_ISO_SERIALIZABLE && thd->lex.sql_command == SQLCOM_SELECT && thd->lex.lock_option == TL_READ) { /* For other than temporary tables, we obtain no lock for consistent read (plain SELECT) */ no lock for consistent read (plain SELECT). */ prebuilt->select_lock_type = LOCK_NONE; } else { /* Not a consistent read: restore the select_lock_type value */ select_lock_type value. The value of stored_select_lock_type was decided in: 1) ::store_lock(), 2) ::external_lock(), and 3) ::init_table_handle_for_HANDLER(). */ prebuilt->select_lock_type = prebuilt->stored_select_lock_type; } if (prebuilt->stored_select_lock_type != LOCK_S && prebuilt->stored_select_lock_type != LOCK_X) { fprintf(stderr, "InnoDB: Error: stored_select_lock_type is %lu inside ::start_stmt()!\n", prebuilt->stored_select_lock_type); /* Set the value to LOCK_X: this is just fault tolerance, we do not know what the correct value should be! */ prebuilt->select_lock_type = LOCK_X; } } /* Set the MySQL flag to mark that there is an active transaction */ Loading Loading @@ -4656,6 +4657,7 @@ ha_innobase::external_lock( /* If this is a SELECT, then it is in UPDATE TABLE ... or SELECT ... FOR UPDATE */ prebuilt->select_lock_type = LOCK_X; prebuilt->stored_select_lock_type = LOCK_X; } if (lock_type != F_UNLCK) { Loading Loading @@ -4910,14 +4912,22 @@ ha_innobase::store_lock( { row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt; if (lock_type == TL_READ_WITH_SHARED_LOCKS || if ((lock_type == TL_READ && thd->in_lock_tables) || (lock_type == TL_READ_HIGH_PRIORITY && thd->in_lock_tables) || lock_type == TL_READ_WITH_SHARED_LOCKS || lock_type == TL_READ_NO_INSERT) { /* This is a SELECT ... IN SHARE MODE, or we are doing a complex SQL statement like /* The OR cases above are in this order: 1) MySQL is doing LOCK TABLES ... READ LOCAL, or 2) (we do not know when TL_READ_HIGH_PRIORITY is used), or 3) this is a SELECT ... IN SHARE MODE, or 4) we are doing a complex SQL statement like INSERT INTO ... SELECT ... and the logical logging (MySQL binlog) requires the use of a locking read */ binlog) requires the use of a locking read, or MySQL is doing LOCK TABLES ... READ. */ prebuilt->select_lock_type = LOCK_S; prebuilt->stored_select_lock_type = LOCK_S; } else if (lock_type != TL_IGNORE) { /* In ha_berkeley.cc there is a comment that MySQL Loading @@ -4928,6 +4938,7 @@ ha_innobase::store_lock( here even if this would be SELECT ... FOR UPDATE */ prebuilt->select_lock_type = LOCK_NONE; prebuilt->stored_select_lock_type = LOCK_NONE; } if (lock_type != TL_IGNORE && lock.type == TL_UNLOCK) { Loading