diff options
author | Ramil Kalimullin <ramil@mysql.com> | 2009-02-26 12:34:15 +0400 |
---|---|---|
committer | Ramil Kalimullin <ramil@mysql.com> | 2009-02-26 12:34:15 +0400 |
commit | c9e1884cd6e70d89f0a0c2bce1b80f84b913f59a (patch) | |
tree | 2d5901ba10153eecf9f24dc21ad08acd92adeac9 /tests | |
parent | b19b8afe6cedcdaac1e21263bc0398e304bd197e (diff) | |
download | mariadb-git-c9e1884cd6e70d89f0a0c2bce1b80f84b913f59a.tar.gz |
Fix for bug#19829:make test Failed in mysql_client_test
*with --with-charset=utf8*
Problem: wrong LONG TEXT field length is sent to a client
when multibyte server character set used.
Fix: always limit field length sent to a client to 2^32,
as we store it in 4 byte slot.
Note: mysql_client_test changed accordingly.
sql/protocol.cc:
Fix for bug#19829:make test Failed in mysql_client_test
*with --with-charset=utf8*
- limit field length sent to client to UINT_MAX32 as
it may exceeds 32 bit slot for LONG TEXT fields if
thd_charset->mbmaxlen > 1.
tests/mysql_client_test.c:
Fix for bug#19829:make test Failed in mysql_client_test
*with --with-charset=utf8*
- checking field members have in mind that field length
is limited to UINT_MAX32.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/mysql_client_test.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index f848e93a5c6..7df84c600c9 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -714,6 +714,7 @@ static void do_verify_prepare_field(MYSQL_RES *result, { MYSQL_FIELD *field; CHARSET_INFO *cs; + ulonglong expected_field_length; if (!(field= mysql_fetch_field_direct(result, no))) { @@ -722,6 +723,8 @@ static void do_verify_prepare_field(MYSQL_RES *result, } cs= get_charset(field->charsetnr, 0); DIE_UNLESS(cs); + if ((expected_field_length= length * cs->mbmaxlen) > UINT_MAX32) + expected_field_length= UINT_MAX32; if (!opt_silent) { fprintf(stdout, "\n field[%d]:", no); @@ -736,8 +739,8 @@ static void do_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 :`%lu`\t(expected: `%lu`)", - field->length, length * cs->mbmaxlen); + fprintf(stdout, "\n length :`%lu`\t(expected: `%llu`)", + field->length, expected_field_length); fprintf(stdout, "\n maxlength:`%ld`", field->max_length); fprintf(stdout, "\n charsetnr:`%d`", field->charsetnr); fprintf(stdout, "\n default :`%s`\t(expected: `%s`)", @@ -773,11 +776,11 @@ static void do_verify_prepare_field(MYSQL_RES *result, as utf8. Field length is calculated as number of characters * maximum number of bytes a character can occupy. */ - if (length && field->length != length * cs->mbmaxlen) + if (length && (field->length != expected_field_length)) { - fprintf(stderr, "Expected field length: %d, got length: %d\n", - (int) (length * cs->mbmaxlen), (int) field->length); - DIE_UNLESS(field->length == length * cs->mbmaxlen); + fprintf(stderr, "Expected field length: %llu, got length: %lu\n", + expected_field_length, field->length); + DIE_UNLESS(field->length == expected_field_length); } if (def) DIE_UNLESS(strcmp(field->def, def) == 0); |