Skip to content

Commit 22f1cf9

Browse files
committed
cleanup: misc
1 parent dda2e94 commit 22f1cf9

File tree

10 files changed

+45
-84
lines changed

10 files changed

+45
-84
lines changed

client/mysqlcheck.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,8 @@ static int handle_request_for_tables(char *tables, size_t length,
953953
puts(query);
954954
if (mysql_real_query(sock, query, query_length))
955955
{
956-
sprintf(message, "when executing '%s%s... %s'", op, tab_view, options);
956+
my_snprintf(message, sizeof(message), "when executing '%s%s... %s'",
957+
op, tab_view, options);
957958
DBerror(sock, message);
958959
my_free(query);
959960
DBUG_RETURN(1);

include/wsrep.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@
5050
#define WSREP_WARN(...) WSREP_LOG(sql_print_warning, ##__VA_ARGS__)
5151
#define WSREP_ERROR(...) WSREP_LOG(sql_print_error, ##__VA_ARGS__)
5252

53-
#define WSREP_SYNC_WAIT(thd_, before_) \
54-
{ if (WSREP_CLIENT(thd_) && \
55-
wsrep_sync_wait(thd_, before_)) goto wsrep_error_label; }
53+
#define WSREP_SYNC_WAIT(thd_, before_) \
54+
do { if (WSREP_CLIENT(thd_) && \
55+
wsrep_sync_wait(thd_, before_)) goto wsrep_error_label; } while(0)
5656
#define WSREP_ERROR_LABEL wsrep_error_label
5757
#else
5858
#define IF_WSREP(A,B) B
@@ -64,7 +64,7 @@
6464
#define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_)
6565
#define WSREP_TO_ISOLATION_END
6666
#define WSREP_TO_ISOLATION_BEGIN_WRTCHK(db_, table_, table_list_)
67-
#define WSREP_SYNC_WAIT(thd_, before_)
67+
#define WSREP_SYNC_WAIT(thd_, before_) do { } while(0)
6868
#define WSREP_ERROR_LABEL goto wsrep_error_label; wsrep_error_label
6969

7070
#endif /* WITH_WSREP */

mysql-test/r/analyze_stmt.result

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ drop table t1;
247247
#
248248
create table t1 (i int);
249249
insert into t1 values (1);
250-
analyze select * from t1 into @var;
250+
analyze select * into @var from t1 ;
251251
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
252252
1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 100.00 NULL
253253
drop table t1;
@@ -281,10 +281,10 @@ drop table t1;
281281
#
282282
create table t1(a int);
283283
insert into t1 values (1),(2);
284-
analyze select a from t1 where a <2 into @var;
284+
analyze select a into @var from t1 where a <2 ;
285285
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
286286
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 2.00 100.00 50.00 Using where
287-
analyze select a from t1 into @var;
287+
analyze select a into @var from t1 ;
288288
ERROR 42000: Result consisted of more than one row
289289
analyze insert into t1 select * from t1;
290290
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra

mysql-test/t/analyze_stmt.test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ drop table t1;
196196
--echo #
197197
create table t1 (i int);
198198
insert into t1 values (1);
199-
analyze select * from t1 into @var;
199+
analyze select * into @var from t1 ;
200200
drop table t1;
201201

202202
--echo #
@@ -223,9 +223,9 @@ drop table t1;
223223
create table t1(a int);
224224
insert into t1 values (1),(2);
225225

226-
analyze select a from t1 where a <2 into @var;
226+
analyze select a into @var from t1 where a <2 ;
227227
--error ER_TOO_MANY_ROWS
228-
analyze select a from t1 into @var;
228+
analyze select a into @var from t1 ;
229229

230230
analyze insert into t1 select * from t1;
231231

sql/protocol.h

Lines changed: 17 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -230,60 +230,34 @@ class Protocol_discard : public Protocol_text
230230
{
231231
public:
232232
Protocol_discard(THD *thd_arg) : Protocol_text(thd_arg) {}
233-
/* The real writing is done only in write() */
234-
virtual bool write() { return 0; }
235233
virtual bool send_result_set_metadata(List<Item> *list, uint flags)
236234
{
237235
// Don't pas Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF flags
238236
return Protocol_text::send_result_set_metadata(list, 0);
239237
}
240238

241-
// send_error is intentionally not overloaded.
242-
virtual bool send_eof(uint server_status, uint statement_warn_count)
243-
{
244-
return 0;
245-
}
246-
247-
void prepare_for_resend()
248-
{
249-
#ifndef DBUG_OFF
250-
field_pos= 0;
251-
#endif
252-
}
239+
bool write() { return 0; }
240+
bool send_eof(uint, uint) { return 0; }
241+
void prepare_for_resend() { IF_DBUG(field_pos= 0,); }
253242

254243
/*
255244
Provide dummy overrides for any storage methods so that we
256245
avoid allocating and copying of data
257246
*/
258-
virtual bool store_null()
259-
{ return false; }
260-
virtual bool store_tiny(longlong from)
261-
{ return false; }
262-
virtual bool store_short(longlong from)
263-
{ return false; }
264-
virtual bool store_long(longlong from)
265-
{ return false; }
266-
virtual bool store_longlong(longlong from, bool unsigned_flag)
267-
{ return false; }
268-
virtual bool store_decimal(const my_decimal *)
269-
{ return false; }
270-
virtual bool store(const char *from, size_t length, CHARSET_INFO *cs)
271-
{ return false; }
272-
virtual bool store(const char *from, size_t length,
273-
CHARSET_INFO *fromcs, CHARSET_INFO *tocs)
274-
{ return false; }
275-
virtual bool store(MYSQL_TIME *time, int decimals)
276-
{ return false; }
277-
virtual bool store_date(MYSQL_TIME *time)
278-
{ return false; }
279-
virtual bool store_time(MYSQL_TIME *time, int decimals)
280-
{ return false; }
281-
virtual bool store(float nr, uint32 decimals, String *buffer)
282-
{ return false; }
283-
virtual bool store(double from, uint32 decimals, String *buffer)
284-
{ return false; }
285-
virtual bool store(Field *field)
286-
{ return false; }
247+
bool store_null() { return false; }
248+
bool store_tiny(longlong) { return false; }
249+
bool store_short(longlong) { return false; }
250+
bool store_long(longlong) { return false; }
251+
bool store_longlong(longlong, bool) { return false; }
252+
bool store_decimal(const my_decimal *) { return false; }
253+
bool store(const char *, size_t, CHARSET_INFO *) { return false; }
254+
bool store(const char *, size_t, CHARSET_INFO *, CHARSET_INFO *) { return false; }
255+
bool store(MYSQL_TIME *, int) { return false; }
256+
bool store_date(MYSQL_TIME *) { return false; }
257+
bool store_time(MYSQL_TIME *, int) { return false; }
258+
bool store(float, uint32, String *) { return false; }
259+
bool store(double, uint32, String *) { return false; }
260+
bool store(Field *) { return false; }
287261

288262
};
289263

sql/sql_class.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4262,6 +4262,7 @@ class select_result_sink: public Sql_alloc
42624262
virtual ~select_result_sink() {};
42634263
};
42644264

4265+
class select_result_interceptor;
42654266

42664267
/*
42674268
Interface for sending tabular data, together with some other stuff:
@@ -4350,11 +4351,10 @@ class select_result :public select_result_sink
43504351

43514352
/*
43524353
This returns
4353-
- FALSE if the class sends output row to the client
4354-
- TRUE if the output is set elsewhere (a file, @variable, or table).
4355-
Currently all intercepting classes derive from select_result_interceptor.
4354+
- NULL if the class sends output row to the client
4355+
- this if the output is set elsewhere (a file, @variable, or table).
43564356
*/
4357-
virtual bool is_result_interceptor()=0;
4357+
virtual select_result_interceptor *result_interceptor()=0;
43584358
};
43594359

