summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sql/field.cc11
-rw-r--r--sql/field.h46
-rw-r--r--sql/sql_insert.cc4
-rw-r--r--sql/sql_join_cache.cc2
-rw-r--r--storage/archive/ha_archive.cc3
5 files changed, 30 insertions, 36 deletions
diff --git a/sql/field.cc b/sql/field.cc
index 2a807ae599b..be6259e6a11 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -7883,7 +7883,7 @@ void Field_blob::store_length(uchar *i_ptr, uint i_packlength, uint32 i_number)
}
-uint32 Field_blob::get_length(const uchar *pos, uint packlength_arg)
+uint32 Field_blob::get_length(const uchar *pos, uint packlength_arg) const
{
return (uint32)read_lowendian(pos, packlength_arg);
}
@@ -7898,8 +7898,7 @@ int Field_blob::copy_value(Field_blob *from)
DBUG_ASSERT(field_charset == from->charset());
int rc= 0;
uint32 length= from->get_length();
- uchar *data;
- from->get_ptr(&data);
+ uchar *data= from->get_ptr();
if (packlength < from->packlength)
{
set_if_smaller(length, Field_blob::max_data_length());
@@ -8146,7 +8145,7 @@ uint Field_blob::get_key_image(uchar *buff,uint length, imagetype type_arg)
bzero(buff, image_length);
return image_length;
}
- get_ptr(&blob);
+ blob= get_ptr();
gobj= Geometry::construct(&buffer, (char*) blob, blob_length);
if (!gobj || gobj->get_mbr(&mbr, &dummy))
bzero(buff, image_length);
@@ -8161,7 +8160,7 @@ uint Field_blob::get_key_image(uchar *buff,uint length, imagetype type_arg)
}
#endif /*HAVE_SPATIAL*/
- get_ptr(&blob);
+ blob= get_ptr();
uint local_char_length= length / field_charset->mbmaxlen;
local_char_length= my_charpos(field_charset, blob, blob + blob_length,
local_char_length);
@@ -8320,7 +8319,7 @@ uchar *Field_blob::pack(uchar *to, const uchar *from, uint max_length)
*/
if (length > 0)
{
- get_ptr((uchar**) &from);
+ from= get_ptr();
memcpy(to+packlength, from,length);
}
ptr=save; // Restore org row pointer
diff --git a/sql/field.h b/sql/field.h
index 52e0d2ea6d7..4292f3ffc8a 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -1265,7 +1265,7 @@ public:
virtual uint max_packed_col_length(uint max_length)
{ return max_length;}
- uint offset(uchar *record)
+ uint offset(uchar *record) const
{
return (uint) (ptr - record);
}
@@ -3266,30 +3266,29 @@ public:
{
store_length(ptr, packlength, number);
}
- inline uint32 get_length(uint row_offset= 0)
+ inline uint32 get_length(uint row_offset= 0) const
{ return get_length(ptr+row_offset, this->packlength); }
- uint32 get_length(const uchar *ptr, uint packlength);
- uint32 get_length(const uchar *ptr_arg)
+ uint32 get_length(const uchar *ptr, uint packlength) const;
+ uint32 get_length(const uchar *ptr_arg) const
{ return get_length(ptr_arg, this->packlength); }
- inline void get_ptr(uchar **str)
- {
- memcpy(str, ptr+packlength, sizeof(uchar*));
- }
- inline void get_ptr(uchar **str, uint row_offset)
- {
- memcpy(str, ptr+packlength+row_offset, sizeof(char*));
- }
+ inline uchar *get_ptr() const { return get_ptr(0); }
+ inline uchar *get_ptr(my_ptrdiff_t row_offset) const
+ {
+ uchar *s;
+ memcpy(&s, ptr + packlength + row_offset, sizeof(uchar*));
+ return s;
+ }
inline void set_ptr(uchar *length, uchar *data)
- {
- memcpy(ptr,length,packlength);
- memcpy(ptr+packlength, &data,sizeof(char*));
- }
+ {
+ memcpy(ptr,length,packlength);
+ memcpy(ptr+packlength, &data,sizeof(char*));
+ }
void set_ptr_offset(my_ptrdiff_t ptr_diff, uint32 length, uchar *data)
- {
- uchar *ptr_ofs= ADD_TO_PTR(ptr,ptr_diff,uchar*);
- store_length(ptr_ofs, packlength, length);
- memcpy(ptr_ofs+packlength, &data, sizeof(char*));
- }
+ {
+ uchar *ptr_ofs= ADD_TO_PTR(ptr,ptr_diff,uchar*);
+ store_length(ptr_ofs, packlength, length);
+ memcpy(ptr_ofs+packlength, &data, sizeof(char*));
+ }
inline void set_ptr(uint32 length, uchar *data)
{
set_ptr_offset(0, length, data);
@@ -3303,8 +3302,7 @@ public:
void sql_type(String &str) const;
inline bool copy()
{
- uchar *tmp;
- get_ptr(&tmp);
+ uchar *tmp= get_ptr();
if (value.copy((char*) tmp, get_length(), charset()))
{
Field_blob::reset();
@@ -3320,7 +3318,7 @@ public:
uint packed_col_length(const uchar *col_ptr, uint length);
uint max_packed_col_length(uint max_length);
void free() { value.free(); }
- inline void clear_temporary() { bzero((uchar*) &value,sizeof(value)); }
+ inline void clear_temporary() { bzero((uchar*) &value, sizeof(value)); }
uint size_of() const { return sizeof(*this); }
bool has_charset(void) const
{ return charset() == &my_charset_bin ? FALSE : TRUE; }
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 88787acea18..aa5b5ac756b 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -3126,9 +3126,7 @@ static void free_delayed_insert_blobs(register TABLE *table)
{
if ((*ptr)->flags & BLOB_FLAG)
{
- uchar *str;
- ((Field_blob *) (*ptr))->get_ptr(&str);
- my_free(str);
+ my_free(((Field_blob *) (*ptr))->get_ptr());
((Field_blob *) (*ptr))->reset();
}
}
diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc
index 71721336722..7c134aba551 100644
--- a/sql/sql_join_cache.cc
+++ b/sql/sql_join_cache.cc
@@ -1304,7 +1304,7 @@ uint JOIN_CACHE::write_record_data(uchar * link, bool *is_full)
uint blob_len= blob_field->get_length();
(*copy_ptr)->blob_length= blob_len;
len+= blob_len;
- blob_field->get_ptr(&(*copy_ptr)->str);
+ (*copy_ptr)->str= blob_field->get_ptr();
}
}
}
diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc
index c322c8eee54..9d6d100c1b8 100644
--- a/storage/archive/ha_archive.cc
+++ b/storage/archive/ha_archive.cc
@@ -383,8 +383,7 @@ unsigned int ha_archive::pack_row_v1(uchar *record)
uint32 length= ((Field_blob *) table->field[*blob])->get_length();
if (length)
{
- uchar *data_ptr;
- ((Field_blob *) table->field[*blob])->get_ptr(&data_ptr);
+ uchar *data_ptr= ((Field_blob *) table->field[*blob])->get_ptr();
memcpy(pos, data_ptr, length);
pos+= length;
}