#At file:///home/msvensson/mysql/6.2/ based on revid:martin.skold@stripped
3134 Magnus Blåudd 2010-10-20
ndb
- revert addition of field->used_length() and instead use new local function
field_used_length() to calculate how much store the field really needs.
modified:
sql/field.cc
sql/field.h
sql/ha_ndbcluster.cc
=== modified file 'sql/field.cc'
--- a/sql/field.cc 2010-10-06 10:06:47 +0000
+++ b/sql/field.cc 2010-10-20 12:13:52 +0000
@@ -7213,11 +7213,6 @@ uint32 Field_varstring::data_length()
return length_bytes == 1 ? (uint32) *ptr : uint2korr(ptr);
}
-uint32 Field_varstring::used_length()
-{
- return length_bytes == 1 ? 1 + (uint32) (uchar) *ptr : 2 + uint2korr(ptr);
-}
-
/*
Functions to create a packed row.
Here the number of length bytes are depending on the given max_length
=== modified file 'sql/field.h'
--- a/sql/field.h 2010-06-09 21:11:56 +0000
+++ b/sql/field.h 2010-10-20 12:13:52 +0000
@@ -194,12 +194,6 @@ public:
For varstrings, this does _not_ include the length bytes.
*/
virtual uint32 data_length() { return pack_length(); }
- /*
- used_length() returns the number of bytes actually used to store the data
- of the field. So for a varstring it includes both lenght byte(s) and
- string data, and anything after data_length() bytes are unused.
- */
- virtual uint32 used_length() { return pack_length(); }
virtual uint32 sort_length() const { return pack_length(); }
/**
@@ -1621,7 +1615,6 @@ public:
uint packed_col_length(const uchar *to, uint length);
uint max_packed_col_length(uint max_length);
uint32 data_length();
- uint32 used_length();
uint size_of() const { return sizeof(*this); }
enum_field_types real_type() const { return MYSQL_TYPE_VARCHAR; }
bool has_charset(void) const
=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc 2010-09-14 14:31:39 +0000
+++ b/sql/ha_ndbcluster.cc 2010-10-20 12:13:52 +0000
@@ -604,6 +604,25 @@ bool ha_ndbcluster::get_error_message(in
}
+/*
+ field_used_length() returns the number of bytes actually used to
+ store the data of the field. So for a varstring it includes both
+ length byte(s) and string data, and anything after data_length()
+ bytes are unused.
+*/
+static
+uint32 field_used_length(const Field* field)
+{
+ if (field->type() == MYSQL_TYPE_VARCHAR)
+ {
+ const Field_varstring* f = static_cast<const Field_varstring*>(field);
+ return f->length_bytes + const_cast<Field_varstring*>(f)->data_length();
+ // ^ no 'data_length() const'
+ }
+ return field->pack_length();
+}
+
+
/**
Check if MySQL field type forces var part in ndb storage
*/
@@ -3629,7 +3648,7 @@ void ha_ndbcluster::unpack_record(uchar
if (!field->is_null())
{
/* Only copy actually used bytes of varstrings. */
- uint32 actual_length= field->used_length();
+ uint32 actual_length= field_used_length(field);
uchar *src_ptr= field->ptr;
field->move_field_offset(dst_offset - src_offset);
field->set_notnull();
Attachment: [text/bzr-bundle] bzr/magnus.blaudd@sun.com-20101020121352-x5uq9dv85r4m5cfi.bundle
| Thread |
|---|
| • bzr commit into mysql-5.1-telco-6.2 branch (magnus.blaudd:3134) | Magnus Blåudd | 20 Oct |