43604360

@@ -4422,7 +4422,7 @@ class select_result_interceptor: public select_result
44224422
} /* Remove gcc warning */
44234423
uint field_count(List<Item> &fields) const { return 0; }
44244424
bool send_result_set_metadata(List<Item> &fields, uint flag) { return FALSE; }
4425-
bool is_result_interceptor() { return true; }
4425+
select_result_interceptor *result_interceptor() { return this; }
44264426

44274427
/*
44284428
Instruct the object to not call my_ok(). Client output will be handled
@@ -4450,7 +4450,7 @@ class select_send :public select_result {
44504450
virtual bool check_simple_select() const { return FALSE; }
44514451
void abort_result_set();
44524452
virtual void cleanup();
4453-
bool is_result_interceptor() { return false; }
4453+
select_result_interceptor *result_interceptor() { return NULL; }
44544454
};
44554455

44564456

sql/sql_parse.cc

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3004,12 +3004,10 @@ mysql_execute_command(THD *thd)
30043004
case SQLCOM_SHOW_PROFILE:
30053005
case SQLCOM_SELECT:
30063006
{
3007-
#ifdef WITH_WSREP
30083007
if (lex->sql_command == SQLCOM_SELECT)
3009-
WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_READ)
3008+
WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_READ);
30103009
else
3011-
WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW)
3012-
#endif /* WITH_WSREP */
3010+
WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW);
30133011

