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

CREATE TABLE + SELECT behaves incoherently

    XMLWordPrintable

Details

    Description

      Creating a table with a PK plus a SELECT statement leads to 2 different behaviors depending on the column matching names or not.
      Here are 3 examples, the first 2 cases with non matching column names and the third matching:

      create-table-select.sql

      MariaDB [test]> CREATE TABLE myTable (myField int, PRIMARY KEY(myField)) AS SELECT 1;
      ERROR 1364 (HY000): Field 'myField' doesn't have a default value
       
      MariaDB [test]> CREATE TABLE myTable (myField int, PRIMARY KEY(myField)) AS SELECT 1 as myField2;
      ERROR 1364 (HY000): Field 'myField' doesn't have a default value
       
      MariaDB [test]> CREATE TABLE myTable (myField int, PRIMARY KEY(myField)) AS SELECT 1 as myField;
      Query OK, 1 row affected (0.00 sec)
      Records: 1  Duplicates: 0  Warnings: 0
      

      Attachments

        Activity

          People

            serg Sergei Golubchik
            gschulman Guillermo Schulman
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

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