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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
552d3309
Commit
552d3309
authored
Jan 27, 2016
by
Alexey Botchkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-5273 Prepared statement doesn't return metadata after prepare.
Fix for SHOW GRANTS statement.
parent
f3926cd1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
4 deletions
+52
-4
sql/sql_acl.cc
sql/sql_acl.cc
+13
-4
sql/sql_acl.h
sql/sql_acl.h
+2
-0
sql/sql_prepare.cc
sql/sql_prepare.cc
+30
-0
tests/mysql_client_test.c
tests/mysql_client_test.c
+7
-0
No files found.
sql/sql_acl.cc
View file @
552d3309
...
...
@@ -7740,6 +7740,16 @@ static int show_grants_callback(ACL_USER_BASE *role, void *data)
}
void
mysql_show_grants_get_fields
(
THD
*
thd
,
List
<
Item
>
*
fields
,
const
char
*
name
)
{
Item_string
*
field
=
new
(
thd
->
mem_root
)
Item_string_ascii
(
thd
,
""
,
0
);
field
->
name
=
(
char
*
)
name
;
field
->
max_length
=
1024
;
fields
->
push_back
(
field
,
thd
->
mem_root
);
}
/*
SHOW GRANTS; Send grants for a user to the client
...
...
@@ -7805,15 +7815,14 @@ bool mysql_show_grants(THD *thd, LEX_USER *lex_user)
}
DBUG_ASSERT
(
rolename
||
username
);
Item_string
*
field
=
new
(
thd
->
mem_root
)
Item_string_ascii
(
thd
,
""
,
0
);
List
<
Item
>
field_list
;
field
->
name
=
buff
;
field
->
max_length
=
1024
;
if
(
!
username
)
strxmov
(
buff
,
"Grants for "
,
rolename
,
NullS
);
else
strxmov
(
buff
,
"Grants for "
,
username
,
"@"
,
hostname
,
NullS
);
field_list
.
push_back
(
field
,
thd
->
mem_root
);
mysql_show_grants_get_fields
(
thd
,
&
field_list
,
buff
);
if
(
protocol
->
send_result_set_metadata
(
&
field_list
,
Protocol
::
SEND_NUM_ROWS
|
Protocol
::
SEND_EOF
))
...
...
sql/sql_acl.h
View file @
552d3309
...
...
@@ -241,6 +241,8 @@ ulong get_table_grant(THD *thd, TABLE_LIST *table);
ulong
get_column_grant
(
THD
*
thd
,
GRANT_INFO
*
grant
,
const
char
*
db_name
,
const
char
*
table_name
,
const
char
*
field_name
);
void
mysql_show_grants_get_fields
(
THD
*
thd
,
List
<
Item
>
*
fields
,
const
char
*
name
);
bool
mysql_show_grants
(
THD
*
thd
,
LEX_USER
*
user
);
int
fill_schema_enabled_roles
(
THD
*
thd
,
TABLE_LIST
*
tables
,
COND
*
cond
);
int
fill_schema_applicable_roles
(
THD
*
thd
,
TABLE_LIST
*
tables
,
COND
*
cond
);
...
...
sql/sql_prepare.cc
View file @
552d3309
...
...
@@ -1869,6 +1869,29 @@ static bool mysql_test_show_create_db(Prepared_statement *stmt)
}
/**
Validate and prepare for execution SHOW GRANTS statement.
@param stmt prepared statement
@retval
FALSE success
@retval
TRUE error, error message is set in THD
*/
static
bool
mysql_test_show_grants
(
Prepared_statement
*
stmt
)
{
DBUG_ENTER
(
"mysql_test_show_grants"
);
THD
*
thd
=
stmt
->
thd
;
List
<
Item
>
fields
;
mysql_show_grants_get_fields
(
thd
,
&
fields
,
"Grants for"
);
DBUG_RETURN
(
send_stmt_metadata
(
thd
,
stmt
,
&
fields
));
}
/**
@brief Validate and prepare for execution CREATE VIEW statement
...
...
@@ -2216,6 +2239,13 @@ static bool check_prepared_statement(Prepared_statement *stmt)
DBUG_RETURN
(
FALSE
);
}
break
;
case
SQLCOM_SHOW_GRANTS
:
if
(
!
(
res
=
mysql_test_show_grants
(
stmt
)))
{
/* Statement and field info has already been sent */
DBUG_RETURN
(
FALSE
);
}
break
;
case
SQLCOM_CREATE_VIEW
:
if
(
lex
->
create_view_mode
==
VIEW_ALTER
)
{
...
...
tests/mysql_client_test.c
View file @
552d3309
...
...
@@ -436,6 +436,13 @@ static void test_prepare_simple()
DIE_UNLESS
(
mysql_stmt_field_count
(
stmt
)
==
2
);
mysql_stmt_close
(
stmt
);
/* show grants */
strmov
(
query
,
"SHOW GRANTS"
);
stmt
=
mysql_simple_prepare
(
mysql
,
query
);
check_stmt
(
stmt
);
DIE_UNLESS
(
mysql_stmt_field_count
(
stmt
)
==
1
);
mysql_stmt_close
(
stmt
);
/* now fetch the results ..*/
rc
=
mysql_commit
(
mysql
);
myquery
(
rc
);
...
...
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