From 0fa2ee981be78dd30073313a9fbeb48edce6e96b Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 4 Mar 2008 10:17:49 -0300 Subject: [PATCH 1/7] Bug#35009 Results of mysql_client_test are discarded upon failure It's impossible to determine which test inside mysql_client_test failed if the log file is overwritten by mysqltest when dumping the test case results. Redirect mysql_client_test output to a separate file. mysql-test/t/mysql_client_test.test: Redirect mysql_client_test output to a separate log file so it doesn't get overwritten by mysqltest. --- mysql-test/t/mysql_client_test.test | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/t/mysql_client_test.test b/mysql-test/t/mysql_client_test.test index 66a27abd61a..b46a127785a 100644 --- a/mysql-test/t/mysql_client_test.test +++ b/mysql-test/t/mysql_client_test.test @@ -8,8 +8,8 @@ # server or run mysql-test-run --debug mysql_client_test and check # var/log/mysql_client_test.trace ---exec echo "$MYSQL_CLIENT_TEST" > $MYSQLTEST_VARDIR/log/mysql_client_test.log 2>&1 ---exec $MYSQL_CLIENT_TEST --getopt-ll-test=25600M >> $MYSQLTEST_VARDIR/log/mysql_client_test.log 2>&1 +--exec echo "$MYSQL_CLIENT_TEST" > $MYSQLTEST_VARDIR/log/mysql_client_test.out 2>&1 +--exec $MYSQL_CLIENT_TEST --getopt-ll-test=25600M >> $MYSQLTEST_VARDIR/log/mysql_client_test.out 2>&1 # End of 4.1 tests echo ok; From 0769fe559036512506736768fb31ddb0482ac2e6 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 4 Mar 2008 10:32:30 -0300 Subject: [PATCH 2/7] Use the same name for mysql_client_test output file in all branches. mysql-test/t/mysql_client_test.test: Rename mysql_client_test output file to mysql_client_test.out.log --- mysql-test/t/mysql_client_test.test | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/t/mysql_client_test.test b/mysql-test/t/mysql_client_test.test index b46a127785a..7667522feaf 100644 --- a/mysql-test/t/mysql_client_test.test +++ b/mysql-test/t/mysql_client_test.test @@ -8,8 +8,8 @@ # server or run mysql-test-run --debug mysql_client_test and check # var/log/mysql_client_test.trace ---exec echo "$MYSQL_CLIENT_TEST" > $MYSQLTEST_VARDIR/log/mysql_client_test.out 2>&1 ---exec $MYSQL_CLIENT_TEST --getopt-ll-test=25600M >> $MYSQLTEST_VARDIR/log/mysql_client_test.out 2>&1 +--exec echo "$MYSQL_CLIENT_TEST" > $MYSQLTEST_VARDIR/log/mysql_client_test.out.log 2>&1 +--exec $MYSQL_CLIENT_TEST --getopt-ll-test=25600M >> $MYSQLTEST_VARDIR/log/mysql_client_test.out.log 2>&1 # End of 4.1 tests echo ok; From aafb492d594776ead1014163461d30cbf9ca5772 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 6 Mar 2008 09:16:53 -0300 Subject: [PATCH 3/7] Bug#35103 mysql_client_test::test_bug29948 causes sporadic failures Disable test case for bug 29948, which is causing sporadically failures in other tests inside mysql_client_test. tests/mysql_client_test.c: Disable test case. --- tests/mysql_client_test.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 260e7b1e7a7..0deb37d25c3 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -15942,6 +15942,7 @@ static void test_bug27592() DBUG_VOID_RETURN; } +#if 0 static void test_bug29948() { @@ -16017,6 +16018,8 @@ static void test_bug29948() mysql_close(dbc); } +#endif + /** Bug#29306 Truncated data in MS Access with decimal (3,1) columns in a VIEW */ @@ -16543,7 +16546,7 @@ static struct my_tests_st my_tests[]= { { "test_bug28505", test_bug28505 }, { "test_bug28934", test_bug28934 }, { "test_bug27592", test_bug27592 }, - { "test_bug29948", test_bug29948 }, + /* { "test_bug29948", test_bug29948 }, Bug#35103 */ { "test_bug29306", test_bug29306 }, { "test_bug31669", test_bug31669 }, { "test_bug32265", test_bug32265 }, From 326c4e90589dd87792eacfa6e8746bc486a10ba0 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 12 Mar 2008 16:13:33 +0300 Subject: [PATCH 4/7] A fix for Bug#34643: TRUNCATE crash if trigger and foreign key. In cases when TRUNCATE was executed by invoking mysql_delete() rather than by table recreation (for example, when TRUNCATE was issued on InnoDB table with is referenced by foreign key) triggers were invoked. In debug builds this also led to crash because of an assertion, which assumes that some preliminary actions take place before trigger invocation, which doesn't happen in case of TRUNCATE. The fix is not to execute triggers in mysql_delete() when this function is used by TRUNCATE. mysql-test/r/trigger-trans.result: Update result file. mysql-test/t/trigger-trans.test: A test case for Bug#34643: TRUNCATE crash if trigger and foreign key. sql/sql_delete.cc: Do not process triggers in TRUNCATE. --- mysql-test/r/trigger-trans.result | 19 ++++++++++++++++++ mysql-test/t/trigger-trans.test | 32 +++++++++++++++++++++++++++++++ sql/sql_delete.cc | 15 ++++++++++----- 3 files changed, 61 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/trigger-trans.result b/mysql-test/r/trigger-trans.result index cd5f629564f..dccaa27c5fd 100644 --- a/mysql-test/r/trigger-trans.result +++ b/mysql-test/r/trigger-trans.result @@ -140,4 +140,23 @@ select * from t3; c 1 drop table t1, t2, t3; +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=innodb; +CREATE TABLE t2(b INT, FOREIGN KEY(b) REFERENCES t1(a)) ENGINE=innodb; +INSERT INTO t1 VALUES (1); +CREATE TRIGGER t1_bd BEFORE DELETE ON t1 FOR EACH ROW SET @a = 1; +CREATE TRIGGER t1_ad AFTER DELETE ON t1 FOR EACH ROW SET @b = 1; +SET @a = 0; +SET @b = 0; +TRUNCATE t1; +SELECT @a, @b; +@a @b +0 0 +INSERT INTO t1 VALUES (1); +DELETE FROM t1; +SELECT @a, @b; +@a @b +1 1 +DROP TABLE t2, t1; End of 5.0 tests diff --git a/mysql-test/t/trigger-trans.test b/mysql-test/t/trigger-trans.test index 8103a1ba0b1..5db5b982773 100644 --- a/mysql-test/t/trigger-trans.test +++ b/mysql-test/t/trigger-trans.test @@ -128,5 +128,37 @@ drop table t1, t2, t3; disconnect connection_update; disconnect connection_aux; +# +# Bug#34643: TRUNCATE crash if trigger and foreign key. +# + +--disable_warnings +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +--enable_warnings + +CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=innodb; +CREATE TABLE t2(b INT, FOREIGN KEY(b) REFERENCES t1(a)) ENGINE=innodb; + +INSERT INTO t1 VALUES (1); + +CREATE TRIGGER t1_bd BEFORE DELETE ON t1 FOR EACH ROW SET @a = 1; +CREATE TRIGGER t1_ad AFTER DELETE ON t1 FOR EACH ROW SET @b = 1; + +SET @a = 0; +SET @b = 0; + +TRUNCATE t1; + +SELECT @a, @b; + +INSERT INTO t1 VALUES (1); + +DELETE FROM t1; + +SELECT @a, @b; + +DROP TABLE t2, t1; + --echo End of 5.0 tests diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index a28a39a769d..3019b68d6f1 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -35,6 +35,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, READ_RECORD info; bool using_limit=limit != HA_POS_ERROR; bool transactional_table, safe_update, const_cond; + bool triggers_applicable; ha_rows deleted; uint usable_index= MAX_KEY; SELECT_LEX *select_lex= &thd->lex->select_lex; @@ -93,6 +94,11 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, select_lex->no_error= thd->lex->ignore; + /* NOTE: TRUNCATE must not invoke triggers. */ + + triggers_applicable= table->triggers && + thd->lex->sql_command != SQLCOM_TRUNCATE; + /* Test if the user wants to delete all rows and deletion doesn't have any side-effects (because of triggers), so we can use optimized @@ -102,8 +108,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, */ if (!using_limit && const_cond && (!conds || conds->val_int()) && !(specialflag & (SPECIAL_NO_NEW_FUNC | SPECIAL_SAFE_MODE)) && - (thd->lex->sql_command == SQLCOM_TRUNCATE || - !(table->triggers && table->triggers->has_delete_triggers())) + !(triggers_applicable && table->triggers->has_delete_triggers()) ) { deleted= table->file->records; @@ -217,7 +222,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, init_ftfuncs(thd, select_lex, 1); thd->proc_info="updating"; - if (table->triggers) + if (triggers_applicable) { table->triggers->mark_fields_used(thd, TRG_EVENT_DELETE); if (table->triggers->has_triggers(TRG_EVENT_DELETE, @@ -239,7 +244,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, if (!(select && select->skip_record())&& !thd->net.report_error ) { - if (table->triggers && + if (triggers_applicable && table->triggers->process_triggers(thd, TRG_EVENT_DELETE, TRG_ACTION_BEFORE, FALSE)) { @@ -250,7 +255,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, if (!(error=table->file->delete_row(table->record[0]))) { deleted++; - if (table->triggers && + if (triggers_applicable && table->triggers->process_triggers(thd, TRG_EVENT_DELETE, TRG_ACTION_AFTER, FALSE)) { From 063b50477296f20b22e5cc5c1f50b8302ef55c19 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 14 Mar 2008 17:40:12 -0300 Subject: [PATCH 5/7] Bug#35103 mysql_client_test::test_bug29948 causes sporadic failures The problem was that the COM_STMT_SEND_LONG_DATA was sending a response packet if the prepared statement wasn't found in the server (due to reconnection). The commands COM_STMT_SEND_LONG_DATA and COM_STMT_CLOSE should not send any packets, even error packets should not be sent since they are not expected by the client API. The solution is to clear generated during the execution of the aforementioned commands and to skip resend of prepared statement commands. Another fix is that if the connection breaks during the send of prepared statement command, the command is not sent again since the prepared statement is no longer in the server. libmysql/libmysql.c: The mysql handle might be reset after a reconnection. Pass the now used stmt argument to cli_advanced_command. sql-common/client.c: Don't resend command if the connection broke and it's a prepared statement command. If the session is broken, prepared statements on the server are gone, set the error accordanly. sql/sql_prepare.cc: Clear any error set during the execution of the request command. tests/mysql_client_test.c: Fix memory leak by freeing result associated with statement. Remove test case for Bug 29948 because it's not reliable in 5.0 (fixed in 5.1) due to KILL queries sending two packets for a thread that kills itself. --- libmysql/libmysql.c | 17 ++++++--- sql-common/client.c | 10 +++-- sql/sql_prepare.cc | 16 +++++--- tests/mysql_client_test.c | 79 +-------------------------------------- 4 files changed, 30 insertions(+), 92 deletions(-) diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 4afc3ec5925..b4fc40bc78a 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -2456,7 +2456,7 @@ static my_bool execute(MYSQL_STMT *stmt, char *packet, ulong length) int4store(buff+5, 1); /* iteration count */ res= test(cli_advanced_command(mysql, COM_STMT_EXECUTE, buff, sizeof(buff), - packet, length, 1, NULL) || + packet, length, 1, stmt) || (*mysql->methods->read_query_result)(mysql)); stmt->affected_rows= mysql->affected_rows; stmt->server_status= mysql->server_status; @@ -2673,7 +2673,7 @@ stmt_read_row_from_cursor(MYSQL_STMT *stmt, unsigned char **row) int4store(buff + 4, stmt->prefetch_rows); /* number of rows to fetch */ if ((*mysql->methods->advanced_command)(mysql, COM_STMT_FETCH, buff, sizeof(buff), NullS, 0, - 1, NULL)) + 1, stmt)) { set_stmt_errmsg(stmt, net->last_error, net->last_errno, net->sqlstate); return 1; @@ -3340,7 +3340,7 @@ mysql_stmt_send_long_data(MYSQL_STMT *stmt, uint param_number, */ if ((*mysql->methods->advanced_command)(mysql, COM_STMT_SEND_LONG_DATA, buff, sizeof(buff), data, - length, 1, NULL)) + length, 1, stmt)) { set_stmt_errmsg(stmt, mysql->net.last_error, mysql->net.last_errno, mysql->net.sqlstate); @@ -4737,6 +4737,13 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt) MYSQL_DATA *result= &stmt->result; DBUG_ENTER("mysql_stmt_store_result"); + if (!mysql) + { + /* mysql can be reset in mysql_close called from mysql_reconnect */ + set_stmt_error(stmt, CR_SERVER_LOST, unknown_sqlstate); + DBUG_RETURN(1); + } + mysql= mysql->last_used_con; if (!stmt->field_count) @@ -4762,7 +4769,7 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt) int4store(buff, stmt->stmt_id); int4store(buff + 4, (int)~0); /* number of rows to fetch */ if (cli_advanced_command(mysql, COM_STMT_FETCH, buff, sizeof(buff), - NullS, 0, 1, NULL)) + NullS, 0, 1, stmt)) { set_stmt_errmsg(stmt, net->last_error, net->last_errno, net->sqlstate); DBUG_RETURN(1); @@ -4949,7 +4956,7 @@ static my_bool reset_stmt_handle(MYSQL_STMT *stmt, uint flags) char buff[MYSQL_STMT_HEADER]; /* packet header: 4 bytes for stmt id */ int4store(buff, stmt->stmt_id); if ((*mysql->methods->advanced_command)(mysql, COM_STMT_RESET, buff, - sizeof(buff), 0, 0, 0, NULL)) + sizeof(buff), 0, 0, 0, stmt)) { set_stmt_errmsg(stmt, mysql->net.last_error, mysql->net.last_errno, mysql->net.sqlstate); diff --git a/sql-common/client.c b/sql-common/client.c index 1fc73549520..8b619b5452d 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -665,11 +665,12 @@ my_bool cli_advanced_command(MYSQL *mysql, enum enum_server_command command, const char *header, ulong header_length, const char *arg, ulong arg_length, my_bool skip_check, - MYSQL_STMT *stmt __attribute__((unused))) + MYSQL_STMT *stmt) { NET *net= &mysql->net; my_bool result= 1; init_sigpipe_variables + my_bool stmt_skip= stmt ? stmt->state != MYSQL_STMT_INIT_DONE : FALSE; DBUG_ENTER("cli_advanced_command"); /* Don't give sigpipe errors if the client doesn't want them */ @@ -677,7 +678,7 @@ cli_advanced_command(MYSQL *mysql, enum enum_server_command command, if (mysql->net.vio == 0) { /* Do reconnect if possible */ - if (mysql_reconnect(mysql)) + if (mysql_reconnect(mysql) || stmt_skip) DBUG_RETURN(1); } if (mysql->status != MYSQL_STATUS_READY || @@ -708,7 +709,7 @@ cli_advanced_command(MYSQL *mysql, enum enum_server_command command, goto end; } end_server(mysql); - if (mysql_reconnect(mysql)) + if (mysql_reconnect(mysql) || stmt_skip) goto end; if (net_write_command(net,(uchar) command, header, header_length, arg, arg_length)) @@ -2503,6 +2504,9 @@ my_bool mysql_reconnect(MYSQL *mysql) if (stmt->state != MYSQL_STMT_INIT_DONE) { stmt->mysql= 0; + stmt->last_errno= CR_SERVER_LOST; + strmov(stmt->last_error, ER(CR_SERVER_LOST)); + strmov(stmt->sqlstate, unknown_sqlstate); } else { diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 18cfd8d7dfc..207183f567c 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -2516,7 +2516,7 @@ void mysql_stmt_close(THD *thd, char *packet) DBUG_ENTER("mysql_stmt_close"); if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_close"))) - DBUG_VOID_RETURN; + goto out; /* The only way currently a statement can be deallocated when it's @@ -2525,6 +2525,9 @@ void mysql_stmt_close(THD *thd, char *packet) DBUG_ASSERT(! (stmt->flags & (uint) Prepared_statement::IS_IN_USE)); (void) stmt->deallocate(); +out: + /* clear errors, response packet is not expected */ + thd->clear_error(); DBUG_VOID_RETURN; } @@ -2591,10 +2594,7 @@ void mysql_stmt_get_longdata(THD *thd, char *packet, ulong packet_length) #ifndef EMBEDDED_LIBRARY /* Minimal size of long data packet is 6 bytes */ if (packet_length <= MYSQL_LONG_DATA_HEADER) - { - my_error(ER_WRONG_ARGUMENTS, MYF(0), "mysql_stmt_send_long_data"); - DBUG_VOID_RETURN; - } + goto out; #endif stmt_id= uint4korr(packet); @@ -2614,7 +2614,7 @@ void mysql_stmt_get_longdata(THD *thd, char *packet, ulong packet_length) stmt->last_errno= ER_WRONG_ARGUMENTS; sprintf(stmt->last_error, ER(ER_WRONG_ARGUMENTS), "mysql_stmt_send_long_data"); - DBUG_VOID_RETURN; + goto out; } #endif @@ -2630,6 +2630,10 @@ void mysql_stmt_get_longdata(THD *thd, char *packet, ulong packet_length) stmt->last_errno= ER_OUTOFMEMORY; sprintf(stmt->last_error, ER(ER_OUTOFMEMORY), 0); } + +out: + /* clear errors, response packet is not expected */ + thd->clear_error(); DBUG_VOID_RETURN; } diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 0deb37d25c3..142fd741443 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -11746,6 +11746,7 @@ static void test_bug5194() rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); + mysql_stmt_reset(stmt); } mysql_stmt_close(stmt); @@ -15942,83 +15943,6 @@ static void test_bug27592() DBUG_VOID_RETURN; } -#if 0 - -static void test_bug29948() -{ - MYSQL *dbc=NULL; - MYSQL_STMT *stmt=NULL; - MYSQL_BIND bind; - - int res=0; - my_bool auto_reconnect=1, error=0, is_null=0; - char kill_buf[20]; - const char *query; - int buf; - unsigned long length, cursor_type; - - dbc = mysql_init(NULL); - DIE_UNLESS(dbc); - - mysql_options(dbc, MYSQL_OPT_RECONNECT, (char*)&auto_reconnect); - if (!mysql_real_connect(dbc, opt_host, opt_user, - opt_password, current_db, opt_port, - opt_unix_socket, - (CLIENT_FOUND_ROWS | CLIENT_MULTI_STATEMENTS | - CLIENT_MULTI_RESULTS))) - { - printf("connection failed: %s (%d)", mysql_error(dbc), - mysql_errno(dbc)); - exit(1); - } - - bzero(&bind, sizeof(bind)); - bind.buffer_type= MYSQL_TYPE_LONG; - bind.buffer= (char *)&buf; - bind.is_null= &is_null; - bind.error= &error; - bind.length= &length; - - res= mysql_query(dbc, "DROP TABLE IF EXISTS t1"); - myquery(res); - res= mysql_query(dbc, "CREATE TABLE t1 (a INT)"); - myquery(res); - res= mysql_query(dbc, "INSERT INTO t1 VALUES(1)"); - myquery(res); - - stmt= mysql_stmt_init(dbc); - check_stmt(stmt); - - cursor_type= CURSOR_TYPE_READ_ONLY; - res= mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (void *)&cursor_type); - myquery(res); - - query= "SELECT * from t1 where a=?"; - res= mysql_stmt_prepare(stmt, query, strlen(query)); - myquery(res); - - res= mysql_stmt_bind_param(stmt, &bind); - myquery(res); - - res= mysql_stmt_execute(stmt); - check_execute(stmt, res); - - res= mysql_stmt_bind_result(stmt,&bind); - check_execute(stmt, res); - - sprintf(kill_buf, "kill %ld", dbc->thread_id); - mysql_query(dbc, kill_buf); - - res= mysql_stmt_store_result(stmt); - DIE_UNLESS(res); - - mysql_stmt_free_result(stmt); - mysql_stmt_close(stmt); - mysql_query(dbc, "DROP TABLE t1"); - mysql_close(dbc); -} - -#endif /** Bug#29306 Truncated data in MS Access with decimal (3,1) columns in a VIEW @@ -16546,7 +16470,6 @@ static struct my_tests_st my_tests[]= { { "test_bug28505", test_bug28505 }, { "test_bug28934", test_bug28934 }, { "test_bug27592", test_bug27592 }, - /* { "test_bug29948", test_bug29948 }, Bug#35103 */ { "test_bug29306", test_bug29306 }, { "test_bug31669", test_bug31669 }, { "test_bug32265", test_bug32265 }, From 23d567aa7cb01811294a24ecda100d2a90fe8acf Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 17 Mar 2008 11:16:37 -0300 Subject: [PATCH 6/7] Post-merge fix for Bug 35103. sql/sql_prepare.cc: Don't send unexpected error to the client. --- sql/sql_prepare.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 207183f567c..b00606aba4a 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -2602,7 +2602,7 @@ void mysql_stmt_get_longdata(THD *thd, char *packet, ulong packet_length) if (!(stmt=find_prepared_statement(thd, stmt_id, "mysql_stmt_send_long_data"))) - DBUG_VOID_RETURN; + goto out; param_number= uint2korr(packet); packet+= 2; From edce44eea0b09d0d052c9d8f2ba523136a6644b2 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 19 Mar 2008 15:01:03 -0300 Subject: [PATCH 7/7] Bug#30960 processlist state '*** DEAD ***' on recent 5.0.48 windows builds The problem is that unimplemented WIN32 version of pthread_kill is returning ESRCH no matter the arguments, causing calls to mysqld_list_processes to set the procinfo to dead because pthread_kill returns non zero. The dead procinfo would show up on a second invocation of show processlist. include/my_pthread.h: When unimplemented, pthread_kill must return zero for any process id other then zero. --- include/my_pthread.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/my_pthread.h b/include/my_pthread.h index 13b7cf93d6f..51202d6665e 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -181,7 +181,7 @@ extern int pthread_mutex_destroy (pthread_mutex_t *); #define pthread_mutex_unlock(A) LeaveCriticalSection(A) #define pthread_mutex_destroy(A) DeleteCriticalSection(A) #define my_pthread_setprio(A,B) SetThreadPriority(GetCurrentThread(), (B)) -#define pthread_kill(A,B) pthread_dummy(ESRCH) +#define pthread_kill(A,B) pthread_dummy((A) ? 0 : ESRCH) #endif /* OS2 */ /* Dummy defines for easier code */ @@ -445,14 +445,14 @@ struct tm *gmtime_r(const time_t *clock, struct tm *res); #define pthread_attr_setdetachstate(A,B) pthread_dummy(0) #define pthread_create(A,B,C,D) pthread_create((A),*(B),(C),(D)) #define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C)) -#define pthread_kill(A,B) pthread_dummy(ESRCH) +#define pthread_kill(A,B) pthread_dummy((A) ? 0 : ESRCH) #undef pthread_detach_this_thread #define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(&tmp); } #endif #ifdef HAVE_DARWIN5_THREADS #define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C)) -#define pthread_kill(A,B) pthread_dummy(ESRCH) +#define pthread_kill(A,B) pthread_dummy((A) ? 0 : ESRCH) #define pthread_condattr_init(A) pthread_dummy(0) #define pthread_condattr_destroy(A) pthread_dummy(0) #undef pthread_detach_this_thread @@ -472,7 +472,7 @@ struct tm *gmtime_r(const time_t *clock, struct tm *res); #ifndef pthread_sigmask #define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C)) #endif -#define pthread_kill(A,B) pthread_dummy(ESRCH) +#define pthread_kill(A,B) pthread_dummy((A) ? 0 : ESRCH) #undef pthread_detach_this_thread #define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(&tmp); } #elif !defined(__NETWARE__) /* HAVE_PTHREAD_ATTR_CREATE && !HAVE_SIGWAIT */