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

CHECK constraints are not shown in I_S.TABLE_CONSTRAINTS

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 10.2(EOL)
    • 10.2.5
    • OTHER
    • 10.2.6-2, 10.2.6-3

    Description

      MySQL documentation mentions that CHECK constraints should be shown in I_S.TABLE_CONSTRAINTS when they are supported:
      http://dev.mysql.com/doc/refman/5.5/en/table-constraints-table.html

      I suppose it should be so in MariaDB, too.
      However, MariaDB documentation does not say that (https://mariadb.com/kb/en/mariadb/information-schema-table_constraints-table/), and the constraints are not returned by the I_S table:

      MariaDB [test]> create table t1 (a int, check(a>0));
      Query OK, 0 rows affected (0.49 sec)
       
      MariaDB [test]> select * from information_schema.table_constraints where table_name = 't1';
      Empty set (0.00 sec)
      

      Attachments

        Issue Links

          Activity

            If it needs to be done at all, it would better be done before GA.

            elenst Elena Stepanova added a comment - If it needs to be done at all, it would better be done before GA.

            I have completed my changes to fix the bug. The changes are ready to be reviewed.

            jacob-mathew Jacob Mathew (Inactive) added a comment - I have completed my changes to fix the bug. The changes are ready to be reviewed.

            Hi Sergei,

            Please review my changes to fix information schema bug MDEV-11115.

            Thanks,
            Jacob

            commit 92f235952021aabb43740b47beaedea0e70a5850
            Author: Jacob Mathew <jacob.mathew@mariadb.com>
            Date: Mon Feb 13 17:18:56 2017 -0800

            Changes to fix information schema bug MDEV_11115.

            diff --git a/sql/sql_show.cc b/sql/sql_show.cc
            index 58fc2edc6f2..ed369f9b6fe 100644
            — a/sql/sql_show.cc
            +++ b/sql/sql_show.cc
            @@ -6375,6 +6375,19 @@ static int get_schema_constraints_record(THD *thd, TABLE_LIST *tables,
            }
            }

            + // Table check constraints
            + for ( uint i = 0; i < show_table->s->table_check_constraints; i++ )
            + {
            + Virtual_column_info *check = show_table->s->check_constraints[ i ];
            +
            + if ( store_constraints( thd, table, db_name, table_name, check->name.str,
            + check->name.length,
            + STRING_WITH_LEN( "CHECK" ) ) )
            +

            { + DBUG_RETURN( 1 ); + }

            + }
            +
            show_table->file->get_foreign_key_list(thd, &f_key_list);
            FOREIGN_KEY_INFO *f_key_info;
            List_iterator_fast<FOREIGN_KEY_INFO> it(f_key_list);

            jacob-mathew Jacob Mathew (Inactive) added a comment - Hi Sergei, Please review my changes to fix information schema bug MDEV-11115 . Thanks, Jacob commit 92f235952021aabb43740b47beaedea0e70a5850 Author: Jacob Mathew <jacob.mathew@mariadb.com> Date: Mon Feb 13 17:18:56 2017 -0800 Changes to fix information schema bug MDEV_11115. diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 58fc2edc6f2..ed369f9b6fe 100644 — a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -6375,6 +6375,19 @@ static int get_schema_constraints_record(THD *thd, TABLE_LIST *tables, } } + // Table check constraints + for ( uint i = 0; i < show_table->s->table_check_constraints; i++ ) + { + Virtual_column_info *check = show_table->s->check_constraints[ i ]; + + if ( store_constraints( thd, table, db_name, table_name, check->name.str, + check->name.length, + STRING_WITH_LEN( "CHECK" ) ) ) + { + DBUG_RETURN( 1 ); + } + } + show_table->file->get_foreign_key_list(thd, &f_key_list); FOREIGN_KEY_INFO *f_key_info; List_iterator_fast<FOREIGN_KEY_INFO> it(f_key_list);

            I merged the fix into the 10.2 branch on 29/March/2017.

            jacob-mathew Jacob Mathew (Inactive) added a comment - I merged the fix into the 10.2 branch on 29/March/2017.

            People

              jacob-mathew Jacob Mathew (Inactive)
              elenst Elena Stepanova
              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.