summaryrefslogtreecommitdiff
path: root/sql/protocol.cc
diff options
context:
space:
mode:
authorunknown <hf@deer.(none)>2005-02-09 02:50:45 +0400
committerunknown <hf@deer.(none)>2005-02-09 02:50:45 +0400
commit91db48e35a57421c00f65d5ce82e84b843ceec22 (patch)
tree9631c72d46b0fd08479ad02de00e5846cd339cda /sql/protocol.cc
parent63bcbfc4339ae843dc367d08fff0760da4d484c3 (diff)
downloadmariadb-git-91db48e35a57421c00f65d5ce82e84b843ceec22.tar.gz
Precision Math implementation
BitKeeper/etc/ignore: Added client/decimal.c client/my_decimal.cc client/my_decimal.h to the ignore list
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)
{