cleanup: misc

This commit is contained in:
Sergei Golubchik 2018-11-11 14:20:37 +01:00
parent dda2e940fb
commit 22f1cf9292
10 changed files with 45 additions and 84 deletions

View File

@ -953,7 +953,8 @@ static int handle_request_for_tables(char *tables, size_t length,
puts(query); puts(query);
if (mysql_real_query(sock, query, query_length)) if (mysql_real_query(sock, query, query_length))
{ {
sprintf(message, "when executing '%s%s... %s'", op, tab_view, options); my_snprintf(message, sizeof(message), "when executing '%s%s... %s'",
op, tab_view, options);
DBerror(sock, message); DBerror(sock, message);
my_free(query); my_free(query);
DBUG_RETURN(1); DBUG_RETURN(1);

View File

@ -50,9 +50,9 @@
#define WSREP_WARN(...) WSREP_LOG(sql_print_warning, ##__VA_ARGS__) #define WSREP_WARN(...) WSREP_LOG(sql_print_warning, ##__VA_ARGS__)
#define WSREP_ERROR(...) WSREP_LOG(sql_print_error, ##__VA_ARGS__) #define WSREP_ERROR(...) WSREP_LOG(sql_print_error, ##__VA_ARGS__)
#define WSREP_SYNC_WAIT(thd_, before_) \ #define WSREP_SYNC_WAIT(thd_, before_) \
{ if (WSREP_CLIENT(thd_) && \ do { if (WSREP_CLIENT(thd_) && \
wsrep_sync_wait(thd_, before_)) goto wsrep_error_label; } wsrep_sync_wait(thd_, before_)) goto wsrep_error_label; } while(0)
#define WSREP_ERROR_LABEL wsrep_error_label #define WSREP_ERROR_LABEL wsrep_error_label
#else #else
#define IF_WSREP(A,B) B #define IF_WSREP(A,B) B
@ -64,7 +64,7 @@
#define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_) #define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_)
#define WSREP_TO_ISOLATION_END #define WSREP_TO_ISOLATION_END
#define WSREP_TO_ISOLATION_BEGIN_WRTCHK(db_, table_, table_list_) #define WSREP_TO_ISOLATION_BEGIN_WRTCHK(db_, table_, table_list_)
#define WSREP_SYNC_WAIT(thd_, before_) #define WSREP_SYNC_WAIT(thd_, before_) do { } while(0)
#define WSREP_ERROR_LABEL goto wsrep_error_label; wsrep_error_label #define WSREP_ERROR_LABEL goto wsrep_error_label; wsrep_error_label
#endif /* WITH_WSREP */ #endif /* WITH_WSREP */

View File

@ -247,7 +247,7 @@ drop table t1;
# #
create table t1 (i int); create table t1 (i int);
insert into t1 values (1); insert into t1 values (1);
analyze select * from t1 into @var; analyze select * into @var from t1 ;
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 100.00 NULL 1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 100.00 NULL
drop table t1; drop table t1;
@ -281,10 +281,10 @@ drop table t1;
# #
create table t1(a int); create table t1(a int);
insert into t1 values (1),(2); insert into t1 values (1),(2);
analyze select a from t1 where a <2 into @var; analyze select a into @var from t1 where a <2 ;
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 2.00 100.00 50.00 Using where 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 2.00 100.00 50.00 Using where
analyze select a from t1 into @var; analyze select a into @var from t1 ;
ERROR 42000: Result consisted of more than one row ERROR 42000: Result consisted of more than one row
analyze insert into t1 select * from t1; analyze insert into t1 select * from t1;
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra

View File

@ -196,7 +196,7 @@ drop table t1;
--echo # --echo #
create table t1 (i int); create table t1 (i int);
insert into t1 values (1); insert into t1 values (1);
analyze select * from t1 into @var; analyze select * into @var from t1 ;
drop table t1; drop table t1;
--echo # --echo #
@ -223,9 +223,9 @@ drop table t1;
create table t1(a int); create table t1(a int);
insert into t1 values (1),(2); insert into t1 values (1),(2);
analyze select a from t1 where a <2 into @var; analyze select a into @var from t1 where a <2 ;
--error ER_TOO_MANY_ROWS --error ER_TOO_MANY_ROWS
analyze select a from t1 into @var; analyze select a into @var from t1 ;
analyze insert into t1 select * from t1; analyze insert into t1 select * from t1;

View File

@ -230,60 +230,34 @@ class Protocol_discard : public Protocol_text
{ {
public: public:
Protocol_discard(THD *thd_arg) : Protocol_text(thd_arg) {} Protocol_discard(THD *thd_arg) : Protocol_text(thd_arg) {}
/* The real writing is done only in write() */
virtual bool write() { return 0; }
virtual bool send_result_set_metadata(List<Item> *list, uint flags) virtual bool send_result_set_metadata(List<Item> *list, uint flags)
{ {
// Don't pas Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF flags // Don't pas Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF flags
return Protocol_text::send_result_set_metadata(list, 0); return Protocol_text::send_result_set_metadata(list, 0);
} }
// send_error is intentionally not overloaded. bool write() { return 0; }
virtual bool send_eof(uint server_status, uint statement_warn_count) bool send_eof(uint, uint) { return 0; }
{ void prepare_for_resend() { IF_DBUG(field_pos= 0,); }
return 0;
}
void prepare_for_resend()
{
#ifndef DBUG_OFF
field_pos= 0;
#endif
}
/* /*
Provide dummy overrides for any storage methods so that we Provide dummy overrides for any storage methods so that we
avoid allocating and copying of data avoid allocating and copying of data
*/ */
virtual bool store_null() bool store_null() { return false; }
{ return false; } bool store_tiny(longlong) { return false; }
virtual bool store_tiny(longlong from) bool store_short(longlong) { return false; }
{ return false; } bool store_long(longlong) { return false; }
virtual bool store_short(longlong from) bool store_longlong(longlong, bool) { return false; }
{ return false; } bool store_decimal(const my_decimal *) { return false; }
virtual bool store_long(longlong from) bool store(const char *, size_t, CHARSET_INFO *) { return false; }
{ return false; } bool store(const char *, size_t, CHARSET_INFO *, CHARSET_INFO *) { return false; }
virtual bool store_longlong(longlong from, bool unsigned_flag) bool store(MYSQL_TIME *, int) { return false; }
{ return false; } bool store_date(MYSQL_TIME *) { return false; }
virtual bool store_decimal(const my_decimal *) bool store_time(MYSQL_TIME *, int) { return false; }
{ return false; } bool store(float, uint32, String *) { return false; }
virtual bool store(const char *from, size_t length, CHARSET_INFO *cs) bool store(double, uint32, String *) { return false; }
{ return false; } bool store(Field *) { return false; }
virtual bool store(const char *from, size_t length,
CHARSET_INFO *fromcs, CHARSET_INFO *tocs)
{ return false; }
virtual bool store(MYSQL_TIME *time, int decimals)
{ return false; }
virtual bool store_date(MYSQL_TIME *time)
{ return false; }
virtual bool store_time(MYSQL_TIME *time, int decimals)
{ return false; }
virtual bool store(float nr, uint32 decimals, String *buffer)
{ return false; }
virtual bool store(double from, uint32 decimals, String *buffer)
{ return false; }
virtual bool store(Field *field)
{ return false; }
}; };

View File

@ -4262,6 +4262,7 @@ public:
virtual ~select_result_sink() {}; virtual ~select_result_sink() {};
}; };
class select_result_interceptor;
/* /*
Interface for sending tabular data, together with some other stuff: Interface for sending tabular data, together with some other stuff:
@ -4350,11 +4351,10 @@ public:
/* /*
This returns This returns
- FALSE if the class sends output row to the client - NULL if the class sends output row to the client
- TRUE if the output is set elsewhere (a file, @variable, or table). - this if the output is set elsewhere (a file, @variable, or table).
Currently all intercepting classes derive from select_result_interceptor.
*/ */
virtual bool is_result_interceptor()=0; virtual select_result_interceptor *result_interceptor()=0;
}; };
@ -4422,7 +4422,7 @@ public:
} /* Remove gcc warning */ } /* Remove gcc warning */
uint field_count(List<Item> &fields) const { return 0; } uint field_count(List<Item> &fields) const { return 0; }
bool send_result_set_metadata(List<Item> &fields, uint flag) { return FALSE; } bool send_result_set_metadata(List<Item> &fields, uint flag) { return FALSE; }
bool is_result_interceptor() { return true; } select_result_interceptor *result_interceptor() { return this; }
/* /*
Instruct the object to not call my_ok(). Client output will be handled Instruct the object to not call my_ok(). Client output will be handled
@ -4450,7 +4450,7 @@ public:
virtual bool check_simple_select() const { return FALSE; } virtual bool check_simple_select() const { return FALSE; }
void abort_result_set(); void abort_result_set();
virtual void cleanup(); virtual void cleanup();
bool is_result_interceptor() { return false; } select_result_interceptor *result_interceptor() { return NULL; }
}; };

View File

@ -3004,12 +3004,10 @@ mysql_execute_command(THD *thd)
case SQLCOM_SHOW_PROFILE: case SQLCOM_SHOW_PROFILE:
case SQLCOM_SELECT: case SQLCOM_SELECT:
{ {
#ifdef WITH_WSREP
if (lex->sql_command == SQLCOM_SELECT) if (lex->sql_command == SQLCOM_SELECT)
WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_READ) WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_READ);
else else
WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW) WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW);
#endif /* WITH_WSREP */
thd->status_var.last_query_cost= 0.0; thd->status_var.last_query_cost= 0.0;
@ -5959,8 +5957,8 @@ static bool execute_sqlcom_select(THD *thd, TABLE_LIST *all_tables)
Protocol *save_protocol= NULL; Protocol *save_protocol= NULL;
if (lex->analyze_stmt) if (lex->analyze_stmt)
{ {
if (result && result->is_result_interceptor()) if (result && result->result_interceptor())
((select_result_interceptor*)result)->disable_my_ok_calls(); result->result_interceptor()->disable_my_ok_calls();
else else
{ {
DBUG_ASSERT(thd->protocol); DBUG_ASSERT(thd->protocol);

View File

@ -175,12 +175,6 @@
*/ */
#define OPTION_MASTER_SQL_ERROR (1ULL << 35) #define OPTION_MASTER_SQL_ERROR (1ULL << 35)
/*
Dont report errors for individual rows,
But just report error on commit (or read ofcourse)
Note! Reserved for use in MySQL Cluster
*/
#define OPTION_ALLOW_BATCH (1ULL << 36) // THD, intern (slave)
#define OPTION_SKIP_REPLICATION (1ULL << 37) // THD, user #define OPTION_SKIP_REPLICATION (1ULL << 37) // THD, user
#define OPTION_RPL_SKIP_PARALLEL (1ULL << 38) #define OPTION_RPL_SKIP_PARALLEL (1ULL << 38)

View File

@ -1142,13 +1142,14 @@ mysqld_show_create_get_fields(THD *thd, TABLE_LIST *table_list,
List<Item> *field_list, String *buffer) List<Item> *field_list, String *buffer)
{ {
bool error= TRUE; bool error= TRUE;
LEX *lex= thd->lex;
MEM_ROOT *mem_root= thd->mem_root; MEM_ROOT *mem_root= thd->mem_root;
DBUG_ENTER("mysqld_show_create_get_fields"); DBUG_ENTER("mysqld_show_create_get_fields");
DBUG_PRINT("enter",("db: %s table: %s",table_list->db, DBUG_PRINT("enter",("db: %s table: %s",table_list->db,
table_list->table_name)); table_list->table_name));
/* We want to preserve the tree for views. */ /* We want to preserve the tree for views. */
thd->lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_VIEW; lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_VIEW;
{ {
/* /*
@ -1163,14 +1164,14 @@ mysqld_show_create_get_fields(THD *thd, TABLE_LIST *table_list,
bool open_error= bool open_error=
open_tables(thd, &table_list, &counter, open_tables(thd, &table_list, &counter,
MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL) || MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL) ||
mysql_handle_derived(thd->lex, DT_PREPARE); mysql_handle_derived(lex, DT_PREPARE);
thd->pop_internal_handler(); thd->pop_internal_handler();
if (open_error && (thd->killed || thd->is_error())) if (open_error && (thd->killed || thd->is_error()))
goto exit; goto exit;
} }
/* TODO: add environment variables show when it become possible */ /* TODO: add environment variables show when it become possible */
if (thd->lex->only_view && !table_list->view) if (lex->only_view && !table_list->view)
{ {
my_error(ER_WRONG_OBJECT, MYF(0), my_error(ER_WRONG_OBJECT, MYF(0),
table_list->db, table_list->table_name, "VIEW"); table_list->db, table_list->table_name, "VIEW");

View File

@ -891,15 +891,8 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
View definition query is stored in the client character set. View definition query is stored in the client character set.
*/ */
char view_query_buff[4096]; StringBuffer<4096> view_query(thd->charset());
String view_query(view_query_buff, StringBuffer<4096> is_query(system_charset_info);
sizeof (view_query_buff),
thd->charset());
char is_query_buff[4096];
String is_query(is_query_buff,
sizeof (is_query_buff),
system_charset_info);
char md5[MD5_BUFF_LENGTH]; char md5[MD5_BUFF_LENGTH];
bool can_be_merged; bool can_be_merged;