From 6fccf8ba05a19e42ef7ec0e88d98fdcf165648bb Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Thu, 27 Apr 2023 16:14:05 +1000 Subject: MDEV-29644 post-merge fixup Applying b98375f instead of 9b32e4b for version 10.5-10.8. Applying 5075f4e instead of 9b32e4b for version 10.9+. --- .../spider/bugfix/r/self_reference_multi.result | 4 +- storage/spider/spd_db_mysql.cc | 60 ++++++++++++++-------- storage/spider/spd_db_mysql.h | 2 +- 3 files changed, 42 insertions(+), 24 deletions(-) (limited to 'storage/spider') diff --git a/storage/spider/mysql-test/spider/bugfix/r/self_reference_multi.result b/storage/spider/mysql-test/spider/bugfix/r/self_reference_multi.result index 8ddf428b4ea..c4399ddf9d2 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/self_reference_multi.result +++ b/storage/spider/mysql-test/spider/bugfix/r/self_reference_multi.result @@ -12,9 +12,9 @@ alter table t2 ENGINE=Spider COMMENT='WRAPPER "mysql", srv "srv",TABLE "t0"'; select * from t0; ERROR HY000: An infinite loop is detected when opening table test.t0 select * from t1; -ERROR HY000: An infinite loop is detected when opening table test.t1 +ERROR HY000: An infinite loop is detected when opening table test.t0 select * from t2; -ERROR HY000: An infinite loop is detected when opening table test.t2 +ERROR HY000: An infinite loop is detected when opening table test.t0 drop table t0, t1, t2; for master_1 for child2 diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index 78734640a52..bc8383017f7 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -2289,44 +2289,64 @@ bool spider_db_mbase::is_xa_nota_error( DBUG_RETURN(xa_nota); } -void spider_db_mbase::fetch_and_print_warnings(struct tm *l_time) +int spider_db_mbase::fetch_and_print_warnings(struct tm *l_time) { + int error_num = 0; DBUG_ENTER("spider_db_mbase::fetch_and_print_warnings"); + DBUG_PRINT("info",("spider this=%p", this)); if (spider_param_dry_access() || db_conn->status != MYSQL_STATUS_READY || - db_conn->server_status & SERVER_MORE_RESULTS_EXISTS) - DBUG_VOID_RETURN; + db_conn->server_status & SERVER_MORE_RESULTS_EXISTS || + !db_conn->warning_count) + DBUG_RETURN(0); if (mysql_real_query(db_conn, SPIDER_SQL_SHOW_WARNINGS_STR, SPIDER_SQL_SHOW_WARNINGS_LEN)) - DBUG_VOID_RETURN; + DBUG_RETURN(0); MYSQL_RES *res= mysql_store_result(db_conn); if (!res) - DBUG_VOID_RETURN; + DBUG_RETURN(0); uint num_fields= mysql_num_fields(res); if (num_fields != 3) { mysql_free_result(res); - DBUG_VOID_RETURN; + DBUG_RETURN(0); } MYSQL_ROW row= mysql_fetch_row(res); - while (row) + if (l_time) { - fprintf(stderr, - "%04d%02d%02d %02d:%02d:%02d [WARN SPIDER RESULT] from [%s] %ld " - "to %ld: %s %s %s\n", - l_time->tm_year + 1900, l_time->tm_mon + 1, l_time->tm_mday, - l_time->tm_hour, l_time->tm_min, l_time->tm_sec, conn->tgt_host, - (ulong) db_conn->thread_id, (ulong) current_thd->thread_id, row[0], - row[1], row[2]); - row= mysql_fetch_row(res); - } + while (row) + { + fprintf(stderr, + "%04d%02d%02d %02d:%02d:%02d [WARN SPIDER RESULT] from [%s] %ld " + "to %ld: %s %s %s\n", + l_time->tm_year + 1900, l_time->tm_mon + 1, l_time->tm_mday, + l_time->tm_hour, l_time->tm_min, l_time->tm_sec, conn->tgt_host, + (ulong) db_conn->thread_id, (ulong) current_thd->thread_id, row[0], + row[1], row[2]); + row= mysql_fetch_row(res); + } + } else { + while (row) + { + DBUG_PRINT("info",("spider row[0]=%s", row[0])); + DBUG_PRINT("info",("spider row[1]=%s", row[1])); + DBUG_PRINT("info",("spider row[2]=%s", row[2])); + longlong res_num = + (longlong) my_strtoll10(row[1], (char**) NULL, &error_num); + DBUG_PRINT("info",("spider res_num=%lld", res_num)); + my_printf_error((int) res_num, row[2], MYF(0)); + error_num = (int) res_num; + row = mysql_fetch_row(res); + } + } + mysql_free_result(res); - DBUG_VOID_RETURN; + DBUG_RETURN(error_num); } spider_db_result *spider_db_mbase::store_result( @@ -14630,11 +14650,9 @@ int spider_mbase_handler::show_table_status( DBUG_RETURN(error_num); } } + if ((error_num = ((spider_db_mbase *) conn->db_conn)->fetch_and_print_warnings(NULL))) { - time_t cur_time = (time_t) time((time_t*) 0); - struct tm lt; - struct tm *l_time = localtime_r(&cur_time, <); - ((spider_db_mbase *) conn->db_conn)->fetch_and_print_warnings(l_time); + DBUG_RETURN(error_num); } if (share->static_records_for_status != -1) { diff --git a/storage/spider/spd_db_mysql.h b/storage/spider/spd_db_mysql.h index 757484c3990..a8eada5a62e 100644 --- a/storage/spider/spd_db_mysql.h +++ b/storage/spider/spd_db_mysql.h @@ -442,7 +442,7 @@ public: bool is_xa_nota_error( int error_num ); - void fetch_and_print_warnings(struct tm *l_time); + int fetch_and_print_warnings(struct tm *l_time); spider_db_result *store_result( spider_db_result_buffer **spider_res_buf, st_spider_db_request_key *request_key, -- cgit v1.2.1