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

Check constraint errors when there is no violation

    XMLWordPrintable

Details

    Description

      Running the following SQL as a reproducer will show the problem:

      create table TemporalEntity1 (
                                       id bigint not null,
                                       excluded bigint not null,
                                       text varchar(255),
                                       version integer not null,
                                       effective_from timestamp(6) not null,
                                       effective_to timestamp(6) null,
                                       primary key (id, version),
                                       check (effective_to is null or effective_to > effective_from)
      ) engine=InnoDB;
       
       
      insert into TemporalEntity1
          (excluded, text, version, effective_from, effective_to, id)
      values
          (1, 'hello', 0, timestamp '2026-03-31T17:11:53.488209', null, 1);
       
      update TemporalEntity1
      set
          effective_to=timestamp '2026-03-31T17:11:54.797437'
      where
          id=1
        and effective_to is null
        and version=0;
      

      Clearly, 2026-03-31T17:11:54.797437 is greater than 2026-03-31T17:11:53.488209, but MariaDB reports CONSTRAINT `CONSTRAINT_1` failed for `TemporalEntity1`.

      It works fine in version 10.11+

      Attachments

        Activity

          People

            Unassigned Unassigned
            cbeikov Christian Beikov
            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.