mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
Give error if locked table is used twice in query. This fixes strange error message when doing LOCK TABLES t1 WRITE; INSERT TABLE t1 SELECT * from t1 (Bug #2296)
This commit is contained in:
@@ -154,7 +154,7 @@ static struct my_option my_long_options[] =
|
|||||||
{"first-slave", 'x', "Locks all tables across all databases.",
|
{"first-slave", 'x', "Locks all tables across all databases.",
|
||||||
(gptr*) &opt_first_slave, (gptr*) &opt_first_slave, 0, GET_BOOL, NO_ARG,
|
(gptr*) &opt_first_slave, (gptr*) &opt_first_slave, 0, GET_BOOL, NO_ARG,
|
||||||
0, 0, 0, 0, 0, 0},
|
0, 0, 0, 0, 0, 0},
|
||||||
{"flush-logs", 'F', "Flush logs file in server before starting dump.",
|
{"flush-logs", 'F', "Flush logs file in server before starting dump. Note that if you use this option in combination with the --all-databases (or -A) option, the logs will be flushed for each database dumped.",
|
||||||
(gptr*) &flush_logs, (gptr*) &flush_logs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
|
(gptr*) &flush_logs, (gptr*) &flush_logs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
|
||||||
0, 0},
|
0, 0},
|
||||||
{"force", 'f', "Continue even if we get an sql-error.",
|
{"force", 'f', "Continue even if we get an sql-error.",
|
||||||
|
@@ -41,5 +41,9 @@ lock tables t1 write;
|
|||||||
check table t2;
|
check table t2;
|
||||||
Table Op Msg_type Msg_text
|
Table Op Msg_type Msg_text
|
||||||
test.t2 check error Table 't2' was not locked with LOCK TABLES
|
test.t2 check error Table 't2' was not locked with LOCK TABLES
|
||||||
|
insert into t1 select nr from t1;
|
||||||
|
Table 't1' was not locked with LOCK TABLES
|
||||||
unlock tables;
|
unlock tables;
|
||||||
|
lock tables t1 write, t1 as t1_alias read;
|
||||||
|
insert into t1 select index1,nr from t1 as t1_alias;
|
||||||
drop table t1,t2;
|
drop table t1,t2;
|
||||||
|
@@ -51,5 +51,9 @@ check table t1;
|
|||||||
# Check error message
|
# Check error message
|
||||||
lock tables t1 write;
|
lock tables t1 write;
|
||||||
check table t2;
|
check table t2;
|
||||||
|
--error 1100
|
||||||
|
insert into t1 select nr from t1;
|
||||||
unlock tables;
|
unlock tables;
|
||||||
|
lock tables t1 write, t1 as t1_alias read;
|
||||||
|
insert into t1 select index1,nr from t1 as t1_alias;
|
||||||
drop table t1,t2;
|
drop table t1,t2;
|
||||||
|
@@ -824,9 +824,13 @@ TABLE *open_table(THD *thd,const char *db,const char *table_name,
|
|||||||
{
|
{
|
||||||
if (table->key_length == key_length &&
|
if (table->key_length == key_length &&
|
||||||
!memcmp(table->table_cache_key,key,key_length) &&
|
!memcmp(table->table_cache_key,key,key_length) &&
|
||||||
!my_strcasecmp(table->table_name,alias))
|
!my_strcasecmp(table->table_name,alias) &&
|
||||||
|
table->query_id != thd->query_id)
|
||||||
|
{
|
||||||
|
table->query_id=thd->query_id;
|
||||||
goto reset;
|
goto reset;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
my_printf_error(ER_TABLE_NOT_LOCKED,ER(ER_TABLE_NOT_LOCKED),MYF(0),alias);
|
my_printf_error(ER_TABLE_NOT_LOCKED,ER(ER_TABLE_NOT_LOCKED),MYF(0),alias);
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user