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

ALTER TABLE…ADD COLUMN…POINT NOT NULL without DEFAULT should be refused if the table is not empty

Details

    • 10.2.10, 10.2.14

    Description

      The following test is based on the test innodb_gis.alter_spatial_index.

      For MDEV-11369 Instant ADD COLUMN, we want consistent behaviour in ALTER TABLE. No matter if the ALTER TABLE was implemented by ALGORITHM=COPY, non-instant ALGORITHM=INPLACE, or instant ALGORITHM=INPLACE, the result must be the same. The result should also be consistent with INSERT and UPDATE operations. Here it is not the case:

      --source include/have_innodb.inc
      --source include/have_geometry.inc
      CREATE TABLE tab(c1 int PRIMARY KEY) ENGINE=InnoDB;
      INSERT INTO tab SET c1=1;
      ALTER TABLE tab add COLUMN c2 POINT NOT NULL;
      SELECT * FROM tab;
      INSERT INTO tab SET c1=2;
      SELECT * FROM tab;
      DROP TABLE tab;
      

      Currently, the ALTER TABLE (no matter if ALGORITHM=COPY or ALGORITHM=INPLACE is specified) will insert the invalid value c2='' (the empty string). But, the INSERT is returning an error:

      mysqltest: At line 7: query 'INSERT INTO tab SET c1=2' failed: 1364: Field 'c2' doesn't have a default value
      

      The behaviour of ALTER TABLE and INSERT are inconsistent with each other.

      appended by HF:
      I came upon a crash that i think should be fixed along with this

      MariaDB [test]> create table pt(g geometry);
      Query OK, 0 rows affected (0.50 sec)
       
      MariaDB [test]> insert into pt values (st_geometryfromtext("point(1 2)"));
      Query OK, 1 row affected (0.05 sec)
      MariaDB [test]> alter table pt add column g2 geometry default("123123");
      ERROR 2013 (HY000): Lost connection to MySQL server during query
      

      Attachments

        Issue Links

          Activity

            marko Marko Mäkelä created issue -
            marko Marko Mäkelä made changes -
            Field Original Value New Value
            holyfoot Alexey Botchkov made changes -
            Description The following test is based on the test innodb_gis.alter_spatial_index.

            For MDEV-11369 Instant ADD COLUMN, we want consistent behaviour in ALTER TABLE. No matter if the ALTER TABLE was implemented by ALGORITHM=COPY, non-instant ALGORITHM=INPLACE, or instant ALGORITHM=INPLACE, the result must be the same. The result should also be consistent with INSERT and UPDATE operations. Here it is not the case:
            {code:SQL}
            --source include/have_innodb.inc
            --source include/have_geometry.inc
            CREATE TABLE tab(c1 int PRIMARY KEY) ENGINE=InnoDB;
            INSERT INTO tab SET c1=1;
            ALTER TABLE tab add COLUMN c2 POINT NOT NULL;
            SELECT * FROM tab;
            INSERT INTO tab SET c1=2;
            SELECT * FROM tab;
            DROP TABLE tab;
            {code}
            Currently, the ALTER TABLE (no matter if ALGORITHM=COPY or ALGORITHM=INPLACE is specified) will insert the invalid value c2='' (the empty string). But, the INSERT is returning an error:
            {noformat}
            mysqltest: At line 7: query 'INSERT INTO tab SET c1=2' failed: 1364: Field 'c2' doesn't have a default value
            {noformat}
            The behaviour of ALTER TABLE and INSERT are inconsistent with each other.
            The following test is based on the test innodb_gis.alter_spatial_index.

            For MDEV-11369 Instant ADD COLUMN, we want consistent behaviour in ALTER TABLE. No matter if the ALTER TABLE was implemented by ALGORITHM=COPY, non-instant ALGORITHM=INPLACE, or instant ALGORITHM=INPLACE, the result must be the same. The result should also be consistent with INSERT and UPDATE operations. Here it is not the case:
            {code:SQL}
            --source include/have_innodb.inc
            --source include/have_geometry.inc
            CREATE TABLE tab(c1 int PRIMARY KEY) ENGINE=InnoDB;
            INSERT INTO tab SET c1=1;
            ALTER TABLE tab add COLUMN c2 POINT NOT NULL;
            SELECT * FROM tab;
            INSERT INTO tab SET c1=2;
            SELECT * FROM tab;
            DROP TABLE tab;
            {code}
            Currently, the ALTER TABLE (no matter if ALGORITHM=COPY or ALGORITHM=INPLACE is specified) will insert the invalid value c2='' (the empty string). But, the INSERT is returning an error:
            {noformat}
            mysqltest: At line 7: query 'INSERT INTO tab SET c1=2' failed: 1364: Field 'c2' doesn't have a default value
            {noformat}
            The behaviour of ALTER TABLE and INSERT are inconsistent with each other.

            appended by HF:
            I came upon a crash that i think should be fixed along with this
            {code:SQL}
            MariaDB [test]> create table pt(g geometry);
            Query OK, 0 rows affected (0.50 sec)

            MariaDB [test]> insert into pt values (st_geometryfromtext("point(1 2)"));
            Query OK, 1 row affected (0.05 sec)
            MariaDB [test]> alter table pt add column g2 geometry default("123123");
            ERROR 2013 (HY000): Lost connection to MySQL server during query
            {code}
            serg Sergei Golubchik made changes -
            Sprint 10.2.10 [ 183 ]
            holyfoot Alexey Botchkov made changes -
            Sprint 10.2.10 [ 183 ] 10.2.10, 10.2.14 [ 183, 229 ]
            holyfoot Alexey Botchkov made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 82424 ] MariaDB v4 [ 144463 ]
            julien.fritsch Julien Fritsch made changes -
            Comment [ Automated message:
            ----------------------------
            Since this issue has not been updated since 6 weeks, it's time to move it back to Stalled. ]
            julien.fritsch Julien Fritsch made changes -
            Status In Progress [ 3 ] Stalled [ 10000 ]

            People

              holyfoot Alexey Botchkov
              marko Marko Mäkelä
              Votes:
              0 Vote for this issue
              Watchers:
              4 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.