Commit ee878504 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-16708: Unsupported commands for prepared statements

Follow-up patch for the bug MDEV-25197 that fixes missed restoring
of thd->cur_stmt on returning error code.

Developed by Dmitry Shulga.

This fixes up the merge d2e2d329
and closes MDEV-25413.
parent 6729dd89
......@@ -5568,4 +5568,38 @@ ERROR 42S02: Table 'test.x' doesn't exist
DEALLOCATE PREPARE stmt;
DROP VIEW v1;
DROP TABLE t1;
# MDEV-25413 FIXME: enable the MDEV-25197 test
#
# MDEV-25197: The statement set password=password('') executed in PS mode
# fails in case it is run by a user with expired password
#
CREATE USER user1@localhost PASSWORD EXPIRE;
SET @disconnect_on_expired_password_save=@@global.disconnect_on_expired_password;
SET GLOBAL disconnect_on_expired_password=OFF;
connect con1,localhost,user1;
connection con1;
# Check that no regular statement like SELECT can be prepared
# by a user with an expired password
PREPARE stmt FROM "SELECT 1";
ERROR HY000: You must SET PASSWORD before executing this statement
# Check that the DEALLOCATE PREPARE statement can be run by a user
# with an expired password
PREPARE stmt FROM "SET password=password('')";
DEALLOCATE PREPARE stmt;
# Check that the SET PASSWORD statement can be executed in PS mode by
# a user with an expired password
PREPARE stmt FROM "SET password=password('')";
EXECUTE stmt;
PREPARE stmt FROM "SELECT 1";
# Check that user's password is not expired anymore
EXECUTE stmt;
1
1
DEALLOCATE PREPARE stmt;
# Clean up
disconnect con1;
connection default;
SET GLOBAL disconnect_on_expired_password=@disconnect_on_expired_password_save;
DROP USER user1@localhost;
#
# End of 10.4 tests
#
......@@ -4999,9 +4999,6 @@ DEALLOCATE PREPARE stmt;
DROP VIEW v1;
DROP TABLE t1;
--echo # MDEV-25413 FIXME: enable the MDEV-25197 test
--exit
--echo #
--echo # MDEV-25197: The statement set password=password('') executed in PS mode
--echo # fails in case it is run by a user with expired password
......
......@@ -4257,6 +4257,7 @@ bool Prepared_statement::prepare(const char *packet, uint packet_len)
thd->restore_backup_statement(this, &stmt_backup);
thd->restore_active_arena(this, &stmt_backup);
thd->stmt_arena= old_stmt_arena;
thd->cur_stmt = save_cur_stmt;
my_error(ER_MUST_CHANGE_PASSWORD, MYF(0));
DBUG_RETURN(true);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment