From a16a61d9590a807eae0037f6bb3f19ecedbe3b14 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 14 Jul 2005 15:13:23 +0400 Subject: A fix and a test case for Bug#9735. No separate typecode for MEDIUMTEXT/LONGTEXT is added, as we have no sound decision yet what typecodes and for what types are sent by the server (aka what constitutes a distinct type in MySQL). mysql-test/r/ps_2myisam.result: Test results fixed: new longtext/longblob length (2^32) mysql-test/r/ps_3innodb.result: Test results fixed: new longtext/longblob length (2^32) mysql-test/r/ps_4heap.result: Test results fixed: new longtext/longblob length (2^32) mysql-test/r/ps_5merge.result: Test results fixed: new longtext/longblob length (2^32) mysql-test/r/ps_6bdb.result: Test results fixed: new longtext/longblob length (2^32) mysql-test/r/ps_7ndb.result: Test results fixed: new longtext/longblob length (2^32) sql/field.cc: A fix for Bug#9735 "mysql_fetch_fields() acts strange on LONGBLOB/LONGTEXT": fix wrong initialization of field_length in case of BLOB fields. tests/mysql_client_test.c: A test case for Bug#9735 "mysql_fetch_fields() acts strange on LONGBLOB/LONGTEXT" --- tests/mysql_client_test.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index dbee6e77e4f..f874276a656 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -672,7 +672,7 @@ static void verify_prepare_field(MYSQL_RES *result, fprintf(stdout, "\n org_table:`%s`\t(expected: `%s`)", field->org_table, org_table); fprintf(stdout, "\n database :`%s`\t(expected: `%s`)", field->db, db); - fprintf(stdout, "\n length :`%ld`\t(expected: `%ld`)", + fprintf(stdout, "\n length :`%lu`\t(expected: `%lu`)", field->length, length * cs->mbmaxlen); fprintf(stdout, "\n maxlength:`%ld`", field->max_length); fprintf(stdout, "\n charsetnr:`%d`", field->charsetnr); @@ -11670,6 +11670,34 @@ static void test_bug8378() #endif } + +/* Test correct max length for MEDIUMTEXT and LONGTEXT columns */ + +static void test_bug9735() +{ + MYSQL_RES *res; + int rc; + + myheader("test_bug9735"); + + rc= mysql_query(mysql, "drop table if exists t1"); + myquery(rc); + rc= mysql_query(mysql, "create table t1 (a mediumtext, b longtext) " + "character set latin1"); + myquery(rc); + rc= mysql_query(mysql, "select * from t1"); + myquery(rc); + res= mysql_store_result(mysql); + verify_prepare_field(res, 0, "a", "a", MYSQL_TYPE_BLOB, + "t1", "t1", current_db, (1U << 24)-1, 0); + verify_prepare_field(res, 1, "b", "b", MYSQL_TYPE_BLOB, + "t1", "t1", current_db, ~0U, 0); + mysql_free_result(res); + rc= mysql_query(mysql, "drop table t1"); + myquery(rc); +} + + /* Read and parse arguments and MySQL options from my.cnf */ @@ -11884,6 +11912,7 @@ static struct my_tests_st my_tests[]= { { "test_bug8330", test_bug8330 }, { "test_bug7990", test_bug7990 }, { "test_bug8378", test_bug8378 }, + { "test_bug9735", test_bug9735 }, { 0, 0 } }; -- cgit v1.2.1