summaryrefslogtreecommitdiff
path: root/sql/sql_prepare.cc
diff options
context:
space:
mode:
authorDavi Arnaut <Davi.Arnaut@Sun.COM>2010-06-28 17:29:19 -0300
committerDavi Arnaut <Davi.Arnaut@Sun.COM>2010-06-28 17:29:19 -0300
commit407b68bf99bbd4321e675259335f9266f0f5fe49 (patch)
tree20ff7734a321bf3d89c39dbe2e2acbd2b480ed73 /sql/sql_prepare.cc
parent715bac92ba447df802d2f144c168cbeb6f2950be (diff)
parente42d90850c6599a1ec5800cc251a345cc34b92b0 (diff)
downloadmariadb-git-407b68bf99bbd4321e675259335f9266f0f5fe49.tar.gz
Merge of mysql-5.0-bugteam into mysql-5.1-bugteam.
Diffstat (limited to 'sql/sql_prepare.cc')
-rw-r--r--sql/sql_prepare.cc29
1 files changed, 29 insertions, 0 deletions
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index a4241772311..041d9f7c30b 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -702,6 +702,19 @@ static void setup_one_conversion_function(THD *thd, Item_param *param,
}
#ifndef EMBEDDED_LIBRARY
+
+/**
+ Check whether this parameter data type is compatible with long data.
+ Used to detect whether a long data stream has been supplied to a
+ incompatible data type.
+*/
+inline bool is_param_long_data_type(Item_param *param)
+{
+ return ((param->param_type >= MYSQL_TYPE_TINY_BLOB) &&
+ (param->param_type <= MYSQL_TYPE_STRING));
+}
+
+
/**
Routines to assign parameters from data supplied by the client.
@@ -771,6 +784,14 @@ static bool insert_params_with_log(Prepared_statement *stmt, uchar *null_array,
DBUG_RETURN(1);
}
}
+ /*
+ A long data stream was supplied for this parameter marker.
+ This was done after prepare, prior to providing a placeholder
+ type (the types are supplied at execute). Check that the
+ supplied type of placeholder can accept a data stream.
+ */
+ else if (!is_param_long_data_type(param))
+ DBUG_RETURN(1);
res= param->query_val_str(&str);
if (param->convert_str_value(thd))
DBUG_RETURN(1); /* out of memory */
@@ -809,6 +830,14 @@ static bool insert_params(Prepared_statement *stmt, uchar *null_array,
DBUG_RETURN(1);
}
}
+ /*
+ A long data stream was supplied for this parameter marker.
+ This was done after prepare, prior to providing a placeholder
+ type (the types are supplied at execute). Check that the
+ supplied type of placeholder can accept a data stream.
+ */
+ else if (is_param_long_data_type(param))
+ DBUG_RETURN(1);
if (param->convert_str_value(stmt->thd))
DBUG_RETURN(1); /* out of memory */
}