summaryrefslogtreecommitdiff
path: root/plugin/userstat
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2018-01-07 18:03:44 +0200
committerMonty <monty@mariadb.org>2018-01-30 21:33:55 +0200
commita7e352b54ddfaf91c92951d605cb02a4ffd2676b (patch)
treedc76f140342938ed2a0fe0e005100402762d5308 /plugin/userstat
parent921c5e931452301a09c84c53ffe35b81e6a1c71a (diff)
downloadmariadb-git-a7e352b54ddfaf91c92951d605cb02a4ffd2676b.tar.gz
Changed database, tablename and alias to be LEX_CSTRING
This was done in, among other things: - thd->db and thd->db_length - TABLE_LIST tablename, db, alias and schema_name - Audit plugin database name - lex->db - All db and table names in Alter_table_ctx - st_select_lex db Other things: - Changed a lot of functions to take const LEX_CSTRING* as argument for db, table_name and alias. See init_one_table() as an example. - Changed some function arguments from LEX_CSTRING to const LEX_CSTRING - Changed some lists from LEX_STRING to LEX_CSTRING - threads_mysql.result changed because process list_db wasn't always correctly updated - New append_identifier() function that takes LEX_CSTRING* as arguments - Added new element tmp_buff to Alter_table_ctx to separate temp name handling from temporary space - Ensure we store the length after my_casedn_str() of table/db names - Removed not used version of rename_table_in_stat_tables() - Changed Natural_join_column::table_name and db_name() to never return NULL (used for print) - thd->get_db() now returns db as a printable string (thd->db.str or "")
Diffstat (limited to 'plugin/userstat')
-rw-r--r--plugin/userstat/index_stats.cc25
-rw-r--r--plugin/userstat/table_stats.cc8
2 files changed, 17 insertions, 16 deletions
diff --git a/plugin/userstat/index_stats.cc b/plugin/userstat/index_stats.cc
index 87e6da63e38..0528507c50e 100644
--- a/plugin/userstat/index_stats.cc
+++ b/plugin/userstat/index_stats.cc
@@ -17,27 +17,26 @@ static int index_stats_fill(THD *thd, TABLE_LIST *tables, COND *cond)
INDEX_STATS *index_stats =
(INDEX_STATS*) my_hash_element(&global_index_stats, i);
TABLE_LIST tmp_table;
- char *index_name;
- size_t schema_name_length, table_name_length, index_name_length;
+ const char *index_name;
+ size_t index_name_length;
bzero((char*) &tmp_table,sizeof(tmp_table));
- tmp_table.db= index_stats->index;
- tmp_table.table_name= strend(index_stats->index)+1;
+ tmp_table.db.str= index_stats->index;
+ tmp_table.db.length= strlen(index_stats->index);
+ tmp_table.table_name.str= index_stats->index + tmp_table.db.length + 1;
+ tmp_table.table_name.length= strlen(tmp_table.table_name.str);
tmp_table.grant.privilege= 0;
- if (check_access(thd, SELECT_ACL, tmp_table.db,
+ if (check_access(thd, SELECT_ACL, tmp_table.db.str,
&tmp_table.grant.privilege, NULL, 0, 1) ||
check_grant(thd, SELECT_ACL, &tmp_table, 1, UINT_MAX, 1))
continue;
- index_name= strend(tmp_table.table_name)+1;
- schema_name_length= (tmp_table.table_name - index_stats->index) -1;
- table_name_length= (index_name - tmp_table.table_name)-1;
- index_name_length= (index_stats->index_name_length - schema_name_length -
- table_name_length - 3);
+ index_name= tmp_table.table_name.str + tmp_table.table_name.length + 1;
+ index_name_length= (index_stats->index_name_length - tmp_table.db.length -
+ tmp_table.table_name.length - 3);
- table->field[0]->store(tmp_table.db, (uint)schema_name_length,
- system_charset_info);
- table->field[1]->store(tmp_table.table_name, (uint) table_name_length,
+ table->field[0]->store(tmp_table.db.str, tmp_table.db.length, system_charset_info);
+ table->field[1]->store(tmp_table.table_name.str, tmp_table.table_name.length,
system_charset_info);
table->field[2]->store(index_name, (uint) index_name_length, system_charset_info);
table->field[3]->store((longlong)index_stats->rows_read, TRUE);
diff --git a/plugin/userstat/table_stats.cc b/plugin/userstat/table_stats.cc
index 7b522a388d7..3119e516e06 100644
--- a/plugin/userstat/table_stats.cc
+++ b/plugin/userstat/table_stats.cc
@@ -26,10 +26,12 @@ static int table_stats_fill(THD *thd, TABLE_LIST *tables, COND *cond)
table_name_length= strlen(table_stats->table + schema_length + 1);
bzero((char*) &tmp_table,sizeof(tmp_table));
- tmp_table.db= table_stats->table;
- tmp_table.table_name= end_of_schema+1;
+ tmp_table.db.str= table_stats->table;
+ tmp_table.db.length= schema_length;
+ tmp_table.table_name.str= end_of_schema+1;
+ tmp_table.table_name.length= table_name_length;
tmp_table.grant.privilege= 0;
- if (check_access(thd, SELECT_ACL, tmp_table.db,
+ if (check_access(thd, SELECT_ACL, tmp_table.db.str,
&tmp_table.grant.privilege, NULL, 0, 1) ||
check_grant(thd, SELECT_ACL, &tmp_table, 1, UINT_MAX,
1))