Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
66099b8f
Commit
66099b8f
authored
Apr 03, 2019
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup
parent
81a8d8be
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
119 additions
and
92 deletions
+119
-92
mysql-test/r/multi_update_big.result
mysql-test/r/multi_update_big.result
+0
-0
mysql-test/t/multi_update_big.opt
mysql-test/t/multi_update_big.opt
+0
-0
mysql-test/t/multi_update_big.test
mysql-test/t/multi_update_big.test
+0
-0
sql/sql_acl.cc
sql/sql_acl.cc
+36
-35
sql/sql_base.cc
sql/sql_base.cc
+52
-43
sql/sql_base.h
sql/sql_base.h
+15
-1
sql/sql_yacc.yy
sql/sql_yacc.yy
+16
-13
No files found.
mysql-test/r/multi_update
2
.result
→
mysql-test/r/multi_update
_big
.result
View file @
66099b8f
File moved
mysql-test/t/multi_update
2-master
.opt
→
mysql-test/t/multi_update
_big
.opt
View file @
66099b8f
File moved
mysql-test/t/multi_update
2
.test
→
mysql-test/t/multi_update
_big
.test
View file @
66099b8f
File moved
sql/sql_acl.cc
View file @
66099b8f
...
...
@@ -1150,6 +1150,16 @@ void acl_free(bool end)
}
static
void
fix_table_list
(
TABLE_LIST
*
tl
,
uint
n
)
{
TABLE_LIST
*
end
;
for
(
end
=
tl
+
n
-
1
;
tl
<
end
;
tl
++
)
{
tl
->
next_local
=
tl
->
next_global
=
tl
+
1
;
}
}
/*
Forget current user/db-level privileges and read new privileges
from the privilege tables.
...
...
@@ -1191,11 +1201,7 @@ my_bool acl_reload(THD *thd)
tables
[
3
].
init_one_table
(
C_STRING_WITH_LEN
(
"mysql"
),
C_STRING_WITH_LEN
(
"proxies_priv"
),
"proxies_priv"
,
TL_READ
);
tables
[
0
].
next_local
=
tables
[
0
].
next_global
=
tables
+
1
;
tables
[
1
].
next_local
=
tables
[
1
].
next_global
=
tables
+
2
;
tables
[
2
].
next_local
=
tables
[
2
].
next_global
=
tables
+
3
;
tables
[
0
].
open_type
=
tables
[
1
].
open_type
=
tables
[
2
].
open_type
=
tables
[
3
].
open_type
=
OT_BASE_ONLY
;
fix_table_list
(
tables
,
4
);
tables
[
3
].
open_strategy
=
TABLE_LIST
::
OPEN_IF_EXISTS
;
if
(
open_and_lock_tables
(
thd
,
tables
,
FALSE
,
MYSQL_LOCK_IGNORE_TIMEOUT
))
...
...
@@ -1921,6 +1927,7 @@ bool change_password(THD *thd, const char *host, const char *user,
DBUG_RETURN
(
1
);
tables
.
init_one_table
(
"mysql"
,
5
,
"user"
,
4
,
"user"
,
TL_WRITE
);
fix_table_list
(
&
tables
,
1
);
#ifdef HAVE_REPLICATION
/*
...
...
@@ -2282,6 +2289,7 @@ static bool test_if_create_new_users(THD *thd)
ulong
db_access
;
tl
.
init_one_table
(
C_STRING_WITH_LEN
(
"mysql"
),
C_STRING_WITH_LEN
(
"user"
),
"user"
,
TL_WRITE
);
fix_table_list
(
&
tl
,
1
);
create_new_users
=
1
;
db_access
=
acl_get
(
sctx
->
host
,
sctx
->
ip
,
...
...
@@ -3689,10 +3697,11 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list,
tables
[
2
].
init_one_table
(
C_STRING_WITH_LEN
(
"mysql"
),
C_STRING_WITH_LEN
(
"columns_priv"
),
"columns_priv"
,
TL_WRITE
);
tables
[
0
].
next_local
=
tables
[
0
].
next_global
=
tables
+
1
;
/* Don't open column table if we don't need it ! */
if
(
column_priv
||
(
revoke_grant
&&
((
rights
&
COL_ACLS
)
||
columns
.
elements
)))
tables
[
1
].
next_local
=
tables
[
1
].
next_global
=
tables
+
2
;
fix_table_list
(
tables
,
3
);
else
fix_table_list
(
tables
,
2
);
/*
This statement will be replicated as a statement, even when using
...
...
@@ -3930,7 +3939,7 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list, bool is_proc,
C_STRING_WITH_LEN
(
"user"
),
"user"
,
TL_WRITE
);
tables
[
1
].
init_one_table
(
C_STRING_WITH_LEN
(
"mysql"
),
C_STRING_WITH_LEN
(
"procs_priv"
),
"procs_priv"
,
TL_WRITE
);
tables
[
0
].
next_local
=
tables
[
0
].
next_global
=
tables
+
1
;
fix_table_list
(
tables
,
2
)
;
/*
This statement will be replicated as a statement, even when using
...
...
@@ -4104,7 +4113,7 @@ bool mysql_grant(THD *thd, const char *db, List <LEX_USER> &list,
C_STRING_WITH_LEN
(
"db"
),
"db"
,
TL_WRITE
);
tables
[
0
].
next_local
=
tables
[
0
].
next_global
=
tables
+
1
;
fix_table_list
(
tables
,
2
)
;
/*
This statement will be replicated as a statement, even when using
...
...
@@ -4525,10 +4534,7 @@ my_bool grant_reload(THD *thd)
tables
[
2
].
init_one_table
(
C_STRING_WITH_LEN
(
"mysql"
),
C_STRING_WITH_LEN
(
"procs_priv"
),
"procs_priv"
,
TL_READ
);
tables
[
0
].
next_local
=
tables
[
0
].
next_global
=
tables
+
1
;
tables
[
1
].
next_local
=
tables
[
1
].
next_global
=
tables
+
2
;
tables
[
0
].
open_type
=
tables
[
1
].
open_type
=
tables
[
2
].
open_type
=
OT_BASE_ONLY
;
fix_table_list
(
tables
,
3
);
/*
Reload will work in the following manner:-
...
...
@@ -5864,29 +5870,24 @@ int open_grant_tables(THD *thd, TABLE_LIST *tables)
DBUG_RETURN
(
-
1
);
}
tables
->
init_one_table
(
C_STRING_WITH_LEN
(
"mysql"
),
C_STRING_WITH_LEN
(
"user"
),
"user"
,
TL_WRITE
);
(
tables
+
1
)
->
init_one_table
(
C_STRING_WITH_LEN
(
"mysql"
),
C_STRING_WITH_LEN
(
"db"
),
"db"
,
TL_WRITE
);
(
tables
+
2
)
->
init_one_table
(
C_STRING_WITH_LEN
(
"mysql"
),
C_STRING_WITH_LEN
(
"tables_priv"
),
"tables_priv"
,
TL_WRITE
);
(
tables
+
3
)
->
init_one_table
(
C_STRING_WITH_LEN
(
"mysql"
),
C_STRING_WITH_LEN
(
"columns_priv"
),
"columns_priv"
,
TL_WRITE
);
(
tables
+
4
)
->
init_one_table
(
C_STRING_WITH_LEN
(
"mysql"
),
C_STRING_WITH_LEN
(
"procs_priv"
),
"procs_priv"
,
TL_WRITE
);
(
tables
+
5
)
->
init_one_table
(
C_STRING_WITH_LEN
(
"mysql"
),
C_STRING_WITH_LEN
(
"proxies_priv"
),
"proxies_priv"
,
TL_WRITE
);
tables
[
0
].
init_one_table
(
C_STRING_WITH_LEN
(
"mysql"
),
C_STRING_WITH_LEN
(
"user"
),
"user"
,
TL_WRITE
);
tables
[
1
].
init_one_table
(
C_STRING_WITH_LEN
(
"mysql"
),
C_STRING_WITH_LEN
(
"db"
),
"db"
,
TL_WRITE
);
tables
[
2
].
init_one_table
(
C_STRING_WITH_LEN
(
"mysql"
),
C_STRING_WITH_LEN
(
"tables_priv"
),
"tables_priv"
,
TL_WRITE
);
tables
[
3
].
init_one_table
(
C_STRING_WITH_LEN
(
"mysql"
),
C_STRING_WITH_LEN
(
"columns_priv"
),
"columns_priv"
,
TL_WRITE
);
tables
[
4
].
init_one_table
(
C_STRING_WITH_LEN
(
"mysql"
),
C_STRING_WITH_LEN
(
"procs_priv"
),
"procs_priv"
,
TL_WRITE
);
tables
[
5
].
init_one_table
(
C_STRING_WITH_LEN
(
"mysql"
),
C_STRING_WITH_LEN
(
"proxies_priv"
),
"proxies_priv"
,
TL_WRITE
);
tables
[
5
].
open_strategy
=
TABLE_LIST
::
OPEN_IF_EXISTS
;
tables
->
next_local
=
tables
->
next_global
=
tables
+
1
;
(
tables
+
1
)
->
next_local
=
(
tables
+
1
)
->
next_global
=
tables
+
2
;
(
tables
+
2
)
->
next_local
=
(
tables
+
2
)
->
next_global
=
tables
+
3
;
(
tables
+
3
)
->
next_local
=
(
tables
+
3
)
->
next_global
=
tables
+
4
;
(
tables
+
4
)
->
next_local
=
(
tables
+
4
)
->
next_global
=
tables
+
5
;
fix_table_list
(
tables
,
6
);
#ifdef HAVE_REPLICATION
/*
...
...
sql/sql_base.cc
View file @
66099b8f
...
...
@@ -4468,6 +4468,45 @@ open_and_process_routine(THD *thd, Query_tables_list *prelocking_ctx,
DBUG_RETURN
(
FALSE
);
}
/*
If we are not already in prelocked mode and extended table list is not
yet built we might have to build the prelocking set for this statement.
Since currently no prelocking strategy prescribes doing anything for
tables which are only read, we do below checks only if table is going
to be changed.
*/
bool
extend_table_list
(
THD
*
thd
,
TABLE_LIST
*
tables
,
Prelocking_strategy
*
prelocking_strategy
,
bool
has_prelocking_list
)
{
bool
error
=
false
;
LEX
*
lex
=
thd
->
lex
;
if
(
thd
->
locked_tables_mode
<=
LTM_LOCK_TABLES
&&
!
has_prelocking_list
&&
tables
->
lock_type
>=
TL_WRITE_ALLOW_WRITE
)
{
bool
need_prelocking
=
FALSE
;
TABLE_LIST
**
save_query_tables_last
=
lex
->
query_tables_last
;
/*
Extend statement's table list and the prelocking set with
tables and routines according to the current prelocking
strategy.
For example, for DML statements we need to add tables and routines
used by triggers which are going to be invoked for this element of
table list and also add tables required for handling of foreign keys.
*/
error
=
prelocking_strategy
->
handle_table
(
thd
,
lex
,
tables
,
&
need_prelocking
);
if
(
need_prelocking
&&
!
lex
->
requires_prelocking
())
lex
->
mark_as_requiring_prelocking
(
save_query_tables_last
);
}
return
error
;
}
/**
Handle table list element by obtaining metadata lock, opening table or view
...
...
@@ -4496,15 +4535,14 @@ open_and_process_routine(THD *thd, Query_tables_list *prelocking_ctx,
*/
static
bool
open_and_process_table
(
THD
*
thd
,
LEX
*
lex
,
TABLE_LIST
*
tables
,
uint
*
counter
,
uint
flags
,
open_and_process_table
(
THD
*
thd
,
TABLE_LIST
*
tables
,
uint
*
counter
,
uint
flags
,
Prelocking_strategy
*
prelocking_strategy
,
bool
has_prelocking_list
,
Open_table_context
*
ot_ctx
,
bool
has_prelocking_list
,
Open_table_context
*
ot_ctx
,
MEM_ROOT
*
new_frm_mem
)
{
bool
error
=
FALSE
;
bool
safe_to_ignore_table
=
FALSE
;
LEX
*
lex
=
thd
->
lex
;
DBUG_ENTER
(
"open_and_process_table"
);
DEBUG_SYNC
(
thd
,
"open_and_process_table"
);
...
...
@@ -4654,38 +4692,9 @@ open_and_process_table(THD *thd, LEX *lex, TABLE_LIST *tables,
if
(
tables
->
open_strategy
&&
!
tables
->
table
)
goto
end
;
/*
If we are not already in prelocked mode and extended table list is not
yet built we might have to build the prelocking set for this statement.
Since currently no prelocking strategy prescribes doing anything for
tables which are only read, we do below checks only if table is going
to be changed.
*/
if
(
thd
->
locked_tables_mode
<=
LTM_LOCK_TABLES
&&
!
has_prelocking_list
&&
tables
->
lock_type
>=
TL_WRITE_ALLOW_WRITE
)
{
bool
need_prelocking
=
FALSE
;
TABLE_LIST
**
save_query_tables_last
=
lex
->
query_tables_last
;
/*
Extend statement's table list and the prelocking set with
tables and routines according to the current prelocking
strategy.
For example, for DML statements we need to add tables and routines
used by triggers which are going to be invoked for this element of
table list and also add tables required for handling of foreign keys.
*/
error
=
prelocking_strategy
->
handle_table
(
thd
,
lex
,
tables
,
&
need_prelocking
);
if
(
need_prelocking
&&
!
lex
->
requires_prelocking
())
lex
->
mark_as_requiring_prelocking
(
save_query_tables_last
);
if
(
error
)
goto
end
;
}
error
=
extend_table_list
(
thd
,
tables
,
prelocking_strategy
,
has_prelocking_list
);
if
(
error
)
goto
end
;
if
(
tables
->
lock_type
!=
TL_UNLOCK
&&
!
thd
->
locked_tables_mode
)
{
...
...
@@ -4994,8 +5003,9 @@ open_tables_check_upgradable_mdl(THD *thd, TABLE_LIST *tables_start,
@retval TRUE Error, reported.
*/
bool
open_tables
(
THD
*
thd
,
TABLE_LIST
**
start
,
uint
*
counter
,
uint
flags
,
Prelocking_strategy
*
prelocking_strategy
)
bool
open_tables
(
THD
*
thd
,
TABLE_LIST
**
start
,
uint
*
counter
,
Sroutine_hash_entry
**
sroutine_to_open_list
,
uint
flags
,
Prelocking_strategy
*
prelocking_strategy
)
{
/*
We use pointers to "next_global" member in the last processed TABLE_LIST
...
...
@@ -5043,7 +5053,7 @@ bool open_tables(THD *thd, TABLE_LIST **start, uint *counter, uint flags,
has_prelocking_list
=
thd
->
lex
->
requires_prelocking
();
table_to_open
=
start
;
sroutine_to_open
=
(
Sroutine_hash_entry
**
)
&
thd
->
lex
->
sroutines_list
.
fir
st
;
sroutine_to_open
=
sroutine_to_open_li
st
;
*
counter
=
0
;
thd_proc_info
(
thd
,
"Opening tables"
);
...
...
@@ -5112,10 +5122,9 @@ bool open_tables(THD *thd, TABLE_LIST **start, uint *counter, uint flags,
for
(
tables
=
*
table_to_open
;
tables
;
table_to_open
=
&
tables
->
next_global
,
tables
=
tables
->
next_global
)
{
error
=
open_and_process_table
(
thd
,
thd
->
lex
,
tables
,
counter
,
flags
,
prelocking_strategy
,
has_prelocking_list
,
&
ot_ctx
,
&
new_frm_mem
);
error
=
open_and_process_table
(
thd
,
tables
,
counter
,
flags
,
prelocking_strategy
,
has_prelocking_list
,
&
ot_ctx
,
&
new_frm_mem
);
if
(
error
)
{
...
...
sql/sql_base.h
View file @
66099b8f
...
...
@@ -276,7 +276,8 @@ int init_ftfuncs(THD *thd, SELECT_LEX* select, bool no_order);
bool
lock_table_names
(
THD
*
thd
,
TABLE_LIST
*
table_list
,
TABLE_LIST
*
table_list_end
,
ulong
lock_wait_timeout
,
uint
flags
);
bool
open_tables
(
THD
*
thd
,
TABLE_LIST
**
tables
,
uint
*
counter
,
uint
flags
,
bool
open_tables
(
THD
*
thd
,
TABLE_LIST
**
tables
,
uint
*
counter
,
Sroutine_hash_entry
**
sroutine_to_open
,
uint
flags
,
Prelocking_strategy
*
prelocking_strategy
);
/* open_and_lock_tables with optional derived handling */
bool
open_and_lock_tables
(
THD
*
thd
,
TABLE_LIST
*
tables
,
...
...
@@ -498,6 +499,15 @@ class Alter_table_prelocking_strategy : public Prelocking_strategy
};
inline
bool
open_tables
(
THD
*
thd
,
TABLE_LIST
**
tables
,
uint
*
counter
,
uint
flags
,
Prelocking_strategy
*
prelocking_strategy
)
{
return
open_tables
(
thd
,
tables
,
counter
,
&
thd
->
lex
->
sroutines_list
.
first
,
flags
,
prelocking_strategy
);
}
inline
bool
open_tables
(
THD
*
thd
,
TABLE_LIST
**
tables
,
uint
*
counter
,
uint
flags
)
{
...
...
@@ -528,6 +538,10 @@ inline bool open_and_lock_tables(THD *thd, TABLE_LIST *tables,
}
bool
extend_table_list
(
THD
*
thd
,
TABLE_LIST
*
tables
,
Prelocking_strategy
*
prelocking_strategy
,
bool
has_prelocking_list
);
/**
A context of open_tables() function, used to recover
from a failed open_table() or open_routine() attempt.
...
...
sql/sql_yacc.yy
View file @
66099b8f
...
...
@@ -11159,14 +11159,14 @@ update:
opt_low_priority opt_ignore join_table_list
SET update_list
{
LEX *lex= L
ex;
if (
lex->select_lex.
table_list.elements > 1)
l
ex->sql_command= SQLCOM_UPDATE_MULTI;
else if (
lex->select_lex.
get_table_list()->derived)
SELECT_LEX *slex= &Lex->select_l
ex;
if (
slex->
table_list.elements > 1)
L
ex->sql_command= SQLCOM_UPDATE_MULTI;
else if (
slex->
get_table_list()->derived)
{
/* it is single table update and it is update of derived table */
my_error(ER_NON_UPDATABLE_TABLE, MYF(0),
lex->select_lex.
get_table_list()->alias, "UPDATE");
slex->
get_table_list()->alias, "UPDATE");
MYSQL_YYABORT;
}
/*
...
...
@@ -11174,7 +11174,7 @@ update:
be too pessimistic. We will decrease lock level if possible in
mysql_multi_update().
*/
Select
->set_lock_for_tables($3);
slex
->set_lock_for_tables($3);
}
where_clause opt_order_clause delete_limit_clause {}
;
...
...
@@ -13834,13 +13834,16 @@ table_lock:
table_ident opt_table_alias lock_option
{
thr_lock_type lock_type= (thr_lock_type) $3;
bool lock_for_write= (lock_type >= TL_WRITE_ALLOW_WRITE);
if (!Select->add_table_to_list(thd, $1, $2, 0, lock_type,
(lock_for_write ?
lock_type == TL_WRITE_CONCURRENT_INSERT ?
MDL_SHARED_WRITE :
MDL_SHARED_NO_READ_WRITE :
MDL_SHARED_READ)))
bool lock_for_write= lock_type >= TL_WRITE_ALLOW_WRITE;
ulong table_options= 0;
enum_mdl_type mdl_type= !lock_for_write
? MDL_SHARED_READ
: lock_type == TL_WRITE_CONCURRENT_INSERT
? MDL_SHARED_WRITE
: MDL_SHARED_NO_READ_WRITE;
if (!Select->add_table_to_list(thd, $1, $2, table_options,
lock_type, mdl_type))
MYSQL_YYABORT;
}
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment