Commit 39968552 authored by unknown's avatar unknown

view.result, view.test:

  Added a test case for bug #6120.
sql_view.cc:
  Fixed bug #6120.
  The SP cache must be invalidated when a view is altered.


sql/sql_view.cc:
  Fixed bug #6120.
  The SP cache must be invalidated when a view is altered.
mysql-test/t/view.test:
  Added a test case for bug #6120.
mysql-test/r/view.result:
  Added a test case for bug #6120.
parent 6dc280da
......@@ -1923,3 +1923,20 @@ ERROR HY000: Field of view 'test.v2' underlying table doesn't have a default val
set sql_mode=default;
drop view v2,v1;
drop table t1;
CREATE TABLE t1 (s1 int, s2 int);
INSERT INTO t1 VALUES (1,2);
CREATE VIEW v1 AS SELECT s2 AS s1, s1 AS s2 FROM t1;
SELECT * FROM v1;
s1 s2
2 1
CREATE PROCEDURE p1 () SELECT * FROM v1;
CALL p1();
s1 s2
2 1
ALTER VIEW v1 AS SELECT s1 AS s1, s2 AS s2 FROM t1;
CALL p1();
s1 s2
1 2
DROP PROCEDURE p1;
DROP VIEW v1;
DROP TABLE t1;
......@@ -1761,3 +1761,20 @@ INSERT INTO v2 (vcol1) VALUES(12);
set sql_mode=default;
drop view v2,v1;
drop table t1;
#
# Test for bug #6120: SP cache to be invalidated when altering a view
#
CREATE TABLE t1 (s1 int, s2 int);
INSERT INTO t1 VALUES (1,2);
CREATE VIEW v1 AS SELECT s2 AS s1, s1 AS s2 FROM t1;
SELECT * FROM v1;
CREATE PROCEDURE p1 () SELECT * FROM v1;
CALL p1();
ALTER VIEW v1 AS SELECT s1 AS s1, s2 AS s2 FROM t1;
CALL p1();
DROP PROCEDURE p1;
DROP VIEW v1;
DROP TABLE t1;
......@@ -20,6 +20,7 @@
#include "parse_file.h"
#include "sp.h"
#include "sp_head.h"
#include "sp_cache.h"
#define MD5_BUFF_LENGTH 33
......@@ -141,6 +142,9 @@ bool mysql_create_view(THD *thd,
goto err;
}
if (mode != VIEW_CREATE_NEW)
sp_cache_invalidate();
#ifndef NO_EMBEDDED_ACCESS_CHECKS
/*
Privilege check for view creation:
......
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