summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorunknown <konstantin@mysql.com>2006-01-18 22:50:31 +0300
committerunknown <konstantin@mysql.com>2006-01-18 22:50:31 +0300
commit1e8e302effdb998223c65ebfe8dbea2d01a8385c (patch)
treeb5c59dd9f326cc1228a43e3927586332f07403ad /tests
parent984484015c2a629c01686bc5ef324855dc9bba3f (diff)
downloadmariadb-git-1e8e302effdb998223c65ebfe8dbea2d01a8385c.tar.gz
A fix and a test case for Bug#15613 "libmysqlclient API function
mysql_stmt_prepare returns wrong field length" sql/protocol.cc: A fix for Bug#15613: make sure that result set column length is evaluated correctly for BLOB/TEXT columns. tests/mysql_client_test.c: A test case for Bug#15613
Diffstat (limited to 'tests')
-rw-r--r--tests/mysql_client_test.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c
index 797a0b1b8d7..91c2ab9205d 100644
--- a/tests/mysql_client_test.c
+++ b/tests/mysql_client_test.c
@@ -11773,6 +11773,70 @@ static void test_bug16144()
/*
+ Bug #15613: "libmysqlclient API function mysql_stmt_prepare returns wrong
+ field length"
+*/
+
+static void test_bug15613()
+{
+ MYSQL_STMT *stmt;
+ const char *stmt_text;
+ MYSQL_RES *metadata;
+ MYSQL_FIELD *field;
+ int rc;
+ myheader("test_bug15613");
+
+ /* I. Prepare the table */
+ rc= mysql_query(mysql, "set names latin1");
+ myquery(rc);
+ mysql_query(mysql, "drop table if exists t1");
+ rc= mysql_query(mysql,
+ "create table t1 (t text character set utf8, "
+ "tt tinytext character set utf8, "
+ "mt mediumtext character set utf8, "
+ "lt longtext character set utf8, "
+ "vl varchar(255) character set latin1,"
+ "vb varchar(255) character set binary,"
+ "vu varchar(255) character set utf8)");
+ myquery(rc);
+
+ stmt= mysql_stmt_init(mysql);
+
+ /* II. Check SELECT metadata */
+ stmt_text= ("select t, tt, mt, lt, vl, vb, vu from t1");
+ rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text));
+ metadata= mysql_stmt_result_metadata(stmt);
+ field= mysql_fetch_fields(metadata);
+ if (!opt_silent)
+ {
+ printf("Field lengths (client character set is latin1):\n"
+ "text character set utf8:\t\t%lu\n"
+ "tinytext character set utf8:\t\t%lu\n"
+ "mediumtext character set utf8:\t\t%lu\n"
+ "longtext character set utf8:\t\t%lu\n"
+ "varchar(255) character set latin1:\t%lu\n"
+ "varchar(255) character set binary:\t%lu\n"
+ "varchar(255) character set utf8:\t%lu\n",
+ field[0].length, field[1].length, field[2].length, field[3].length,
+ field[4].length, field[5].length, field[6].length);
+ }
+ DIE_UNLESS(field[0].length == 65535);
+ DIE_UNLESS(field[1].length == 255);
+ DIE_UNLESS(field[2].length == 16777215);
+ DIE_UNLESS(field[3].length == 4294967295UL);
+ DIE_UNLESS(field[4].length == 255);
+ DIE_UNLESS(field[5].length == 255);
+ DIE_UNLESS(field[6].length == 255);
+
+ /* III. Cleanup */
+ rc= mysql_query(mysql, "drop table t1");
+ myquery(rc);
+ rc= mysql_query(mysql, "set names default");
+ myquery(rc);
+ mysql_stmt_close(stmt);
+}
+
+/*
Read and parse arguments and MySQL options from my.cnf
*/
@@ -11994,6 +12058,7 @@ static struct my_tests_st my_tests[]= {
{ "test_bug11718", test_bug11718 },
{ "test_bug12925", test_bug12925 },
{ "test_bug16144", test_bug16144 },
+ { "test_bug15613", test_bug15613 },
{ 0, 0 }
};