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

Use of a spatial column in a primary key leads to invalid CREATE TABLE, breaks mysqldump

    XMLWordPrintable

Details

    Description

      A prefixed spatial column can be used in a primary key (as a part of it, or alone).
      However, SHOW CREATE TABLE loses the prefix from the key definition. So, an attempt to re-execute this CREATE TABLE, e.g. upon restoring a mysqldump, fails with ER_BLOB_KEY_WITHOUT_LENGTH.

      CREATE TABLE t1 (col_spatial GEOMETRY, PRIMARY KEY(col_spatial(4)));
      SHOW CREATE TABLE `t1`;
      DROP TABLE t1;
      

      10.3 e7be2d31

      CREATE TABLE t1 (col_spatial GEOMETRY, PRIMARY KEY(col_spatial(4)));
      SHOW CREATE TABLE `t1`;
      Table	Create Table
      t1	CREATE TABLE `t1` (
        `col_spatial` geometry NOT NULL,
        PRIMARY KEY (`col_spatial`)
      ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
      DROP TABLE t1;
      

      Trying to re-create:

      query 'CREATE TABLE `t1` (
      `col_spatial` geometry NOT NULL,
      PRIMARY KEY (`col_spatial`)
      ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci' failed: 1170: BLOB/TEXT column 'col_spatial' used in key specification without a key length
      

      Reproducible on all MariaDB 10.x versions, dead and alive.
      5.5 was keeping the prefix in the definition, so does MySQL 5.7.
      MySQL 8.0 forbids the original create.

      Attachments

        Activity

          People

            sanja Oleksandr Byelkin
            elenst Elena Stepanova
            Votes:
            0 Vote for this issue
            Watchers:
            2 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.