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

ERROR 1901 (HY000): Function or expression '`UUID_TO_BIN`()' cannot be used in the DEFAULT clause

    XMLWordPrintable

Details

    Description

      Hi,

      Supposedly it is possible to run the following:

      CREATE TABLE `session` (
        `id` binary(16) NOT NULL DEFAULT (UUID_TO_BIN(UUID(), TRUE)),
        `start_timestamp` timestamp NOT NULL, 
        `end_timestamp` timestamp NULL DEFAULT NULL,
        `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
        `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
        `status` varchar(20) DEFAULT NULL
      ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
      

      But there's an error saying:

      ERROR 1901 (HY000): Function or expression '`UUID_TO_BIN`()' cannot be used in the DEFAULT clause of `id`
      

      According to https://stackoverflow.com/questions/60462208/mysql-8-0-13-default-value-as-uuid-not-working it should work on MySQL anyway.

      And for MariaDB, supposedly all deterministic functions should be supported in the DEFAULT clause, no?

      Please help, thanks!

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              MariaDBFreak Roger S
              Votes:
              0 Vote for this issue
              Watchers:
              3 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.