Bug #6442 | Views: updatability not established at view creation time | ||
---|---|---|---|
Submitted: | 4 Nov 2004 20:33 | Modified: | 3 Oct 2008 9:26 |
Reporter: | Paul DuBois | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: Views | Severity: | S3 (Non-critical) |
Version: | 5.0.2, 5.1.28 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[4 Nov 2004 20:33]
Paul DuBois
[18 Jan 2005 20:03]
Oleksandr Byelkin
saving environment is not fully implemented now
[29 Sep 2008 18:29]
Konstantin Osipov
Needs to be re-verified. We store view creation context in 5.1
[3 Oct 2008 9:26]
Valeriy Kravchuk
We still have this problem in 5.1.28: C:\Program Files\MySQL\MySQL Server 5.0\bin>mysql -uroot -proot -P3310 test Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8 Server version: 5.1.28-rc-community MySQL Community Server (GPL) Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> drop table t; Query OK, 0 rows affected (0.06 sec) mysql> drop view v; ERROR 1051 (42S02): Unknown table 'v' mysql> DROP TABLE IF EXISTS t; Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> DROP VIEW IF EXISTS v; Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> CREATE TABLE t (col1 INT NOT NULL, col2 INT NOT NULL) ENGINE = INNODB; Query OK, 0 rows affected (0.09 sec) mysql> set sql_mode='strict_all_tables'; Query OK, 0 rows affected (0.05 sec) mysql> CREATE VIEW v (vcol1) AS SELECT col1 FROM t; Query OK, 0 rows affected (0.03 sec) mysql> INSERT INTO v (vcol1) VALUES(12); ERROR 1423 (HY000): Field of view 'test.v' underlying table doesn't have a defau lt value mysql> DROP TABLE IF EXISTS t; Query OK, 0 rows affected (0.05 sec) mysql> DROP VIEW IF EXISTS v; Query OK, 0 rows affected (0.00 sec) mysql> CREATE TABLE t (col1 INT NOT NULL, col2 INT NOT NULL) ENGINE = INNODB; Query OK, 0 rows affected (0.11 sec) mysql> CREATE VIEW v (vcol1) AS SELECT col1 FROM t; Query OK, 0 rows affected (0.00 sec) mysql> set sql_mode='strict_all_tables'; Query OK, 0 rows affected (0.00 sec) mysql> INSERT INTO v (vcol1) VALUES(12); ERROR 1423 (HY000): Field of view 'test.v' underlying table doesn't have a defau lt value mysql> set sql_mode=''; Query OK, 0 rows affected (0.00 sec) mysql> INSERT INTO v (vcol1) VALUES(12); Query OK, 1 row affected, 1 warning (0.03 sec)
[11 Nov 2017 18:48]
Federico Razzoli
Seems to be fixed in (or before) 8.0.3: mysql> # Case 1: mysql> # The INSERT should fail when the view was created in strict mode, mysql> # because no value is supplied for underlying table column t.col2. mysql> DROP TABLE IF EXISTS t; Query OK, 0 rows affected, 1 warning (0.02 sec) mysql> DROP VIEW IF EXISTS v; Query OK, 0 rows affected, 1 warning (0.03 sec) mysql> CREATE TABLE t (col1 INT NOT NULL, col2 INT NOT NULL) ENGINE = INNODB; Query OK, 0 rows affected (0.25 sec) mysql> set sql_mode='strict_all_tables'; Query OK, 0 rows affected, 2 warnings (0.00 sec) mysql> CREATE VIEW v (vcol1) AS SELECT col1 FROM t; Query OK, 0 rows affected (0.05 sec) mysql> INSERT INTO v (vcol1) VALUES(12); ERROR 1423 (HY000): Field of view 'test.v' underlying table doesn't have a default value mysql> mysql> # Case 2: mysql> # The INSERT should not fail because the view was not created in strict mysql> # mode. But in fact it does fail when strict mode is turned on before mysql> # the insert. mysql> DROP TABLE IF EXISTS t; Query OK, 0 rows affected (0.14 sec) mysql> DROP VIEW IF EXISTS v; Query OK, 0 rows affected (0.05 sec) mysql> CREATE TABLE t (col1 INT NOT NULL, col2 INT NOT NULL) ENGINE = INNODB; Query OK, 0 rows affected (0.26 sec) mysql> CREATE VIEW v (vcol1) AS SELECT col1 FROM t; Query OK, 0 rows affected (0.05 sec) mysql> set sql_mode='strict_all_tables'; Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> INSERT INTO v (vcol1) VALUES(12); ERROR 1423 (HY000): Field of view 'test.v' underlying table doesn't have a default value