summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2020-06-18 11:10:53 +0300
committerMonty <monty@mariadb.org>2020-06-19 12:03:13 +0300
commit1a49c5eb4d11dd6a35d293856281239d8e459582 (patch)
tree262a3904cbe838fa5ac325a3185ed67595ea5b0c
parent605555fc31784302a54d398d9503ca1e9e4bdec9 (diff)
downloadmariadb-git-1a49c5eb4d11dd6a35d293856281239d8e459582.tar.gz
Cleanup's and more DBUG_PRINT's
- Rewrote bool Query_compressed_log_event::write() to make it more readable (no logic changes). - Changed DBUG_PRINT of 'is_error:' to 'is_error():' to make it easier to find error: in traces. - Ensure that 'db' is never null in Query_log_event (Simplified code).
-rw-r--r--sql/handler.cc13
-rw-r--r--sql/item_func.cc14
-rw-r--r--sql/log.cc3
-rw-r--r--sql/log_event_server.cc58
-rw-r--r--sql/sql_cache.cc3
-rw-r--r--sql/sql_class.cc2
-rw-r--r--sql/sql_insert.cc2
-rw-r--r--sql/sql_parse.cc2
-rw-r--r--sql/sql_show.cc2
-rw-r--r--storage/maria/ha_s3.cc1
-rw-r--r--storage/maria/s3_func.c2
11 files changed, 67 insertions, 35 deletions
diff --git a/sql/handler.cc b/sql/handler.cc
index ed1ac7356cc..c2fb7da384c 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -5850,8 +5850,10 @@ bool ha_table_exists(THD *thd, const LEX_CSTRING *db,
if ((type= dd_frm_type(thd, path, &engine, is_sequence)) ==
TABLE_TYPE_UNKNOWN)
+ {
+ DBUG_PRINT("exit", ("Does not exist"));
DBUG_RETURN(true); // Frm exists
-
+ }
if (type != TABLE_TYPE_VIEW)
{
plugin_ref p= plugin_lock_by_name(thd, &engine,
@@ -5866,6 +5868,7 @@ bool ha_table_exists(THD *thd, const LEX_CSTRING *db,
else
*hton= view_pseudo_hton;
}
+ DBUG_PRINT("exit", (exists ? "Exists" : "Does not exist"));
DBUG_RETURN(exists);
}
@@ -5875,13 +5878,16 @@ bool ha_table_exists(THD *thd, const LEX_CSTRING *db,
{
if (hton)
*hton= args.hton;
+ DBUG_PRINT("exit", ("discovery found file"));
DBUG_RETURN(TRUE);
}
if (need_full_discover_for_existence)
{
TABLE_LIST table;
+ bool exists;
uint flags = GTS_TABLE | GTS_VIEW;
+
if (!hton)
flags|= GTS_NOLOCK;
@@ -5898,9 +5904,12 @@ bool ha_table_exists(THD *thd, const LEX_CSTRING *db,
}
// the table doesn't exist if we've caught ER_NO_SUCH_TABLE and nothing else
- DBUG_RETURN(!no_such_table_handler.safely_trapped_errors());
+ exists= !no_such_table_handler.safely_trapped_errors();
+ DBUG_PRINT("exit", (exists ? "Exists" : "Does not exist"));
+ DBUG_RETURN(exists);
}
+ DBUG_PRINT("exit", ("Does not exist"));
DBUG_RETURN(FALSE);
}
diff --git a/sql/item_func.cc b/sql/item_func.cc
index f79bd9d59b3..9e30afd0239 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -3747,12 +3747,13 @@ longlong Item_master_pos_wait::val_int()
THD* thd = current_thd;
String *log_name = args[0]->val_str(&value);
int event_count= 0;
+ DBUG_ENTER("Item_master_pos_wait::val_int");
null_value=0;
if (thd->slave_thread || !log_name || !log_name->length())
{
null_value = 1;
- return 0;
+ DBUG_RETURN(0);
}
#ifdef HAVE_REPLICATION
longlong pos = (ulong)args[1]->val_int();
@@ -3788,13 +3789,15 @@ longlong Item_master_pos_wait::val_int()
}
mi->release();
#endif
- return event_count;
+ DBUG_PRINT("exit", ("event_count: %d null_value: %d", event_count,
+ (int) null_value));
+ DBUG_RETURN(event_count);
#ifdef HAVE_REPLICATION
err:
{
null_value = 1;
- return 0;
+ DBUG_RETURN(0);
}
#endif
}
@@ -3805,11 +3808,12 @@ longlong Item_master_gtid_wait::val_int()
DBUG_ASSERT(fixed == 1);
longlong result= 0;
String *gtid_pos __attribute__((unused)) = args[0]->val_str(&value);
+ DBUG_ENTER("Item_master_gtid_wait::val_int");
if (args[0]->null_value)
{
null_value= 1;
- return 0;
+ DBUG_RETURN(0);
}
null_value=0;
@@ -3826,7 +3830,7 @@ longlong Item_master_gtid_wait::val_int()
#else
null_value= 0;
#endif /* REPLICATION */
- return result;
+ DBUG_RETURN(result);
}
diff --git a/sql/log.cc b/sql/log.cc
index d5fcb853dc6..3e774d2fe8d 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -6557,7 +6557,8 @@ bool MYSQL_BIN_LOG::write(Log_event *event_info, my_bool *with_annotate)
nodes. A check has been added to stop them from getting logged into
binary log files.
*/
- if (WSREP(thd)) option_bin_log_flag= true;
+ if (WSREP(thd))
+ option_bin_log_flag= true;
if ((!(option_bin_log_flag)) ||
(thd->lex->sql_command != SQLCOM_ROLLBACK_TO_SAVEPOINT &&
diff --git a/sql/log_event_server.cc b/sql/log_event_server.cc
index f48b9524ce5..87212773b4d 100644
--- a/sql/log_event_server.cc
+++ b/sql/log_event_server.cc
@@ -736,12 +736,14 @@ void Log_event::init_show_field_list(THD *thd, List<Item>* field_list)
@note A side effect of the method is altering Log_event::checksum_alg
it the latter was undefined at calling.
- @return true (positive) or false (negative)
+ @return true Checksum should be used. Log_event::checksum_alg is set.
+ @return false No checksum
*/
+
my_bool Log_event::need_checksum()
{
- DBUG_ENTER("Log_event::need_checksum");
my_bool ret;
+ DBUG_ENTER("Log_event::need_checksum");
/*
few callers of Log_event::write
(incl FD::write, FD constructing code on the slave side, Rotate relay log
@@ -1310,35 +1312,46 @@ bool Query_log_event::write()
Calculate length of whole event
The "1" below is the \0 in the db's length
*/
- event_length= (uint) (start-buf) + get_post_header_size_for_derived() + db_len + 1 + q_len;
+ event_length= ((uint) (start-buf) + get_post_header_size_for_derived() +
+ db_len + 1 + q_len);
return write_header(event_length) ||
write_data(buf, QUERY_HEADER_LEN) ||
write_post_header_for_derived() ||
- write_data(start_of_status, (uint) (start-start_of_status)) ||
- write_data(safe_str(db), db_len + 1) ||
+ write_data(start_of_status, (uint) status_vars_len) ||
+ write_data(db, db_len + 1) ||
write_data(query, q_len) ||
write_footer();
}
bool Query_compressed_log_event::write()
{
- const char *query_tmp = query;
- uint32 q_len_tmp = q_len;
- uint32 alloc_size;
- bool ret = true;
- q_len = alloc_size = binlog_get_compress_len(q_len);
- query = (char *)my_safe_alloca(alloc_size);
- if(query && !binlog_buf_compress(query_tmp, (char *)query, q_len_tmp, &q_len))
+ char *buffer;
+ uint32 alloc_size, compressed_size;
+ bool ret= true;
+
+ compressed_size= alloc_size= binlog_get_compress_len(q_len);
+ buffer= (char*) my_safe_alloca(alloc_size);
+ if (buffer &&
+ !binlog_buf_compress(query, buffer, q_len, &compressed_size))
{
- ret = Query_log_event::write();
- }
- my_safe_afree((void *)query, alloc_size);
- query = query_tmp;
- q_len = q_len_tmp;
+ /*
+ Write the compressed event. We have to temporarily store the event
+ in query and q_len as Query_log_event::write() uses these.
+ */
+ const char *query_tmp= query;
+ uint32 q_len_tmp= q_len;
+ query= buffer;
+ q_len= compressed_size;
+ ret= Query_log_event::write();
+ query= query_tmp;
+ q_len= q_len_tmp;
+ }
+ my_safe_afree(buffer, alloc_size);
return ret;
}
+
/**
The simplest constructor that could possibly work. This is used for
creating static objects that have a special meaning and are invisible
@@ -1377,7 +1390,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.str), q_len((uint32) query_length),
+ 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),
@@ -1390,6 +1403,8 @@ Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg,
table_map_for_update((ulonglong)thd_arg->table_map_for_update),
master_data_written(0)
{
+ /* status_vars_len is set just before writing the event */
+
time_t end_time;
#ifdef WITH_WSREP
@@ -1408,7 +1423,6 @@ Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg,
memset(&user, 0, sizeof(user));
memset(&host, 0, sizeof(host));
-
error_code= errcode;
end_time= my_time(0);
@@ -1418,8 +1432,10 @@ Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg,
as an existing catalog of length zero. is that safe? /sven
*/
catalog_len = (catalog) ? (uint32) strlen(catalog) : 0;
- /* status_vars_len is set just before writing the event */
- db_len = (db) ? (uint32) strlen(db) : 0;
+
+ if (!(db= thd->db.str))
+ db= "";
+ db_len= (uint32) strlen(db);
if (thd_arg->variables.collation_database != thd_arg->db_charset)
charset_database_number= thd_arg->variables.collation_database->number;
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index c44a98c75b9..35e3a7c5608 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -3503,7 +3503,8 @@ my_bool Query_cache::register_all_tables(THD *thd,
my_bool
Query_cache::insert_table(THD *thd, size_t key_len, const char *key,
- Query_cache_block_table *node, size_t db_length, uint8 suffix_length_arg,
+ Query_cache_block_table *node, size_t db_length,
+ uint8 suffix_length_arg,
uint8 cache_type,
qc_engine_callback callback,
ulonglong engine_data,
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 23176d5a1db..c370008d96e 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -7368,7 +7368,7 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype, char const *query_arg,
log event is written to the binary log, we pretend that no
table maps were written.
*/
- if(binlog_should_compress(query_len))
+ if (binlog_should_compress(query_len))
{
Query_compressed_log_event qinfo(this, query_arg, query_len, is_trans, direct,
suppress_use, errcode);
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index a934427f02a..1576a28f43a 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -2538,7 +2538,7 @@ bool delayed_get_table(THD *thd, MDL_request *grl_protection_request,
end_create:
mysql_mutex_unlock(&LOCK_delayed_create);
- DBUG_PRINT("exit", ("is_error: %d", thd->is_error()));
+ DBUG_PRINT("exit", ("is_error(): %d", thd->is_error()));
DBUG_RETURN(thd->is_error());
}
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 7a133d84f89..e35ee16cf4b 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -5949,7 +5949,7 @@ mysql_execute_command(THD *thd)
lex->create_info.set(DDL_options_st::OPT_IF_EXISTS);
DBUG_ASSERT(lex->m_sql_cmd != NULL);
res= lex->m_sql_cmd->execute(thd);
- DBUG_PRINT("result", ("res: %d killed: %d is_error: %d",
+ DBUG_PRINT("result", ("res: %d killed: %d is_error(): %d",
res, thd->killed, thd->is_error()));
break;
default:
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 62c93f6b61c..323d0865b3a 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -1753,7 +1753,7 @@ static bool get_field_default_value(THD *thd, Field *field, String *def_value,
@param thd thread handler
@param packet string to append
@param opt list of options
- @param check_options only print known options
+ @param check_options print all used options
@param rules list of known options
*/
diff --git a/storage/maria/ha_s3.cc b/storage/maria/ha_s3.cc
index dc267d31405..60d83440a98 100644
--- a/storage/maria/ha_s3.cc
+++ b/storage/maria/ha_s3.cc
@@ -770,6 +770,7 @@ static int s3_discover_table_existance(handlerton *hton, const char *db,
res= s3_frm_exists(s3_client, &s3_info);
s3_deinit(s3_client);
+ DBUG_PRINT("exit", ("exists: %d", res == 0));
DBUG_RETURN(res == 0); // Return 1 if exists
}
diff --git a/storage/maria/s3_func.c b/storage/maria/s3_func.c
index 33024294616..410958ff295 100644
--- a/storage/maria/s3_func.c
+++ b/storage/maria/s3_func.c
@@ -1500,7 +1500,7 @@ int s3_check_frm_version(ms3_st *s3_client, S3_INFO *s3_info)
if (res)
DBUG_PRINT("error", ("Wrong table version"));
else
- DBUG_PRINT("error", ("Version strings matches"));
+ DBUG_PRINT("exit", ("Version strings matches"));
DBUG_RETURN(res);
}