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

ALTER TABLE fails with bogus "BLOB/TEXT column '(null)' can't have a default value"

Details

    Description

      Support for default values for blobs was added in scope of MDEV-10134. So now this works:

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (i INT);
      ALTER TABLE t1 ADD COLUMN b1 BLOB NULL;
      ALTER TABLE t1 ALTER COLUMN b1 SET DEFAULT NULL;
      

      MariaDB [test]> ALTER TABLE t1 ALTER COLUMN b1 SET DEFAULT NULL;
      Query OK, 0 rows affected (0.00 sec)
      Records: 0  Duplicates: 0  Warnings: 0
      

      But this does not work:

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (i INT);
      ALTER TABLE t1 ADD COLUMN b2 BLOB NULL, ALTER COLUMN b2 SET DEFAULT NULL;
      

      MariaDB [test]> ALTER TABLE t1 ADD COLUMN b2 BLOB NULL, ALTER COLUMN b2 SET DEFAULT NULL;
      ERROR 1101 (42000): BLOB/TEXT column '(null)' can't have a default value
      

      Attachments

        Issue Links

          Activity

            elenst Elena Stepanova added a comment - - edited

            It was fixed in 10.2 by/together with this merge:

            commit f2a0c758da3d9f0fa42c96114b453cf4835bcbab (HEAD)
            Merge: fc168c3a5e5 d0116e10a5d
            Author: Sergei Golubchik
            Date:   Fri Mar 29 10:58:20 2019 +0100
             
                Merge branch '10.1' into 10.2
            

            Apparently by this change, probably on top of the merge:

            --- a/sql/sql_table.cc
            +++ b/sql/sql_table.cc
            @@ -7873,11 +7873,6 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
                 }
                 if (alter)
                 {
            -      if (def->sql_type == MYSQL_TYPE_BLOB)
            -      {
            -        my_error(ER_BLOB_CANT_HAVE_DEFAULT, MYF(0), def->change);
            -        goto err;
            -      }
                   if ((def->default_value= alter->default_value)) // Use new default
                     def->flags&= ~NO_DEFAULT_VALUE_FLAG;
                   else
            

            elenst Elena Stepanova added a comment - - edited It was fixed in 10.2 by/together with this merge: commit f2a0c758da3d9f0fa42c96114b453cf4835bcbab (HEAD) Merge: fc168c3a5e5 d0116e10a5d Author: Sergei Golubchik Date: Fri Mar 29 10:58:20 2019 +0100   Merge branch '10.1' into 10.2 Apparently by this change, probably on top of the merge: --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -7873,11 +7873,6 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, } if (alter) { - if (def->sql_type == MYSQL_TYPE_BLOB) - { - my_error(ER_BLOB_CANT_HAVE_DEFAULT, MYF(0), def->change); - goto err; - } if ((def->default_value= alter->default_value)) // Use new default def->flags&= ~NO_DEFAULT_VALUE_FLAG; else

            People

              Unassigned Unassigned
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              1 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.