Bug #67863 INSERT INTO view_name () VALUES () fails with ER_WRONG_VALUE_COUNT_ON_ROW
Submitted: 10 Dec 2012 16:24 Modified: 7 Oct 2020 13:48
Reporter: Elena Stepanova Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version:5.1, 5.5, 5.6 OS:Any
Assigned to: CPU Architecture:Any

[10 Dec 2012 16:24] Elena Stepanova
Description:
An attempt to insert all default values into a view fails with "Column count doesn't match value count at row 1", while the same statement with the base table works all right. I couldn't find any explanation or a mention of such limitation in the docs. 

mysql> CREATE TABLE t1 (i INT DEFAULT '0');
Query OK, 0 rows affected (2.38 sec)

mysql> INSERT INTO t1 () VALUES ();
Query OK, 1 row affected (0.20 sec)

mysql> CREATE VIEW v1 AS SELECT * FROM t1;
Query OK, 0 rows affected (0.14 sec)

mysql> INSERT INTO v1 () VALUES ();
ERROR 1136 (21S01): Column count doesn't match value count at row 1

How to repeat:
CREATE TABLE t1 (i INT DEFAULT '0');
CREATE VIEW v1 AS SELECT * FROM t1;
INSERT INTO v1 () VALUES ();
[12 Dec 2012 5:01] Erlend Dahl
Verified as described on 5.5.28-0ubuntu0.12.10.1. Moving to the internal bug db for further analysis.
[7 Oct 2020 13:48] Paul DuBois
Posted by developer:
 
Fixed in 8.0.22.

This construct works for base tables to insert a row using all
default values but failed for views:

INSERT INTO name () VALUES ();