diff options
author | Alexander Barkov <bar@mariadb.com> | 2019-12-25 13:33:28 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2019-12-25 13:33:28 +0400 |
commit | 4c57ab34d4852387da4ef8eac862045d1458de1e (patch) | |
tree | 743ed619818e8862b9707f7c8f12691eeda76db5 /sql/sql_show.cc | |
parent | 3fbd9f1522cf52247b9659cd50efe367767abf0e (diff) | |
parent | ee9a19fb054085fcea006a25ec957e0d5cb01ce8 (diff) | |
download | mariadb-git-4c57ab34d4852387da4ef8eac862045d1458de1e.tar.gz |
Merge remote-tracking branch 'origin/10.3' into 10.4
Diffstat (limited to 'sql/sql_show.cc')
-rw-r--r-- | sql/sql_show.cc | 44 |
1 files changed, 28 insertions, 16 deletions
diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 1cd43cc24ab..03de557b400 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -6908,23 +6908,35 @@ static int get_check_constraints_record(THD *thd, TABLE_LIST *tables, thd->clear_error(); DBUG_RETURN(0); } - else if (!tables->view) + if (!tables->view) { - if (tables->table->s->table_check_constraints) + 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++) { - for (uint i= 0; i < tables->table->s->table_check_constraints; i++) +#ifndef NO_EMBEDDED_ACCESS_CHECKS + if (!(thd->col_access & TABLE_ACLS)) { - StringBuffer<MAX_FIELD_WIDTH> str(system_charset_info); - Virtual_column_info *check= tables->table->check_constraints[i]; - restore_record(table, s->default_values); - table->field[0]->store(STRING_WITH_LEN("def"), system_charset_info); - table->field[1]->store(db_name->str, db_name->length, system_charset_info); - table->field[2]->store(check->name.str, check->name.length, system_charset_info); - table->field[3]->store(table_name->str, table_name->length, system_charset_info); - check->print(&str); - table->field[4]->store(str.ptr(), str.length(), system_charset_info); - schema_table_store_record(thd, table); + table_acl_check.db= *db_name; + table_acl_check.table_name= *table_name; + 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); + if (schema_table_store_record(thd, table)) + DBUG_RETURN(1); } } DBUG_RETURN(res); @@ -9847,9 +9859,9 @@ 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}, + {"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}, - {"TABLE_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} @@ -9873,8 +9885,8 @@ ST_SCHEMA_TABLE schema_tables[]= fill_schema_applicable_roles, 0, 0, -1, -1, 0, 0}, {"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}, + {"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}, {"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, |