From 225e1d6cfc83fc315f6876b8dae907d3c0f225e3 Mon Sep 17 00:00:00 2001 From: Daniel Bartholomew Date: Tue, 12 Nov 2024 13:15:53 -0500 Subject: [PATCH 1/4] bump the VERSION --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2a189201..7bdf600b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,7 +37,7 @@ SET(CC_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) SET(CPACK_PACKAGE_VERSION_MAJOR 3) SET(CPACK_PACKAGE_VERSION_MINOR 1) -SET(CPACK_PACKAGE_VERSION_PATCH 26) +SET(CPACK_PACKAGE_VERSION_PATCH 27) SET(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") MATH(EXPR MARIADB_PACKAGE_VERSION_ID "${CPACK_PACKAGE_VERSION_MAJOR} * 10000 + ${CPACK_PACKAGE_VERSION_MINOR} * 100 + From 55e3b63c343207371283a749508e0df4dfadd249 Mon Sep 17 00:00:00 2001 From: Georg Richter Date: Fri, 15 Nov 2024 17:41:23 +0100 Subject: [PATCH 2/4] CONPY-739: prepared statement support AUTO_SEC_PART_DIGITS FROM_UNIXTIME() function always returns AUTO_SEC_PART_DIGITS (value=39). In case the microsecond value was set in MYSQL_TIME, the decimal part should be SEC_PART_DIGITS (=6). --- libmariadb/ma_stmt_codec.c | 33 +++++++++++------------ unittest/libmariadb/ps_bugs.c | 49 +++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 18 deletions(-) diff --git a/libmariadb/ma_stmt_codec.c b/libmariadb/ma_stmt_codec.c index afb46b25..ab3ec1ed 100644 --- a/libmariadb/ma_stmt_codec.c +++ b/libmariadb/ma_stmt_codec.c @@ -50,6 +50,7 @@ #include "mysql.h" #include /* ceil() */ #include +#include #ifdef WIN32 #include @@ -1145,29 +1146,25 @@ void ps_fetch_datetime(MYSQL_BIND *r_param, const MYSQL_FIELD * field, length= sprintf(dtbuffer, "%04u-%02u-%02u", tm.year, tm.month, tm.day); break; case MYSQL_TYPE_TIME: - length= sprintf(dtbuffer, "%s%02u:%02u:%02u", (tm.neg ? "-" : ""), tm.hour, tm.minute, tm.second); - if (field->decimals && field->decimals <= 6) + if (field->decimals && (field->decimals <= SEC_PART_DIGITS || + (field->decimals == AUTO_SEC_PART_DIGITS && tm.second_part))) { - char ms[8]; - sprintf(ms, ".%06lu", tm.second_part); - if (field->decimals < 6) - ms[field->decimals + 1]= 0; - length+= strlen(ms); - strcat(dtbuffer, ms); - } + uint8_t decimals= (field->decimals == AUTO_SEC_PART_DIGITS) ? SEC_PART_DIGITS : field->decimals; + length= sprintf(dtbuffer, "%s%02u:%02u:%02u.%0*u", (tm.neg ? "-" : ""), tm.hour, tm.minute, tm.second, + decimals, (uint32_t)(tm.second_part / pow(10, 6 - decimals))); + } else + length= sprintf(dtbuffer, "%s%02u:%02u:%02u", (tm.neg ? "-" : ""), tm.hour, tm.minute, tm.second); break; case MYSQL_TYPE_DATETIME: case MYSQL_TYPE_TIMESTAMP: - length= sprintf(dtbuffer, "%04u-%02u-%02u %02u:%02u:%02u", tm.year, tm.month, tm.day, tm.hour, tm.minute, tm.second); - if (field->decimals && field->decimals <= 6) + if (field->decimals && (field->decimals <= SEC_PART_DIGITS || + (field->decimals == AUTO_SEC_PART_DIGITS && tm.second_part))) { - char ms[8]; - sprintf(ms, ".%06lu", tm.second_part); - if (field->decimals < 6) - ms[field->decimals + 1]= 0; - length+= strlen(ms); - strcat(dtbuffer, ms); - } + uint8_t decimals= (field->decimals == AUTO_SEC_PART_DIGITS) ? SEC_PART_DIGITS : field->decimals; + length= sprintf(dtbuffer, "%04u-%02u-%02u %02u:%02u:%02u.%0*u", tm.year, tm.month, tm.day, tm.hour, tm.minute, tm.second, + decimals, (uint32_t)(tm.second_part / pow(10, 6 - decimals))); + } else + length= sprintf(dtbuffer, "%04u-%02u-%02u %02u:%02u:%02u", tm.year, tm.month, tm.day, tm.hour, tm.minute, tm.second); break; default: dtbuffer[0]= 0; diff --git a/unittest/libmariadb/ps_bugs.c b/unittest/libmariadb/ps_bugs.c index 91de2ee3..f193e3af 100644 --- a/unittest/libmariadb/ps_bugs.c +++ b/unittest/libmariadb/ps_bugs.c @@ -5572,7 +5572,56 @@ end: return ret; } +static int test_conc739(MYSQL *mysql) +{ + MYSQL_STMT *stmt; + int rc; + MYSQL_BIND bind[2]; + char buffer[2][100]; + MYSQL_ROW row; + MYSQL_RES *result; + uint8 i; + + rc= mysql_query(mysql, "SELECT FROM_UNIXTIME('1922.1'), FROM_UNIXTIME('1922.0')"); + check_mysql_rc(rc, mysql); + result= mysql_store_result(mysql); + row= mysql_fetch_row(result); + + stmt= mysql_stmt_init(mysql); + + rc= mysql_stmt_prepare(stmt, SL("SELECT FROM_UNIXTIME('1922.1'), FROM_UNIXTIME('1922.0')")); + check_stmt_rc(rc, stmt); + + memset(bind, 0, 2 * sizeof(MYSQL_BIND)); + for (i=0; i < 2; i++) + { + bind[i].buffer_type= MYSQL_TYPE_STRING; + bind[i].buffer= &buffer[i]; + bind[i].buffer_length= 100; + } + + rc= mysql_stmt_execute(stmt); + check_stmt_rc(rc, stmt); + + rc= mysql_stmt_bind_result(stmt, bind); + check_stmt_rc(rc, stmt); + + rc= mysql_stmt_fetch(stmt); + check_stmt_rc(rc, stmt); + + for (i=0; i < 2; i++) + { + diag("text: %s binary: %s", row[i], buffer[i]); + FAIL_IF(strcmp(buffer[i], row[i]), "Different results (text/binary protocol)"); + } + + mysql_stmt_close(stmt); + mysql_free_result(result); + return OK; +} + struct my_tests_st my_tests[] = { + {"test_conc739", test_conc739, TEST_CONNECTION_DEFAULT, 0, NULL, NULL}, {"test_conc633", test_conc633, TEST_CONNECTION_DEFAULT, 0, NULL, NULL}, {"test_conc627", test_conc627, TEST_CONNECTION_DEFAULT, 0, NULL, NULL}, {"test_mdev19838", test_mdev19838, TEST_CONNECTION_DEFAULT, 0, NULL, NULL}, From 1a2ed3f67af698b394b2faed069b49d4f409a155 Mon Sep 17 00:00:00 2001 From: Georg Richter Date: Wed, 20 Nov 2024 14:42:04 +0100 Subject: [PATCH 3/4] CONC-710: Remove UDF declarations Removed UDF declarations from mariadb_com.h --- include/mariadb_com.h | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/include/mariadb_com.h b/include/mariadb_com.h index 340568d6..57e48925 100644 --- a/include/mariadb_com.h +++ b/include/mariadb_com.h @@ -404,30 +404,6 @@ struct rand_struct { double max_value_dbl; }; - /* The following is for user defined functions */ - -enum Item_result {STRING_RESULT,REAL_RESULT,INT_RESULT,ROW_RESULT,DECIMAL_RESULT}; - -typedef struct st_udf_args -{ - unsigned int arg_count; /* Number of arguments */ - enum Item_result *arg_type; /* Pointer to item_results */ - char **args; /* Pointer to argument */ - unsigned long *lengths; /* Length of string arguments */ - char *maybe_null; /* Set to 1 for all maybe_null args */ -} UDF_ARGS; - - /* This holds information about the result */ - -typedef struct st_udf_init -{ - my_bool maybe_null; /* 1 if function can return NULL */ - unsigned int decimals; /* for real functions */ - unsigned int max_length; /* For string functions */ - char *ptr; /* free pointer for function data */ - my_bool const_item; /* 0 if result is independent of arguments */ -} UDF_INIT; - /* Connection types */ #define MARIADB_CONNECTION_UNIXSOCKET 0 #define MARIADB_CONNECTION_TCP 1 From a13f65c4c6225902f62b8a88461e42b661a25dbc Mon Sep 17 00:00:00 2001 From: Georg Richter Date: Wed, 27 Nov 2024 07:52:29 +0100 Subject: [PATCH 4/4] Fix CMake deprecation warning Minimum required CMake version is now 3.5.1 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7bdf600b..ba7e6509 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ # This is the LGPL libmariadb project. -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12 FATAL_ERROR) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5.1 FATAL_ERROR) INCLUDE(CheckFunctionExists) INCLUDE(FeatureSummary) IF(COMMAND CMAKE_POLICY)