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
52a25d7b
Commit
52a25d7b
authored
Jun 28, 2018
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-16473 WITH statement throws 'no database selected' error
Different fix, just use NULL, not no_db,
parent
090febbb
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
13 additions
and
45 deletions
+13
-45
mysql-test/r/cte_nonrecursive.result
mysql-test/r/cte_nonrecursive.result
+0
-11
mysql-test/t/cte_nonrecursive.test
mysql-test/t/cte_nonrecursive.test
+0
-7
sql/sql_acl.cc
sql/sql_acl.cc
+1
-1
sql/sql_base.cc
sql/sql_base.cc
+6
-8
sql/sql_class.h
sql/sql_class.h
+3
-6
sql/sql_lex.h
sql/sql_lex.h
+0
-2
sql/sql_parse.cc
sql/sql_parse.cc
+2
-8
sql/table.h
sql/table.h
+1
-2
No files found.
mysql-test/r/cte_nonrecursive.result
View file @
52a25d7b
...
...
@@ -1511,15 +1511,4 @@ a a
3 3
1 1
drop database db_mdev_16473;
create database `*` ;
create table `*`.t1 (a int);
insert into `*`.t1 values (2), (7), (3), (1);
use `*`;
select * from t1;
a
2
7
3
1
drop database `*`;
use test;
mysql-test/t/cte_nonrecursive.test
View file @
52a25d7b
...
...
@@ -1056,11 +1056,4 @@ select * from cte, db_mdev_16473.t1 as t where cte.a=t.a;
drop
database
db_mdev_16473
;
create
database
`*`
;
create
table
`*`
.
t1
(
a
int
);
insert
into
`*`
.
t1
values
(
2
),
(
7
),
(
3
),
(
1
);
use
`*`
;
select
*
from
t1
;
drop
database
`*`
;
use
test
;
sql/sql_acl.cc
View file @
52a25d7b
...
...
@@ -7581,7 +7581,7 @@ bool check_grant(THD *thd, ulong want_access, TABLE_LIST *tables,
tl
->
correspondent_table
?
tl
->
correspondent_table
:
tl
;
sctx
=
t_ref
->
security_ctx
?
t_ref
->
security_ctx
:
thd
->
security_ctx
;
if
(
tl
->
with
||
if
(
tl
->
with
||
!
tl
->
db
||
(
tl
->
select_lex
&&
(
tl
->
with
=
tl
->
select_lex
->
find_table_def_in_with_clauses
(
tl
))))
continue
;
...
...
sql/sql_base.cc
View file @
52a25d7b
...
...
@@ -1531,6 +1531,12 @@ bool open_table(THD *thd, TABLE_LIST *table_list, Open_table_context *ot_ctx)
DBUG_RETURN
(
true
);
}
if
(
!
table_list
->
db
)
{
my_error
(
ER_NO_DB_ERROR
,
MYF
(
0
));
DBUG_RETURN
(
true
);
}
key_length
=
get_table_def_key
(
table_list
,
&
key
);
/*
...
...
@@ -3330,14 +3336,6 @@ open_and_process_table(THD *thd, LEX *lex, TABLE_LIST *tables,
/*
Not a placeholder: must be a base/temporary table or a view. Let us open it.
*/
if
(
tables
->
no_default_db
&&
!
tables
->
is_fqtn
)
{
my_message
(
ER_NO_DB_ERROR
,
ER
(
ER_NO_DB_ERROR
),
MYF
(
0
));
error
=
TRUE
;
goto
end
;
}
if
(
tables
->
table
)
{
/*
...
...
sql/sql_class.h
View file @
52a25d7b
...
...
@@ -3959,12 +3959,9 @@ class THD :public Statement,
my_message
(
ER_NO_DB_ERROR
,
ER
(
ER_NO_DB_ERROR
),
MYF
(
0
));
return
TRUE
;
}
/*
It does not matter what database name is set in this case
because it will never be used after parser stage
*/
*
p_db_length
=
strlen
(
no_db
);
*
p_db
=
strmake
(
no_db
,
*
p_db_length
);
/* This will allow to throw an error later for non-CTE references */
*
p_db
=
NULL
;
*
p_db_length
=
0
;
}
else
{
...
...
sql/sql_lex.h
View file @
52a25d7b
...
...
@@ -156,8 +156,6 @@ struct LEX_TYPE
extern
const
LEX_STRING
null_lex_str
;
extern
const
LEX_STRING
empty_lex_str
;
extern
const
char
*
no_db
;
enum
enum_sp_suid_behaviour
{
SP_IS_DEFAULT_SUID
=
0
,
...
...
sql/sql_parse.cc
View file @
52a25d7b
...
...
@@ -139,7 +139,6 @@ static bool execute_show_status(THD *, TABLE_LIST *);
static
bool
check_rename_table
(
THD
*
,
TABLE_LIST
*
,
TABLE_LIST
*
);
const
char
*
any_db
=
"*any*"
;
// Special symbol for check_access
const
char
*
no_db
=
"*"
;
// Used when no default db is set
const
LEX_STRING
command_name
[
257
]
=
{
{
C_STRING_WITH_LEN
(
"Sleep"
)
},
//0
...
...
@@ -6685,11 +6684,7 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv,
THD_STAGE_INFO
(
thd
,
stage_checking_permissions
);
if
((
!
db
||
!
db
[
0
])
&&
!
thd
->
db
&&
!
dont_check_global_grants
)
{
DBUG_PRINT
(
"error"
,(
"No database"
));
if
(
!
no_errors
)
my_message
(
ER_NO_DB_ERROR
,
ER_THD
(
thd
,
ER_NO_DB_ERROR
),
MYF
(
0
));
/* purecov: tested */
DBUG_RETURN
(
TRUE
);
/* purecov: tested */
DBUG_RETURN
(
FALSE
);
// CTE reference or an error later
}
if
((
db
!=
NULL
)
&&
(
db
!=
any_db
))
...
...
@@ -8188,7 +8183,6 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
DBUG_RETURN
(
0
);
else
ptr
->
is_fqtn
=
FALSE
;
ptr
->
no_default_db
=
!
thd
->
db
&&
!
(
lex
->
sphead
&&
lex
->
sphead
->
m_name
.
str
);
ptr
->
alias
=
alias_str
;
ptr
->
is_alias
=
alias
?
TRUE
:
FALSE
;
...
...
@@ -8301,7 +8295,7 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
lex
->
add_to_query_tables
(
ptr
);
// Pure table aliases do not need to be locked:
if
(
!
MY_TEST
(
table_options
&
TL_OPTION_ALIAS
))
if
(
ptr
->
db
&&
!
(
table_options
&
TL_OPTION_ALIAS
))
{
ptr
->
mdl_request
.
init
(
MDL_key
::
TABLE
,
ptr
->
db
,
ptr
->
table_name
,
mdl_type
,
MDL_TRANSACTION
);
...
...
sql/table.h
View file @
52a25d7b
...
...
@@ -2095,8 +2095,7 @@ struct TABLE_LIST
qualified name (<db_name>.<table_name>).
*/
bool
is_fqtn
;
/** TRUE if no default database is defined for the table name */
bool
no_default_db
;
/* TRUE <=> derived table should be filled right after optimization. */
bool
fill_me
;
/* TRUE <=> view/DT is merged. */
...
...
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