Skip to content

Commit

Permalink
Merge branch '3.2' into 3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
9EOR9 committed Oct 8, 2021
2 parents e142c3b + 0bf84c0 commit 52934a1
Show file tree
Hide file tree
Showing 15 changed files with 244 additions and 38 deletions.
20 changes: 20 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,26 @@ ELSE()
SET(MARIADB_CLIENT_VERSION_PATCH "5")
SET(MARIADB_CLIENT_VERSION_EXTRA "")
ENDIF()

IF(WIN32)
# version in resource files need to be consistent
# with server's , so that MSI minor upgrade work.
# if this is not a subproject build, C/C version is used.
FOREACH(v MAJOR MINOR PATCH TINY)
IF(DEFINED ${v}_VERSION)
SET(${v}_FILE_VERSION "${${v}_VERSION}")
ELSEIF(DEFINED CPACK_PACKAGE_VERSION_${v})
SET(${v}_FILE_VERSION "${CPACK_PACKAGE_VERSION_${v}}")
ELSE()
SET(${v}_FILE_VERSION "0")
ENDIF()
IF(NOT ${v}_FILE_VERSION MATCHES "^[0-9]+$")
MESSAGE(FATAL_ERROR
"${v}_FILE_VERSION is not numeric - '${${v}_FILE_VERSION}'")
ENDIF()
ENDFOREACH()
ENDIF()

