mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
PR#1127: Fix is_check_constraints.result to be compatibile with 10.3 The patch is done according to the original patch for MDEV-144741edd09c325
and not one which is merged on serverd526679efd
. 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 patchc8b8b01b61
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
This commit is contained in:
committed by
Vicențiu Ciorbaru
parent
f0aa073f2b
commit
a134f1ebb1
@ -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,
|
||||
|
Reference in New Issue
Block a user