30143012
thd->status_var.last_query_cost= 0.0;
30153013

@@ -5959,8 +5957,8 @@ static bool execute_sqlcom_select(THD *thd, TABLE_LIST *all_tables)
59595957
Protocol *save_protocol= NULL;
59605958
if (lex->analyze_stmt)
59615959
{
5962-
if (result && result->is_result_interceptor())
5963-
((select_result_interceptor*)result)->disable_my_ok_calls();
5960+
if (result && result->result_interceptor())
5961+
result->result_interceptor()->disable_my_ok_calls();
59645962
else
59655963
{
59665964
DBUG_ASSERT(thd->protocol);

sql/sql_priv.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,6 @@
175175
*/
176176
#define OPTION_MASTER_SQL_ERROR (1ULL << 35)
177177

178-
/*
179-
Dont report errors for individual rows,
180-
But just report error on commit (or read ofcourse)
181-
Note! Reserved for use in MySQL Cluster
182-
*/
183-
#define OPTION_ALLOW_BATCH (1ULL << 36) // THD, intern (slave)
184178
#define OPTION_SKIP_REPLICATION (1ULL << 37) // THD, user
185179
#define OPTION_RPL_SKIP_PARALLEL (1ULL << 38)
186180

sql/sql_show.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,13 +1142,14 @@ mysqld_show_create_get_fields(THD *thd, TABLE_LIST *table_list,
11421142
List<Item> *field_list, String *buffer)
11431143
{
11441144
bool error= TRUE;
1145+
LEX *lex= thd->lex;
11451146
MEM_ROOT *mem_root= thd->mem_root;
11461147
DBUG_ENTER("mysqld_show_create_get_fields");
11471148
DBUG_PRINT("enter",("db: %s table: %s",table_list->db,
11481149
table_list->table_name));
11491150

11501151
/* We want to preserve the tree for views. */
1151-
thd->lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_VIEW;
1152+
lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_VIEW;
11521153

11531154
{
11541155
/*
@@ -1163,14 +1164,14 @@ mysqld_show_create_get_fields(THD *thd, TABLE_LIST *table_list,
11631164
bool open_error=
11641165
open_tables(thd, &table_list, &counter,
11651166
MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL) ||
1166-
mysql_handle_derived(thd->lex, DT_PREPARE);
1167+
mysql_handle_derived(lex, DT_PREPARE);
11671168
thd->pop_internal_handler();
11681169
if (open_error && (thd->killed || thd->is_error()))
11691170
goto exit;
11701171
}
11711172

11721173
/* TODO: add environment variables show when it become possible */
1173-
if (thd->lex->only_view && !table_list->view)
1174+
if (lex->only_view && !table_list->view)
11741175
{
11751176
my_error(ER_WRONG_OBJECT, MYF(0),
11761177
table_list->db, table_list->table_name, "VIEW");

sql/sql_view.cc

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -891,15 +891,8 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
891891
892892
View definition query is stored in the client character set.
893893
*/
894-
char view_query_buff[4096];
895-
String view_query(view_query_buff,
896-
sizeof (view_query_buff),
897-
thd->charset());
898-
899-
char is_query_buff[4096];
900-
String is_query(is_query_buff,
901-
sizeof (is_query_buff),
902-
system_charset_info);
894+
StringBuffer<4096> view_query(thd->charset());
895+
StringBuffer<4096> is_query(system_charset_info);
903896

904897
char md5[MD5_BUFF_LENGTH];
905898
bool can_be_merged;

0 commit comments

Comments
 (0)