| Bug #6049 | Loss of sign when using prepared statements and negative time/date values | ||
|---|---|---|---|
| Submitted: | 12 Oct 2004 17:33 | Modified: | 20 Oct 2004 14:40 |
| Reporter: | Georg Richter | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Server | Severity: | S2 (Serious) |
| Version: | >= 4.1 | OS: | Linux (Linux) |
| Assigned to: | Konstantin Osipov | CPU Architecture: | Any |
[12 Oct 2004 20:22]
MySQL Verification Team
Verified on latest 4.1 source tree.
[15 Oct 2004 20:14]
Konstantin Osipov
Subject: bk commit - 4.1 tree (konstantin:1.2107) BUG#6049 ChangeSet 1.2107 04/10/16 00:12:59 konstantin@mysql.com +10 -0 A fix and test case for Bug#6049 "Loss of sign when using prepared statements and negative time/date values". The bug was in wrong sprintf format used in the client library. The fix moves TIME -> string conversion functions to sql-common and utilized them in the client library.
[20 Oct 2004 14:40]
Konstantin Osipov
Fixed in 4.1.7
[28 Mar 2006 19:34]
Florian Rissner
it's here again: a regular statement return's the expected result; a prepared statement returns the absolut timevalue (e.g. without Minus-Sign) tested with 5.0.16 and max-4.1.13 used a modified mysqlconnector from mysql-connector-java-3.1.12.zip
[28 Mar 2006 19:44]
Konstantin Osipov
Could you please provide a reproducibe test case for the problem? Please open a separate bug report. It's very unlikely that the original problem re-occured: the patch contained a test case which is now a part of our daily test suite.

Description: When using negative time values, e.g. MAKETIME(-25,12,12) prepared statements always deliver positive values. Output: Result from query: -25:12:12 Result from prepared statement: 25:12:12 How to repeat: #include <stdio.h> #include <mysql.h> int main () { MYSQL *mysql = mysql_init(NULL); MYSQL_STMT *stmt; MYSQL_BIND bind[1]; MYSQL_RES *res; MYSQL_ROW row; char query[500]; char buffer[100]; int length; if (!mysql_real_connect(mysql, "localhost", "", "", "test", 0, NULL, 0)) { printf("Can't connect! Error: %s\n", mysql_error(mysql)); return 1; } stmt = mysql_stmt_init(mysql); strcpy(query, "SELECT MAKETIME(-25,12,12)"); mysql_query(mysql, query); res = mysql_store_result(mysql); row = mysql_fetch_row(res); printf("Result from query: %s\n", row[0]); mysql_free_result(res); if (mysql_stmt_prepare(stmt, query, strlen(query))) { printf("Error in mysql_stmt_prepare: %s\n", mysql_error(mysql)); return 1; } if (mysql_stmt_execute(stmt)) { printf("Error in mysql_stmt_execute: %s\n", mysql_stmt_error(stmt)); return 1; } bind[0].buffer_type = MYSQL_TYPE_STRING; bind[0].buffer = &buffer; bind[0].buffer_length = 100; bind[0].length = &length; bind[0].is_unsigned = 0; mysql_stmt_bind_result(stmt, bind); mysql_stmt_fetch(stmt); printf("Result from prepared statement: %s\n", buffer); mysql_stmt_close(stmt); mysql_close(mysql); }