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

SHOW CREATE TABLE reports a column as json and drops its CHECK (JSON_VALID(expr)) when expr is not the column itself: backups fail to restore or restore with a weaker constraint

    XMLWordPrintable

Details

    • Not for Release Notes
    • Q1/2027 Server Maintenance

    Description

      SHOW CREATE TABLE reports a column as json and drops its CHECK (JSON_VALID(expr)) when expr is not the column itself: backups fail to restore or restore with a weaker constraint

      MDEV-38740 CS 13.1.0 30b179125daa805fc47b3996d09a9263bb414ca9 (Optimized, Clang 18.1.3-11) Build 13/10/2026

      CREATE TABLE t (c LONGTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin CHECK (JSON_VALID('{}')));
      INSERT INTO t VALUES ('a');
      SHOW CREATE TABLE t;
      

      CLI Output

      13.1.0-opt>CREATE TABLE t (c LONGTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin CHECK (JSON_VALID('{}')));
      Query OK, 0 rows affected (0.009 sec)
       
      13.1.0-opt>INSERT INTO t VALUES ('a');
      Query OK, 1 row affected (0.001 sec)
       
      13.1.0-opt>SHOW CREATE TABLE t\G
      *************************** 1. row ***************************
             Table: t
      Create Table: CREATE TABLE `t` (
        `c` json DEFAULT NULL
      ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
      1 row in set (0.000 sec)
       
      13.1.0-opt>
      

      Backup info

      --
      -- Table structure for table `t`
      --
       
      DROP TABLE IF EXISTS `t`;
      /*!40101 SET @saved_cs_client     = @@character_set_client */;
      /*!40101 SET character_set_client = utf8mb4 */;
      CREATE TABLE `t` (
        `c` json DEFAULT NULL
      ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
      /*!40101 SET character_set_client = @saved_cs_client */;
       
      --
      -- Dumping data for table `t`
      --
       
      SET @OLD_AUTOCOMMIT=@@AUTOCOMMIT, @@AUTOCOMMIT=0;
      LOCK TABLES `t` WRITE;
      /*!40000 ALTER TABLE `t` DISABLE KEYS */;
      INSERT INTO `t` VALUES
      ('a');
      /*!40000 ALTER TABLE `t` ENABLE KEYS */;
      UNLOCK TABLES;
      COMMIT;
      SET AUTOCOMMIT=@OLD_AUTOCOMMIT;
      /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
      

      Backup cannot be restored due to ERROR 4025 (23000) at line 38: CONSTRAINT

      $ /test/mtest/MDEV-38740/MD131026-mariadb-13.1.0-linux-x86_64-opt/bin/mariadb -uroot -S/test/mtest/MDEV-38740/MD131026-mariadb-13.1.0-linux-x86_64-opt/socket.sock test < 1.sql
      --------------
      INSERT INTO `t` VALUES
      ('a')
      --------------
       
      ERROR 4025 (23000) at line 38: CONSTRAINT `t.c` failed for `test`.`t`
      

      Attachments

        Issue Links

          Activity

            People

              serg Sergei Golubchik
              ramesh Ramesh Sivaraman
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - 0d
                  0d
                  Remaining:
                  Remaining Estimate - 0d
                  0d
                  Logged:
                  Time Spent - 0.5h
                  0.5h

                  Git Integration

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