diff options
author | Sergei Golubchik <serg@mariadb.org> | 2018-11-11 14:20:37 +0100 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2019-03-12 13:10:49 +0100 |
commit | 22f1cf9292f859f2f59208f267917481b29d4739 (patch) | |
tree | 13fd60bcaad9487c60db585afaa5281d367c0c0f | |
parent | dda2e940fb035d41852e95a1c2f513ab1534b041 (diff) | |
download | mariadb-git-22f1cf9292f859f2f59208f267917481b29d4739.tar.gz |
cleanup: misc
-rw-r--r-- | client/mysqlcheck.c | 3 | ||||
-rw-r--r-- | include/wsrep.h | 8 | ||||
-rw-r--r-- | mysql-test/r/analyze_stmt.result | 6 | ||||
-rw-r--r-- | mysql-test/t/analyze_stmt.test | 6 | ||||
-rw-r--r-- | sql/protocol.h | 60 | ||||
-rw-r--r-- | sql/sql_class.h | 12 | ||||
-rw-r--r-- | sql/sql_parse.cc | 10 | ||||
-rw-r--r-- | sql/sql_priv.h | 6 | ||||
-rw-r--r-- | sql/sql_show.cc | 7 | ||||
-rw-r--r-- | sql/sql_view.cc | 11 |
10 files changed, 45 insertions, 84 deletions
diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index a4410eba8aa..eafd47132ad 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -953,7 +953,8 @@ static int handle_request_for_tables(char *tables, size_t length, puts(query); 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); my_free(query); DBUG_RETURN(1); diff --git a/include/wsrep.h b/include/wsrep.h index 14d624aec26..d9800b7014f 100644 --- a/include/wsrep.h +++ b/include/wsrep.h @@ -50,9 +50,9 @@ #define WSREP_WARN(...) WSREP_LOG(sql_print_warning, ##__VA_ARGS__) #define WSREP_ERROR(...) WSREP_LOG(sql_print_error, ##__VA_ARGS__) -#define WSREP_SYNC_WAIT(thd_, before_) \ - { if (WSREP_CLIENT(thd_) && \ - wsrep_sync_wait(thd_, before_)) goto wsrep_error_label; } +#define WSREP_SYNC_WAIT(thd_, before_) \ + do { if (WSREP_CLIENT(thd_) && \ + wsrep_sync_wait(thd_, before_)) goto wsrep_error_label; } while(0) #define WSREP_ERROR_LABEL wsrep_error_label #else #define IF_WSREP(A,B) B @@ -64,7 +64,7 @@ #define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_) #define WSREP_TO_ISOLATION_END #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 #endif /* WITH_WSREP */ diff --git a/mysql-test/r/analyze_stmt.result b/mysql-test/r/analyze_stmt.result index c3c98593210..3ae49c5eeb6 100644 --- a/mysql-test/r/analyze_stmt.result +++ b/mysql-test/r/analyze_stmt.result @@ -247,7 +247,7 @@ drop table t1; # create table t1 (i int); 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 1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 100.00 NULL drop table t1; @@ -281,10 +281,10 @@ drop table t1; # create table t1(a int); 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 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 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 diff --git a/mysql-test/t/analyze_stmt.test b/mysql-test/t/analyze_stmt.test index d02139fe0c8..15fc00a321d 100644 --- a/mysql-test/t/analyze_stmt.test +++ b/mysql-test/t/analyze_stmt.test @@ -196,7 +196,7 @@ drop table t1; --echo # create table t1 (i int); insert into t1 values (1); -analyze select * from t1 into @var; +analyze select * into @var from t1 ; drop table t1; --echo # @@ -223,9 +223,9 @@ drop table t1; create table t1(a int); 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 -analyze select a from t1 into @var; +analyze select a into @var from t1 ; analyze insert into t1 select * from t1; diff --git a/sql/protocol.h b/sql/protocol.h index ea33c6bbb45..93b8fcbe8ef 100644 --- a/sql/protocol.h +++ b/sql/protocol.h @@ -230,60 +230,34 @@ class Protocol_discard : public Protocol_text { public: 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) { // Don't pas Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF flags return Protocol_text::send_result_set_metadata(list, 0); } - // send_error is intentionally not overloaded. - virtual bool send_eof(uint server_status, uint statement_warn_count) - { - return 0; - } - - void prepare_for_resend() - { -#ifndef DBUG_OFF - field_pos= 0; -#endif - } + bool write() { return 0; } + bool send_eof(uint, uint) { return 0; } + void prepare_for_resend() { IF_DBUG(field_pos= 0,); } /* Provide dummy overrides for any storage methods so that we avoid allocating and copying of data */ - virtual bool store_null() - { return false; } - virtual bool store_tiny(longlong from) - { return false; } - virtual bool store_short(longlong from) - { return false; } - virtual bool store_long(longlong from) - { return false; } - virtual bool store_longlong(longlong from, bool unsigned_flag) - { return false; } - virtual bool store_decimal(const my_decimal *) - { return false; } - virtual bool store(const char *from, size_t length, CHARSET_INFO *cs) - { 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; } + bool store_null() { return false; } + bool store_tiny(longlong) { return false; } + bool store_short(longlong) { return false; } + bool store_long(longlong) { return false; } + bool store_longlong(longlong, bool) { return false; } + bool store_decimal(const my_decimal *) { return false; } + bool store(const char *, size_t, CHARSET_INFO *) { return false; } + bool store(const char *, size_t, CHARSET_INFO *, CHARSET_INFO *) { return false; } + bool store(MYSQL_TIME *, int) { return false; } + bool store_date(MYSQL_TIME *) { return false; } + bool store_time(MYSQL_TIME *, int) { return false; } + bool store(float, uint32, String *) { return false; } + bool store(double, uint32, String *) { return false; } + bool store(Field *) { return false; } }; diff --git a/sql/sql_class.h b/sql/sql_class.h index db9a3742fc0..a52367be108 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -4262,6 +4262,7 @@ public: virtual ~select_result_sink() {}; }; +class select_result_interceptor; /* Interface for sending tabular data, together with some other stuff: @@ -4350,11 +4351,10 @@ public: /* This returns - - FALSE if the class sends output row to the client - - TRUE if the output is set elsewhere (a file, @variable, or table). - Currently all intercepting classes derive from select_result_interceptor. + - NULL if the class sends output row to the client + - this if the output is set elsewhere (a file, @variable, or table). */ - virtual bool is_result_interceptor()=0; + virtual select_result_interceptor *result_interceptor()=0; }; @@ -4422,7 +4422,7 @@ public: } /* Remove gcc warning */ uint field_count(List<Item> &fields) const { return 0; } 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 @@ -4450,7 +4450,7 @@ public: virtual bool check_simple_select() const { return FALSE; } void abort_result_set(); virtual void cleanup(); - bool is_result_interceptor() { return false; } + select_result_interceptor *result_interceptor() { return NULL; } }; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index c9651e1038b..150d13f1360 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3004,12 +3004,10 @@ mysql_execute_command(THD *thd) case SQLCOM_SHOW_PROFILE: case SQLCOM_SELECT: { -#ifdef WITH_WSREP 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 - WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW) -#endif /* WITH_WSREP */ + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); 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; if (lex->analyze_stmt) { - if (result && result->is_result_interceptor()) - ((select_result_interceptor*)result)->disable_my_ok_calls(); + if (result && result->result_interceptor()) + result->result_interceptor()->disable_my_ok_calls(); else { DBUG_ASSERT(thd->protocol); diff --git a/sql/sql_priv.h b/sql/sql_priv.h index e30060c8d3e..f54c66e1d99 100644 --- a/sql/sql_priv.h +++ b/sql/sql_priv.h @@ -175,12 +175,6 @@ */ #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_RPL_SKIP_PARALLEL (1ULL << 38) diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 46030f96043..e0a4fb4ea95 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1142,13 +1142,14 @@ mysqld_show_create_get_fields(THD *thd, TABLE_LIST *table_list, List<Item> *field_list, String *buffer) { bool error= TRUE; + LEX *lex= thd->lex; 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)); /* 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= open_tables(thd, &table_list, &counter, MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL) || - mysql_handle_derived(thd->lex, DT_PREPARE); + mysql_handle_derived(lex, DT_PREPARE); thd->pop_internal_handler(); if (open_error && (thd->killed || thd->is_error())) goto exit; } /* 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), table_list->db, table_list->table_name, "VIEW"); diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 9a9309a133b..df9fdab6635 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -891,15 +891,8 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view, View definition query is stored in the client character set. */ - char view_query_buff[4096]; - String view_query(view_query_buff, - sizeof (view_query_buff), - thd->charset()); - - char is_query_buff[4096]; - String is_query(is_query_buff, - sizeof (is_query_buff), - system_charset_info); + StringBuffer<4096> view_query(thd->charset()); + StringBuffer<4096> is_query(system_charset_info); char md5[MD5_BUFF_LENGTH]; bool can_be_merged; |