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

Table Value Constructor during an INSERT SELECT statement

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Duplicate
    • 10.3.11
    • 10.4.33
    • None
    • 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

            Unassigned Unassigned
            proust Christian Proust
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.