diff options
author | Anel Husakovic <anel@mariadb.org> | 2019-01-24 03:06:56 -0800 |
---|---|---|
committer | Vicențiu Ciorbaru <vicentiu@mariadb.org> | 2019-12-13 16:38:14 +0200 |
commit | 8129ff14407826d54745346c552fadf3d292a0d8 (patch) | |
tree | 0b1200a9de302211a4474052701a1014c2d1651e /sql/sql_show.cc | |
parent | f0aa073f2bf3d8d85b3d028df89cdb4cdfc4002d (diff) | |
download | mariadb-git-8129ff14407826d54745346c552fadf3d292a0d8.tar.gz |
PR #1127 and PR #1150
PR#1127: Fix is_check_constraints.result to be compatibile with 10.3
The patch is done according to the original patch for MDEV-14474
1edd09c325525cba33152 and not one which is merged on server
d526679efd108478cc2af07578.
This patch includes:
- Rename from `is_check_constraint` to `is_check_constraints` to tests
and results
- Per review, change the order of fields in IS check_constraints table by adding
the column `table_name` before `constraint_name`. According to the standard
2006 there is no `table_name` column.
- Original patch and one in `10.3` supports embedded server this patch doesn't
support. After the merge `10.3` will not support also.
- Don't use patch c8b8b01b61 to change the length of `CHECK_CLAUSE` field
PR#1150: MDEV-18440: Information_schema.check_constraints possible data leak
This patch is extension of PR 1127 and includes:
- Check for table grants
- Additional test according to the MDEV specification
Signed-off-by: Vicențiu Ciorbaru <vicentiu@mariadb.org>
Diffstat (limited to 'sql/sql_show.cc')
-rw-r--r-- | sql/sql_show.cc | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/sql/sql_show.cc b/sql/sql_show.cc index f54a9af5441..fcf97fc8fee 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -6526,7 +6526,7 @@ static int get_check_constraints_record(THD *thd, TABLE_LIST *tables, LEX_STRING *table_name) { DBUG_ENTER("get_check_constraints_record"); - if(res) + if (res) { if (thd->is_error()) push_warning(thd, Sql_condition::WARN_LEVEL_WARN, @@ -6535,15 +6535,32 @@ static int get_check_constraints_record(THD *thd, TABLE_LIST *tables, thd->clear_error(); DBUG_RETURN(0); } - if(!tables->view) + if (!tables->view) { StringBuffer<MAX_FIELD_WIDTH> str(system_charset_info); +#ifndef NO_EMBEDDED_ACCESS_CHECKS + TABLE_LIST table_acl_check; + bzero((char*) &table_acl_check, sizeof(table_acl_check)); +#endif for (uint i= 0; i < tables->table->s->table_check_constraints; i++) { +#ifndef NO_EMBEDDED_ACCESS_CHECKS + if (!(thd->col_access & TABLE_ACLS)) + { + table_acl_check.db= db_name->str; + table_acl_check.db_length= db_name->length; + table_acl_check.table_name= table_name->str; + table_acl_check.table_name_length= table_name->length; + table_acl_check.grant.privilege= thd->col_access; + if (check_grant(thd, TABLE_ACLS, &table_acl_check, FALSE, 1, TRUE)) + continue; + } +#endif Virtual_column_info *check= tables->table->check_constraints[i]; table->field[0]->store(STRING_WITH_LEN("def"), system_charset_info); table->field[3]->store(check->name.str, check->name.length, system_charset_info); + /* Make sure the string is empty between each print. */ str.length(0); check->print(&str); table->field[4]->store(str.ptr(), str.length(), system_charset_info); @@ -6551,8 +6568,7 @@ static int get_check_constraints_record(THD *thd, TABLE_LIST *tables, DBUG_RETURN(1); } } - - DBUG_RETURN(0); + DBUG_RETURN(res); } static int get_schema_constraints_record(THD *thd, TABLE_LIST *tables, @@ -9370,11 +9386,14 @@ ST_FIELD_INFO spatial_ref_sys_fields_info[]= ST_FIELD_INFO check_constraints_fields_info[]= { {"CONSTRAINT_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE}, - {"CONSTRAINT_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE}, + {"CONSTRAINT_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, + OPEN_FULL_TABLE}, {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE}, - {"CONSTRAINT_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE}, - {"CHECK_CLAUSE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE}, - {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE } + {"CONSTRAINT_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, + OPEN_FULL_TABLE}, + {"CHECK_CLAUSE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, + OPEN_FULL_TABLE}, + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} }; /* @@ -9393,7 +9412,7 @@ ST_SCHEMA_TABLE schema_tables[]= {"CHARACTER_SETS", charsets_fields_info, 0, fill_schema_charsets, make_character_sets_old_format, 0, -1, -1, 0, 0}, {"CHECK_CONSTRAINTS", check_constraints_fields_info, 0, get_all_tables, 0, - get_check_constraints_record, 1, 2, 0, OPTIMIZE_I_S_TABLE|OPEN_TABLE_ONLY}, + get_check_constraints_record, 1, 2, 0, OPTIMIZE_I_S_TABLE|OPEN_TABLE_ONLY}, {"COLLATIONS", collation_fields_info, 0, fill_schema_collation, make_old_format, 0, -1, -1, 0, 0}, {"COLLATION_CHARACTER_SET_APPLICABILITY", coll_charset_app_fields_info, |