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
f3926cd1
Commit
f3926cd1
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 CREATE DATABASE.
parent
07e97629
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
63 additions
and
26 deletions
+63
-26
sql/sql_prepare.cc
sql/sql_prepare.cc
+40
-17
sql/sql_show.cc
sql/sql_show.cc
+16
-8
sql/sql_show.h
sql/sql_show.h
+1
-0
tests/mysql_client_test.c
tests/mysql_client_test.c
+6
-1
No files found.
sql/sql_prepare.cc
View file @
f3926cd1
...
...
@@ -1812,6 +1812,14 @@ static bool mysql_test_create_table(Prepared_statement *stmt)
}
static
bool
send_stmt_metadata
(
THD
*
thd
,
Prepared_statement
*
stmt
,
List
<
Item
>
*
fields
)
{
return
send_prep_stmt
(
stmt
,
fields
->
elements
)
||
thd
->
protocol
->
send_result_set_metadata
(
fields
,
Protocol
::
SEND_EOF
)
||
thd
->
protocol
->
flush
();
}
/**
Validate and prepare for execution SHOW CREATE TABLE statement.
...
...
@@ -1824,7 +1832,7 @@ static bool mysql_test_create_table(Prepared_statement *stmt)
TRUE error, error message is set in THD
*/
static
int
mysql_test_show_create_table
(
Prepared_statement
*
stmt
,
static
bool
mysql_test_show_create_table
(
Prepared_statement
*
stmt
,
TABLE_LIST
*
tables
)
{
DBUG_ENTER
(
"mysql_test_show_create_table"
);
...
...
@@ -1833,22 +1841,31 @@ static int mysql_test_show_create_table(Prepared_statement *stmt,
char
buff
[
2048
];
String
buffer
(
buff
,
sizeof
(
buff
),
system_charset_info
);
if
(
mysqld_show_create_get_fields
(
thd
,
tables
,
&
fields
,
&
buffer
))
goto
err_exit
;
if
(
!
stmt
->
is_sql_prepare
())
{
if
(
send_prep_stmt
(
stmt
,
fields
.
elements
)
||
thd
->
protocol
->
send_result_set_metadata
(
&
fields
,
Protocol
::
SEND_EOF
)
||
thd
->
protocol
->
flush
())
goto
err_exit
;
DBUG_RETURN
(
mysqld_show_create_get_fields
(
thd
,
tables
,
&
fields
,
&
buffer
)
||
send_stmt_metadata
(
thd
,
stmt
,
&
fields
));
}
DBUG_RETURN
(
2
);
}
DBUG_RETURN
(
0
);
err_exit:
DBUG_RETURN
(
1
);
/**
Validate and prepare for execution SHOW CREATE DATABASE statement.
@param stmt prepared statement
@retval
FALSE success
@retval
TRUE error, error message is set in THD
*/
static
bool
mysql_test_show_create_db
(
Prepared_statement
*
stmt
)
{
DBUG_ENTER
(
"mysql_test_show_create_db"
);
THD
*
thd
=
stmt
->
thd
;
List
<
Item
>
fields
;
mysqld_show_create_db_get_fields
(
thd
,
&
fields
);
DBUG_RETURN
(
send_stmt_metadata
(
thd
,
stmt
,
&
fields
));
}
...
...
@@ -2186,8 +2203,14 @@ static bool check_prepared_statement(Prepared_statement *stmt)
res
=
mysql_test_create_table
(
stmt
);
break
;
case
SQLCOM_SHOW_CREATE
:
res
=
mysql_test_show_create_table
(
stmt
,
tables
);
if
(
res
==
2
)
if
(
!
(
res
=
mysql_test_show_create_table
(
stmt
,
tables
)))
{
/* Statement and field info has already been sent */
DBUG_RETURN
(
FALSE
);
}
break
;
case
SQLCOM_SHOW_CREATE_DB
:
if
(
!
(
res
=
mysql_test_show_create_db
(
stmt
)))
{
/* Statement and field info has already been sent */
DBUG_RETURN
(
FALSE
);
...
...
sql/sql_show.cc
View file @
f3926cd1
...
...
@@ -1272,6 +1272,19 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
DBUG_RETURN
(
error
);
}
void
mysqld_show_create_db_get_fields
(
THD
*
thd
,
List
<
Item
>
*
field_list
)
{
MEM_ROOT
*
mem_root
=
thd
->
mem_root
;
field_list
->
push_back
(
new
(
mem_root
)
Item_empty_string
(
thd
,
"Database"
,
NAME_CHAR_LEN
),
mem_root
);
field_list
->
push_back
(
new
(
mem_root
)
Item_empty_string
(
thd
,
"Create Database"
,
1024
),
mem_root
);
}
bool
mysqld_show_create_db
(
THD
*
thd
,
LEX_STRING
*
dbname
,
LEX_STRING
*
orig_dbname
,
const
DDL_options_st
&
options
)
...
...
@@ -1284,7 +1297,7 @@ bool mysqld_show_create_db(THD *thd, LEX_STRING *dbname,
#endif
Schema_specification_st
create
;
Protocol
*
protocol
=
thd
->
protocol
;
MEM_ROOT
*
mem_root
=
thd
->
mem_roo
t
;
List
<
Item
>
field_lis
t
;
DBUG_ENTER
(
"mysql_show_create_db"
);
#ifndef NO_EMBEDDED_ACCESS_CHECKS
...
...
@@ -1318,13 +1331,8 @@ bool mysqld_show_create_db(THD *thd, LEX_STRING *dbname,
load_db_opt_by_name
(
thd
,
dbname
->
str
,
&
create
);
}
List
<
Item
>
field_list
;
field_list
.
push_back
(
new
(
mem_root
)
Item_empty_string
(
thd
,
"Database"
,
NAME_CHAR_LEN
),
mem_root
);
field_list
.
push_back
(
new
(
mem_root
)
Item_empty_string
(
thd
,
"Create Database"
,
1024
),
mem_root
);
mysqld_show_create_db_get_fields
(
thd
,
&
field_list
);
if
(
protocol
->
send_result_set_metadata
(
&
field_list
,
Protocol
::
SEND_NUM_ROWS
|
...
...
sql/sql_show.h
View file @
f3926cd1
...
...
@@ -88,6 +88,7 @@ int mysqld_dump_create_info(THD *thd, TABLE_LIST *table_list, int fd);
bool
mysqld_show_create_get_fields
(
THD
*
thd
,
TABLE_LIST
*
table_list
,
List
<
Item
>
*
field_list
,
String
*
buffer
);
bool
mysqld_show_create
(
THD
*
thd
,
TABLE_LIST
*
table_list
);
void
mysqld_show_create_db_get_fields
(
THD
*
thd
,
List
<
Item
>
*
field_list
);
bool
mysqld_show_create_db
(
THD
*
thd
,
LEX_STRING
*
db_name
,
LEX_STRING
*
orig_db_name
,
const
DDL_options_st
&
options
);
...
...
tests/mysql_client_test.c
View file @
f3926cd1
...
...
@@ -426,9 +426,14 @@ static void test_prepare_simple()
strmov
(
query
,
"SHOW CREATE TABLE test_prepare_simple"
);
stmt
=
mysql_simple_prepare
(
mysql
,
query
);
check_stmt
(
stmt
);
DIE_UNLESS
(
mysql_stmt_field_count
(
stmt
)
==
2
);
mysql_stmt_close
(
stmt
);
/* show create database */
strmov
(
query
,
"SHOW CREATE DATABASE test"
);
stmt
=
mysql_simple_prepare
(
mysql
,
query
);
check_stmt
(
stmt
);
DIE_UNLESS
(
mysql_stmt_field_count
(
stmt
)
==
2
);
mysql_stmt_close
(
stmt
);
/* now fetch the results ..*/
...
...
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