Commit 22f1cf92 authored by Sergei Golubchik's avatar Sergei Golubchik

cleanup: misc

parent dda2e940
......@@ -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);
......
......@@ -51,8 +51,8 @@
#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; }
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 */
......
......@@ -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
......
......@@ -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;
......
......@@ -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; }
};
......
......@@ -4262,6 +4262,7 @@ class select_result_sink: public Sql_alloc
virtual ~select_result_sink() {};
};
class select_result_interceptor;
/*
Interface for sending tabular data, together with some other stuff:
......@@ -4350,11 +4351,10 @@ class select_result :public select_result_sink
/*
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 @@ class select_result_interceptor: public select_result
} /* 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 @@ class select_send :public select_result {
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; }
};
......
......@@ -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);
......
......@@ -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)
......
......@@ -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");
......
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment