mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
row0mysql.c, row0mysql.h, ha_innodb.cc:
Inside LOCK TABLES, use either LOCK_S or LOCK_X in locking reads; an improvent over the previous patch sql/ha_innodb.cc: Inside LOCK TABLES, use either LOCK_S or LOCK_X in locking reads; an improvent over the previous patch innobase/include/row0mysql.h: Inside LOCK TABLES, use either LOCK_S or LOCK_X in locking reads; an improvent over the previous patch innobase/row/row0mysql.c: Inside LOCK TABLES, use either LOCK_S or LOCK_X in locking reads; an improvent over the previous patch
This commit is contained in:
@ -507,6 +507,9 @@ struct row_prebuilt_struct {
|
|||||||
dtuple_t* clust_ref; /* prebuilt dtuple used in
|
dtuple_t* clust_ref; /* prebuilt dtuple used in
|
||||||
sel/upd/del */
|
sel/upd/del */
|
||||||
ulint select_lock_type;/* LOCK_NONE, LOCK_S, or LOCK_X */
|
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 mysql_row_len; /* length in bytes of a row in the
|
ulint mysql_row_len; /* length in bytes of a row in the
|
||||||
MySQL format */
|
MySQL format */
|
||||||
ulint n_rows_fetched; /* number of rows fetched after
|
ulint n_rows_fetched; /* number of rows fetched after
|
||||||
|
@ -380,6 +380,7 @@ row_create_prebuilt(
|
|||||||
prebuilt->clust_pcur = btr_pcur_create_for_mysql();
|
prebuilt->clust_pcur = btr_pcur_create_for_mysql();
|
||||||
|
|
||||||
prebuilt->select_lock_type = LOCK_NONE;
|
prebuilt->select_lock_type = LOCK_NONE;
|
||||||
|
prebuilt->stored_select_lock_type = 99999999;
|
||||||
|
|
||||||
prebuilt->sel_graph = NULL;
|
prebuilt->sel_graph = NULL;
|
||||||
|
|
||||||
|
@ -4505,16 +4505,38 @@ ha_innobase::start_stmt(
|
|||||||
|
|
||||||
prebuilt->select_lock_type = LOCK_X;
|
prebuilt->select_lock_type = LOCK_X;
|
||||||
} else {
|
} else {
|
||||||
/* For other than temporary tables, we obtain
|
/* When we first come here after LOCK TABLES,
|
||||||
no lock for consistent read (plain SELECT), and
|
select_lock_type is set to LOCK_S or LOCK_X. Store the value
|
||||||
an exclusive lock for SELECT ... FOR UPDATE or
|
in case we run also consistent reads and need to restore the
|
||||||
SELECT ... LOCK IN SHARE MODE. */
|
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
|
||||||
|
&& thd->lex.lock_option == TL_READ) {
|
||||||
|
|
||||||
|
/* For other than temporary tables, we obtain
|
||||||
|
no lock for consistent read (plain SELECT) */
|
||||||
|
|
||||||
|
prebuilt->select_lock_type = LOCK_NONE;
|
||||||
|
} else {
|
||||||
|
/* Not a consistent read: restore the
|
||||||
|
select_lock_type value */
|
||||||
prebuilt->select_lock_type =
|
prebuilt->select_lock_type =
|
||||||
thd->lex.sql_command == SQLCOM_SELECT
|
prebuilt->stored_select_lock_type;
|
||||||
&& thd->lex.lock_option == TL_READ
|
}
|
||||||
? LOCK_NONE
|
|
||||||
: LOCK_X;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set the MySQL flag to mark that there is an active transaction */
|
/* Set the MySQL flag to mark that there is an active transaction */
|
||||||
|
Reference in New Issue
Block a user