[MDEV-11115] CHECK constraints are not shown in I_S.TABLE_CONSTRAINTS Created: 2016-10-23  Updated: 2017-03-31  Resolved: 2017-03-31

Status: Closed
Project: MariaDB Server
Component/s: OTHER
Affects Version/s: 10.2
Fix Version/s: 10.2.5

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Jacob Mathew (Inactive)
Resolution: Fixed Votes: 0
Labels: 10.2-ga

Issue Links:
Relates
relates to MDEV-7563 Support CHECK constraint as in (or cl... Closed
Sprint: 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)



 Comments   
Comment by Elena Stepanova [ 2017-01-24 ]

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

Comment by Jacob Mathew (Inactive) [ 2017-02-14 ]

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

Comment by Jacob Mathew (Inactive) [ 2017-02-14 ]

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);

Comment by Jacob Mathew (Inactive) [ 2017-03-31 ]

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

Generated at Thu Feb 08 07:47:25 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.