SET(MARIADB_CLIENT_VERSION "${MARIADB_CLIENT_VERSION_MAJOR}.${MARIADB_CLIENT_VERSION_MINOR}.${MARIADB_CLIENT_VERSION_PATCH}${MARIADB_CLIENT_VERSION_EXTRA}")
SET(MARIADB_BASE_VERSION "mariadb-${MARIADB_CLIENT_VERSION_MAJOR}.${MARIADB_CLIENT_VERSION_MINOR}")
MATH(EXPR MARIADB_VERSION_ID "${MARIADB_CLIENT_VERSION_MAJOR} * 10000 +
Expand Down
11 changes: 0 additions & 11 deletions cmake/version_info.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,6 @@ MACRO(SET_VERSION_INFO)
STRING(REPLACE "FILE_DESCRIPTION:" "" FILE_DESCRIPTION ${PROPERTY})
ENDIF()
ENDFOREACH()
# Connector can be packaged with server, so set the "file version"
# to the server version
# In this case, numeric file version should be consistent with server
# Only this way MSI minor upgrade can work.
# The product version string will still refer to Connectors own version
IF((NOT DEFINED MAJOR_VERSION) OR (NOT DEFINED MINOR_VERSION) OR (NOT DEFINED PATCH_VERSION) OR (NOT DEFINED TINY_VERSION))
SET(MAJOR_VERSION ${CPACK_PACKAGE_VERSION_MAJOR})
SET(MINOR_VERSION ${CPACK_PACKAGE_VERSION_MINOR})
SET(PATCH_VERSION ${CPACK_PACKAGE_VERSION_PATCH})
SET(TINY_VERSION ${FILE_VERSION})
ENDIF()
CONFIGURE_FILE(${CC_SOURCE_DIR}/win/resource.rc.in
${CC_BINARY_DIR}/win/${TARGET}.rc)
SET(${TARGET}_RC ${CC_BINARY_DIR}/win/${TARGET}.rc)
Expand Down
2 changes: 1 addition & 1 deletion include/mariadb_com.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

#define NAME_CHAR_LEN 64
#define NAME_LEN 256 /* Field/table name length */
#define HOSTNAME_LENGTH 60
#define HOSTNAME_LENGTH 255
#define SYSTEM_MB_MAX_CHAR_LENGTH 4
#define USERNAME_CHAR_LENGTH 128
#define USERNAME_LENGTH (USERNAME_CHAR_LENGTH * SYSTEM_MB_MAX_CHAR_LENGTH)
Expand Down
3 changes: 3 additions & 0 deletions libmariadb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,9 @@ ELSE()
IF(NOT CMAKE_SYSTEM_NAME MATCHES AIX)
ADD_DEFINITIONS(-DLIBICONV_PLUG)
ENDIF()
IF(APPLE)
ADD_DEFINITIONS(-Wno-deprecated-declarations)
ENDIF()
ENDIF()

IF(ZLIB_FOUND AND WITH_EXTERNAL_ZLIB)
Expand Down
14 changes: 4 additions & 10 deletions libmariadb/ma_client_plugin.c.in
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ struct st_mysql_client_plugin * STDCALL
mysql_client_register_plugin(MYSQL *mysql,
struct st_mysql_client_plugin *plugin)
{
struct st_mysql_client_plugin *found_plugin= NULL;
va_list unused;
LINT_INIT_STRUCT(unused);

Expand All @@ -339,18 +340,11 @@ mysql_client_register_plugin(MYSQL *mysql,
pthread_mutex_lock(&LOCK_load_client_plugin);

/* make sure the plugin wasn't loaded meanwhile */
if (find_plugin(plugin->name, plugin->type))
{
my_set_error(mysql, CR_AUTH_PLUGIN_CANNOT_LOAD,
SQLSTATE_UNKNOWN, ER(CR_AUTH_PLUGIN_CANNOT_LOAD),
plugin->name, "it is already loaded");
plugin= NULL;
}
else
plugin= add_plugin(mysql, plugin, 0, 0, unused);
if (!(found_plugin= find_plugin(plugin->name, plugin->type)))
found_plugin= add_plugin(mysql, plugin, 0, 0, unused);

pthread_mutex_unlock(&LOCK_load_client_plugin);
return plugin;
return found_plugin;
}


Expand Down
6 changes: 3 additions & 3 deletions libmariadb/ma_stmt_codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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].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].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].pack_len = 2;
Expand All @@ -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].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].pack_len= 8;
Expand Down
2 changes: 1 addition & 1 deletion libmariadb/mariadb_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -4179,7 +4179,7 @@ my_bool mariadb_get_infov(MYSQL *mysql, enum mariadb_value value, void *arg, ...
*((char **)arg)= (char *)ma_pvio_tls_cipher(mysql->net.pvio->ctls);
else
#endif
goto error;
*((char **)arg)= NULL;
break;
case MARIADB_CLIENT_ERRORS:
*((char ***)arg)= (char **)client_errors;
Expand Down
26 changes: 23 additions & 3 deletions libmariadb/mariadb_stmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,24 @@ int mthd_stmt_read_all_rows(MYSQL_STMT *stmt)
{
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)
stmt->fields[i].max_length= (unsigned long)len;
}
else if (!stmt->fields[i].max_length)
{
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;
}
Expand Down Expand Up @@ -798,7 +809,7 @@ unsigned char* ma_stmt_execute_generate_simple_request(MYSQL_STMT *stmt, size_t
case MYSQL_TYPE_ENUM:
case MYSQL_TYPE_BIT:
case MYSQL_TYPE_SET:
size+= 5; /* max 8 bytes for size */
size+= 9; /* max 8 bytes for size */
size+= (size_t)ma_get_length(stmt, i, 0);
break;
default:
Expand Down Expand Up @@ -1634,6 +1645,7 @@ my_bool mthd_stmt_read_prepare_response(MYSQL_STMT *stmt)
if (stmt->prebind_params != stmt->param_count)
{
SET_CLIENT_STMT_ERROR(stmt, CR_INVALID_PARAMETER_NO, SQLSTATE_UNKNOWN, 0);
stmt->param_count= stmt->prebind_params;
return 1;
}
} else {
Expand Down Expand Up @@ -1920,6 +1932,13 @@ int mthd_stmt_read_execute_response(MYSQL_STMT *stmt)
{
SET_CLIENT_STMT_ERROR(stmt, mysql->net.last_errno, mysql->net.sqlstate,
mysql->net.last_error);
/* if mariadb_stmt_execute_direct was used, we need to send the number
of parameters to the specified prebinded value to prevent possible
memory overrun */
if (stmt->prebind_params)
{
stmt->param_count= stmt->prebind_params;
}
stmt->state= MYSQL_STMT_PREPARED;
return(1);
}
Expand Down Expand Up @@ -1994,7 +2013,8 @@ int mthd_stmt_read_execute_response(MYSQL_STMT *stmt)
/* Only cursor read */
stmt->default_rset_handler = _mysql_stmt_use_result;

} else if (stmt->flags & CURSOR_TYPE_READ_ONLY)
} else if (stmt->flags & CURSOR_TYPE_READ_ONLY &&
!(stmt->upsert_status.server_status & SERVER_MORE_RESULTS_EXIST))
{
/*
We have asked for CURSOR but got no cursor, because the condition
Expand Down
1 change: 1 addition & 0 deletions plugins/auth/my_auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ static int native_password_auth_client(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql)
if (mysql && mysql->passwd[0])
{
char scrambled[SCRAMBLE_LENGTH + 1];
memset(scrambled, 0, SCRAMBLE_LENGTH + 1);
ma_scramble_41((uchar *)scrambled, (char*)pkt, mysql->passwd);
if (vio->write_packet(vio, (uchar*)scrambled, SCRAMBLE_LENGTH))
return CR_ERROR;
Expand Down
2 changes: 1 addition & 1 deletion unittest/libmariadb/async.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static int test_async(MYSQL *mysql)
if (type > MARIADB_CONNECTION_TCP)
{
skip_async= 1;
diag("Asnyc IO not supported");
diag("Async IO not supported");
}
return OK;
}
Expand Down
5 changes: 2 additions & 3 deletions unittest/libmariadb/bulk1.c
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ static int bulk_null_null(MYSQL *mysql)
rc= mysql_stmt_prepare(stmt, "INSERT INTO bulk_null VALUES (?,?,?,?,?)", -1);
check_stmt_rc(rc, stmt);

memset(bind, 0, sizeof(MYSQL_BIND)*2);
memset(bind, 0, sizeof(MYSQL_BIND)*5);

rc= mysql_stmt_attr_set(stmt, STMT_ATTR_ARRAY_SIZE, &array_size);
check_stmt_rc(rc, stmt);
Expand Down Expand Up @@ -1011,15 +1011,14 @@ static int test_mdev16593(MYSQL *mysql)
diag("waiting for server fix");
return SKIP;

memset(&bind, 0, 2 * sizeof(MYSQL_BIND));
for (i=0; i < 3; i++)
{
MYSQL_RES *res;
MYSQL_ROW row;
MYSQL_STMT *stmt= mysql_stmt_init(mysql);
rc= mysql_query(mysql, "CREATE OR REPLACE TABLE t1 (a int not null auto_increment primary key, b int)");
check_mysql_rc(rc, mysql);

memset(&bind, 0, sizeof(MYSQL_BIND));
switch (i) {
case 0:
bind[0].buffer_type= MYSQL_TYPE_LONG;
Expand Down
11 changes: 11 additions & 0 deletions unittest/libmariadb/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1064,6 +1064,10 @@ static int test_read_timeout(MYSQL *unused __attribute__((unused)))
return OK;
}

#ifndef __has_feature
# define __has_feature(x) 0
#endif
#if !__has_feature(memory_sanitizer)
#ifdef HAVE_REMOTEIO
void *remote_plugin;
static int test_remote1(MYSQL *mysql)
Expand Down Expand Up @@ -1131,6 +1135,7 @@ static int test_remote2(MYSQL *my)
return OK;
}
#endif
#endif

#ifndef _WIN32
static int test_mdev12965(MYSQL *unused __attribute__((unused)))
Expand Down Expand Up @@ -1499,6 +1504,7 @@ static int test_sslenforce(MYSQL *unused __attribute__((unused)))
}
#endif

#if !__has_feature(memory_sanitizer)
static int test_conc457(MYSQL *mysql)
{
MYSQL_RES *result;
Expand All @@ -1511,6 +1517,7 @@ static int test_conc457(MYSQL *mysql)
mysql_free_result(result);
return OK;
}
#endif

static int test_conc458(MYSQL *my __attribute__((unused)))
{
Expand Down Expand Up @@ -1618,7 +1625,9 @@ struct my_tests_st my_tests[] = {
{"test_ext_field_attr", test_ext_field_attr, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
{"test_conc533", test_conc533, TEST_CONNECTION_NEW, 0, NULL, NULL},
{"test_conc458", test_conc458, TEST_CONNECTION_NONE, 0, NULL, NULL},
#if !__has_feature(memory_sanitizer)
{"test_conc457", test_conc457, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
#endif
{"test_conc384", test_conc384, TEST_CONNECTION_NONE, 0, NULL, NULL},
#ifndef _WIN32
{"test_mdev12965", test_mdev12965, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
Expand All @@ -1629,9 +1638,11 @@ struct my_tests_st my_tests[] = {
{"test_server_status", test_server_status, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
{"test_read_timeout", test_read_timeout, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
{"test_zerofill", test_zerofill, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
#if !__has_feature(memory_sanitizer)
#ifdef HAVE_REMOTEIO
{"test_remote1", test_remote1, TEST_CONNECTION_NEW, 0, NULL, NULL},
{"test_remote2", test_remote2, TEST_CONNECTION_NEW, 0, NULL, NULL},
#endif
#endif
{"test_get_info", test_get_info, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
{"test_conc117", test_conc117, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
Expand Down
Loading

0 comments on commit 52934a1

Please sign in to comment.