summaryrefslogtreecommitdiff
path: root/sql/sql_show.cc
diff options
context:
space:
mode:
authorVicențiu Ciorbaru <vicentiu@mariadb.org>2019-12-13 16:36:46 +0200
committerVicențiu Ciorbaru <vicentiu@mariadb.org>2019-12-13 16:36:46 +0200
commit193b5ed50bc203a68aacc5298b01717777701285 (patch)
tree6dd2d99935e9bb50c8c127475ecab94ce9ee55c7 /sql/sql_show.cc
parent3466b47b0d2f0aca0a2191574c593c7eaea0b0b8 (diff)
parenta134f1ebb129bdd0f312ec0204b9dba38fa24359 (diff)
downloadmariadb-git-193b5ed50bc203a68aacc5298b01717777701285.tar.gz
Merge branch '10.2' into 10.3
Diffstat (limited to 'sql/sql_show.cc')
-rw-r--r--sql/sql_show.cc44
1 files changed, 28 insertions, 16 deletions
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 85e915bb65a..3f18f659f7e 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -6865,23 +6865,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);
@@ -9806,9 +9818,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}
@@ -9828,8 +9840,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,