mirror of
https://github.com/MariaDB/server.git
synced 2026-01-06 05:22:24 +03:00
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 "")
This commit is contained in:
@@ -969,6 +969,7 @@ static struct errors *generate_empty_message(uint d_code, my_bool skip)
|
||||
new_error->d_code= d_code;
|
||||
new_error->sql_code1= empty_string;
|
||||
new_error->sql_code2= empty_string;
|
||||
new_error->next_error= 0;
|
||||
|
||||
message.text= 0; /* If skip set, don't generate a text */
|
||||
|
||||
@@ -998,6 +999,7 @@ static struct errors *parse_error_string(char *str, int er_count)
|
||||
MYF(MY_WME))))
|
||||
DBUG_RETURN(0);
|
||||
|
||||
new_error->next_error= 0;
|
||||
if (my_init_dynamic_array(&new_error->msg, sizeof(struct message), 0, 0, MYF(0)))
|
||||
DBUG_RETURN(0); /* OOM: Fatal error */
|
||||
|
||||
|
||||
@@ -65,8 +65,7 @@ struct mysql_event_general
|
||||
unsigned long long general_rows;
|
||||
/* Added in version 0x302 */
|
||||
unsigned long long query_id;
|
||||
const char *database;
|
||||
unsigned int database_length;
|
||||
MYSQL_CONST_LEX_STRING database;
|
||||
};
|
||||
|
||||
|
||||
@@ -101,8 +100,7 @@ struct mysql_event_connection
|
||||
unsigned int host_length;
|
||||
const char *ip;
|
||||
unsigned int ip_length;
|
||||
const char *database;
|
||||
unsigned int database_length;
|
||||
MYSQL_CONST_LEX_STRING database;
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -137,17 +135,13 @@ struct mysql_event_table
|
||||
const char *proxy_user;
|
||||
const char *host;
|
||||
const char *ip;
|
||||
const char *database;
|
||||
unsigned int database_length;
|
||||
const char *table;
|
||||
unsigned int table_length;
|
||||
MYSQL_CONST_LEX_STRING database;
|
||||
MYSQL_CONST_LEX_STRING table;
|
||||
/* for MYSQL_AUDIT_TABLE_RENAME */
|
||||
MYSQL_CONST_LEX_STRING new_database;
|
||||
MYSQL_CONST_LEX_STRING new_table;
|
||||
/* for MYSQL_AUDIT_TABLE_LOCK, true if read-only, false if read/write */
|
||||
int read_only;
|
||||
/* for MYSQL_AUDIT_TABLE_RENAME */
|
||||
const char *new_database;
|
||||
unsigned int new_database_length;
|
||||
const char *new_table;
|
||||
unsigned int new_table_length;
|
||||
/* Added in version 0x302 */
|
||||
unsigned long long query_id;
|
||||
};
|
||||
|
||||
@@ -543,8 +543,7 @@ struct mysql_event_general
|
||||
unsigned long long general_time;
|
||||
unsigned long long general_rows;
|
||||
unsigned long long query_id;
|
||||
const char *database;
|
||||
unsigned int database_length;
|
||||
MYSQL_CONST_LEX_STRING database;
|
||||
};
|
||||
struct mysql_event_connection
|
||||
{
|
||||
@@ -563,8 +562,7 @@ struct mysql_event_connection
|
||||
unsigned int host_length;
|
||||
const char *ip;
|
||||
unsigned int ip_length;
|
||||
const char *database;
|
||||
unsigned int database_length;
|
||||
MYSQL_CONST_LEX_STRING database;
|
||||
};
|
||||
struct mysql_event_table
|
||||
{
|
||||
@@ -577,15 +575,11 @@ struct mysql_event_table
|
||||
const char *proxy_user;
|
||||
const char *host;
|
||||
const char *ip;
|
||||
const char *database;
|
||||
unsigned int database_length;
|
||||
const char *table;
|
||||
unsigned int table_length;
|
||||
MYSQL_CONST_LEX_STRING database;
|
||||
MYSQL_CONST_LEX_STRING table;
|
||||
MYSQL_CONST_LEX_STRING new_database;
|
||||
MYSQL_CONST_LEX_STRING new_table;
|
||||
int read_only;
|
||||
const char *new_database;
|
||||
unsigned int new_database_length;
|
||||
const char *new_table;
|
||||
unsigned int new_table_length;
|
||||
unsigned long long query_id;
|
||||
};
|
||||
struct st_mysql_audit
|
||||
|
||||
@@ -50,11 +50,12 @@ extern struct my_print_error_service_st {
|
||||
#define my_printv_error(A,B,C,D) my_print_error_service->my_printv_error_func(A,B,C,D)
|
||||
|
||||
#else
|
||||
|
||||
#ifndef MY_ERROR_DEFINED
|
||||
extern void my_error(unsigned int nr, unsigned long MyFlags, ...);
|
||||
extern void my_printf_error(unsigned int my_err, const char *format, unsigned long MyFlags, ...);
|
||||
extern void my_printv_error(unsigned int error, const char *format, unsigned long MyFlags,va_list ap);
|
||||
#endif
|
||||
#endif /* MY_ERROR_DEFINED */
|
||||
#endif /* MYSQL_DYNAMIC_PLUGIN */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -692,8 +692,7 @@ void *create_embedded_thd(int client_flag)
|
||||
thd->client_capabilities= client_flag;
|
||||
thd->real_id= pthread_self();
|
||||
|
||||
thd->db= NULL;
|
||||
thd->db_length= 0;
|
||||
thd->db= null_clex_str;
|
||||
#ifndef NO_EMBEDDED_ACCESS_CHECKS
|
||||
thd->security_ctx->db_access= DB_ACLS;
|
||||
thd->security_ctx->master_access= ~NO_ACCESS;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
FLUSH TABLES;
|
||||
#
|
||||
# MDEV-11369: Instant ADD COLUMN for InnoDB
|
||||
#
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
--source include/have_debug.inc
|
||||
--source include/have_debug_sync.inc
|
||||
|
||||
FLUSH TABLES;
|
||||
|
||||
let INNODB_PAGE_SIZE=`select @@innodb_page_size`;
|
||||
let MYSQLD_DATADIR=`select @@datadir`;
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ name thread/sql/main
|
||||
type BACKGROUND
|
||||
processlist_user NULL
|
||||
processlist_host NULL
|
||||
processlist_db NULL
|
||||
processlist_db mysql
|
||||
processlist_command NULL
|
||||
processlist_info NULL
|
||||
unified_parent_thread_id NULL
|
||||
@@ -99,7 +99,7 @@ name thread/sql/event_worker
|
||||
type FOREGROUND
|
||||
processlist_user root
|
||||
processlist_host localhost
|
||||
processlist_db NULL
|
||||
processlist_db test
|
||||
processlist_command Sleep
|
||||
processlist_info SELECT SLEEP(3)
|
||||
unified_parent_thread_id unified parent_thread_id
|
||||
|
||||
@@ -145,7 +145,7 @@ static void audit_null_notify(MYSQL_THD thd __attribute__((unused)),
|
||||
break;
|
||||
case MYSQL_AUDIT_TABLE_RENAME:
|
||||
snprintf(buf, sizeof(buf), "rename to %s.%s",
|
||||
event_table->new_database, event_table->new_table);
|
||||
event_table->new_database.str, event_table->new_table.str);
|
||||
buf[sizeof(buf)-1]= 0;
|
||||
op= buf;
|
||||
break;
|
||||
@@ -154,7 +154,7 @@ static void audit_null_notify(MYSQL_THD thd __attribute__((unused)),
|
||||
fprintf(f, "%s[%s] @ %s [%s]\t%s.%s : %s\n",
|
||||
event_table->priv_user, event_table->user,
|
||||
event_table->host, ip,
|
||||
event_table->database, event_table->table, op);
|
||||
event_table->database.str, event_table->table.str, op);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ static COND* make_cond(THD *thd, TABLE_LIST *tables, LEX_STRING *filter)
|
||||
{
|
||||
Item_cond_or *res= NULL;
|
||||
Name_resolution_context nrc;
|
||||
const char *db= tables->db, *table= tables->alias;
|
||||
const char *db= tables->db.str, *table= tables->alias.str;
|
||||
LEX_CSTRING *field= &tables->table->field[0]->field_name;
|
||||
CHARSET_INFO *cs= &my_charset_latin1;
|
||||
|
||||
|
||||
@@ -105,8 +105,7 @@ static int prepare_for_fill(TABLE_LIST *tables)
|
||||
thd->set_time();
|
||||
thd->init_for_queries();
|
||||
thd->real_id= pthread_self();
|
||||
thd->db= NULL;
|
||||
thd->db_length= 0;
|
||||
thd->db= null_clex_str;
|
||||
thd->security_ctx->host_or_ip= "";
|
||||
thd->security_ctx->db_access= DB_ACLS;
|
||||
thd->security_ctx->master_access= ~NO_ACCESS;
|
||||
@@ -114,11 +113,9 @@ static int prepare_for_fill(TABLE_LIST *tables)
|
||||
lex_start(thd);
|
||||
mysql_init_select(thd->lex);
|
||||
|
||||
tables->init_one_table(INFORMATION_SCHEMA_NAME.str,
|
||||
INFORMATION_SCHEMA_NAME.length,
|
||||
i_s_feedback->table_name,
|
||||
strlen(i_s_feedback->table_name),
|
||||
0, TL_READ);
|
||||
LEX_CSTRING tbl_name= {i_s_feedback->table_name, strlen(i_s_feedback->table_name) };
|
||||
|
||||
tables->init_one_table(&INFORMATION_SCHEMA_NAME, &tbl_name, 0, TL_READ);
|
||||
tables->schema_table= i_s_feedback;
|
||||
tables->table= create_schema_table(thd, tables);
|
||||
if (!tables->table)
|
||||
|
||||
@@ -297,9 +297,9 @@ dbcontext::init_thread(const void *stack_bottom, volatile int& shutdown_flag)
|
||||
#else
|
||||
thd->options |= OPTION_BIN_LOG;
|
||||
#endif
|
||||
safeFree(thd->db);
|
||||
thd->db = 0;
|
||||
thd->db = my_strdup("handlersocket", MYF(0));
|
||||
safeFree((char*) thd->db.str);
|
||||
thd->db.str= my_strdup("handlersocket", MYF(0));
|
||||
thd->db.length= sizeof("handlersocket")-1;
|
||||
}
|
||||
thd->variables.option_bits |= OPTION_TABLE_LOCK;
|
||||
my_pthread_setspecific_ptr(THR_THD, thd);
|
||||
@@ -1005,8 +1005,9 @@ dbcontext::cmd_open(dbcallback_i& cb, const cmd_open_args& arg)
|
||||
bool refresh = true;
|
||||
const thr_lock_type lock_type = for_write_flag ? TL_WRITE : TL_READ;
|
||||
#if MYSQL_VERSION_ID >= 50505
|
||||
tables.init_one_table(arg.dbn, strlen(arg.dbn), arg.tbl, strlen(arg.tbl),
|
||||
arg.tbl, lock_type);
|
||||
LEX_CSTRING db_name= { arg.dbn, strlen(arg.dbn) };
|
||||
LEX_CSTRING tbl_name= { arg.tbl, strlen(arg.tbl) };
|
||||
tables.init_one_table(&db_name, &tbl_name, 0, lock_type);
|
||||
tables.mdl_request.init(MDL_key::TABLE, arg.dbn, arg.tbl,
|
||||
for_write_flag ? MDL_SHARED_WRITE : MDL_SHARED_READ, MDL_TRANSACTION);
|
||||
Open_table_context ot_act(thd, 0);
|
||||
|
||||
@@ -1088,7 +1088,7 @@ static void setup_connection_connect(struct connection_info *cn,
|
||||
cn->log_always= 0;
|
||||
cn->thread_id= event->thread_id;
|
||||
get_str_n(cn->db, &cn->db_length, sizeof(cn->db),
|
||||
event->database, event->database_length);
|
||||
event->database.str, event->database.length);
|
||||
get_str_n(cn->user, &cn->user_length, sizeof(cn->db),
|
||||
event->user, event->user_length);
|
||||
get_str_n(cn->host, &cn->host_length, sizeof(cn->host),
|
||||
@@ -1176,7 +1176,7 @@ static void setup_connection_table(struct connection_info *cn,
|
||||
cn->log_always= 0;
|
||||
cn->query_length= 0;
|
||||
get_str_n(cn->db, &cn->db_length, sizeof(cn->db),
|
||||
event->database, event->database_length);
|
||||
event->database.str, event->database.length);
|
||||
get_str_n(cn->user, &cn->user_length, sizeof(cn->db),
|
||||
event->user, SAFE_STRLEN(event->user));
|
||||
get_str_n(cn->host, &cn->host_length, sizeof(cn->host),
|
||||
@@ -1324,7 +1324,7 @@ static int log_connection_event(const struct mysql_event_connection *event,
|
||||
event->ip, event->ip_length,
|
||||
event->thread_id, 0, type);
|
||||
csize+= my_snprintf(message+csize, sizeof(message) - 1 - csize,
|
||||
",%.*s,,%d", event->database_length, event->database, event->status);
|
||||
",%.*s,,%d", event->database.length, event->database.str, event->status);
|
||||
message[csize]= '\n';
|
||||
return write_log(message, csize + 1);
|
||||
}
|
||||
@@ -1742,8 +1742,8 @@ static int log_table(const struct connection_info *cn,
|
||||
event->ip, (unsigned int)SAFE_STRLEN(event->ip),
|
||||
event->thread_id, cn->query_id, type);
|
||||
csize+= my_snprintf(message+csize, sizeof(message) - 1 - csize,
|
||||
",%.*s,%.*s,",event->database_length, event->database,
|
||||
event->table_length, event->table);
|
||||
",%.*s,%.*s,",event->database.length, event->database.str,
|
||||
event->table.length, event->table.str);
|
||||
message[csize]= '\n';
|
||||
return write_log(message, csize + 1);
|
||||
}
|
||||
@@ -1764,10 +1764,10 @@ static int log_rename(const struct connection_info *cn,
|
||||
event->ip, (unsigned int)SAFE_STRLEN(event->ip),
|
||||
event->thread_id, cn->query_id, "RENAME");
|
||||
csize+= my_snprintf(message+csize, sizeof(message) - 1 - csize,
|
||||
",%.*s,%.*s|%.*s.%.*s,",event->database_length, event->database,
|
||||
event->table_length, event->table,
|
||||
event->new_database_length, event->new_database,
|
||||
event->new_table_length, event->new_table);
|
||||
",%.*s,%.*s|%.*s.%.*s,",event->database.length, event->database.str,
|
||||
event->table.length, event->table.str,
|
||||
event->new_database.length, event->new_database.str,
|
||||
event->new_table.length, event->new_table.str);
|
||||
message[csize]= '\n';
|
||||
return write_log(message, csize + 1);
|
||||
}
|
||||
@@ -1832,7 +1832,7 @@ static void update_connection_info(struct connection_info *cn,
|
||||
/* Change DB */
|
||||
if (mysql_57_started)
|
||||
get_str_n(cn->db, &cn->db_length, sizeof(cn->db),
|
||||
event->database, event->database_length);
|
||||
event->database.str, event->database.length);
|
||||
else
|
||||
get_str_n(cn->db, &cn->db_length, sizeof(cn->db),
|
||||
event->general_query, event->general_query_length);
|
||||
@@ -1858,9 +1858,9 @@ static void update_connection_info(struct connection_info *cn,
|
||||
if (ci_needs_setup(cn))
|
||||
setup_connection_query(cn, event);
|
||||
|
||||
if (mode == 0 && cn->db_length == 0 && event->database_length > 0)
|
||||
if (mode == 0 && cn->db_length == 0 && event->database.length > 0)
|
||||
get_str_n(cn->db, &cn->db_length, sizeof(cn->db),
|
||||
event->database, event->database_length);
|
||||
event->database.str, event->database.length);
|
||||
|
||||
if (event->general_error_code == 0)
|
||||
{
|
||||
@@ -1875,7 +1875,7 @@ static void update_connection_info(struct connection_info *cn,
|
||||
event->general_query + 4, event->general_query_length - 4);
|
||||
else
|
||||
get_str_n(cn->db, &cn->db_length, sizeof(cn->db),
|
||||
event->database, event->database_length);
|
||||
event->database.str, event->database.length);
|
||||
}
|
||||
}
|
||||
update_general_user(cn, event);
|
||||
@@ -1916,9 +1916,9 @@ static void update_connection_info(struct connection_info *cn,
|
||||
event->ip, SAFE_STRLEN(event->ip));
|
||||
}
|
||||
|
||||
if (cn->db_length == 0 && event->database_length != 0)
|
||||
if (cn->db_length == 0 && event->database.length != 0)
|
||||
get_str_n(cn->db, &cn->db_length, sizeof(cn->db),
|
||||
event->database, event->database_length);
|
||||
event->database.str, event->database.length);
|
||||
|
||||
if (mode == 0)
|
||||
cn->query_id= event->query_id;
|
||||
@@ -2145,8 +2145,8 @@ static void auditing_v8(MYSQL_THD thd, struct mysql_event_general_v8 *ev_v8)
|
||||
event.general_charset= ev_v8->general_charset;
|
||||
event.general_time= ev_v8->general_time;
|
||||
event.general_rows= ev_v8->general_rows;
|
||||
event.database= 0;
|
||||
event.database_length= 0;
|
||||
event.database.str= 0;
|
||||
event.database.length= 0;
|
||||
|
||||
if (event.general_query_length > 0)
|
||||
{
|
||||
@@ -2154,8 +2154,8 @@ static void auditing_v8(MYSQL_THD thd, struct mysql_event_general_v8 *ev_v8)
|
||||
event.general_command= "Query";
|
||||
event.general_command_length= 5;
|
||||
#ifdef __linux__
|
||||
event.database= *(char **) (((char *) thd) + db_off);
|
||||
event.database_length= *(size_t *) (((char *) thd) + db_len_off);
|
||||
event.database.str= *(char **) (((char *) thd) + db_off);
|
||||
event.database.length= *(size_t *) (((char *) thd) + db_len_off);
|
||||
#endif /*__linux*/
|
||||
}
|
||||
#ifdef __linux__
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -110,7 +110,7 @@ SET (SQL_SOURCE
|
||||
debug_sync.cc
|
||||
sql_repl.cc sql_select.cc sql_show.cc sql_state.c
|
||||
group_by_handler.cc
|
||||
sql_statistics.cc sql_string.cc
|
||||
sql_statistics.cc sql_string.cc lex_string.h
|
||||
sql_table.cc sql_test.cc sql_trigger.cc sql_udf.cc sql_union.cc
|
||||
sql_update.cc sql_view.cc strfunc.cc table.cc thr_malloc.cc
|
||||
sql_time.cc tztime.cc unireg.cc item_xmlfunc.cc
|
||||
|
||||
@@ -171,11 +171,11 @@ Event_creation_ctx::load_from_db(THD *thd,
|
||||
*/
|
||||
|
||||
bool
|
||||
Event_queue_element_for_exec::init(LEX_CSTRING db, LEX_CSTRING n)
|
||||
Event_queue_element_for_exec::init(const LEX_CSTRING *db, const LEX_CSTRING *n)
|
||||
{
|
||||
if (!(dbname.str= my_strndup(db.str, dbname.length= db.length, MYF(MY_WME))))
|
||||
if (!(dbname.str= my_strndup(db->str, dbname.length= db->length, MYF(MY_WME))))
|
||||
return TRUE;
|
||||
if (!(name.str= my_strndup(n.str, name.length= n.length, MYF(MY_WME))))
|
||||
if (!(name.str= my_strndup(n->str, name.length= n->length, MYF(MY_WME))))
|
||||
{
|
||||
my_free(const_cast<char*>(dbname.str));
|
||||
return TRUE;
|
||||
@@ -1196,7 +1196,7 @@ Event_timed::get_create_event(THD *thd, String *buf)
|
||||
buf->append(STRING_WITH_LEN("CREATE "));
|
||||
append_definer(thd, buf, &definer_user, &definer_host);
|
||||
buf->append(STRING_WITH_LEN("EVENT "));
|
||||
append_identifier(thd, buf, name.str, name.length);
|
||||
append_identifier(thd, buf, &name);
|
||||
|
||||
if (expression)
|
||||
{
|
||||
@@ -1274,7 +1274,7 @@ Event_job_data::construct_sp_sql(THD *thd, String *sp_sql)
|
||||
We're using append_identifier here to successfully parse
|
||||
events with reserved names.
|
||||
*/
|
||||
append_identifier(thd, sp_sql, name.str, name.length);
|
||||
append_identifier(thd, sp_sql, &name);
|
||||
|
||||
/*
|
||||
The default SQL security of a stored procedure is DEFINER. We
|
||||
@@ -1311,9 +1311,9 @@ Event_job_data::construct_drop_event_sql(THD *thd, String *sp_sql)
|
||||
sp_sql->length(0);
|
||||
|
||||
sp_sql->append(C_STRING_WITH_LEN("DROP EVENT "));
|
||||
append_identifier(thd, sp_sql, dbname.str, dbname.length);
|
||||
append_identifier(thd, sp_sql, &dbname);
|
||||
sp_sql->append('.');
|
||||
append_identifier(thd, sp_sql, name.str, name.length);
|
||||
append_identifier(thd, sp_sql, &name);
|
||||
|
||||
DBUG_RETURN(thd->is_fatal_error);
|
||||
}
|
||||
@@ -1355,7 +1355,7 @@ Event_job_data::execute(THD *thd, bool drop)
|
||||
mysql_change_db will be invoked anyway later, to activate the
|
||||
procedure database before it's executed.
|
||||
*/
|
||||
thd->set_db(dbname.str, dbname.length);
|
||||
thd->set_db(&dbname);
|
||||
|
||||
lex_start(thd);
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ public:
|
||||
~Event_queue_element_for_exec();
|
||||
|
||||
bool
|
||||
init(LEX_CSTRING dbname, LEX_CSTRING name);
|
||||
init(const LEX_CSTRING *dbname, const LEX_CSTRING *name);
|
||||
|
||||
LEX_CSTRING dbname;
|
||||
LEX_CSTRING name;
|
||||
|
||||
@@ -164,6 +164,8 @@ const TABLE_FIELD_TYPE event_table_fields[ET_FIELD_COUNT] =
|
||||
}
|
||||
};
|
||||
|
||||
static LEX_CSTRING MYSQL_EVENT_NAME= { STRING_WITH_LEN("event") };
|
||||
|
||||
static const TABLE_FIELD_DEF
|
||||
event_table_def= {ET_FIELD_COUNT, event_table_fields, 0, (uint*) 0};
|
||||
|
||||
@@ -538,7 +540,7 @@ Event_db_repository::fill_schema_events(THD *thd, TABLE_LIST *i_s_table,
|
||||
DBUG_ENTER("Event_db_repository::fill_schema_events");
|
||||
DBUG_PRINT("info",("db=%s", db? db:"(null)"));
|
||||
|
||||
event_table.init_one_table("mysql", 5, "event", 5, "event", TL_READ);
|
||||
event_table.init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_EVENT_NAME, 0, TL_READ);
|
||||
|
||||
if (open_system_tables_for_read(thd, &event_table, &open_tables_backup))
|
||||
DBUG_RETURN(TRUE);
|
||||
@@ -600,7 +602,7 @@ Event_db_repository::open_event_table(THD *thd, enum thr_lock_type lock_type,
|
||||
TABLE_LIST tables;
|
||||
DBUG_ENTER("Event_db_repository::open_event_table");
|
||||
|
||||
tables.init_one_table("mysql", 5, "event", 5, "event", lock_type);
|
||||
tables.init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_EVENT_NAME, 0, lock_type);
|
||||
|
||||
if (open_and_lock_tables(thd, &tables, FALSE, MYSQL_LOCK_IGNORE_TIMEOUT))
|
||||
DBUG_RETURN(TRUE);
|
||||
@@ -1066,7 +1068,7 @@ Event_db_repository::load_named_event(THD *thd, const LEX_CSTRING *dbname,
|
||||
DBUG_PRINT("enter",("thd: %p name: %*s", thd,
|
||||
(int) name->length, name->str));
|
||||
|
||||
event_table.init_one_table("mysql", 5, "event", 5, "event", TL_READ);
|
||||
event_table.init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_EVENT_NAME, 0, TL_READ);
|
||||
|
||||
/* Reset sql_mode during data dictionary operations. */
|
||||
thd->variables.sql_mode= 0;
|
||||
@@ -1189,7 +1191,7 @@ Event_db_repository::check_system_tables(THD *thd)
|
||||
DBUG_PRINT("enter", ("thd: %p", thd));
|
||||
|
||||
/* Check mysql.db */
|
||||
tables.init_one_table("mysql", 5, "db", 2, "db", TL_READ);
|
||||
tables.init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_DB_NAME, 0, TL_READ);
|
||||
|
||||
if (open_and_lock_tables(thd, &tables, FALSE, MYSQL_LOCK_IGNORE_TIMEOUT))
|
||||
{
|
||||
@@ -1204,7 +1206,7 @@ Event_db_repository::check_system_tables(THD *thd)
|
||||
close_mysql_tables(thd);
|
||||
}
|
||||
/* Check mysql.user */
|
||||
tables.init_one_table("mysql", 5, "user", 4, "user", TL_READ);
|
||||
tables.init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_USER_NAME, 0, TL_READ);
|
||||
|
||||
if (open_and_lock_tables(thd, &tables, FALSE, MYSQL_LOCK_IGNORE_TIMEOUT))
|
||||
{
|
||||
@@ -1224,7 +1226,7 @@ Event_db_repository::check_system_tables(THD *thd)
|
||||
close_mysql_tables(thd);
|
||||
}
|
||||
/* Check mysql.event */
|
||||
tables.init_one_table("mysql", 5, "event", 5, "event", TL_READ);
|
||||
tables.init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_EVENT_NAME, 0, TL_READ);
|
||||
|
||||
if (open_and_lock_tables(thd, &tables, FALSE, MYSQL_LOCK_IGNORE_TIMEOUT))
|
||||
{
|
||||
|
||||
@@ -637,7 +637,7 @@ Event_queue::get_top_for_execution_if_time(THD *thd,
|
||||
}
|
||||
|
||||
if (!(*event_name= new Event_queue_element_for_exec()) ||
|
||||
(*event_name)->init(top->dbname, top->name))
|
||||
(*event_name)->init(&top->dbname, &top->name))
|
||||
{
|
||||
ret= TRUE;
|
||||
break;
|
||||
|
||||
@@ -826,12 +826,12 @@ Events::fill_schema_events(THD *thd, TABLE_LIST *tables, COND * /* cond */)
|
||||
*/
|
||||
if (thd->lex->sql_command == SQLCOM_SHOW_EVENTS)
|
||||
{
|
||||
DBUG_ASSERT(thd->lex->select_lex.db);
|
||||
if (!is_infoschema_db(thd->lex->select_lex.db) && // There is no events in I_S
|
||||
check_access(thd, EVENT_ACL, thd->lex->select_lex.db,
|
||||
DBUG_ASSERT(thd->lex->select_lex.db.str);
|
||||
if (!is_infoschema_db(&thd->lex->select_lex.db) && // There is no events in I_S
|
||||
check_access(thd, EVENT_ACL, thd->lex->select_lex.db.str,
|
||||
NULL, NULL, 0, 0))
|
||||
DBUG_RETURN(1);
|
||||
db= normalize_db_name(thd->lex->select_lex.db, db_tmp, sizeof(db_tmp));
|
||||
db= normalize_db_name(thd->lex->select_lex.db.str, db_tmp, sizeof(db_tmp));
|
||||
}
|
||||
ret= db_repository->fill_schema_events(thd, tables, db);
|
||||
|
||||
@@ -1252,7 +1252,7 @@ int wsrep_create_event_query(THD *thd, uchar** buf, size_t* buf_len)
|
||||
if (create_query_string(thd, &log_query))
|
||||
{
|
||||
WSREP_WARN("events create string failed: schema: %s, query: %s",
|
||||
(thd->db ? thd->db : "(null)"), thd->query());
|
||||
thd->get_db(), thd->query());
|
||||
return 1;
|
||||
}
|
||||
return wsrep_to_buf_helper(thd, log_query.ptr(), log_query.length(), buf, buf_len);
|
||||
|
||||
@@ -2078,7 +2078,7 @@ bool Field_vers_trx_id::get_date(MYSQL_TIME *ltime, ulonglong fuzzydate, ulonglo
|
||||
|
||||
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
|
||||
ER_VERS_NO_TRX_ID, ER_THD(thd, ER_VERS_NO_TRX_ID),
|
||||
trx_id);
|
||||
(longlong) trx_id);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -2567,7 +2567,7 @@ int ha_partition::set_up_table_before_create(TABLE *tbl,
|
||||
partition_element *part_elem)
|
||||
{
|
||||
int error= 0;
|
||||
const char *partition_name;
|
||||
LEX_CSTRING part_name;
|
||||
THD *thd= ha_thd();
|
||||
DBUG_ENTER("set_up_table_before_create");
|
||||
|
||||
@@ -2577,15 +2577,16 @@ int ha_partition::set_up_table_before_create(TABLE *tbl,
|
||||
DBUG_RETURN(1);
|
||||
tbl->s->max_rows= part_elem->part_max_rows;
|
||||
tbl->s->min_rows= part_elem->part_min_rows;
|
||||
partition_name= strrchr(partition_name_with_path, FN_LIBCHAR);
|
||||
part_name.str= strrchr(partition_name_with_path, FN_LIBCHAR)+1;
|
||||
part_name.length= strlen(part_name.str);
|
||||
if ((part_elem->index_file_name &&
|
||||
(error= append_file_to_dir(thd,
|
||||
(const char**)&part_elem->index_file_name,
|
||||
partition_name+1))) ||
|
||||
&part_name))) ||
|
||||
(part_elem->data_file_name &&
|
||||
(error= append_file_to_dir(thd,
|
||||
(const char**)&part_elem->data_file_name,
|
||||
partition_name+1))))
|
||||
&part_name))))
|
||||
{
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
@@ -10789,10 +10790,8 @@ int ha_partition::check_for_upgrade(HA_CHECK_OPT *check_opt)
|
||||
partition_info::enum_key_algorithm old_algorithm;
|
||||
old_algorithm= m_part_info->key_algorithm;
|
||||
error= HA_ADMIN_FAILED;
|
||||
append_identifier(ha_thd(), &db_name, table_share->db.str,
|
||||
table_share->db.length);
|
||||
append_identifier(ha_thd(), &table_name, table_share->table_name.str,
|
||||
table_share->table_name.length);
|
||||
append_identifier(ha_thd(), &db_name, &table_share->db);
|
||||
append_identifier(ha_thd(), &table_name, &table_share->table_name);
|
||||
if (m_part_info->key_algorithm != partition_info::KEY_ALGORITHM_NONE)
|
||||
{
|
||||
/*
|
||||
|
||||
@@ -2501,7 +2501,7 @@ const char *get_canonical_filename(handler *file, const char *path,
|
||||
The .frm file will be deleted only if we return 0.
|
||||
*/
|
||||
int ha_delete_table(THD *thd, handlerton *table_type, const char *path,
|
||||
const char *db, const char *alias, bool generate_warning)
|
||||
const LEX_CSTRING *db, const LEX_CSTRING *alias, bool generate_warning)
|
||||
{
|
||||
handler *file;
|
||||
char tmp_path[FN_REFLEN];
|
||||
@@ -2534,12 +2534,9 @@ int ha_delete_table(THD *thd, handlerton *table_type, const char *path,
|
||||
dummy_share.path.str= (char*) path;
|
||||
dummy_share.path.length= strlen(path);
|
||||
dummy_share.normalized_path= dummy_share.path;
|
||||
dummy_share.db.str= (char*) db;
|
||||
dummy_share.db.length= strlen(db);
|
||||
dummy_share.table_name.str= (char*) alias;
|
||||
dummy_share.table_name.length= strlen(alias);
|
||||
dummy_table.alias.set(alias, dummy_share.table_name.length,
|
||||
table_alias_charset);
|
||||
dummy_share.db= *db;
|
||||
dummy_share.table_name= *alias;
|
||||
dummy_table.alias.set(alias->str, alias->length, table_alias_charset);
|
||||
file->change_table_ptr(&dummy_table, &dummy_share);
|
||||
file->print_error(error, MYF(intercept ? ME_JUST_WARNING : 0));
|
||||
}
|
||||
@@ -4875,7 +4872,6 @@ int ha_create_table(THD *thd, const char *path,
|
||||
TABLE_SHARE share;
|
||||
bool temp_table __attribute__((unused)) =
|
||||
create_info->options & (HA_LEX_CREATE_TMP_TABLE | HA_CREATE_TMP_ALTER);
|
||||
|
||||
DBUG_ENTER("ha_create_table");
|
||||
|
||||
init_tmp_table_share(thd, &share, db, 0, table_name, path);
|
||||
@@ -4903,7 +4899,7 @@ int ha_create_table(THD *thd, const char *path,
|
||||
|
||||
share.m_psi= PSI_CALL_get_table_share(temp_table, &share);
|
||||
|
||||
if (open_table_from_share(thd, &share, "", 0, READ_ALL, 0, &table, true))
|
||||
if (open_table_from_share(thd, &share, &empty_clex_str, 0, READ_ALL, 0, &table, true))
|
||||
goto err;
|
||||
|
||||
update_create_info_from_table(create_info, &table);
|
||||
@@ -5214,7 +5210,7 @@ private:
|
||||
*hton will be NULL.
|
||||
*/
|
||||
|
||||
bool ha_table_exists(THD *thd, const char *db, const char *table_name,
|
||||
bool ha_table_exists(THD *thd, const LEX_CSTRING *db, const LEX_CSTRING *table_name,
|
||||
handlerton **hton, bool *is_sequence)
|
||||
{
|
||||
handlerton *dummy;
|
||||
@@ -5229,7 +5225,7 @@ bool ha_table_exists(THD *thd, const char *db, const char *table_name,
|
||||
is_sequence= &dummy2;
|
||||
*is_sequence= 0;
|
||||
|
||||
TDC_element *element= tdc_lock_share(thd, db, table_name);
|
||||
TDC_element *element= tdc_lock_share(thd, db->str, table_name->str);
|
||||
if (element && element != MY_ERRPTR)
|
||||
{
|
||||
if (hton)
|
||||
@@ -5241,8 +5237,8 @@ bool ha_table_exists(THD *thd, const char *db, const char *table_name,
|
||||
|
||||
char path[FN_REFLEN + 1];
|
||||
size_t path_len = build_table_filename(path, sizeof(path) - 1,
|
||||
db, table_name, "", 0);
|
||||
st_discover_existence_args args= {path, path_len, db, table_name, 0, true};
|
||||
db->str, table_name->str, "", 0);
|
||||
st_discover_existence_args args= {path, path_len, db->str, table_name->str, 0, true};
|
||||
|
||||
if (file_ext_exists(path, path_len, reg_ext))
|
||||
{
|
||||
@@ -5285,14 +5281,12 @@ bool ha_table_exists(THD *thd, const char *db, const char *table_name,
|
||||
{
|
||||
TABLE_LIST table;
|
||||
uint flags = GTS_TABLE | GTS_VIEW;
|
||||
|
||||
if (!hton)
|
||||
flags|= GTS_NOLOCK;
|
||||
|
||||
Table_exists_error_handler no_such_table_handler;
|
||||
thd->push_internal_handler(&no_such_table_handler);
|
||||
table.init_one_table(db, strlen(db), table_name, strlen(table_name),
|
||||
table_name, TL_READ);
|
||||
table.init_one_table(db, table_name, 0, TL_READ);
|
||||
TABLE_SHARE *share= tdc_acquire_share(thd, &table, flags);
|
||||
thd->pop_internal_handler();
|
||||
|
||||
@@ -7000,7 +6994,8 @@ bool Table_scope_and_contents_source_st::vers_fix_system_fields(
|
||||
|
||||
if (!(alter_info->flags & Alter_info::ALTER_ADD_SYSTEM_VERSIONING) && vers_info)
|
||||
{
|
||||
my_error(ER_MISSING, MYF(0), create_table.table_name, "WITH SYSTEM VERSIONING");
|
||||
my_error(ER_MISSING, MYF(0), create_table.table_name.str,
|
||||
"WITH SYSTEM VERSIONING");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -7118,15 +7113,16 @@ bool Table_scope_and_contents_source_st::vers_fix_system_fields(
|
||||
vers_cols == 0 &&
|
||||
(plain_cols == 0 || !vers_info))
|
||||
{
|
||||
my_error(ER_VERS_TABLE_MUST_HAVE_COLUMNS, MYF(0), create_table.table_name);
|
||||
my_error(ER_VERS_TABLE_MUST_HAVE_COLUMNS, MYF(0),
|
||||
create_table.table_name.str);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (vers_info.check_with_conditions(create_table.table_name))
|
||||
if (vers_info.check_with_conditions(create_table.table_name.str))
|
||||
return true;
|
||||
|
||||
bool native= vers_native(thd);
|
||||
if (vers_info.check_sys_fields(create_table.table_name, alter_info, native))
|
||||
if (vers_info.check_sys_fields(create_table.table_name.str, alter_info, native))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@@ -7188,7 +7184,8 @@ bool Vers_parse_info::fix_alter_info(THD *thd, Alter_info *alter_info,
|
||||
return true;
|
||||
}
|
||||
|
||||
if (alter_info->flags & Alter_info::ALTER_ADD_SYSTEM_VERSIONING && table->versioned())
|
||||
if (alter_info->flags & Alter_info::ALTER_ADD_SYSTEM_VERSIONING &&
|
||||
table->versioned())
|
||||
{
|
||||
my_error(ER_VERS_ALREADY_VERSIONED, MYF(0), table_name);
|
||||
return true;
|
||||
@@ -7397,7 +7394,7 @@ Vers_parse_info::fix_create_like(Alter_info &alter_info, HA_CREATE_INFO &create_
|
||||
push_warning_printf(current_thd, Sql_condition::WARN_LEVEL_WARN,
|
||||
ER_UNKNOWN_ERROR,
|
||||
"System versioning is stripped from temporary `%s.%s`",
|
||||
table.db, table.table_name);
|
||||
table.db.str, table.table_name.str);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -7419,8 +7416,8 @@ Vers_parse_info::fix_create_like(Alter_info &alter_info, HA_CREATE_INFO &create_
|
||||
|
||||
if (!f_start || !f_end)
|
||||
{
|
||||
my_error(ER_MISSING, MYF(0), src_table.table_name,
|
||||
f_start ? "AS ROW END" : "AS ROW START");
|
||||
my_error(ER_MISSING, MYF(0), src_table.table_name.str,
|
||||
f_start ? "AS ROW END" : "AS ROW START");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -7480,7 +7477,8 @@ bool Vers_parse_info::check_sys_fields(const char *table_name,
|
||||
if (sys_flag & found_flag)
|
||||
{
|
||||
my_error(ER_VERS_DUPLICATE_ROW_START_END, MYF(0),
|
||||
found_flag & VERS_SYS_START_FLAG ? "START" : "END", f->field_name.str);
|
||||
found_flag & VERS_SYS_START_FLAG ? "START" : "END",
|
||||
f->field_name.str);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -7521,10 +7519,10 @@ bool Vers_parse_info::check_sys_fields(const char *table_name,
|
||||
}
|
||||
error:
|
||||
my_error(ER_VERS_FIELD_WRONG_TYPE, MYF(0), f->field_name.str,
|
||||
found == VERS_TIMESTAMP ?
|
||||
"TIMESTAMP(6)" :
|
||||
"BIGINT(20) UNSIGNED",
|
||||
table_name);
|
||||
found == VERS_TIMESTAMP ?
|
||||
"TIMESTAMP(6)" :
|
||||
"BIGINT(20) UNSIGNED",
|
||||
table_name);
|
||||
return true;
|
||||
}
|
||||
found= check_unit;
|
||||
@@ -7532,6 +7530,6 @@ bool Vers_parse_info::check_sys_fields(const char *table_name,
|
||||
}
|
||||
|
||||
my_error(ER_MISSING, MYF(0), table_name, found_flag & VERS_SYS_START_FLAG ?
|
||||
"ROW END" : found_flag ? "ROW START" : "ROW START/END");
|
||||
"ROW END" : found_flag ? "ROW START" : "ROW START/END");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1813,9 +1813,9 @@ struct Table_scope_and_contents_source_st
|
||||
LEX_CUSTRING tabledef_version;
|
||||
LEX_CSTRING connect_string;
|
||||
LEX_CSTRING comment;
|
||||
LEX_CSTRING alias;
|
||||
const char *password, *tablespace;
|
||||
const char *data_file_name, *index_file_name;
|
||||
const char *alias;
|
||||
ulonglong max_rows,min_rows;
|
||||
ulonglong auto_increment_value;
|
||||
ulong table_options; ///< HA_OPTION_ values
|
||||
@@ -4684,7 +4684,7 @@ int ha_create_table(THD *thd, const char *path,
|
||||
const char *db, const char *table_name,
|
||||
HA_CREATE_INFO *create_info, LEX_CUSTRING *frm);
|
||||
int ha_delete_table(THD *thd, handlerton *db_type, const char *path,
|
||||
const char *db, const char *alias, bool generate_warning);
|
||||
const LEX_CSTRING *db, const LEX_CSTRING *alias, bool generate_warning);
|
||||
|
||||
/* statistics and info */
|
||||
bool ha_show_status(THD *thd, handlerton *db_type, enum ha_stat_type stat);
|
||||
@@ -4722,7 +4722,7 @@ public:
|
||||
int ha_discover_table(THD *thd, TABLE_SHARE *share);
|
||||
int ha_discover_table_names(THD *thd, LEX_CSTRING *db, MY_DIR *dirp,
|
||||
Discovered_table_list *result, bool reusable);
|
||||
bool ha_table_exists(THD *thd, const char *db, const char *table_name,
|
||||
bool ha_table_exists(THD *thd, const LEX_CSTRING *db, const LEX_CSTRING *table_name,
|
||||
handlerton **hton= 0, bool *is_sequence= 0);
|
||||
#endif
|
||||
|
||||
@@ -4773,9 +4773,9 @@ const char *get_canonical_filename(handler *file, const char *path,
|
||||
bool mysql_xa_recover(THD *thd);
|
||||
void commit_checkpoint_notify_ha(handlerton *hton, void *cookie);
|
||||
|
||||
inline const char *table_case_name(HA_CREATE_INFO *info, const char *name)
|
||||
inline const LEX_CSTRING *table_case_name(HA_CREATE_INFO *info, const LEX_CSTRING *name)
|
||||
{
|
||||
return ((lower_case_table_names == 2 && info->alias) ? info->alias : name);
|
||||
return ((lower_case_table_names == 2 && info->alias.str) ? &info->alias : name);
|
||||
}
|
||||
|
||||
typedef bool Log_func(THD*, TABLE*, bool, const uchar*, const uchar*);
|
||||
|
||||
20
sql/item.cc
20
sql/item.cc
@@ -616,7 +616,7 @@ void Item::print_item_w_name(String *str, enum_query_type query_type)
|
||||
DBUG_ASSERT(name.length == strlen(name.str));
|
||||
THD *thd= current_thd;
|
||||
str->append(STRING_WITH_LEN(" AS "));
|
||||
append_identifier(thd, str, name.str, name.length);
|
||||
append_identifier(thd, str, &name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -762,10 +762,10 @@ Item_ident::Item_ident(THD *thd, Name_resolution_context *context_arg,
|
||||
Item_ident::Item_ident(THD *thd, TABLE_LIST *view_arg,
|
||||
const LEX_CSTRING *field_name_arg)
|
||||
:Item_result_field(thd), orig_db_name(NullS),
|
||||
orig_table_name(view_arg->table_name),
|
||||
orig_table_name(view_arg->table_name.str),
|
||||
orig_field_name(*field_name_arg),
|
||||
context(&view_arg->view->select_lex.context),
|
||||
db_name(NullS), table_name(view_arg->alias),
|
||||
db_name(NullS), table_name(view_arg->alias.str),
|
||||
field_name(*field_name_arg),
|
||||
alias_name_used(FALSE), cached_field_index(NO_CACHED_FIELD_INDEX),
|
||||
cached_table(NULL), depended_from(NULL), can_be_depended(TRUE)
|
||||
@@ -2770,10 +2770,10 @@ Item_sp::func_name(THD *thd) const
|
||||
qname.length(0);
|
||||
if (m_name->m_explicit_name)
|
||||
{
|
||||
append_identifier(thd, &qname, m_name->m_db.str, m_name->m_db.length);
|
||||
append_identifier(thd, &qname, &m_name->m_db);
|
||||
qname.append('.');
|
||||
}
|
||||
append_identifier(thd, &qname, m_name->m_name.str, m_name->m_name.length);
|
||||
append_identifier(thd, &qname, &m_name->m_name);
|
||||
return qname.c_ptr_safe();
|
||||
}
|
||||
|
||||
@@ -3279,7 +3279,7 @@ void Item_ident::print(String *str, enum_query_type query_type)
|
||||
bool use_db_name= use_table_name && db_name && db_name[0] && !alias_name_used;
|
||||
|
||||
if (use_db_name && (query_type & QT_ITEM_IDENT_SKIP_DB_NAMES))
|
||||
use_db_name= !thd->db || strcmp(thd->db, db_name);
|
||||
use_db_name= !thd->db.str || strcmp(thd->db.str, db_name);
|
||||
|
||||
if (use_db_name)
|
||||
use_db_name= !(cached_table && cached_table->belong_to_view &&
|
||||
@@ -3336,7 +3336,7 @@ void Item_ident::print(String *str, enum_query_type query_type)
|
||||
append_identifier(thd, str, t_name, (uint) strlen(t_name));
|
||||
str->append('.');
|
||||
}
|
||||
append_identifier(thd, str, field_name.str, field_name.length);
|
||||
append_identifier(thd, str, &field_name);
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
@@ -6047,8 +6047,7 @@ bool Item_field::fix_fields(THD *thd, Item **reference)
|
||||
|
||||
if (select && select->in_tvc)
|
||||
{
|
||||
my_error(ER_FIELD_REFERENCE_IN_TVC, MYF(0),
|
||||
full_name(), thd->where);
|
||||
my_error(ER_FIELD_REFERENCE_IN_TVC, MYF(0), full_name());
|
||||
return(1);
|
||||
}
|
||||
|
||||
@@ -8196,8 +8195,7 @@ void Item_ref::print(String *str, enum_query_type query_type)
|
||||
!table_name && name.str && alias_name_used)
|
||||
{
|
||||
THD *thd= current_thd;
|
||||
append_identifier(thd, str, (*ref)->real_item()->name.str,
|
||||
(*ref)->real_item()->name.length);
|
||||
append_identifier(thd, str, &(*ref)->real_item()->name);
|
||||
}
|
||||
else
|
||||
(*ref)->print(str, query_type);
|
||||
|
||||
@@ -3253,7 +3253,7 @@ Create_qfunc::create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list)
|
||||
{
|
||||
LEX_CSTRING db;
|
||||
|
||||
if (! thd->db && ! thd->lex->sphead)
|
||||
if (! thd->db.str && ! thd->lex->sphead)
|
||||
{
|
||||
/*
|
||||
The proper error message should be in the lines of:
|
||||
@@ -3271,7 +3271,7 @@ Create_qfunc::create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (thd->lex->copy_db_to(&db.str, &db.length))
|
||||
if (thd->lex->copy_db_to(&db))
|
||||
return NULL;
|
||||
|
||||
return create_with_db(thd, &db, name, false, item_list);
|
||||
|
||||
@@ -5439,7 +5439,7 @@ bool Item_func_get_user_var::const_item() const
|
||||
void Item_func_get_user_var::print(String *str, enum_query_type query_type)
|
||||
{
|
||||
str->append(STRING_WITH_LEN("@"));
|
||||
append_identifier(current_thd, str, name.str, name.length);
|
||||
append_identifier(current_thd, str, &name);
|
||||
}
|
||||
|
||||
|
||||
@@ -6410,8 +6410,8 @@ Item_func_sp::fix_fields(THD *thd, Item **ref)
|
||||
whether to return "Access denied" or "Routine does not exist".
|
||||
*/
|
||||
res= sp ? sp->check_execute_access(thd) :
|
||||
check_routine_access(thd, EXECUTE_ACL, m_name->m_db.str,
|
||||
m_name->m_name.str,
|
||||
check_routine_access(thd, EXECUTE_ACL, &m_name->m_db,
|
||||
&m_name->m_name,
|
||||
&sp_handler_function, false);
|
||||
thd->security_ctx= save_security_ctx;
|
||||
|
||||
@@ -6629,7 +6629,7 @@ void Item_func_last_value::fix_length_and_dec()
|
||||
|
||||
void Cursor_ref::print_func(String *str, const char *func_name)
|
||||
{
|
||||
append_identifier(current_thd, str, m_cursor_name.str, m_cursor_name.length);
|
||||
append_identifier(current_thd, str, &m_cursor_name);
|
||||
str->append(func_name);
|
||||
}
|
||||
|
||||
@@ -6751,8 +6751,9 @@ longlong Item_func_nextval::val_int()
|
||||
void Item_func_nextval::print(String *str, enum_query_type query_type)
|
||||
{
|
||||
char d_name_buff[MAX_ALIAS_NAME], t_name_buff[MAX_ALIAS_NAME];
|
||||
const char *d_name= table_list->db, *t_name= table_list->table_name;
|
||||
bool use_db_name= d_name && d_name[0];
|
||||
LEX_CSTRING d_name= table_list->db;
|
||||
LEX_CSTRING t_name= table_list->table_name;
|
||||
bool use_db_name= d_name.str && d_name.str[0];
|
||||
THD *thd= current_thd; // Don't trust 'table'
|
||||
|
||||
str->append(func_name());
|
||||
@@ -6765,23 +6766,23 @@ void Item_func_nextval::print(String *str, enum_query_type query_type)
|
||||
|
||||
if (lower_case_table_names > 0)
|
||||
{
|
||||
strmake(t_name_buff, t_name, MAX_ALIAS_NAME-1);
|
||||
my_casedn_str(files_charset_info, t_name_buff);
|
||||
t_name= t_name_buff;
|
||||
strmake(t_name_buff, t_name.str, MAX_ALIAS_NAME-1);
|
||||
t_name.length= my_casedn_str(files_charset_info, t_name_buff);
|
||||
t_name.str= t_name_buff;
|
||||
if (use_db_name)
|
||||
{
|
||||
strmake(d_name_buff, d_name, MAX_ALIAS_NAME-1);
|
||||
my_casedn_str(files_charset_info, d_name_buff);
|
||||
d_name= d_name_buff;
|
||||
strmake(d_name_buff, d_name.str, MAX_ALIAS_NAME-1);
|
||||
d_name.length= my_casedn_str(files_charset_info, d_name_buff);
|
||||
d_name.str= d_name_buff;
|
||||
}
|
||||
}
|
||||
|
||||
if (use_db_name)
|
||||
{
|
||||
append_identifier(thd, str, d_name, (uint)strlen(d_name));
|
||||
append_identifier(thd, str, &d_name);
|
||||
str->append('.');
|
||||
}
|
||||
append_identifier(thd, str, t_name, (uint) strlen(t_name));
|
||||
append_identifier(thd, str, &t_name);
|
||||
str->append(')');
|
||||
}
|
||||
|
||||
@@ -6874,8 +6875,9 @@ longlong Item_func_setval::val_int()
|
||||
void Item_func_setval::print(String *str, enum_query_type query_type)
|
||||
{
|
||||
char d_name_buff[MAX_ALIAS_NAME], t_name_buff[MAX_ALIAS_NAME];
|
||||
const char *d_name= table_list->db, *t_name= table_list->table_name;
|
||||
bool use_db_name= d_name && d_name[0];
|
||||
LEX_CSTRING d_name= table_list->db;
|
||||
LEX_CSTRING t_name= table_list->table_name;
|
||||
bool use_db_name= d_name.str && d_name.str[0];
|
||||
THD *thd= current_thd; // Don't trust 'table'
|
||||
|
||||
str->append(func_name());
|
||||
@@ -6888,23 +6890,23 @@ void Item_func_setval::print(String *str, enum_query_type query_type)
|
||||
|
||||
if (lower_case_table_names > 0)
|
||||
{
|
||||
strmake(t_name_buff, t_name, MAX_ALIAS_NAME-1);
|
||||
my_casedn_str(files_charset_info, t_name_buff);
|
||||
t_name= t_name_buff;
|
||||
strmake(t_name_buff, t_name.str, MAX_ALIAS_NAME-1);
|
||||
t_name.length= my_casedn_str(files_charset_info, t_name_buff);
|
||||
t_name.str= t_name_buff;
|
||||
if (use_db_name)
|
||||
{
|
||||
strmake(d_name_buff, d_name, MAX_ALIAS_NAME-1);
|
||||
my_casedn_str(files_charset_info, d_name_buff);
|
||||
d_name= d_name_buff;
|
||||
strmake(d_name_buff, d_name.str, MAX_ALIAS_NAME-1);
|
||||
d_name.length= my_casedn_str(files_charset_info, d_name_buff);
|
||||
d_name.str= d_name_buff;
|
||||
}
|
||||
}
|
||||
|
||||
if (use_db_name)
|
||||
{
|
||||
append_identifier(thd, str, d_name, (uint)strlen(d_name));
|
||||
append_identifier(thd, str, &d_name);
|
||||
str->append('.');
|
||||
}
|
||||
append_identifier(thd, str, t_name, (uint) strlen(t_name));
|
||||
append_identifier(thd, str, &t_name);
|
||||
str->append(',');
|
||||
str->append_longlong(nextval);
|
||||
str->append(',');
|
||||
|
||||
@@ -2383,13 +2383,13 @@ String *Item_func_database::val_str(String *str)
|
||||
{
|
||||
DBUG_ASSERT(fixed == 1);
|
||||
THD *thd= current_thd;
|
||||
if (thd->db == NULL)
|
||||
if (thd->db.str == NULL)
|
||||
{
|
||||
null_value= 1;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
str->copy(thd->db, thd->db_length, system_charset_info);
|
||||
str->copy(thd->db.str, thd->db.length, system_charset_info);
|
||||
null_value= 0;
|
||||
return str;
|
||||
}
|
||||
|
||||
@@ -4937,11 +4937,10 @@ bool subselect_hash_sj_engine::init(List<Item> *tmp_columns, uint subquery_id)
|
||||
DBUG_RETURN(TRUE);
|
||||
|
||||
char buf[32];
|
||||
uint len= my_snprintf(buf, sizeof(buf), "<subquery%u>", subquery_id);
|
||||
char *name;
|
||||
if (!(name= (char*)thd->alloc(len + 1)))
|
||||
LEX_CSTRING name;
|
||||
name.length= my_snprintf(buf, sizeof(buf), "<subquery%u>", subquery_id);
|
||||
if (!(name.str= (char*) thd->memdup(buf, name.length + 1)))
|
||||
DBUG_RETURN(TRUE);
|
||||
memcpy(name, buf, len+1);
|
||||
|
||||
result_sink->get_tmp_table_param()->materialized_subquery= true;
|
||||
if (item->substype() == Item_subselect::IN_SUBS &&
|
||||
@@ -4951,7 +4950,7 @@ bool subselect_hash_sj_engine::init(List<Item> *tmp_columns, uint subquery_id)
|
||||
}
|
||||
if (result_sink->create_result_table(thd, tmp_columns, TRUE,
|
||||
tmp_create_options,
|
||||
name, TRUE, TRUE, FALSE, 0))
|
||||
&name, TRUE, TRUE, FALSE, 0))
|
||||
DBUG_RETURN(TRUE);
|
||||
|
||||
tmp_table= result_sink->table;
|
||||
@@ -5037,7 +5036,7 @@ bool subselect_hash_sj_engine::make_semi_join_conds()
|
||||
/* Name resolution context for all tmp_table columns created below. */
|
||||
Name_resolution_context *context;
|
||||
Item_in_subselect *item_in= (Item_in_subselect *) item;
|
||||
|
||||
LEX_CSTRING table_name;
|
||||
DBUG_ENTER("subselect_hash_sj_engine::make_semi_join_conds");
|
||||
DBUG_ASSERT(semi_join_conds == NULL);
|
||||
|
||||
@@ -5047,10 +5046,9 @@ bool subselect_hash_sj_engine::make_semi_join_conds()
|
||||
if (!(tmp_table_ref= (TABLE_LIST*) thd->alloc(sizeof(TABLE_LIST))))
|
||||
DBUG_RETURN(TRUE);
|
||||
|
||||
tmp_table_ref->init_one_table(STRING_WITH_LEN(""),
|
||||
tmp_table->alias.c_ptr(),
|
||||
tmp_table->alias.length(),
|
||||
NULL, TL_READ);
|
||||
table_name.str= tmp_table->alias.c_ptr();
|
||||
table_name.length= tmp_table->alias.length(),
|
||||
tmp_table_ref->init_one_table(&empty_clex_str, &table_name, NULL, TL_READ);
|
||||
tmp_table_ref->table= tmp_table;
|
||||
|
||||
context= new Name_resolution_context;
|
||||
|
||||
@@ -794,7 +794,7 @@ bool Aggregator_distinct::setup(THD *thd)
|
||||
if (!(table= create_tmp_table(thd, tmp_table_param, list, (ORDER*) 0, 1,
|
||||
0,
|
||||
(select_lex->options | thd->variables.option_bits),
|
||||
HA_POS_ERROR, const_cast<char*>(""))))
|
||||
HA_POS_ERROR, &empty_clex_str)))
|
||||
return TRUE;
|
||||
table->file->extra(HA_EXTRA_NO_ROWS); // Don't update rows
|
||||
table->no_rows=1;
|
||||
@@ -4026,7 +4026,7 @@ bool Item_func_group_concat::setup(THD *thd)
|
||||
(ORDER*) 0, 0, TRUE,
|
||||
(select_lex->options |
|
||||
thd->variables.option_bits),
|
||||
HA_POS_ERROR, (char*) "")))
|
||||
HA_POS_ERROR, &empty_clex_str)))
|
||||
DBUG_RETURN(TRUE);
|
||||
table->file->extra(HA_EXTRA_NO_ROWS);
|
||||
table->no_rows= 1;
|
||||
|
||||
@@ -63,7 +63,7 @@ Item_func_vtq_ts::get_date(MYSQL_TIME *res, ulonglong fuzzy_date)
|
||||
null_value= !trt.query(trx_id);
|
||||
if (null_value)
|
||||
{
|
||||
my_error(ER_VERS_NO_TRX_ID, MYF(0), trx_id);
|
||||
my_error(ER_VERS_NO_TRX_ID, MYF(0), (longlong) trx_id);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
52
sql/lex_string.h
Normal file
52
sql/lex_string.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
Copyright (c) 2018, MariaDB Corporation.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
|
||||
#ifndef LEX_STRING_INCLUDED
|
||||
#define LEX_STRING_INCLUDED
|
||||
|
||||
typedef struct st_mysql_const_lex_string LEX_CSTRING;
|
||||
|
||||
/* Functions to compare if two lex strings are equal */
|
||||
inline bool lex_string_cmp(CHARSET_INFO *charset,
|
||||
const LEX_CSTRING *a,
|
||||
const LEX_CSTRING *b)
|
||||
{
|
||||
return my_strcasecmp(charset, a->str, b->str);
|
||||
}
|
||||
|
||||
/*
|
||||
Compare to LEX_CSTRING's and return 0 if equal
|
||||
*/
|
||||
inline bool cmp(const LEX_CSTRING *a, const LEX_CSTRING *b)
|
||||
{
|
||||
return (a->length != b->length ||
|
||||
memcmp(a->str, b->str, a->length));
|
||||
}
|
||||
|
||||
/*
|
||||
Compare if two LEX_CSTRING are equal. Assumption is that
|
||||
character set is ASCII (like for plugin names)
|
||||
*/
|
||||
inline bool lex_string_eq(const LEX_CSTRING *a,
|
||||
const LEX_CSTRING *b)
|
||||
{
|
||||
if (a->length != b->length)
|
||||
return 1; /* Different */
|
||||
return strcasecmp(a->str, b->str) != 0;
|
||||
}
|
||||
|
||||
#endif /* LEX_STRING_INCLUDED */
|
||||
@@ -1093,8 +1093,8 @@ void Global_read_lock::unlock_global_read_lock(THD *thd)
|
||||
int ret = wsrep->resync(wsrep);
|
||||
if (ret != WSREP_OK)
|
||||
{
|
||||
WSREP_WARN("resync failed %d for FTWRL: db: %s, query: %s", ret,
|
||||
(thd->db ? thd->db : "(null)"), thd->query());
|
||||
WSREP_WARN("resync failed %d for FTWRL: db: %s, query: %s",
|
||||
ret, thd->get_db(), thd->query());
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
}
|
||||
@@ -1180,7 +1180,7 @@ bool Global_read_lock::make_global_read_lock_block_commit(THD *thd)
|
||||
if (rcode != WSREP_OK)
|
||||
{
|
||||
WSREP_WARN("FTWRL desync failed %d for schema: %s, query: %s",
|
||||
rcode, (thd->db ? thd->db : "(null)"), thd->query());
|
||||
rcode, thd->get_db(), thd->query());
|
||||
my_message(ER_LOCK_DEADLOCK, "wsrep desync failed for FTWRL", MYF(0));
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
|
||||
40
sql/log.cc
40
sql/log.cc
@@ -608,19 +608,19 @@ int check_if_log_table(const TABLE_LIST *table,
|
||||
const char *error_msg)
|
||||
{
|
||||
int result= 0;
|
||||
if (table->db_length == 5 &&
|
||||
!my_strcasecmp(table_alias_charset, table->db, "mysql"))
|
||||
if (table->db.length == 5 &&
|
||||
!my_strcasecmp(table_alias_charset, table->db.str, "mysql"))
|
||||
{
|
||||
const char *table_name= table->table_name;
|
||||
const char *table_name= table->table_name.str;
|
||||
|
||||
if (table->table_name_length == 11 &&
|
||||
if (table->table_name.length == 11 &&
|
||||
!my_strcasecmp(table_alias_charset, table_name, "general_log"))
|
||||
{
|
||||
result= QUERY_LOG_GENERAL;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (table->table_name_length == 8 &&
|
||||
if (table->table_name.length == 8 &&
|
||||
!my_strcasecmp(table_alias_charset, table_name, "slow_log"))
|
||||
{
|
||||
result= QUERY_LOG_SLOW;
|
||||
@@ -716,9 +716,7 @@ bool Log_to_csv_event_handler::
|
||||
save_thd_options= thd->variables.option_bits;
|
||||
thd->variables.option_bits&= ~OPTION_BIN_LOG;
|
||||
|
||||
table_list.init_one_table(MYSQL_SCHEMA_NAME.str, MYSQL_SCHEMA_NAME.length,
|
||||
GENERAL_LOG_NAME.str, GENERAL_LOG_NAME.length,
|
||||
GENERAL_LOG_NAME.str,
|
||||
table_list.init_one_table(&MYSQL_SCHEMA_NAME, &GENERAL_LOG_NAME, 0,
|
||||
TL_WRITE_CONCURRENT_INSERT);
|
||||
|
||||
/*
|
||||
@@ -881,9 +879,7 @@ bool Log_to_csv_event_handler::
|
||||
*/
|
||||
save_time_zone_used= thd->time_zone_used;
|
||||
|
||||
table_list.init_one_table(MYSQL_SCHEMA_NAME.str, MYSQL_SCHEMA_NAME.length,
|
||||
SLOW_LOG_NAME.str, SLOW_LOG_NAME.length,
|
||||
SLOW_LOG_NAME.str,
|
||||
table_list.init_one_table(&MYSQL_SCHEMA_NAME, &SLOW_LOG_NAME, 0,
|
||||
TL_WRITE_CONCURRENT_INSERT);
|
||||
|
||||
if (!(table= open_log_table(thd, &table_list, &open_tables_backup)))
|
||||
@@ -937,9 +933,9 @@ bool Log_to_csv_event_handler::
|
||||
goto err;
|
||||
|
||||
/* fill database field */
|
||||
if (thd->db)
|
||||
if (thd->db.str)
|
||||
{
|
||||
if (table->field[6]->store(thd->db, thd->db_length, client_cs))
|
||||
if (table->field[6]->store(thd->db.str, thd->db.length, client_cs))
|
||||
goto err;
|
||||
table->field[6]->set_notnull();
|
||||
}
|
||||
@@ -1035,9 +1031,7 @@ int Log_to_csv_event_handler::
|
||||
|
||||
log_name= &SLOW_LOG_NAME;
|
||||
}
|
||||
table_list.init_one_table(MYSQL_SCHEMA_NAME.str, MYSQL_SCHEMA_NAME.length,
|
||||
log_name->str, log_name->length, log_name->str,
|
||||
TL_WRITE_CONCURRENT_INSERT);
|
||||
table_list.init_one_table(&MYSQL_SCHEMA_NAME, log_name, 0, TL_WRITE_CONCURRENT_INSERT);
|
||||
|
||||
table= open_log_table(thd, &table_list, &open_tables_backup);
|
||||
if (table)
|
||||
@@ -2263,8 +2257,7 @@ static int binlog_savepoint_set(handlerton *hton, THD *thd, void *sv)
|
||||
|
||||
String log_query(buf, sizeof(buf), &my_charset_bin);
|
||||
if (log_query.copy(STRING_WITH_LEN("SAVEPOINT "), &my_charset_bin) ||
|
||||
append_identifier(thd, &log_query,
|
||||
thd->lex->ident.str, thd->lex->ident.length))
|
||||
append_identifier(thd, &log_query, &thd->lex->ident))
|
||||
DBUG_RETURN(1);
|
||||
int errcode= query_error_code(thd, thd->killed == NOT_KILLED);
|
||||
Query_log_event qinfo(thd, log_query.c_ptr_safe(), log_query.length(),
|
||||
@@ -2306,8 +2299,7 @@ static int binlog_savepoint_rollback(handlerton *hton, THD *thd, void *sv)
|
||||
char buf[1024];
|
||||
String log_query(buf, sizeof(buf), &my_charset_bin);
|
||||
if (log_query.copy(STRING_WITH_LEN("ROLLBACK TO "), &my_charset_bin) ||
|
||||
append_identifier(thd, &log_query,
|
||||
thd->lex->ident.str, thd->lex->ident.length))
|
||||
append_identifier(thd, &log_query, &thd->lex->ident))
|
||||
DBUG_RETURN(1);
|
||||
int errcode= query_error_code(thd, thd->killed == NOT_KILLED);
|
||||
Query_log_event qinfo(thd, log_query.ptr(), log_query.length(),
|
||||
@@ -3029,7 +3021,7 @@ bool MYSQL_QUERY_LOG::write(THD *thd, time_t current_time,
|
||||
"# Thread_id: %lu Schema: %s QC_hit: %s\n"
|
||||
"# Query_time: %s Lock_time: %s Rows_sent: %lu Rows_examined: %lu\n"
|
||||
"# Rows_affected: %lu Bytes_sent: %lu\n",
|
||||
(ulong) thd->thread_id, (thd->db ? thd->db : ""),
|
||||
(ulong) thd->thread_id, thd->get_db(),
|
||||
((thd->query_plan_flags & QPLAN_QC) ? "Yes" : "No"),
|
||||
query_time_buff, lock_time_buff,
|
||||
(ulong) thd->get_sent_row_count(),
|
||||
@@ -3085,11 +3077,11 @@ bool MYSQL_QUERY_LOG::write(THD *thd, time_t current_time,
|
||||
goto err;
|
||||
thd->free_items();
|
||||
}
|
||||
if (thd->db && strcmp(thd->db, db))
|
||||
if (thd->db.str && strcmp(thd->db.str, db))
|
||||
{ // Database changed
|
||||
if (my_b_printf(&log_file,"use %s;\n",thd->db))
|
||||
if (my_b_printf(&log_file,"use %s;\n",thd->db.str))
|
||||
goto err;
|
||||
strmov(db,thd->db);
|
||||
strmov(db,thd->db.str);
|
||||
}
|
||||
if (thd->stmt_depends_on_first_successful_insert_id_in_prev_stmt)
|
||||
{
|
||||
|
||||
@@ -4271,7 +4271,7 @@ Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg,
|
||||
(suppress_use ? LOG_EVENT_SUPPRESS_USE_F : 0),
|
||||
using_trans),
|
||||
data_buf(0), query(query_arg), catalog(thd_arg->catalog),
|
||||
db(thd_arg->db), q_len((uint32) query_length),
|
||||
db(thd_arg->db.str), q_len((uint32) query_length),
|
||||
thread_id(thd_arg->thread_id),
|
||||
/* save the original thread id; we already know the server id */
|
||||
slave_proxy_id((ulong)thd_arg->variables.pseudo_thread_id),
|
||||
@@ -5353,7 +5353,7 @@ bool test_if_equal_repl_errors(int expected_error, int actual_error)
|
||||
int Query_log_event::do_apply_event(rpl_group_info *rgi,
|
||||
const char *query_arg, uint32 q_len_arg)
|
||||
{
|
||||
LEX_STRING new_db;
|
||||
LEX_CSTRING new_db;
|
||||
int expected_error,actual_error= 0;
|
||||
Schema_specification_st db_options;
|
||||
uint64 sub_id= 0;
|
||||
@@ -5374,12 +5374,12 @@ int Query_log_event::do_apply_event(rpl_group_info *rgi,
|
||||
thd->catalog= catalog_len ? (char *) catalog : (char *)"";
|
||||
new_db.length= db_len;
|
||||
new_db.str= (char *) rpl_filter->get_rewrite_db(db, &new_db.length);
|
||||
thd->set_db(new_db.str, new_db.length); /* allocates a copy of 'db' */
|
||||
thd->set_db(&new_db); /* allocates a copy of 'db' */
|
||||
|
||||
/*
|
||||
Setting the character set and collation of the current database thd->db.
|
||||
*/
|
||||
load_db_opt_by_name(thd, thd->db, &db_options);
|
||||
load_db_opt_by_name(thd, thd->db.str, &db_options);
|
||||
if (db_options.default_table_charset)
|
||||
thd->db_charset= db_options.default_table_charset;
|
||||
thd->variables.auto_increment_increment= auto_increment_increment;
|
||||
@@ -5403,7 +5403,7 @@ int Query_log_event::do_apply_event(rpl_group_info *rgi,
|
||||
::do_apply_event(), then the companion SET also have so
|
||||
we don't need to reset_one_shot_variables().
|
||||
*/
|
||||
if (is_trans_keyword() || rpl_filter->db_ok(thd->db))
|
||||
if (is_trans_keyword() || rpl_filter->db_ok(thd->db.str))
|
||||
{
|
||||
thd->set_time(when, when_sec_part);
|
||||
thd->set_query_and_id((char*)query_arg, q_len_arg,
|
||||
@@ -5571,7 +5571,7 @@ int Query_log_event::do_apply_event(rpl_group_info *rgi,
|
||||
DBUG_ASSERT(thd->m_statement_psi == NULL);
|
||||
thd->m_statement_psi= MYSQL_START_STATEMENT(&thd->m_statement_state,
|
||||
stmt_info_rpl.m_key,
|
||||
thd->db, thd->db_length,
|
||||
thd->db.str, thd->db.length,
|
||||
thd->charset());
|
||||
THD_STAGE_INFO(thd, stage_init);
|
||||
MYSQL_SET_STATEMENT_TEXT(thd->m_statement_psi, thd->query(), thd->query_length());
|
||||
@@ -5705,7 +5705,7 @@ compare_errors:
|
||||
"Error '%s' on query. Default database: '%s'. Query: '%s'",
|
||||
(actual_error ? thd->get_stmt_da()->message() :
|
||||
"unexpected success or fatal error"),
|
||||
print_slave_db_safe(thd->db), query_arg);
|
||||
thd->get_db(), query_arg);
|
||||
thd->is_slave_error= 1;
|
||||
}
|
||||
|
||||
@@ -5762,7 +5762,7 @@ end:
|
||||
TABLE uses the db.table syntax.
|
||||
*/
|
||||
thd->catalog= 0;
|
||||
thd->set_db(NULL, 0); /* will free the current database */
|
||||
thd->set_db(&null_clex_str); /* will free the current database */
|
||||
thd->reset_query();
|
||||
DBUG_PRINT("info", ("end: query= 0"));
|
||||
|
||||
@@ -7193,14 +7193,14 @@ void Load_log_event::set_fields(const char* affected_db,
|
||||
int Load_log_event::do_apply_event(NET* net, rpl_group_info *rgi,
|
||||
bool use_rli_only_for_errors)
|
||||
{
|
||||
LEX_STRING new_db;
|
||||
LEX_CSTRING new_db;
|
||||
Relay_log_info const *rli= rgi->rli;
|
||||
Rpl_filter *rpl_filter= rli->mi->rpl_filter;
|
||||
DBUG_ENTER("Load_log_event::do_apply_event");
|
||||
|
||||
new_db.length= db_len;
|
||||
new_db.str= (char *) rpl_filter->get_rewrite_db(db, &new_db.length);
|
||||
thd->set_db(new_db.str, new_db.length);
|
||||
new_db.str= rpl_filter->get_rewrite_db(db, &new_db.length);
|
||||
thd->set_db(&new_db);
|
||||
DBUG_ASSERT(thd->query() == 0);
|
||||
thd->clear_error(1);
|
||||
|
||||
@@ -7237,21 +7237,20 @@ int Load_log_event::do_apply_event(NET* net, rpl_group_info *rgi,
|
||||
::do_apply_event(), then the companion SET also have so
|
||||
we don't need to reset_one_shot_variables().
|
||||
*/
|
||||
if (rpl_filter->db_ok(thd->db))
|
||||
if (rpl_filter->db_ok(thd->db.str))
|
||||
{
|
||||
thd->set_time(when, when_sec_part);
|
||||
thd->set_query_id(next_query_id());
|
||||
thd->get_stmt_da()->opt_clear_warning_info(thd->query_id);
|
||||
|
||||
TABLE_LIST tables;
|
||||
tables.init_one_table(thd->strmake(thd->db, thd->db_length),
|
||||
thd->db_length,
|
||||
table_name, strlen(table_name),
|
||||
table_name, TL_WRITE);
|
||||
LEX_CSTRING db_name= { thd->strmake(thd->db.str, thd->db.length), thd->db.length };
|
||||
LEX_CSTRING tbl_name= { table_name, strlen(table_name) };
|
||||
tables.init_one_table(&db_name, &tbl_name, 0, TL_WRITE);
|
||||
tables.updating= 1;
|
||||
|
||||
// the table will be opened in mysql_load
|
||||
if (rpl_filter->is_on() && !rpl_filter->tables_ok(thd->db, &tables))
|
||||
if (rpl_filter->is_on() && !rpl_filter->tables_ok(thd->db.str, &tables))
|
||||
{
|
||||
// TODO: this is a bug - this needs to be moved to the I/O thread
|
||||
if (net)
|
||||
@@ -7337,7 +7336,7 @@ int Load_log_event::do_apply_event(NET* net, rpl_group_info *rgi,
|
||||
ex.skip_lines = skip_lines;
|
||||
List<Item> field_list;
|
||||
thd->lex->select_lex.context.resolve_in_table_list_only(&tables);
|
||||
set_fields(tables.db, field_list, &thd->lex->select_lex.context);
|
||||
set_fields(tables.db.str, field_list, &thd->lex->select_lex.context);
|
||||
thd->variables.pseudo_thread_id= thread_id;
|
||||
if (net)
|
||||
{
|
||||
@@ -7363,7 +7362,7 @@ int Load_log_event::do_apply_event(NET* net, rpl_group_info *rgi,
|
||||
"warning(s). Default database: '%s'",
|
||||
(char*) table_name, log_pos, RPL_LOG_NAME,
|
||||
(ulong) thd->cuted_fields,
|
||||
print_slave_db_safe(thd->db));
|
||||
thd->get_db());
|
||||
}
|
||||
if (net)
|
||||
net->pkt_nr= thd->net.pkt_nr;
|
||||
@@ -7382,9 +7381,9 @@ int Load_log_event::do_apply_event(NET* net, rpl_group_info *rgi,
|
||||
|
||||
error:
|
||||
thd->net.vio = 0;
|
||||
const char *remember_db= thd->db;
|
||||
const char *remember_db= thd->get_db();
|
||||
thd->catalog= 0;
|
||||
thd->set_db(NULL, 0); /* will free the current database */
|
||||
thd->set_db(&null_clex_str); /* will free the current database */
|
||||
thd->reset_query();
|
||||
thd->get_stmt_da()->set_overwrite_status(true);
|
||||
thd->is_error() ? trans_rollback_stmt(thd) : trans_commit_stmt(thd);
|
||||
@@ -7433,7 +7432,7 @@ error:
|
||||
}
|
||||
rli->report(ERROR_LEVEL, sql_errno, rgi->gtid_info(), "\
|
||||
Error '%s' running LOAD DATA INFILE on table '%s'. Default database: '%s'",
|
||||
err, (char*)table_name, print_slave_db_safe(remember_db));
|
||||
err, (char*)table_name, remember_db);
|
||||
free_root(thd->mem_root,MYF(MY_KEEP_PREALLOC));
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
@@ -7446,7 +7445,7 @@ Error '%s' running LOAD DATA INFILE on table '%s'. Default database: '%s'",
|
||||
"Running LOAD DATA INFILE on table '%-.64s'."
|
||||
" Default database: '%-.64s'",
|
||||
(char*)table_name,
|
||||
print_slave_db_safe(remember_db));
|
||||
remember_db);
|
||||
|
||||
rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR, rgi->gtid_info(),
|
||||
ER_THD(thd, ER_SLAVE_FATAL_ERROR), buf);
|
||||
@@ -12435,7 +12434,7 @@ check_table_map(rpl_group_info *rgi, RPL_TABLE_LIST *table_list)
|
||||
Relay_log_info *rli= rgi->rli;
|
||||
if ((rgi->thd->slave_thread /* filtering is for slave only */ ||
|
||||
IF_WSREP((WSREP(rgi->thd) && rgi->thd->wsrep_applier), 0)) &&
|
||||
(!rli->mi->rpl_filter->db_ok(table_list->db) ||
|
||||
(!rli->mi->rpl_filter->db_ok(table_list->db.str) ||
|
||||
(rli->mi->rpl_filter->is_on() && !rli->mi->rpl_filter->tables_ok("", table_list))))
|
||||
res= FILTERED_OUT;
|
||||
else
|
||||
@@ -12447,8 +12446,8 @@ check_table_map(rpl_group_info *rgi, RPL_TABLE_LIST *table_list)
|
||||
if (ptr->table_id == table_list->table_id)
|
||||
{
|
||||
|
||||
if (strcmp(ptr->db, table_list->db) ||
|
||||
strcmp(ptr->alias, table_list->table_name) ||
|
||||
if (cmp(&ptr->db, &table_list->db) ||
|
||||
cmp(&ptr->alias, &table_list->table_name) ||
|
||||
ptr->lock_type != TL_WRITE) // the ::do_apply_event always sets TL_WRITE
|
||||
res= SAME_ID_MAPPING_DIFFERENT_TABLE;
|
||||
else
|
||||
@@ -12468,7 +12467,7 @@ int Table_map_log_event::do_apply_event(rpl_group_info *rgi)
|
||||
{
|
||||
RPL_TABLE_LIST *table_list;
|
||||
char *db_mem, *tname_mem;
|
||||
size_t dummy_len;
|
||||
size_t dummy_len, db_mem_length, tname_mem_length;
|
||||
void *memory;
|
||||
Rpl_filter *filter;
|
||||
Relay_log_info const *rli= rgi->rli;
|
||||
@@ -12486,19 +12485,20 @@ int Table_map_log_event::do_apply_event(rpl_group_info *rgi)
|
||||
|
||||
/* call from mysql_client_binlog_statement() will not set rli->mi */
|
||||
filter= rgi->thd->slave_thread ? rli->mi->rpl_filter : global_rpl_filter;
|
||||
strmov(db_mem, filter->get_rewrite_db(m_dbnam, &dummy_len));
|
||||
strmov(tname_mem, m_tblnam);
|
||||
db_mem_length= strmov(db_mem, filter->get_rewrite_db(m_dbnam, &dummy_len))- db_mem;
|
||||
tname_mem_length= strmov(tname_mem, m_tblnam)- tname_mem;
|
||||
|
||||
table_list->init_one_table(db_mem, strlen(db_mem),
|
||||
tname_mem, strlen(tname_mem),
|
||||
tname_mem, TL_WRITE);
|
||||
LEX_CSTRING tmp_db_name= {db_mem, db_mem_length };
|
||||
LEX_CSTRING tmp_tbl_name= {tname_mem, tname_mem_length };
|
||||
|
||||
table_list->init_one_table(&tmp_db_name, &tmp_tbl_name, 0, TL_WRITE);
|
||||
table_list->table_id= DBUG_EVALUATE_IF("inject_tblmap_same_id_maps_diff_table", 0, m_table_id);
|
||||
table_list->updating= 1;
|
||||
table_list->required_type= TABLE_TYPE_NORMAL;
|
||||
|
||||
DBUG_PRINT("debug", ("table: %s is mapped to %u", table_list->table_name,
|
||||
table_list->table_id));
|
||||
DBUG_PRINT("debug", ("table: %s is mapped to %u",
|
||||
table_list->table_name.str,
|
||||
table_list->table_id));
|
||||
table_list->master_had_triggers= ((m_flags & TM_BIT_HAS_TRIGGERS_F) ? 1 : 0);
|
||||
DBUG_PRINT("debug", ("table->master_had_triggers=%d",
|
||||
(int)table_list->master_had_triggers));
|
||||
@@ -13497,7 +13497,7 @@ void issue_long_find_row_warning(Log_event_type type,
|
||||
|
||||
sql_print_information("The slave is applying a ROW event on behalf of a%s statement "
|
||||
"on table %s and is currently taking a considerable amount "
|
||||
"of time (%ld seconds). This is due to the fact that it is %s "
|
||||
"of time (%lld seconds). This is due to the fact that it is %s "
|
||||
"while looking up records to be processed. Consider adding a "
|
||||
"primary key (or unique key) to the table to improve "
|
||||
"performance.", evt_type, table_name, delta, scan_type);
|
||||
|
||||
@@ -1253,7 +1253,7 @@ public:
|
||||
#endif /* HAVE_REPLICATION */
|
||||
virtual const char* get_db()
|
||||
{
|
||||
return thd ? thd->db : 0;
|
||||
return thd ? thd->db.str : 0;
|
||||
}
|
||||
#else
|
||||
Log_event() : temp_buf(0), when(0), flags(0) {}
|
||||
|
||||
@@ -1246,7 +1246,7 @@ void net_after_header_psi(struct st_net *net, void *user_data,
|
||||
{
|
||||
thd->m_statement_psi= MYSQL_START_STATEMENT(&thd->m_statement_state,
|
||||
stmt_info_new_packet.m_key,
|
||||
thd->db, thd->db_length,
|
||||
thd->get_db(), thd->db.length,
|
||||
thd->charset());
|
||||
|
||||
THD_STAGE_INFO(thd, stage_init);
|
||||
|
||||
@@ -37,7 +37,6 @@ class Time_zone;
|
||||
|
||||
struct scheduler_functions;
|
||||
|
||||
typedef struct st_mysql_const_lex_string LEX_CSTRING;
|
||||
typedef struct st_mysql_show_var SHOW_VAR;
|
||||
|
||||
#if MAX_INDEXES <= 64
|
||||
|
||||
@@ -1497,6 +1497,7 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred)
|
||||
{
|
||||
TABLE_LIST *outer_tbl= subq_pred->emb_on_expr_nest;
|
||||
TABLE_LIST *wrap_nest;
|
||||
LEX_CSTRING sj_wrap_name= { STRING_WITH_LEN("(sj-wrap)") };
|
||||
/*
|
||||
We're dealing with
|
||||
|
||||
@@ -1522,7 +1523,7 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred)
|
||||
}
|
||||
wrap_nest->embedding= outer_tbl->embedding;
|
||||
wrap_nest->join_list= outer_tbl->join_list;
|
||||
wrap_nest->alias= (char*) "(sj-wrap)";
|
||||
wrap_nest->alias= sj_wrap_name;
|
||||
|
||||
wrap_nest->nested_join->join_list.empty();
|
||||
wrap_nest->nested_join->join_list.push_back(outer_tbl, thd->mem_root);
|
||||
@@ -1561,6 +1562,7 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred)
|
||||
|
||||
TABLE_LIST *sj_nest;
|
||||
NESTED_JOIN *nested_join;
|
||||
LEX_CSTRING sj_nest_name= { STRING_WITH_LEN("(sj-nest)") };
|
||||
if (!(sj_nest= alloc_join_nest(thd)))
|
||||
{
|
||||
DBUG_RETURN(TRUE);
|
||||
@@ -1569,7 +1571,7 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred)
|
||||
|
||||
sj_nest->join_list= emb_join_list;
|
||||
sj_nest->embedding= emb_tbl_nest;
|
||||
sj_nest->alias= (char*) "(sj-nest)";
|
||||
sj_nest->alias= sj_nest_name;
|
||||
sj_nest->sj_subq_pred= subq_pred;
|
||||
sj_nest->original_subq_pred_used_tables= subq_pred->used_tables() |
|
||||
subq_pred->left_expr->used_tables();
|
||||
@@ -1842,13 +1844,15 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred)
|
||||
|
||||
const int SUBQERY_TEMPTABLE_NAME_MAX_LEN= 20;
|
||||
|
||||
static void create_subquery_temptable_name(char *to, uint number)
|
||||
static void create_subquery_temptable_name(LEX_STRING *str, uint number)
|
||||
{
|
||||
char *to= str->str;
|
||||
DBUG_ASSERT(number < 10000);
|
||||
to= strmov(to, "<subquery");
|
||||
to= int10_to_str((int) number, to, 10);
|
||||
to[0]= '>';
|
||||
to[1]= 0;
|
||||
str->length= (size_t) (to - str->str)+1;
|
||||
}
|
||||
|
||||
|
||||
@@ -1876,7 +1880,7 @@ static bool convert_subq_to_jtbm(JOIN *parent_join,
|
||||
TABLE_LIST *tl;
|
||||
bool optimization_delayed= TRUE;
|
||||
TABLE_LIST *jtbm;
|
||||
char *tbl_alias;
|
||||
LEX_STRING tbl_alias;
|
||||
THD *thd= parent_join->thd;
|
||||
DBUG_ENTER("convert_subq_to_jtbm");
|
||||
|
||||
@@ -1885,7 +1889,7 @@ static bool convert_subq_to_jtbm(JOIN *parent_join,
|
||||
|
||||
*remove_item= TRUE;
|
||||
|
||||
if (!(tbl_alias= (char*)thd->calloc(SUBQERY_TEMPTABLE_NAME_MAX_LEN)) ||
|
||||
if (!(tbl_alias.str= (char*)thd->calloc(SUBQERY_TEMPTABLE_NAME_MAX_LEN)) ||
|
||||
!(jtbm= alloc_join_nest(thd))) //todo: this is not a join nest!
|
||||
{
|
||||
DBUG_RETURN(TRUE);
|
||||
@@ -1925,9 +1929,10 @@ static bool convert_subq_to_jtbm(JOIN *parent_join,
|
||||
|
||||
jtbm->jtbm_table_no= parent_join->table_count;
|
||||
|
||||
create_subquery_temptable_name(tbl_alias,
|
||||
create_subquery_temptable_name(&tbl_alias,
|
||||
subq_pred->unit->first_select()->select_number);
|
||||
jtbm->alias= tbl_alias;
|
||||
jtbm->alias.str= tbl_alias.str;
|
||||
jtbm->alias.length= tbl_alias.length;
|
||||
parent_join->table_count++;
|
||||
DBUG_RETURN(thd->is_fatal_error);
|
||||
}
|
||||
@@ -1947,9 +1952,10 @@ static bool convert_subq_to_jtbm(JOIN *parent_join,
|
||||
|
||||
DBUG_EXECUTE("where", print_where(conds,"SJ-EXPR", QT_ORDINARY););
|
||||
|
||||
create_subquery_temptable_name(tbl_alias, hash_sj_engine->materialize_join->
|
||||
create_subquery_temptable_name(&tbl_alias, hash_sj_engine->materialize_join->
|
||||
select_lex->select_number);
|
||||
jtbm->alias= tbl_alias;
|
||||
jtbm->alias.str= tbl_alias.str;
|
||||
jtbm->alias.length= tbl_alias.length;
|
||||
|
||||
parent_lex->have_merged_subqueries= TRUE;
|
||||
|
||||
@@ -3705,6 +3711,7 @@ bool setup_sj_materialization_part1(JOIN_TAB *sjm_tab)
|
||||
sjm->sjm_table_param.init();
|
||||
sjm->sjm_table_param.bit_fields_as_long= TRUE;
|
||||
SELECT_LEX *subq_select= emb_sj_nest->sj_subq_pred->unit->first_select();
|
||||
const LEX_CSTRING sj_materialize_name= { STRING_WITH_LEN("sj-materialize") };
|
||||
Ref_ptr_array p_items= subq_select->ref_pointer_array;
|
||||
for (uint i= 0; i < subq_select->item_list.elements; i++)
|
||||
sjm->sjm_table_cols.push_back(p_items[i], thd->mem_root);
|
||||
@@ -3718,7 +3725,7 @@ bool setup_sj_materialization_part1(JOIN_TAB *sjm_tab)
|
||||
1, /*save_sum_fields*/
|
||||
thd->variables.option_bits | TMP_TABLE_ALL_COLUMNS,
|
||||
HA_POS_ERROR /*rows_limit */,
|
||||
(char*)"sj-materialize")))
|
||||
&sj_materialize_name)))
|
||||
DBUG_RETURN(TRUE); /* purecov: inspected */
|
||||
sjm->table->map= emb_sj_nest->nested_join->used_tables;
|
||||
sjm->table->file->extra(HA_EXTRA_WRITE_CACHE);
|
||||
@@ -5335,6 +5342,7 @@ TABLE *create_dummy_tmp_table(THD *thd)
|
||||
sjm_table_param.init();
|
||||
sjm_table_param.field_count= 1;
|
||||
List<Item> sjm_table_cols;
|
||||
const LEX_CSTRING dummy_name= { STRING_WITH_LEN("dummy") };
|
||||
Item *column_item= new (thd->mem_root) Item_int(thd, 1);
|
||||
if (!column_item)
|
||||
DBUG_RETURN(NULL);
|
||||
@@ -5347,7 +5355,7 @@ TABLE *create_dummy_tmp_table(THD *thd)
|
||||
thd->variables.option_bits |
|
||||
TMP_TABLE_ALL_COLUMNS,
|
||||
HA_POS_ERROR /*rows_limit */,
|
||||
(char*)"dummy", TRUE /* Do not open */)))
|
||||
&dummy_name, TRUE /* Do not open */)))
|
||||
{
|
||||
DBUG_RETURN(NULL);
|
||||
}
|
||||
|
||||
@@ -1071,7 +1071,7 @@ public:
|
||||
saved_lock(_thd->lock),
|
||||
saved_mode(_thd->locked_tables_mode),
|
||||
saved_query_tables_own_last(_thd->lex->query_tables_own_last),
|
||||
table_list(_table, lock_type),
|
||||
table_list(&_table, lock_type),
|
||||
locked(false)
|
||||
{
|
||||
table.reginfo.lock_type= lock_type;
|
||||
@@ -1246,7 +1246,7 @@ bool partition_info::vers_setup_stats(THD * thd, bool is_create_table_ind)
|
||||
|
||||
bool error= false;
|
||||
|
||||
TABLE_LIST tl(*table, TL_READ);
|
||||
TABLE_LIST tl(table, TL_READ);
|
||||
MDL_auto_lock mdl_lock(thd, tl);
|
||||
if (mdl_lock.acquire_error())
|
||||
return true;
|
||||
@@ -2077,8 +2077,8 @@ bool partition_info::check_partition_info(THD *thd, handlerton **eng_type,
|
||||
DBUG_ASSERT(vers_info);
|
||||
if (num_parts < 2 || !vers_info->now_part)
|
||||
{
|
||||
DBUG_ASSERT(info && info->alias);
|
||||
my_error(ER_VERS_WRONG_PARTS, MYF(0), info->alias);
|
||||
DBUG_ASSERT(info && info->alias.str);
|
||||
my_error(ER_VERS_WRONG_PARTS, MYF(0), info->alias.str);
|
||||
goto end;
|
||||
}
|
||||
DBUG_ASSERT(vers_info->initialized(false));
|
||||
@@ -2206,7 +2206,7 @@ bool partition_info::check_partition_info(THD *thd, handlerton **eng_type,
|
||||
}
|
||||
if (unlikely(now_parts > 1))
|
||||
{
|
||||
my_error(ER_VERS_WRONG_PARTS, MYF(0), info->alias);
|
||||
my_error(ER_VERS_WRONG_PARTS, MYF(0), info->alias.str);
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -2259,8 +2259,8 @@ void partition_info::print_no_partition_found(TABLE *table_arg, myf errflag)
|
||||
THD *thd= current_thd;
|
||||
|
||||
bzero(&table_list, sizeof(table_list));
|
||||
table_list.db= table_arg->s->db.str;
|
||||
table_list.table_name= table_arg->s->table_name.str;
|
||||
table_list.db= table_arg->s->db;
|
||||
table_list.table_name= table_arg->s->table_name;
|
||||
|
||||
if (check_single_table_access(thd,
|
||||
SELECT_ACL, &table_list, TRUE))
|
||||
|
||||
@@ -96,7 +96,7 @@ setup_procedure(THD *thd,ORDER *param,select_result *result,
|
||||
DBUG_RETURN(proc);
|
||||
}
|
||||
}
|
||||
my_error(ER_UNKNOWN_PROCEDURE, MYF(0), (*param->item)->name);
|
||||
my_error(ER_UNKNOWN_PROCEDURE, MYF(0), (*param->item)->name.str);
|
||||
*error=1;
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
|
||||
|
||||
#include <my_global.h>
|
||||
#include <mariadb.h>
|
||||
#include <mysql.h>
|
||||
#include <mysql_com.h>
|
||||
#include <mysqld_error.h>
|
||||
|
||||
@@ -105,9 +105,9 @@ Rpl_filter::tables_ok(const char* db, TABLE_LIST* tables)
|
||||
if (!tables->updating)
|
||||
continue;
|
||||
some_tables_updating= 1;
|
||||
end= strmov(hash_key, tables->db ? tables->db : db);
|
||||
end= strmov(hash_key, tables->db.str ? tables->db.str : db);
|
||||
*end++= '.';
|
||||
len= (uint) (strmov(end, tables->table_name) - hash_key);
|
||||
len= (uint) (strmov(end, tables->table_name.str) - hash_key);
|
||||
if (do_table_inited) // if there are any do's
|
||||
{
|
||||
if (my_hash_search(&do_table, (uchar*) hash_key, len))
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
#include "slave.h"
|
||||
#include "log_event.h"
|
||||
|
||||
const LEX_STRING rpl_gtid_slave_state_table_name=
|
||||
{ C_STRING_WITH_LEN("gtid_slave_pos") };
|
||||
const LEX_CSTRING rpl_gtid_slave_state_table_name=
|
||||
{ STRING_WITH_LEN("gtid_slave_pos") };
|
||||
|
||||
|
||||
void
|
||||
@@ -401,10 +401,7 @@ rpl_slave_state::truncate_state_table(THD *thd)
|
||||
int err= 0;
|
||||
|
||||
tmp_disable_binlog(thd);
|
||||
tlist.init_one_table(STRING_WITH_LEN("mysql"),
|
||||
rpl_gtid_slave_state_table_name.str,
|
||||
rpl_gtid_slave_state_table_name.length,
|
||||
NULL, TL_WRITE);
|
||||
tlist.init_one_table(&MYSQL_SCHEMA_NAME, &rpl_gtid_slave_state_table_name, NULL, TL_WRITE);
|
||||
if (!(err= open_and_lock_tables(thd, &tlist, FALSE, 0)))
|
||||
{
|
||||
err= tlist.table->file->ha_truncate();
|
||||
@@ -655,8 +652,7 @@ rpl_slave_state::record_gtid(THD *thd, const rpl_gtid *gtid, uint64 sub_id,
|
||||
*/
|
||||
suspended_wfc= thd->suspend_subsequent_commits();
|
||||
thd->lex->reset_n_backup_query_tables_list(&lex_backup);
|
||||
tlist.init_one_table(STRING_WITH_LEN("mysql"), gtid_pos_table_name.str,
|
||||
gtid_pos_table_name.length, NULL, TL_WRITE);
|
||||
tlist.init_one_table(&MYSQL_SCHEMA_NAME, >id_pos_table_name, NULL, TL_WRITE);
|
||||
if ((err= open_and_lock_tables(thd, &tlist, FALSE, 0)))
|
||||
goto end;
|
||||
table_opened= true;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
/* Definitions for MariaDB global transaction ID (GTID). */
|
||||
|
||||
|
||||
extern const LEX_STRING rpl_gtid_slave_state_table_name;
|
||||
extern const LEX_CSTRING rpl_gtid_slave_state_table_name;
|
||||
|
||||
class String;
|
||||
|
||||
|
||||
@@ -1393,7 +1393,7 @@ handle_rpl_parallel_thread(void *arg)
|
||||
thd->clear_error();
|
||||
thd->catalog= 0;
|
||||
thd->reset_query();
|
||||
thd->reset_db(NULL, 0);
|
||||
thd->reset_db(&null_clex_str);
|
||||
thd_proc_info(thd, "Slave worker thread exiting");
|
||||
thd->temporary_tables= 0;
|
||||
|
||||
|
||||
@@ -1527,8 +1527,7 @@ scan_one_gtid_slave_pos_table(THD *thd, HASH *hash, DYNAMIC_ARRAY *array,
|
||||
int err= 0;
|
||||
|
||||
thd->reset_for_next_command();
|
||||
tlist.init_one_table(STRING_WITH_LEN("mysql"), tablename->str,
|
||||
tablename->length, NULL, TL_READ);
|
||||
tlist.init_one_table(&MYSQL_SCHEMA_NAME, tablename, NULL, TL_READ);
|
||||
if ((err= open_and_lock_tables(thd, &tlist, FALSE, 0)))
|
||||
goto end;
|
||||
table_opened= true;
|
||||
@@ -1642,15 +1641,14 @@ static int
|
||||
scan_all_gtid_slave_pos_table(THD *thd, int (*cb)(THD *, LEX_CSTRING *, void *),
|
||||
void *cb_data)
|
||||
{
|
||||
static LEX_CSTRING mysql_db_name= {C_STRING_WITH_LEN("mysql")};
|
||||
char path[FN_REFLEN];
|
||||
MY_DIR *dirp;
|
||||
|
||||
thd->reset_for_next_command();
|
||||
if (lock_schema_name(thd, mysql_db_name.str))
|
||||
if (lock_schema_name(thd, MYSQL_SCHEMA_NAME.str))
|
||||
return 1;
|
||||
|
||||
build_table_filename(path, sizeof(path) - 1, mysql_db_name.str, "", "", 0);
|
||||
build_table_filename(path, sizeof(path) - 1, MYSQL_SCHEMA_NAME.str, "", "", 0);
|
||||
if (!(dirp= my_dir(path, MYF(MY_DONT_SORT))))
|
||||
{
|
||||
my_error(ER_FILE_NOT_FOUND, MYF(0), path, my_errno);
|
||||
@@ -1665,7 +1663,7 @@ scan_all_gtid_slave_pos_table(THD *thd, int (*cb)(THD *, LEX_CSTRING *, void *),
|
||||
Discovered_table_list tl(thd, &files);
|
||||
int err;
|
||||
|
||||
err= ha_discover_table_names(thd, &mysql_db_name, dirp, &tl, false);
|
||||
err= ha_discover_table_names(thd, &MYSQL_SCHEMA_NAME, dirp, &tl, false);
|
||||
my_dirend(dirp);
|
||||
close_thread_tables(thd);
|
||||
thd->mdl_context.release_transactional_locks();
|
||||
@@ -1928,8 +1926,7 @@ find_gtid_pos_tables_cb(THD *thd, LEX_CSTRING *table_name, void *arg)
|
||||
int err;
|
||||
|
||||
thd->reset_for_next_command();
|
||||
tlist.init_one_table(STRING_WITH_LEN("mysql"), table_name->str,
|
||||
table_name->length, NULL, TL_READ);
|
||||
tlist.init_one_table(&MYSQL_SCHEMA_NAME, table_name, NULL, TL_READ);
|
||||
if ((err= open_and_lock_tables(thd, &tlist, FALSE, 0)))
|
||||
goto end;
|
||||
table= tlist.table;
|
||||
|
||||
@@ -755,10 +755,10 @@ int Repl_semi_sync_master::dump_start(THD* thd,
|
||||
add_slave();
|
||||
report_reply_binlog(thd->variables.server_id,
|
||||
log_file + dirname_length(log_file), log_pos);
|
||||
sql_print_information("Start semi-sync binlog_dump to slave (server_id: %d), "
|
||||
"pos(%s, %lu",
|
||||
thd->variables.server_id, log_file,
|
||||
(unsigned long)log_pos);
|
||||
sql_print_information("Start semi-sync binlog_dump to slave "
|
||||
"(server_id: %ld), pos(%s, %lu)",
|
||||
(long) thd->variables.server_id, log_file,
|
||||
(ulong) log_pos);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -768,7 +768,8 @@ void Repl_semi_sync_master::dump_end(THD* thd)
|
||||
if (!thd->semi_sync_slave)
|
||||
return;
|
||||
|
||||
sql_print_information("Stop semi-sync binlog_dump to slave (server_id: %d)", thd->variables.server_id);
|
||||
sql_print_information("Stop semi-sync binlog_dump to slave (server_id: %ld)",
|
||||
(long) thd->variables.server_id);
|
||||
|
||||
remove_slave();
|
||||
ack_receiver.remove_slave(thd);
|
||||
|
||||
@@ -974,7 +974,7 @@ bool Current_schema_tracker::store(THD *thd, String *buf)
|
||||
It saves length of database name and name of database name +
|
||||
length of saved length of database length.
|
||||
*/
|
||||
length= db_length= thd->db_length;
|
||||
length= db_length= thd->db.length;
|
||||
length += net_length_size(length);
|
||||
|
||||
compile_time_assert(SESSION_TRACK_SCHEMA < 251);
|
||||
@@ -991,7 +991,7 @@ bool Current_schema_tracker::store(THD *thd, String *buf)
|
||||
buf->q_net_store_length(length);
|
||||
|
||||
/* Length and current schema name */
|
||||
buf->q_net_store_data((const uchar *)thd->db, thd->db_length);
|
||||
buf->q_net_store_data((const uchar *)thd->db.str, thd->db.length);
|
||||
|
||||
reset();
|
||||
|
||||
|
||||
@@ -7877,7 +7877,7 @@ ER_VERS_WRONG_PARTS
|
||||
eng "Wrong partitions for %`s: must have at least one HISTORY and exactly one last CURRENT"
|
||||
|
||||
ER_VERS_NO_TRX_ID
|
||||
eng "TRX_ID %lu not found in `mysql.transaction_registry`"
|
||||
eng "TRX_ID %llu not found in `mysql.transaction_registry`"
|
||||
|
||||
ER_VERS_ALTER_SYSTEM_FIELD
|
||||
eng "Can not change system versioning field %`s"
|
||||
|
||||
10
sql/slave.cc
10
sql/slave.cc
@@ -310,9 +310,9 @@ build_gtid_pos_create_query(THD *thd, String *query,
|
||||
{
|
||||
bool err= false;
|
||||
err|= query->append(gtid_pos_table_definition1);
|
||||
err|= append_identifier(thd, query, table_name->str, table_name->length);
|
||||
err|= append_identifier(thd, query, table_name);
|
||||
err|= query->append(gtid_pos_table_definition2);
|
||||
err|= append_identifier(thd, query, engine_name->str, engine_name->length);
|
||||
err|= append_identifier(thd, query, engine_name);
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -331,7 +331,7 @@ gtid_pos_table_creation(THD *thd, plugin_ref engine, LEX_CSTRING *table_name)
|
||||
return 1;
|
||||
}
|
||||
|
||||
thd->set_db("mysql", 5);
|
||||
thd->set_db(&MYSQL_SCHEMA_NAME);
|
||||
thd->clear_error();
|
||||
ulonglong thd_saved_option= thd->variables.option_bits;
|
||||
/* This query shuold not be binlogged. */
|
||||
@@ -4945,7 +4945,7 @@ err:
|
||||
}
|
||||
repl_semisync_slave.slave_stop(mi);
|
||||
thd->reset_query();
|
||||
thd->reset_db(NULL, 0);
|
||||
thd->reset_db(&null_clex_str);
|
||||
if (mysql)
|
||||
{
|
||||
/*
|
||||
@@ -5531,7 +5531,7 @@ pthread_handler_t handle_slave_sql(void *arg)
|
||||
*/
|
||||
thd->catalog= 0;
|
||||
thd->reset_query();
|
||||
thd->reset_db(NULL, 0);
|
||||
thd->reset_db(&null_clex_str);
|
||||
if (rli->mi->using_gtid != Master_info::USE_GTID_NO)
|
||||
{
|
||||
ulong domain_count;
|
||||
|
||||
28
sql/sp.cc
28
sql/sp.cc
@@ -35,7 +35,6 @@
|
||||
|
||||
#include <my_user.h>
|
||||
|
||||
|
||||
sp_cache **Sp_handler_procedure::get_cache(THD *thd) const
|
||||
{
|
||||
return &thd->sp_proc_cache;
|
||||
@@ -455,7 +454,7 @@ TABLE *open_proc_table_for_read(THD *thd, Open_tables_backup *backup)
|
||||
|
||||
DBUG_ENTER("open_proc_table_for_read");
|
||||
|
||||
table.init_one_table("mysql", 5, "proc", 4, "proc", TL_READ);
|
||||
table.init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_PROC_NAME, NULL, TL_READ);
|
||||
|
||||
if (open_system_tables_for_read(thd, &table, backup))
|
||||
DBUG_RETURN(NULL);
|
||||
@@ -490,7 +489,7 @@ static TABLE *open_proc_table_for_update(THD *thd)
|
||||
MDL_savepoint mdl_savepoint= thd->mdl_context.mdl_savepoint();
|
||||
DBUG_ENTER("open_proc_table_for_update");
|
||||
|
||||
table_list.init_one_table("mysql", 5, "proc", 4, "proc", TL_WRITE);
|
||||
table_list.init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_PROC_NAME, NULL, TL_WRITE);
|
||||
|
||||
if (!(table= open_system_table_for_update(thd, &table_list)))
|
||||
DBUG_RETURN(NULL);
|
||||
@@ -1919,16 +1918,16 @@ Sp_handler::sp_exist_routines(THD *thd, TABLE_LIST *routines) const
|
||||
sp_name *name;
|
||||
LEX_CSTRING lex_db;
|
||||
LEX_CSTRING lex_name;
|
||||
thd->make_lex_string(&lex_db, routine->db, strlen(routine->db));
|
||||
thd->make_lex_string(&lex_name, routine->table_name,
|
||||
strlen(routine->table_name));
|
||||
thd->make_lex_string(&lex_db, routine->db.str, routine->db.length);
|
||||
thd->make_lex_string(&lex_name, routine->table_name.str,
|
||||
routine->table_name.length);
|
||||
name= new sp_name(&lex_db, &lex_name, true);
|
||||
sp_object_found= sp_find_routine(thd, name, false) != NULL;
|
||||
thd->get_stmt_da()->clear_warning_info(thd->query_id);
|
||||
if (! sp_object_found)
|
||||
{
|
||||
my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "FUNCTION or PROCEDURE",
|
||||
routine->table_name);
|
||||
routine->table_name.str);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
}
|
||||
@@ -2270,6 +2269,8 @@ Sp_handler::show_create_sp(THD *thd, String *buf,
|
||||
{
|
||||
sql_mode_t old_sql_mode= thd->variables.sql_mode;
|
||||
size_t agglen= (chistics.agg_type == GROUP_AGGREGATE)? 10 : 0;
|
||||
LEX_CSTRING tmp;
|
||||
|
||||
/* Make some room to begin with */
|
||||
if (buf->alloc(100 + db.length + 1 + name.length +
|
||||
params.length + returns.length +
|
||||
@@ -2284,19 +2285,20 @@ Sp_handler::show_create_sp(THD *thd, String *buf,
|
||||
append_definer(thd, buf, &definer.user, &definer.host);
|
||||
if (chistics.agg_type == GROUP_AGGREGATE)
|
||||
buf->append(STRING_WITH_LEN("AGGREGATE "));
|
||||
buf->append(type_lex_cstring());
|
||||
tmp= type_lex_cstring();
|
||||
buf->append(&tmp);
|
||||
buf->append(STRING_WITH_LEN(" "));
|
||||
if (ddl_options.if_not_exists())
|
||||
buf->append(STRING_WITH_LEN("IF NOT EXISTS "));
|
||||
|
||||
if (db.length > 0)
|
||||
{
|
||||
append_identifier(thd, buf, db.str, db.length);
|
||||
append_identifier(thd, buf, &db);
|
||||
buf->append('.');
|
||||
}
|
||||
append_identifier(thd, buf, name.str, name.length);
|
||||
append_identifier(thd, buf, &name);
|
||||
buf->append('(');
|
||||
buf->append(params);
|
||||
buf->append(¶ms);
|
||||
buf->append(')');
|
||||
if (type() == TYPE_ENUM_FUNCTION)
|
||||
{
|
||||
@@ -2304,7 +2306,7 @@ Sp_handler::show_create_sp(THD *thd, String *buf,
|
||||
buf->append(STRING_WITH_LEN(" RETURN "));
|
||||
else
|
||||
buf->append(STRING_WITH_LEN(" RETURNS "));
|
||||
buf->append(returns);
|
||||
buf->append(&returns);
|
||||
}
|
||||
buf->append('\n');
|
||||
switch (chistics.daccess) {
|
||||
@@ -2326,7 +2328,7 @@ Sp_handler::show_create_sp(THD *thd, String *buf,
|
||||
buf->append(STRING_WITH_LEN(" DETERMINISTIC\n"));
|
||||
append_suid(buf, chistics.suid);
|
||||
append_comment(buf, chistics.comment);
|
||||
buf->append(body);
|
||||
buf->append(&body);
|
||||
thd->variables.sql_mode= old_sql_mode;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -898,13 +898,13 @@ subst_spvars(THD *thd, sp_instr *instr, LEX_STRING *query_str)
|
||||
<flags> Flags struct
|
||||
*/
|
||||
int buf_len= (qbuf.length() + 1 + QUERY_CACHE_DB_LENGTH_SIZE +
|
||||
thd->db_length + QUERY_CACHE_FLAGS_SIZE + 1);
|
||||
thd->db.length + QUERY_CACHE_FLAGS_SIZE + 1);
|
||||
if ((pbuf= (char *) alloc_root(thd->mem_root, buf_len)))
|
||||
{
|
||||
char *ptr= pbuf + qbuf.length();
|
||||
memcpy(pbuf, qbuf.ptr(), qbuf.length());
|
||||
*ptr= 0;
|
||||
int2store(ptr+1, thd->db_length);
|
||||
int2store(ptr+1, thd->db.length);
|
||||
}
|
||||
else
|
||||
DBUG_RETURN(TRUE);
|
||||
@@ -1403,7 +1403,7 @@ set_routine_security_ctx(THD *thd, sp_head *sp, Security_context **save_ctx)
|
||||
*/
|
||||
if (*save_ctx &&
|
||||
check_routine_access(thd, EXECUTE_ACL,
|
||||
sp->m_db.str, sp->m_name.str, sp->m_handler, false))
|
||||
&sp->m_db, &sp->m_name, sp->m_handler, false))
|
||||
{
|
||||
sp->m_security_ctx.restore_security_context(thd, *save_ctx);
|
||||
*save_ctx= 0;
|
||||
@@ -1418,7 +1418,7 @@ set_routine_security_ctx(THD *thd, sp_head *sp, Security_context **save_ctx)
|
||||
bool sp_head::check_execute_access(THD *thd) const
|
||||
{
|
||||
return check_routine_access(thd, EXECUTE_ACL,
|
||||
m_db.str, m_name.str,
|
||||
&m_db, &m_name,
|
||||
m_handler, false);
|
||||
}
|
||||
|
||||
@@ -1733,9 +1733,9 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount,
|
||||
{
|
||||
binlog_buf.length(0);
|
||||
binlog_buf.append(STRING_WITH_LEN("SELECT "));
|
||||
append_identifier(thd, &binlog_buf, m_db.str, m_db.length);
|
||||
append_identifier(thd, &binlog_buf, &m_db);
|
||||
binlog_buf.append('.');
|
||||
append_identifier(thd, &binlog_buf, m_name.str, m_name.length);
|
||||
append_identifier(thd, &binlog_buf, &m_name);
|
||||
binlog_buf.append('(');
|
||||
for (arg_no= 0; arg_no < argcount; arg_no++)
|
||||
{
|
||||
@@ -2526,8 +2526,10 @@ bool check_show_routine_access(THD *thd, sp_head *sp, bool *full_access)
|
||||
{
|
||||
TABLE_LIST tables;
|
||||
bzero((char*) &tables,sizeof(tables));
|
||||
tables.db= (char*) "mysql";
|
||||
tables.table_name= tables.alias= (char*) "proc";
|
||||
tables.db= MYSQL_SCHEMA_NAME;
|
||||
tables.table_name= MYSQL_PROC_NAME;
|
||||
tables.alias= MYSQL_PROC_NAME;
|
||||
|
||||
*full_access= ((!check_table_access(thd, SELECT_ACL, &tables, FALSE,
|
||||
1, TRUE) &&
|
||||
(tables.grant.privilege & SELECT_ACL) != 0) ||
|
||||
@@ -3356,7 +3358,7 @@ sp_instr_stmt::exec_core(THD *thd, uint *nextp)
|
||||
{
|
||||
MYSQL_QUERY_EXEC_START(thd->query(),
|
||||
thd->thread_id,
|
||||
(char *) (thd->db ? thd->db : ""),
|
||||
thd->get_db(),
|
||||
&thd->security_ctx->priv_user[0],
|
||||
(char *)thd->security_ctx->host_or_ip,
|
||||
3);
|
||||
@@ -4454,12 +4456,12 @@ sp_head::merge_table_list(THD *thd, TABLE_LIST *table, LEX *lex_for_tmp_check)
|
||||
uint temp_table_key_length;
|
||||
|
||||
tname.length(0);
|
||||
tname.append(table->db, table->db_length);
|
||||
tname.append(&table->db);
|
||||
tname.append('\0');
|
||||
tname.append(table->table_name, table->table_name_length);
|
||||
tname.append(&table->table_name);
|
||||
tname.append('\0');
|
||||
temp_table_key_length= tname.length();
|
||||
tname.append(table->alias);
|
||||
tname.append(&table->alias);
|
||||
tname.append('\0');
|
||||
|
||||
/*
|
||||
@@ -4505,8 +4507,8 @@ sp_head::merge_table_list(THD *thd, TABLE_LIST *table, LEX *lex_for_tmp_check)
|
||||
tab->qname.str= (char*) thd->memdup(tname.ptr(), tab->qname.length);
|
||||
if (!tab->qname.str)
|
||||
return FALSE;
|
||||
tab->table_name_length= table->table_name_length;
|
||||
tab->db_length= table->db_length;
|
||||
tab->table_name_length= table->table_name.length;
|
||||
tab->db_length= table->db.length;
|
||||
tab->lock_type= table->lock_type;
|
||||
tab->lock_count= tab->query_lock_count= 1;
|
||||
tab->trg_event_map= table->trg_event_map;
|
||||
@@ -4563,8 +4565,8 @@ sp_head::add_used_tables_to_table_list(THD *thd,
|
||||
for (i=0 ; i < m_sptabs.records ; i++)
|
||||
{
|
||||
char *tab_buff, *key_buff;
|
||||
TABLE_LIST *table;
|
||||
SP_TABLE *stab= (SP_TABLE*) my_hash_element(&m_sptabs, i);
|
||||
LEX_CSTRING db_name;
|
||||
if (stab->temp)
|
||||
continue;
|
||||
|
||||
@@ -4574,16 +4576,26 @@ sp_head::add_used_tables_to_table_list(THD *thd,
|
||||
stab->qname.length)))
|
||||
DBUG_RETURN(FALSE);
|
||||
|
||||
db_name.str= key_buff;
|
||||
db_name.length= stab->db_length;
|
||||
|
||||
|
||||
for (uint j= 0; j < stab->lock_count; j++)
|
||||
{
|
||||
table= (TABLE_LIST *)tab_buff;
|
||||
table->init_one_table_for_prelocking(key_buff, stab->db_length,
|
||||
key_buff + stab->db_length + 1, stab->table_name_length,
|
||||
key_buff + stab->db_length + stab->table_name_length + 2,
|
||||
stab->lock_type, TABLE_LIST::PRELOCK_ROUTINE, belong_to_view,
|
||||
stab->trg_event_map,
|
||||
query_tables_last_ptr);
|
||||
TABLE_LIST *table= (TABLE_LIST *)tab_buff;
|
||||
LEX_CSTRING table_name= { key_buff + stab->db_length + 1,
|
||||
stab->table_name_length };
|
||||
LEX_CSTRING alias= { table_name.str + table_name.length + 1,
|
||||
strlen(table_name.str + table_name.length + 1) };
|
||||
|
||||
table->init_one_table_for_prelocking(&db_name,
|
||||
&table_name,
|
||||
&alias,
|
||||
stab->lock_type,
|
||||
TABLE_LIST::PRELOCK_ROUTINE,
|
||||
belong_to_view,
|
||||
stab->trg_event_map,
|
||||
query_tables_last_ptr);
|
||||
tab_buff+= ALIGN_SIZE(sizeof(TABLE_LIST));
|
||||
result= TRUE;
|
||||
}
|
||||
@@ -4603,7 +4615,7 @@ sp_head::add_used_tables_to_table_list(THD *thd,
|
||||
|
||||
TABLE_LIST *
|
||||
sp_add_to_query_tables(THD *thd, LEX *lex,
|
||||
const char *db, const char *name,
|
||||
const LEX_CSTRING *db, const LEX_CSTRING *name,
|
||||
thr_lock_type locktype,
|
||||
enum_mdl_type mdl_type)
|
||||
{
|
||||
@@ -4611,15 +4623,15 @@ sp_add_to_query_tables(THD *thd, LEX *lex,
|
||||
|
||||
if (!(table= (TABLE_LIST *)thd->calloc(sizeof(TABLE_LIST))))
|
||||
return NULL;
|
||||
table->db_length= strlen(db);
|
||||
table->db= thd->strmake(db, table->db_length);
|
||||
table->table_name_length= strlen(name);
|
||||
table->table_name= thd->strmake(name, table->table_name_length);
|
||||
table->alias= thd->strdup(name);
|
||||
if (!thd->make_lex_string(&table->db, db->str, db->length) ||
|
||||
!thd->make_lex_string(&table->table_name, name->str, name->length) ||
|
||||
!thd->make_lex_string(&table->alias, name->str, name->length))
|
||||
return NULL;
|
||||
|
||||
table->lock_type= locktype;
|
||||
table->select_lex= lex->current_select;
|
||||
table->cacheable_table= 1;
|
||||
table->mdl_request.init(MDL_key::TABLE, table->db, table->table_name,
|
||||
table->mdl_request.init(MDL_key::TABLE, table->db.str, table->table_name.str,
|
||||
mdl_type, MDL_TRANSACTION);
|
||||
|
||||
lex->add_to_query_tables(table);
|
||||
|
||||
@@ -1940,7 +1940,7 @@ set_routine_security_ctx(THD *thd, sp_head *sp, Security_context **save_ctx);
|
||||
|
||||
TABLE_LIST *
|
||||
sp_add_to_query_tables(THD *thd, LEX *lex,
|
||||
const char *db, const char *name,
|
||||
const LEX_CSTRING *db, const LEX_CSTRING *name,
|
||||
thr_lock_type locktype,
|
||||
enum_mdl_type mdl_type);
|
||||
|
||||
|
||||
101
sql/sql_acl.cc
101
sql/sql_acl.cc
@@ -859,7 +859,7 @@ class Grant_table_base
|
||||
if (table_exists())
|
||||
return 0;
|
||||
|
||||
my_error(ER_NO_SUCH_TABLE, MYF(0), tl.db, tl.alias);
|
||||
my_error(ER_NO_SUCH_TABLE, MYF(0), tl.db.str, tl.alias.str);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1024,9 +1024,7 @@ class User_table: public Grant_table_base
|
||||
void init(enum thr_lock_type lock_type)
|
||||
{
|
||||
/* We are relying on init_one_table zeroing out the TABLE_LIST structure. */
|
||||
tl.init_one_table(C_STRING_WITH_LEN("mysql"),
|
||||
C_STRING_WITH_LEN("user"),
|
||||
NULL, lock_type);
|
||||
tl.init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_USER_NAME, NULL, lock_type);
|
||||
Grant_table_base::init(lock_type, false);
|
||||
}
|
||||
|
||||
@@ -1070,9 +1068,7 @@ class Db_table: public Grant_table_base
|
||||
void init(enum thr_lock_type lock_type)
|
||||
{
|
||||
/* We are relying on init_one_table zeroing out the TABLE_LIST structure. */
|
||||
tl.init_one_table(C_STRING_WITH_LEN("mysql"),
|
||||
C_STRING_WITH_LEN("db"),
|
||||
NULL, lock_type);
|
||||
tl.init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_DB_NAME, NULL, lock_type);
|
||||
Grant_table_base::init(lock_type, false);
|
||||
}
|
||||
};
|
||||
@@ -1097,9 +1093,8 @@ class Tables_priv_table: public Grant_table_base
|
||||
void init(enum thr_lock_type lock_type, Grant_table_base *next_table= NULL)
|
||||
{
|
||||
/* We are relying on init_one_table zeroing out the TABLE_LIST structure. */
|
||||
tl.init_one_table(C_STRING_WITH_LEN("mysql"),
|
||||
C_STRING_WITH_LEN("tables_priv"),
|
||||
NULL, lock_type);
|
||||
LEX_CSTRING MYSQL_TABLES_PRIV_NAME={STRING_WITH_LEN("tables_priv") };
|
||||
tl.init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_TABLES_PRIV_NAME, NULL, lock_type);
|
||||
Grant_table_base::init(lock_type, false);
|
||||
}
|
||||
};
|
||||
@@ -1123,9 +1118,8 @@ class Columns_priv_table: public Grant_table_base
|
||||
void init(enum thr_lock_type lock_type)
|
||||
{
|
||||
/* We are relying on init_one_table zeroing out the TABLE_LIST structure. */
|
||||
tl.init_one_table(C_STRING_WITH_LEN("mysql"),
|
||||
C_STRING_WITH_LEN("columns_priv"),
|
||||
NULL, lock_type);
|
||||
LEX_CSTRING MYSQL_COLUMNS_PRIV_NAME={ STRING_WITH_LEN("columns_priv") };
|
||||
tl.init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_COLUMNS_PRIV_NAME, NULL, lock_type);
|
||||
Grant_table_base::init(lock_type, false);
|
||||
}
|
||||
};
|
||||
@@ -1144,9 +1138,8 @@ class Host_table: public Grant_table_base
|
||||
void init(enum thr_lock_type lock_type)
|
||||
{
|
||||
/* We are relying on init_one_table zeroing out the TABLE_LIST structure. */
|
||||
tl.init_one_table(C_STRING_WITH_LEN("mysql"),
|
||||
C_STRING_WITH_LEN("host"),
|
||||
NULL, lock_type);
|
||||
LEX_CSTRING MYSQL_HOST_NAME={STRING_WITH_LEN("host") };
|
||||
tl.init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_HOST_NAME, NULL, lock_type);
|
||||
Grant_table_base::init(lock_type, true);
|
||||
}
|
||||
};
|
||||
@@ -1171,9 +1164,8 @@ class Procs_priv_table: public Grant_table_base
|
||||
void init(enum thr_lock_type lock_type)
|
||||
{
|
||||
/* We are relying on init_one_table zeroing out the TABLE_LIST structure. */
|
||||
tl.init_one_table(C_STRING_WITH_LEN("mysql"),
|
||||
C_STRING_WITH_LEN("procs_priv"),
|
||||
NULL, lock_type);
|
||||
LEX_CSTRING MYSQL_PROCS_PRIV_NAME={STRING_WITH_LEN("procs_priv") };
|
||||
tl.init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_PROCS_PRIV_NAME, NULL, lock_type);
|
||||
Grant_table_base::init(lock_type, true);
|
||||
}
|
||||
};
|
||||
@@ -1197,9 +1189,8 @@ class Proxies_priv_table: public Grant_table_base
|
||||
void init(enum thr_lock_type lock_type)
|
||||
{
|
||||
/* We are relying on init_one_table zeroing out the TABLE_LIST structure. */
|
||||
tl.init_one_table(C_STRING_WITH_LEN("mysql"),
|
||||
C_STRING_WITH_LEN("proxies_priv"),
|
||||
NULL, lock_type);
|
||||
LEX_CSTRING MYSQL_PROXIES_PRIV_NAME={STRING_WITH_LEN("proxies_priv") };
|
||||
tl.init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_PROXIES_PRIV_NAME, NULL, lock_type);
|
||||
Grant_table_base::init(lock_type, true);
|
||||
}
|
||||
};
|
||||
@@ -1220,9 +1211,8 @@ class Roles_mapping_table: public Grant_table_base
|
||||
void init(enum thr_lock_type lock_type)
|
||||
{
|
||||
/* We are relying on init_one_table zeroing out the TABLE_LIST structure. */
|
||||
tl.init_one_table(C_STRING_WITH_LEN("mysql"),
|
||||
C_STRING_WITH_LEN("roles_mapping"),
|
||||
NULL, lock_type);
|
||||
LEX_CSTRING MYSQL_ROLES_MAPPING_NAME={STRING_WITH_LEN("roles_mapping") };
|
||||
tl.init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_ROLES_MAPPING_NAME, NULL, lock_type);
|
||||
Grant_table_base::init(lock_type, true);
|
||||
}
|
||||
};
|
||||
@@ -2691,8 +2681,8 @@ int acl_setrole(THD *thd, const char *rolename, ulonglong access)
|
||||
/* merge the privileges */
|
||||
Security_context *sctx= thd->security_ctx;
|
||||
sctx->master_access= static_cast<ulong>(access);
|
||||
if (thd->db)
|
||||
sctx->db_access= acl_get(sctx->host, sctx->ip, sctx->user, thd->db, FALSE);
|
||||
if (thd->db.str)
|
||||
sctx->db_access= acl_get(sctx->host, sctx->ip, sctx->user, thd->db.str, FALSE);
|
||||
|
||||
if (!strcasecmp(rolename, "NONE"))
|
||||
{
|
||||
@@ -2700,8 +2690,8 @@ int acl_setrole(THD *thd, const char *rolename, ulonglong access)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (thd->db)
|
||||
sctx->db_access|= acl_get("", "", rolename, thd->db, FALSE);
|
||||
if (thd->db.str)
|
||||
sctx->db_access|= acl_get("", "", rolename, thd->db.str, FALSE);
|
||||
/* mark the current role */
|
||||
strmake_buf(thd->security_ctx->priv_role, rolename);
|
||||
}
|
||||
@@ -3973,14 +3963,13 @@ static bool test_if_create_new_users(THD *thd)
|
||||
{
|
||||
TABLE_LIST tl;
|
||||
ulong db_access;
|
||||
tl.init_one_table(C_STRING_WITH_LEN("mysql"),
|
||||
C_STRING_WITH_LEN("user"), "user", TL_WRITE);
|
||||
tl.init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_USER_NAME, NULL, TL_WRITE);
|
||||
create_new_users= 1;
|
||||
|
||||
db_access=acl_get(sctx->host, sctx->ip,
|
||||
sctx->priv_user, tl.db, 0);
|
||||
sctx->priv_user, tl.db.str, 0);
|
||||
if (sctx->priv_role[0])
|
||||
db_access|= acl_get("", "", sctx->priv_role, tl.db, 0);
|
||||
db_access|= acl_get("", "", sctx->priv_role, tl.db.str, 0);
|
||||
if (!(db_access & INSERT_ACL))
|
||||
{
|
||||
if (check_grant(thd, INSERT_ACL, &tl, FALSE, UINT_MAX, TRUE))
|
||||
@@ -6482,7 +6471,7 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list,
|
||||
if (f == (Field*)0)
|
||||
{
|
||||
my_error(ER_BAD_FIELD_ERROR, MYF(0),
|
||||
column->column.c_ptr(), table_list->alias);
|
||||
column->column.c_ptr(), table_list->alias.str);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
if (f == (Field *)-1)
|
||||
@@ -6495,9 +6484,10 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list,
|
||||
{
|
||||
if (!(rights & CREATE_ACL))
|
||||
{
|
||||
if (!ha_table_exists(thd, table_list->db, table_list->table_name))
|
||||
if (!ha_table_exists(thd, &table_list->db, &table_list->table_name))
|
||||
{
|
||||
my_error(ER_NO_SUCH_TABLE, MYF(0), table_list->db, table_list->alias);
|
||||
my_error(ER_NO_SUCH_TABLE, MYF(0), table_list->db.str,
|
||||
table_list->alias.str);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
}
|
||||
@@ -6508,7 +6498,7 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list,
|
||||
table_list->grant.want_privilege);
|
||||
my_error(ER_TABLEACCESS_DENIED_ERROR, MYF(0),
|
||||
command, thd->security_ctx->priv_user,
|
||||
thd->security_ctx->host_or_ip, table_list->alias);
|
||||
thd->security_ctx->host_or_ip, table_list->alias.str);
|
||||
DBUG_RETURN(-1);
|
||||
}
|
||||
}
|
||||
@@ -6584,7 +6574,7 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list,
|
||||
if (revoke_grant)
|
||||
{
|
||||
my_error(ER_NONEXISTING_TABLE_GRANT, MYF(0),
|
||||
Str->user.str, Str->host.str, table_list->table_name);
|
||||
Str->user.str, Str->host.str, table_list->table_name.str);
|
||||
result= TRUE;
|
||||
continue;
|
||||
}
|
||||
@@ -6751,8 +6741,8 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list,
|
||||
continue;
|
||||
}
|
||||
|
||||
db_name= table_list->db;
|
||||
table_name= table_list->table_name;
|
||||
db_name= table_list->db.str;
|
||||
table_name= table_list->table_name.str;
|
||||
grant_name= routine_hash_search(Str->host.str, NullS, db_name,
|
||||
Str->user.str, table_name, sph, 1);
|
||||
if (!grant_name || !grant_name->init_privs)
|
||||
@@ -8179,13 +8169,13 @@ bool check_grant_routine(THD *thd, ulong want_access,
|
||||
for (table= procs; table; table= table->next_global)
|
||||
{
|
||||
GRANT_NAME *grant_proc;
|
||||
if ((grant_proc= routine_hash_search(host, sctx->ip, table->db, user,
|
||||
table->table_name, sph, 0)))
|
||||
if ((grant_proc= routine_hash_search(host, sctx->ip, table->db.str, user,
|
||||
table->table_name.str, sph, 0)))
|
||||
table->grant.privilege|= grant_proc->privs;
|
||||
if (role[0]) /* current role set check */
|
||||
{
|
||||
if ((grant_proc= routine_hash_search("", NULL, table->db, role,
|
||||
table->table_name, sph, 0)))
|
||||
if ((grant_proc= routine_hash_search("", NULL, table->db.str, role,
|
||||
table->table_name.str, sph, 0)))
|
||||
table->grant.privilege|= grant_proc->privs;
|
||||
}
|
||||
|
||||
@@ -8204,7 +8194,7 @@ err:
|
||||
char buff[1024];
|
||||
const char *command="";
|
||||
if (table)
|
||||
strxmov(buff, table->db, ".", table->table_name, NullS);
|
||||
strxmov(buff, table->db.str, ".", table->table_name.str, NullS);
|
||||
if (want_access & EXECUTE_ACL)
|
||||
command= "execute";
|
||||
else if (want_access & ALTER_PROC_ACL)
|
||||
@@ -8267,7 +8257,7 @@ ulong get_table_grant(THD *thd, TABLE_LIST *table)
|
||||
{
|
||||
ulong privilege;
|
||||
Security_context *sctx= thd->security_ctx;
|
||||
const char *db = table->db ? table->db : thd->db;
|
||||
const char *db = table->db.str ? table->db.str : thd->db.str;
|
||||
GRANT_TABLE *grant_table;
|
||||
GRANT_TABLE *grant_table_role= NULL;
|
||||
|
||||
@@ -8277,10 +8267,10 @@ ulong get_table_grant(THD *thd, TABLE_LIST *table)
|
||||
grant_table_role= NULL;
|
||||
#else
|
||||
grant_table= table_hash_search(sctx->host, sctx->ip, db, sctx->priv_user,
|
||||
table->table_name, 0);
|
||||
table->table_name.str, 0);
|
||||
if (sctx->priv_role[0])
|
||||
grant_table_role= table_hash_search("", "", db, sctx->priv_role,
|
||||
table->table_name, 0);
|
||||
table->table_name.str, 0);
|
||||
#endif
|
||||
table->grant.grant_table_user= grant_table; // Remember for column test
|
||||
table->grant.grant_table_role= grant_table_role;
|
||||
@@ -9194,7 +9184,8 @@ static int show_routine_grants(THD* thd,
|
||||
}
|
||||
}
|
||||
global.append(STRING_WITH_LEN(" ON "));
|
||||
global.append(sph->type_lex_cstring());
|
||||
LEX_CSTRING tmp= sph->type_lex_cstring();
|
||||
global.append(&tmp);
|
||||
global.append(' ');
|
||||
append_identifier(thd, &global, grant_proc->db,
|
||||
strlen(grant_proc->db));
|
||||
@@ -11026,8 +11017,10 @@ bool sp_grant_privileges(THD *thd, const char *sp_db, const char *sp_name,
|
||||
bzero((char*)tables, sizeof(TABLE_LIST));
|
||||
user_list.empty();
|
||||
|
||||
tables->db= (char*)sp_db;
|
||||
tables->table_name= tables->alias= (char*)sp_name;
|
||||
tables->db.str= sp_db;
|
||||
tables->db.length= sp_db ? strlen(sp_db) : 0;
|
||||
tables->table_name.str= tables->alias.str= sp_name;
|
||||
tables->table_name.length= tables->alias.length= sp_name ? strlen(sp_name) : 0;
|
||||
|
||||
thd->make_lex_string(&combo->user, combo->user.str, strlen(combo->user.str));
|
||||
thd->make_lex_string(&combo->host, combo->host.str, strlen(combo->host.str));
|
||||
@@ -11826,7 +11819,7 @@ void fill_effective_table_privileges(THD *thd, GRANT_INFO *grant,
|
||||
/* global privileges */
|
||||
grant->privilege= sctx->master_access;
|
||||
|
||||
if (!thd->db || strcmp(db, thd->db))
|
||||
if (!thd->db.str || strcmp(db, thd->db.str))
|
||||
{
|
||||
/* db privileges */
|
||||
grant->privilege|= acl_get(sctx->host, sctx->ip, sctx->priv_user, db, 0);
|
||||
@@ -12552,7 +12545,7 @@ static bool parse_com_change_user_packet(MPVIO_EXT *mpvio, uint packet_length)
|
||||
connection is closed. We don't want to accidentally free a wrong
|
||||
pointer if connect failed.
|
||||
*/
|
||||
thd->reset_db(NULL, 0);
|
||||
thd->reset_db(&null_clex_str);
|
||||
|
||||
if (!initialized)
|
||||
{
|
||||
@@ -12803,7 +12796,7 @@ static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio,
|
||||
connection is closed. We don't want to accidentally free a wrong
|
||||
pointer if connect failed.
|
||||
*/
|
||||
thd->reset_db(NULL, 0);
|
||||
thd->reset_db(&null_clex_str);
|
||||
|
||||
if (!initialized)
|
||||
{
|
||||
|
||||
@@ -77,7 +77,7 @@ static int send_check_errmsg(THD *thd, TABLE_LIST* table,
|
||||
{
|
||||
Protocol *protocol= thd->protocol;
|
||||
protocol->prepare_for_resend();
|
||||
protocol->store(table->alias, system_charset_info);
|
||||
protocol->store(table->alias.str, table->alias.length, system_charset_info);
|
||||
protocol->store((char*) operator_name, system_charset_info);
|
||||
protocol->store(STRING_WITH_LEN("error"), system_charset_info);
|
||||
protocol->store(errmsg, system_charset_info);
|
||||
@@ -123,7 +123,7 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list,
|
||||
*/
|
||||
|
||||
table_list->mdl_request.init(MDL_key::TABLE,
|
||||
table_list->db, table_list->table_name,
|
||||
table_list->db.str, table_list->table_name.str,
|
||||
MDL_EXCLUSIVE, MDL_TRANSACTION);
|
||||
|
||||
if (lock_table_names(thd, table_list, table_list->next_global,
|
||||
@@ -135,7 +135,8 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list,
|
||||
if (share == NULL)
|
||||
DBUG_RETURN(0); // Can't open frm file
|
||||
|
||||
if (open_table_from_share(thd, share, "", 0, 0, 0, &tmp_table, FALSE))
|
||||
if (open_table_from_share(thd, share, &empty_clex_str, 0, 0, 0,
|
||||
&tmp_table, FALSE))
|
||||
{
|
||||
tdc_release_share(share);
|
||||
DBUG_RETURN(0); // Out of memory
|
||||
@@ -218,7 +219,7 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list,
|
||||
"Failed renaming data file");
|
||||
goto end;
|
||||
}
|
||||
if (dd_recreate_table(thd, table_list->db, table_list->table_name))
|
||||
if (dd_recreate_table(thd, table_list->db.str, table_list->table_name.str))
|
||||
{
|
||||
error= send_check_errmsg(thd, table_list, "repair",
|
||||
"Failed generating table from .frm file");
|
||||
@@ -492,13 +493,13 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
|
||||
for (table= tables; table; table= table->next_local)
|
||||
{
|
||||
char table_name[SAFE_NAME_LEN*2+2];
|
||||
const char *db= table->db;
|
||||
const char *db= table->db.str;
|
||||
bool fatal_error=0;
|
||||
bool open_error;
|
||||
bool collect_eis= FALSE;
|
||||
|
||||
DBUG_PRINT("admin", ("table: '%s'.'%s'", table->db, table->table_name));
|
||||
strxmov(table_name, db, ".", table->table_name, NullS);
|
||||
DBUG_PRINT("admin", ("table: '%s'.'%s'", db, table->table_name.str));
|
||||
strxmov(table_name, db, ".", table->table_name.str, NullS);
|
||||
thd->open_options|= extra_open_options;
|
||||
table->lock_type= lock_type;
|
||||
/*
|
||||
@@ -547,7 +548,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
|
||||
close_thread_tables(thd);
|
||||
table->table= NULL;
|
||||
thd->mdl_context.release_transactional_locks();
|
||||
table->mdl_request.init(MDL_key::TABLE, table->db, table->table_name,
|
||||
table->mdl_request.init(MDL_key::TABLE, table->db.str, table->table_name.str,
|
||||
MDL_SHARED_NO_READ_WRITE, MDL_TRANSACTION);
|
||||
}
|
||||
|
||||
@@ -818,7 +819,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
|
||||
close_thread_tables(thd);
|
||||
table->table= NULL;
|
||||
thd->mdl_context.release_transactional_locks();
|
||||
table->mdl_request.init(MDL_key::TABLE, table->db, table->table_name,
|
||||
table->mdl_request.init(MDL_key::TABLE, table->db.str, table->table_name.str,
|
||||
MDL_SHARED_NO_READ_WRITE, MDL_TRANSACTION);
|
||||
table->mdl_request.set_type(MDL_SHARED_READ);
|
||||
|
||||
@@ -1118,11 +1119,11 @@ send_result_message:
|
||||
if (what_to_upgrade)
|
||||
length= my_snprintf(buf, sizeof(buf),
|
||||
ER_THD(thd, ER_TABLE_NEEDS_UPGRADE),
|
||||
what_to_upgrade, table->table_name);
|
||||
what_to_upgrade, table->table_name.str);
|
||||
else
|
||||
length= my_snprintf(buf, sizeof(buf),
|
||||
ER_THD(thd, ER_TABLE_NEEDS_REBUILD),
|
||||
table->table_name);
|
||||
table->table_name.str);
|
||||
protocol->store(buf, length, system_charset_info);
|
||||
fatal_error=1;
|
||||
break;
|
||||
@@ -1154,7 +1155,7 @@ send_result_message:
|
||||
else if (open_for_modify || fatal_error)
|
||||
{
|
||||
tdc_remove_table(thd, TDC_RT_REMOVE_UNUSED,
|
||||
table->db, table->table_name, FALSE);
|
||||
table->db.str, table->table_name.str, FALSE);
|
||||
/*
|
||||
May be something modified. Consequently, we have to
|
||||
invalidate the query cache.
|
||||
|
||||
@@ -86,8 +86,8 @@ bool Alter_info::set_requested_lock(const LEX_CSTRING *str)
|
||||
Alter_table_ctx::Alter_table_ctx()
|
||||
: datetime_field(NULL), error_if_not_empty(false),
|
||||
tables_opened(0),
|
||||
db(NULL), table_name(NULL), alias(NULL),
|
||||
new_db(NULL), new_name(NULL), new_alias(NULL),
|
||||
db(null_clex_str), table_name(null_clex_str), alias(null_clex_str),
|
||||
new_db(null_clex_str), new_name(null_clex_str), new_alias(null_clex_str),
|
||||
fk_error_if_delete_row(false), fk_error_id(NULL),
|
||||
fk_error_table(NULL)
|
||||
#ifdef DBUG_ASSERT_EXISTS
|
||||
@@ -103,11 +103,11 @@ Alter_table_ctx::Alter_table_ctx()
|
||||
|
||||
Alter_table_ctx::Alter_table_ctx(THD *thd, TABLE_LIST *table_list,
|
||||
uint tables_opened_arg,
|
||||
const char *new_db_arg,
|
||||
const char *new_name_arg)
|
||||
const LEX_CSTRING *new_db_arg,
|
||||
const LEX_CSTRING *new_name_arg)
|
||||
: datetime_field(NULL), error_if_not_empty(false),
|
||||
tables_opened(tables_opened_arg),
|
||||
new_db(new_db_arg), new_name(new_name_arg),
|
||||
new_db(*new_db_arg), new_name(*new_name_arg),
|
||||
fk_error_if_delete_row(false), fk_error_id(NULL),
|
||||
fk_error_table(NULL)
|
||||
#ifdef DBUG_ASSERT_EXISTS
|
||||
@@ -123,29 +123,31 @@ Alter_table_ctx::Alter_table_ctx(THD *thd, TABLE_LIST *table_list,
|
||||
table_name= table_list->table_name;
|
||||
alias= (lower_case_table_names == 2) ? table_list->alias : table_name;
|
||||
|
||||
if (!new_db || !my_strcasecmp(table_alias_charset, new_db, db))
|
||||
if (!new_db.str || !my_strcasecmp(table_alias_charset, new_db.str, db.str))
|
||||
new_db= db;
|
||||
|
||||
if (new_name)
|
||||
if (new_name.str)
|
||||
{
|
||||
DBUG_PRINT("info", ("new_db.new_name: '%s'.'%s'", new_db, new_name));
|
||||
DBUG_PRINT("info", ("new_db.new_name: '%s'.'%s'", new_db.str, new_name.str));
|
||||
|
||||
if (lower_case_table_names == 1) // Convert new_name/new_alias to lower case
|
||||
if (lower_case_table_names == 1) // Convert new_name/new_alias to lower
|
||||
{
|
||||
my_casedn_str(files_charset_info, (char*) new_name);
|
||||
new_name.length= my_casedn_str(files_charset_info, (char*) new_name.str);
|
||||
new_alias= new_name;
|
||||
}
|
||||
else if (lower_case_table_names == 2) // Convert new_name to lower case
|
||||
{
|
||||
new_alias= new_alias_buff;
|
||||
strmov(new_alias_buff, new_name);
|
||||
my_casedn_str(files_charset_info, (char*) new_name);
|
||||
new_alias.str= new_alias_buff;
|
||||
new_alias.length= new_name.length;
|
||||
strmov(new_alias_buff, new_name.str);
|
||||
new_name.length= my_casedn_str(files_charset_info, (char*) new_name.str);
|
||||
|
||||
}
|
||||
else
|
||||
new_alias= new_name; // LCTN=0 => case sensitive + case preserving
|
||||
|
||||
if (!is_database_changed() &&
|
||||
!my_strcasecmp(table_alias_charset, new_name, table_name))
|
||||
!my_strcasecmp(table_alias_charset, new_name.str, table_name.str))
|
||||
{
|
||||
/*
|
||||
Source and destination table names are equal:
|
||||
@@ -161,22 +163,23 @@ Alter_table_ctx::Alter_table_ctx(THD *thd, TABLE_LIST *table_list,
|
||||
new_name= table_name;
|
||||
}
|
||||
|
||||
my_snprintf(tmp_name, sizeof(tmp_name), "%s-%lx_%llx", tmp_file_prefix,
|
||||
current_pid, thd->thread_id);
|
||||
tmp_name.str= tmp_name_buff;
|
||||
tmp_name.length= my_snprintf(tmp_name_buff, sizeof(tmp_name_buff), "%s-%lx_%llx",
|
||||
tmp_file_prefix, current_pid, thd->thread_id);
|
||||
/* Safety fix for InnoDB */
|
||||
if (lower_case_table_names)
|
||||
my_casedn_str(files_charset_info, tmp_name);
|
||||
tmp_name.length= my_casedn_str(files_charset_info, tmp_name_buff);
|
||||
|
||||
if (table_list->table->s->tmp_table == NO_TMP_TABLE)
|
||||
{
|
||||
build_table_filename(path, sizeof(path) - 1, db, table_name, "", 0);
|
||||
build_table_filename(path, sizeof(path) - 1, db.str, table_name.str, "", 0);
|
||||
|
||||
build_table_filename(new_path, sizeof(new_path) - 1, new_db, new_name, "", 0);
|
||||
build_table_filename(new_path, sizeof(new_path) - 1, new_db.str, new_name.str, "", 0);
|
||||
|
||||
build_table_filename(new_filename, sizeof(new_filename) - 1,
|
||||
new_db, new_name, reg_ext, 0);
|
||||
new_db.str, new_name.str, reg_ext, 0);
|
||||
|
||||
build_table_filename(tmp_path, sizeof(tmp_path) - 1, new_db, tmp_name, "",
|
||||
build_table_filename(tmp_path, sizeof(tmp_path) - 1, new_db.str, tmp_name.str, "",
|
||||
FN_IS_TMP);
|
||||
}
|
||||
else
|
||||
@@ -227,14 +230,14 @@ bool Sql_cmd_alter_table::execute(THD *thd)
|
||||
priv_needed|= DROP_ACL;
|
||||
|
||||
/* Must be set in the parser */
|
||||
DBUG_ASSERT(select_lex->db);
|
||||
DBUG_ASSERT(select_lex->db.str);
|
||||
DBUG_ASSERT(!(alter_info.flags & Alter_info::ALTER_EXCHANGE_PARTITION));
|
||||
DBUG_ASSERT(!(alter_info.flags & Alter_info::ALTER_ADMIN_PARTITION));
|
||||
if (check_access(thd, priv_needed, first_table->db,
|
||||
if (check_access(thd, priv_needed, first_table->db.str,
|
||||
&first_table->grant.privilege,
|
||||
&first_table->grant.m_internal,
|
||||
0, 0) ||
|
||||
check_access(thd, INSERT_ACL | CREATE_ACL, select_lex->db,
|
||||
check_access(thd, INSERT_ACL | CREATE_ACL, select_lex->db.str,
|
||||
&priv,
|
||||
NULL, /* Don't use first_tab->grant with sel_lex->db */
|
||||
0, 0))
|
||||
@@ -291,7 +294,7 @@ bool Sql_cmd_alter_table::execute(THD *thd)
|
||||
// Rename of table
|
||||
TABLE_LIST tmp_table;
|
||||
memset(&tmp_table, 0, sizeof(tmp_table));
|
||||
tmp_table.table_name= lex->name.str;
|
||||
tmp_table.table_name= lex->name;
|
||||
tmp_table.db= select_lex->db;
|
||||
tmp_table.grant.privilege= priv;
|
||||
if (check_grant(thd, INSERT_ACL | CREATE_ACL, &tmp_table, FALSE,
|
||||
@@ -316,13 +319,13 @@ bool Sql_cmd_alter_table::execute(THD *thd)
|
||||
if ((!thd->is_current_stmt_binlog_format_row() ||
|
||||
!thd->find_temporary_table(first_table)))
|
||||
{
|
||||
WSREP_TO_ISOLATION_BEGIN(((lex->name.str) ? select_lex->db : NULL),
|
||||
WSREP_TO_ISOLATION_BEGIN(((lex->name.str) ? select_lex->db.str : NULL),
|
||||
((lex->name.str) ? lex->name.str : NULL),
|
||||
first_table);
|
||||
}
|
||||
#endif /* WITH_WSREP */
|
||||
|
||||
result= mysql_alter_table(thd, select_lex->db, lex->name.str,
|
||||
result= mysql_alter_table(thd, &select_lex->db, &lex->name,
|
||||
&create_info,
|
||||
first_table,
|
||||
&alter_info,
|
||||
@@ -346,7 +349,7 @@ bool Sql_cmd_discard_import_tablespace::execute(THD *thd)
|
||||
/* first table of first SELECT_LEX */
|
||||
TABLE_LIST *table_list= (TABLE_LIST*) select_lex->table_list.first;
|
||||
|
||||
if (check_access(thd, ALTER_ACL, table_list->db,
|
||||
if (check_access(thd, ALTER_ACL, table_list->db.str,
|
||||
&table_list->grant.privilege,
|
||||
&table_list->grant.m_internal,
|
||||
0, 0))
|
||||
|
||||
@@ -268,19 +268,19 @@ public:
|
||||
Alter_table_ctx();
|
||||
|
||||
Alter_table_ctx(THD *thd, TABLE_LIST *table_list, uint tables_opened_arg,
|
||||
const char *new_db_arg, const char *new_name_arg);
|
||||
const LEX_CSTRING *new_db_arg, const LEX_CSTRING *new_name_arg);
|
||||
|
||||
/**
|
||||
@return true if the table is moved to another database, false otherwise.
|
||||
*/
|
||||
bool is_database_changed() const
|
||||
{ return (new_db != db); };
|
||||
{ return (new_db.str != db.str); };
|
||||
|
||||
/**
|
||||
@return true if the table is renamed, false otherwise.
|
||||
*/
|
||||
bool is_table_renamed() const
|
||||
{ return (is_database_changed() || new_name != table_name); };
|
||||
{ return (is_database_changed() || new_name.str != table_name.str); };
|
||||
|
||||
/**
|
||||
@return filename (including .frm) for the new table.
|
||||
@@ -330,13 +330,14 @@ public:
|
||||
Create_field *datetime_field;
|
||||
bool error_if_not_empty;
|
||||
uint tables_opened;
|
||||
const char *db;
|
||||
const char *table_name;
|
||||
const char *alias;
|
||||
const char *new_db;
|
||||
const char *new_name;
|
||||
const char *new_alias;
|
||||
char tmp_name[80];
|
||||
LEX_CSTRING db;
|
||||
LEX_CSTRING table_name;
|
||||
LEX_CSTRING alias;
|
||||
LEX_CSTRING new_db;
|
||||
LEX_CSTRING new_name;
|
||||
LEX_CSTRING new_alias;
|
||||
LEX_CSTRING tmp_name;
|
||||
char tmp_buff[80];
|
||||
/**
|
||||
Indicates that if a row is deleted during copying of data from old version
|
||||
of table to the new version ER_FK_CANNOT_DELETE_PARENT error should be
|
||||
@@ -350,7 +351,8 @@ public:
|
||||
|
||||
private:
|
||||
char new_filename[FN_REFLEN + 1];
|
||||
char new_alias_buff[FN_REFLEN + 1];
|
||||
char new_alias_buff[NAME_LEN + 1];
|
||||
char tmp_name_buff[NAME_LEN + 1];
|
||||
char path[FN_REFLEN + 1];
|
||||
char new_path[FN_REFLEN + 1];
|
||||
char tmp_path[FN_REFLEN + 1];
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
#include "mariadb.h"
|
||||
#include "sql_priv.h"
|
||||
#include "mysqld.h"
|
||||
#include "sql_audit.h"
|
||||
|
||||
extern int initialize_audit_plugin(st_plugin_int *plugin);
|
||||
|
||||
@@ -121,15 +121,13 @@ void mysql_audit_general_log(THD *thd, time_t time,
|
||||
event.general_thread_id= (unsigned long)thd->thread_id;
|
||||
event.general_charset= thd->variables.character_set_client;
|
||||
event.database= thd->db;
|
||||
event.database_length= (unsigned int)thd->db_length;
|
||||
event.query_id= thd->query_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
event.general_thread_id= 0;
|
||||
event.general_charset= global_system_variables.character_set_client;
|
||||
event.database= "";
|
||||
event.database_length= 0;
|
||||
event.database= null_clex_str;
|
||||
event.query_id= 0;
|
||||
}
|
||||
|
||||
@@ -175,7 +173,6 @@ void mysql_audit_general(THD *thd, uint event_subtype,
|
||||
event.general_charset= thd->query_string.charset();
|
||||
event.general_rows= thd->get_stmt_da()->current_row_for_warning();
|
||||
event.database= thd->db;
|
||||
event.database_length= (uint)thd->db_length;
|
||||
event.query_id= thd->query_id;
|
||||
}
|
||||
else
|
||||
@@ -187,8 +184,7 @@ void mysql_audit_general(THD *thd, uint event_subtype,
|
||||
event.general_query_length= 0;
|
||||
event.general_charset= &my_charset_bin;
|
||||
event.general_rows= 0;
|
||||
event.database= "";
|
||||
event.database_length= 0;
|
||||
event.database= null_clex_str;
|
||||
event.query_id= 0;
|
||||
}
|
||||
|
||||
@@ -222,7 +218,6 @@ void mysql_audit_notify_connection_connect(THD *thd)
|
||||
event.ip= sctx->ip;
|
||||
event.ip_length= safe_strlen_uint(sctx->ip);
|
||||
event.database= thd->db;
|
||||
event.database_length= safe_strlen_uint(thd->db);
|
||||
|
||||
mysql_audit_notify(thd, MYSQL_AUDIT_CONNECTION_CLASS, &event);
|
||||
}
|
||||
@@ -252,7 +247,6 @@ void mysql_audit_notify_connection_disconnect(THD *thd, int errcode)
|
||||
event.ip= sctx->ip;
|
||||
event.ip_length= safe_strlen_uint(sctx->ip) ;
|
||||
event.database= thd->db;
|
||||
event.database_length= safe_strlen_uint(thd->db);
|
||||
|
||||
mysql_audit_notify(thd, MYSQL_AUDIT_CONNECTION_CLASS, &event);
|
||||
}
|
||||
@@ -283,7 +277,6 @@ void mysql_audit_notify_connection_change_user(THD *thd)
|
||||
event.ip= sctx->ip;
|
||||
event.ip_length= safe_strlen_uint(sctx->ip);
|
||||
event.database= thd->db;
|
||||
event.database_length= safe_strlen_uint(thd->db);
|
||||
|
||||
mysql_audit_notify(thd, MYSQL_AUDIT_CONNECTION_CLASS, &event);
|
||||
}
|
||||
@@ -307,14 +300,10 @@ void mysql_audit_external_lock(THD *thd, TABLE_SHARE *share, int lock)
|
||||
event.proxy_user= sctx->proxy_user;
|
||||
event.host= sctx->host;
|
||||
event.ip= sctx->ip;
|
||||
event.database= share->db.str;
|
||||
event.database_length= (unsigned int)share->db.length;
|
||||
event.table= share->table_name.str;
|
||||
event.table_length= (unsigned int)share->table_name.length;
|
||||
event.new_database= 0;
|
||||
event.new_database_length= 0;
|
||||
event.new_table= 0;
|
||||
event.new_table_length= 0;
|
||||
event.database= share->db;
|
||||
event.table= share->table_name;
|
||||
event.new_database= null_clex_str;
|
||||
event.new_table= null_clex_str;
|
||||
event.query_id= thd->query_id;
|
||||
|
||||
mysql_audit_notify(thd, MYSQL_AUDIT_TABLE_CLASS, &event);
|
||||
@@ -341,15 +330,11 @@ void mysql_audit_create_table(TABLE *table)
|
||||
event.proxy_user= sctx->proxy_user;
|
||||
event.host= sctx->host;
|
||||
event.ip= sctx->ip;
|
||||
event.database= share->db.str;
|
||||
event.database_length= (unsigned int)share->db.length;
|
||||
event.table= share->table_name.str;
|
||||
event.table_length= (unsigned int)share->table_name.length;
|
||||
event.new_database= 0;
|
||||
event.new_database_length= 0;
|
||||
event.new_table= 0;
|
||||
event.new_table_length= 0;
|
||||
event.query_id= thd->query_id;
|
||||
event.database= share->db;
|
||||
event.table= share->table_name;
|
||||
event.new_database= null_clex_str;
|
||||
event.new_table= null_clex_str;
|
||||
event.query_id= thd->query_id;
|
||||
|
||||
mysql_audit_notify(thd, MYSQL_AUDIT_TABLE_CLASS, &event);
|
||||
}
|
||||
@@ -373,23 +358,20 @@ void mysql_audit_drop_table(THD *thd, TABLE_LIST *table)
|
||||
event.proxy_user= sctx->proxy_user;
|
||||
event.host= sctx->host;
|
||||
event.ip= sctx->ip;
|
||||
event.database= table->db;
|
||||
event.database_length= (unsigned int)table->db_length;
|
||||
event.table= table->table_name;
|
||||
event.table_length= (unsigned int)table->table_name_length;
|
||||
event.new_database= 0;
|
||||
event.new_database_length= 0;
|
||||
event.new_table= 0;
|
||||
event.new_table_length= 0;
|
||||
event.query_id= thd->query_id;
|
||||
event.database= table->db;
|
||||
event.table= table->table_name;
|
||||
event.new_database= null_clex_str;
|
||||
event.new_table= null_clex_str;
|
||||
event.query_id= thd->query_id;
|
||||
|
||||
mysql_audit_notify(thd, MYSQL_AUDIT_TABLE_CLASS, &event);
|
||||
}
|
||||
}
|
||||
|
||||
static inline
|
||||
void mysql_audit_rename_table(THD *thd, const char *old_db, const char *old_tb,
|
||||
const char *new_db, const char *new_tb)
|
||||
void mysql_audit_rename_table(THD *thd, const LEX_CSTRING *old_db,
|
||||
const LEX_CSTRING *old_tb,
|
||||
const LEX_CSTRING *new_db, const LEX_CSTRING *new_tb)
|
||||
{
|
||||
if (mysql_audit_table_enabled())
|
||||
{
|
||||
@@ -406,14 +388,10 @@ void mysql_audit_rename_table(THD *thd, const char *old_db, const char *old_tb,
|
||||
event.proxy_user= sctx->proxy_user;
|
||||
event.host= sctx->host;
|
||||
event.ip= sctx->ip;
|
||||
event.database= old_db;
|
||||
event.database_length= strlen_uint(old_db);
|
||||
event.table= old_tb;
|
||||
event.table_length= strlen_uint(old_tb);
|
||||
event.new_database= new_db;
|
||||
event.new_database_length= strlen_uint(new_db);
|
||||
event.new_table= new_tb;
|
||||
event.new_table_length= strlen_uint(new_tb);
|
||||
event.database= *old_db;
|
||||
event.table= *old_tb;
|
||||
event.new_database= *new_db;
|
||||
event.new_table= *new_tb;
|
||||
event.query_id= thd->query_id;
|
||||
|
||||
mysql_audit_notify(thd, MYSQL_AUDIT_TABLE_CLASS, &event);
|
||||
@@ -439,13 +417,9 @@ void mysql_audit_alter_table(THD *thd, TABLE_LIST *table)
|
||||
event.host= sctx->host;
|
||||
event.ip= sctx->ip;
|
||||
event.database= table->db;
|
||||
event.database_length= (unsigned int)table->db_length;
|
||||
event.table= table->table_name;
|
||||
event.table_length= (unsigned int)table->table_name_length;
|
||||
event.new_database= 0;
|
||||
event.new_database_length= 0;
|
||||
event.new_table= 0;
|
||||
event.new_table_length= 0;
|
||||
event.new_database= null_clex_str;
|
||||
event.new_table= null_clex_str;
|
||||
event.query_id= thd->query_id;
|
||||
|
||||
mysql_audit_notify(thd, MYSQL_AUDIT_TABLE_CLASS, &event);
|
||||
|
||||
239
sql/sql_base.cc
239
sql/sql_base.cc
@@ -244,8 +244,9 @@ struct list_open_tables_arg
|
||||
static my_bool list_open_tables_callback(TDC_element *element,
|
||||
list_open_tables_arg *arg)
|
||||
{
|
||||
char *db= (char*) element->m_key;
|
||||
char *table_name= (char*) element->m_key + strlen((char*) element->m_key) + 1;
|
||||
const char *db= (char*) element->m_key;
|
||||
uint db_length= strlen(db);
|
||||
const char *table_name= db + db_length + 1;
|
||||
|
||||
if (arg->db && my_strcasecmp(system_charset_info, arg->db, db))
|
||||
return FALSE;
|
||||
@@ -253,8 +254,10 @@ static my_bool list_open_tables_callback(TDC_element *element,
|
||||
return FALSE;
|
||||
|
||||
/* Check if user has SELECT privilege for any column in the table */
|
||||
arg->table_list.db= db;
|
||||
arg->table_list.table_name= table_name;
|
||||
arg->table_list.db.str= db;
|
||||
arg->table_list.db.length= db_length;
|
||||
arg->table_list.table_name.str= table_name;
|
||||
arg->table_list.table_name.length= strlen(table_name);
|
||||
arg->table_list.grant.privilege= 0;
|
||||
|
||||
if (check_table_access(arg->thd, SELECT_ACL, &arg->table_list, TRUE, 1, TRUE))
|
||||
@@ -381,8 +384,8 @@ bool close_cached_tables(THD *thd, TABLE_LIST *tables,
|
||||
for (TABLE_LIST *table= tables; table; table= table->next_local)
|
||||
{
|
||||
/* tdc_remove_table() also sets TABLE_SHARE::version to 0. */
|
||||
found|= tdc_remove_table(thd, TDC_RT_REMOVE_UNUSED, table->db,
|
||||
table->table_name, TRUE);
|
||||
found|= tdc_remove_table(thd, TDC_RT_REMOVE_UNUSED, table->db.str,
|
||||
table->table_name.str, TRUE);
|
||||
}
|
||||
if (!found)
|
||||
wait_for_refresh=0; // Nothing to wait for
|
||||
@@ -412,8 +415,8 @@ bool close_cached_tables(THD *thd, TABLE_LIST *tables,
|
||||
table_list= table_list->next_global)
|
||||
{
|
||||
/* A check that the table was locked for write is done by the caller. */
|
||||
TABLE *table= find_table_for_mdl_upgrade(thd, table_list->db,
|
||||
table_list->table_name, TRUE);
|
||||
TABLE *table= find_table_for_mdl_upgrade(thd, table_list->db.str,
|
||||
table_list->table_name.str, TRUE);
|
||||
|
||||
/* May return NULL if this table has already been closed via an alias. */
|
||||
if (! table)
|
||||
@@ -463,7 +466,7 @@ bool close_cached_tables(THD *thd, TABLE_LIST *tables,
|
||||
{
|
||||
if (thd->killed)
|
||||
break;
|
||||
if (tdc_wait_for_old_version(thd, table->db, table->table_name, timeout,
|
||||
if (tdc_wait_for_old_version(thd, table->db.str, table->table_name.str, timeout,
|
||||
MDL_wait_for_subgraph::DEADLOCK_WEIGHT_DDL,
|
||||
refresh_version))
|
||||
{
|
||||
@@ -530,9 +533,9 @@ static my_bool close_cached_connection_tables_callback(
|
||||
|
||||
/* close_cached_tables() only uses these elements */
|
||||
if (!(tmp= (TABLE_LIST*) alloc_root(arg->thd->mem_root, sizeof(TABLE_LIST))) ||
|
||||
!(tmp->db= strdup_root(arg->thd->mem_root, element->share->db.str)) ||
|
||||
!(tmp->table_name= strdup_root(arg->thd->mem_root,
|
||||
element->share->table_name.str)))
|
||||
!(arg->thd->make_lex_string(&tmp->db, element->share->db.str, element->share->db.length)) ||
|
||||
!(arg->thd->make_lex_string(&tmp->table_name, element->share->table_name.str,
|
||||
element->share->table_name.length)))
|
||||
{
|
||||
mysql_mutex_unlock(&element->LOCK_table_share);
|
||||
return TRUE;
|
||||
@@ -919,8 +922,7 @@ void close_thread_table(THD *thd, TABLE **table_ptr)
|
||||
table_name Table name
|
||||
|
||||
NOTES:
|
||||
This is called by find_table_in_local_list() and
|
||||
find_table_in_global_list().
|
||||
This is called by find_table_in_global_list().
|
||||
|
||||
RETURN VALUES
|
||||
NULL Table not found
|
||||
@@ -929,13 +931,13 @@ void close_thread_table(THD *thd, TABLE **table_ptr)
|
||||
|
||||
TABLE_LIST *find_table_in_list(TABLE_LIST *table,
|
||||
TABLE_LIST *TABLE_LIST::*link,
|
||||
const char *db_name,
|
||||
const char *table_name)
|
||||
const LEX_CSTRING *db_name,
|
||||
const LEX_CSTRING *table_name)
|
||||
{
|
||||
for (; table; table= table->*link )
|
||||
{
|
||||
if (strcmp(table->db, db_name) == 0 &&
|
||||
strcmp(table->table_name, table_name) == 0)
|
||||
if (cmp(&table->db, db_name) == 0 &&
|
||||
cmp(&table->table_name, table_name) == 0)
|
||||
break;
|
||||
}
|
||||
return table;
|
||||
@@ -980,9 +982,9 @@ TABLE_LIST* find_dup_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list,
|
||||
bool check_alias)
|
||||
{
|
||||
TABLE_LIST *res;
|
||||
const char *d_name, *t_name, *t_alias;
|
||||
LEX_CSTRING *d_name, *t_name, *t_alias;
|
||||
DBUG_ENTER("find_dup_table");
|
||||
DBUG_PRINT("enter", ("table alias: %s", table->alias));
|
||||
DBUG_PRINT("enter", ("table alias: %s", table->alias.str));
|
||||
|
||||
/*
|
||||
If this function called for query which update table (INSERT/UPDATE/...)
|
||||
@@ -1006,12 +1008,12 @@ TABLE_LIST* find_dup_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list,
|
||||
*/
|
||||
DBUG_ASSERT(table);
|
||||
}
|
||||
d_name= table->db;
|
||||
t_name= table->table_name;
|
||||
t_alias= table->alias;
|
||||
d_name= &table->db;
|
||||
t_name= &table->table_name;
|
||||
t_alias= &table->alias;
|
||||
|
||||
retry:
|
||||
DBUG_PRINT("info", ("real table: %s.%s", d_name, t_name));
|
||||
DBUG_PRINT("info", ("real table: %s.%s", d_name->str, t_name->str));
|
||||
for (TABLE_LIST *tl= table_list;;)
|
||||
{
|
||||
if (tl &&
|
||||
@@ -1039,7 +1041,7 @@ retry:
|
||||
/* Skip if table alias does not match. */
|
||||
if (check_alias)
|
||||
{
|
||||
if (my_strcasecmp(table_alias_charset, t_alias, res->alias))
|
||||
if (my_strcasecmp(table_alias_charset, t_alias->str, res->alias.str))
|
||||
goto next;
|
||||
}
|
||||
|
||||
@@ -1177,21 +1179,21 @@ void update_non_unique_table_error(TABLE_LIST *update,
|
||||
if (update->view == duplicate->view)
|
||||
my_error(!strncmp(operation, "INSERT", 6) ?
|
||||
ER_NON_INSERTABLE_TABLE : ER_NON_UPDATABLE_TABLE, MYF(0),
|
||||
update->alias, operation);
|
||||
update->alias.str, operation);
|
||||
else
|
||||
my_error(ER_VIEW_PREVENT_UPDATE, MYF(0),
|
||||
(duplicate->view ? duplicate->alias : update->alias),
|
||||
operation, update->alias);
|
||||
(duplicate->view ? duplicate->alias.str : update->alias.str),
|
||||
operation, update->alias.str);
|
||||
return;
|
||||
}
|
||||
if (duplicate->view)
|
||||
{
|
||||
my_error(ER_VIEW_PREVENT_UPDATE, MYF(0), duplicate->alias, operation,
|
||||
update->alias);
|
||||
my_error(ER_VIEW_PREVENT_UPDATE, MYF(0), duplicate->alias.str, operation,
|
||||
update->alias.str);
|
||||
return;
|
||||
}
|
||||
}
|
||||
my_error(ER_UPDATE_TABLE_USED, MYF(0), update->alias, operation);
|
||||
my_error(ER_UPDATE_TABLE_USED, MYF(0), update->alias.str, operation);
|
||||
}
|
||||
|
||||
|
||||
@@ -1256,8 +1258,8 @@ bool wait_while_table_is_used(THD *thd, TABLE *table,
|
||||
prelocked mode, e.g. if we do CREATE TABLE .. SELECT f1();
|
||||
*/
|
||||
|
||||
void drop_open_table(THD *thd, TABLE *table, const char *db_name,
|
||||
const char *table_name)
|
||||
void drop_open_table(THD *thd, TABLE *table, const LEX_CSTRING *db_name,
|
||||
const LEX_CSTRING *table_name)
|
||||
{
|
||||
DBUG_ENTER("drop_open_table");
|
||||
if (table->s->tmp_table)
|
||||
@@ -1270,7 +1272,7 @@ void drop_open_table(THD *thd, TABLE *table, const char *db_name,
|
||||
table->file->extra(HA_EXTRA_PREPARE_FOR_DROP);
|
||||
close_thread_table(thd, &thd->open_tables);
|
||||
/* Remove the table share from the table cache. */
|
||||
tdc_remove_table(thd, TDC_RT_REMOVE_ALL, db_name, table_name,
|
||||
tdc_remove_table(thd, TDC_RT_REMOVE_ALL, db_name->str, table_name->str,
|
||||
FALSE);
|
||||
/* Remove the table from the storage engine and rm the .frm. */
|
||||
quick_rm_table(thd, table_type, db_name, table_name, 0);
|
||||
@@ -1507,7 +1509,7 @@ bool open_table(THD *thd, TABLE_LIST *table_list, Open_table_context *ot_ctx)
|
||||
TABLE *table;
|
||||
const char *key;
|
||||
uint key_length;
|
||||
const char *alias= table_list->alias;
|
||||
const char *alias= table_list->alias.str;
|
||||
uint flags= ot_ctx->get_flags();
|
||||
MDL_ticket *mdl_ticket;
|
||||
TABLE_SHARE *share;
|
||||
@@ -1628,13 +1630,13 @@ bool open_table(THD *thd, TABLE_LIST *table_list, Open_table_context *ot_ctx)
|
||||
to deadlocks) it should be disallowed.
|
||||
*/
|
||||
if (thd->mdl_context.is_lock_owner(MDL_key::TABLE,
|
||||
table_list->db,
|
||||
table_list->table_name,
|
||||
table_list->db.str,
|
||||
table_list->table_name.str,
|
||||
MDL_SHARED))
|
||||
{
|
||||
char path[FN_REFLEN + 1];
|
||||
build_table_filename(path, sizeof(path) - 1,
|
||||
table_list->db, table_list->table_name, reg_ext, 0);
|
||||
table_list->db.str, table_list->table_name.str, reg_ext, 0);
|
||||
/*
|
||||
Note that we can't be 100% sure that it is a view since it's
|
||||
possible that we either simply have not found unused TABLE
|
||||
@@ -1669,7 +1671,7 @@ bool open_table(THD *thd, TABLE_LIST *table_list, Open_table_context *ot_ctx)
|
||||
locked tables list was created.
|
||||
*/
|
||||
if (thd->locked_tables_mode == LTM_PRELOCKED)
|
||||
my_error(ER_NO_SUCH_TABLE, MYF(0), table_list->db, table_list->alias);
|
||||
my_error(ER_NO_SUCH_TABLE, MYF(0), table_list->db.str, table_list->alias.str);
|
||||
else
|
||||
my_error(ER_TABLE_NOT_LOCKED, MYF(0), alias);
|
||||
DBUG_RETURN(TRUE);
|
||||
@@ -1755,7 +1757,7 @@ bool open_table(THD *thd, TABLE_LIST *table_list, Open_table_context *ot_ctx)
|
||||
|
||||
if (table_list->open_strategy == TABLE_LIST::OPEN_IF_EXISTS)
|
||||
{
|
||||
if (!ha_table_exists(thd, table_list->db, table_list->table_name))
|
||||
if (!ha_table_exists(thd, &table_list->db, &table_list->table_name))
|
||||
DBUG_RETURN(FALSE);
|
||||
}
|
||||
else if (table_list->open_strategy == TABLE_LIST::OPEN_STUB)
|
||||
@@ -1818,7 +1820,8 @@ retry_share:
|
||||
}
|
||||
if (table_list->sequence)
|
||||
{
|
||||
my_error(ER_NOT_SEQUENCE, MYF(0), table_list->db, table_list->alias);
|
||||
my_error(ER_NOT_SEQUENCE, MYF(0), table_list->db.str,
|
||||
table_list->alias.str);
|
||||
goto err_lock;
|
||||
}
|
||||
/*
|
||||
@@ -1865,8 +1868,8 @@ retry_share:
|
||||
bool wait_result;
|
||||
|
||||
thd->push_internal_handler(&mdl_deadlock_handler);
|
||||
wait_result= tdc_wait_for_old_version(thd, table_list->db,
|
||||
table_list->table_name,
|
||||
wait_result= tdc_wait_for_old_version(thd, table_list->db.str,
|
||||
table_list->table_name.str,
|
||||
ot_ctx->get_timeout(),
|
||||
mdl_ticket->get_deadlock_weight());
|
||||
thd->pop_internal_handler();
|
||||
@@ -1914,7 +1917,7 @@ retry_share:
|
||||
if (!(table=(TABLE*) my_malloc(sizeof(*table),MYF(MY_WME))))
|
||||
goto err_lock;
|
||||
|
||||
error= open_table_from_share(thd, share, alias,
|
||||
error= open_table_from_share(thd, share, &table_list->alias,
|
||||
HA_OPEN_KEYFILE | HA_TRY_READ_ONLY,
|
||||
EXTRA_RECORD,
|
||||
thd->open_options, table, FALSE,
|
||||
@@ -1983,7 +1986,7 @@ retry_share:
|
||||
#endif
|
||||
if (table_list->sequence && table->s->table_type != TABLE_TYPE_SEQUENCE)
|
||||
{
|
||||
my_error(ER_NOT_SEQUENCE, MYF(0), table_list->db, table_list->alias);
|
||||
my_error(ER_NOT_SEQUENCE, MYF(0), table_list->db.str, table_list->alias.str);
|
||||
DBUG_RETURN(true);
|
||||
}
|
||||
|
||||
@@ -2111,28 +2114,30 @@ Locked_tables_list::init_locked_tables(THD *thd)
|
||||
table= table->next, m_locked_tables_count++)
|
||||
{
|
||||
TABLE_LIST *src_table_list= table->pos_in_table_list;
|
||||
char *db, *table_name, *alias;
|
||||
size_t db_len= table->s->db.length;
|
||||
size_t table_name_len= table->s->table_name.length;
|
||||
size_t alias_len= table->alias.length();
|
||||
LEX_CSTRING db, table_name, alias;
|
||||
|
||||
db.length= table->s->db.length;
|
||||
table_name.length= table->s->table_name.length;
|
||||
alias.length= table->alias.length();
|
||||
TABLE_LIST *dst_table_list;
|
||||
|
||||
if (! multi_alloc_root(&m_locked_tables_root,
|
||||
&dst_table_list, sizeof(*dst_table_list),
|
||||
&db, db_len + 1,
|
||||
&table_name, table_name_len + 1,
|
||||
&alias, alias_len + 1,
|
||||
&db.str, (size_t) db.length + 1,
|
||||
&table_name.str, (size_t) table_name.length + 1,
|
||||
&alias.str, (size_t) alias.length + 1,
|
||||
NullS))
|
||||
{
|
||||
reset();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
memcpy(db, table->s->db.str, db_len + 1);
|
||||
memcpy(table_name, table->s->table_name.str, table_name_len + 1);
|
||||
strmake(alias, table->alias.ptr(), alias_len);
|
||||
dst_table_list->init_one_table(db, db_len, table_name, table_name_len,
|
||||
alias, table->reginfo.lock_type);
|
||||
memcpy((char*) db.str, table->s->db.str, db.length + 1);
|
||||
memcpy((char*) table_name.str, table->s->table_name.str,
|
||||
table_name.length + 1);
|
||||
memcpy((char*) alias.str, table->alias.c_ptr(), alias.length + 1);
|
||||
dst_table_list->init_one_table(&db, &table_name,
|
||||
&alias, table->reginfo.lock_type);
|
||||
dst_table_list->table= table;
|
||||
dst_table_list->mdl_request.ticket= src_table_list->mdl_request.ticket;
|
||||
|
||||
@@ -2467,7 +2472,7 @@ bool Locked_tables_list::restore_lock(THD *thd, TABLE_LIST *dst_table_list,
|
||||
{
|
||||
MYSQL_LOCK *merged_lock;
|
||||
DBUG_ENTER("restore_lock");
|
||||
DBUG_ASSERT(!strcmp(dst_table_list->table_name, table->s->table_name.str));
|
||||
DBUG_ASSERT(!strcmp(dst_table_list->table_name.str, table->s->table_name.str));
|
||||
|
||||
/* Ensure we have the memory to add the table back */
|
||||
if (!(merged_lock= mysql_lock_merge(thd->lock, lock)))
|
||||
@@ -2696,8 +2701,8 @@ ret:
|
||||
|
||||
static bool open_table_entry_fini(THD *thd, TABLE_SHARE *share, TABLE *entry)
|
||||
{
|
||||
if (Table_triggers_list::check_n_load(thd, share->db.str,
|
||||
share->table_name.str, entry, 0))
|
||||
if (Table_triggers_list::check_n_load(thd, &share->db,
|
||||
&share->table_name, entry, 0))
|
||||
return TRUE;
|
||||
|
||||
/*
|
||||
@@ -2714,10 +2719,9 @@ static bool open_table_entry_fini(THD *thd, TABLE_SHARE *share, TABLE *entry)
|
||||
|
||||
query.length(0);
|
||||
query.append("DELETE FROM ");
|
||||
append_identifier(thd, &query, share->db.str, share->db.length);
|
||||
append_identifier(thd, &query, &share->db);
|
||||
query.append(".");
|
||||
append_identifier(thd, &query, share->table_name.str,
|
||||
share->table_name.length);
|
||||
append_identifier(thd, &query, &share->table_name);
|
||||
|
||||
/*
|
||||
we bypass thd->binlog_query() here,
|
||||
@@ -2753,7 +2757,7 @@ static bool auto_repair_table(THD *thd, TABLE_LIST *table_list)
|
||||
|
||||
DBUG_ASSERT(! share->is_view);
|
||||
|
||||
if (open_table_from_share(thd, share, table_list->alias,
|
||||
if (open_table_from_share(thd, share, &table_list->alias,
|
||||
HA_OPEN_KEYFILE | HA_TRY_READ_ONLY,
|
||||
EXTRA_RECORD,
|
||||
ha_open_options | HA_OPEN_FOR_REPAIR,
|
||||
@@ -2778,7 +2782,7 @@ static bool auto_repair_table(THD *thd, TABLE_LIST *table_list)
|
||||
tdc_release_share(share);
|
||||
/* Remove the repaired share from the table cache. */
|
||||
tdc_remove_table(thd, TDC_RT_REMOVE_ALL,
|
||||
table_list->db, table_list->table_name,
|
||||
table_list->db.str, table_list->table_name.str,
|
||||
FALSE);
|
||||
end_free:
|
||||
my_free(entry);
|
||||
@@ -2881,10 +2885,7 @@ request_backoff_action(enum_open_table_action action_arg,
|
||||
m_failed_table= (TABLE_LIST*) m_thd->alloc(sizeof(TABLE_LIST));
|
||||
if (m_failed_table == NULL)
|
||||
return TRUE;
|
||||
m_failed_table->init_one_table(table->db, table->db_length,
|
||||
table->table_name,
|
||||
table->table_name_length,
|
||||
table->alias, TL_WRITE);
|
||||
m_failed_table->init_one_table(&table->db, &table->table_name, &table->alias, TL_WRITE);
|
||||
m_failed_table->open_strategy= table->open_strategy;
|
||||
m_failed_table->mdl_request.set_type(MDL_EXCLUSIVE);
|
||||
}
|
||||
@@ -2953,8 +2954,8 @@ Open_table_context::recover_from_failed_open()
|
||||
get_timeout(), 0)))
|
||||
break;
|
||||
|
||||
tdc_remove_table(m_thd, TDC_RT_REMOVE_ALL, m_failed_table->db,
|
||||
m_failed_table->table_name, FALSE);
|
||||
tdc_remove_table(m_thd, TDC_RT_REMOVE_ALL, m_failed_table->db.str,
|
||||
m_failed_table->table_name.str, FALSE);
|
||||
|
||||
m_thd->get_stmt_da()->clear_warning_info(m_thd->query_id);
|
||||
m_thd->clear_error(); // Clear error message
|
||||
@@ -2989,8 +2990,8 @@ Open_table_context::recover_from_failed_open()
|
||||
get_timeout(), 0)))
|
||||
break;
|
||||
|
||||
tdc_remove_table(m_thd, TDC_RT_REMOVE_ALL, m_failed_table->db,
|
||||
m_failed_table->table_name, FALSE);
|
||||
tdc_remove_table(m_thd, TDC_RT_REMOVE_ALL, m_failed_table->db.str,
|
||||
m_failed_table->table_name.str, FALSE);
|
||||
|
||||
result= auto_repair_table(m_thd, m_failed_table);
|
||||
/*
|
||||
@@ -3310,10 +3311,8 @@ open_and_process_table(THD *thd, LEX *lex, TABLE_LIST *tables,
|
||||
obtain proper metadata locks and do other necessary steps like
|
||||
stored routine processing.
|
||||
*/
|
||||
tables->db= tables->view_db.str;
|
||||
tables->db_length= tables->view_db.length;
|
||||
tables->table_name= tables->view_name.str;
|
||||
tables->table_name_length= tables->view_name.length;
|
||||
tables->db= tables->view_db;
|
||||
tables->table_name= tables->view_name;
|
||||
}
|
||||
else if (tables->select_lex)
|
||||
{
|
||||
@@ -3370,7 +3369,7 @@ open_and_process_table(THD *thd, LEX *lex, TABLE_LIST *tables,
|
||||
goto end;
|
||||
}
|
||||
DBUG_PRINT("tcache", ("opening table: '%s'.'%s' item: %p",
|
||||
tables->db, tables->table_name, tables)); //psergey: invalid read of size 1 here
|
||||
tables->db.str, tables->table_name.str, tables));
|
||||
(*counter)++;
|
||||
|
||||
/*
|
||||
@@ -3386,7 +3385,7 @@ open_and_process_table(THD *thd, LEX *lex, TABLE_LIST *tables,
|
||||
DBUG_ASSERT(is_temporary_table(tables) || tables->table->s->sequence);
|
||||
if (tables->sequence && tables->table->s->table_type != TABLE_TYPE_SEQUENCE)
|
||||
{
|
||||
my_error(ER_NOT_SEQUENCE, MYF(0), tables->db, tables->alias);
|
||||
my_error(ER_NOT_SEQUENCE, MYF(0), tables->db.str, tables->alias.str);
|
||||
DBUG_RETURN(true);
|
||||
}
|
||||
}
|
||||
@@ -3489,7 +3488,7 @@ open_and_process_table(THD *thd, LEX *lex, TABLE_LIST *tables,
|
||||
if (! ot_ctx->can_recover_from_failed_open() && safe_to_ignore_table)
|
||||
{
|
||||
DBUG_PRINT("info", ("open_table: ignoring table '%s'.'%s'",
|
||||
tables->db, tables->alias));
|
||||
tables->db.str, tables->alias.str));
|
||||
error= FALSE;
|
||||
}
|
||||
goto end;
|
||||
@@ -3712,7 +3711,7 @@ lock_table_names(THD *thd, const DDL_options_st &options,
|
||||
MDL_request *schema_request= new (thd->mem_root) MDL_request;
|
||||
if (schema_request == NULL)
|
||||
DBUG_RETURN(TRUE);
|
||||
schema_request->init(MDL_key::SCHEMA, table->db, "",
|
||||
schema_request->init(MDL_key::SCHEMA, table->db.str, "",
|
||||
MDL_INTENTION_EXCLUSIVE,
|
||||
MDL_TRANSACTION);
|
||||
mdl_requests.push_front(schema_request);
|
||||
@@ -3763,17 +3762,17 @@ lock_table_names(THD *thd, const DDL_options_st &options,
|
||||
We come here in the case of lock timeout when executing CREATE TABLE.
|
||||
Verify that table does exist (it usually does, as we got a lock conflict)
|
||||
*/
|
||||
if (ha_table_exists(thd, tables_start->db, tables_start->table_name))
|
||||
if (ha_table_exists(thd, &tables_start->db, &tables_start->table_name))
|
||||
{
|
||||
if (options.if_not_exists())
|
||||
{
|
||||
push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE,
|
||||
ER_TABLE_EXISTS_ERROR,
|
||||
ER_THD(thd, ER_TABLE_EXISTS_ERROR),
|
||||
tables_start->table_name);
|
||||
tables_start->table_name.str);
|
||||
}
|
||||
else
|
||||
my_error(ER_TABLE_EXISTS_ERROR, MYF(0), tables_start->table_name);
|
||||
my_error(ER_TABLE_EXISTS_ERROR, MYF(0), tables_start->table_name.str);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
/*
|
||||
@@ -3847,7 +3846,7 @@ open_tables_check_upgradable_mdl(THD *thd, TABLE_LIST *tables_start,
|
||||
Note that find_table_for_mdl_upgrade() will report an error if
|
||||
no suitable ticket is found.
|
||||
*/
|
||||
if (!find_table_for_mdl_upgrade(thd, table->db, table->table_name, false))
|
||||
if (!find_table_for_mdl_upgrade(thd, table->db.str, table->table_name.str, false))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -4163,7 +4162,7 @@ restart:
|
||||
(*start)->table &&
|
||||
(*start)->table->file->ht == myisam_hton &&
|
||||
wsrep_thd_exec_mode(thd) == LOCAL_STATE &&
|
||||
!is_stat_table((*start)->db, (*start)->alias) &&
|
||||
!is_stat_table(&(*start)->db, &(*start)->alias) &&
|
||||
thd->get_command() != COM_STMT_PREPARE &&
|
||||
((thd->lex->sql_command == SQLCOM_INSERT ||
|
||||
thd->lex->sql_command == SQLCOM_INSERT_SELECT ||
|
||||
@@ -4252,8 +4251,8 @@ static bool table_already_fk_prelocked(TABLE_LIST *tl, LEX_CSTRING *db,
|
||||
{
|
||||
if (tl->lock_type >= lock_type &&
|
||||
tl->prelocking_placeholder == TABLE_LIST::PRELOCK_FK &&
|
||||
strcmp(tl->db, db->str) == 0 &&
|
||||
strcmp(tl->table_name, table->str) == 0)
|
||||
strcmp(tl->db.str, db->str) == 0 &&
|
||||
strcmp(tl->table_name.str, table->str) == 0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -4265,7 +4264,7 @@ static bool internal_table_exists(TABLE_LIST *global_list,
|
||||
{
|
||||
do
|
||||
{
|
||||
if (global_list->table_name == table_name)
|
||||
if (global_list->table_name.str == table_name)
|
||||
return 1;
|
||||
} while ((global_list= global_list->next_global));
|
||||
return 0;
|
||||
@@ -4284,16 +4283,14 @@ add_internal_tables(THD *thd, Query_tables_list *prelocking_ctx,
|
||||
Skip table if already in the list. Can happen with prepared statements
|
||||
*/
|
||||
if (tables->next_local &&
|
||||
internal_table_exists(global_table_list, tables->table_name))
|
||||
internal_table_exists(global_table_list, tables->table_name.str))
|
||||
continue;
|
||||
|
||||
TABLE_LIST *tl= (TABLE_LIST *) thd->alloc(sizeof(TABLE_LIST));
|
||||
if (!tl)
|
||||
return TRUE;
|
||||
tl->init_one_table_for_prelocking(tables->db,
|
||||
strlen(tables->db),
|
||||
tables->table_name,
|
||||
strlen(tables->table_name),
|
||||
tl->init_one_table_for_prelocking(&tables->db,
|
||||
&tables->table_name,
|
||||
NULL, tables->lock_type,
|
||||
TABLE_LIST::PRELOCK_NONE,
|
||||
0, 0,
|
||||
@@ -4389,10 +4386,8 @@ handle_table(THD *thd, Query_tables_list *prelocking_ctx,
|
||||
continue;
|
||||
|
||||
TABLE_LIST *tl= (TABLE_LIST *) thd->alloc(sizeof(TABLE_LIST));
|
||||
tl->init_one_table_for_prelocking(fk->foreign_db->str,
|
||||
fk->foreign_db->length,
|
||||
fk->foreign_table->str,
|
||||
fk->foreign_table->length,
|
||||
tl->init_one_table_for_prelocking(fk->foreign_db,
|
||||
fk->foreign_table,
|
||||
NULL, lock_type,
|
||||
TABLE_LIST::PRELOCK_FK,
|
||||
table_list->belong_to_view, op,
|
||||
@@ -5436,7 +5431,7 @@ find_field_in_view(THD *thd, TABLE_LIST *table_list,
|
||||
DBUG_ENTER("find_field_in_view");
|
||||
DBUG_PRINT("enter",
|
||||
("view: '%s', field name: '%s', item name: '%s', ref %p",
|
||||
table_list->alias, name, item_name, ref));
|
||||
table_list->alias.str, name, item_name, ref));
|
||||
Field_iterator_view field_it;
|
||||
field_it.set(table_list);
|
||||
Query_arena *arena= 0, backup;
|
||||
@@ -5704,6 +5699,7 @@ find_field_in_table(THD *thd, TABLE *table, const char *name, uint length,
|
||||
item_name [in] name of item if it will be created (VIEW)
|
||||
db_name [in] optional database name that qualifies the
|
||||
table_name [in] optional table name that qualifies the field
|
||||
0 for non-qualified field in natural joins
|
||||
ref [in/out] if 'name' is resolved to a view field, ref
|
||||
is set to point to the found view field
|
||||
check_privileges [in] check privileges
|
||||
@@ -5747,12 +5743,12 @@ find_field_in_table_ref(THD *thd, TABLE_LIST *table_list,
|
||||
{
|
||||
Field *fld;
|
||||
DBUG_ENTER("find_field_in_table_ref");
|
||||
DBUG_ASSERT(table_list->alias);
|
||||
DBUG_ASSERT(table_list->alias.str);
|
||||
DBUG_ASSERT(name);
|
||||
DBUG_ASSERT(item_name);
|
||||
DBUG_PRINT("enter",
|
||||
("table: '%s' field name: '%s' item name: '%s' ref %p",
|
||||
table_list->alias, name, item_name, ref));
|
||||
table_list->alias.str, name, item_name, ref));
|
||||
|
||||
/*
|
||||
Check that the table and database that qualify the current field name
|
||||
@@ -5768,9 +5764,13 @@ find_field_in_table_ref(THD *thd, TABLE_LIST *table_list,
|
||||
inside the view, but we want to search directly in the view columns
|
||||
which are represented as a 'field_translation'.
|
||||
|
||||
TODO: Ensure that table_name, db_name and tables->db always points to
|
||||
something !
|
||||
tables->db.str may be 0 if we are preparing a statement
|
||||
db_name is 0 if item doesn't have a db name
|
||||
table_name is 0 if item doesn't have a specified table_name
|
||||
*/
|
||||
if (db_name && !db_name[0])
|
||||
db_name= 0; // Simpler test later
|
||||
|
||||
if (/* Exclude nested joins. */
|
||||
(!table_list->nested_join ||
|
||||
/* Include merge views and information schema tables. */
|
||||
@@ -5780,12 +5780,12 @@ find_field_in_table_ref(THD *thd, TABLE_LIST *table_list,
|
||||
to search.
|
||||
*/
|
||||
table_name && table_name[0] &&
|
||||
(my_strcasecmp(table_alias_charset, table_list->alias, table_name) ||
|
||||
(db_name && db_name[0] && (!table_list->db || !table_list->db[0])) ||
|
||||
(db_name && db_name[0] && table_list->db && table_list->db[0] &&
|
||||
(my_strcasecmp(table_alias_charset, table_list->alias.str, table_name) ||
|
||||
(db_name && (!table_list->db.str || !table_list->db.str[0])) ||
|
||||
(db_name && table_list->db.str && table_list->db.str[0] &&
|
||||
(table_list->schema_table ?
|
||||
my_strcasecmp(system_charset_info, db_name, table_list->db) :
|
||||
strcmp(db_name, table_list->db)))))
|
||||
my_strcasecmp(system_charset_info, db_name, table_list->db.str) :
|
||||
strcmp(db_name, table_list->db.str)))))
|
||||
DBUG_RETURN(0);
|
||||
|
||||
/*
|
||||
@@ -6549,7 +6549,7 @@ mark_common_columns(THD *thd, TABLE_LIST *table_ref_1, TABLE_LIST *table_ref_2,
|
||||
|
||||
DBUG_ENTER("mark_common_columns");
|
||||
DBUG_PRINT("info", ("operand_1: %s operand_2: %s",
|
||||
table_ref_1->alias, table_ref_2->alias));
|
||||
table_ref_1->alias.str, table_ref_2->alias.str));
|
||||
|
||||
*found_using_fields= 0;
|
||||
arena= thd->activate_stmt_arena_if_needed(&backup);
|
||||
@@ -6570,7 +6570,7 @@ mark_common_columns(THD *thd, TABLE_LIST *table_ref_1, TABLE_LIST *table_ref_2,
|
||||
is_using_column_1= using_fields &&
|
||||
test_if_string_in_list(field_name_1->str, using_fields);
|
||||
DBUG_PRINT ("info", ("field_name_1=%s.%s",
|
||||
nj_col_1->table_name() ? nj_col_1->table_name() : "",
|
||||
nj_col_1->safe_table_name(),
|
||||
field_name_1->str));
|
||||
|
||||
/*
|
||||
@@ -6589,8 +6589,7 @@ mark_common_columns(THD *thd, TABLE_LIST *table_ref_1, TABLE_LIST *table_ref_2,
|
||||
goto err;
|
||||
cur_field_name_2= cur_nj_col_2->name();
|
||||
DBUG_PRINT ("info", ("cur_field_name_2=%s.%s",
|
||||
cur_nj_col_2->table_name() ?
|
||||
cur_nj_col_2->table_name() : "",
|
||||
cur_nj_col_2->safe_table_name(),
|
||||
cur_field_name_2->str));
|
||||
|
||||
/*
|
||||
@@ -6700,11 +6699,9 @@ mark_common_columns(THD *thd, TABLE_LIST *table_ref_1, TABLE_LIST *table_ref_2,
|
||||
|
||||
nj_col_1->is_common= nj_col_2->is_common= TRUE;
|
||||
DBUG_PRINT ("info", ("%s.%s and %s.%s are common",
|
||||
nj_col_1->table_name() ?
|
||||
nj_col_1->table_name() : "",
|
||||
nj_col_1->safe_table_name(),
|
||||
nj_col_1->name()->str,
|
||||
nj_col_2->table_name() ?
|
||||
nj_col_2->table_name() : "",
|
||||
nj_col_2->safe_table_name(),
|
||||
nj_col_2->name()->str));
|
||||
|
||||
if (field_1)
|
||||
@@ -7624,7 +7621,7 @@ bool get_key_map_from_key_list(key_map *map, TABLE *table,
|
||||
0)
|
||||
{
|
||||
my_error(ER_KEY_DOES_NOT_EXITS, MYF(0), name->c_ptr(),
|
||||
table->pos_in_table_list->alias);
|
||||
table->pos_in_table_list->alias.str);
|
||||
map->set_all();
|
||||
return 1;
|
||||
}
|
||||
@@ -7695,8 +7692,8 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name,
|
||||
DBUG_ASSERT(tables->is_leaf_for_name_resolution());
|
||||
|
||||
if ((table_name && my_strcasecmp(table_alias_charset, table_name,
|
||||
tables->alias)) ||
|
||||
(db_name && strcmp(tables->db,db_name)))
|
||||
tables->alias.str)) ||
|
||||
(db_name && strcmp(tables->db.str, db_name)))
|
||||
continue;
|
||||
|
||||
#ifndef NO_EMBEDDED_ACCESS_CHECKS
|
||||
@@ -7875,13 +7872,13 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name,
|
||||
*/
|
||||
if (!table_name)
|
||||
my_error(ER_NO_TABLES_USED, MYF(0));
|
||||
else if (!db_name && !thd->db)
|
||||
else if (!db_name && !thd->db.str)
|
||||
my_error(ER_NO_DB_ERROR, MYF(0));
|
||||
else
|
||||
{
|
||||
char name[FN_REFLEN];
|
||||
my_snprintf(name, sizeof(name), "%s.%s",
|
||||
db_name ? db_name : thd->db, table_name);
|
||||
db_name ? db_name : thd->get_db(), table_name);
|
||||
my_error(ER_BAD_TABLE_ERROR, MYF(0), name);
|
||||
}
|
||||
|
||||
|
||||
@@ -136,8 +136,8 @@ void close_tables_for_reopen(THD *thd, TABLE_LIST **tables,
|
||||
const MDL_savepoint &start_of_statement_svp);
|
||||
TABLE_LIST *find_table_in_list(TABLE_LIST *table,
|
||||
TABLE_LIST *TABLE_LIST::*link,
|
||||
const char *db_name,
|
||||
const char *table_name);
|
||||
const LEX_CSTRING *db_name,
|
||||
const LEX_CSTRING *table_name);
|
||||
void close_thread_tables(THD *thd);
|
||||
void switch_to_nullable_trigger_fields(List<Item> &items, TABLE *);
|
||||
void switch_defaults_to_nullable_trigger_fields(TABLE *table);
|
||||
@@ -205,8 +205,8 @@ bool setup_tables_and_check_access(THD *thd,
|
||||
bool wait_while_table_is_used(THD *thd, TABLE *table,
|
||||
enum ha_extra_function function);
|
||||
|
||||
void drop_open_table(THD *thd, TABLE *table, const char *db_name,
|
||||
const char *table_name);
|
||||
void drop_open_table(THD *thd, TABLE *table, const LEX_CSTRING *db_name,
|
||||
const LEX_CSTRING *table_name);
|
||||
void update_non_unique_table_error(TABLE_LIST *update,
|
||||
const char *operation,
|
||||
TABLE_LIST *duplicate);
|
||||
@@ -344,22 +344,13 @@ inline void setup_table_map(TABLE *table, TABLE_LIST *table_list, uint tablenr)
|
||||
}
|
||||
|
||||
inline TABLE_LIST *find_table_in_global_list(TABLE_LIST *table,
|
||||
const char *db_name,
|
||||
const char *table_name)
|
||||
LEX_CSTRING *db_name,
|
||||
LEX_CSTRING *table_name)
|
||||
{
|
||||
return find_table_in_list(table, &TABLE_LIST::next_global,
|
||||
db_name, table_name);
|
||||
}
|
||||
|
||||
inline TABLE_LIST *find_table_in_local_list(TABLE_LIST *table,
|
||||
const char *db_name,
|
||||
const char *table_name)
|
||||
{
|
||||
return find_table_in_list(table, &TABLE_LIST::next_local,
|
||||
db_name, table_name);
|
||||
}
|
||||
|
||||
|
||||
inline bool setup_fields_with_no_wrap(THD *thd, Ref_ptr_array ref_pointer_array,
|
||||
List<Item> &item,
|
||||
enum_mark_columns mark_used_columns,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1475,6 +1475,75 @@ void THD::change_user(void)
|
||||
sp_cache_clear(&sp_func_cache);
|
||||
}
|
||||
|
||||
/**
|
||||
Change default database
|
||||
|
||||
@note This is coded to have as few instructions as possible under
|
||||
LOCK_thd_data
|
||||
*/
|
||||
|
||||
bool THD::set_db(const LEX_CSTRING *new_db)
|
||||
{
|
||||
bool result= 0;
|
||||
/*
|
||||
Acquiring mutex LOCK_thd_data as we either free the memory allocated
|
||||
for the database and reallocating the memory for the new db or memcpy
|
||||
the new_db to the db.
|
||||
*/
|
||||
/* Do not reallocate memory if current chunk is big enough. */
|
||||
if (db.str && new_db->str && db.length >= new_db->length)
|
||||
{
|
||||
mysql_mutex_lock(&LOCK_thd_data);
|
||||
db.length= new_db->length;
|
||||
memcpy((char*) db.str, new_db->str, new_db->length+1);
|
||||
mysql_mutex_unlock(&LOCK_thd_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *org_db= db.str;
|
||||
const char *tmp= NULL;
|
||||
if (new_db->str)
|
||||
{
|
||||
if (!(tmp= my_strndup(new_db->str, new_db->length, MYF(MY_WME | ME_FATALERROR))))
|
||||
result= 1;
|
||||
}
|
||||
|
||||
mysql_mutex_lock(&LOCK_thd_data);
|
||||
db.str= tmp;
|
||||
db.length= tmp ? new_db->length : 0;
|
||||
mysql_mutex_unlock(&LOCK_thd_data);
|
||||
my_free((char*) org_db);
|
||||
}
|
||||
PSI_CALL_set_thread_db(db.str, (int) db.length);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Set the current database
|
||||
|
||||
@param new_db a pointer to the new database name.
|
||||
@param new_db_len length of the new database name.
|
||||
|
||||
@note This operation just sets {db, db_length}. Switching the current
|
||||
database usually involves other actions, like switching other database
|
||||
attributes including security context. In the future, this operation
|
||||
will be made private and more convenient interface will be provided.
|
||||
*/
|
||||
|
||||
void THD::reset_db(const LEX_CSTRING *new_db)
|
||||
{
|
||||
if (new_db->str != db.str || new_db->length != db.length)
|
||||
{
|
||||
if (db.str != 0)
|
||||
DBUG_PRINT("QQ", ("Overwriting: %p", db.str));
|
||||
mysql_mutex_lock(&LOCK_thd_data);
|
||||
db= *new_db;
|
||||
mysql_mutex_unlock(&LOCK_thd_data);
|
||||
PSI_CALL_set_thread_db(db.str, (int) db.length);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Do operations that may take a long time */
|
||||
|
||||
@@ -1553,8 +1622,8 @@ void THD::cleanup(void)
|
||||
void THD::free_connection()
|
||||
{
|
||||
DBUG_ASSERT(free_connection_done == 0);
|
||||
my_free(db);
|
||||
db= NULL;
|
||||
my_free((char*) db.str);
|
||||
db= null_clex_str;
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
if (net.vio)
|
||||
vio_delete(net.vio);
|
||||
@@ -3043,8 +3112,7 @@ static File create_file(THD *thd, char *path, sql_exchange *exchange,
|
||||
|
||||
if (!dirname_length(exchange->file_name))
|
||||
{
|
||||
strxnmov(path, FN_REFLEN-1, mysql_real_data_home, thd->db ? thd->db : "",
|
||||
NullS);
|
||||
strxnmov(path, FN_REFLEN-1, mysql_real_data_home, thd->get_db(), NullS);
|
||||
(void) fn_format(path, exchange->file_name, path, "", option);
|
||||
}
|
||||
else
|
||||
@@ -3737,10 +3805,9 @@ Statement::Statement(LEX *lex_arg, MEM_ROOT *mem_root_arg,
|
||||
id(id_arg),
|
||||
mark_used_columns(MARK_COLUMNS_READ),
|
||||
lex(lex_arg),
|
||||
db(NULL),
|
||||
db_length(0)
|
||||
db(null_clex_str)
|
||||
{
|
||||
name.str= NULL;
|
||||
name= null_clex_str;
|
||||
}
|
||||
|
||||
|
||||
@@ -4077,7 +4144,7 @@ bool
|
||||
select_materialize_with_stats::
|
||||
create_result_table(THD *thd_arg, List<Item> *column_types,
|
||||
bool is_union_distinct, ulonglong options,
|
||||
const char *table_alias, bool bit_fields_as_long,
|
||||
const LEX_CSTRING *table_alias, bool bit_fields_as_long,
|
||||
bool create_table,
|
||||
bool keep_row_order,
|
||||
uint hidden)
|
||||
@@ -4088,7 +4155,7 @@ create_result_table(THD *thd_arg, List<Item> *column_types,
|
||||
|
||||
if (! (table= create_tmp_table(thd_arg, &tmp_table_param, *column_types,
|
||||
(ORDER*) 0, is_union_distinct, 1,
|
||||
options, HA_POS_ERROR, (char*) table_alias,
|
||||
options, HA_POS_ERROR, table_alias,
|
||||
!create_table, keep_row_order)))
|
||||
return TRUE;
|
||||
|
||||
@@ -4663,8 +4730,10 @@ TABLE *open_purge_table(THD *thd, const char *db, size_t dblen,
|
||||
|
||||
Open_table_context ot_ctx(thd, 0);
|
||||
TABLE_LIST *tl= (TABLE_LIST*)thd->alloc(sizeof(TABLE_LIST));
|
||||
LEX_CSTRING db_name= {db, dblen };
|
||||
LEX_CSTRING table_name= { tb, tblen };
|
||||
|
||||
tl->init_one_table(db, dblen, tb, tblen, tb, TL_READ);
|
||||
tl->init_one_table(&db_name, &table_name, 0, TL_READ);
|
||||
tl->i_s_requested_object= OPEN_TABLE_ONLY;
|
||||
|
||||
bool error= open_table(thd, tl, &ot_ctx);
|
||||
@@ -5057,7 +5126,7 @@ extern "C" void thd_mark_transaction_to_rollback(MYSQL_THD thd, bool all)
|
||||
|
||||
extern "C" bool thd_binlog_filter_ok(const MYSQL_THD thd)
|
||||
{
|
||||
return binlog_filter->db_ok(thd->db);
|
||||
return binlog_filter->db_ok(thd->db.str);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -5959,7 +6028,7 @@ int THD::decide_logging_format(TABLE_LIST *tables)
|
||||
*/
|
||||
if (mysql_bin_log.is_open() && (variables.option_bits & OPTION_BIN_LOG) &&
|
||||
!(wsrep_binlog_format() == BINLOG_FORMAT_STMT &&
|
||||
!binlog_filter->db_ok(db)))
|
||||
!binlog_filter->db_ok(db.str)))
|
||||
{
|
||||
|
||||
if (is_bulk_op())
|
||||
@@ -6062,7 +6131,7 @@ int THD::decide_logging_format(TABLE_LIST *tables)
|
||||
handler::Table_flags const flags= table->table->file->ha_table_flags();
|
||||
|
||||
DBUG_PRINT("info", ("table: %s; ha_table_flags: 0x%llx",
|
||||
table->table_name, flags));
|
||||
table->table_name.str, flags));
|
||||
|
||||
if (table->table->s->no_replicate)
|
||||
{
|
||||
@@ -6366,7 +6435,7 @@ int THD::decide_logging_format(TABLE_LIST *tables)
|
||||
if (table->table->file->ht->db_type == DB_TYPE_BLACKHOLE_DB &&
|
||||
table->lock_type >= TL_WRITE_ALLOW_WRITE)
|
||||
{
|
||||
table_names.append(table->table_name);
|
||||
table_names.append(&table->table_name);
|
||||
table_names.append(",");
|
||||
}
|
||||
}
|
||||
@@ -6398,7 +6467,7 @@ int THD::decide_logging_format(TABLE_LIST *tables)
|
||||
mysql_bin_log.is_open(),
|
||||
(variables.option_bits & OPTION_BIN_LOG),
|
||||
(uint) wsrep_binlog_format(),
|
||||
binlog_filter->db_ok(db)));
|
||||
binlog_filter->db_ok(db.str)));
|
||||
#endif
|
||||
|
||||
DBUG_RETURN(0);
|
||||
|
||||
114
sql/sql_class.h
114
sql/sql_class.h
@@ -1142,18 +1142,13 @@ public:
|
||||
/**
|
||||
Name of the current (default) database.
|
||||
|
||||
If there is the current (default) database, "db" contains its name. If
|
||||
there is no current (default) database, "db" is NULL and "db_length" is
|
||||
0. In other words, "db", "db_length" must either be NULL, or contain a
|
||||
If there is the current (default) database, "db.str" contains its name. If
|
||||
there is no current (default) database, "db.str" is NULL and "db.length" is
|
||||
0. In other words, db must either be NULL, or contain a
|
||||
valid database name.
|
||||
|
||||
@note this attribute is set and alloced by the slave SQL thread (for
|
||||
the THD of that thread); that thread is (and must remain, for now) the
|
||||
only responsible for freeing this member.
|
||||
*/
|
||||
|
||||
char *db;
|
||||
size_t db_length;
|
||||
LEX_CSTRING db;
|
||||
|
||||
/* This is set to 1 of last call to send_result_to_client() was ok */
|
||||
my_bool query_cache_is_applicable;
|
||||
@@ -2242,7 +2237,7 @@ public:
|
||||
Protects THD data accessed from other threads:
|
||||
- thd->query and thd->query_length (used by SHOW ENGINE
|
||||
INNODB STATUS and SHOW PROCESSLIST
|
||||
- thd->db and thd->db_length (used in SHOW PROCESSLIST)
|
||||
- thd->db (used in SHOW PROCESSLIST)
|
||||
Is locked when THD is deleted.
|
||||
*/
|
||||
mysql_mutex_t LOCK_thd_data;
|
||||
@@ -4034,70 +4029,33 @@ public:
|
||||
@retval FALSE Success
|
||||
@retval TRUE Out-of-memory error
|
||||
*/
|
||||
bool set_db(const char *new_db, size_t new_db_len)
|
||||
{
|
||||
/*
|
||||
Acquiring mutex LOCK_thd_data as we either free the memory allocated
|
||||
for the database and reallocating the memory for the new db or memcpy
|
||||
the new_db to the db.
|
||||
*/
|
||||
mysql_mutex_lock(&LOCK_thd_data);
|
||||
/* Do not reallocate memory if current chunk is big enough. */
|
||||
if (db && new_db && db_length >= new_db_len)
|
||||
memcpy(db, new_db, new_db_len+1);
|
||||
else
|
||||
{
|
||||
my_free(db);
|
||||
if (new_db)
|
||||
db= my_strndup(new_db, new_db_len, MYF(MY_WME | ME_FATALERROR));
|
||||
else
|
||||
db= NULL;
|
||||
}
|
||||
db_length= db ? new_db_len : 0;
|
||||
bool result= new_db && !db;
|
||||
mysql_mutex_unlock(&LOCK_thd_data);
|
||||
if (result)
|
||||
PSI_CALL_set_thread_db(new_db, (int) new_db_len);
|
||||
return result;
|
||||
}
|
||||
bool set_db(const LEX_CSTRING *new_db);
|
||||
|
||||
/**
|
||||
Set the current database; use shallow copy of C-string.
|
||||
/** Set the current database, without copying */
|
||||
void reset_db(const LEX_CSTRING *new_db);
|
||||
|
||||
@param new_db a pointer to the new database name.
|
||||
@param new_db_len length of the new database name.
|
||||
|
||||
@note This operation just sets {db, db_length}. Switching the current
|
||||
database usually involves other actions, like switching other database
|
||||
attributes including security context. In the future, this operation
|
||||
will be made private and more convenient interface will be provided.
|
||||
*/
|
||||
void reset_db(char *new_db, size_t new_db_len)
|
||||
{
|
||||
if (new_db != db || new_db_len != db_length)
|
||||
{
|
||||
mysql_mutex_lock(&LOCK_thd_data);
|
||||
db= new_db;
|
||||
db_length= new_db_len;
|
||||
mysql_mutex_unlock(&LOCK_thd_data);
|
||||
PSI_CALL_set_thread_db(new_db, (int) new_db_len);
|
||||
}
|
||||
}
|
||||
/*
|
||||
Copy the current database to the argument. Use the current arena to
|
||||
allocate memory for a deep copy: current database may be freed after
|
||||
a statement is parsed but before it's executed.
|
||||
|
||||
Can only be called by owner of thd (no mutex protection)
|
||||
*/
|
||||
bool copy_db_to(const char **p_db, size_t *p_db_length)
|
||||
bool copy_db_to(LEX_CSTRING *to)
|
||||
{
|
||||
if (db == NULL)
|
||||
if (db.str == NULL)
|
||||
{
|
||||
my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0));
|
||||
return TRUE;
|
||||
}
|
||||
*p_db= strmake(db, db_length);
|
||||
*p_db_length= db_length;
|
||||
return FALSE;
|
||||
to->str= strmake(db.str, db.length);
|
||||
to->length= db.length;
|
||||
return to->str == NULL; /* True on error */
|
||||
}
|
||||
/* Get db name or "". Use for printing current db */
|
||||
const char *get_db()
|
||||
{
|
||||
return db.str ? db.str : "";
|
||||
}
|
||||
thd_scheduler event_scheduler;
|
||||
|
||||
@@ -4357,7 +4315,7 @@ public:
|
||||
{
|
||||
Security_context *sctx= &main_security_ctx;
|
||||
sql_print_warning(ER_THD(this, ER_NEW_ABORTING_CONNECTION),
|
||||
thread_id, (db ? db : "unconnected"),
|
||||
thread_id, (db.str ? db.str : "unconnected"),
|
||||
sctx->user ? sctx->user : "unauthenticated",
|
||||
sctx->host_or_ip, reason);
|
||||
}
|
||||
@@ -4500,8 +4458,8 @@ public:
|
||||
bool open_temporary_tables(TABLE_LIST *tl);
|
||||
|
||||
bool close_temporary_tables();
|
||||
bool rename_temporary_table(TABLE *table, const char *db,
|
||||
const char *table_name);
|
||||
bool rename_temporary_table(TABLE *table, const LEX_CSTRING *db,
|
||||
const LEX_CSTRING *table_name);
|
||||
bool drop_temporary_table(TABLE *table, bool *is_trans, bool delete_table);
|
||||
bool rm_temporary_table(handlerton *hton, const char *path);
|
||||
void mark_tmp_tables_as_free_for_reuse();
|
||||
@@ -5337,7 +5295,7 @@ public:
|
||||
void cleanup();
|
||||
virtual bool create_result_table(THD *thd, List<Item> *column_types,
|
||||
bool is_distinct, ulonglong options,
|
||||
const char *alias,
|
||||
const LEX_CSTRING *alias,
|
||||
bool bit_fields_as_long,
|
||||
bool create_table,
|
||||
bool keep_row_order,
|
||||
@@ -5371,7 +5329,7 @@ class select_union_recursive :public select_unit
|
||||
int send_data(List<Item> &items);
|
||||
bool create_result_table(THD *thd, List<Item> *column_types,
|
||||
bool is_distinct, ulonglong options,
|
||||
const char *alias,
|
||||
const LEX_CSTRING *alias,
|
||||
bool bit_fields_as_long,
|
||||
bool create_table,
|
||||
bool keep_row_order,
|
||||
@@ -5538,7 +5496,7 @@ public:
|
||||
{ tmp_table_param.init(); }
|
||||
bool create_result_table(THD *thd, List<Item> *column_types,
|
||||
bool is_distinct, ulonglong options,
|
||||
const char *alias,
|
||||
const LEX_CSTRING *alias,
|
||||
bool bit_fields_as_long,
|
||||
bool create_table,
|
||||
bool keep_row_order,
|
||||
@@ -6339,26 +6297,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/* Functions to compare if two lex strings are equal */
|
||||
inline bool lex_string_cmp(CHARSET_INFO *charset,
|
||||
const LEX_CSTRING *a,
|
||||
const LEX_CSTRING *b)
|
||||
{
|
||||
return my_strcasecmp(charset, a->str, b->str);
|
||||
}
|
||||
|
||||
/*
|
||||
Compare if two LEX_CSTRING are equal. Assumption is that
|
||||
character set is ASCII (like for plugin names)
|
||||
*/
|
||||
inline bool lex_string_eq(const LEX_CSTRING *a,
|
||||
const LEX_CSTRING *b)
|
||||
{
|
||||
if (a->length != b->length)
|
||||
return 1; /* Different */
|
||||
return strcasecmp(a->str, b->str) != 0;
|
||||
}
|
||||
|
||||
class Type_holder: public Sql_alloc,
|
||||
public Item_args,
|
||||
public Type_handler_hybrid_field_type,
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
*/
|
||||
|
||||
#include "mariadb.h"
|
||||
#include "mysqld.h"
|
||||
#include "sql_priv.h"
|
||||
#ifndef __WIN__
|
||||
#include <netdb.h> // getservbyname, servent
|
||||
@@ -1264,7 +1265,7 @@ void prepare_new_connection_state(THD* thd)
|
||||
if (packet_length != packet_error)
|
||||
my_error(ER_NEW_ABORTING_CONNECTION, MYF(0),
|
||||
thd->thread_id,
|
||||
thd->db ? thd->db : "unconnected",
|
||||
thd->db.str ? thd->db.str : "unconnected",
|
||||
sctx->user ? sctx->user : "unauthenticated",
|
||||
sctx->host_or_ip, "init_connect command failed");
|
||||
thd->server_status&= ~SERVER_STATUS_CLEAR_SET;
|
||||
|
||||
@@ -240,7 +240,7 @@ With_element *With_clause::find_table_def(TABLE_LIST *table,
|
||||
with_elem= with_elem->next)
|
||||
{
|
||||
if (my_strcasecmp(system_charset_info, with_elem->query_name->str,
|
||||
table->table_name) == 0)
|
||||
table->table_name.str) == 0)
|
||||
{
|
||||
table->set_derived();
|
||||
return with_elem;
|
||||
|
||||
@@ -132,7 +132,7 @@ int mysql_open_cursor(THD *thd, select_result *result,
|
||||
|
||||
MYSQL_QUERY_EXEC_START(thd->query(),
|
||||
thd->thread_id,
|
||||
(char *) (thd->db ? thd->db : ""),
|
||||
thd->get_db(),
|
||||
&thd->security_ctx->priv_user[0],
|
||||
(char *) thd->security_ctx->host_or_ip,
|
||||
2);
|
||||
@@ -440,7 +440,7 @@ bool Select_materialize::send_result_set_metadata(List<Item> &list, uint flags)
|
||||
if (create_result_table(unit->thd, unit->get_column_types(true),
|
||||
FALSE,
|
||||
thd->variables.option_bits | TMP_TABLE_ALL_COLUMNS,
|
||||
"", FALSE, TRUE, TRUE, 0))
|
||||
&empty_clex_str, FALSE, TRUE, TRUE, 0))
|
||||
return TRUE;
|
||||
|
||||
materialized_cursor= new (&table->mem_root)
|
||||
|
||||
137
sql/sql_db.cc
137
sql/sql_db.cc
@@ -62,7 +62,7 @@ static void mysql_change_db_impl(THD *thd,
|
||||
LEX_CSTRING *new_db_name,
|
||||
ulong new_db_access,
|
||||
CHARSET_INFO *new_db_charset);
|
||||
static bool mysql_rm_db_internal(THD *thd, const char *db,
|
||||
static bool mysql_rm_db_internal(THD *thd, const LEX_CSTRING *db,
|
||||
bool if_exists, bool silent);
|
||||
|
||||
|
||||
@@ -94,12 +94,12 @@ typedef struct my_dbopt_st
|
||||
*/
|
||||
|
||||
static inline bool
|
||||
cmp_db_names(const char *db1_name,
|
||||
const char *db2_name)
|
||||
cmp_db_names(LEX_CSTRING *db1_name, const LEX_CSTRING *db2_name)
|
||||
{
|
||||
return ((!db1_name && !db2_name) ||
|
||||
(db1_name && db2_name &&
|
||||
my_strcasecmp(table_alias_charset, db1_name, db2_name) == 0));
|
||||
return (db1_name->length == db2_name->length &&
|
||||
(db1_name->length == 0 ||
|
||||
my_strcasecmp(table_alias_charset,
|
||||
db1_name->str, db2_name->str) == 0));
|
||||
}
|
||||
|
||||
|
||||
@@ -523,7 +523,7 @@ CHARSET_INFO *get_default_db_collation(THD *thd, const char *db_name)
|
||||
{
|
||||
Schema_specification_st db_info;
|
||||
|
||||
if (thd->db != NULL && strcmp(db_name, thd->db) == 0)
|
||||
if (thd->db.str != NULL && strcmp(db_name, thd->db.str) == 0)
|
||||
return thd->db_charset;
|
||||
|
||||
load_db_opt_by_name(thd, db_name, &db_info);
|
||||
@@ -566,7 +566,7 @@ CHARSET_INFO *get_default_db_collation(THD *thd, const char *db_name)
|
||||
*/
|
||||
|
||||
static int
|
||||
mysql_create_db_internal(THD *thd, const char *db,
|
||||
mysql_create_db_internal(THD *thd, const LEX_CSTRING *db,
|
||||
const DDL_options_st &options,
|
||||
Schema_specification_st *create_info,
|
||||
bool silent)
|
||||
@@ -579,18 +579,18 @@ mysql_create_db_internal(THD *thd, const char *db,
|
||||
/* do not create 'information_schema' db */
|
||||
if (is_infoschema_db(db))
|
||||
{
|
||||
my_error(ER_DB_CREATE_EXISTS, MYF(0), db);
|
||||
my_error(ER_DB_CREATE_EXISTS, MYF(0), db->str);
|
||||
DBUG_RETURN(-1);
|
||||
}
|
||||
|
||||
char db_tmp[SAFE_NAME_LEN];
|
||||
const char *dbnorm= normalize_db_name(db, db_tmp, sizeof(db_tmp));
|
||||
char db_tmp[SAFE_NAME_LEN+1];
|
||||
const char *dbnorm= normalize_db_name(db->str, db_tmp, sizeof(db_tmp));
|
||||
|
||||
if (lock_schema_name(thd, dbnorm))
|
||||
DBUG_RETURN(-1);
|
||||
|
||||
/* Check directory */
|
||||
path_len= build_table_filename(path, sizeof(path) - 1, db, "", "", 0);
|
||||
path_len= build_table_filename(path, sizeof(path) - 1, db->str, "", "", 0);
|
||||
path[path_len-1]= 0; // Remove last '/' from path
|
||||
|
||||
long affected_rows= 1;
|
||||
@@ -618,20 +618,20 @@ mysql_create_db_internal(THD *thd, const char *db,
|
||||
{
|
||||
push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE,
|
||||
ER_DB_CREATE_EXISTS, ER_THD(thd, ER_DB_CREATE_EXISTS),
|
||||
db);
|
||||
db->str);
|
||||
affected_rows= 0;
|
||||
goto not_silent;
|
||||
}
|
||||
else
|
||||
{
|
||||
my_error(ER_DB_CREATE_EXISTS, MYF(0), db);
|
||||
my_error(ER_DB_CREATE_EXISTS, MYF(0), db->str);
|
||||
DBUG_RETURN(-1);
|
||||
}
|
||||
|
||||
|
||||
if (my_mkdir(path, 0777, MYF(0)) < 0)
|
||||
{
|
||||
my_error(ER_CANT_CREATE_DB, MYF(0), db, my_errno);
|
||||
my_error(ER_CANT_CREATE_DB, MYF(0), db->str, my_errno);
|
||||
DBUG_RETURN(-1);
|
||||
}
|
||||
|
||||
@@ -687,8 +687,8 @@ not_silent:
|
||||
USE sisyfos; # Will give error on slave since
|
||||
# database does not exist.
|
||||
*/
|
||||
qinfo.db = db;
|
||||
qinfo.db_len = strlen(db);
|
||||
qinfo.db = db->str;
|
||||
qinfo.db_len = db->length;
|
||||
|
||||
/*
|
||||
These DDL methods and logging are protected with the exclusive
|
||||
@@ -707,7 +707,7 @@ not_silent:
|
||||
/* db-name is already validated when we come here */
|
||||
|
||||
static bool
|
||||
mysql_alter_db_internal(THD *thd, const char *db,
|
||||
mysql_alter_db_internal(THD *thd, const LEX_CSTRING *db,
|
||||
Schema_specification_st *create_info)
|
||||
{
|
||||
char path[FN_REFLEN+16];
|
||||
@@ -715,7 +715,7 @@ mysql_alter_db_internal(THD *thd, const char *db,
|
||||
int error= 0;
|
||||
DBUG_ENTER("mysql_alter_db");
|
||||
|
||||
if (lock_schema_name(thd, db))
|
||||
if (lock_schema_name(thd, db->str))
|
||||
DBUG_RETURN(TRUE);
|
||||
|
||||
/*
|
||||
@@ -723,13 +723,13 @@ mysql_alter_db_internal(THD *thd, const char *db,
|
||||
We pass MY_DB_OPT_FILE as "extension" to avoid
|
||||
"table name to file name" encoding.
|
||||
*/
|
||||
build_table_filename(path, sizeof(path) - 1, db, "", MY_DB_OPT_FILE, 0);
|
||||
build_table_filename(path, sizeof(path) - 1, db->str, "", MY_DB_OPT_FILE, 0);
|
||||
if ((error=write_db_opt(thd, path, create_info)))
|
||||
goto exit;
|
||||
|
||||
/* Change options if current database is being altered. */
|
||||
|
||||
if (thd->db && !strcmp(thd->db,db))
|
||||
if (thd->db.str && !cmp(&thd->db, db))
|
||||
{
|
||||
thd->db_charset= create_info->default_table_charset ?
|
||||
create_info->default_table_charset :
|
||||
@@ -747,8 +747,8 @@ mysql_alter_db_internal(THD *thd, const char *db,
|
||||
database" and not the threads current database, which is the
|
||||
default.
|
||||
*/
|
||||
qinfo.db = db;
|
||||
qinfo.db_len = strlen(db);
|
||||
qinfo.db= db->str;
|
||||
qinfo.db_len= db->length;
|
||||
|
||||
/*
|
||||
These DDL methods and logging are protected with the exclusive
|
||||
@@ -764,7 +764,7 @@ exit:
|
||||
}
|
||||
|
||||
|
||||
int mysql_create_db(THD *thd, const char *db,
|
||||
int mysql_create_db(THD *thd, const LEX_CSTRING *db,
|
||||
const DDL_options_st &options,
|
||||
const Schema_specification_st *create_info)
|
||||
{
|
||||
@@ -777,7 +777,7 @@ int mysql_create_db(THD *thd, const char *db,
|
||||
}
|
||||
|
||||
|
||||
bool mysql_alter_db(THD *thd, const char *db,
|
||||
bool mysql_alter_db(THD *thd, const LEX_CSTRING *db,
|
||||
const Schema_specification_st *create_info)
|
||||
{
|
||||
/*
|
||||
@@ -805,7 +805,7 @@ bool mysql_alter_db(THD *thd, const char *db,
|
||||
*/
|
||||
|
||||
static bool
|
||||
mysql_rm_db_internal(THD *thd, const char *db, bool if_exists, bool silent)
|
||||
mysql_rm_db_internal(THD *thd, const LEX_CSTRING *db, bool if_exists, bool silent)
|
||||
{
|
||||
ulong deleted_tables= 0;
|
||||
bool error= true, rm_mysql_schema;
|
||||
@@ -817,13 +817,13 @@ mysql_rm_db_internal(THD *thd, const char *db, bool if_exists, bool silent)
|
||||
Drop_table_error_handler err_handler;
|
||||
DBUG_ENTER("mysql_rm_db");
|
||||
|
||||
char db_tmp[SAFE_NAME_LEN];
|
||||
const char *dbnorm= normalize_db_name(db, db_tmp, sizeof(db_tmp));
|
||||
char db_tmp[SAFE_NAME_LEN+1];
|
||||
const char *dbnorm= normalize_db_name(db->str, db_tmp, sizeof(db_tmp));
|
||||
|
||||
if (lock_schema_name(thd, dbnorm))
|
||||
DBUG_RETURN(true);
|
||||
|
||||
length= build_table_filename(path, sizeof(path) - 1, db, "", "", 0);
|
||||
length= build_table_filename(path, sizeof(path) - 1, db->str, "", "", 0);
|
||||
strmov(path+length, MY_DB_OPT_FILE); // Append db option file name
|
||||
del_dbopt(path); // Remove dboption hash entry
|
||||
/*
|
||||
@@ -846,14 +846,14 @@ mysql_rm_db_internal(THD *thd, const char *db, bool if_exists, bool silent)
|
||||
{
|
||||
if (!if_exists)
|
||||
{
|
||||
my_error(ER_DB_DROP_EXISTS, MYF(0), db);
|
||||
my_error(ER_DB_DROP_EXISTS, MYF(0), db->str);
|
||||
DBUG_RETURN(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE,
|
||||
ER_DB_DROP_EXISTS, ER_THD(thd, ER_DB_DROP_EXISTS),
|
||||
db);
|
||||
db->str);
|
||||
error= false;
|
||||
goto update_binlog;
|
||||
}
|
||||
@@ -867,7 +867,7 @@ mysql_rm_db_internal(THD *thd, const char *db, bool if_exists, bool silent)
|
||||
This check is only needed if we are dropping the "mysql" database.
|
||||
*/
|
||||
if ((rm_mysql_schema=
|
||||
(my_strcasecmp(system_charset_info, MYSQL_SCHEMA_NAME.str, db) == 0)))
|
||||
(my_strcasecmp(system_charset_info, MYSQL_SCHEMA_NAME.str, db->str) == 0)))
|
||||
{
|
||||
for (table= tables; table; table= table->next_local)
|
||||
if (check_if_log_table(table, TRUE, "DROP"))
|
||||
@@ -884,11 +884,9 @@ mysql_rm_db_internal(THD *thd, const char *db, bool if_exists, bool silent)
|
||||
{
|
||||
for (table= tables; table; table= table->next_local)
|
||||
{
|
||||
LEX_CSTRING db_name= { table->db, table->db_length };
|
||||
LEX_CSTRING table_name= { table->table_name, table->table_name_length };
|
||||
if (table->open_type == OT_BASE_ONLY ||
|
||||
!thd->find_temporary_table(table))
|
||||
(void) delete_statistics_for_table(thd, &db_name, &table_name);
|
||||
(void) delete_statistics_for_table(thd, &table->db, &table->table_name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -959,8 +957,8 @@ update_binlog:
|
||||
database" and not the threads current database, which is the
|
||||
default.
|
||||
*/
|
||||
qinfo.db = db;
|
||||
qinfo.db_len = strlen(db);
|
||||
qinfo.db = db->str;
|
||||
qinfo.db_len = db->length;
|
||||
|
||||
/*
|
||||
These DDL methods and logging are protected with the exclusive
|
||||
@@ -980,13 +978,11 @@ update_binlog:
|
||||
{
|
||||
char *query, *query_pos, *query_end, *query_data_start;
|
||||
TABLE_LIST *tbl;
|
||||
uint db_len;
|
||||
|
||||
if (!(query= (char*) thd->alloc(MAX_DROP_TABLE_Q_LEN)))
|
||||
goto exit; /* not much else we can do */
|
||||
query_pos= query_data_start= strmov(query,"DROP TABLE IF EXISTS ");
|
||||
query_end= query + MAX_DROP_TABLE_Q_LEN;
|
||||
db_len= strlen(db);
|
||||
|
||||
for (tbl= tables; tbl; tbl= tbl->next_local)
|
||||
{
|
||||
@@ -994,19 +990,20 @@ update_binlog:
|
||||
char quoted_name[FN_REFLEN+3];
|
||||
|
||||
// Only write drop table to the binlog for tables that no longer exist.
|
||||
if (ha_table_exists(thd, tbl->db, tbl->table_name))
|
||||
if (ha_table_exists(thd, &tbl->db, &tbl->table_name))
|
||||
continue;
|
||||
|
||||
my_snprintf(quoted_name, sizeof(quoted_name), quoted_string,
|
||||
tbl->table_name);
|
||||
tbl_name_len= strlen(quoted_name) + 1; /* +1 for the comma */
|
||||
tbl_name_len= my_snprintf(quoted_name, sizeof(quoted_name),
|
||||
quoted_string,
|
||||
tbl->table_name.str);
|
||||
tbl_name_len++; /* +1 for the comma */
|
||||
if (query_pos + tbl_name_len + 1 >= query_end)
|
||||
{
|
||||
/*
|
||||
These DDL methods and logging are protected with the exclusive
|
||||
metadata lock on the schema.
|
||||
*/
|
||||
if (write_to_binlog(thd, query, (uint)(query_pos -1 - query), db, db_len))
|
||||
if (write_to_binlog(thd, query, (uint)(query_pos -1 - query), db->str, db->length))
|
||||
{
|
||||
error= true;
|
||||
goto exit;
|
||||
@@ -1024,7 +1021,7 @@ update_binlog:
|
||||
These DDL methods and logging are protected with the exclusive
|
||||
metadata lock on the schema.
|
||||
*/
|
||||
if (write_to_binlog(thd, query, (uint)(query_pos -1 - query), db, db_len))
|
||||
if (write_to_binlog(thd, query, (uint)(query_pos -1 - query), db->str, db->length))
|
||||
{
|
||||
error= true;
|
||||
goto exit;
|
||||
@@ -1039,7 +1036,7 @@ exit:
|
||||
SELECT DATABASE() in the future). For this we free() thd->db and set
|
||||
it to 0.
|
||||
*/
|
||||
if (thd->db && cmp_db_names(thd->db, db) && !error)
|
||||
if (thd->db.str && cmp_db_names(&thd->db, db) && !error)
|
||||
{
|
||||
mysql_change_db_impl(thd, NULL, 0, thd->variables.collation_server);
|
||||
SESSION_TRACKER_CHANGED(thd, CURRENT_SCHEMA_TRACKER, NULL);
|
||||
@@ -1049,7 +1046,7 @@ exit:
|
||||
}
|
||||
|
||||
|
||||
bool mysql_rm_db(THD *thd, const char *db, bool if_exists)
|
||||
bool mysql_rm_db(THD *thd, const LEX_CSTRING *db, bool if_exists)
|
||||
{
|
||||
return mysql_rm_db_internal(thd, db, if_exists, false);
|
||||
}
|
||||
@@ -1084,20 +1081,18 @@ static bool find_db_tables_and_rm_known_files(THD *thd, MY_DIR *dirp,
|
||||
|
||||
if (!table_list)
|
||||
DBUG_RETURN(true);
|
||||
table_list->db= db.str;
|
||||
table_list->db_length= db.length;
|
||||
table_list->table_name= table->str;
|
||||
table_list->table_name_length= table->length;
|
||||
table_list->db= db;
|
||||
table_list->table_name= *table;
|
||||
table_list->open_type= OT_BASE_ONLY;
|
||||
|
||||
/* To be able to correctly look up the table in the table cache. */
|
||||
if (lower_case_table_names)
|
||||
table_list->table_name_length= my_casedn_str(files_charset_info,
|
||||
(char*) table_list->table_name);
|
||||
table_list->table_name.length= my_casedn_str(files_charset_info,
|
||||
(char*) table_list->table_name.str);
|
||||
|
||||
table_list->alias= table_list->table_name; // If lower_case_table_names=2
|
||||
table_list->mdl_request.init(MDL_key::TABLE, table_list->db,
|
||||
table_list->table_name, MDL_EXCLUSIVE,
|
||||
table_list->mdl_request.init(MDL_key::TABLE, table_list->db.str,
|
||||
table_list->table_name.str, MDL_EXCLUSIVE,
|
||||
MDL_TRANSACTION);
|
||||
/* Link into list */
|
||||
(*tot_list_next_local)= table_list;
|
||||
@@ -1312,16 +1307,16 @@ static void mysql_change_db_impl(THD *thd,
|
||||
sets the new one.
|
||||
*/
|
||||
|
||||
thd->set_db(NULL, 0);
|
||||
thd->set_db(&null_clex_str);
|
||||
}
|
||||
else if (new_db_name == &INFORMATION_SCHEMA_NAME)
|
||||
else if (new_db_name->str == INFORMATION_SCHEMA_NAME.str)
|
||||
{
|
||||
/*
|
||||
Here we must use THD::set_db(), because we want to copy
|
||||
INFORMATION_SCHEMA_NAME constant.
|
||||
*/
|
||||
|
||||
thd->set_db(INFORMATION_SCHEMA_NAME.str, INFORMATION_SCHEMA_NAME.length);
|
||||
thd->set_db(&INFORMATION_SCHEMA_NAME);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1330,8 +1325,8 @@ static void mysql_change_db_impl(THD *thd,
|
||||
we just call THD::reset_db(). Since THD::reset_db() does not releases
|
||||
the previous database name, we should do it explicitly.
|
||||
*/
|
||||
thd->set_db(NULL, 0);
|
||||
thd->reset_db(const_cast<char*>(new_db_name->str), new_db_name->length);
|
||||
thd->set_db(&null_clex_str);
|
||||
thd->reset_db(new_db_name);
|
||||
}
|
||||
|
||||
/* 2. Update security context. */
|
||||
@@ -1366,17 +1361,17 @@ static void mysql_change_db_impl(THD *thd,
|
||||
static void backup_current_db_name(THD *thd,
|
||||
LEX_STRING *saved_db_name)
|
||||
{
|
||||
if (!thd->db)
|
||||
DBUG_ASSERT(saved_db_name->length >= SAFE_NAME_LEN +1);
|
||||
if (!thd->db.str)
|
||||
{
|
||||
/* No current (default) database selected. */
|
||||
|
||||
saved_db_name->str= NULL;
|
||||
saved_db_name->str= 0;
|
||||
saved_db_name->length= 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
strmake(saved_db_name->str, thd->db, saved_db_name->length - 1);
|
||||
saved_db_name->length= thd->db_length;
|
||||
memcpy(saved_db_name->str, thd->db.str, thd->db.length + 1);
|
||||
saved_db_name->length= thd->db.length;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1479,7 +1474,7 @@ bool mysql_change_db(THD *thd, const LEX_CSTRING *new_db_name,
|
||||
}
|
||||
DBUG_PRINT("enter",("name: '%s'", new_db_name->str));
|
||||
|
||||
if (is_infoschema_db(new_db_name->str, new_db_name->length))
|
||||
if (is_infoschema_db(new_db_name))
|
||||
{
|
||||
/* Switch the current database to INFORMATION_SCHEMA. */
|
||||
|
||||
@@ -1630,7 +1625,7 @@ bool mysql_opt_change_db(THD *thd,
|
||||
bool force_switch,
|
||||
bool *cur_db_changed)
|
||||
{
|
||||
*cur_db_changed= !cmp_db_names(thd->db, new_db_name->str);
|
||||
*cur_db_changed= !cmp_db_names(&thd->db, new_db_name);
|
||||
|
||||
if (!*cur_db_changed)
|
||||
return FALSE;
|
||||
@@ -1656,7 +1651,7 @@ bool mysql_opt_change_db(THD *thd,
|
||||
@return 0 on success, 1 on error
|
||||
*/
|
||||
|
||||
bool mysql_upgrade_db(THD *thd, LEX_CSTRING *old_db)
|
||||
bool mysql_upgrade_db(THD *thd, const LEX_CSTRING *old_db)
|
||||
{
|
||||
int error= 0, change_to_newdb= 0;
|
||||
char path[FN_REFLEN+16];
|
||||
@@ -1691,7 +1686,7 @@ bool mysql_upgrade_db(THD *thd, LEX_CSTRING *old_db)
|
||||
Let's remember if we should do "USE newdb" afterwards.
|
||||
thd->db will be cleared in mysql_rename_db()
|
||||
*/
|
||||
if (thd->db && !strcmp(thd->db, old_db->str))
|
||||
if (thd->db.str && !cmp(&thd->db, old_db))
|
||||
change_to_newdb= 1;
|
||||
|
||||
build_table_filename(path, sizeof(path)-1,
|
||||
@@ -1709,7 +1704,7 @@ bool mysql_upgrade_db(THD *thd, LEX_CSTRING *old_db)
|
||||
}
|
||||
|
||||
/* Step1: Create the new database */
|
||||
if ((error= mysql_create_db_internal(thd, new_db.str,
|
||||
if ((error= mysql_create_db_internal(thd, &new_db,
|
||||
DDL_options(), &create_info, 1)))
|
||||
goto exit;
|
||||
|
||||
@@ -1833,7 +1828,7 @@ bool mysql_upgrade_db(THD *thd, LEX_CSTRING *old_db)
|
||||
to execute them again.
|
||||
mysql_rm_db() also "unuses" if we drop the current database.
|
||||
*/
|
||||
error= mysql_rm_db_internal(thd, old_db->str, 0, true);
|
||||
error= mysql_rm_db_internal(thd, old_db, 0, true);
|
||||
|
||||
/* Step8: logging */
|
||||
if (mysql_bin_log.is_open())
|
||||
|
||||
@@ -20,13 +20,13 @@
|
||||
|
||||
class THD;
|
||||
|
||||
int mysql_create_db(THD *thd, const char *db,
|
||||
int mysql_create_db(THD *thd, const LEX_CSTRING *db,
|
||||
const DDL_options_st &options,
|
||||
const Schema_specification_st *create);
|
||||
bool mysql_alter_db(THD *thd, const char *db,
|
||||
bool mysql_alter_db(THD *thd, const LEX_CSTRING *db,
|
||||
const Schema_specification_st *create);
|
||||
bool mysql_rm_db(THD *thd, const char *db, bool if_exists);
|
||||
bool mysql_upgrade_db(THD *thd, LEX_CSTRING *old_db);
|
||||
bool mysql_rm_db(THD *thd, const LEX_CSTRING *db, bool if_exists);
|
||||
bool mysql_upgrade_db(THD *thd, const LEX_CSTRING *old_db);
|
||||
bool mysql_change_db(THD *thd, const LEX_CSTRING *new_db_name,
|
||||
bool force_switch);
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ bool Update_plan::save_explain_data_intern(MEM_ROOT *mem_root,
|
||||
bool is_analyze)
|
||||
{
|
||||
explain->select_type= "SIMPLE";
|
||||
explain->table_name.append(table->pos_in_table_list->alias);
|
||||
explain->table_name.append(&table->pos_in_table_list->alias);
|
||||
|
||||
explain->impossible_where= false;
|
||||
explain->no_partitions= false;
|
||||
@@ -344,7 +344,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
|
||||
|
||||
if (!table_list->single_table_updatable())
|
||||
{
|
||||
my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias, "DELETE");
|
||||
my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias.str, "DELETE");
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
if (!(table= table_list->table) || !table->is_created())
|
||||
@@ -961,7 +961,7 @@ l
|
||||
if (!table_list->single_table_updatable() ||
|
||||
check_key_in_view(thd, table_list))
|
||||
{
|
||||
my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias, "DELETE");
|
||||
my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias.str, "DELETE");
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
|
||||
@@ -1053,7 +1053,7 @@ int mysql_multi_delete_prepare(THD *thd)
|
||||
check_key_in_view(thd, target_tbl->correspondent_table))
|
||||
{
|
||||
my_error(ER_NON_UPDATABLE_TABLE, MYF(0),
|
||||
target_tbl->table_name, "DELETE");
|
||||
target_tbl->table_name.str, "DELETE");
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
/*
|
||||
|
||||
@@ -174,7 +174,7 @@ mysql_handle_single_derived(LEX *lex, TABLE_LIST *derived, uint phases)
|
||||
DBUG_ENTER("mysql_handle_single_derived");
|
||||
DBUG_PRINT("enter", ("phases: 0x%x allowed: 0x%x alias: '%s'",
|
||||
phases, allowed_phases,
|
||||
(derived->alias ? derived->alias : "<NULL>")));
|
||||
(derived->alias.str ? derived->alias.str : "<NULL>")));
|
||||
if (!lex->derived_tables)
|
||||
DBUG_RETURN(FALSE);
|
||||
|
||||
@@ -365,7 +365,7 @@ bool mysql_derived_merge(THD *thd, LEX *lex, TABLE_LIST *derived)
|
||||
Query_arena *arena, backup;
|
||||
DBUG_ENTER("mysql_derived_merge");
|
||||
DBUG_PRINT("enter", ("Alias: '%s' Unit: %p",
|
||||
(derived->alias ? derived->alias : "<NULL>"),
|
||||
(derived->alias.str ? derived->alias.str : "<NULL>"),
|
||||
derived->get_unit()));
|
||||
|
||||
if (derived->merged)
|
||||
@@ -514,7 +514,7 @@ bool mysql_derived_merge_for_insert(THD *thd, LEX *lex, TABLE_LIST *derived)
|
||||
{
|
||||
DBUG_ENTER("mysql_derived_merge_for_insert");
|
||||
DBUG_PRINT("enter", ("Alias: '%s' Unit: %p",
|
||||
(derived->alias ? derived->alias : "<NULL>"),
|
||||
(derived->alias.str ? derived->alias.str : "<NULL>"),
|
||||
derived->get_unit()));
|
||||
DBUG_PRINT("info", ("merged_for_insert: %d is_materialized_derived: %d "
|
||||
"is_multitable: %d single_table_updatable: %d "
|
||||
@@ -572,7 +572,7 @@ bool mysql_derived_init(THD *thd, LEX *lex, TABLE_LIST *derived)
|
||||
SELECT_LEX_UNIT *unit= derived->get_unit();
|
||||
DBUG_ENTER("mysql_derived_init");
|
||||
DBUG_PRINT("enter", ("Alias: '%s' Unit: %p",
|
||||
(derived->alias ? derived->alias : "<NULL>"),
|
||||
(derived->alias.str ? derived->alias.str : "<NULL>"),
|
||||
derived->get_unit()));
|
||||
|
||||
// Skip already prepared views/DT
|
||||
@@ -647,11 +647,10 @@ bool mysql_derived_init(THD *thd, LEX *lex, TABLE_LIST *derived)
|
||||
bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *derived)
|
||||
{
|
||||
SELECT_LEX_UNIT *unit= derived->get_unit();
|
||||
DBUG_ENTER("mysql_derived_prepare");
|
||||
bool res= FALSE;
|
||||
DBUG_PRINT("enter", ("Alias: '%s' Unit: %p",
|
||||
(derived->alias ? derived->alias : "<NULL>"),
|
||||
unit));
|
||||
DBUG_ENTER("mysql_derived_prepare");
|
||||
DBUG_PRINT("enter", ("unit: %p table_list: %p alias: '%s'",
|
||||
unit, derived, derived->alias.str));
|
||||
|
||||
if (!unit)
|
||||
DBUG_RETURN(FALSE);
|
||||
@@ -692,7 +691,7 @@ bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *derived)
|
||||
(first_select->options |
|
||||
thd->variables.option_bits |
|
||||
TMP_TABLE_ALL_COLUMNS),
|
||||
derived->alias, FALSE, FALSE, FALSE, 0);
|
||||
&derived->alias, FALSE, FALSE, FALSE, 0);
|
||||
thd->create_tmp_table_for_derived= FALSE;
|
||||
|
||||
if (!res && !derived->table)
|
||||
@@ -785,7 +784,7 @@ bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *derived)
|
||||
(first_select->options |
|
||||
thd->variables.option_bits |
|
||||
TMP_TABLE_ALL_COLUMNS),
|
||||
derived->alias,
|
||||
&derived->alias,
|
||||
FALSE, FALSE, FALSE,
|
||||
0))
|
||||
{
|
||||
@@ -810,8 +809,8 @@ exit:
|
||||
thd->get_stmt_da()->sql_errno() == ER_SP_DOES_NOT_EXIST))
|
||||
{
|
||||
thd->clear_error();
|
||||
my_error(ER_VIEW_INVALID, MYF(0), derived->db,
|
||||
derived->table_name);
|
||||
my_error(ER_VIEW_INVALID, MYF(0), derived->db.str,
|
||||
derived->table_name.str);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -881,11 +880,10 @@ bool mysql_derived_optimize(THD *thd, LEX *lex, TABLE_LIST *derived)
|
||||
SELECT_LEX_UNIT *unit= derived->get_unit();
|
||||
SELECT_LEX *first_select= unit->first_select();
|
||||
SELECT_LEX *save_current_select= lex->current_select;
|
||||
|
||||
bool res= FALSE;
|
||||
DBUG_ENTER("mysql_derived_optimize");
|
||||
DBUG_PRINT("enter", ("Alias: '%s' Unit: %p",
|
||||
(derived->alias ? derived->alias : "<NULL>"),
|
||||
(derived->alias.str ? derived->alias.str : "<NULL>"),
|
||||
derived->get_unit()));
|
||||
|
||||
lex->current_select= first_select;
|
||||
@@ -966,7 +964,7 @@ bool mysql_derived_create(THD *thd, LEX *lex, TABLE_LIST *derived)
|
||||
{
|
||||
DBUG_ENTER("mysql_derived_create");
|
||||
DBUG_PRINT("enter", ("Alias: '%s' Unit: %p",
|
||||
(derived->alias ? derived->alias : "<NULL>"),
|
||||
(derived->alias.str ? derived->alias.str : "<NULL>"),
|
||||
derived->get_unit()));
|
||||
TABLE *table= derived->table;
|
||||
SELECT_LEX_UNIT *unit= derived->get_unit();
|
||||
@@ -1067,7 +1065,7 @@ bool mysql_derived_fill(THD *thd, LEX *lex, TABLE_LIST *derived)
|
||||
bool res= FALSE;
|
||||
DBUG_ENTER("mysql_derived_fill");
|
||||
DBUG_PRINT("enter", ("Alias: '%s' Unit: %p",
|
||||
(derived->alias ? derived->alias : "<NULL>"),
|
||||
(derived->alias.str ? derived->alias.str : "<NULL>"),
|
||||
derived->get_unit()));
|
||||
|
||||
if (unit->executed && !unit->uncacheable && !unit->describe &&
|
||||
@@ -1189,7 +1187,7 @@ bool mysql_derived_reinit(THD *thd, LEX *lex, TABLE_LIST *derived)
|
||||
{
|
||||
DBUG_ENTER("mysql_derived_reinit");
|
||||
DBUG_PRINT("enter", ("Alias: '%s' Unit: %p",
|
||||
(derived->alias ? derived->alias : "<NULL>"),
|
||||
(derived->alias.str ? derived->alias.str : "<NULL>"),
|
||||
derived->get_unit()));
|
||||
st_select_lex_unit *unit= derived->get_unit();
|
||||
|
||||
|
||||
@@ -97,6 +97,7 @@ void Expression_cache_tmptable::init()
|
||||
List_iterator<Item> li(items);
|
||||
Item_iterator_list it(li);
|
||||
uint field_counter;
|
||||
LEX_CSTRING cache_table_name= { STRING_WITH_LEN("subquery-cache-table") };
|
||||
DBUG_ENTER("Expression_cache_tmptable::init");
|
||||
DBUG_ASSERT(!inited);
|
||||
inited= TRUE;
|
||||
@@ -124,7 +125,7 @@ void Expression_cache_tmptable::init()
|
||||
TMP_TABLE_ALL_COLUMNS) &
|
||||
~TMP_TABLE_FORCE_MYISAM),
|
||||
HA_POS_ERROR,
|
||||
(char *)"subquery-cache-table",
|
||||
&cache_table_name,
|
||||
TRUE)))
|
||||
{
|
||||
DBUG_PRINT("error", ("create_tmp_table failed, caching switched off"));
|
||||
|
||||
@@ -116,7 +116,7 @@ static char *mysql_ha_hash_get_key(SQL_HANDLER *table, size_t *key_len,
|
||||
my_bool first __attribute__((unused)))
|
||||
{
|
||||
*key_len= table->handler_name.length + 1 ; /* include '\0' in comparisons */
|
||||
return table->handler_name.str;
|
||||
return (char*) table->handler_name.str;
|
||||
}
|
||||
|
||||
|
||||
@@ -266,7 +266,7 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, SQL_HANDLER *reopen)
|
||||
Query_arena backup_arena;
|
||||
DBUG_ENTER("mysql_ha_open");
|
||||
DBUG_PRINT("enter",("'%s'.'%s' as '%s' reopen: %d",
|
||||
tables->db, tables->table_name, tables->alias,
|
||||
tables->db.str, tables->table_name.str, tables->alias.str,
|
||||
reopen != 0));
|
||||
|
||||
if (thd->locked_tables_mode)
|
||||
@@ -298,12 +298,12 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, SQL_HANDLER *reopen)
|
||||
}
|
||||
else if (! reopen) /* Otherwise we have 'tables' already. */
|
||||
{
|
||||
if (my_hash_search(&thd->handler_tables_hash, (uchar*) tables->alias,
|
||||
strlen(tables->alias) + 1))
|
||||
if (my_hash_search(&thd->handler_tables_hash, (uchar*) tables->alias.str,
|
||||
tables->alias.length + 1))
|
||||
{
|
||||
DBUG_PRINT("info",("duplicate '%s'", tables->alias));
|
||||
DBUG_PRINT("info",("duplicate '%s'", tables->alias.str));
|
||||
DBUG_PRINT("exit",("ERROR"));
|
||||
my_error(ER_NONUNIQ_TABLE, MYF(0), tables->alias);
|
||||
my_error(ER_NONUNIQ_TABLE, MYF(0), tables->alias.str);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
}
|
||||
@@ -330,7 +330,7 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, SQL_HANDLER *reopen)
|
||||
right from the start as open_tables() can't handle properly
|
||||
back-off for such locks.
|
||||
*/
|
||||
tables->mdl_request.init(MDL_key::TABLE, tables->db, tables->table_name,
|
||||
tables->mdl_request.init(MDL_key::TABLE, tables->db.str, tables->table_name.str,
|
||||
MDL_SHARED_READ, MDL_TRANSACTION);
|
||||
mdl_savepoint= thd->mdl_context.mdl_savepoint();
|
||||
|
||||
@@ -384,12 +384,12 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, SQL_HANDLER *reopen)
|
||||
goto err;
|
||||
init_alloc_root(&sql_handler->mem_root, 1024, 0, MYF(MY_THREAD_SPECIFIC));
|
||||
|
||||
sql_handler->db.length= strlen(tables->db);
|
||||
sql_handler->table_name.length= strlen(tables->table_name);
|
||||
sql_handler->handler_name.length= strlen(tables->alias);
|
||||
sql_handler->db.length= tables->db.length;
|
||||
sql_handler->table_name.length= tables->table_name.length;
|
||||
sql_handler->handler_name.length= tables->alias.length;
|
||||
|
||||
if (!(my_multi_malloc(MY_WME,
|
||||
&sql_handler->db.str,
|
||||
&sql_handler->base_data,
|
||||
(uint) sql_handler->db.length + 1,
|
||||
&sql_handler->table_name.str,
|
||||
(uint) sql_handler->table_name.length + 1,
|
||||
@@ -397,12 +397,12 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, SQL_HANDLER *reopen)
|
||||
(uint) sql_handler->handler_name.length + 1,
|
||||
NullS)))
|
||||
goto err;
|
||||
sql_handler->base_data= sql_handler->db.str; // Free this
|
||||
memcpy(sql_handler->db.str, tables->db, sql_handler->db.length +1);
|
||||
memcpy(sql_handler->table_name.str, tables->table_name,
|
||||
sql_handler->table_name.length+1);
|
||||
memcpy(sql_handler->handler_name.str, tables->alias,
|
||||
sql_handler->handler_name.length +1);
|
||||
sql_handler->db.str= sql_handler->base_data;
|
||||
memcpy((char*) sql_handler->db.str, tables->db.str, tables->db.length +1);
|
||||
memcpy((char*) sql_handler->table_name.str, tables->table_name.str,
|
||||
tables->table_name.length+1);
|
||||
memcpy((char*) sql_handler->handler_name.str, tables->alias.str,
|
||||
tables->alias.length +1);
|
||||
|
||||
/* add to hash */
|
||||
if (my_hash_insert(&thd->handler_tables_hash, (uchar*) sql_handler))
|
||||
@@ -520,7 +520,7 @@ bool mysql_ha_close(THD *thd, TABLE_LIST *tables)
|
||||
SQL_HANDLER *handler;
|
||||
DBUG_ENTER("mysql_ha_close");
|
||||
DBUG_PRINT("enter",("'%s'.'%s' as '%s'",
|
||||
tables->db, tables->table_name, tables->alias));
|
||||
tables->db.str, tables->table_name.str, tables->alias.str));
|
||||
|
||||
if (thd->locked_tables_mode)
|
||||
{
|
||||
@@ -529,15 +529,15 @@ bool mysql_ha_close(THD *thd, TABLE_LIST *tables)
|
||||
}
|
||||
if ((my_hash_inited(&thd->handler_tables_hash)) &&
|
||||
(handler= (SQL_HANDLER*) my_hash_search(&thd->handler_tables_hash,
|
||||
(uchar*) tables->alias,
|
||||
strlen(tables->alias) + 1)))
|
||||
(const uchar*) tables->alias.str,
|
||||
tables->alias.length + 1)))
|
||||
{
|
||||
mysql_ha_close_table(handler);
|
||||
my_hash_delete(&thd->handler_tables_hash, (uchar*) handler);
|
||||
}
|
||||
else
|
||||
{
|
||||
my_error(ER_UNKNOWN_TABLE, MYF(0), tables->alias, "HANDLER");
|
||||
my_error(ER_UNKNOWN_TABLE, MYF(0), tables->alias.str, "HANDLER");
|
||||
DBUG_PRINT("exit",("ERROR"));
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
@@ -564,13 +564,13 @@ bool mysql_ha_close(THD *thd, TABLE_LIST *tables)
|
||||
@return handler
|
||||
*/
|
||||
|
||||
SQL_HANDLER *mysql_ha_find_handler(THD *thd, const char *name)
|
||||
static SQL_HANDLER *mysql_ha_find_handler(THD *thd, const LEX_CSTRING *name)
|
||||
{
|
||||
SQL_HANDLER *handler;
|
||||
if ((my_hash_inited(&thd->handler_tables_hash)) &&
|
||||
(handler= (SQL_HANDLER*) my_hash_search(&thd->handler_tables_hash,
|
||||
(uchar*) name,
|
||||
strlen(name) + 1)))
|
||||
(const uchar*) name->str,
|
||||
name->length + 1)))
|
||||
{
|
||||
DBUG_PRINT("info-in-hash",("'%s'.'%s' as '%s' table: %p",
|
||||
handler->db.str,
|
||||
@@ -580,9 +580,8 @@ SQL_HANDLER *mysql_ha_find_handler(THD *thd, const char *name)
|
||||
{
|
||||
/* The handler table has been closed. Re-open it. */
|
||||
TABLE_LIST tmp;
|
||||
tmp.init_one_table(handler->db.str, handler->db.length,
|
||||
handler->table_name.str, handler->table_name.length,
|
||||
handler->handler_name.str, TL_READ);
|
||||
tmp.init_one_table(&handler->db, &handler->table_name,
|
||||
&handler->handler_name, TL_READ);
|
||||
|
||||
if (mysql_ha_open(thd, &tmp, handler))
|
||||
{
|
||||
@@ -593,7 +592,7 @@ SQL_HANDLER *mysql_ha_find_handler(THD *thd, const char *name)
|
||||
}
|
||||
else
|
||||
{
|
||||
my_error(ER_UNKNOWN_TABLE, MYF(0), name, "HANDLER");
|
||||
my_error(ER_UNKNOWN_TABLE, MYF(0), name->str, "HANDLER");
|
||||
return 0;
|
||||
}
|
||||
return handler;
|
||||
@@ -756,7 +755,7 @@ bool mysql_ha_read(THD *thd, TABLE_LIST *tables,
|
||||
MDL_deadlock_and_lock_abort_error_handler sql_handler_lock_error;
|
||||
DBUG_ENTER("mysql_ha_read");
|
||||
DBUG_PRINT("enter",("'%s'.'%s' as '%s'",
|
||||
tables->db, tables->table_name, tables->alias));
|
||||
tables->db.str, tables->table_name.str, tables->alias.str));
|
||||
|
||||
if (thd->locked_tables_mode)
|
||||
{
|
||||
@@ -765,7 +764,7 @@ bool mysql_ha_read(THD *thd, TABLE_LIST *tables,
|
||||
}
|
||||
|
||||
retry:
|
||||
if (!(handler= mysql_ha_find_handler(thd, tables->alias)))
|
||||
if (!(handler= mysql_ha_find_handler(thd, &tables->alias)))
|
||||
goto err0;
|
||||
|
||||
table= handler->table;
|
||||
@@ -950,7 +949,7 @@ retry:
|
||||
if (error != HA_ERR_RECORD_CHANGED && error != HA_ERR_WRONG_COMMAND)
|
||||
sql_print_error("mysql_ha_read: Got error %d when reading "
|
||||
"table '%s'",
|
||||
error, tables->table_name);
|
||||
error, tables->table_name.str);
|
||||
table->file->print_error(error,MYF(0));
|
||||
table->file->ha_index_or_rnd_end();
|
||||
goto err;
|
||||
@@ -1007,7 +1006,7 @@ SQL_HANDLER *mysql_ha_read_prepare(THD *thd, TABLE_LIST *tables,
|
||||
{
|
||||
SQL_HANDLER *handler;
|
||||
DBUG_ENTER("mysql_ha_read_prepare");
|
||||
if (!(handler= mysql_ha_find_handler(thd, tables->alias)))
|
||||
if (!(handler= mysql_ha_find_handler(thd, &tables->alias)))
|
||||
DBUG_RETURN(0);
|
||||
tables->table= handler->table; // This is used by fix_fields
|
||||
if (mysql_ha_fix_cond_and_key(handler, mode, keyname, key_expr, cond, 1))
|
||||
@@ -1043,7 +1042,7 @@ static SQL_HANDLER *mysql_ha_find_match(THD *thd, TABLE_LIST *tables)
|
||||
{
|
||||
if (tables->is_anonymous_derived_table())
|
||||
continue;
|
||||
if ((! *tables->db ||
|
||||
if ((! tables->db.str[0] ||
|
||||
! my_strcasecmp(&my_charset_latin1, hash_tables->db.str,
|
||||
tables->get_db_name())) &&
|
||||
! my_strcasecmp(&my_charset_latin1, hash_tables->table_name.str,
|
||||
|
||||
@@ -31,9 +31,9 @@ public:
|
||||
TABLE *table;
|
||||
List<Item> fields; /* Fields, set on open */
|
||||
THD *thd;
|
||||
LEX_STRING handler_name;
|
||||
LEX_STRING db;
|
||||
LEX_STRING table_name;
|
||||
LEX_CSTRING handler_name;
|
||||
LEX_CSTRING db;
|
||||
LEX_CSTRING table_name;
|
||||
MEM_ROOT mem_root;
|
||||
MYSQL_LOCK *lock;
|
||||
MDL_request mdl_request;
|
||||
|
||||
@@ -689,20 +689,16 @@ static bool mysqld_help_internal(THD *thd, const char *mask)
|
||||
uint mlen= strlen(mask);
|
||||
size_t i;
|
||||
MEM_ROOT *mem_root= thd->mem_root;
|
||||
LEX_CSTRING MYSQL_HELP_TOPIC_NAME= {STRING_WITH_LEN("help_topic") };
|
||||
LEX_CSTRING MYSQL_HELP_CATEGORY_NAME= {STRING_WITH_LEN("help_category") };
|
||||
LEX_CSTRING MYSQL_HELP_RELATION_NAME= {STRING_WITH_LEN("help_relation") };
|
||||
LEX_CSTRING MYSQL_HELP_KEYWORD_NAME= {STRING_WITH_LEN("help_keyword") };
|
||||
DBUG_ENTER("mysqld_help");
|
||||
|
||||
tables[0].init_one_table(C_STRING_WITH_LEN("mysql"),
|
||||
C_STRING_WITH_LEN("help_topic"),
|
||||
"help_topic", TL_READ);
|
||||
tables[1].init_one_table(C_STRING_WITH_LEN("mysql"),
|
||||
C_STRING_WITH_LEN("help_category"),
|
||||
"help_category", TL_READ);
|
||||
tables[2].init_one_table(C_STRING_WITH_LEN("mysql"),
|
||||
C_STRING_WITH_LEN("help_relation"),
|
||||
"help_relation", TL_READ);
|
||||
tables[3].init_one_table(C_STRING_WITH_LEN("mysql"),
|
||||
C_STRING_WITH_LEN("help_keyword"),
|
||||
"help_keyword", TL_READ);
|
||||
tables[0].init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_HELP_TOPIC_NAME, 0, TL_READ);
|
||||
tables[1].init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_HELP_CATEGORY_NAME, 0, TL_READ);
|
||||
tables[2].init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_HELP_RELATION_NAME, 0, TL_READ);
|
||||
tables[3].init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_HELP_KEYWORD_NAME, 0, TL_READ);
|
||||
tables[0].next_global= tables[0].next_local=
|
||||
tables[0].next_name_resolution_table= &tables[1];
|
||||
tables[1].next_global= tables[1].next_local=
|
||||
|
||||
@@ -168,9 +168,9 @@ static bool check_view_single_update(List<Item> &fields, List<Item> *values,
|
||||
if (!tbl->single_table_updatable())
|
||||
{
|
||||
if (insert)
|
||||
my_error(ER_NON_INSERTABLE_TABLE, MYF(0), view->alias, "INSERT");
|
||||
my_error(ER_NON_INSERTABLE_TABLE, MYF(0), view->alias.str, "INSERT");
|
||||
else
|
||||
my_error(ER_NON_UPDATABLE_TABLE, MYF(0), view->alias, "UPDATE");
|
||||
my_error(ER_NON_UPDATABLE_TABLE, MYF(0), view->alias.str, "UPDATE");
|
||||
return TRUE;
|
||||
}
|
||||
*map= tables;
|
||||
@@ -210,7 +210,7 @@ static int check_insert_fields(THD *thd, TABLE_LIST *table_list,
|
||||
|
||||
if (!table_list->single_table_updatable())
|
||||
{
|
||||
my_error(ER_NON_INSERTABLE_TABLE, MYF(0), table_list->alias, "INSERT");
|
||||
my_error(ER_NON_INSERTABLE_TABLE, MYF(0), table_list->alias.str, "INSERT");
|
||||
DBUG_RETURN(-1);
|
||||
}
|
||||
|
||||
@@ -304,7 +304,7 @@ static int check_insert_fields(THD *thd, TABLE_LIST *table_list,
|
||||
(table_list->view &&
|
||||
check_view_insertability(thd, table_list)))
|
||||
{
|
||||
my_error(ER_NON_INSERTABLE_TABLE, MYF(0), table_list->alias, "INSERT");
|
||||
my_error(ER_NON_INSERTABLE_TABLE, MYF(0), table_list->alias.str, "INSERT");
|
||||
DBUG_RETURN(-1);
|
||||
}
|
||||
|
||||
@@ -742,11 +742,11 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
|
||||
*/
|
||||
if (table_list->lock_type == TL_WRITE_DELAYED &&
|
||||
thd->locked_tables_mode &&
|
||||
find_locked_table(thd->open_tables, table_list->db,
|
||||
table_list->table_name))
|
||||
find_locked_table(thd->open_tables, table_list->db.str,
|
||||
table_list->table_name.str))
|
||||
{
|
||||
my_error(ER_DELAYED_INSERT_TABLE_LOCKED, MYF(0),
|
||||
table_list->table_name);
|
||||
table_list->table_name.str);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
/*
|
||||
@@ -1381,7 +1381,7 @@ static bool mysql_prepare_insert_check_table(THD *thd, TABLE_LIST *table_list,
|
||||
|
||||
if (!table_list->single_table_updatable())
|
||||
{
|
||||
my_error(ER_NON_INSERTABLE_TABLE, MYF(0), table_list->alias, "INSERT");
|
||||
my_error(ER_NON_INSERTABLE_TABLE, MYF(0), table_list->alias.str, "INSERT");
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
/*
|
||||
@@ -2262,8 +2262,8 @@ Delayed_insert *find_handler(THD *thd, TABLE_LIST *table_list)
|
||||
Delayed_insert *di;
|
||||
while ((di= it++))
|
||||
{
|
||||
if (!strcmp(table_list->db, di->table_list.db) &&
|
||||
!strcmp(table_list->table_name, di->table_list.table_name))
|
||||
if (!cmp(&table_list->db, &di->table_list.db) &&
|
||||
!cmp(&table_list->table_name, &di->table_list.table_name))
|
||||
{
|
||||
di->lock();
|
||||
break;
|
||||
@@ -2327,7 +2327,7 @@ bool delayed_get_table(THD *thd, MDL_request *grl_protection_request,
|
||||
DBUG_ENTER("delayed_get_table");
|
||||
|
||||
/* Must be set in the parser */
|
||||
DBUG_ASSERT(table_list->db);
|
||||
DBUG_ASSERT(table_list->db.str);
|
||||
|
||||
/* Find the thread which handles this table. */
|
||||
if (!(di= find_handler(thd, table_list)))
|
||||
@@ -2354,11 +2354,12 @@ bool delayed_get_table(THD *thd, MDL_request *grl_protection_request,
|
||||
*/
|
||||
di->thd.variables.binlog_annotate_row_events= 0;
|
||||
|
||||
di->thd.set_db(table_list->db, (uint) strlen(table_list->db));
|
||||
di->thd.set_query(my_strdup(table_list->table_name,
|
||||
MYF(MY_WME | ME_FATALERROR)),
|
||||
0, system_charset_info);
|
||||
if (di->thd.db == NULL || di->thd.query() == NULL)
|
||||
di->thd.set_db(&table_list->db);
|
||||
di->thd.set_query(my_strndup(table_list->table_name.str,
|
||||
table_list->table_name.length,
|
||||
MYF(MY_WME | ME_FATALERROR)),
|
||||
table_list->table_name.length, system_charset_info);
|
||||
if (di->thd.db.str == NULL || di->thd.query() == NULL)
|
||||
{
|
||||
/* The error is reported */
|
||||
delete di;
|
||||
@@ -2366,7 +2367,8 @@ bool delayed_get_table(THD *thd, MDL_request *grl_protection_request,
|
||||
}
|
||||
di->table_list= *table_list; // Needed to open table
|
||||
/* Replace volatile strings with local copies */
|
||||
di->table_list.alias= di->table_list.table_name= di->thd.query();
|
||||
di->table_list.alias.str= di->table_list.table_name.str= di->thd.query();
|
||||
di->table_list.alias.length= di->table_list.table_name.length= di->thd.query_length();
|
||||
di->table_list.db= di->thd.db;
|
||||
/* We need the tickets so that they can be cloned in handle_delayed_insert */
|
||||
di->grl_protection.init(MDL_key::GLOBAL, "", "",
|
||||
@@ -2848,7 +2850,7 @@ handle_table(THD *thd, Query_tables_list *prelocking_ctx,
|
||||
|
||||
if (!(table_list->table->file->ha_table_flags() & HA_CAN_INSERT_DELAYED))
|
||||
{
|
||||
my_error(ER_DELAYED_NOT_SUPPORTED, MYF(0), table_list->table_name);
|
||||
my_error(ER_DELAYED_NOT_SUPPORTED, MYF(0), table_list->table_name.str);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
@@ -4219,8 +4221,8 @@ TABLE *select_create::create_table_from_items(THD *thd,
|
||||
open_table().
|
||||
*/
|
||||
|
||||
if (!mysql_create_table_no_lock(thd, create_table->db,
|
||||
create_table->table_name,
|
||||
if (!mysql_create_table_no_lock(thd, &create_table->db,
|
||||
&create_table->table_name,
|
||||
create_info, alter_info, NULL,
|
||||
select_field_count, create_table))
|
||||
{
|
||||
@@ -4246,8 +4248,8 @@ TABLE *select_create::create_table_from_items(THD *thd,
|
||||
*/
|
||||
if (open_table(thd, create_table, &ot_ctx))
|
||||
{
|
||||
quick_rm_table(thd, create_info->db_type, create_table->db,
|
||||
table_case_name(create_info, create_table->table_name),
|
||||
quick_rm_table(thd, create_info->db_type, &create_table->db,
|
||||
table_case_name(create_info, &create_table->table_name),
|
||||
0);
|
||||
}
|
||||
/* Restore */
|
||||
@@ -4304,7 +4306,7 @@ TABLE *select_create::create_table_from_items(THD *thd,
|
||||
mysql_unlock_tables(thd, *lock);
|
||||
*lock= 0;
|
||||
}
|
||||
drop_open_table(thd, table, create_table->db, create_table->table_name);
|
||||
drop_open_table(thd, table, &create_table->db, &create_table->table_name);
|
||||
DBUG_RETURN(0);
|
||||
/* purecov: end */
|
||||
}
|
||||
@@ -4692,16 +4694,14 @@ void select_create::abort_result_set()
|
||||
table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
|
||||
table->file->extra(HA_EXTRA_WRITE_CANNOT_REPLACE);
|
||||
table->auto_increment_field_not_null= FALSE;
|
||||
drop_open_table(thd, table, create_table->db, create_table->table_name);
|
||||
drop_open_table(thd, table, &create_table->db, &create_table->table_name);
|
||||
table=0; // Safety
|
||||
if (thd->log_current_statement && mysql_bin_log.is_open())
|
||||
{
|
||||
/* Remove logging of drop, create + insert rows */
|
||||
binlog_reset_cache(thd);
|
||||
/* Original table was deleted. We have to log it */
|
||||
log_drop_table(thd, create_table->db, create_table->db_length,
|
||||
create_table->table_name, create_table->table_name_length,
|
||||
tmp_table);
|
||||
log_drop_table(thd, &create_table->db, &create_table->table_name, tmp_table);
|
||||
}
|
||||
}
|
||||
DBUG_VOID_RETURN;
|
||||
|
||||
@@ -2282,7 +2282,8 @@ void st_select_lex::init_select()
|
||||
group_list.empty();
|
||||
if (group_list_ptrs)
|
||||
group_list_ptrs->clear();
|
||||
type= db= 0;
|
||||
type= 0;
|
||||
db= null_clex_str;
|
||||
having= 0;
|
||||
table_join_options= 0;
|
||||
in_sum_expr= with_wild= 0;
|
||||
@@ -3288,8 +3289,7 @@ uint8 LEX::get_effective_with_check(TABLE_LIST *view)
|
||||
case of success
|
||||
*/
|
||||
|
||||
bool
|
||||
LEX::copy_db_to(const char **p_db, size_t *p_db_length) const
|
||||
bool LEX::copy_db_to(LEX_CSTRING *to)
|
||||
{
|
||||
if (sphead && sphead->m_name.str)
|
||||
{
|
||||
@@ -3298,12 +3298,10 @@ LEX::copy_db_to(const char **p_db, size_t *p_db_length) const
|
||||
It is safe to assign the string by-pointer, both sphead and
|
||||
its statements reside in the same memory root.
|
||||
*/
|
||||
*p_db= sphead->m_db.str;
|
||||
if (p_db_length)
|
||||
*p_db_length= sphead->m_db.length;
|
||||
*to= sphead->m_db;
|
||||
return FALSE;
|
||||
}
|
||||
return thd->copy_db_to(p_db, p_db_length);
|
||||
return thd->copy_db_to(to);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -6033,7 +6031,7 @@ sp_name *LEX::make_sp_name(THD *thd, const LEX_CSTRING *name)
|
||||
sp_name *res;
|
||||
LEX_CSTRING db;
|
||||
if (check_routine_name(name) ||
|
||||
copy_db_to(&db.str, &db.length) ||
|
||||
copy_db_to(&db) ||
|
||||
(!(res= new (thd->mem_root) sp_name(&db, name, false))))
|
||||
return NULL;
|
||||
return res;
|
||||
@@ -7484,18 +7482,16 @@ bool SELECT_LEX::vers_push_field(THD *thd, TABLE_LIST *table, const LEX_CSTRING
|
||||
{
|
||||
DBUG_ASSERT(field_name.str);
|
||||
Item_field *fld= new (thd->mem_root) Item_field(thd, &context,
|
||||
table->db, table->alias, &field_name);
|
||||
if (!fld)
|
||||
table->db.str, table->alias.str, &field_name);
|
||||
if (!fld || item_list.push_back(fld))
|
||||
return true;
|
||||
|
||||
item_list.push_back(fld);
|
||||
|
||||
if (thd->lex->view_list.elements)
|
||||
{
|
||||
if (LEX_STRING *l= thd->make_lex_string(field_name.str, field_name.length))
|
||||
thd->lex->view_list.push_back(l);
|
||||
else
|
||||
LEX_CSTRING *l;
|
||||
if (!(l= thd->make_clex_string(field_name.str, field_name.length)))
|
||||
return true;
|
||||
thd->lex->view_list.push_back(l);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -206,7 +206,7 @@ struct LEX_TYPE
|
||||
#ifdef MYSQL_SERVER
|
||||
|
||||
extern const LEX_STRING empty_lex_str;
|
||||
extern const LEX_CSTRING empty_clex_str;
|
||||
extern MYSQL_PLUGIN_IMPORT const LEX_CSTRING empty_clex_str;
|
||||
extern const LEX_CSTRING star_clex_str;
|
||||
extern const LEX_CSTRING param_clex_str;
|
||||
|
||||
@@ -837,7 +837,7 @@ class st_select_lex: public st_select_lex_node
|
||||
{
|
||||
public:
|
||||
Name_resolution_context context;
|
||||
const char *db;
|
||||
LEX_CSTRING db;
|
||||
Item *where, *having; /* WHERE & HAVING clauses */
|
||||
Item *prep_where; /* saved WHERE clause for prepared statement processing */
|
||||
Item *prep_having;/* saved HAVING clause for prepared statement processing */
|
||||
@@ -2754,7 +2754,7 @@ public:
|
||||
|
||||
List<Item_func_set_user_var> set_var_list; // in-query assignment list
|
||||
List<Item_param> param_list;
|
||||
List<LEX_STRING> view_list; // view list (list of field names in view)
|
||||
List<LEX_CSTRING> view_list; // view list (list of field names in view)
|
||||
List<LEX_CSTRING> with_column_list; // list of column names in with_list_element
|
||||
List<LEX_STRING> *column_list; // list of column names (in ANALYZE)
|
||||
List<LEX_STRING> *index_list; // list of index names (in ANALYZE)
|
||||
@@ -3124,7 +3124,7 @@ public:
|
||||
context_stack.pop();
|
||||
}
|
||||
|
||||
bool copy_db_to(const char **p_db, size_t *p_db_length) const;
|
||||
bool copy_db_to(LEX_CSTRING *to);
|
||||
|
||||
Name_resolution_context *current_context()
|
||||
{
|
||||
|
||||
@@ -322,13 +322,13 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
|
||||
killed_state killed_status;
|
||||
bool is_concurrent;
|
||||
#endif
|
||||
const char *db = table_list->db; // This is never null
|
||||
const char *db= table_list->db.str; // This is never null
|
||||
/*
|
||||
If path for file is not defined, we will use the current database.
|
||||
If this is not set, we will use the directory where the table to be
|
||||
loaded is located
|
||||
*/
|
||||
const char *tdb= thd->db ? thd->db : db; // Result is never null
|
||||
const char *tdb= thd->db.str ? thd->db.str : db; // Result is never null
|
||||
ulong skip_lines= ex->skip_lines;
|
||||
bool transactional_table __attribute__((unused));
|
||||
DBUG_ENTER("mysql_load");
|
||||
@@ -379,7 +379,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
|
||||
!table_list->single_table_updatable() || // and derived tables
|
||||
check_key_in_view(thd, table_list))
|
||||
{
|
||||
my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias, "LOAD");
|
||||
my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias.str, "LOAD");
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
if (table_list->prepare_where(thd, 0, TRUE) ||
|
||||
@@ -398,7 +398,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
|
||||
*/
|
||||
if (unique_table(thd, table_list, table_list->next_global, 0))
|
||||
{
|
||||
my_error(ER_UPDATE_TABLE_USED, MYF(0), table_list->table_name,
|
||||
my_error(ER_UPDATE_TABLE_USED, MYF(0), table_list->table_name.str,
|
||||
"LOAD DATA");
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
@@ -710,8 +710,8 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
|
||||
writing binary log will be ignored */
|
||||
if (thd->transaction.stmt.modified_non_trans_table)
|
||||
(void) write_execute_load_query_log_event(thd, ex,
|
||||
table_list->db,
|
||||
table_list->table_name,
|
||||
table_list->db.str,
|
||||
table_list->table_name.str,
|
||||
is_concurrent,
|
||||
handle_duplicates, ignore,
|
||||
transactional_table,
|
||||
@@ -761,7 +761,8 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
|
||||
{
|
||||
int errcode= query_error_code(thd, killed_status == NOT_KILLED);
|
||||
error= write_execute_load_query_log_event(thd, ex,
|
||||
table_list->db, table_list->table_name,
|
||||
table_list->db.str,
|
||||
table_list->table_name.str,
|
||||
is_concurrent,
|
||||
handle_duplicates, ignore,
|
||||
transactional_table,
|
||||
@@ -810,7 +811,7 @@ static bool write_execute_load_query_log_event(THD *thd, sql_exchange* ex,
|
||||
List<Item> fv;
|
||||
Item *item, *val;
|
||||
int n;
|
||||
const char *tdb= (thd->db != NULL ? thd->db : db_arg);
|
||||
const char *tdb= (thd->db.str != NULL ? thd->db.str : db_arg);
|
||||
const char *qualify_db= NULL;
|
||||
char command_buffer[1024];
|
||||
String query_str(command_buffer, sizeof(command_buffer),
|
||||
@@ -826,7 +827,7 @@ static bool write_execute_load_query_log_event(THD *thd, sql_exchange* ex,
|
||||
lle.set_fname_outside_temp_buf(ex->file_name, strlen(ex->file_name));
|
||||
|
||||
query_str.length(0);
|
||||
if (!thd->db || strcmp(db_arg, thd->db))
|
||||
if (!thd->db.str || strcmp(db_arg, thd->db.str))
|
||||
{
|
||||
/*
|
||||
If used database differs from table's database,
|
||||
@@ -853,7 +854,7 @@ static bool write_execute_load_query_log_event(THD *thd, sql_exchange* ex,
|
||||
if (n++)
|
||||
query_str.append(", ");
|
||||
if (item->real_type() == Item::FIELD_ITEM)
|
||||
append_identifier(thd, &query_str, item->name.str, item->name.length);
|
||||
append_identifier(thd, &query_str, &item->name);
|
||||
else
|
||||
{
|
||||
/* Actually Item_user_var_as_out_param despite claiming STRING_ITEM. */
|
||||
@@ -877,7 +878,7 @@ static bool write_execute_load_query_log_event(THD *thd, sql_exchange* ex,
|
||||
val= lv++;
|
||||
if (n++)
|
||||
query_str.append(STRING_WITH_LEN(", "));
|
||||
append_identifier(thd, &query_str, item->name.str, item->name.length);
|
||||
append_identifier(thd, &query_str, &item->name);
|
||||
query_str.append(&val->name);
|
||||
}
|
||||
}
|
||||
@@ -966,7 +967,7 @@ read_fixed_length(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
|
||||
*/
|
||||
while ((sql_field= (Item_field*) it++))
|
||||
{
|
||||
Field *field= sql_field->field;
|
||||
Field *field= sql_field->field;
|
||||
table->auto_increment_field_not_null= auto_increment_field_not_null;
|
||||
/*
|
||||
No fields specified in fields_vars list can be null in this format.
|
||||
|
||||
238
sql/sql_parse.cc
238
sql/sql_parse.cc
@@ -403,7 +403,7 @@ inline bool all_tables_not_ok(THD *thd, TABLE_LIST *tables)
|
||||
{
|
||||
Rpl_filter *rpl_filter= thd->system_thread_info.rpl_sql_info->rpl_filter;
|
||||
return rpl_filter->is_on() && tables && !thd->spcont &&
|
||||
!rpl_filter->tables_ok(thd->db, tables);
|
||||
!rpl_filter->tables_ok(thd->db.str, tables);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -412,7 +412,7 @@ static bool some_non_temp_table_to_be_updated(THD *thd, TABLE_LIST *tables)
|
||||
{
|
||||
for (TABLE_LIST *table= tables; table; table= table->next_global)
|
||||
{
|
||||
DBUG_ASSERT(table->db && table->table_name);
|
||||
DBUG_ASSERT(table->db.str && table->table_name.str);
|
||||
if (table->updating && !thd->find_tmp_table_share(table))
|
||||
return 1;
|
||||
}
|
||||
@@ -1015,7 +1015,7 @@ static void handle_bootstrap_impl(THD *thd)
|
||||
}
|
||||
|
||||
query= (char *) thd->memdup_w_gap(buffer, length + 1,
|
||||
thd->db_length + 1 +
|
||||
thd->db.length + 1 +
|
||||
QUERY_CACHE_DB_LENGTH_SIZE +
|
||||
QUERY_CACHE_FLAGS_SIZE);
|
||||
size_t db_len= 0;
|
||||
@@ -1670,7 +1670,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
break;
|
||||
if (!mysql_change_db(thd, &tmp, FALSE))
|
||||
{
|
||||
general_log_write(thd, command, thd->db, thd->db_length);
|
||||
general_log_write(thd, command, thd->db.str, thd->db.length);
|
||||
my_ok(thd);
|
||||
}
|
||||
break;
|
||||
@@ -1703,8 +1703,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
/* acl_authenticate() takes the data from net->read_pos */
|
||||
net->read_pos= (uchar*)packet;
|
||||
|
||||
uint save_db_length= thd->db_length;
|
||||
char *save_db= thd->db;
|
||||
LEX_CSTRING save_db= thd->db;
|
||||
USER_CONN *save_user_connect= thd->user_connect;
|
||||
Security_context save_security_ctx= *thd->security_ctx;
|
||||
CHARSET_INFO *save_character_set_client=
|
||||
@@ -1740,7 +1739,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
if (thd->user_connect)
|
||||
decrease_user_connections(thd->user_connect);
|
||||
thd->user_connect= save_user_connect;
|
||||
thd->reset_db(save_db, save_db_length);
|
||||
thd->reset_db(&save_db);
|
||||
thd->update_charset(save_character_set_client, save_collation_connection,
|
||||
save_character_set_results);
|
||||
thd->failed_com_change_user++;
|
||||
@@ -1753,7 +1752,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
if (save_user_connect)
|
||||
decrease_user_connections(save_user_connect);
|
||||
#endif /* NO_EMBEDDED_ACCESS_CHECKS */
|
||||
my_free(save_db);
|
||||
my_free((char*) save_db.str);
|
||||
my_free(const_cast<char*>(save_security_ctx.user));
|
||||
}
|
||||
break;
|
||||
@@ -1802,7 +1801,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
if (alloc_query(thd, packet, packet_length))
|
||||
break; // fatal error is set
|
||||
MYSQL_QUERY_START(thd->query(), thd->thread_id,
|
||||
(char *) (thd->db ? thd->db : ""),
|
||||
thd->get_db(),
|
||||
&thd->security_ctx->priv_user[0],
|
||||
(char *) thd->security_ctx->host_or_ip);
|
||||
char *packet_end= thd->query() + thd->query_length();
|
||||
@@ -1880,7 +1879,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
|
||||
/* DTRACE begin */
|
||||
MYSQL_QUERY_START(beginning_of_next_stmt, thd->thread_id,
|
||||
(char *) (thd->db ? thd->db : ""),
|
||||
thd->get_db(),
|
||||
&thd->security_ctx->priv_user[0],
|
||||
(char *) thd->security_ctx->host_or_ip);
|
||||
|
||||
@@ -1889,7 +1888,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
|
||||
thd->m_statement_psi= MYSQL_START_STATEMENT(&thd->m_statement_state,
|
||||
com_statement_info[command].m_key,
|
||||
thd->db, thd->db_length,
|
||||
thd->db.str, thd->db.length,
|
||||
thd->charset());
|
||||
THD_STAGE_INFO(thd, stage_init);
|
||||
MYSQL_SET_STATEMENT_TEXT(thd->m_statement_psi, beginning_of_next_stmt,
|
||||
@@ -1939,7 +1938,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
MDL_savepoint mdl_savepoint= thd->mdl_context.mdl_savepoint();
|
||||
|
||||
status_var_increment(thd->status_var.com_stat[SQLCOM_SHOW_FIELDS]);
|
||||
if (thd->copy_db_to(&db.str, &db.length))
|
||||
if (thd->copy_db_to(&db))
|
||||
break;
|
||||
/*
|
||||
We have name + wildcard in packet, separated by endzero
|
||||
@@ -1979,8 +1978,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
table_name.length= my_casedn_str(files_charset_info, table_name.str);
|
||||
db.length= my_casedn_str(files_charset_info, (char*) db.str);
|
||||
}
|
||||
table_list.init_one_table(db.str, db.length, table_name.str,
|
||||
table_name.length, table_name.str, TL_READ);
|
||||
table_list.init_one_table(&db, (LEX_CSTRING*) &table_name, 0, TL_READ);
|
||||
/*
|
||||
Init TABLE_LIST members necessary when the undelrying
|
||||
table is view.
|
||||
@@ -1991,9 +1989,9 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
&table_list.next_local);
|
||||
thd->lex->add_to_query_tables(&table_list);
|
||||
|
||||
if (is_infoschema_db(table_list.db, table_list.db_length))
|
||||
if (is_infoschema_db(&table_list.db))
|
||||
{
|
||||
ST_SCHEMA_TABLE *schema_table= find_schema_table(thd, table_list.alias);
|
||||
ST_SCHEMA_TABLE *schema_table= find_schema_table(thd, &table_list.alias);
|
||||
if (schema_table)
|
||||
table_list.schema_table= schema_table;
|
||||
}
|
||||
@@ -2002,7 +2000,8 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
if (!(fields= (char *) thd->memdup(packet, query_length + 1)))
|
||||
break;
|
||||
thd->set_query(fields, query_length);
|
||||
general_log_print(thd, command, "%s %s", table_list.table_name, fields);
|
||||
general_log_print(thd, command, "%s %s", table_list.table_name.str,
|
||||
fields);
|
||||
|
||||
if (thd->open_temporary_tables(&table_list))
|
||||
break;
|
||||
@@ -2549,27 +2548,23 @@ int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident,
|
||||
DBUG_RETURN(1);
|
||||
#else
|
||||
{
|
||||
LEX_STRING db;
|
||||
size_t dummy;
|
||||
if (lex->select_lex.db == NULL &&
|
||||
lex->copy_db_to(&lex->select_lex.db, &dummy))
|
||||
if (lex->select_lex.db.str == NULL &&
|
||||
lex->copy_db_to(&lex->select_lex.db))
|
||||
{
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
schema_select_lex= new (thd->mem_root) SELECT_LEX();
|
||||
schema_select_lex->table_list.first= NULL;
|
||||
if (lower_case_table_names == 1)
|
||||
lex->select_lex.db= thd->strdup(lex->select_lex.db);
|
||||
lex->select_lex.db.str= thd->strdup(lex->select_lex.db.str);
|
||||
schema_select_lex->db= lex->select_lex.db;
|
||||
/*
|
||||
check_db_name() may change db.str if lower_case_table_names == 1,
|
||||
but that's ok as the db is allocted above in this case.
|
||||
*/
|
||||
db.str= (char*) lex->select_lex.db;
|
||||
db.length= strlen(db.str);
|
||||
if (check_db_name(&db))
|
||||
if (check_db_name((LEX_STRING*) &lex->select_lex.db))
|
||||
{
|
||||
my_error(ER_WRONG_DB_NAME, MYF(0), db.str);
|
||||
my_error(ER_WRONG_DB_NAME, MYF(0), lex->select_lex.db.str);
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
break;
|
||||
@@ -2660,7 +2655,7 @@ bool alloc_query(THD *thd, const char *packet, uint packet_length)
|
||||
*/
|
||||
if (! (query= (char*) thd->memdup_w_gap(packet,
|
||||
packet_length,
|
||||
1 + thd->db_length +
|
||||
1 + thd->db.length +
|
||||
QUERY_CACHE_DB_LENGTH_SIZE +
|
||||
QUERY_CACHE_FLAGS_SIZE)))
|
||||
return TRUE;
|
||||
@@ -2670,7 +2665,7 @@ bool alloc_query(THD *thd, const char *packet, uint packet_length)
|
||||
also store this length, in case current database is changed during
|
||||
execution. We might need to reallocate the 'query' buffer
|
||||
*/
|
||||
int2store(query + packet_length + 1, thd->db_length);
|
||||
int2store(query + packet_length + 1, thd->db.length);
|
||||
|
||||
thd->set_query(query, packet_length);
|
||||
|
||||
@@ -2963,8 +2958,8 @@ static int mysql_create_routine(THD *thd, LEX *lex)
|
||||
/* Checking the drop permissions if CREATE OR REPLACE is used */
|
||||
if (lex->create_info.or_replace())
|
||||
{
|
||||
if (check_routine_access(thd, ALTER_PROC_ACL, lex->sphead->m_db.str,
|
||||
lex->sphead->m_name.str,
|
||||
if (check_routine_access(thd, ALTER_PROC_ACL, &lex->sphead->m_db,
|
||||
&lex->sphead->m_name,
|
||||
Sp_handler::handler(lex->sql_command), 0))
|
||||
return true;
|
||||
}
|
||||
@@ -3033,7 +3028,7 @@ static int mysql_create_routine(THD *thd, LEX *lex)
|
||||
|
||||
if (sp_automatic_privileges && !opt_noacl &&
|
||||
check_routine_access(thd, DEFAULT_CREATE_PROC_ACLS,
|
||||
lex->sphead->m_db.str, name->str,
|
||||
&lex->sphead->m_db, name,
|
||||
Sp_handler::handler(lex->sql_command), 1))
|
||||
{
|
||||
if (sp_grant_privileges(thd, lex->sphead->m_db.str, name->str,
|
||||
@@ -3134,8 +3129,8 @@ bool Sql_cmd_call::execute(THD *thd)
|
||||
If the routine is not found, let's still check EXECUTE_ACL to decide
|
||||
whether to return "Access denied" or "Routine does not exist".
|
||||
*/
|
||||
if (check_routine_access(thd, EXECUTE_ACL, m_name->m_db.str,
|
||||
m_name->m_name.str,
|
||||
if (check_routine_access(thd, EXECUTE_ACL, &m_name->m_db,
|
||||
&m_name->m_name,
|
||||
&sp_handler_procedure,
|
||||
false))
|
||||
return true;
|
||||
@@ -3869,7 +3864,7 @@ mysql_execute_command(THD *thd)
|
||||
case SQLCOM_ASSIGN_TO_KEYCACHE:
|
||||
{
|
||||
DBUG_ASSERT(first_table == all_tables && first_table != 0);
|
||||
if (check_access(thd, INDEX_ACL, first_table->db,
|
||||
if (check_access(thd, INDEX_ACL, first_table->db.str,
|
||||
&first_table->grant.privilege,
|
||||
&first_table->grant.m_internal,
|
||||
0, 0))
|
||||
@@ -3880,7 +3875,7 @@ mysql_execute_command(THD *thd)
|
||||
case SQLCOM_PRELOAD_KEYS:
|
||||
{
|
||||
DBUG_ASSERT(first_table == all_tables && first_table != 0);
|
||||
if (check_access(thd, INDEX_ACL, first_table->db,
|
||||
if (check_access(thd, INDEX_ACL, first_table->db.str,
|
||||
&first_table->grant.privilege,
|
||||
&first_table->grant.m_internal,
|
||||
0, 0))
|
||||
@@ -4043,9 +4038,9 @@ mysql_execute_command(THD *thd)
|
||||
|
||||
/* Fix names if symlinked or relocated tables */
|
||||
if (append_file_to_dir(thd, &create_info.data_file_name,
|
||||
create_table->table_name) ||
|
||||
&create_table->table_name) ||
|
||||
append_file_to_dir(thd, &create_info.index_file_name,
|
||||
create_table->table_name))
|
||||
&create_table->table_name))
|
||||
goto end_with_restore_list;
|
||||
|
||||
/*
|
||||
@@ -4158,8 +4153,8 @@ mysql_execute_command(THD *thd)
|
||||
*/
|
||||
if (create_info.used_fields & HA_CREATE_USED_UNION)
|
||||
{
|
||||
my_error(ER_WRONG_OBJECT, MYF(0), create_table->db,
|
||||
create_table->table_name, "BASE TABLE");
|
||||
my_error(ER_WRONG_OBJECT, MYF(0), create_table->db.str,
|
||||
create_table->table_name.str, "BASE TABLE");
|
||||
res= 1;
|
||||
goto end_with_restore_list;
|
||||
}
|
||||
@@ -4250,12 +4245,12 @@ mysql_execute_command(THD *thd)
|
||||
engine is allowed/supported.
|
||||
*/
|
||||
if (WSREP(thd) &&
|
||||
!check_engine(thd, create_table->db, create_table->table_name,
|
||||
!check_engine(thd, create_table->db.str, create_table->table_name.str,
|
||||
&create_info) &&
|
||||
(!thd->is_current_stmt_binlog_format_row() ||
|
||||
!create_info.tmp_table()))
|
||||
{
|
||||
WSREP_TO_ISOLATION_BEGIN(create_table->db, create_table->table_name, NULL);
|
||||
WSREP_TO_ISOLATION_BEGIN(create_table->db.str, create_table->table_name.str, NULL);
|
||||
}
|
||||
/* Regular CREATE TABLE */
|
||||
res= mysql_create_table(thd, create_table, &create_info, &alter_info);
|
||||
@@ -4300,7 +4295,7 @@ end_with_restore_list:
|
||||
DBUG_ASSERT(first_table == all_tables && first_table != 0);
|
||||
if (check_one_table_access(thd, INDEX_ACL, all_tables))
|
||||
goto error; /* purecov: inspected */
|
||||
WSREP_TO_ISOLATION_BEGIN(first_table->db, first_table->table_name, NULL);
|
||||
WSREP_TO_ISOLATION_BEGIN(first_table->db.str, first_table->table_name.str, NULL);
|
||||
/*
|
||||
Currently CREATE INDEX or DROP INDEX cause a full table rebuild
|
||||
and thus classify as slow administrative statements just like
|
||||
@@ -4313,7 +4308,7 @@ end_with_restore_list:
|
||||
create_info.row_type= ROW_TYPE_NOT_USED;
|
||||
create_info.default_table_charset= thd->variables.collation_database;
|
||||
|
||||
res= mysql_alter_table(thd, first_table->db, first_table->table_name,
|
||||
res= mysql_alter_table(thd, &first_table->db, &first_table->table_name,
|
||||
&create_info, first_table, &alter_info,
|
||||
0, (ORDER*) 0, 0);
|
||||
break;
|
||||
@@ -4468,7 +4463,7 @@ end_with_restore_list:
|
||||
|
||||
DBUG_PRINT("debug", ("lex->only_view: %d, table: %s.%s",
|
||||
lex->table_type == TABLE_TYPE_VIEW,
|
||||
first_table->db, first_table->table_name));
|
||||
first_table->db.str, first_table->table_name.str));
|
||||
if (lex->table_type == TABLE_TYPE_VIEW)
|
||||
{
|
||||
if (check_table_access(thd, SELECT_ACL, first_table, FALSE, 1, FALSE))
|
||||
@@ -4476,7 +4471,7 @@ end_with_restore_list:
|
||||
DBUG_PRINT("debug", ("check_table_access failed"));
|
||||
my_error(ER_TABLEACCESS_DENIED_ERROR, MYF(0),
|
||||
"SHOW", thd->security_ctx->priv_user,
|
||||
thd->security_ctx->host_or_ip, first_table->alias);
|
||||
thd->security_ctx->host_or_ip, first_table->alias.str);
|
||||
goto error;
|
||||
}
|
||||
DBUG_PRINT("debug", ("check_table_access succeeded"));
|
||||
@@ -4505,7 +4500,7 @@ end_with_restore_list:
|
||||
{
|
||||
my_error(ER_TABLEACCESS_DENIED_ERROR, MYF(0),
|
||||
"SHOW", thd->security_ctx->priv_user,
|
||||
thd->security_ctx->host_or_ip, first_table->alias);
|
||||
thd->security_ctx->host_or_ip, first_table->alias.str);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
@@ -4753,7 +4748,7 @@ end_with_restore_list:
|
||||
if (WSREP(thd) && thd->wsrep_consistency_check == CONSISTENCY_CHECK_DECLARED)
|
||||
{
|
||||
thd->wsrep_consistency_check = CONSISTENCY_CHECK_RUNNING;
|
||||
WSREP_TO_ISOLATION_BEGIN(first_table->db, first_table->table_name, NULL);
|
||||
WSREP_TO_ISOLATION_BEGIN(first_table->db.str, first_table->table_name.str, NULL);
|
||||
}
|
||||
#endif /* WITH_WSREP */
|
||||
|
||||
@@ -5077,9 +5072,7 @@ end_with_restore_list:
|
||||
#endif
|
||||
case SQLCOM_CHANGE_DB:
|
||||
{
|
||||
LEX_CSTRING db_str= { (char *) select_lex->db, strlen(select_lex->db) };
|
||||
|
||||
if (!mysql_change_db(thd, &db_str, FALSE))
|
||||
if (!mysql_change_db(thd, &select_lex->db, FALSE))
|
||||
my_ok(thd);
|
||||
|
||||
break;
|
||||
@@ -5206,7 +5199,7 @@ end_with_restore_list:
|
||||
&lex->name))
|
||||
break;
|
||||
WSREP_TO_ISOLATION_BEGIN(lex->name.str, NULL, NULL);
|
||||
res= mysql_create_db(thd, lex->name.str,
|
||||
res= mysql_create_db(thd, &lex->name,
|
||||
lex->create_info, &lex->create_info);
|
||||
break;
|
||||
}
|
||||
@@ -5215,7 +5208,7 @@ end_with_restore_list:
|
||||
if (prepare_db_action(thd, DROP_ACL, &lex->name))
|
||||
break;
|
||||
WSREP_TO_ISOLATION_BEGIN(lex->name.str, NULL, NULL);
|
||||
res= mysql_rm_db(thd, lex->name.str, lex->if_exists());
|
||||
res= mysql_rm_db(thd, &lex->name, lex->if_exists());
|
||||
break;
|
||||
}
|
||||
case SQLCOM_ALTER_DB_UPGRADE:
|
||||
@@ -5258,7 +5251,7 @@ end_with_restore_list:
|
||||
if (prepare_db_action(thd, ALTER_ACL, db))
|
||||
break;
|
||||
WSREP_TO_ISOLATION_BEGIN(db->str, NULL, NULL);
|
||||
res= mysql_alter_db(thd, db->str, &lex->create_info);
|
||||
res= mysql_alter_db(thd, db, &lex->create_info);
|
||||
break;
|
||||
}
|
||||
case SQLCOM_SHOW_CREATE_DB:
|
||||
@@ -5418,7 +5411,7 @@ end_with_restore_list:
|
||||
{
|
||||
if (lex->type != TYPE_ENUM_PROXY &&
|
||||
check_access(thd, lex->grant | lex->grant_tot_col | GRANT_ACL,
|
||||
first_table ? first_table->db : select_lex->db,
|
||||
first_table ? first_table->db.str : select_lex->db.str,
|
||||
first_table ? &first_table->grant.privilege : NULL,
|
||||
first_table ? &first_table->grant.m_internal : NULL,
|
||||
first_table ? 0 : 1, 0))
|
||||
@@ -5499,7 +5492,7 @@ end_with_restore_list:
|
||||
{
|
||||
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL);
|
||||
/* Conditionally writes to binlog */
|
||||
res= mysql_grant(thd, select_lex->db, lex->users_list, lex->grant,
|
||||
res= mysql_grant(thd, select_lex->db.str, lex->users_list, lex->grant,
|
||||
lex->sql_command == SQLCOM_REVOKE,
|
||||
lex->type == TYPE_ENUM_PROXY);
|
||||
}
|
||||
@@ -5884,8 +5877,8 @@ end_with_restore_list:
|
||||
{
|
||||
int sp_result;
|
||||
const Sp_handler *sph= Sp_handler::handler(lex->sql_command);
|
||||
if (check_routine_access(thd, ALTER_PROC_ACL, lex->spname->m_db.str,
|
||||
lex->spname->m_name.str, sph, 0))
|
||||
if (check_routine_access(thd, ALTER_PROC_ACL, &lex->spname->m_db,
|
||||
&lex->spname->m_name, sph, 0))
|
||||
goto error;
|
||||
|
||||
/*
|
||||
@@ -5958,10 +5951,8 @@ end_with_restore_list:
|
||||
|
||||
int sp_result;
|
||||
const Sp_handler *sph= Sp_handler::handler(lex->sql_command);
|
||||
const char *db= lex->spname->m_db.str;
|
||||
const char *name= lex->spname->m_name.str;
|
||||
|
||||
if (check_routine_access(thd, ALTER_PROC_ACL, db, name,
|
||||
if (check_routine_access(thd, ALTER_PROC_ACL, &lex->spname->m_db, &lex->spname->m_name,
|
||||
Sp_handler::handler(lex->sql_command), 0))
|
||||
goto error;
|
||||
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL);
|
||||
@@ -5990,7 +5981,7 @@ end_with_restore_list:
|
||||
|
||||
if (sp_result != SP_KEY_NOT_FOUND &&
|
||||
sp_automatic_privileges && !opt_noacl &&
|
||||
sp_revoke_privileges(thd, db, name,
|
||||
sp_revoke_privileges(thd, lex->spname->m_db.str, lex->spname->m_name.str,
|
||||
Sp_handler::handler(lex->sql_command)))
|
||||
{
|
||||
push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
|
||||
@@ -6587,11 +6578,11 @@ static bool check_rename_table(THD *thd, TABLE_LIST *first_table,
|
||||
TABLE_LIST *table;
|
||||
for (table= first_table; table; table= table->next_local->next_local)
|
||||
{
|
||||
if (check_access(thd, ALTER_ACL | DROP_ACL, table->db,
|
||||
if (check_access(thd, ALTER_ACL | DROP_ACL, table->db.str,
|
||||
&table->grant.privilege,
|
||||
&table->grant.m_internal,
|
||||
0, 0) ||
|
||||
check_access(thd, INSERT_ACL | CREATE_ACL, table->next_local->db,
|
||||
check_access(thd, INSERT_ACL | CREATE_ACL, table->next_local->db.str,
|
||||
&table->next_local->grant.privilege,
|
||||
&table->next_local->grant.m_internal,
|
||||
0, 0))
|
||||
@@ -6681,7 +6672,7 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv,
|
||||
/* check access may be called twice in a row. Don't change to same stage */
|
||||
if (thd->proc_info != stage_checking_permissions.m_name)
|
||||
THD_STAGE_INFO(thd, stage_checking_permissions);
|
||||
if ((!db || !db[0]) && !thd->db && !dont_check_global_grants)
|
||||
if ((!db || !db[0]) && !thd->db.str && !dont_check_global_grants)
|
||||
{
|
||||
DBUG_PRINT("error",("No database"));
|
||||
if (!no_errors)
|
||||
@@ -6737,7 +6728,7 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv,
|
||||
*/
|
||||
if (!(sctx->master_access & SELECT_ACL))
|
||||
{
|
||||
if (db && (!thd->db || db_is_pattern || strcmp(db, thd->db)))
|
||||
if (db && (!thd->db.str || db_is_pattern || strcmp(db, thd->db.str)))
|
||||
{
|
||||
db_access= acl_get(sctx->host, sctx->ip, sctx->priv_user, db,
|
||||
db_is_pattern);
|
||||
@@ -6786,7 +6777,7 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv,
|
||||
DBUG_RETURN(FALSE);
|
||||
}
|
||||
|
||||
if (db && (!thd->db || db_is_pattern || strcmp(db,thd->db)))
|
||||
if (db && (!thd->db.str || db_is_pattern || strcmp(db, thd->db.str)))
|
||||
{
|
||||
db_access= acl_get(sctx->host, sctx->ip, sctx->priv_user, db,
|
||||
db_is_pattern);
|
||||
@@ -6841,8 +6832,8 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv,
|
||||
status_var_increment(thd->status_var.access_denied_errors);
|
||||
my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
|
||||
sctx->priv_user, sctx->priv_host,
|
||||
(db ? db : (thd->db ?
|
||||
thd->db :
|
||||
(db ? db : (thd->db.str ?
|
||||
thd->db.str :
|
||||
"unknown")));
|
||||
}
|
||||
DBUG_RETURN(TRUE);
|
||||
@@ -6880,7 +6871,7 @@ bool check_single_table_access(THD *thd, ulong privilege,
|
||||
!all_tables->schema_table)
|
||||
db_name= all_tables->view_db.str;
|
||||
else
|
||||
db_name= all_tables->db;
|
||||
db_name= all_tables->db.str;
|
||||
|
||||
if (check_access(thd, privilege, db_name,
|
||||
&all_tables->grant.privilege,
|
||||
@@ -6969,7 +6960,7 @@ static bool check_show_access(THD *thd, TABLE_LIST *table)
|
||||
case SCH_TRIGGERS:
|
||||
case SCH_EVENTS:
|
||||
{
|
||||
const char *dst_db_name= table->schema_select_lex->db;
|
||||
const char *dst_db_name= table->schema_select_lex->db.str;
|
||||
|
||||
DBUG_ASSERT(dst_db_name);
|
||||
|
||||
@@ -7004,7 +6995,7 @@ static bool check_show_access(THD *thd, TABLE_LIST *table)
|
||||
if (thd->open_temporary_tables(dst_table))
|
||||
return TRUE;
|
||||
|
||||
if (check_access(thd, SELECT_ACL, dst_table->db,
|
||||
if (check_access(thd, SELECT_ACL, dst_table->db.str,
|
||||
&dst_table->grant.privilege,
|
||||
&dst_table->grant.m_internal,
|
||||
FALSE, FALSE))
|
||||
@@ -7140,15 +7131,15 @@ deny:
|
||||
|
||||
|
||||
bool
|
||||
check_routine_access(THD *thd, ulong want_access, const char *db,
|
||||
const char *name,
|
||||
check_routine_access(THD *thd, ulong want_access, const LEX_CSTRING *db,
|
||||
const LEX_CSTRING *name,
|
||||
const Sp_handler *sph, bool no_errors)
|
||||
{
|
||||
TABLE_LIST tables[1];
|
||||
|
||||
bzero((char *)tables, sizeof(TABLE_LIST));
|
||||
tables->db= db;
|
||||
tables->table_name= tables->alias= name;
|
||||
tables->db= *db;
|
||||
tables->table_name= tables->alias= *name;
|
||||
|
||||
/*
|
||||
The following test is just a shortcut for check_access() (to avoid
|
||||
@@ -7165,7 +7156,7 @@ check_routine_access(THD *thd, ulong want_access, const char *db,
|
||||
DBUG_ASSERT((want_access & CREATE_PROC_ACL) == 0);
|
||||
if ((thd->security_ctx->master_access & want_access) == want_access)
|
||||
tables->grant.privilege= want_access;
|
||||
else if (check_access(thd, want_access, db,
|
||||
else if (check_access(thd, want_access, db->str,
|
||||
&tables->grant.privilege,
|
||||
&tables->grant.m_internal,
|
||||
0, no_errors))
|
||||
@@ -7232,7 +7223,7 @@ bool check_some_access(THD *thd, ulong want_access, TABLE_LIST *table)
|
||||
{
|
||||
if (access & want_access)
|
||||
{
|
||||
if (!check_access(thd, access, table->db,
|
||||
if (!check_access(thd, access, table->db.str,
|
||||
&table->grant.privilege,
|
||||
&table->grant.m_internal,
|
||||
0, 1) &&
|
||||
@@ -7345,7 +7336,7 @@ bool check_fk_parent_table_access(THD *thd,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!thd->db)
|
||||
if (!thd->db.str)
|
||||
{
|
||||
DBUG_ASSERT(create_db);
|
||||
db_name.length= strlen(create_db);
|
||||
@@ -7362,7 +7353,7 @@ bool check_fk_parent_table_access(THD *thd,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (thd->lex->copy_db_to(&db_name.str, &db_name.length))
|
||||
if (thd->lex->copy_db_to(&db_name))
|
||||
return true;
|
||||
else
|
||||
is_qualified_table_name= false;
|
||||
@@ -7379,9 +7370,7 @@ bool check_fk_parent_table_access(THD *thd,
|
||||
db_name.length= my_casedn_str(files_charset_info, (char*) db_name.str);
|
||||
}
|
||||
|
||||
parent_table.init_one_table(db_name.str, db_name.length,
|
||||
table_name.str, table_name.length,
|
||||
table_name.str, TL_IGNORE);
|
||||
parent_table.init_one_table(&db_name, &table_name, 0, TL_IGNORE);
|
||||
|
||||
/*
|
||||
Check if user has any of the "privileges" at table level on
|
||||
@@ -7980,7 +7969,7 @@ void mysql_parse(THD *thd, char *rawbuf, uint length,
|
||||
lex->set_trg_event_type_for_tables();
|
||||
MYSQL_QUERY_EXEC_START(thd->query(),
|
||||
thd->thread_id,
|
||||
(char *) (thd->db ? thd->db : ""),
|
||||
thd->get_db(),
|
||||
&thd->security_ctx->priv_user[0],
|
||||
(char *) thd->security_ctx->host_or_ip,
|
||||
0);
|
||||
@@ -8132,13 +8121,14 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
|
||||
{
|
||||
register TABLE_LIST *ptr;
|
||||
TABLE_LIST *UNINIT_VAR(previous_table_ref); /* The table preceding the current one. */
|
||||
const char *alias_str;
|
||||
LEX_CSTRING alias_str;
|
||||
LEX *lex= thd->lex;
|
||||
DBUG_ENTER("add_table_to_list");
|
||||
|
||||
if (!table)
|
||||
DBUG_RETURN(0); // End of memory
|
||||
alias_str= alias ? alias->str : table->table.str;
|
||||
alias_str= alias ? *alias : table->table;
|
||||
DBUG_ASSERT(alias_str.str);
|
||||
if (!MY_TEST(table_options & TL_OPTION_ALIAS) &&
|
||||
check_table_name(table->table.str, table->table.length, FALSE))
|
||||
{
|
||||
@@ -8153,7 +8143,7 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
if (!alias) /* Alias is case sensitive */
|
||||
if (!alias) /* Alias is case sensitive */
|
||||
{
|
||||
if (table->sel)
|
||||
{
|
||||
@@ -8161,7 +8151,8 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
|
||||
ER_THD(thd, ER_DERIVED_MUST_HAVE_ALIAS), MYF(0));
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
if (!(alias_str= (char*) thd->memdup(alias_str,table->table.length+1)))
|
||||
/* alias_str points to table->table; Let's make a copy */
|
||||
if (!(alias_str.str= (char*) thd->memdup(alias_str.str, alias_str.length+1)))
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
if (!(ptr = (TABLE_LIST *) thd->calloc(sizeof(TABLE_LIST))))
|
||||
@@ -8169,10 +8160,9 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
|
||||
if (table->db.str)
|
||||
{
|
||||
ptr->is_fqtn= TRUE;
|
||||
ptr->db= table->db.str;
|
||||
ptr->db_length= table->db.length;
|
||||
ptr->db= table->db;
|
||||
}
|
||||
else if (lex->copy_db_to(&ptr->db, &ptr->db_length))
|
||||
else if (lex->copy_db_to(&ptr->db))
|
||||
DBUG_RETURN(0);
|
||||
else
|
||||
ptr->is_fqtn= FALSE;
|
||||
@@ -8184,12 +8174,11 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
|
||||
if (table->table.length)
|
||||
table->table.length= my_casedn_str(files_charset_info,
|
||||
(char*) table->table.str);
|
||||
if (ptr->db_length && ptr->db != any_db)
|
||||
ptr->db_length= my_casedn_str(files_charset_info, (char*) ptr->db);
|
||||
if (ptr->db.length && ptr->db.str != any_db)
|
||||
ptr->db.length= my_casedn_str(files_charset_info, (char*) ptr->db.str);
|
||||
}
|
||||
|
||||
ptr->table_name=table->table.str;
|
||||
ptr->table_name_length=table->table.length;
|
||||
ptr->table_name= table->table;
|
||||
ptr->lock_type= lock_type;
|
||||
ptr->updating= MY_TEST(table_options & TL_OPTION_UPDATING);
|
||||
/* TODO: remove TL_OPTION_FORCE_INDEX as it looks like it's not used */
|
||||
@@ -8197,7 +8186,7 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
|
||||
ptr->ignore_leaves= MY_TEST(table_options & TL_OPTION_IGNORE_LEAVES);
|
||||
ptr->sequence= MY_TEST(table_options & TL_OPTION_SEQUENCE);
|
||||
ptr->derived= table->sel;
|
||||
if (!ptr->derived && is_infoschema_db(ptr->db, ptr->db_length))
|
||||
if (!ptr->derived && is_infoschema_db(&ptr->db))
|
||||
{
|
||||
ST_SCHEMA_TABLE *schema_table;
|
||||
if (ptr->updating &&
|
||||
@@ -8211,7 +8200,7 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
|
||||
INFORMATION_SCHEMA_NAME.str);
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
schema_table= find_schema_table(thd, ptr->table_name);
|
||||
schema_table= find_schema_table(thd, &ptr->table_name);
|
||||
if (!schema_table ||
|
||||
(schema_table->hidden &&
|
||||
((sql_command_flags[lex->sql_command] & CF_STATUS_COMMAND) == 0 ||
|
||||
@@ -8222,7 +8211,7 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
|
||||
lex->sql_command == SQLCOM_SHOW_KEYS)))
|
||||
{
|
||||
my_error(ER_UNKNOWN_TABLE, MYF(0),
|
||||
ptr->table_name, INFORMATION_SCHEMA_NAME.str);
|
||||
ptr->table_name.str, INFORMATION_SCHEMA_NAME.str);
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
ptr->schema_table_name= ptr->table_name;
|
||||
@@ -8246,10 +8235,10 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
|
||||
tables ;
|
||||
tables=tables->next_local)
|
||||
{
|
||||
if (!my_strcasecmp(table_alias_charset, alias_str, tables->alias) &&
|
||||
!strcmp(ptr->db, tables->db) && ! tables->sequence)
|
||||
if (!my_strcasecmp(table_alias_charset, alias_str.str, tables->alias.str) &&
|
||||
!cmp(&ptr->db, &tables->db) && ! tables->sequence)
|
||||
{
|
||||
my_error(ER_NONUNIQ_TABLE, MYF(0), alias_str); /* purecov: tested */
|
||||
my_error(ER_NONUNIQ_TABLE, MYF(0), alias_str.str); /* purecov: tested */
|
||||
DBUG_RETURN(0); /* purecov: tested */
|
||||
}
|
||||
}
|
||||
@@ -8295,7 +8284,8 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
|
||||
// Pure table aliases do not need to be locked:
|
||||
if (!MY_TEST(table_options & TL_OPTION_ALIAS))
|
||||
{
|
||||
ptr->mdl_request.init(MDL_key::TABLE, ptr->db, ptr->table_name, mdl_type,
|
||||
ptr->mdl_request.init(MDL_key::TABLE, ptr->db.str, ptr->table_name.str,
|
||||
mdl_type,
|
||||
MDL_TRANSACTION);
|
||||
}
|
||||
DBUG_RETURN(ptr);
|
||||
@@ -8336,7 +8326,8 @@ bool st_select_lex::init_nested_join(THD *thd)
|
||||
join_list->push_front(ptr, thd->mem_root);
|
||||
ptr->embedding= embedding;
|
||||
ptr->join_list= join_list;
|
||||
ptr->alias= (char*) "(nested_join)";
|
||||
ptr->alias.str="(nested_join)";
|
||||
ptr->alias.length= sizeof("(nested_join)")-1;
|
||||
embedding= ptr;
|
||||
join_list= &nested_join->join_list;
|
||||
join_list->empty();
|
||||
@@ -8416,7 +8407,8 @@ TABLE_LIST *st_select_lex::nest_last_join(THD *thd)
|
||||
|
||||
ptr->embedding= embedding;
|
||||
ptr->join_list= join_list;
|
||||
ptr->alias= (char*) "(nest_last_join)";
|
||||
ptr->alias.str= "(nest_last_join)";
|
||||
ptr->alias.length= sizeof("(nest_last_join)")-1;
|
||||
embedded_list= &nested_join->join_list;
|
||||
embedded_list->empty();
|
||||
|
||||
@@ -9017,14 +9009,14 @@ void sql_kill_user(THD *thd, LEX_USER *user, killed_state state)
|
||||
/** If pointer is not a null pointer, append filename to it. */
|
||||
|
||||
bool append_file_to_dir(THD *thd, const char **filename_ptr,
|
||||
const char *table_name)
|
||||
const LEX_CSTRING *table_name)
|
||||
{
|
||||
char buff[FN_REFLEN],*ptr, *end;
|
||||
if (!*filename_ptr)
|
||||
return 0; // nothing to do
|
||||
|
||||
/* Check that the filename is not too long and it's a hard path */
|
||||
if (strlen(*filename_ptr)+strlen(table_name) >= FN_REFLEN-1 ||
|
||||
if (strlen(*filename_ptr)+table_name->length >= FN_REFLEN-1 ||
|
||||
!test_if_hard_path(*filename_ptr))
|
||||
{
|
||||
my_error(ER_WRONG_TABLE_NAME, MYF(0), *filename_ptr);
|
||||
@@ -9033,10 +9025,10 @@ bool append_file_to_dir(THD *thd, const char **filename_ptr,
|
||||
/* Fix is using unix filename format on dos */
|
||||
strmov(buff,*filename_ptr);
|
||||
end=convert_dirname(buff, *filename_ptr, NullS);
|
||||
if (!(ptr= (char*) thd->alloc((size_t) (end-buff) + strlen(table_name)+1)))
|
||||
if (!(ptr= (char*) thd->alloc((size_t) (end-buff) + table_name->length + 1)))
|
||||
return 1; // End of memory
|
||||
*filename_ptr=ptr;
|
||||
strxmov(ptr,buff,table_name,NullS);
|
||||
strxmov(ptr,buff,table_name->str,NullS);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -9171,12 +9163,12 @@ bool multi_update_precheck(THD *thd, TABLE_LIST *tables)
|
||||
continue;
|
||||
if (table->derived)
|
||||
table->grant.privilege= SELECT_ACL;
|
||||
else if ((check_access(thd, UPDATE_ACL, table->db,
|
||||
else if ((check_access(thd, UPDATE_ACL, table->db.str,
|
||||
&table->grant.privilege,
|
||||
&table->grant.m_internal,
|
||||
0, 1) ||
|
||||
check_grant(thd, UPDATE_ACL, table, FALSE, 1, TRUE)) &&
|
||||
(check_access(thd, SELECT_ACL, table->db,
|
||||
(check_access(thd, SELECT_ACL, table->db.str,
|
||||
&table->grant.privilege,
|
||||
&table->grant.m_internal,
|
||||
0, 0) ||
|
||||
@@ -9196,7 +9188,7 @@ bool multi_update_precheck(THD *thd, TABLE_LIST *tables)
|
||||
{
|
||||
if (!table->table_in_first_from_clause)
|
||||
{
|
||||
if (check_access(thd, SELECT_ACL, table->db,
|
||||
if (check_access(thd, SELECT_ACL, table->db.str,
|
||||
&table->grant.privilege,
|
||||
&table->grant.m_internal,
|
||||
0, 0) ||
|
||||
@@ -9294,25 +9286,25 @@ static TABLE_LIST *multi_delete_table_match(LEX *lex, TABLE_LIST *tbl,
|
||||
|
||||
for (TABLE_LIST *elem= tables; elem; elem= elem->next_local)
|
||||
{
|
||||
int cmp;
|
||||
int res;
|
||||
|
||||
if (tbl->is_fqtn && elem->is_alias)
|
||||
continue; /* no match */
|
||||
if (tbl->is_fqtn && elem->is_fqtn)
|
||||
cmp= my_strcasecmp(table_alias_charset, tbl->table_name, elem->table_name) ||
|
||||
strcmp(tbl->db, elem->db);
|
||||
res= (my_strcasecmp(table_alias_charset, tbl->table_name.str, elem->table_name.str) ||
|
||||
cmp(&tbl->db, &elem->db));
|
||||
else if (elem->is_alias)
|
||||
cmp= my_strcasecmp(table_alias_charset, tbl->alias, elem->alias);
|
||||
res= my_strcasecmp(table_alias_charset, tbl->alias.str, elem->alias.str);
|
||||
else
|
||||
cmp= my_strcasecmp(table_alias_charset, tbl->table_name, elem->table_name) ||
|
||||
strcmp(tbl->db, elem->db);
|
||||
res= (my_strcasecmp(table_alias_charset, tbl->table_name.str, elem->table_name.str) ||
|
||||
cmp(&tbl->db, &elem->db));
|
||||
|
||||
if (cmp)
|
||||
if (res)
|
||||
continue;
|
||||
|
||||
if (match)
|
||||
{
|
||||
my_error(ER_NONUNIQ_TABLE, MYF(0), elem->alias);
|
||||
my_error(ER_NONUNIQ_TABLE, MYF(0), elem->alias.str);
|
||||
DBUG_RETURN(NULL);
|
||||
}
|
||||
|
||||
@@ -9320,7 +9312,7 @@ static TABLE_LIST *multi_delete_table_match(LEX *lex, TABLE_LIST *tbl,
|
||||
}
|
||||
|
||||
if (!match)
|
||||
my_error(ER_UNKNOWN_TABLE, MYF(0), tbl->table_name, "MULTI DELETE");
|
||||
my_error(ER_UNKNOWN_TABLE, MYF(0), tbl->table_name.str, "MULTI DELETE");
|
||||
|
||||
DBUG_RETURN(match);
|
||||
}
|
||||
@@ -9355,10 +9347,7 @@ bool multi_delete_set_locks_and_link_aux_tables(LEX *lex)
|
||||
if (!walk)
|
||||
DBUG_RETURN(TRUE);
|
||||
if (!walk->derived)
|
||||
{
|
||||
target_tbl->table_name= walk->table_name;
|
||||
target_tbl->table_name_length= walk->table_name_length;
|
||||
}
|
||||
walk->updating= target_tbl->updating;
|
||||
walk->lock_type= target_tbl->lock_type;
|
||||
/* We can assume that tables to be deleted from are locked for write. */
|
||||
@@ -9524,7 +9513,7 @@ bool create_table_precheck(THD *thd, TABLE_LIST *tables,
|
||||
if (lex->create_info.or_replace() && !lex->tmp_table())
|
||||
want_priv|= DROP_ACL;
|
||||
|
||||
if (check_access(thd, want_priv, create_table->db,
|
||||
if (check_access(thd, want_priv, create_table->db.str,
|
||||
&create_table->grant.privilege,
|
||||
&create_table->grant.m_internal,
|
||||
0, 0))
|
||||
@@ -9591,7 +9580,8 @@ bool create_table_precheck(THD *thd, TABLE_LIST *tables,
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (check_fk_parent_table_access(thd, &lex->create_info, &lex->alter_info, create_table->db))
|
||||
if (check_fk_parent_table_access(thd, &lex->create_info, &lex->alter_info,
|
||||
create_table->db.str))
|
||||
goto err;
|
||||
|
||||
error= FALSE;
|
||||
|
||||
@@ -107,9 +107,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
bool is_com_multi, bool is_next_command);
|
||||
void log_slow_statement(THD *thd);
|
||||
bool append_file_to_dir(THD *thd, const char **filename_ptr,
|
||||
const char *table_name);
|
||||
bool append_file_to_dir(THD *thd, const char **filename_ptr,
|
||||
const char *table_name);
|
||||
const LEX_CSTRING *table_name);
|
||||
void execute_init_command(THD *thd, LEX_STRING *init_command,
|
||||
mysql_rwlock_t *var_lock);
|
||||
bool add_to_list(THD *thd, SQL_I_List<ORDER> &list, Item *group, bool asc);
|
||||
@@ -149,8 +147,9 @@ inline bool check_identifier_name(LEX_CSTRING *str)
|
||||
bool check_one_table_access(THD *thd, ulong privilege, TABLE_LIST *tables);
|
||||
bool check_single_table_access(THD *thd, ulong privilege,
|
||||
TABLE_LIST *tables, bool no_errors);
|
||||
bool check_routine_access(THD *thd,ulong want_access,const char *db,
|
||||
const char *name,
|
||||
bool check_routine_access(THD *thd,ulong want_access,
|
||||
const LEX_CSTRING *db,
|
||||
const LEX_CSTRING *name,
|
||||
const Sp_handler *sph, bool no_errors);
|
||||
bool check_some_access(THD *thd, ulong want_access, TABLE_LIST *table);
|
||||
bool check_some_routine_access(THD *thd, const char *db, const char *name,
|
||||
@@ -165,8 +164,9 @@ inline bool check_one_table_access(THD *thd, ulong privilege, TABLE_LIST *tables
|
||||
inline bool check_single_table_access(THD *thd, ulong privilege,
|
||||
TABLE_LIST *tables, bool no_errors)
|
||||
{ return false; }
|
||||
inline bool check_routine_access(THD *thd,ulong want_access, const char *db,
|
||||
const char *name,
|
||||
inline bool check_routine_access(THD *thd,ulong want_access,
|
||||
const LEX_CSTRING *db,
|
||||
const LEX_CSTRING *name,
|
||||
const Sp_handler *sph, bool no_errors)
|
||||
{ return false; }
|
||||
inline bool check_some_access(THD *thd, ulong want_access, TABLE_LIST *table)
|
||||
|
||||
@@ -4604,8 +4604,8 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info,
|
||||
object to allow fast_alter_partition_table to perform the changes.
|
||||
*/
|
||||
DBUG_ASSERT(thd->mdl_context.is_lock_owner(MDL_key::TABLE,
|
||||
alter_ctx->db,
|
||||
alter_ctx->table_name,
|
||||
alter_ctx->db.str,
|
||||
alter_ctx->table_name.str,
|
||||
MDL_INTENTION_EXCLUSIVE));
|
||||
|
||||
tab_part_info= table->part_info;
|
||||
@@ -5680,7 +5680,7 @@ static bool mysql_change_partitions(ALTER_PARTITION_PARAM_TYPE *lpt)
|
||||
THD *thd= lpt->thd;
|
||||
DBUG_ENTER("mysql_change_partitions");
|
||||
|
||||
build_table_filename(path, sizeof(path) - 1, lpt->db, lpt->table_name, "", 0);
|
||||
build_table_filename(path, sizeof(path) - 1, lpt->db.str, lpt->table_name.str, "", 0);
|
||||
|
||||
if(mysql_trans_prepare_alter_copy_data(thd))
|
||||
DBUG_RETURN(TRUE);
|
||||
@@ -5726,7 +5726,7 @@ static bool mysql_rename_partitions(ALTER_PARTITION_PARAM_TYPE *lpt)
|
||||
int error;
|
||||
DBUG_ENTER("mysql_rename_partitions");
|
||||
|
||||
build_table_filename(path, sizeof(path) - 1, lpt->db, lpt->table_name, "", 0);
|
||||
build_table_filename(path, sizeof(path) - 1, lpt->db.str, lpt->table_name.str, "", 0);
|
||||
if ((error= lpt->table->file->ha_rename_partitions(path)))
|
||||
{
|
||||
if (error != 1)
|
||||
@@ -5772,7 +5772,7 @@ static bool mysql_drop_partitions(ALTER_PARTITION_PARAM_TYPE *lpt)
|
||||
lpt->table->s->table_name.str,
|
||||
MDL_EXCLUSIVE));
|
||||
|
||||
build_table_filename(path, sizeof(path) - 1, lpt->db, lpt->table_name, "", 0);
|
||||
build_table_filename(path, sizeof(path) - 1, lpt->db.str, lpt->table_name.str, "", 0);
|
||||
if ((error= lpt->table->file->ha_drop_partitions(path)))
|
||||
{
|
||||
lpt->table->file->print_error(error, MYF(0));
|
||||
@@ -6169,8 +6169,7 @@ static bool write_log_rename_frm(ALTER_PARTITION_PARAM_TYPE *lpt)
|
||||
DBUG_ENTER("write_log_rename_frm");
|
||||
|
||||
part_info->first_log_entry= NULL;
|
||||
build_table_filename(path, sizeof(path) - 1, lpt->db,
|
||||
lpt->table_name, "", 0);
|
||||
build_table_filename(path, sizeof(path) - 1, lpt->db.str, lpt->table_name.str, "", 0);
|
||||
build_table_shadow_filename(shadow_path, sizeof(shadow_path) - 1, lpt);
|
||||
mysql_mutex_lock(&LOCK_gdl);
|
||||
if (write_log_replace_delete_frm(lpt, 0UL, shadow_path, path, TRUE))
|
||||
@@ -6221,8 +6220,7 @@ static bool write_log_drop_partition(ALTER_PARTITION_PARAM_TYPE *lpt)
|
||||
DBUG_ENTER("write_log_drop_partition");
|
||||
|
||||
part_info->first_log_entry= NULL;
|
||||
build_table_filename(path, sizeof(path) - 1, lpt->db,
|
||||
lpt->table_name, "", 0);
|
||||
build_table_filename(path, sizeof(path) - 1, lpt->db.str, lpt->table_name.str, "", 0);
|
||||
build_table_shadow_filename(tmp_path, sizeof(tmp_path) - 1, lpt);
|
||||
mysql_mutex_lock(&LOCK_gdl);
|
||||
if (write_log_dropped_partitions(lpt, &next_entry, (const char*)path,
|
||||
@@ -6280,8 +6278,7 @@ static bool write_log_add_change_partition(ALTER_PARTITION_PARAM_TYPE *lpt)
|
||||
DBUG_ASSERT(old_first_log_entry);
|
||||
DBUG_ENTER("write_log_add_change_partition");
|
||||
|
||||
build_table_filename(path, sizeof(path) - 1, lpt->db,
|
||||
lpt->table_name, "", 0);
|
||||
build_table_filename(path, sizeof(path) - 1, lpt->db.str, lpt->table_name.str, "", 0);
|
||||
build_table_shadow_filename(tmp_path, sizeof(tmp_path) - 1, lpt);
|
||||
mysql_mutex_lock(&LOCK_gdl);
|
||||
|
||||
@@ -6349,8 +6346,7 @@ static bool write_log_final_change_partition(ALTER_PARTITION_PARAM_TYPE *lpt)
|
||||
Replace the revert operations with forced retry operations.
|
||||
*/
|
||||
part_info->first_log_entry= NULL;
|
||||
build_table_filename(path, sizeof(path) - 1, lpt->db,
|
||||
lpt->table_name, "", 0);
|
||||
build_table_filename(path, sizeof(path) - 1, lpt->db.str, lpt->table_name.str, "", 0);
|
||||
build_table_shadow_filename(shadow_path, sizeof(shadow_path) - 1, lpt);
|
||||
mysql_mutex_lock(&LOCK_gdl);
|
||||
if (write_log_changed_partitions(lpt, &next_entry, (const char*)path))
|
||||
@@ -6535,8 +6531,8 @@ void handle_alter_part_error(ALTER_PARTITION_PARAM_TYPE *lpt,
|
||||
Better to do that here, than leave the cleaning up to others.
|
||||
Aquire EXCLUSIVE mdl lock if not already aquired.
|
||||
*/
|
||||
if (!thd->mdl_context.is_lock_owner(MDL_key::TABLE, lpt->db,
|
||||
lpt->table_name,
|
||||
if (!thd->mdl_context.is_lock_owner(MDL_key::TABLE, lpt->db.str,
|
||||
lpt->table_name.str,
|
||||
MDL_EXCLUSIVE))
|
||||
{
|
||||
if (wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN))
|
||||
@@ -6733,8 +6729,8 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
|
||||
Alter_info *alter_info,
|
||||
HA_CREATE_INFO *create_info,
|
||||
TABLE_LIST *table_list,
|
||||
const char *db,
|
||||
const char *table_name)
|
||||
const LEX_CSTRING *db,
|
||||
const LEX_CSTRING *table_name)
|
||||
{
|
||||
/* Set-up struct used to write frm files */
|
||||
partition_info *part_info;
|
||||
@@ -6757,8 +6753,8 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
|
||||
lpt->table= table;
|
||||
lpt->key_info_buffer= 0;
|
||||
lpt->key_count= 0;
|
||||
lpt->db= db;
|
||||
lpt->table_name= table_name;
|
||||
lpt->db= *db;
|
||||
lpt->table_name= *table_name;
|
||||
lpt->copied= 0;
|
||||
lpt->deleted= 0;
|
||||
lpt->pack_frm_data= NULL;
|
||||
|
||||
@@ -57,8 +57,8 @@ typedef struct st_lock_param_type
|
||||
Alter_info *alter_info;
|
||||
TABLE *table;
|
||||
KEY *key_info_buffer;
|
||||
const char *db;
|
||||
const char *table_name;
|
||||
LEX_CSTRING db;
|
||||
LEX_CSTRING table_name;
|
||||
uchar *pack_frm_data;
|
||||
uint key_count;
|
||||
uint db_options;
|
||||
@@ -267,8 +267,8 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
|
||||
Alter_info *alter_info,
|
||||
HA_CREATE_INFO *create_info,
|
||||
TABLE_LIST *table_list,
|
||||
const char *db,
|
||||
const char *table_name);
|
||||
const LEX_CSTRING *db,
|
||||
const LEX_CSTRING *table_name);
|
||||
bool set_part_state(Alter_info *alter_info, partition_info *tab_part_info,
|
||||
enum partition_state part_state);
|
||||
uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info,
|
||||
|
||||
@@ -71,15 +71,15 @@ bool Sql_cmd_alter_table_exchange_partition::execute(THD *thd)
|
||||
DBUG_RETURN(TRUE);
|
||||
|
||||
/* Must be set in the parser */
|
||||
DBUG_ASSERT(select_lex->db);
|
||||
DBUG_ASSERT(select_lex->db.str);
|
||||
/* also check the table to be exchanged with the partition */
|
||||
DBUG_ASSERT(alter_info.flags & Alter_info::ALTER_EXCHANGE_PARTITION);
|
||||
|
||||
if (check_access(thd, priv_needed, first_table->db,
|
||||
if (check_access(thd, priv_needed, first_table->db.str,
|
||||
&first_table->grant.privilege,
|
||||
&first_table->grant.m_internal,
|
||||
0, 0) ||
|
||||
check_access(thd, priv_needed, first_table->next_local->db,
|
||||
check_access(thd, priv_needed, first_table->next_local->db.str,
|
||||
&first_table->next_local->grant.privilege,
|
||||
&first_table->next_local->grant.m_internal,
|
||||
0, 0))
|
||||
@@ -552,13 +552,13 @@ bool Sql_cmd_alter_table_exchange_partition::
|
||||
/* Will append the partition name later in part_info->get_part_elem() */
|
||||
part_file_name_len= build_table_filename(part_file_name,
|
||||
sizeof(part_file_name),
|
||||
table_list->db,
|
||||
table_list->table_name,
|
||||
table_list->db.str,
|
||||
table_list->table_name.str,
|
||||
"", 0);
|
||||
build_table_filename(swap_file_name,
|
||||
sizeof(swap_file_name),
|
||||
swap_table_list->db,
|
||||
swap_table_list->table_name,
|
||||
swap_table_list->db.str,
|
||||
swap_table_list->table_name.str,
|
||||
"", 0);
|
||||
/* create a unique temp name #sqlx-nnnn_nnnn, x for eXchange */
|
||||
my_snprintf(temp_name, sizeof(temp_name), "%sx-%lx_%llx",
|
||||
@@ -566,7 +566,7 @@ bool Sql_cmd_alter_table_exchange_partition::
|
||||
if (lower_case_table_names)
|
||||
my_casedn_str(files_charset_info, temp_name);
|
||||
build_table_filename(temp_file_name, sizeof(temp_file_name),
|
||||
table_list->next_local->db,
|
||||
table_list->next_local->db.str,
|
||||
temp_name, "", FN_IS_TMP);
|
||||
|
||||
if (!(part_elem= part_table->part_info->get_part_elem(partition_name,
|
||||
@@ -768,7 +768,7 @@ bool Sql_cmd_alter_table_truncate_partition::execute(THD *thd)
|
||||
(!thd->is_current_stmt_binlog_format_row() ||
|
||||
!thd->find_temporary_table(first_table)) &&
|
||||
wsrep_to_isolation_begin(
|
||||
thd, first_table->db, first_table->table_name, NULL)
|
||||
thd, first_table->db.str, first_table->table_name.str, NULL)
|
||||
)
|
||||
{
|
||||
WSREP_WARN("ALTER TABLE TRUNCATE PARTITION isolation failure");
|
||||
@@ -818,8 +818,8 @@ bool Sql_cmd_alter_table_truncate_partition::execute(THD *thd)
|
||||
if (thd->mdl_context.upgrade_shared_lock(ticket, MDL_EXCLUSIVE, timeout))
|
||||
DBUG_RETURN(TRUE);
|
||||
|
||||
tdc_remove_table(thd, TDC_RT_REMOVE_NOT_OWN, first_table->db,
|
||||
first_table->table_name, FALSE);
|
||||
tdc_remove_table(thd, TDC_RT_REMOVE_NOT_OWN, first_table->db.str,
|
||||
first_table->table_name.str, FALSE);
|
||||
|
||||
partition= (ha_partition*) first_table->table->file;
|
||||
/* Invoke the handler method responsible for truncating the partition. */
|
||||
|
||||
@@ -66,6 +66,8 @@ char *opt_plugin_dir_ptr;
|
||||
char opt_plugin_dir[FN_REFLEN];
|
||||
ulong plugin_maturity;
|
||||
|
||||
static LEX_CSTRING MYSQL_PLUGIN_NAME= {STRING_WITH_LEN("plugin") };
|
||||
|
||||
/*
|
||||
not really needed now, this map will become essential when we add more
|
||||
maturity levels. We cannot change existing maturity constants,
|
||||
@@ -1817,11 +1819,9 @@ static void plugin_load(MEM_ROOT *tmp_root)
|
||||
|
||||
new_thd->thread_stack= (char*) &tables;
|
||||
new_thd->store_globals();
|
||||
new_thd->db= my_strdup("mysql", MYF(0));
|
||||
new_thd->db_length= 5;
|
||||
new_thd->db= MYSQL_SCHEMA_NAME;
|
||||
bzero((char*) &new_thd->net, sizeof(new_thd->net));
|
||||
tables.init_one_table(STRING_WITH_LEN("mysql"), STRING_WITH_LEN("plugin"),
|
||||
"plugin", TL_READ);
|
||||
tables.init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_PLUGIN_NAME, 0, TL_READ);
|
||||
tables.open_strategy= TABLE_LIST::OPEN_NORMAL;
|
||||
|
||||
result= open_and_lock_tables(new_thd, &tables, FALSE, MYSQL_LOCK_IGNORE_TIMEOUT);
|
||||
@@ -1875,6 +1875,7 @@ static void plugin_load(MEM_ROOT *tmp_root)
|
||||
table->m_needs_reopen= TRUE; // Force close to free memory
|
||||
close_mysql_tables(new_thd);
|
||||
end:
|
||||
new_thd->db= null_clex_str; // Avoid free on thd->db
|
||||
delete new_thd;
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
@@ -2169,7 +2170,7 @@ bool mysql_install_plugin(THD *thd, const LEX_CSTRING *name,
|
||||
{ MYSQL_AUDIT_GENERAL_CLASSMASK };
|
||||
DBUG_ENTER("mysql_install_plugin");
|
||||
|
||||
tables.init_one_table("mysql", 5, "plugin", 6, "plugin", TL_WRITE);
|
||||
tables.init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_PLUGIN_NAME, 0, TL_WRITE);
|
||||
if (!opt_noacl && check_table_access(thd, INSERT_ACL, &tables, FALSE, 1, FALSE))
|
||||
DBUG_RETURN(TRUE);
|
||||
|
||||
@@ -2312,7 +2313,7 @@ bool mysql_uninstall_plugin(THD *thd, const LEX_CSTRING *name,
|
||||
{ MYSQL_AUDIT_GENERAL_CLASSMASK };
|
||||
DBUG_ENTER("mysql_uninstall_plugin");
|
||||
|
||||
tables.init_one_table("mysql", 5, "plugin", 6, "plugin", TL_WRITE);
|
||||
tables.init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_PLUGIN_NAME, 0, TL_WRITE);
|
||||
|
||||
if (!opt_noacl && check_table_access(thd, DELETE_ACL, &tables, FALSE, 1, FALSE))
|
||||
DBUG_RETURN(TRUE);
|
||||
|
||||
@@ -229,7 +229,7 @@ private:
|
||||
MEM_ROOT main_mem_root;
|
||||
sql_mode_t m_sql_mode;
|
||||
private:
|
||||
bool set_db(const char *db, uint db_length);
|
||||
bool set_db(const LEX_CSTRING *db);
|
||||
bool set_parameters(String *expanded_query,
|
||||
uchar *packet, uchar *packet_end);
|
||||
bool execute(String *expanded_query, bool open_cursor);
|
||||
@@ -1306,7 +1306,7 @@ static bool mysql_test_insert(Prepared_statement *stmt,
|
||||
{
|
||||
my_error(ER_DELAYED_NOT_SUPPORTED, MYF(0), (table_list->view ?
|
||||
table_list->view_name.str :
|
||||
table_list->table_name));
|
||||
table_list->table_name.str));
|
||||
goto error;
|
||||
}
|
||||
while ((values= its++))
|
||||
@@ -1390,7 +1390,7 @@ static int mysql_test_update(Prepared_statement *stmt,
|
||||
|
||||
if (!table_list->single_table_updatable())
|
||||
{
|
||||
my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias, "UPDATE");
|
||||
my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias.str, "UPDATE");
|
||||
goto error;
|
||||
}
|
||||
|
||||
@@ -1468,7 +1468,7 @@ static bool mysql_test_delete(Prepared_statement *stmt,
|
||||
|
||||
if (!table_list->single_table_updatable())
|
||||
{
|
||||
my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias, "DELETE");
|
||||
my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias.str, "DELETE");
|
||||
goto error;
|
||||
}
|
||||
if (!table_list->table || !table_list->table->is_created())
|
||||
@@ -3817,24 +3817,22 @@ bool Prepared_statement::set_name(LEX_CSTRING *name_arg)
|
||||
a prepared statement since it affects execution environment:
|
||||
privileges, @@character_set_database, and other.
|
||||
|
||||
@return Returns an error if out of memory.
|
||||
@return 1 if out of memory.
|
||||
*/
|
||||
|
||||
bool
|
||||
Prepared_statement::set_db(const char *db_arg, uint db_length_arg)
|
||||
Prepared_statement::set_db(const LEX_CSTRING *db_arg)
|
||||
{
|
||||
/* Remember the current database. */
|
||||
if (db_arg && db_length_arg)
|
||||
if (db_arg->length)
|
||||
{
|
||||
db= this->strmake(db_arg, db_length_arg);
|
||||
db_length= db_length_arg;
|
||||
if (!(db.str= this->strmake(db_arg->str, db_arg->length)))
|
||||
return 1;
|
||||
db.length= db_arg->length;
|
||||
}
|
||||
else
|
||||
{
|
||||
db= NULL;
|
||||
db_length= 0;
|
||||
}
|
||||
return db_arg != NULL && db == NULL;
|
||||
db= null_clex_str;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
@@ -3882,7 +3880,7 @@ bool Prepared_statement::prepare(const char *packet, uint packet_len)
|
||||
if (! (lex= new (mem_root) st_lex_local))
|
||||
DBUG_RETURN(TRUE);
|
||||
|
||||
if (set_db(thd->db, thd->db_length))
|
||||
if (set_db(&thd->db))
|
||||
DBUG_RETURN(TRUE);
|
||||
|
||||
/*
|
||||
@@ -4460,7 +4458,7 @@ Prepared_statement::reprepare()
|
||||
char saved_cur_db_name_buf[SAFE_NAME_LEN+1];
|
||||
LEX_STRING saved_cur_db_name=
|
||||
{ saved_cur_db_name_buf, sizeof(saved_cur_db_name_buf) };
|
||||
LEX_CSTRING stmt_db_name= { db, db_length };
|
||||
LEX_CSTRING stmt_db_name= db;
|
||||
bool cur_db_changed;
|
||||
bool error;
|
||||
|
||||
@@ -4583,8 +4581,7 @@ Prepared_statement::swap_prepared_statement(Prepared_statement *copy)
|
||||
/* Swap names, the old name is allocated in the wrong memory root */
|
||||
swap_variables(LEX_CSTRING, name, copy->name);
|
||||
/* Ditto */
|
||||
swap_variables(char *, db, copy->db);
|
||||
swap_variables(size_t, db_length, copy->db_length);
|
||||
swap_variables(LEX_CSTRING, db, copy->db);
|
||||
|
||||
DBUG_ASSERT(param_count == copy->param_count);
|
||||
DBUG_ASSERT(thd == copy->thd);
|
||||
@@ -4626,7 +4623,7 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor)
|
||||
{ saved_cur_db_name_buf, sizeof(saved_cur_db_name_buf) };
|
||||
bool cur_db_changed;
|
||||
|
||||
LEX_CSTRING stmt_db_name= { db, db_length };
|
||||
LEX_CSTRING stmt_db_name= db;
|
||||
|
||||
status_var_increment(thd->status_var.com_stmt_execute);
|
||||
|
||||
@@ -4727,7 +4724,7 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor)
|
||||
PSI_statement_locker *parent_locker;
|
||||
MYSQL_QUERY_EXEC_START(thd->query(),
|
||||
thd->thread_id,
|
||||
(char *) (thd->db ? thd->db : ""),
|
||||
thd->get_db(),
|
||||
&thd->security_ctx->priv_user[0],
|
||||
(char *) thd->security_ctx->host_or_ip,
|
||||
1);
|
||||
|
||||
@@ -289,7 +289,7 @@ bool reload_acl_and_cache(THD *thd, unsigned long long options,
|
||||
if (tables)
|
||||
{
|
||||
for (TABLE_LIST *t= tables; t; t= t->next_local)
|
||||
if (!find_table_for_mdl_upgrade(thd, t->db, t->table_name, false))
|
||||
if (!find_table_for_mdl_upgrade(thd, t->db.str, t->table_name.str, false))
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
@@ -412,11 +412,11 @@ bool reload_acl_and_cache(THD *thd, unsigned long long options,
|
||||
reset_mqh((LEX_USER *) NULL, 0); /* purecov: inspected */
|
||||
if (options & REFRESH_GENERIC)
|
||||
{
|
||||
List_iterator_fast<LEX_STRING> li(thd->lex->view_list);
|
||||
LEX_STRING *ls;
|
||||
List_iterator_fast<LEX_CSTRING> li(thd->lex->view_list);
|
||||
LEX_CSTRING *ls;
|
||||
while ((ls= li++))
|
||||
{
|
||||
ST_SCHEMA_TABLE *table= find_schema_table(thd, ls->str);
|
||||
ST_SCHEMA_TABLE *table= find_schema_table(thd, ls);
|
||||
if (table->reset_table())
|
||||
result= 1;
|
||||
}
|
||||
@@ -540,8 +540,8 @@ bool flush_tables_with_read_lock(THD *thd, TABLE_LIST *all_tables)
|
||||
{
|
||||
/* Request removal of table from cache. */
|
||||
tdc_remove_table(thd, TDC_RT_REMOVE_UNUSED,
|
||||
table_list->db,
|
||||
table_list->table_name, FALSE);
|
||||
table_list->db.str,
|
||||
table_list->table_name.str, FALSE);
|
||||
/* Reset ticket to satisfy asserts in open_tables(). */
|
||||
table_list->mdl_request.ticket= NULL;
|
||||
}
|
||||
@@ -573,7 +573,7 @@ bool flush_tables_with_read_lock(THD *thd, TABLE_LIST *all_tables)
|
||||
if (!(table_list->table->file->ha_table_flags() & HA_CAN_EXPORT))
|
||||
{
|
||||
my_error(ER_ILLEGAL_HA, MYF(0),table_list->table->file->table_type(),
|
||||
table_list->db, table_list->table_name);
|
||||
table_list->db.str, table_list->table_name.str);
|
||||
goto error_reset_bits;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,8 +34,8 @@
|
||||
|
||||
static TABLE_LIST *rename_tables(THD *thd, TABLE_LIST *table_list,
|
||||
bool skip_error);
|
||||
static bool do_rename(THD *thd, TABLE_LIST *ren_table, const char *new_db,
|
||||
const char *new_table_name, const char *new_table_alias,
|
||||
static bool do_rename(THD *thd, TABLE_LIST *ren_table, const LEX_CSTRING *new_db,
|
||||
const LEX_CSTRING *new_table_name, const LEX_CSTRING *new_table_alias,
|
||||
bool skip_error);
|
||||
|
||||
static TABLE_LIST *reverse_table_list(TABLE_LIST *table_list);
|
||||
@@ -104,8 +104,9 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list, bool silent)
|
||||
Two renames of "log_table TO" w/o rename "TO log_table" in
|
||||
between.
|
||||
*/
|
||||
my_error(ER_CANT_RENAME_LOG_TABLE, MYF(0), ren_table->table_name,
|
||||
ren_table->table_name);
|
||||
my_error(ER_CANT_RENAME_LOG_TABLE, MYF(0),
|
||||
ren_table->table_name.str,
|
||||
ren_table->table_name.str);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
@@ -117,14 +118,15 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list, bool silent)
|
||||
Attempt to rename a table TO log_table w/o renaming
|
||||
log_table TO some table.
|
||||
*/
|
||||
my_error(ER_CANT_RENAME_LOG_TABLE, MYF(0), ren_table->table_name,
|
||||
ren_table->table_name);
|
||||
my_error(ER_CANT_RENAME_LOG_TABLE, MYF(0),
|
||||
ren_table->table_name.str,
|
||||
ren_table->table_name.str);
|
||||
goto err;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* save the name of the log table to report an error */
|
||||
rename_log_table[log_table_rename]= ren_table->table_name;
|
||||
rename_log_table[log_table_rename]= ren_table->table_name.str;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -216,21 +218,21 @@ static bool
|
||||
do_rename_temporary(THD *thd, TABLE_LIST *ren_table, TABLE_LIST *new_table,
|
||||
bool skip_error)
|
||||
{
|
||||
const char *new_alias;
|
||||
LEX_CSTRING *new_alias;
|
||||
DBUG_ENTER("do_rename_temporary");
|
||||
|
||||
new_alias= (lower_case_table_names == 2) ? new_table->alias :
|
||||
new_table->table_name;
|
||||
new_alias= (lower_case_table_names == 2) ? &new_table->alias :
|
||||
&new_table->table_name;
|
||||
|
||||
if (is_temporary_table(new_table))
|
||||
{
|
||||
my_error(ER_TABLE_EXISTS_ERROR, MYF(0), new_alias);
|
||||
my_error(ER_TABLE_EXISTS_ERROR, MYF(0), new_alias->str);
|
||||
DBUG_RETURN(1); // This can't be skipped
|
||||
}
|
||||
|
||||
|
||||
DBUG_RETURN(thd->rename_temporary_table(ren_table->table,
|
||||
new_table->db, new_alias));
|
||||
&new_table->db, new_alias));
|
||||
}
|
||||
|
||||
|
||||
@@ -255,67 +257,62 @@ do_rename_temporary(THD *thd, TABLE_LIST *ren_table, TABLE_LIST *new_table,
|
||||
*/
|
||||
|
||||
static bool
|
||||
do_rename(THD *thd, TABLE_LIST *ren_table, const char *new_db,
|
||||
const char *new_table_name, const char *new_table_alias,
|
||||
do_rename(THD *thd, TABLE_LIST *ren_table, const LEX_CSTRING *new_db,
|
||||
const LEX_CSTRING *new_table_name, const LEX_CSTRING *new_table_alias,
|
||||
bool skip_error)
|
||||
{
|
||||
int rc= 1;
|
||||
handlerton *hton;
|
||||
const char *new_alias, *old_alias;
|
||||
LEX_CSTRING old_alias, new_alias;
|
||||
DBUG_ENTER("do_rename");
|
||||
|
||||
if (lower_case_table_names == 2)
|
||||
{
|
||||
old_alias= ren_table->alias;
|
||||
new_alias= new_table_alias;
|
||||
new_alias= *new_table_alias;
|
||||
}
|
||||
else
|
||||
{
|
||||
old_alias= ren_table->table_name;
|
||||
new_alias= new_table_name;
|
||||
new_alias= *new_table_name;
|
||||
}
|
||||
DBUG_ASSERT(new_alias);
|
||||
DBUG_ASSERT(new_alias.str);
|
||||
|
||||
if (ha_table_exists(thd, new_db, new_alias))
|
||||
if (ha_table_exists(thd, new_db, &new_alias))
|
||||
{
|
||||
my_error(ER_TABLE_EXISTS_ERROR, MYF(0), new_alias);
|
||||
my_error(ER_TABLE_EXISTS_ERROR, MYF(0), new_alias.str);
|
||||
DBUG_RETURN(1); // This can't be skipped
|
||||
}
|
||||
|
||||
if (ha_table_exists(thd, ren_table->db, old_alias, &hton) && hton)
|
||||
if (ha_table_exists(thd, &ren_table->db, &old_alias, &hton) && hton)
|
||||
{
|
||||
DBUG_ASSERT(!thd->locked_tables_mode);
|
||||
tdc_remove_table(thd, TDC_RT_REMOVE_ALL,
|
||||
ren_table->db, ren_table->table_name, false);
|
||||
ren_table->db.str, ren_table->table_name.str, false);
|
||||
|
||||
if (hton != view_pseudo_hton)
|
||||
{
|
||||
if (!(rc= mysql_rename_table(hton, ren_table->db, old_alias,
|
||||
new_db, new_alias, 0)))
|
||||
if (!(rc= mysql_rename_table(hton, &ren_table->db, &old_alias,
|
||||
new_db, &new_alias, 0)))
|
||||
{
|
||||
LEX_CSTRING db_name= { ren_table->db, ren_table->db_length };
|
||||
LEX_CSTRING table_name= { ren_table->table_name,
|
||||
ren_table->table_name_length };
|
||||
LEX_CSTRING new_table= { new_alias, strlen(new_alias) };
|
||||
LEX_CSTRING new_db_name= { new_db, strlen(new_db)};
|
||||
(void) rename_table_in_stat_tables(thd, &db_name, &table_name,
|
||||
&new_db_name, &new_table);
|
||||
(void) rename_table_in_stat_tables(thd, &ren_table->db,
|
||||
&ren_table->table_name,
|
||||
new_db, &new_alias);
|
||||
VTMD_rename vtmd(*ren_table);
|
||||
if (thd->variables.vers_alter_history == VERS_ALTER_HISTORY_SURVIVE)
|
||||
{
|
||||
rc= vtmd.try_rename(thd, new_db_name, new_table);
|
||||
rc= vtmd.try_rename(thd, new_db->str, new_alias.str);
|
||||
if (rc)
|
||||
goto revert_table_name;
|
||||
}
|
||||
rc= Table_triggers_list::change_table_name(thd, ren_table->db,
|
||||
old_alias,
|
||||
ren_table->table_name,
|
||||
new_db,
|
||||
new_alias);
|
||||
if (rc)
|
||||
if ((rc= Table_triggers_list::change_table_name(thd, &ren_table->db,
|
||||
&old_alias,
|
||||
&ren_table->table_name,
|
||||
new_db,
|
||||
&new_alias)))
|
||||
{
|
||||
if (thd->variables.vers_alter_history == VERS_ALTER_HISTORY_SURVIVE)
|
||||
vtmd.revert_rename(thd, new_db_name);
|
||||
vtmd.revert_rename(thd, new_db->str);
|
||||
revert_table_name:
|
||||
/*
|
||||
We've succeeded in renaming table's .frm and in updating
|
||||
@@ -323,8 +320,8 @@ revert_table_name:
|
||||
triggers appropriately. So let us revert operations on .frm
|
||||
and handler's data and report about failure to rename table.
|
||||
*/
|
||||
(void) mysql_rename_table(hton, new_db, new_alias,
|
||||
ren_table->db, old_alias, NO_FK_CHECKS);
|
||||
(void) mysql_rename_table(hton, new_db, &new_alias,
|
||||
&ren_table->db, &old_alias, NO_FK_CHECKS);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -336,15 +333,15 @@ revert_table_name:
|
||||
because a view has valid internal db&table names in this case.
|
||||
*/
|
||||
if (thd->lex->sql_command != SQLCOM_ALTER_DB_UPGRADE &&
|
||||
strcmp(ren_table->db, new_db))
|
||||
my_error(ER_FORBID_SCHEMA_CHANGE, MYF(0), ren_table->db, new_db);
|
||||
cmp(&ren_table->db, new_db))
|
||||
my_error(ER_FORBID_SCHEMA_CHANGE, MYF(0), ren_table->db.str, new_db->str);
|
||||
else
|
||||
rc= mysql_rename_view(thd, new_db, new_alias, ren_table);
|
||||
rc= mysql_rename_view(thd, new_db, &new_alias, ren_table);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
my_error(ER_NO_SUCH_TABLE, MYF(0), ren_table->db, old_alias);
|
||||
my_error(ER_NO_SUCH_TABLE, MYF(0), ren_table->db.str, old_alias.str);
|
||||
}
|
||||
if (rc && !skip_error)
|
||||
DBUG_RETURN(1);
|
||||
@@ -390,8 +387,8 @@ rename_tables(THD *thd, TABLE_LIST *table_list, bool skip_error)
|
||||
|
||||
if (is_temporary_table(ren_table) ?
|
||||
do_rename_temporary(thd, ren_table, new_table, skip_error) :
|
||||
do_rename(thd, ren_table, new_table->db, new_table->table_name,
|
||||
new_table->alias, skip_error))
|
||||
do_rename(thd, ren_table, &new_table->db, &new_table->table_name,
|
||||
&new_table->alias, skip_error))
|
||||
DBUG_RETURN(ren_table);
|
||||
}
|
||||
DBUG_RETURN(0);
|
||||
|
||||
@@ -4265,7 +4265,7 @@ int log_loaded_block(IO_CACHE* file, uchar *Buffer, size_t Count)
|
||||
lf_info->last_pos_in_file= my_b_get_pos_in_file(file);
|
||||
if (lf_info->wrote_create_file)
|
||||
{
|
||||
Append_block_log_event a(lf_info->thd, lf_info->thd->db, buffer,
|
||||
Append_block_log_event a(lf_info->thd, lf_info->thd->db.str, buffer,
|
||||
MY_MIN(block_len, max_event_size),
|
||||
lf_info->log_delayed);
|
||||
if (mysql_bin_log.write(&a))
|
||||
@@ -4273,7 +4273,7 @@ int log_loaded_block(IO_CACHE* file, uchar *Buffer, size_t Count)
|
||||
}
|
||||
else
|
||||
{
|
||||
Begin_load_query_log_event b(lf_info->thd, lf_info->thd->db,
|
||||
Begin_load_query_log_event b(lf_info->thd, lf_info->thd->db.str,
|
||||
buffer,
|
||||
MY_MIN(block_len, max_event_size),
|
||||
lf_info->log_delayed);
|
||||
|
||||
@@ -753,7 +753,7 @@ int SELECT_LEX::vers_setup_conds(THD *thd, TABLE_LIST *tables, COND **where_expr
|
||||
else if (table->vers_conditions.user_defined() &&
|
||||
(table->is_non_derived() || !table->vers_conditions.used))
|
||||
{
|
||||
my_error(ER_VERS_NOT_VERSIONED, MYF(0), table->alias);
|
||||
my_error(ER_VERS_NOT_VERSIONED, MYF(0), table->alias.str);
|
||||
DBUG_RETURN(-1);
|
||||
}
|
||||
}
|
||||
@@ -807,7 +807,7 @@ int SELECT_LEX::vers_setup_conds(THD *thd, TABLE_LIST *tables, COND **where_expr
|
||||
{
|
||||
#define PART_VERS_ERR_MSG "%s PARTITION (%s)"
|
||||
char buf[NAME_LEN*2 + sizeof(PART_VERS_ERR_MSG)];
|
||||
my_snprintf(buf, sizeof(buf), PART_VERS_ERR_MSG, table->alias,
|
||||
my_snprintf(buf, sizeof(buf), PART_VERS_ERR_MSG, table->alias.str,
|
||||
table->partition_names->head()->c_ptr());
|
||||
my_error(ER_VERS_NOT_VERSIONED, MYF(0), buf);
|
||||
DBUG_RETURN(-1);
|
||||
@@ -848,9 +848,9 @@ int SELECT_LEX::vers_setup_conds(THD *thd, TABLE_LIST *tables, COND **where_expr
|
||||
const LEX_CSTRING *fend= &table->table->vers_end_field()->field_name;
|
||||
|
||||
Item *row_start=
|
||||
newx Item_field(thd, &this->context, table->db, table->alias, fstart);
|
||||
newx Item_field(thd, &this->context, table->db.str, table->alias.str, fstart);
|
||||
Item *row_end=
|
||||
newx Item_field(thd, &this->context, table->db, table->alias, fend);
|
||||
newx Item_field(thd, &this->context, table->db.str, table->alias.str, fend);
|
||||
|
||||
bool tmp_from_ib=
|
||||
table->table->s->table_category == TABLE_CATEGORY_TEMPORARY &&
|
||||
@@ -867,7 +867,7 @@ int SELECT_LEX::vers_setup_conds(THD *thd, TABLE_LIST *tables, COND **where_expr
|
||||
if (timestamps_only && (vers_conditions.unit_start == VERS_TRX_ID ||
|
||||
vers_conditions.unit_end == VERS_TRX_ID))
|
||||
{
|
||||
my_error(ER_VERS_ENGINE_UNSUPPORTED, MYF(0), table->table_name);
|
||||
my_error(ER_VERS_ENGINE_UNSUPPORTED, MYF(0), table->table_name.str);
|
||||
DBUG_RETURN(-1);
|
||||
}
|
||||
}
|
||||
@@ -2870,7 +2870,7 @@ bool JOIN::make_aggr_tables_info()
|
||||
all_fields,
|
||||
NULL, query.distinct,
|
||||
TRUE, select_options, HA_POS_ERROR,
|
||||
"", !need_tmp,
|
||||
&empty_clex_str, !need_tmp,
|
||||
query.order_by || query.group_by);
|
||||
if (!table)
|
||||
DBUG_RETURN(1);
|
||||
@@ -3373,7 +3373,7 @@ JOIN::create_postjoin_aggr_table(JOIN_TAB *tab, List<Item> *table_fields,
|
||||
TABLE* table= create_tmp_table(thd, tab->tmp_table_param, *table_fields,
|
||||
table_group, distinct,
|
||||
save_sum_fields, select_options, table_rows_limit,
|
||||
"", true, keep_row_order);
|
||||
&empty_clex_str, true, keep_row_order);
|
||||
if (!table)
|
||||
DBUG_RETURN(true);
|
||||
tmp_table_param.using_outer_summary_function=
|
||||
@@ -17039,7 +17039,7 @@ TABLE *
|
||||
create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields,
|
||||
ORDER *group, bool distinct, bool save_sum_fields,
|
||||
ulonglong select_options, ha_rows rows_limit,
|
||||
const char *table_alias, bool do_not_open,
|
||||
const LEX_CSTRING *table_alias, bool do_not_open,
|
||||
bool keep_row_order)
|
||||
{
|
||||
MEM_ROOT *mem_root_save, own_root;
|
||||
@@ -17076,7 +17076,7 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields,
|
||||
DBUG_ENTER("create_tmp_table");
|
||||
DBUG_PRINT("enter",
|
||||
("table_alias: '%s' distinct: %d save_sum_fields: %d "
|
||||
"rows_limit: %lu group: %d", table_alias,
|
||||
"rows_limit: %lu group: %d", table_alias->str,
|
||||
(int) distinct, (int) save_sum_fields,
|
||||
(ulong) rows_limit, MY_TEST(group)));
|
||||
|
||||
@@ -17192,7 +17192,7 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields,
|
||||
thd->mem_root= &table->mem_root;
|
||||
|
||||
table->field=reg_field;
|
||||
table->alias.set(table_alias, strlen(table_alias), table_alias_charset);
|
||||
table->alias.set(table_alias->str, table_alias->length, table_alias_charset);
|
||||
|
||||
table->reginfo.lock_type=TL_WRITE; /* Will be updated */
|
||||
table->map=1;
|
||||
@@ -25007,7 +25007,7 @@ bool JOIN_TAB::save_explain_data(Explain_table_access *eta,
|
||||
}
|
||||
}
|
||||
}
|
||||
eta->table_name.copy(real_table->alias, strlen(real_table->alias), cs);
|
||||
eta->table_name.copy(real_table->alias.str, real_table->alias.length, cs);
|
||||
}
|
||||
|
||||
/* "partitions" column */
|
||||
@@ -25333,7 +25333,7 @@ bool JOIN_TAB::save_explain_data(Explain_table_access *eta,
|
||||
eta->firstmatch_table_name.append(namebuf, len);
|
||||
}
|
||||
else
|
||||
eta->firstmatch_table_name.append(prev_table->pos_in_table_list->alias);
|
||||
eta->firstmatch_table_name.append(&prev_table->pos_in_table_list->alias);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25932,8 +25932,8 @@ Index_hint::print(THD *thd, String *str)
|
||||
strlen(primary_key_name)))
|
||||
str->append(primary_key_name);
|
||||
else
|
||||
append_identifier(thd, str, key_name.str, key_name.length);
|
||||
}
|
||||
append_identifier(thd, str, &key_name);
|
||||
}
|
||||
str->append(')');
|
||||
}
|
||||
|
||||
@@ -25989,10 +25989,10 @@ void TABLE_LIST::print(THD *thd, table_map eliminated_tables, String *str,
|
||||
if (!(belong_to_view &&
|
||||
belong_to_view->compact_view_format))
|
||||
{
|
||||
append_identifier(thd, str, view_db.str, view_db.length);
|
||||
append_identifier(thd, str, &view_db);
|
||||
str->append('.');
|
||||
}
|
||||
append_identifier(thd, str, view_name.str, view_name.length);
|
||||
append_identifier(thd, str, &view_name);
|
||||
cmp_name= view_name.str;
|
||||
}
|
||||
else if (derived)
|
||||
@@ -26007,8 +26007,8 @@ void TABLE_LIST::print(THD *thd, table_map eliminated_tables, String *str,
|
||||
}
|
||||
else
|
||||
{
|
||||
append_identifier(thd, str, table_name, table_name_length);
|
||||
cmp_name= table_name;
|
||||
append_identifier(thd, str, &table_name);
|
||||
cmp_name= table_name.str;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -26018,19 +26018,18 @@ void TABLE_LIST::print(THD *thd, table_map eliminated_tables, String *str,
|
||||
if (!(belong_to_view &&
|
||||
belong_to_view->compact_view_format))
|
||||
{
|
||||
append_identifier(thd, str, db, db_length);
|
||||
append_identifier(thd, str, &db);
|
||||
str->append('.');
|
||||
}
|
||||
if (schema_table)
|
||||
{
|
||||
append_identifier(thd, str, schema_table_name,
|
||||
strlen(schema_table_name));
|
||||
cmp_name= schema_table_name;
|
||||
append_identifier(thd, str, &schema_table_name);
|
||||
cmp_name= schema_table_name.str;
|
||||
}
|
||||
else
|
||||
{
|
||||
append_identifier(thd, str, table_name, table_name_length);
|
||||
cmp_name= table_name;
|
||||
append_identifier(thd, str, &table_name);
|
||||
cmp_name= table_name.str;
|
||||
}
|
||||
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||
if (partition_names && partition_names->elements)
|
||||
@@ -26054,23 +26053,23 @@ void TABLE_LIST::print(THD *thd, table_map eliminated_tables, String *str,
|
||||
// versioning conditions are already unwrapped to WHERE clause
|
||||
str->append(" FOR SYSTEM_TIME ALL");
|
||||
}
|
||||
if (my_strcasecmp(table_alias_charset, cmp_name, alias))
|
||||
if (my_strcasecmp(table_alias_charset, cmp_name, alias.str))
|
||||
{
|
||||
char t_alias_buff[MAX_ALIAS_NAME];
|
||||
const char *t_alias= alias;
|
||||
LEX_CSTRING t_alias= alias;
|
||||
|
||||
str->append(' ');
|
||||
if (lower_case_table_names== 1)
|
||||
{
|
||||
if (alias && alias[0])
|
||||
if (alias.str && alias.str[0])
|
||||
{
|
||||
strmov(t_alias_buff, alias);
|
||||
my_casedn_str(files_charset_info, t_alias_buff);
|
||||
t_alias= t_alias_buff;
|
||||
strmov(t_alias_buff, alias.str);
|
||||
t_alias.length= my_casedn_str(files_charset_info, t_alias_buff);
|
||||
t_alias.str= t_alias_buff;
|
||||
}
|
||||
}
|
||||
|
||||
append_identifier(thd, str, t_alias, strlen(t_alias));
|
||||
append_identifier(thd, str, &t_alias);
|
||||
}
|
||||
|
||||
if (index_hints)
|
||||
|
||||
@@ -2377,7 +2377,7 @@ int append_possible_keys(MEM_ROOT *alloc, String_list &list, TABLE *table,
|
||||
TABLE *create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
|
||||
ORDER *group, bool distinct, bool save_sum_fields,
|
||||
ulonglong select_options, ha_rows rows_limit,
|
||||
const char* alias, bool do_not_open=FALSE,
|
||||
const LEX_CSTRING *alias, bool do_not_open=FALSE,
|
||||
bool keep_row_order= FALSE);
|
||||
void free_tmp_table(THD *thd, TABLE *entry);
|
||||
bool create_internal_tmp_table_from_heap(THD *thd, TABLE *table,
|
||||
|
||||
@@ -220,8 +220,8 @@ bool check_sequence_fields(LEX *lex, List<Create_field> *fields)
|
||||
|
||||
err:
|
||||
my_error(ER_SEQUENCE_INVALID_TABLE_STRUCTURE, MYF(0),
|
||||
lex->select_lex.table_list.first->db,
|
||||
lex->select_lex.table_list.first->table_name, reason);
|
||||
lex->select_lex.table_list.first->db.str,
|
||||
lex->select_lex.table_list.first->table_name.str, reason);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
|
||||
@@ -843,7 +843,7 @@ bool Sql_cmd_alter_sequence::execute(THD *thd)
|
||||
No_such_table_error_handler no_such_table_handler;
|
||||
DBUG_ENTER("Sql_cmd_alter_sequence::execute");
|
||||
|
||||
if (check_access(thd, ALTER_ACL, first_table->db,
|
||||
if (check_access(thd, ALTER_ACL, first_table->db.str,
|
||||
&first_table->grant.privilege,
|
||||
&first_table->grant.m_internal,
|
||||
0, 0))
|
||||
@@ -865,9 +865,9 @@ bool Sql_cmd_alter_sequence::execute(THD *thd)
|
||||
if (trapped_errors)
|
||||
{
|
||||
StringBuffer<FN_REFLEN> tbl_name;
|
||||
tbl_name.append(first_table->db);
|
||||
tbl_name.append(&first_table->db);
|
||||
tbl_name.append('.');
|
||||
tbl_name.append(first_table->table_name);
|
||||
tbl_name.append(&first_table->table_name);
|
||||
push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE,
|
||||
ER_UNKNOWN_SEQUENCES,
|
||||
ER_THD(thd, ER_UNKNOWN_SEQUENCES),
|
||||
@@ -909,8 +909,8 @@ bool Sql_cmd_alter_sequence::execute(THD *thd)
|
||||
if (new_seq->check_and_adjust(0))
|
||||
{
|
||||
my_error(ER_SEQUENCE_INVALID_DATA, MYF(0),
|
||||
first_table->db,
|
||||
first_table->table_name);
|
||||
first_table->db.str,
|
||||
first_table->table_name.str);
|
||||
error= 1;
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -54,6 +54,8 @@
|
||||
static HASH servers_cache;
|
||||
static MEM_ROOT mem;
|
||||
static mysql_rwlock_t THR_LOCK_servers;
|
||||
static LEX_CSTRING MYSQL_SERVERS_NAME= {STRING_WITH_LEN("servers") };
|
||||
|
||||
|
||||
static bool get_server_from_table_to_cache(TABLE *table);
|
||||
|
||||
@@ -251,7 +253,7 @@ bool servers_reload(THD *thd)
|
||||
DBUG_PRINT("info", ("locking servers_cache"));
|
||||
mysql_rwlock_wrlock(&THR_LOCK_servers);
|
||||
|
||||
tables[0].init_one_table("mysql", 5, "servers", 7, "servers", TL_READ);
|
||||
tables[0].init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_SERVERS_NAME, 0, TL_READ);
|
||||
|
||||
if (open_and_lock_tables(thd, tables, FALSE, MYSQL_LOCK_IGNORE_TIMEOUT))
|
||||
{
|
||||
@@ -383,10 +385,9 @@ insert_server(THD *thd, FOREIGN_SERVER *server)
|
||||
int error= -1;
|
||||
TABLE_LIST tables;
|
||||
TABLE *table;
|
||||
|
||||
DBUG_ENTER("insert_server");
|
||||
|
||||
tables.init_one_table("mysql", 5, "servers", 7, "servers", TL_WRITE);
|
||||
tables.init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_SERVERS_NAME, 0, TL_WRITE);
|
||||
|
||||
/* need to open before acquiring THR_LOCK_plugin or it will deadlock */
|
||||
if (! (table= open_ltable(thd, &tables, TL_WRITE, MYSQL_LOCK_IGNORE_TIMEOUT)))
|
||||
@@ -603,7 +604,7 @@ static int drop_server_internal(THD *thd, LEX_SERVER_OPTIONS *server_options)
|
||||
DBUG_PRINT("info", ("server name server->server_name %s",
|
||||
server_options->server_name.str));
|
||||
|
||||
tables.init_one_table("mysql", 5, "servers", 7, "servers", TL_WRITE);
|
||||
tables.init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_SERVERS_NAME, 0, TL_WRITE);
|
||||
|
||||
/* hit the memory hit first */
|
||||
if ((error= delete_server_record_in_cache(server_options)))
|
||||
@@ -734,8 +735,7 @@ int update_server(THD *thd, FOREIGN_SERVER *existing, FOREIGN_SERVER *altered)
|
||||
TABLE_LIST tables;
|
||||
DBUG_ENTER("update_server");
|
||||
|
||||
tables.init_one_table("mysql", 5, "servers", 7, "servers",
|
||||
TL_WRITE);
|
||||
tables.init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_SERVERS_NAME, 0, TL_WRITE);
|
||||
|
||||
if (!(table= open_ltable(thd, &tables, TL_WRITE, MYSQL_LOCK_IGNORE_TIMEOUT)))
|
||||
{
|
||||
|
||||
179
sql/sql_show.cc
179
sql/sql_show.cc
@@ -1247,8 +1247,8 @@ mysqld_show_create_get_fields(THD *thd, TABLE_LIST *table_list,
|
||||
bool error= TRUE;
|
||||
MEM_ROOT *mem_root= thd->mem_root;
|
||||
DBUG_ENTER("mysqld_show_create_get_fields");
|
||||
DBUG_PRINT("enter",("db: %s table: %s",table_list->db,
|
||||
table_list->table_name));
|
||||
DBUG_PRINT("enter",("db: %s table: %s",table_list->db.str,
|
||||
table_list->table_name.str));
|
||||
|
||||
/* We want to preserve the tree for views. */
|
||||
thd->lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_VIEW;
|
||||
@@ -1276,14 +1276,14 @@ mysqld_show_create_get_fields(THD *thd, TABLE_LIST *table_list,
|
||||
if (thd->lex->table_type == TABLE_TYPE_VIEW && !table_list->view)
|
||||
{
|
||||
my_error(ER_WRONG_OBJECT, MYF(0),
|
||||
table_list->db, table_list->table_name, "VIEW");
|
||||
table_list->db.str, table_list->table_name.str, "VIEW");
|
||||
goto exit;
|
||||
}
|
||||
else if (thd->lex->table_type == TABLE_TYPE_SEQUENCE &&
|
||||
table_list->table->s->table_type != TABLE_TYPE_SEQUENCE)
|
||||
{
|
||||
my_error(ER_NOT_SEQUENCE, MYF(0),
|
||||
table_list->db, table_list->table_name);
|
||||
table_list->db.str, table_list->table_name.str);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
@@ -1359,8 +1359,8 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
|
||||
List<Item> field_list;
|
||||
bool error= TRUE;
|
||||
DBUG_ENTER("mysqld_show_create");
|
||||
DBUG_PRINT("enter",("db: %s table: %s",table_list->db,
|
||||
table_list->table_name));
|
||||
DBUG_PRINT("enter",("db: %s table: %s",table_list->db.str,
|
||||
table_list->table_name.str));
|
||||
|
||||
/*
|
||||
Metadata locks taken during SHOW CREATE should be released when
|
||||
@@ -1392,8 +1392,7 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
|
||||
else
|
||||
{
|
||||
if (table_list->schema_table)
|
||||
protocol->store(table_list->schema_table->table_name,
|
||||
system_charset_info);
|
||||
protocol->store(table_list->schema_table->table_name, system_charset_info);
|
||||
else
|
||||
protocol->store(table_list->table->alias.c_ptr(), system_charset_info);
|
||||
}
|
||||
@@ -1481,7 +1480,7 @@ bool mysqld_show_create_db(THD *thd, LEX_CSTRING *dbname,
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
#endif
|
||||
if (is_infoschema_db(dbname->str))
|
||||
if (is_infoschema_db(dbname))
|
||||
{
|
||||
*dbname= INFORMATION_SCHEMA_NAME;
|
||||
create.default_table_charset= system_charset_info;
|
||||
@@ -1510,7 +1509,7 @@ bool mysqld_show_create_db(THD *thd, LEX_CSTRING *dbname,
|
||||
buffer.append(STRING_WITH_LEN("CREATE DATABASE "));
|
||||
if (options.if_not_exists())
|
||||
buffer.append(STRING_WITH_LEN("/*!32312 IF NOT EXISTS*/ "));
|
||||
append_identifier(thd, &buffer, dbname->str, dbname->length);
|
||||
append_identifier(thd, &buffer, dbname);
|
||||
|
||||
if (create.default_table_charset)
|
||||
{
|
||||
@@ -1545,7 +1544,7 @@ mysqld_list_fields(THD *thd, TABLE_LIST *table_list, const char *wild)
|
||||
TABLE *table;
|
||||
MEM_ROOT *mem_root= thd->mem_root;
|
||||
DBUG_ENTER("mysqld_list_fields");
|
||||
DBUG_PRINT("enter",("table: %s",table_list->table_name));
|
||||
DBUG_PRINT("enter",("table: %s", table_list->table_name.str));
|
||||
|
||||
if (open_normal_and_derived_tables(thd, table_list,
|
||||
MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL,
|
||||
@@ -1885,7 +1884,7 @@ static void append_create_options(THD *thd, String *packet,
|
||||
|
||||
DBUG_ASSERT(opt->value.str);
|
||||
packet->append(' ');
|
||||
append_identifier(thd, packet, opt->name.str, opt->name.length);
|
||||
append_identifier(thd, packet, &opt->name);
|
||||
packet->append('=');
|
||||
if (opt->quoted_value)
|
||||
append_unescaped(packet, opt->value.str, opt->value.length);
|
||||
@@ -2099,7 +2098,7 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
|
||||
{
|
||||
List<Item> field_list;
|
||||
char tmp[MAX_FIELD_WIDTH], *for_str, def_value_buf[MAX_FIELD_WIDTH];
|
||||
const char *alias;
|
||||
LEX_CSTRING alias;
|
||||
String type;
|
||||
String def_value;
|
||||
Field **ptr,*field;
|
||||
@@ -2145,15 +2144,19 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
|
||||
if (create_info_arg && create_info_arg->if_not_exists())
|
||||
packet->append(STRING_WITH_LEN("IF NOT EXISTS "));
|
||||
if (table_list->schema_table)
|
||||
alias= table_list->schema_table->table_name;
|
||||
{
|
||||
alias.str= table_list->schema_table->table_name;
|
||||
alias.length= strlen(alias.str);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (lower_case_table_names == 2 || table_list->vers_force_alias)
|
||||
alias= table->alias.c_ptr();
|
||||
else
|
||||
{
|
||||
alias= share->table_name.str;
|
||||
alias.str= table->alias.c_ptr();
|
||||
alias.length= table->alias.length();
|
||||
}
|
||||
else
|
||||
alias= share->table_name;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2167,14 +2170,14 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
|
||||
{
|
||||
const LEX_CSTRING *const db=
|
||||
table_list->schema_table ? &INFORMATION_SCHEMA_NAME : &table->s->db;
|
||||
if (!thd->db || strcmp(db->str, thd->db))
|
||||
if (!thd->db.str || cmp(db, &thd->db))
|
||||
{
|
||||
append_identifier(thd, packet, db->str, db->length);
|
||||
append_identifier(thd, packet, db);
|
||||
packet->append(STRING_WITH_LEN("."));
|
||||
}
|
||||
}
|
||||
|
||||
append_identifier(thd, packet, alias, strlen(alias));
|
||||
append_identifier(thd, packet, &alias);
|
||||
packet->append(STRING_WITH_LEN(" (\n"));
|
||||
/*
|
||||
We need this to get default values from the table
|
||||
@@ -2196,8 +2199,7 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
|
||||
|
||||
not_the_first_field= true;
|
||||
packet->append(STRING_WITH_LEN(" "));
|
||||
append_identifier(thd,packet,field->field_name.str,
|
||||
field->field_name.length);
|
||||
append_identifier(thd, packet, &field->field_name);
|
||||
packet->append(' ');
|
||||
|
||||
type.set(tmp, sizeof(tmp), system_charset_info);
|
||||
@@ -2330,7 +2332,7 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
|
||||
packet->append(STRING_WITH_LEN("KEY "));
|
||||
|
||||
if (!found_primary)
|
||||
append_identifier(thd, packet, key_info->name.str, key_info->name.length);
|
||||
append_identifier(thd, packet, &key_info->name);
|
||||
|
||||
packet->append(STRING_WITH_LEN(" ("));
|
||||
|
||||
@@ -2344,8 +2346,7 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
|
||||
packet->append(',');
|
||||
|
||||
if (key_part->field)
|
||||
append_identifier(thd,packet, key_part->field->field_name.str,
|
||||
key_part->field->field_name.length);
|
||||
append_identifier(thd, packet, &key_part->field->field_name);
|
||||
if (key_part->field &&
|
||||
(key_part->length !=
|
||||
table->field[key_part->fieldnr-1]->key_length() &&
|
||||
@@ -2361,7 +2362,7 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
|
||||
{
|
||||
LEX_CSTRING *parser_name= plugin_name(key_info->parser);
|
||||
packet->append(STRING_WITH_LEN(" /*!50100 WITH PARSER "));
|
||||
append_identifier(thd, packet, parser_name->str, parser_name->length);
|
||||
append_identifier(thd, packet, parser_name);
|
||||
packet->append(STRING_WITH_LEN(" */ "));
|
||||
}
|
||||
append_create_options(thd, packet, key_info->option_list, check_options,
|
||||
@@ -2413,10 +2414,10 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
|
||||
check->print(&str);
|
||||
|
||||
packet->append(STRING_WITH_LEN(",\n "));
|
||||
if (check->name.length)
|
||||
if (check->name.str)
|
||||
{
|
||||
packet->append(STRING_WITH_LEN("CONSTRAINT "));
|
||||
append_identifier(thd, packet, check->name.str, check->name.length);
|
||||
append_identifier(thd, packet, &check->name);
|
||||
}
|
||||
packet->append(STRING_WITH_LEN(" CHECK ("));
|
||||
packet->append(str);
|
||||
@@ -2560,11 +2561,11 @@ void append_definer(THD *thd, String *buffer, const LEX_CSTRING *definer_user,
|
||||
const LEX_CSTRING *definer_host)
|
||||
{
|
||||
buffer->append(STRING_WITH_LEN("DEFINER="));
|
||||
append_identifier(thd, buffer, definer_user->str, definer_user->length);
|
||||
append_identifier(thd, buffer, definer_user);
|
||||
if (definer_host->str && definer_host->str[0])
|
||||
{
|
||||
buffer->append('@');
|
||||
append_identifier(thd, buffer, definer_host->str, definer_host->length);
|
||||
append_identifier(thd, buffer, definer_host);
|
||||
}
|
||||
buffer->append(' ');
|
||||
}
|
||||
@@ -2580,7 +2581,7 @@ static int show_create_view(THD *thd, TABLE_LIST *table, String *buff)
|
||||
MODE_MAXDB |
|
||||
MODE_ANSI)) != 0;
|
||||
|
||||
if (!thd->db || strcmp(thd->db, table->view_db.str))
|
||||
if (!thd->db.str || cmp(&thd->db, &table->view_db))
|
||||
/*
|
||||
print compact view name if the view belongs to the current database
|
||||
*/
|
||||
@@ -2597,7 +2598,7 @@ static int show_create_view(THD *thd, TABLE_LIST *table, String *buff)
|
||||
tbl;
|
||||
tbl= tbl->next_global)
|
||||
{
|
||||
if (strcmp(table->view_db.str, tbl->view ? tbl->view_db.str :tbl->db)!= 0)
|
||||
if (cmp(&table->view_db, tbl->view ? &tbl->view_db : &tbl->db))
|
||||
{
|
||||
table->compact_view_format= FALSE;
|
||||
break;
|
||||
@@ -2613,10 +2614,10 @@ static int show_create_view(THD *thd, TABLE_LIST *table, String *buff)
|
||||
buff->append(STRING_WITH_LEN("VIEW "));
|
||||
if (!compact_view_name)
|
||||
{
|
||||
append_identifier(thd, buff, table->view_db.str, table->view_db.length);
|
||||
append_identifier(thd, buff, &table->view_db);
|
||||
buff->append('.');
|
||||
}
|
||||
append_identifier(thd, buff, table->view_name.str, table->view_name.length);
|
||||
append_identifier(thd, buff, &table->view_name);
|
||||
buff->append(STRING_WITH_LEN(" AS "));
|
||||
|
||||
/*
|
||||
@@ -2659,7 +2660,7 @@ static int show_create_sequence(THD *thd, TABLE_LIST *table_list,
|
||||
alias= table->s->table_name;
|
||||
|
||||
packet->append(STRING_WITH_LEN("CREATE SEQUENCE "));
|
||||
append_identifier(thd, packet, alias.str, alias.length);
|
||||
append_identifier(thd, packet, &alias);
|
||||
packet->append(STRING_WITH_LEN(" start with "));
|
||||
packet->append_longlong(seq->start);
|
||||
packet->append(STRING_WITH_LEN(" minvalue "));
|
||||
@@ -2833,8 +2834,9 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose)
|
||||
The following variables are only safe to access under a lock
|
||||
*/
|
||||
|
||||
if ((thd_info->db= tmp->db)) // Safe test
|
||||
thd_info->db= thd->strdup(thd_info->db);
|
||||
thd_info->db= 0;
|
||||
if (tmp->db.str)
|
||||
thd_info->db= thd->strmake(tmp->db.str, tmp->db.length);
|
||||
|
||||
if (tmp->query())
|
||||
{
|
||||
@@ -3194,7 +3196,7 @@ int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond)
|
||||
while ((tmp= it++))
|
||||
{
|
||||
Security_context *tmp_sctx= tmp->security_ctx;
|
||||
const char *val, *db;
|
||||
const char *val;
|
||||
ulonglong max_counter;
|
||||
bool got_thd_data;
|
||||
|
||||
@@ -3226,9 +3228,9 @@ int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond)
|
||||
if ((got_thd_data= !trylock_short(&tmp->LOCK_thd_data)))
|
||||
{
|
||||
/* DB */
|
||||
if ((db= tmp->db))
|
||||
if (tmp->db.str)
|
||||
{
|
||||
table->field[3]->store(db, strlen(db), cs);
|
||||
table->field[3]->store(tmp->db.str, tmp->db.length, cs);
|
||||
table->field[3]->set_notnull();
|
||||
}
|
||||
}
|
||||
@@ -4143,7 +4145,7 @@ bool get_lookup_field_values(THD *thd, COND *cond, TABLE_LIST *tables,
|
||||
case SQLCOM_SHOW_TRIGGERS:
|
||||
case SQLCOM_SHOW_EVENTS:
|
||||
thd->make_lex_string(&lookup_field_values->db_value,
|
||||
lex->select_lex.db, strlen(lex->select_lex.db));
|
||||
lex->select_lex.db.str, lex->select_lex.db.length);
|
||||
if (wild)
|
||||
{
|
||||
thd->make_lex_string(&lookup_field_values->table_value,
|
||||
@@ -4241,8 +4243,7 @@ static int make_db_list(THD *thd, Dynamic_array<LEX_CSTRING*> *files,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (is_infoschema_db(lookup_field_vals->db_value.str,
|
||||
lookup_field_vals->db_value.length))
|
||||
if (is_infoschema_db(&lookup_field_vals->db_value))
|
||||
{
|
||||
if (files->append_val(&INFORMATION_SCHEMA_NAME))
|
||||
return 1;
|
||||
@@ -4385,7 +4386,7 @@ make_table_name_list(THD *thd, Dynamic_array<LEX_CSTRING*> *table_names,
|
||||
{
|
||||
LEX_CSTRING *name;
|
||||
ST_SCHEMA_TABLE *schema_table=
|
||||
find_schema_table(thd, lookup_field_vals->table_value.str);
|
||||
find_schema_table(thd, &lookup_field_vals->table_value);
|
||||
if (schema_table && !schema_table->hidden)
|
||||
{
|
||||
if (!(name= thd->make_clex_string(schema_table->table_name,
|
||||
@@ -4665,8 +4666,7 @@ static int fill_schema_table_names(THD *thd, TABLE_LIST *tables,
|
||||
CHARSET_INFO *cs= system_charset_info;
|
||||
handlerton *hton;
|
||||
bool is_sequence;
|
||||
if (ha_table_exists(thd, db_name->str, table_name->str, &hton,
|
||||
&is_sequence))
|
||||
if (ha_table_exists(thd, db_name, table_name, &hton, &is_sequence))
|
||||
{
|
||||
if (hton == view_pseudo_hton)
|
||||
table->field[3]->store(STRING_WITH_LEN("VIEW"), cs);
|
||||
@@ -4768,7 +4768,7 @@ try_acquire_high_prio_shared_mdl_lock(THD *thd, TABLE_LIST *table,
|
||||
bool can_deadlock)
|
||||
{
|
||||
bool error;
|
||||
table->mdl_request.init(MDL_key::TABLE, table->db, table->table_name,
|
||||
table->mdl_request.init(MDL_key::TABLE, table->db.str, table->table_name.str,
|
||||
MDL_SHARED_HIGH_PRIO, MDL_TRANSACTION);
|
||||
|
||||
if (can_deadlock)
|
||||
@@ -4847,15 +4847,15 @@ static int fill_schema_table_from_frm(THD *thd, TABLE *table,
|
||||
*/
|
||||
strmov(db_name_buff, db_name->str);
|
||||
strmov(table_name_buff, table_name->str);
|
||||
my_casedn_str(files_charset_info, db_name_buff);
|
||||
my_casedn_str(files_charset_info, table_name_buff);
|
||||
table_list.db= db_name_buff;
|
||||
table_list.table_name= table_name_buff;
|
||||
table_list.db.length= my_casedn_str(files_charset_info, db_name_buff);
|
||||
table_list.table_name.length= my_casedn_str(files_charset_info, table_name_buff);
|
||||
table_list.db.str= db_name_buff;
|
||||
table_list.table_name.str= table_name_buff;
|
||||
}
|
||||
else
|
||||
{
|
||||
table_list.table_name= table_name->str;
|
||||
table_list.db= db_name->str;
|
||||
table_list.table_name= *table_name;
|
||||
table_list.db= *db_name;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -4885,15 +4885,15 @@ static int fill_schema_table_from_frm(THD *thd, TABLE *table,
|
||||
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
|
||||
ER_WARN_I_S_SKIPPED_TABLE,
|
||||
ER_THD(thd, ER_WARN_I_S_SKIPPED_TABLE),
|
||||
table_list.db, table_list.table_name);
|
||||
table_list.db.str, table_list.table_name.str);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (schema_table->i_s_requested_object & OPEN_TRIGGER_ONLY)
|
||||
{
|
||||
init_sql_alloc(&tbl.mem_root, TABLE_ALLOC_BLOCK_SIZE, 0, MYF(0));
|
||||
if (!Table_triggers_list::check_n_load(thd, db_name->str,
|
||||
table_name->str, &tbl, 1))
|
||||
if (!Table_triggers_list::check_n_load(thd, db_name,
|
||||
table_name, &tbl, 1))
|
||||
{
|
||||
table_list.table= &tbl;
|
||||
res= schema_table->process_table(thd, &table_list, table,
|
||||
@@ -4950,7 +4950,7 @@ static int fill_schema_table_from_frm(THD *thd, TABLE *table,
|
||||
goto end_share;
|
||||
}
|
||||
|
||||
if (!open_table_from_share(thd, share, table_name->str, 0,
|
||||
if (!open_table_from_share(thd, share, table_name, 0,
|
||||
(EXTRA_RECORD | OPEN_FRM_FILE_ONLY),
|
||||
thd->open_options, &tbl, FALSE))
|
||||
{
|
||||
@@ -5143,17 +5143,10 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
|
||||
*/
|
||||
if (lsel && lsel->table_list.first)
|
||||
{
|
||||
LEX_CSTRING db_name, table_name;
|
||||
|
||||
db_name.str= lsel->table_list.first->db;
|
||||
db_name.length= lsel->table_list.first->db_length;
|
||||
|
||||
table_name.str= lsel->table_list.first->table_name;
|
||||
table_name.length= lsel->table_list.first->table_name_length;
|
||||
|
||||
error= fill_schema_table_by_open(thd, thd->mem_root, TRUE,
|
||||
table, schema_table,
|
||||
&db_name, &table_name,
|
||||
&lsel->table_list.first->db,
|
||||
&lsel->table_list.first->table_name,
|
||||
&open_tables_state_backup,
|
||||
can_deadlock);
|
||||
goto err;
|
||||
@@ -5215,10 +5208,8 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
|
||||
#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.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, TRUE, 1, TRUE))
|
||||
continue;
|
||||
@@ -6432,10 +6423,9 @@ int fill_schema_proc(THD *thd, TABLE_LIST *tables, COND *cond)
|
||||
thd->security_ctx->priv_host, NullS);
|
||||
/* We use this TABLE_LIST instance only for checking of privileges. */
|
||||
bzero((char*) &proc_tables,sizeof(proc_tables));
|
||||
proc_tables.db= (char*) "mysql";
|
||||
proc_tables.db_length= 5;
|
||||
proc_tables.table_name= proc_tables.alias= (char*) "proc";
|
||||
proc_tables.table_name_length= 4;
|
||||
proc_tables.db= MYSQL_SCHEMA_NAME;
|
||||
proc_tables.table_name= MYSQL_PROC_NAME;
|
||||
proc_tables.alias= MYSQL_PROC_NAME;
|
||||
proc_tables.lock_type= TL_READ;
|
||||
full_access= !check_table_access(thd, SELECT_ACL, &proc_tables, FALSE,
|
||||
1, TRUE);
|
||||
@@ -7663,7 +7653,7 @@ int fill_open_tables(THD *thd, TABLE_LIST *tables, COND *cond)
|
||||
TABLE *table= tables->table;
|
||||
CHARSET_INFO *cs= system_charset_info;
|
||||
OPEN_TABLE_LIST *open_list;
|
||||
if (!(open_list=list_open_tables(thd,thd->lex->select_lex.db, wild))
|
||||
if (!(open_list=list_open_tables(thd,thd->lex->select_lex.db.str, wild))
|
||||
&& thd->is_fatal_error)
|
||||
DBUG_RETURN(1);
|
||||
|
||||
@@ -7883,7 +7873,8 @@ static my_bool find_schema_table_in_plugin(THD *thd, plugin_ref plugin,
|
||||
|
||||
if (!my_strcasecmp(system_charset_info,
|
||||
schema_table->table_name,
|
||||
table_name)) {
|
||||
table_name))
|
||||
{
|
||||
my_plugin_lock(thd, plugin);
|
||||
p_schema_table->schema_table= schema_table;
|
||||
DBUG_RETURN(1);
|
||||
@@ -7894,7 +7885,7 @@ static my_bool find_schema_table_in_plugin(THD *thd, plugin_ref plugin,
|
||||
|
||||
|
||||
/*
|
||||
Find schema_tables elment by name
|
||||
Find schema_tables element by name
|
||||
|
||||
SYNOPSIS
|
||||
find_schema_table()
|
||||
@@ -7906,7 +7897,7 @@ static my_bool find_schema_table_in_plugin(THD *thd, plugin_ref plugin,
|
||||
# pointer to 'schema_tables' element
|
||||
*/
|
||||
|
||||
ST_SCHEMA_TABLE *find_schema_table(THD *thd, const char* table_name,
|
||||
ST_SCHEMA_TABLE *find_schema_table(THD *thd, const LEX_CSTRING *table_name,
|
||||
bool *in_plugin)
|
||||
{
|
||||
schema_table_ref schema_table_a;
|
||||
@@ -7918,12 +7909,12 @@ ST_SCHEMA_TABLE *find_schema_table(THD *thd, const char* table_name,
|
||||
{
|
||||
if (!my_strcasecmp(system_charset_info,
|
||||
schema_table->table_name,
|
||||
table_name))
|
||||
table_name->str))
|
||||
DBUG_RETURN(schema_table);
|
||||
}
|
||||
|
||||
*in_plugin= true;
|
||||
schema_table_a.table_name= table_name;
|
||||
schema_table_a.table_name= table_name->str;
|
||||
if (plugin_foreach(thd, find_schema_table_in_plugin,
|
||||
MYSQL_INFORMATION_SCHEMA_PLUGIN, &schema_table_a))
|
||||
DBUG_RETURN(schema_table_a.schema_table);
|
||||
@@ -8084,7 +8075,7 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list)
|
||||
field_list, (ORDER*) 0, 0, 0,
|
||||
(select_lex->options | thd->variables.option_bits |
|
||||
TMP_TABLE_ALL_COLUMNS), HA_POS_ERROR,
|
||||
table_list->alias, false, keep_row_order)))
|
||||
&table_list->alias, false, keep_row_order)))
|
||||
DBUG_RETURN(0);
|
||||
my_bitmap_map* bitmaps=
|
||||
(my_bitmap_map*) thd->alloc(bitmap_buffer_size(field_count));
|
||||
@@ -8182,7 +8173,7 @@ int make_table_names_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
|
||||
|
||||
buffer.length(0);
|
||||
buffer.append(field_info->old_name);
|
||||
buffer.append(lex->select_lex.db);
|
||||
buffer.append(&lex->select_lex.db);
|
||||
if (lex->wild && lex->wild->ptr())
|
||||
{
|
||||
buffer.append(STRING_WITH_LEN(" ("));
|
||||
@@ -8324,12 +8315,11 @@ int mysql_schema_table(THD *thd, LEX *lex, TABLE_LIST *table_list)
|
||||
views
|
||||
working correctly
|
||||
*/
|
||||
if (table_list->schema_table_name)
|
||||
if (table_list->schema_table_name.str)
|
||||
table->alias_name_used= my_strcasecmp(table_alias_charset,
|
||||
table_list->schema_table_name,
|
||||
table_list->alias);
|
||||
table_list->table_name= table->s->table_name.str;
|
||||
table_list->table_name_length= table->s->table_name.length;
|
||||
table_list->schema_table_name.str,
|
||||
table_list->alias.str);
|
||||
table_list->table_name= table->s->table_name;
|
||||
table_list->table= table;
|
||||
table->next= thd->derived_tables;
|
||||
thd->derived_tables= table;
|
||||
@@ -9946,12 +9936,12 @@ static
|
||||
TABLE_LIST *get_trigger_table(THD *thd, const sp_name *trg_name)
|
||||
{
|
||||
char trn_path_buff[FN_REFLEN];
|
||||
LEX_STRING trn_path= { trn_path_buff, 0 };
|
||||
LEX_CSTRING trn_path= { trn_path_buff, 0 };
|
||||
LEX_CSTRING db;
|
||||
LEX_CSTRING tbl_name;
|
||||
TABLE_LIST *table;
|
||||
|
||||
build_trn_path(thd, trg_name, &trn_path);
|
||||
build_trn_path(thd, trg_name, (LEX_STRING*) &trn_path);
|
||||
|
||||
if (check_trn_exists(&trn_path))
|
||||
{
|
||||
@@ -9959,8 +9949,7 @@ TABLE_LIST *get_trigger_table(THD *thd, const sp_name *trg_name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (load_table_name_for_trigger(thd, trg_name, (LEX_CSTRING*) &trn_path,
|
||||
&tbl_name))
|
||||
if (load_table_name_for_trigger(thd, trg_name, &trn_path, &tbl_name))
|
||||
return NULL;
|
||||
|
||||
/* We need to reset statement table list to be PS/SP friendly. */
|
||||
@@ -9978,8 +9967,7 @@ TABLE_LIST *get_trigger_table(THD *thd, const sp_name *trg_name)
|
||||
if (db.str == NULL || tbl_name.str == NULL)
|
||||
return NULL;
|
||||
|
||||
table->init_one_table(db.str, db.length, tbl_name.str, tbl_name.length,
|
||||
tbl_name.str, TL_IGNORE);
|
||||
table->init_one_table(&db, &tbl_name, 0, TL_IGNORE);
|
||||
|
||||
return table;
|
||||
}
|
||||
@@ -10027,7 +10015,7 @@ bool show_create_trigger(THD *thd, const sp_name *trg_name)
|
||||
{
|
||||
my_error(ER_TRG_CANT_OPEN_TABLE, MYF(0),
|
||||
(const char *) trg_name->m_db.str,
|
||||
(const char *) lst->table_name);
|
||||
(const char *) lst->table_name.str);
|
||||
|
||||
goto exit;
|
||||
|
||||
@@ -10048,8 +10036,7 @@ bool show_create_trigger(THD *thd, const sp_name *trg_name)
|
||||
{
|
||||
my_error(ER_TRG_CORRUPTED_FILE, MYF(0),
|
||||
(const char *) trg_name->m_db.str,
|
||||
(const char *) lst->table_name);
|
||||
|
||||
(const char *) lst->table_name.str);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
||||
@@ -84,6 +84,10 @@ int copy_event_to_schema_table(THD *thd, TABLE *sch_table, TABLE *event_table);
|
||||
|
||||
bool append_identifier(THD *thd, String *packet, const char *name,
|
||||
uint length);
|
||||
static inline bool append_identifier(THD *thd, String *packet, const LEX_CSTRING *name)
|
||||
{
|
||||
return append_identifier(thd, packet, name->str, name->length);
|
||||
}
|
||||
void mysqld_list_fields(THD *thd,TABLE_LIST *table, const char *wild);
|
||||
int mysqld_dump_create_info(THD *thd, TABLE_LIST *table_list, int fd);
|
||||
bool mysqld_show_create_get_fields(THD *thd, TABLE_LIST *table_list,
|
||||
@@ -118,8 +122,9 @@ bool schema_table_store_record(THD *thd, TABLE *table);
|
||||
void initialize_information_schema_acl();
|
||||
COND *make_cond_for_info_schema(THD *thd, COND *cond, TABLE_LIST *table);
|
||||
|
||||
ST_SCHEMA_TABLE *find_schema_table(THD *thd, const char* table_name, bool *in_plugin);
|
||||
static inline ST_SCHEMA_TABLE *find_schema_table(THD *thd, const char* table_name)
|
||||
ST_SCHEMA_TABLE *find_schema_table(THD *thd, const LEX_CSTRING *table_name,
|
||||
bool *in_plugin);
|
||||
static inline ST_SCHEMA_TABLE *find_schema_table(THD *thd, const LEX_CSTRING *table_name)
|
||||
{ bool unused; return find_schema_table(thd, table_name, &unused); }
|
||||
|
||||
ST_SCHEMA_TABLE *get_schema_table(enum enum_schema_tables schema_table_idx);
|
||||
|
||||
@@ -65,16 +65,13 @@ static const uint STATISTICS_TABLES= 3;
|
||||
The names of the statistical tables in this array must correspond the
|
||||
definitions of the tables in the file ../scripts/mysql_system_tables.sql
|
||||
*/
|
||||
static const LEX_STRING stat_table_name[STATISTICS_TABLES]=
|
||||
static const LEX_CSTRING stat_table_name[STATISTICS_TABLES]=
|
||||
{
|
||||
{ C_STRING_WITH_LEN("table_stats") },
|
||||
{ C_STRING_WITH_LEN("column_stats") },
|
||||
{ C_STRING_WITH_LEN("index_stats") }
|
||||
{ STRING_WITH_LEN("table_stats") },
|
||||
{ STRING_WITH_LEN("column_stats") },
|
||||
{ STRING_WITH_LEN("index_stats") }
|
||||
};
|
||||
|
||||
/* Name of database to which the statistical tables belong */
|
||||
static const LEX_STRING stat_tables_db_name= { C_STRING_WITH_LEN("mysql") };
|
||||
|
||||
|
||||
/**
|
||||
@details
|
||||
@@ -93,10 +90,9 @@ inline void init_table_list_for_stat_tables(TABLE_LIST *tables, bool for_write)
|
||||
|
||||
for (i= 0; i < STATISTICS_TABLES; i++)
|
||||
{
|
||||
tables[i].db= stat_tables_db_name.str;
|
||||
tables[i].db_length= stat_tables_db_name.length;
|
||||
tables[i].alias= tables[i].table_name= stat_table_name[i].str;
|
||||
tables[i].table_name_length= stat_table_name[i].length;
|
||||
tables[i].db= MYSQL_SCHEMA_NAME;
|
||||
tables[i].table_name= stat_table_name[i];
|
||||
tables[i].alias= stat_table_name[i];
|
||||
tables[i].lock_type= for_write ? TL_WRITE : TL_READ;
|
||||
if (i < STATISTICS_TABLES - 1)
|
||||
tables[i].next_global= tables[i].next_local=
|
||||
@@ -115,17 +111,16 @@ inline void init_table_list_for_stat_tables(TABLE_LIST *tables, bool for_write)
|
||||
otherwise it is set to TL_WRITE.
|
||||
*/
|
||||
|
||||
static
|
||||
inline void init_table_list_for_single_stat_table(TABLE_LIST *tbl,
|
||||
const LEX_STRING *stat_tab_name,
|
||||
bool for_write)
|
||||
static inline
|
||||
void init_table_list_for_single_stat_table(TABLE_LIST *tbl,
|
||||
const LEX_CSTRING *stat_tab_name,
|
||||
bool for_write)
|
||||
{
|
||||
memset((char *) tbl, 0, sizeof(TABLE_LIST));
|
||||
|
||||
tbl->db= stat_tables_db_name.str;
|
||||
tbl->db_length= stat_tables_db_name.length;
|
||||
tbl->alias= tbl->table_name= stat_tab_name->str;
|
||||
tbl->table_name_length= stat_tab_name->length;
|
||||
tbl->db= MYSQL_SCHEMA_NAME;
|
||||
tbl->table_name= *stat_tab_name;
|
||||
tbl->alias= *stat_tab_name;
|
||||
tbl->lock_type= for_write ? TL_WRITE : TL_READ;
|
||||
}
|
||||
|
||||
@@ -294,7 +289,7 @@ inline int open_stat_tables(THD *thd, TABLE_LIST *tables,
|
||||
*/
|
||||
static
|
||||
inline int open_single_stat_table(THD *thd, TABLE_LIST *table,
|
||||
const LEX_STRING *stat_tab_name,
|
||||
const LEX_CSTRING *stat_tab_name,
|
||||
Open_tables_backup *backup,
|
||||
bool for_write)
|
||||
{
|
||||
@@ -472,8 +467,8 @@ protected:
|
||||
/* Table for which statistical data is read / updated */
|
||||
TABLE *table;
|
||||
TABLE_SHARE *table_share; /* Table share for 'table */
|
||||
LEX_CSTRING *db_name; /* Name of the database containing 'table' */
|
||||
LEX_CSTRING *table_name; /* Name of the table 'table' */
|
||||
const LEX_CSTRING *db_name; /* Name of the database containing 'table' */
|
||||
const LEX_CSTRING *table_name; /* Name of the table 'table' */
|
||||
|
||||
void store_record_for_update()
|
||||
{
|
||||
@@ -528,12 +523,10 @@ public:
|
||||
by the database name 'db' and the table name 'tab'.
|
||||
*/
|
||||
|
||||
Stat_table(TABLE *stat, LEX_CSTRING *db, LEX_CSTRING *tab)
|
||||
:stat_table(stat), table_share(NULL)
|
||||
Stat_table(TABLE *stat, const LEX_CSTRING *db, const LEX_CSTRING *tab)
|
||||
:stat_table(stat), table_share(NULL),db_name(db), table_name(tab)
|
||||
{
|
||||
common_init_stat_table();
|
||||
db_name= db;
|
||||
table_name= tab;
|
||||
}
|
||||
|
||||
|
||||
@@ -553,7 +546,7 @@ public:
|
||||
The method is called by the update_table_name_key_parts function.
|
||||
*/
|
||||
|
||||
virtual void change_full_table_name(LEX_CSTRING *db, LEX_CSTRING *tab)= 0;
|
||||
virtual void change_full_table_name(const LEX_CSTRING *db, const LEX_CSTRING *tab)= 0;
|
||||
|
||||
|
||||
/**
|
||||
@@ -709,7 +702,7 @@ public:
|
||||
to store the new names in the record buffer used for updates.
|
||||
*/
|
||||
|
||||
bool update_table_name_key_parts(LEX_CSTRING *db, LEX_CSTRING *tab)
|
||||
bool update_table_name_key_parts(const LEX_CSTRING *db, const LEX_CSTRING *tab)
|
||||
{
|
||||
store_record_for_update();
|
||||
change_full_table_name(db, tab);
|
||||
@@ -771,7 +764,7 @@ private:
|
||||
table_name_field= stat_table->field[TABLE_STAT_TABLE_NAME];
|
||||
}
|
||||
|
||||
void change_full_table_name(LEX_CSTRING *db, LEX_CSTRING *tab)
|
||||
void change_full_table_name(const LEX_CSTRING *db, const LEX_CSTRING *tab)
|
||||
{
|
||||
db_name_field->store(db->str, db->length, system_charset_info);
|
||||
table_name_field->store(tab->str, tab->length, system_charset_info);
|
||||
@@ -801,7 +794,7 @@ public:
|
||||
from the database 'db'.
|
||||
*/
|
||||
|
||||
Table_stat(TABLE *stat, LEX_CSTRING *db, LEX_CSTRING *tab)
|
||||
Table_stat(TABLE *stat, const LEX_CSTRING *db, const LEX_CSTRING *tab)
|
||||
:Stat_table(stat, db, tab)
|
||||
{
|
||||
common_init_table_stat();
|
||||
@@ -915,7 +908,7 @@ private:
|
||||
column_name_field= stat_table->field[COLUMN_STAT_COLUMN_NAME];
|
||||
}
|
||||
|
||||
void change_full_table_name(LEX_CSTRING *db, LEX_CSTRING *tab)
|
||||
void change_full_table_name(const LEX_CSTRING *db, const LEX_CSTRING *tab)
|
||||
{
|
||||
db_name_field->store(db->str, db->length, system_charset_info);
|
||||
table_name_field->store(tab->str, tab->length, system_charset_info);
|
||||
@@ -945,7 +938,7 @@ public:
|
||||
from the database 'db'.
|
||||
*/
|
||||
|
||||
Column_stat(TABLE *stat, LEX_CSTRING *db, LEX_CSTRING *tab)
|
||||
Column_stat(TABLE *stat, const LEX_CSTRING *db, const LEX_CSTRING *tab)
|
||||
:Stat_table(stat, db, tab)
|
||||
{
|
||||
common_init_column_stat_table();
|
||||
@@ -1250,7 +1243,7 @@ private:
|
||||
prefix_arity_field= stat_table->field[INDEX_STAT_PREFIX_ARITY];
|
||||
}
|
||||
|
||||
void change_full_table_name(LEX_CSTRING *db, LEX_CSTRING *tab)
|
||||
void change_full_table_name(const LEX_CSTRING *db, const LEX_CSTRING *tab)
|
||||
{
|
||||
db_name_field->store(db->str, db->length, system_charset_info);
|
||||
table_name_field->store(tab->str, tab->length, system_charset_info);
|
||||
@@ -1282,7 +1275,7 @@ public:
|
||||
from the database 'db'.
|
||||
*/
|
||||
|
||||
Index_stat(TABLE *stat, LEX_CSTRING *db, LEX_CSTRING *tab)
|
||||
Index_stat(TABLE *stat, const LEX_CSTRING *db, const LEX_CSTRING *tab)
|
||||
:Stat_table(stat, db, tab)
|
||||
{
|
||||
common_init_index_stat_table();
|
||||
@@ -3526,8 +3519,8 @@ int delete_statistics_for_index(THD *thd, TABLE *tab, KEY *key_info,
|
||||
The function is called when executing any statement that renames a table
|
||||
*/
|
||||
|
||||
int rename_table_in_stat_tables(THD *thd, LEX_CSTRING *db, LEX_CSTRING *tab,
|
||||
LEX_CSTRING *new_db, LEX_CSTRING *new_tab)
|
||||
int rename_table_in_stat_tables(THD *thd, const LEX_CSTRING *db, const LEX_CSTRING *tab,
|
||||
const LEX_CSTRING *new_db, const LEX_CSTRING *new_tab)
|
||||
{
|
||||
int err;
|
||||
enum_binlog_format save_binlog_format;
|
||||
@@ -3535,7 +3528,6 @@ int rename_table_in_stat_tables(THD *thd, LEX_CSTRING *db, LEX_CSTRING *tab,
|
||||
TABLE_LIST tables[STATISTICS_TABLES];
|
||||
Open_tables_backup open_tables_backup;
|
||||
int rc= 0;
|
||||
|
||||
DBUG_ENTER("rename_table_in_stat_tables");
|
||||
|
||||
if (open_stat_tables(thd, tables, &open_tables_backup, TRUE))
|
||||
@@ -3984,18 +3976,17 @@ double Histogram::point_selectivity(double pos, double avg_sel)
|
||||
/*
|
||||
Check whether the table is one of the persistent statistical tables.
|
||||
*/
|
||||
bool is_stat_table(const char *db, const char *table)
|
||||
bool is_stat_table(const LEX_CSTRING *db, LEX_CSTRING *table)
|
||||
{
|
||||
DBUG_ASSERT(db && table);
|
||||
DBUG_ASSERT(db->str && table->str);
|
||||
|
||||
if (!memcmp(db, stat_tables_db_name.str, stat_tables_db_name.length))
|
||||
if (!cmp(db, &MYSQL_SCHEMA_NAME))
|
||||
{
|
||||
for (uint i= 0; i < STATISTICS_TABLES; i ++)
|
||||
{
|
||||
if (!memcmp(table, stat_table_name[i].str, stat_table_name[i].length))
|
||||
if (cmp(table, &stat_table_name[i]) == 0)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -98,8 +98,8 @@ int delete_statistics_for_table(THD *thd, LEX_CSTRING *db, LEX_CSTRING *tab);
|
||||
int delete_statistics_for_column(THD *thd, TABLE *tab, Field *col);
|
||||
int delete_statistics_for_index(THD *thd, TABLE *tab, KEY *key_info,
|
||||
bool ext_prefixes_only);
|
||||
int rename_table_in_stat_tables(THD *thd, LEX_CSTRING *db, LEX_CSTRING *tab,
|
||||
LEX_CSTRING *new_db, LEX_CSTRING *new_tab);
|
||||
int rename_table_in_stat_tables(THD *thd, const LEX_CSTRING *db, const LEX_CSTRING *tab,
|
||||
const LEX_CSTRING *new_db, const LEX_CSTRING *new_tab);
|
||||
int rename_column_in_stat_tables(THD *thd, TABLE *tab, Field *col,
|
||||
const char *new_name);
|
||||
void set_statistics_for_table(THD *thd, TABLE *table);
|
||||
@@ -110,7 +110,7 @@ double get_column_range_cardinality(Field *field,
|
||||
key_range *min_endp,
|
||||
key_range *max_endp,
|
||||
uint range_flag);
|
||||
bool is_stat_table(const char *db, const char *table);
|
||||
bool is_stat_table(const LEX_CSTRING *db, LEX_CSTRING *table);
|
||||
|
||||
class Histogram
|
||||
{
|
||||
@@ -255,18 +255,6 @@ public:
|
||||
class Columns_statistics;
|
||||
class Index_statistics;
|
||||
|
||||
static inline
|
||||
int rename_table_in_stat_tables(THD *thd, const char *db, const char *tab,
|
||||
const char *new_db, const char *new_tab)
|
||||
{
|
||||
LEX_CSTRING od= { db, strlen(db) };
|
||||
LEX_CSTRING ot= { tab, strlen(tab) };
|
||||
LEX_CSTRING nd= { new_db, strlen(new_db) };
|
||||
LEX_CSTRING nt= { new_tab, strlen(new_tab) };
|
||||
return rename_table_in_stat_tables(thd, &od, &ot, &nd, &nt);
|
||||
}
|
||||
|
||||
|
||||
/* Statistical data on a table */
|
||||
|
||||
class Table_statistics
|
||||
|
||||
445
sql/sql_table.cc
445
sql/sql_table.cc
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user