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
7cc507f2
Commit
7cc507f2
authored
Jan 23, 2018
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-14603 signal 11 with short stacktrace
parent
87db5eb8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
179 additions
and
0 deletions
+179
-0
mysql-test/r/ps.result
mysql-test/r/ps.result
+42
-0
mysql-test/t/ps.test
mysql-test/t/ps.test
+57
-0
sql/sql_class.h
sql/sql_class.h
+19
-0
sql/sql_prepare.cc
sql/sql_prepare.cc
+61
-0
No files found.
mysql-test/r/ps.result
View file @
7cc507f2
...
...
@@ -5121,3 +5121,45 @@ END;
$$
ERROR 22007: Incorrect datetime value: '10' for column 'a' at row 1
DROP PROCEDURE p1;
#
# MDEV-14603 signal 11 with short stacktrace
#
SET NAMES utf8;
CREATE TABLE t1(i INT);
CREATE PROCEDURE p1(tn VARCHAR(32))
EXECUTE IMMEDIATE CONCAT('ANALYZE TABLE ',tn);
CALL p1('t1');
Table Op Msg_type Msg_text
test.t1 analyze status Table is already up to date
DROP PROCEDURE p1;
DROP TABLE t1;
SET NAMES utf8;
CREATE PROCEDURE p1()
EXECUTE IMMEDIATE CONCAT('SELECT ',CONVERT(RAND() USING latin1));
CALL p1();
DROP PROCEDURE p1;
SET NAMES utf8;
CREATE PROCEDURE p1()
BEGIN
PREPARE stmt FROM CONCAT('SELECT ',CONVERT(RAND() USING latin1));
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
END;
$$
CALL p1();
DROP PROCEDURE p1;
SET NAMES utf8;
CREATE PROCEDURE p1(a VARCHAR(10) CHARACTER SET utf8)
EXECUTE IMMEDIATE 'SELECT ?' USING CONCAT(a, CONVERT(RAND() USING latin1));
CALL p1('x');
DROP PROCEDURE p1;
SET NAMES utf8;
CREATE PROCEDURE p1(a VARCHAR(10) CHARACTER SET utf8)
BEGIN
PREPARE stmt FROM 'SELECT ?';
EXECUTE stmt USING CONCAT(a, CONVERT(RAND() USING latin1));
DEALLOCATE PREPARE stmt;
END;
$$
CALL p1('x');
DROP PROCEDURE p1;
mysql-test/t/ps.test
View file @
7cc507f2
...
...
@@ -4578,3 +4578,60 @@ END;
$$
DELIMITER
;
$$
DROP
PROCEDURE
p1
;
--
echo
#
--
echo
# MDEV-14603 signal 11 with short stacktrace
--
echo
#
SET
NAMES
utf8
;
CREATE
TABLE
t1
(
i
INT
);
CREATE
PROCEDURE
p1
(
tn
VARCHAR
(
32
))
EXECUTE
IMMEDIATE
CONCAT
(
'ANALYZE TABLE '
,
tn
);
CALL
p1
(
't1'
);
DROP
PROCEDURE
p1
;
DROP
TABLE
t1
;
SET
NAMES
utf8
;
CREATE
PROCEDURE
p1
()
EXECUTE
IMMEDIATE
CONCAT
(
'SELECT '
,
CONVERT
(
RAND
()
USING
latin1
));
--
disable_result_log
CALL
p1
();
--
enable_result_log
DROP
PROCEDURE
p1
;
SET
NAMES
utf8
;
DELIMITER
$$
;
CREATE
PROCEDURE
p1
()
BEGIN
PREPARE
stmt
FROM
CONCAT
(
'SELECT '
,
CONVERT
(
RAND
()
USING
latin1
));
EXECUTE
stmt
;
DEALLOCATE
PREPARE
stmt
;
END
;
$$
DELIMITER
;
$$
--
disable_result_log
CALL
p1
();
--
enable_result_log
DROP
PROCEDURE
p1
;
SET
NAMES
utf8
;
CREATE
PROCEDURE
p1
(
a
VARCHAR
(
10
)
CHARACTER
SET
utf8
)
EXECUTE
IMMEDIATE
'SELECT ?'
USING
CONCAT
(
a
,
CONVERT
(
RAND
()
USING
latin1
));
--
disable_result_log
CALL
p1
(
'x'
);
--
enable_result_log
DROP
PROCEDURE
p1
;
SET
NAMES
utf8
;
DELIMITER
$$
;
CREATE
PROCEDURE
p1
(
a
VARCHAR
(
10
)
CHARACTER
SET
utf8
)
BEGIN
PREPARE
stmt
FROM
'SELECT ?'
;
EXECUTE
stmt
USING
CONCAT
(
a
,
CONVERT
(
RAND
()
USING
latin1
));
DEALLOCATE
PREPARE
stmt
;
END
;
$$
DELIMITER
;
$$
--
disable_result_log
CALL
p1
(
'x'
);
DROP
PROCEDURE
p1
;
sql/sql_class.h
View file @
7cc507f2
...
...
@@ -1296,6 +1296,25 @@ class Item_change_list
};
class
Item_change_list_savepoint
:
public
Item_change_list
{
public:
Item_change_list_savepoint
(
Item_change_list
*
list
)
{
list
->
move_elements_to
(
this
);
}
void
rollback
(
Item_change_list
*
list
)
{
list
->
rollback_item_tree_changes
();
move_elements_to
(
list
);
}
~
Item_change_list_savepoint
()
{
DBUG_ASSERT
(
is_empty
());
}
};
/**
Type of locked tables mode.
See comment for THD::locked_tables_mode for complete description.
...
...
sql/sql_prepare.cc
View file @
7cc507f2
...
...
@@ -2823,6 +2823,25 @@ void mysql_sql_stmt_prepare(THD *thd)
DBUG_VOID_RETURN
;
}
/*
Make sure we call Prepared_statement::prepare() with an empty
THD::change_list. It can be non-empty as LEX::get_dynamic_sql_string()
calls fix_fields() for the Item containing the PS source,
e.g. on character set conversion:
SET NAMES utf8;
DELIMITER $$
CREATE PROCEDURE p1()
BEGIN
PREPARE stmt FROM CONCAT('SELECT ',CONVERT(RAND() USING latin1));
EXECUTE stmt;
END;
$$
DELIMITER ;
CALL p1();
*/
Item_change_list_savepoint
change_list_savepoint
(
thd
);
if
(
stmt
->
prepare
(
query
.
str
,
(
uint
)
query
.
length
))
{
/* Statement map deletes the statement on erase */
...
...
@@ -2833,6 +2852,7 @@ void mysql_sql_stmt_prepare(THD *thd)
SESSION_TRACKER_CHANGED
(
thd
,
SESSION_STATE_CHANGE_TRACKER
,
NULL
);
my_ok
(
thd
,
0L
,
0L
,
"Statement prepared"
);
}
change_list_savepoint
.
rollback
(
thd
);
DBUG_VOID_RETURN
;
}
...
...
@@ -2864,7 +2884,28 @@ void mysql_sql_stmt_execute_immediate(THD *thd)
// See comments on thd->free_list in mysql_sql_stmt_execute()
Item
*
free_list_backup
=
thd
->
free_list
;
thd
->
free_list
=
NULL
;
/*
Make sure we call Prepared_statement::execute_immediate()
with an empty THD::change_list. It can be non empty as the above
LEX::prepared_stmt_params_fix_fields() and LEX::get_dynamic_str_string()
call fix_fields() for the PS source and PS parameter Items and
can do Item tree changes, e.g. on character set conversion:
- Example #1: Item tree changes in get_dynamic_str_string()
SET NAMES utf8;
CREATE PROCEDURE p1()
EXECUTE IMMEDIATE CONCAT('SELECT ',CONVERT(RAND() USING latin1));
CALL p1();
- Example #2: Item tree changes in prepared_stmt_param_fix_fields():
SET NAMES utf8;
CREATE PROCEDURE p1(a VARCHAR(10) CHARACTER SET utf8)
EXECUTE IMMEDIATE 'SELECT ?' USING CONCAT(a, CONVERT(RAND() USING latin1));
CALL p1('x');
*/
Item_change_list_savepoint
change_list_savepoint
(
thd
);
(
void
)
stmt
->
execute_immediate
(
query
.
str
,
(
uint
)
query
.
length
);
change_list_savepoint
.
rollback
(
thd
);
thd
->
free_items
();
thd
->
free_list
=
free_list_backup
;
...
...
@@ -3262,7 +3303,27 @@ void mysql_sql_stmt_execute(THD *thd)
*/
Item
*
free_list_backup
=
thd
->
free_list
;
thd
->
free_list
=
NULL
;
// Hide the external (e.g. "SET STATEMENT") Items
/*
Make sure we call Prepared_statement::execute_loop() with an empty
THD::change_list. It can be non-empty because the above
LEX::prepared_stmt_params_fix_fields() calls fix_fields() for
the PS parameter Items and can do some Item tree changes,
e.g. on character set conversion:
SET NAMES utf8;
DELIMITER $$
CREATE PROCEDURE p1(a VARCHAR(10) CHARACTER SET utf8)
BEGIN
PREPARE stmt FROM 'SELECT ?';
EXECUTE stmt USING CONCAT(a, CONVERT(RAND() USING latin1));
END;
$$
DELIMITER ;
CALL p1('x');
*/
Item_change_list_savepoint
change_list_savepoint
(
thd
);
(
void
)
stmt
->
execute_loop
(
&
expanded_query
,
FALSE
,
NULL
,
NULL
);
change_list_savepoint
.
rollback
(
thd
);
thd
->
free_items
();
// Free items created by execute_loop()
/*
Now restore the "external" (e.g. "SET STATEMENT") Item list.
...
...
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