diff options
author | Alexander Nozdrin <alexander.nozdrin@oracle.com> | 2010-11-13 18:05:02 +0300 |
---|---|---|
committer | Alexander Nozdrin <alexander.nozdrin@oracle.com> | 2010-11-13 18:05:02 +0300 |
commit | 3fa437cf4061c20f2995e859b89a6898d3b646b4 (patch) | |
tree | 62acd4e216e7befb8d3b54c2689173b961a839c4 /sql/sql_prepare.cc | |
parent | b4d5039e717bc02a94a42f5511e7077404a31d72 (diff) | |
download | mariadb-git-3fa437cf4061c20f2995e859b89a6898d3b646b4.tar.gz |
Fix for Bug#56934 (mysql_stmt_fetch() incorrectly fills MYSQL_TIME
structure buffer).
This is a follow-up for WL#4435. The bug actually existed not only
MYSQL_TYPE_DATETIME type. The problem was that Item_param::set_value()
was written in an assumption that it's working with expressions, i.e.
with basic data types.
There are two different quick fixes here:
a) Change Item_param::make_field() -- remove setting of
Send_field::length, Send_field::charsetnr, Send_field::flags and
Send_field::type.
That would lead to marshalling all data using basic types to the client
(MYSQL_TYPE_LONGLONG, MYSQL_TYPE_DOUBLE, MYSQL_TYPE_STRING and
MYSQL_TYPE_NEWDECIMAL). In particular, that means, DATETIME would be
sent as MYSQL_TYPE_STRING, TINYINT -- as MYSQL_TYPE_LONGLONG, etc.
That could be Ok for the client, because the client library does
reverse conversion automatically (the client program would see DATETIME
as MYSQL_TIME object). However, there is a problem with metadata --
the metadata would be wrong (misleading): it would say that DATETIME is
marshaled as MYSQL_TYPE_DATETIME, not as MYSQL_TYPE_STRING.
b) Set Item_param::param_type properly to actual underlying field type.
That would lead to double conversion inside the server: for example,
MYSQL_TIME-object would be converted into STRING-object
(in Item_param::set_value()), and then converted back to MYSQL_TIME-object
(in Item_param::send()).
The data however would be marshalled more properly, and also metadata would
be correct.
This patch implements b).
There is also a possibility to avoid double conversion either by clonning
the data field, or by storing a reference to it and using it on Item::send()
time. That requires more work and might be done later.
Diffstat (limited to 'sql/sql_prepare.cc')
-rw-r--r-- | sql/sql_prepare.cc | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index fcbf2c48896..6a84d050d7f 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1185,7 +1185,7 @@ static bool insert_params_from_vars_with_log(Prepared_statement *stmt, uint32 length= 0; THD *thd= stmt->thd; - DBUG_ENTER("insert_params_from_vars"); + DBUG_ENTER("insert_params_from_vars_with_log"); if (query->copy(stmt->query(), stmt->query_length(), default_charset_info)) DBUG_RETURN(1); |