summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorunknown <anozdrin/alik@quad.>2008-02-20 22:23:39 +0300
committerunknown <anozdrin/alik@quad.>2008-02-20 22:23:39 +0300
commit792eb1f17beb1bd8a52c780605c7502f89c3eaed (patch)
tree2a2ddbf915e37d20e3a5b3c2624dad304ae6431f /mysql-test
parent0705693075e8bda8028234f87d91084bdeb818a4 (diff)
downloadmariadb-git-792eb1f17beb1bd8a52c780605c7502f89c3eaed.tar.gz
Fix for Bug#34337: Server crash when Altering a view using
a table name. The problem was that fill_defined_view_parts() did not return an error if a table is going to be altered. That happened if the table was already in the table cache. In that case, open_table() returned non-NULL value (valid TABLE-instance from the cache). The fix is to ensure that an error is thrown even if the table is in the cache. mysql-test/r/view.result: Fix result file. mysql-test/t/view.test: Add a test case for Bug#34337: Server crash when Altering a view using a table name. sql/sql_view.cc: Report an error if we're going to work with a table.
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/view.result15
-rw-r--r--mysql-test/t/view.test28
2 files changed, 43 insertions, 0 deletions
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result
index 3f8ed1b4e56..e5c20a2c26f 100644
--- a/mysql-test/r/view.result
+++ b/mysql-test/r/view.result
@@ -3721,5 +3721,20 @@ DROP VIEW v1;
# -- End of test case for Bug#32538.
# -----------------------------------------------------------------
+# -- Bug#34337: Server crash when Altering a view using a table name.
+# -----------------------------------------------------------------
+
+DROP TABLE IF EXISTS t1;
+
+CREATE TABLE t1(c1 INT);
+
+ALTER ALGORITHM=TEMPTABLE SQL SECURITY INVOKER VIEW t1 (c2) AS SELECT (1);
+ERROR HY000: 'test.t1' is not VIEW
+
+DROP TABLE t1;
+
+# -- End of test case for Bug#34337.
+
+# -----------------------------------------------------------------
# -- End of 5.1 tests.
# -----------------------------------------------------------------
diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test
index 3f10bc62289..d350dd102d7 100644
--- a/mysql-test/t/view.test
+++ b/mysql-test/t/view.test
@@ -3604,5 +3604,33 @@ DROP VIEW v1;
###########################################################################
--echo # -----------------------------------------------------------------
+--echo # -- Bug#34337: Server crash when Altering a view using a table name.
+--echo # -----------------------------------------------------------------
+--echo
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--echo
+
+CREATE TABLE t1(c1 INT);
+
+--echo
+
+--error ER_WRONG_OBJECT
+ALTER ALGORITHM=TEMPTABLE SQL SECURITY INVOKER VIEW t1 (c2) AS SELECT (1);
+
+--echo
+
+DROP TABLE t1;
+
+--echo
+--echo # -- End of test case for Bug#34337.
+--echo
+
+###########################################################################
+
+--echo # -----------------------------------------------------------------
--echo # -- End of 5.1 tests.
--echo # -----------------------------------------------------------------