[MDEV-21865] Table Value Constructor during an INSERT SELECT statement Created: 2020-03-04  Updated: 2023-12-14  Resolved: 2023-12-14

Status: Closed
Project: MariaDB Server
Component/s: Data Manipulation - Insert
Affects Version/s: 10.3.11
Fix Version/s: 10.4.33

Type: Bug Priority: Minor
Reporter: Christian Proust Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Environment:

OS: CentOS 8
mysql --version
mysql Ver 15.1 Distrib 10.3.11-MariaDB, for Linux (x86_64) using readline 5.1



 Description   

When running the following query, I get the error: ERROR 1136 (21S01): Column count doesn't match value count at row 1.

DROP TABLE IF EXISTS bug;
CREATE TABLE bug (
	id INT UNSIGNED NOT NULL UNIQUE
	, c1 INT UNSIGNED
);
 
INSERT INTO bug (id)
WITH 
	table_value_constructor(i) AS (
		VALUES
		(1),
		(2),
		(3)
	)
SELECT i*10 
FROM table_value_constructor;
 
SELECT * FROM bug;

The error disappears by removing the line:

	, c1 INT UNSIGNED

or by replacing the Table Value Constructor

		VALUES
		(1),
		(2),
		(3)

by

		SELECT 1
		UNION SELECT 2
		UNION SELECT 3



 Comments   
Comment by Elena Stepanova [ 2020-03-08 ]

In 10.4 the problem disappeared after

commit de745ecf29721795710910a19bd0ea3389da804c
Author: Oleksandr Byelkin <sanja@mariadb.com>
Date:   Tue May 22 19:08:39 2018 +0200
 
    MDEV-11953: support of brackets in UNION/EXCEPT/INTERSECT operations

Comment by Dave Gosselin [ 2023-12-14 ]

I tested latest 10.4, at the time of this comment, git sha b4712242dd6d2 and no error message was seen. I attempted to build git sha de745ecf29721795 as noted in the above comment but due to platform changes since 2018, the system no longer builds at that point. Considering and closing this ticket as a duplicate of MDEV-11953 seems appropriate at this point.

Generated at Thu Feb 08 09:10:26 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.