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

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).
This commit is contained in:
Georg Richter
2024-11-15 17:41:23 +01:00
parent 225e1d6cfc
commit 55e3b63c34
2 changed files with 64 additions and 18 deletions

View File

@@ -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},