Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-21865

Table Value Constructor during an INSERT SELECT statement

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Confirmed (View Workflow)
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 10.3.11
    • Fix Version/s: 10.3
    • 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
      

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            proust Christian Proust
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated: