summaryrefslogtreecommitdiff
path: root/sql/field.cc
diff options
context:
space:
mode:
authorunknown <monty@donna.mysql.com>2001-01-17 03:15:20 +0200
committerunknown <monty@donna.mysql.com>2001-01-17 03:15:20 +0200
commit5372aa60ce6c076297815958bbbec2180d919772 (patch)
tree256b185f833ce2fac42471efe65aa7bde9b9a8da /sql/field.cc
parentf0a33e62a1ed70f3b2393e6548b7a128d7dea3e1 (diff)
downloadmariadb-git-5372aa60ce6c076297815958bbbec2180d919772.tar.gz
Fixed for bugs that was found when getting full code coverage of BDB
Fixed bug with HEAP tables on windows Fixed bug with HAVING on empty tables Docs/manual.texi: Update of UDF functions mysql-test/mysql-test-run.sh: Added option --user mysql-test/r/bdb.result: Added more test to get better coverage mysql-test/t/bdb.test: Added more test to get better coverage sql/field.cc: Fixes for key packing in BDB sql/field.h: Fixes for key packing in BDB sql/ha_berkeley.cc: Fixed for bugs that was found when getting full code coverage sql/ha_heap.cc: Fixed problem with HEAP tables on windows sql/log.cc: Safety fix sql/sql_select.cc: Fixed bug with HAVING on empty tables sql/table.cc: Fixed problem with HEAP tables on windows
Diffstat (limited to 'sql/field.cc')
-rw-r--r--sql/field.cc65
1 files changed, 63 insertions, 2 deletions
diff --git a/sql/field.cc b/sql/field.cc
index 1c6aa32e167..225189a1098 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -3599,7 +3599,7 @@ void Field_varstring::sql_type(String &res) const
char *Field_varstring::pack(char *to, const char *from, uint max_length)
{
- uint length=uint2korr(to);
+ uint length=uint2korr(from);
if (length > max_length)
length=max_length;
*to++= (length & 255);
@@ -4037,6 +4037,43 @@ void Field_blob::sql_type(String &res) const
}
+char *Field_blob::pack(char *to, const char *from, uint max_length)
+{
+ char *save=ptr;
+ ptr=(char*) from;
+ ulong length=get_length(); // Length of from string
+ if (length > max_length)
+ {
+ ptr=to;
+ length=max_length;
+ store_length(length); // Store max length
+ ptr=(char*) from;
+ }
+ else
+ memcpy(to,from,packlength); // Copy length
+ if (length)
+ {
+ get_ptr((char**) &from);
+ memcpy(to+packlength, from,length);
+ }
+ ptr=save; // Restore org row pointer
+ return to+packlength+length;
+}
+
+
+const char *Field_blob::unpack(char *to, const char *from)
+{
+ memcpy(to,from,packlength);
+ from+=packlength;
+ ulong length=get_length();
+ if (length)
+ memcpy_fixed(to+packlength, &from, sizeof(from));
+ else
+ bzero(to+packlength,sizeof(from));
+ return from+length;
+}
+
+
/* Keys for blobs are like keys on varchars */
int Field_blob::pack_cmp(const char *a, const char *b, uint key_length)
@@ -4087,10 +4124,33 @@ int Field_blob::pack_cmp(const char *b, uint key_length)
return my_sortncmp(a,a_length, b,b_length);
}
+/* Create a packed key that will be used for storage from a MySQL row */
char *Field_blob::pack_key(char *to, const char *from, uint max_length)
{
- uint length=uint2korr(to);
+ char *save=ptr;
+ ptr=(char*) from;
+ ulong length=get_length(); // Length of from string
+ if (length > max_length)
+ length=max_length;
+ *to++= (uchar) length;
+ if (max_length > 255) // 2 byte length
+ *to++= (uchar) (length >> 8);
+ if (length)
+ {
+ get_ptr((char**) &from);
+ memcpy(to, from, length);
+ }
+ ptr=save; // Restore org row pointer
+ return to+length;
+}
+
+/* Create a packed key that will be used for storage from a MySQL key */
+
+char *Field_blob::pack_key_from_key_image(char *to, const char *from,
+ uint max_length)
+{
+ uint length=uint2korr(from);
if (length > max_length)
length=max_length;
*to++= (length & 255);
@@ -4101,6 +4161,7 @@ char *Field_blob::pack_key(char *to, const char *from, uint max_length)
return to+length;
}
+
/****************************************************************************
** enum type.
** This is a string which only can have a selection of different values.