diff options
author | Monty <monty@mariadb.org> | 2018-01-07 18:03:44 +0200 |
---|---|---|
committer | Monty <monty@mariadb.org> | 2018-01-30 21:33:55 +0200 |
commit | a7e352b54ddfaf91c92951d605cb02a4ffd2676b (patch) | |
tree | dc76f140342938ed2a0fe0e005100402762d5308 /sql/sql_cache.cc | |
parent | 921c5e931452301a09c84c53ffe35b81e6a1c71a (diff) | |
download | mariadb-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 'sql/sql_cache.cc')
-rw-r--r-- | sql/sql_cache.cc | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index 766aa8099ba..c340f4afc8b 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -1498,18 +1498,18 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d", query_length= thd->base_query.length(); /* Key is query + database + flag */ - if (thd->db_length) + if (thd->db.length) { memcpy((char*) (query + query_length + 1 + QUERY_CACHE_DB_LENGTH_SIZE), - thd->db, thd->db_length); + thd->db.str, thd->db.length); DBUG_PRINT("qcache", ("database: %s length: %u", - thd->db, (unsigned) thd->db_length)); + thd->db.str, (unsigned) thd->db.length)); } else { DBUG_PRINT("qcache", ("No active database")); } - tot_length= (query_length + thd->db_length + 1 + + tot_length= (query_length + thd->db.length + 1 + QUERY_CACHE_DB_LENGTH_SIZE + QUERY_CACHE_FLAGS_SIZE); /* We should only copy structure (don't use it location directly) @@ -1693,7 +1693,7 @@ size_t build_normalized_name(char *buff, size_t bufflen, In case of -1, no error is sent to the client. *) The buffer must be allocated memory of size: - tot_length= query_length + thd->db_length + 1 + QUERY_CACHE_FLAGS_SIZE; + tot_length= query_length + thd->db.length + 1 + QUERY_CACHE_FLAGS_SIZE; */ int @@ -1852,7 +1852,7 @@ Query_cache::send_result_to_client(THD *thd, char *org_sql, uint query_length) as the previous one. */ size_t db_len= uint2korr(sql_end+1); - if (thd->db_length != db_len) + if (thd->db.length != db_len) { /* We should probably reallocate the buffer in this case, @@ -1886,7 +1886,7 @@ Query_cache::send_result_to_client(THD *thd, char *org_sql, uint query_length) if (found_brace) sql= found_brace; make_base_query(&thd->base_query, sql, (size_t) (sql_end - sql), - thd->db_length + 1 + QUERY_CACHE_DB_LENGTH_SIZE + + thd->db.length + 1 + QUERY_CACHE_DB_LENGTH_SIZE + QUERY_CACHE_FLAGS_SIZE); sql= thd->base_query.ptr(); query_length= thd->base_query.length(); @@ -1898,14 +1898,14 @@ Query_cache::send_result_to_client(THD *thd, char *org_sql, uint query_length) } tot_length= (query_length + 1 + QUERY_CACHE_DB_LENGTH_SIZE + - thd->db_length + QUERY_CACHE_FLAGS_SIZE); + thd->db.length + QUERY_CACHE_FLAGS_SIZE); - if (thd->db_length) + if (thd->db.length) { memcpy((uchar*) sql + query_length + 1 + QUERY_CACHE_DB_LENGTH_SIZE, - thd->db, thd->db_length); + thd->db.str, thd->db.length); DBUG_PRINT("qcache", ("database: '%s' length: %u", - thd->db, (uint) thd->db_length)); + thd->db.str, (uint) thd->db.length)); } else { @@ -2061,14 +2061,17 @@ lookup: } bzero((char*) &table_list,sizeof(table_list)); - table_list.db = table->db(); - table_list.alias= table_list.table_name= table->table(); + table_list.db.str= table->db(); + table_list.db.length= strlen(table_list.db.str); + table_list.alias.str= table_list.table_name.str= table->table(); + table_list.alias.length= table_list.table_name.length= strlen(table->table()); + #ifndef NO_EMBEDDED_ACCESS_CHECKS if (check_table_access(thd,SELECT_ACL,&table_list, FALSE, 1,TRUE)) { DBUG_PRINT("qcache", ("probably no SELECT access to %s.%s => return to normal processing", - table_list.db, table_list.alias)); + table_list.db.str, table_list.alias.str)); unlock(); thd->query_cache_is_applicable= 0; // Query can't be cached thd->lex->safe_to_cache_query= 0; // For prepared statements @@ -2078,7 +2081,7 @@ lookup: if (table_list.grant.want_privilege) { DBUG_PRINT("qcache", ("Need to check column privileges for %s.%s", - table_list.db, table_list.alias)); + table_list.db.str, table_list.alias.str)); BLOCK_UNLOCK_RD(query_block); thd->query_cache_is_applicable= 0; // Query can't be cached thd->lex->safe_to_cache_query= 0; // For prepared statements @@ -2138,7 +2141,7 @@ lookup: } else DBUG_PRINT("qcache", ("handler allow caching %s,%s", - table_list.db, table_list.alias)); + table_list.db.str, table_list.alias.str)); } move_to_query_list_end(query_block); hits++; @@ -3397,7 +3400,7 @@ Query_cache::register_tables_from_list(THD *thd, TABLE_LIST *tables_used, if (!insert_table(thd, tables_used->table->s->table_cache_key.length, tables_used->table->s->table_cache_key.str, (*block_table), - tables_used->db_length, 0, + tables_used->db.length, 0, tables_used->table->file->table_cache_type(), tables_used->callback_func, tables_used->engine_data, @@ -4053,7 +4056,7 @@ Query_cache::process_and_count_tables(THD *thd, TABLE_LIST *tables_used, } if (tables_used->derived) { - DBUG_PRINT("qcache", ("table: %s", tables_used->alias)); + DBUG_PRINT("qcache", ("table: %s", tables_used->alias.str)); table_count--; DBUG_PRINT("qcache", ("derived table skipped")); continue; |