From 0ac493d16c03617d7bde630eda8a00ca32095d12 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Thu, 13 Oct 2005 13:37:10 +0200 Subject: [PATCH 1/4] Bug #12698 abnormal program termination running mysql_client_test - The testcase create a .frm file consisting of "junk". Unfortunately the "junk" wasn't written to the .frm file if mysql_client_test was run with -s option to make it run silent. This most likely caused the file never to be created on windows, and thus the test case failed. --- tests/mysql_client_test.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index eadbd37f8f6..6717e31c18f 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -6962,8 +6962,7 @@ static void test_frm_bug() fprintf(stdout, "\n test cancelled"); exit(1); } - if (!opt_silent) - fprintf(test_file, "this is a junk file for test"); + fprintf(test_file, "this is a junk file for test"); rc= mysql_query(mysql, "SHOW TABLE STATUS like 'test_frm_bug'"); myquery(rc); From b81f3ef1ef750f2ea5c4e4d71ced6c7429d5ab32 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Thu, 13 Oct 2005 15:52:22 +0200 Subject: [PATCH 2/4] Bug #12698 abnormal program termination running mysql_client_test - Move test for bug#93 from mysql_client_test.c to show_check.test - No need for test written in c --- mysql-test/r/show_check.result | 7 +++ mysql-test/t/show_check.test | 13 +++++ tests/mysql_client_test.c | 92 ---------------------------------- 3 files changed, 20 insertions(+), 92 deletions(-) diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result index 1e5e8f442a8..9861daff409 100644 --- a/mysql-test/r/show_check.result +++ b/mysql-test/r/show_check.result @@ -513,3 +513,10 @@ t1 CREATE TABLE `t1` ( KEY `c2` USING BTREE (`c2`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 DROP TABLE t1; +flush tables; +SHOW TABLE STATUS like 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 NULL NULL NULL NULL # # # # NULL NULL NULL NULL NULL NULL NULL NULL Incorrect information in file: './test/t1.frm' +show create table t1; +ERROR HY000: Incorrect information in file: './test/t1.frm' +drop table t1; diff --git a/mysql-test/t/show_check.test b/mysql-test/t/show_check.test index e6a404e3b57..d70903adbc4 100644 --- a/mysql-test/t/show_check.test +++ b/mysql-test/t/show_check.test @@ -378,4 +378,17 @@ create table t1 ( SHOW CREATE TABLE t1; DROP TABLE t1; +# Test for BUG#93: 4.1 protocl crash on corupted frm and SHOW TABLE STATUS + +flush tables; + +# Create a junk frm file on disk +system echo "this is a junk file for test" >> var/master-data/test/t1.frm ; +--replace_column 6 # 7 # 8 # 9 # +SHOW TABLE STATUS like 't1'; +--error 1033 +show create table t1; +drop table t1; + + # End of 4.1 tests diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 6717e31c18f..99d014107de 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -6899,97 +6899,6 @@ static void test_prepare_grant() } #endif /* EMBEDDED_LIBRARY */ -/* - Test a crash when invalid/corrupted .frm is used in the - SHOW TABLE STATUS - bug #93 (reported by serg@mysql.com). -*/ - -static void test_frm_bug() -{ - MYSQL_STMT *stmt; - MYSQL_BIND bind[2]; - MYSQL_RES *result; - MYSQL_ROW row; - FILE *test_file; - char data_dir[FN_REFLEN]; - char test_frm[FN_REFLEN]; - int rc; - - myheader("test_frm_bug"); - - mysql_autocommit(mysql, TRUE); - - rc= mysql_query(mysql, "drop table if exists test_frm_bug"); - myquery(rc); - - rc= mysql_query(mysql, "flush tables"); - myquery(rc); - - stmt= mysql_simple_prepare(mysql, "show variables like 'datadir'"); - check_stmt(stmt); - - rc= mysql_stmt_execute(stmt); - check_execute(stmt, rc); - - bind[0].buffer_type= MYSQL_TYPE_STRING; - bind[0].buffer= data_dir; - bind[0].buffer_length= FN_REFLEN; - bind[0].is_null= 0; - bind[0].length= 0; - bind[1]= bind[0]; - - rc= mysql_stmt_bind_result(stmt, bind); - check_execute(stmt, rc); - - rc= mysql_stmt_fetch(stmt); - check_execute(stmt, rc); - - if (!opt_silent) - fprintf(stdout, "\n data directory: %s", data_dir); - - rc= mysql_stmt_fetch(stmt); - DIE_UNLESS(rc == MYSQL_NO_DATA); - - strxmov(test_frm, data_dir, "/", current_db, "/", "test_frm_bug.frm", NullS); - - if (!opt_silent) - fprintf(stdout, "\n test_frm: %s", test_frm); - - if (!(test_file= my_fopen(test_frm, (int) (O_RDWR | O_CREAT), MYF(MY_WME)))) - { - fprintf(stdout, "\n ERROR: my_fopen failed for '%s'", test_frm); - fprintf(stdout, "\n test cancelled"); - exit(1); - } - fprintf(test_file, "this is a junk file for test"); - - rc= mysql_query(mysql, "SHOW TABLE STATUS like 'test_frm_bug'"); - myquery(rc); - - result= mysql_store_result(mysql); - mytest(result);/* It can't be NULL */ - - rc= my_process_result_set(result); - DIE_UNLESS(rc == 1); - - mysql_data_seek(result, 0); - - row= mysql_fetch_row(result); - mytest(row); - - if (!opt_silent) - fprintf(stdout, "\n Comment: %s", row[17]); - DIE_UNLESS(row[17] != 0); - - mysql_free_result(result); - mysql_stmt_close(stmt); - - my_fclose(test_file, MYF(0)); - mysql_query(mysql, "drop table if exists test_frm_bug"); -} - - /* Test DECIMAL conversion */ static void test_decimal_bug() @@ -11975,7 +11884,6 @@ static struct my_tests_st my_tests[]= { #ifndef EMBEDDED_LIBRARY { "test_prepare_grant", test_prepare_grant }, #endif - { "test_frm_bug", test_frm_bug }, { "test_explain_bug", test_explain_bug }, { "test_decimal_bug", test_decimal_bug }, { "test_nstmts", test_nstmts }, From 6f3caecffd599da321f119825197e6ce71b75319 Mon Sep 17 00:00:00 2001 From: "jonas@perch.ndb.mysql.com" <> Date: Fri, 21 Oct 2005 06:41:49 +0200 Subject: [PATCH 3/4] bug#14199 - ndb leak of index opertaions in TC leading to error 288 --- .../kernel/signaldata/DumpStateOrd.hpp | 2 ++ ndb/src/kernel/blocks/dbtc/DbtcMain.cpp | 30 ++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/ndb/include/kernel/signaldata/DumpStateOrd.hpp b/ndb/include/kernel/signaldata/DumpStateOrd.hpp index 7368a0ec40d..bde690e056d 100644 --- a/ndb/include/kernel/signaldata/DumpStateOrd.hpp +++ b/ndb/include/kernel/signaldata/DumpStateOrd.hpp @@ -98,6 +98,8 @@ public: StartTcTimer = 2509, StopTcTimer = 2510, StartPeriodicTcTimer = 2511, + TcStartDumpIndexOpCount = 2512, + TcDumpIndexOpCount = 2513, CmvmiDumpConnections = 2600, CmvmiDumpLongSignalMemory = 2601, CmvmiSetRestartOnErrorInsert = 2602, diff --git a/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp b/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp index 04b40dafcb5..30a50e7695e 100644 --- a/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp +++ b/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp @@ -4607,6 +4607,7 @@ void Dbtc::copyApi(Signal* signal) regTmpApiPtr->commitAckMarker = RNIL; regTmpApiPtr->firstTcConnect = RNIL; regTmpApiPtr->lastTcConnect = RNIL; + releaseAllSeizedIndexOperations(regTmpApiPtr); }//Dbtc::copyApi() void Dbtc::unlinkApiConnect(Signal* signal) @@ -10134,7 +10135,7 @@ void Dbtc::releaseAbortResources(Signal* signal) // apiConnectptr.p->apiConnectstate = CS_CONNECTED; apiConnectptr.p->apiConnectstate = CS_ABORTING; apiConnectptr.p->abortState = AS_IDLE; - + releaseAllSeizedIndexOperations(apiConnectptr.p); if(apiConnectptr.p->m_exec_flag || apiConnectptr.p->apiFailState == ZTRUE){ jam(); bool ok = false; @@ -10707,6 +10708,33 @@ Dbtc::execDUMP_STATE_ORD(Signal* signal) signal->theData[0] = TcContinueB::ZTRANS_EVENT_REP; sendSignalWithDelay(cownref, GSN_CONTINUEB, signal, 5000, 1); } + + if (dumpState->args[0] == DumpStateOrd::TcStartDumpIndexOpCount) + { + static int frequency = 1; + if (signal->getLength() > 1) + frequency = signal->theData[1]; + else + if (refToBlock(signal->getSendersBlockRef()) != DBTC) + frequency = 1; + + if (frequency) + { + dumpState->args[0] = DumpStateOrd::TcDumpIndexOpCount; + execDUMP_STATE_ORD(signal); + dumpState->args[0] = DumpStateOrd::TcStartDumpIndexOpCount; + + Uint32 delay = 1000 * (frequency > 25 ? 25 : frequency); + sendSignalWithDelay(cownref, GSN_DUMP_STATE_ORD, signal, delay, 1); + } + } + + if (dumpState->args[0] == DumpStateOrd::TcDumpIndexOpCount) + { + infoEvent("IndexOpCount: pool: %d free: %d", + c_theIndexOperationPool.getSize(), + c_theIndexOperationPool.getNoOfFree()); + } }//Dbtc::execDUMP_STATE_ORD() void Dbtc::execSET_VAR_REQ(Signal* signal) From a167ddc6e7886e2b681511bde2c82ec5c2379290 Mon Sep 17 00:00:00 2001 From: "bar@mysql.com" <> Date: Fri, 21 Oct 2005 14:41:56 +0500 Subject: [PATCH 4/4] Bug#13233 select distinct char(column) fails with utf8 ctype_utf8.result, ctype_utf8.test: Adding test case sql_yacc.yy: Adding new syntax. item_strfunc.h: Fixing wrong max_length calculation. Also, adding CHAR(x USING charset), for easier migrating from 4.1 to 5.0, according to Monty's suggestion. --- mysql-test/r/ctype_utf8.result | 9 +++++++++ mysql-test/t/ctype_utf8.test | 9 +++++++++ sql/item_strfunc.h | 9 ++++++--- sql/sql_yacc.yy | 2 ++ 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result index c7606b918df..03d3ab9f22e 100644 --- a/mysql-test/r/ctype_utf8.result +++ b/mysql-test/r/ctype_utf8.result @@ -1061,3 +1061,12 @@ create table t1 (a varchar(255)) default charset=utf8; select * from t1 where find_in_set('-1', a); a drop table t1; +create table t1 (a int); +insert into t1 values (48),(49),(50); +set names utf8; +select distinct char(a) from t1; +char(a) +0 +1 +2 +drop table t1; diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test index dcb7469d46e..8c0e03c0cd3 100644 --- a/mysql-test/t/ctype_utf8.test +++ b/mysql-test/t/ctype_utf8.test @@ -873,4 +873,13 @@ create table t1 (a varchar(255)) default charset=utf8; select * from t1 where find_in_set('-1', a); drop table t1; +# +# Bug#13233: select distinct char(column) fails with utf8 +# +create table t1 (a int); +insert into t1 values (48),(49),(50); +set names utf8; +select distinct char(a) from t1; +drop table t1; + # End of 4.1 tests diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index b01d75b8e02..5525c046b95 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -444,12 +444,15 @@ public: class Item_func_char :public Item_str_func { public: - Item_func_char(List &list) :Item_str_func(list) {} + Item_func_char(List &list) :Item_str_func(list) + { collation.set(default_charset()); } + Item_func_char(List &list, CHARSET_INFO *cs) :Item_str_func(list) + { collation.set(cs); } String *val_str(String *); void fix_length_and_dec() { - collation.set(default_charset()); - maybe_null=0; max_length=arg_count; + maybe_null=0; + max_length=arg_count * collation.collation->mbmaxlen; } const char *func_name() const { return "char"; } }; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 82f9c5a288f..c99abc7d349 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -2924,6 +2924,8 @@ simple_expr: { $$= new Item_func_atan($3,$5); } | CHAR_SYM '(' expr_list ')' { $$= new Item_func_char(*$3); } + | CHAR_SYM '(' expr_list USING charset_name ')' + { $$= new Item_func_char(*$3, $5); } | CHARSET '(' expr ')' { $$= new Item_func_charset($3); } | COALESCE '(' expr_list ')'