A test case for BUG#26676: VIEW using old table schema in a session.

The following clarification should be made in The Manual:

Standard SQL is quite clear that, if new columns are added
to a table after a view on that table is created with
"select *", the new columns will not become part of the view.
In all cases, the view definition (view structure) is frozen
at CREATE time, so changes to the underlying tables do not
affect the view structure.


mysql-test/r/view.result:
  Update result file.
mysql-test/t/view.test:
  Add a test case for BUG#26676: VIEW using old table schema in a session.
This commit is contained in:
unknown 2007-11-30 12:14:07 +03:00
commit 9395421a14
2 changed files with 94 additions and 0 deletions

View file

@ -3617,4 +3617,47 @@ DROP TABLE `t-2`;
DROP VIEW `v-2`;
DROP DATABASE `d-1`;
USE test;
#
# Bug#26676: VIEW using old table schema in a session.
#
DROP VIEW IF EXISTS v1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1(c1 INT, c2 INT);
INSERT INTO t1 VALUES (1, 2), (3, 4);
SELECT * FROM t1;
c1 c2
1 2
3 4
CREATE VIEW v1 AS SELECT * FROM t1;
SELECT * FROM v1;
c1 c2
1 2
3 4
ALTER TABLE t1 ADD COLUMN c3 INT AFTER c2;
SELECT * FROM t1;
c1 c2 c3
1 2 NULL
3 4 NULL
SELECT * FROM v1;
c1 c2
1 2
3 4
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`c1` AS `c1`,`t1`.`c2` AS `c2` from `t1` latin1 latin1_swedish_ci
DROP VIEW v1;
DROP TABLE t1;
# End of test case for Bug#26676.
End of 5.1 tests.

View file

@ -3475,4 +3475,55 @@ DROP VIEW `v-2`;
DROP DATABASE `d-1`;
USE test;
--echo
--echo #
--echo # Bug#26676: VIEW using old table schema in a session.
--echo #
--echo
--disable_warnings
DROP VIEW IF EXISTS v1;
DROP TABLE IF EXISTS t1;
--enable_warnings
CREATE TABLE t1(c1 INT, c2 INT);
INSERT INTO t1 VALUES (1, 2), (3, 4);
--echo
SELECT * FROM t1;
--echo
CREATE VIEW v1 AS SELECT * FROM t1;
--echo
SELECT * FROM v1;
--echo
ALTER TABLE t1 ADD COLUMN c3 INT AFTER c2;
--echo
SELECT * FROM t1;
--echo
SELECT * FROM v1;
--echo
SHOW CREATE VIEW v1;
--echo
DROP VIEW v1;
DROP TABLE t1;
--echo
--echo # End of test case for Bug#26676.
--echo
--echo End of 5.1 tests.