Commit ee66332c authored by Davi Arnaut's avatar Davi Arnaut

Bug#47734: Assertion failed: ! is_set() when locking a view with non-existing definer

The problem was that a failure to open a view wasn't being
properly handled. When opening a view with unknown definer,
the open procedure would be treated as successful and would
later crash when attempting to lock the view (which wasn't
opened to begin with).

The solution is to skip further processing when opening a
table if it fails with a fatal error.

mysql-test/r/view.result:
  Add test case result for Bug#47734.
mysql-test/t/view.test:
  Add test case for Bug#47734.
sql/sql_base.cc:
  Skip further processing if opening a table failed due to
  a fatal error (for the statement).
parent f4a16558
......@@ -3844,6 +3844,16 @@ CREATE VIEW v1 AS SELECT a FROM t1;
ALTER TABLE v1;
DROP VIEW v1;
DROP TABLE t1;
#
# Bug#47734: Assertion failed: ! is_set() when locking a view with non-existing definer
#
DROP VIEW IF EXISTS v1;
CREATE DEFINER=`unknown`@`unknown` SQL SECURITY DEFINER VIEW v1 AS SELECT 1;
Warnings:
Note 1449 The user specified as a definer ('unknown'@'unknown') does not exist
LOCK TABLES v1 READ;
ERROR HY000: The user specified as a definer ('unknown'@'unknown') does not exist
DROP VIEW v1;
# -----------------------------------------------------------------
# -- End of 5.1 tests.
# -----------------------------------------------------------------
......@@ -3869,6 +3869,18 @@ ALTER TABLE v1;
DROP VIEW v1;
DROP TABLE t1;
--echo #
--echo # Bug#47734: Assertion failed: ! is_set() when locking a view with non-existing definer
--echo #
--disable_warnings
DROP VIEW IF EXISTS v1;
--enable_warnings
CREATE DEFINER=`unknown`@`unknown` SQL SECURITY DEFINER VIEW v1 AS SELECT 1;
--error ER_NO_SUCH_USER
LOCK TABLES v1 READ;
DROP VIEW v1;
--echo # -----------------------------------------------------------------
--echo # -- End of 5.1 tests.
......
......@@ -4591,7 +4591,20 @@ int open_tables(THD *thd, TABLE_LIST **start, uint *counter, uint flags)
safe_to_ignore_table= prelock_handler.safely_trapped_errors();
}
else
{
tables->table= open_table(thd, tables, &new_frm_mem, &refresh, flags);
/*
Skip further processing if there has been a fatal error while
trying to open a table. For example, this might happen due to
stack shortage, unknown definer in views, etc.
*/
if (!tables->table && thd->is_error())
{
result= -1;
goto err;
}
}
}
else
DBUG_PRINT("tcache", ("referenced table: '%s'.'%s' 0x%lx",
......
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