#At file:///home/msvensson/mysql/7.0/ based on revid:magnus.blaudd@stripped
3879 Magnus Blåudd 2010-10-20
Merge 6.3 to 7.0
modified:
sql/field.cc
sql/field.h
sql/ha_ndbcluster.cc
=== modified file 'sql/field.cc'
--- a/sql/field.cc 2010-10-12 11:54:35 +0000
+++ b/sql/field.cc 2010-10-20 12:33:24 +0000
@@ -7254,11 +7254,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-16 12:04:53 +0000
+++ b/sql/field.h 2010-10-20 12:33:24 +0000
@@ -185,12 +185,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(); }
/**
@@ -1619,7 +1613,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-10-15 08:56:18 +0000
+++ b/sql/ha_ndbcluster.cc 2010-10-20 12:33:24 +0000
@@ -1062,6 +1062,24 @@ 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
@@ -1679,7 +1697,7 @@ int ha_ndbcluster::check_default_values(
value= value >> 1;
}
- Uint32 defaultLen = field->used_length();
+ Uint32 defaultLen = field_used_length(field);
defaultLen = ((defaultLen + 3) & ~(Uint32)0x7);
defaults_aligned= (0 == memcmp(ndb_default,
out,
@@ -4984,7 +5002,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();
@@ -5055,7 +5073,7 @@ static void get_default_value(void *def_
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->set_notnull();
memcpy(def_val, src_ptr, actual_length);
@@ -6912,7 +6930,7 @@ static int create_ndb_column(THD *thd,
/* For bit columns, default length is rounded up to
nearest word, ensuring all data sent
*/
- Uint32 defaultLen = field->used_length();
+ Uint32 defaultLen = field_used_length(field);
if(field->type() == MYSQL_TYPE_BIT)
defaultLen = ((defaultLen + 3) /4) * 4;
col.setDefaultValue(buf, defaultLen);
Attachment: [text/bzr-bundle] bzr/magnus.blaudd@sun.com-20101020123324-jwlbsai4iw0ufcrs.bundle
| Thread |
|---|
| • bzr commit into mysql-5.1-telco-7.0 branch (magnus.blaudd:3879) | Magnus Blåudd | 20 Oct |