Below is the list of changes that have just been committed into a local
5.0 repository of schwenke. When schwenke does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.2182 06/06/19 20:05:44 schwenke@stripped +2 -0
bug #20152: mysql_stmt_execute() overwrites parameter buffers
When using a parameter bind MYSQL_TYPE_DATE in a prepared statement,
the time part of the MYSQL_TIME buffer was written to zero in
mysql_stmt_execute(). The param_store_date() function in libmysql.c
worked directly on the provided buffer.
Changed to use a copy of the buffer.
tests/mysql_client_test.c
1.187 06/06/19 20:05:37 schwenke@stripped +56 -1
added test for bug#20152
libmysql/libmysql.c
1.244 06/06/19 20:05:37 schwenke@stripped +3 -4
fix for bug #20152
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: schwenke
# Host: lmy003.xl.local
# Root: /home/schwenke/Work/MySQL/bk-internal-tree/mysql-5.0-work
--- 1.243/libmysql/libmysql.c 2006-05-15 18:07:52 +02:00
+++ 1.244/libmysql/libmysql.c 2006-06-19 20:05:37 +02:00
@@ -2391,10 +2391,9 @@
static void store_param_date(NET *net, MYSQL_BIND *param)
{
- MYSQL_TIME *tm= (MYSQL_TIME *) param->buffer;
- tm->hour= tm->minute= tm->second= 0;
- tm->second_part= 0;
- net_store_datetime(net, tm);
+ MYSQL_TIME tm= *((MYSQL_TIME *) param->buffer);
+ tm.hour= tm.minute= tm.second= tm.second_part= 0;
+ net_store_datetime(net, &tm);
}
static void store_param_datetime(NET *net, MYSQL_BIND *param)
--- 1.186/tests/mysql_client_test.c 2006-06-16 13:43:36 +02:00
+++ 1.187/tests/mysql_client_test.c 2006-06-19 20:05:37 +02:00
@@ -14929,7 +14929,61 @@
rc= mysql_query(mysql, "drop table t1");
myquery(rc);
-}/*
+}
+
+
+/*
+ Bug#20152: mysql_stmt_execute() writes to MYSQL_TYPE_DATE buffer
+ */
+static void test_bug20152()
+{
+ MYSQL_BIND bind[1];
+ MYSQL_STMT *stmt;
+ MYSQL_TIME tm;
+ int rc;
+ const char *query= "INSERT INTO t1 (f1) VALUES (?)";
+
+ myheader("test_bug20152");
+
+ memset(bind, 0, sizeof(bind));
+ bind[0].buffer_type= MYSQL_TYPE_DATE;
+ bind[0].buffer= (void*)&tm;
+
+ tm.year = 2006;
+ tm.month = 6;
+ tm.day = 18;
+ tm.hour = 14;
+ tm.minute = 9;
+ tm.second = 42;
+
+ rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1");
+ myquery(rc);
+ rc= mysql_query(mysql, "CREATE TABLE t1 (f1 DATE)");
+ myquery(rc);
+
+ stmt= mysql_stmt_init(mysql);
+ rc= mysql_stmt_prepare(stmt, query, strlen(query));
+ check_execute(stmt, rc);
+ rc= mysql_stmt_bind_param(stmt, bind);
+ check_execute(stmt, rc);
+ rc= mysql_stmt_execute(stmt);
+ check_execute(stmt, rc);
+ rc= mysql_stmt_close(stmt);
+ check_execute(stmt, rc);
+ rc= mysql_query(mysql, "DROP TABLE t1");
+ myquery(rc);
+
+ if (tm.hour == 14 && tm.minute == 9 && tm.second == 42) {
+ if (!opt_silent)
+ printf("OK!");
+ } else {
+ printf("[14:09:42] != [%02d:%02d:%02d]\n", tm.hour, tm.minute, tm.second);
+ DIE_UNLESS(0==1);
+ }
+}
+
+
+/*
Read and parse arguments and MySQL options from my.cnf
*/
@@ -15195,6 +15249,7 @@
{ "test_bug15613", test_bug15613 },
{ "test_bug14169", test_bug14169 },
{ "test_bug17667", test_bug17667 },
+ { "test_bug20152", test_bug20152 },
{ 0, 0 }
};
| Thread |
|---|
| • bk commit into 5.0 tree (schwenke:1.2182) BUG#20152 | axel | 19 Jun |