You've already forked mariadb-connector-c
mirror of
https://github.com/mariadb-corporation/mariadb-connector-c.git
synced 2025-08-07 02:42:49 +03:00
Merge branch '3.1' into 3.3
This commit is contained in:
@@ -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)
|
||||
IF(COMMAND CMAKE_POLICY)
|
||||
SET(NEW_POLICIES CMP0003 CMP0022 CMP0023 CMP0057 CMP0077 CMP0069 CMP0075)
|
||||
|
@@ -421,30 +421,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
|
||||
|
@@ -50,6 +50,7 @@
|
||||
#include "mysql.h"
|
||||
#include <math.h> /* ceil() */
|
||||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <malloc.h>
|
||||
@@ -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;
|
||||
|
@@ -5803,12 +5803,60 @@ static int test_conc702(MYSQL *ma)
|
||||
mysql_stmt_close(stmt2);
|
||||
|
||||
mysql_stmt_close(stmt);
|
||||
return OK;
|
||||
}
|
||||
|
||||
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_conc702", test_conc702, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||
{"test_conc739", test_conc739, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||
{"test_conc633", test_conc633, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||
{"test_conc623", test_conc623, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||
{"test_conc627", test_conc627, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||
|
Reference in New Issue
Block a user