summaryrefslogtreecommitdiff
path: root/sql/protocol.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/protocol.cc')
-rw-r--r--sql/protocol.cc40
1 files changed, 40 insertions, 0 deletions
diff --git a/sql/protocol.cc b/sql/protocol.cc
index d537f9cf829..7c56bb3fc7a 100644
--- a/sql/protocol.cc
+++ b/sql/protocol.cc
@@ -735,6 +735,7 @@ bool Protocol_simple::store(const char *from, uint length,
DBUG_ASSERT(field_types == 0 ||
field_types[field_pos] == MYSQL_TYPE_DECIMAL ||
field_types[field_pos] == MYSQL_TYPE_BIT ||
+ field_types[field_pos] == MYSQL_TYPE_NEWDECIMAL ||
(field_types[field_pos] >= MYSQL_TYPE_ENUM &&
field_types[field_pos] <= MYSQL_TYPE_GEOMETRY));
field_pos++;
@@ -751,6 +752,7 @@ bool Protocol_simple::store(const char *from, uint length,
DBUG_ASSERT(field_types == 0 ||
field_types[field_pos] == MYSQL_TYPE_DECIMAL ||
field_types[field_pos] == MYSQL_TYPE_BIT ||
+ field_types[field_pos] == MYSQL_TYPE_NEWDECIMAL ||
(field_types[field_pos] >= MYSQL_TYPE_ENUM &&
field_types[field_pos] <= MYSQL_TYPE_GEOMETRY));
field_pos++;
@@ -813,6 +815,26 @@ bool Protocol_simple::store_longlong(longlong from, bool unsigned_flag)
}
+bool Protocol_simple::store_decimal(const my_decimal *d)
+{
+#ifndef DEBUG_OFF
+ DBUG_ASSERT(field_types == 0 ||
+ field_types[field_pos] == MYSQL_TYPE_NEWDECIMAL);
+ field_pos++;
+#endif
+ int buf_size= my_decimal_string_length(d);
+ char *buff= (char *)my_alloca(buf_size);
+ String str(buff, buf_size, &my_charset_bin);
+ if (my_decimal2string(E_DEC_FATAL_ERROR, d, 0, 0, 0, &str))
+ {
+ my_afree(buff);
+ return TRUE;
+ }
+ my_afree(buff);
+ return net_store_data(str.ptr(), str.length());
+}
+
+
bool Protocol_simple::store(float from, uint32 decimals, String *buffer)
{
#ifndef DEBUG_OFF
@@ -1027,6 +1049,24 @@ bool Protocol_prep::store_longlong(longlong from, bool unsigned_flag)
return 0;
}
+bool Protocol_prep::store_decimal(const my_decimal *d)
+{
+#ifndef DEBUG_OFF
+ DBUG_ASSERT(field_types == 0 ||
+ field_types[field_pos] == MYSQL_TYPE_NEWDECIMAL);
+ field_pos++;
+#endif
+ int buf_size= my_decimal_string_length(d);
+ char *buff= (char *)my_alloca(buf_size);
+ String str(buff, buf_size, &my_charset_bin);
+ if (my_decimal2string(E_DEC_FATAL_ERROR, d, 0, 0, 0, &str))
+ {
+ my_afree(buff);
+ return TRUE;
+ }
+ my_afree(buff);
+ return store(str.ptr(), str.length(), str.charset());
+}
bool Protocol_prep::store(float from, uint32 decimals, String *buffer)
{