diff --git a/libmariadb/ma_stmt_codec.c b/libmariadb/ma_stmt_codec.c index 913b6a87..2da04651 100644 --- a/libmariadb/ma_stmt_codec.c +++ b/libmariadb/ma_stmt_codec.c @@ -1240,27 +1240,27 @@ void mysql_init_ps_subsystem(void) mysql_ps_fetch_functions[MYSQL_TYPE_TINY].func = ps_fetch_int8; mysql_ps_fetch_functions[MYSQL_TYPE_TINY].pack_len = 1; - mysql_ps_fetch_functions[MYSQL_TYPE_TINY].max_len = 4; + mysql_ps_fetch_functions[MYSQL_TYPE_TINY].max_len = 3; mysql_ps_fetch_functions[MYSQL_TYPE_SHORT].func = ps_fetch_int16; mysql_ps_fetch_functions[MYSQL_TYPE_SHORT].pack_len = 2; - mysql_ps_fetch_functions[MYSQL_TYPE_SHORT].max_len = 6; + mysql_ps_fetch_functions[MYSQL_TYPE_SHORT].max_len = 5; mysql_ps_fetch_functions[MYSQL_TYPE_YEAR].func = ps_fetch_int16; mysql_ps_fetch_functions[MYSQL_TYPE_YEAR].pack_len = 2; - mysql_ps_fetch_functions[MYSQL_TYPE_YEAR].max_len = 6; + mysql_ps_fetch_functions[MYSQL_TYPE_YEAR].max_len = 4; mysql_ps_fetch_functions[MYSQL_TYPE_INT24].func = ps_fetch_int32; mysql_ps_fetch_functions[MYSQL_TYPE_INT24].pack_len = 4; - mysql_ps_fetch_functions[MYSQL_TYPE_INT24].max_len = 9; + mysql_ps_fetch_functions[MYSQL_TYPE_INT24].max_len = 8; mysql_ps_fetch_functions[MYSQL_TYPE_LONG].func = ps_fetch_int32; mysql_ps_fetch_functions[MYSQL_TYPE_LONG].pack_len = 4; - mysql_ps_fetch_functions[MYSQL_TYPE_LONG].max_len = 11; + mysql_ps_fetch_functions[MYSQL_TYPE_LONG].max_len = 10; mysql_ps_fetch_functions[MYSQL_TYPE_LONGLONG].func = ps_fetch_int64; mysql_ps_fetch_functions[MYSQL_TYPE_LONGLONG].pack_len= 8; - mysql_ps_fetch_functions[MYSQL_TYPE_LONGLONG].max_len = 21; + mysql_ps_fetch_functions[MYSQL_TYPE_LONGLONG].max_len = 20; mysql_ps_fetch_functions[MYSQL_TYPE_FLOAT].func = ps_fetch_float; mysql_ps_fetch_functions[MYSQL_TYPE_FLOAT].pack_len = 4; diff --git a/unittest/libmariadb/ps.c b/unittest/libmariadb/ps.c index 40ccad6f..58aa6f58 100644 --- a/unittest/libmariadb/ps.c +++ b/unittest/libmariadb/ps.c @@ -5118,7 +5118,59 @@ static int test_conc349(MYSQL *mysql) return OK; } +static int test_conc565(MYSQL *mysql) +{ + MYSQL_STMT *stmt= mysql_stmt_init(mysql); + MYSQL_FIELD *fields_binary, *fields_text; + MYSQL_RES *result; + int rc; + my_bool x=1; + my_bool error= 0; + + rc= mysql_query(mysql, "CREATE TEMPORARY TABLE t1 (a year, b tinyint unsigned, c smallint unsigned, d mediumint unsigned, e int unsigned, f bigint unsigned)"); + check_mysql_rc(rc, mysql); + + rc= mysql_query(mysql, "INSERT INTO t1 VALUES (2020, 127, 0xFFFF, 0xFFFFFF, 0xFFFFFFFF, 0xFFFFFFFFFFFFFFFF)"); + check_mysql_rc(rc, mysql); + + rc= mysql_stmt_prepare(stmt, "select a,b,c,d,e,f from t1", -1); + check_stmt_rc(rc, stmt); + + rc= mysql_stmt_attr_set(stmt, STMT_ATTR_UPDATE_MAX_LENGTH, (void *)&x); + check_stmt_rc(rc, stmt); + + rc= mysql_stmt_execute(stmt); + check_stmt_rc(rc, stmt); + + mysql_stmt_store_result(stmt); + fields_binary= mariadb_stmt_fetch_fields(stmt); + + rc= mysql_query(mysql, "SELECT a,b,c,d,e,f FROM t1"); + result= mysql_store_result(mysql); + fields_text= mysql_fetch_fields(result); + + for (unsigned int i=0; i < mysql_field_count(mysql); i++) + { + if (fields_binary[i].length != fields_text[i].length || + fields_binary[i].max_length != fields_text[i].max_length) + { + diag("Sizes differ for column %d (type= %d)", i, fields_binary[i].type); + diag("Binary (length=%ld max_length=%ld) != Text(length=%ld max_length=%ld", + fields_binary[i].length, fields_binary[i].max_length, + fields_text[i].length, fields_text[i].max_length); + error= 1; + goto end; + } + } +end: + mysql_free_result(result); + mysql_stmt_close(stmt); + + return error ? FAIL : OK; +} + struct my_tests_st my_tests[] = { + {"test_conc565", test_conc565, TEST_CONNECTION_DEFAULT, 0, NULL, NULL}, {"test_conc349", test_conc349, TEST_CONNECTION_DEFAULT, 0, NULL, NULL}, {"test_prepare_error", test_prepare_error, TEST_CONNECTION_NEW, 0, NULL, NULL}, {"test_reexecute", test_reexecute, TEST_CONNECTION_NEW, 0, NULL, NULL},