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

Column-level CHECK constraint on timestamp column causes ER_EXPRESSION_REFERS_TO_UNINIT_FIELD

Details

    Description

      10.2 469a4b02ce

      MariaDB [test]> CREATE TABLE t1 (t TIMESTAMP CHECK(t>'2018-01-01 00:00:00'));
      ERROR 4029 (01000): Expression for field `t` is refering to uninitialized field `t`
      

      Datetime works all right.

      MariaDB [test]> CREATE TABLE t1 (t DATETIME CHECK(t>'2018-01-01 00:00:00'));
      Query OK, 0 rows affected (0.39 sec)
      

      Table-level CHECK also works all right:

      MariaDB [test]> CREATE TABLE t2 (t TIMESTAMP, CHECK(t>'2018-01-01 00:00:00'));
      Query OK, 0 rows affected (0.19 sec)
      

      Attachments

        Issue Links

          Activity

            Same happens for virtual columns (both stored and generated), although maybe it's by design:

            MariaDB [test]> CREATE TABLE t1 (a INT, b INT AS (a) CHECK (b>0));
            ERROR 4029 (01000): Expression for field `b` is refering to uninitialized field `b`
            

            Table-level still works:

            MariaDB [test]> CREATE TABLE t1 (a INT, b INT AS (a), CHECK (b>0));
            Query OK, 0 rows affected (0.50 sec)
            

            elenst Elena Stepanova added a comment - Same happens for virtual columns (both stored and generated), although maybe it's by design: MariaDB [test]> CREATE TABLE t1 (a INT , b INT AS (a) CHECK (b>0)); ERROR 4029 (01000): Expression for field `b` is refering to uninitialized field `b` Table-level still works: MariaDB [test]> CREATE TABLE t1 (a INT , b INT AS (a), CHECK (b>0)); Query OK, 0 rows affected (0.50 sec)

            People

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