1
0
mirror of https://github.com/mariadb-corporation/mariadb-connector-c.git synced 2025-08-08 14:02:17 +03:00

Merge branch '3.1' into 3.2

This commit is contained in:
Georg Richter
2021-09-21 14:49:06 +02:00
2 changed files with 15 additions and 4 deletions

View File

@@ -1240,11 +1240,11 @@ void mysql_init_ps_subsystem(void)
mysql_ps_fetch_functions[MYSQL_TYPE_TINY].func = ps_fetch_int8; 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].pack_len = 1;
mysql_ps_fetch_functions[MYSQL_TYPE_TINY].max_len = 3; mysql_ps_fetch_functions[MYSQL_TYPE_TINY].max_len = 4;
mysql_ps_fetch_functions[MYSQL_TYPE_SHORT].func = ps_fetch_int16; 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].pack_len = 2;
mysql_ps_fetch_functions[MYSQL_TYPE_SHORT].max_len = 5; mysql_ps_fetch_functions[MYSQL_TYPE_SHORT].max_len = 6;
mysql_ps_fetch_functions[MYSQL_TYPE_YEAR].func = ps_fetch_int16; 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].pack_len = 2;
@@ -1256,7 +1256,7 @@ void mysql_init_ps_subsystem(void)
mysql_ps_fetch_functions[MYSQL_TYPE_LONG].func = ps_fetch_int32; 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].pack_len = 4;
mysql_ps_fetch_functions[MYSQL_TYPE_LONG].max_len = 10; mysql_ps_fetch_functions[MYSQL_TYPE_LONG].max_len = 11;
mysql_ps_fetch_functions[MYSQL_TYPE_LONGLONG].func = ps_fetch_int64; 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].pack_len= 8;

View File

@@ -252,13 +252,24 @@ int mthd_stmt_read_all_rows(MYSQL_STMT *stmt)
{ {
if (stmt->fields[i].flags & ZEROFILL_FLAG) if (stmt->fields[i].flags & ZEROFILL_FLAG)
{ {
size_t len= MAX(stmt->fields[i].length, mysql_ps_fetch_functions[stmt->fields[i].type].max_len); /* The -1 is because a ZEROFILL:ed field is always unsigned */
size_t len= MAX(stmt->fields[i].length, mysql_ps_fetch_functions[stmt->fields[i].type].max_len-1);
if (len > stmt->fields[i].max_length) if (len > stmt->fields[i].max_length)
stmt->fields[i].max_length= (unsigned long)len; stmt->fields[i].max_length= (unsigned long)len;
} }
else if (!stmt->fields[i].max_length) else if (!stmt->fields[i].max_length)
{ {
stmt->fields[i].max_length= mysql_ps_fetch_functions[stmt->fields[i].type].max_len; stmt->fields[i].max_length= mysql_ps_fetch_functions[stmt->fields[i].type].max_len;
if (stmt->fields[i].flags & UNSIGNED_FLAG &&
stmt->fields[i].type != MYSQL_TYPE_INT24 &&
stmt->fields[i].type != MYSQL_TYPE_LONGLONG)
{
/*
Unsigned integers has one character less than signed integers
as '-' is counted as part of max_length
*/
stmt->fields[i].max_length--;
}
} }
cp+= mysql_ps_fetch_functions[stmt->fields[i].type].pack_len; cp+= mysql_ps_fetch_functions[stmt->fields[i].type].pack_len;
} }